c - What is the use scenario of switch_dev_register -
i trying understand fsa9485 driver(usb switch). there in dock initialization code came across:
switch_dev_register(&switch_dock)
switch_dock
construction of type switch_dev
, in accessory detection routine used like:
switch_set_state(&switch_dock, attached)
i inferring : there 2 types of dock 1 beingness auto dock , other beingness desk dock , switch_dev
class switching between them.
why require switch_dev
classes??. how class differentiates between 2 different dock?
the switch_dev_register
function registers device sysfs
, creates files in /sys/
. switch_set_state
updates value in 1 of created files on running kernel (the state
file). in kernel can see state reading file "/sys/devices/virtual/switch/dock/state." state
1 deskdock
, 2 cardock
, , 0 otherwise. simple way of passing hardware info userspace.
it necessary utilize switch_dev
class standardization in sysfs
. driver differentiates between 2 docks reading register values fsa9485 chip resides on i2c bus. see fsa9480_detect_dev
in fsa9480.c driver reads values analog digital converter (adc)
, device type register determine type of dock.
c linux-kernel linux-device-driver
No comments:
Post a Comment