Skip to content

Device

Defined in: src/device.ts:121

TData = unknown

new Device<TData>(init): Device<TData>

Defined in: src/device.ts:157

DeviceInit

Device<TData>

attrs: Record<string, DeviceAttribute> = {}

Defined in: src/device.ts:151


optional bus?: BusType<Device<unknown>, DeviceDriver<Device<unknown>>>

Defined in: src/device.ts:128


optional class?: Class

Defined in: src/device.ts:131


optional dev_t?: DevT

Defined in: src/device.ts:134

The device number. Devices with one get a dev attribute and a link in /sys/dev.


optional driver?: DeviceDriver<Device<unknown>>

Defined in: src/device.ts:129


optional driver_data?: TData

Defined in: src/device.ts:140

Whatever the bound driver wants to keep with the device, i.e. dev->driver_data


optional id?: number

Defined in: src/device.ts:126


optional kobj_parent?: KObject

Defined in: src/device.ts:146

Forces where the device goes in sysfs, like setting dev->kobj.parent before register. This is how a bus’ root device ends up somewhere like /sys/devices/system.


optional kobject?: DeviceKObject

Defined in: src/device.ts:149

/sys/devices/.../<name>. Only set while the device is registered.


name: string

Defined in: src/device.ts:122


optional of_node?: object & object

Defined in: src/device.ts:137

The device tree node this device was created from, i.e. dev->of_node

optional id?: string

What the device is called under /sys/devices/platform. One is made up when there isn’t one.

kind: "xterm"

optional options?: AttachXTermOptions

terminal: XTermLike


optional parent?: Device<unknown> | null

Defined in: src/device.ts:124


power: Partial<DevicePowerInfo> = {}

Defined in: src/device.ts:153


optional removable?: "unknown" | "removable" | "fixed"

Defined in: src/device.ts:155


optional type?: DeviceType

Defined in: src/device.ts:130

get path(): string | undefined

Defined in: src/device.ts:171

The device’s path relative to the root of sysfs, if it is registered

string | undefined


get registered(): boolean

Defined in: src/device.ts:166

Whether the device is currently in sysfs

boolean

attach(): boolean

Defined in: src/device.ts:212

Look for a driver on the device’s bus that can handle it.

boolean

whether the device ended up bound


bind_driver(drv): void

Defined in: src/device.ts:255

Bind a device to a driver without probing it.

DeviceDriver

void

EBUSY if the device is already bound


dev_node(): object

Defined in: src/device.ts:356

Internal

Work out the name and mode a device’s node under /dev should have.

object

a mode of 0 when nothing set one

mode: number

name: string


protected link_driver(): void

Defined in: src/device.ts:197

Link the device up with the driver it just bound to.

void


register(): void

Defined in: src/device.ts:284

Add a device to sysfs, link it up with its bus and class, then try to find it a driver.

void

EEXIST if the device is already registered, or something else has its name


release_driver(): void

Defined in: src/device.ts:265

Unbind a device from its driver. Does nothing if it isn’t bound.

void


protected sysfs_parent(): KObject

Defined in: src/device.ts:178

Work out where a device goes in sysfs.

KObject


try_bind(drv): boolean

Defined in: src/device.ts:234

Offer the device to a driver, binding the two if the driver’s probe accepts it. A driver without a probe takes every device the bus matched for it.

DeviceDriver

boolean

whether the device was bound


unregister(): void

Defined in: src/device.ts:327

Remove a device from sysfs, unbinding it from its driver first. Does nothing if the device isn’t registered.

void