Skip to content

Commit af50371

Browse files
martinezjavierWolfram Sang
authored and
Wolfram Sang
committed
i2c: core: report OF style module alias for devices registered via OF
The buses should honor the firmware interface used to register the device, but the I2C core reports a MODALIAS of the form i2c:<device> even for I2C devices registered via OF. This means that user-space will never get an OF stype uevent MODALIAS even when the drivers modules contain aliases exported from both the I2C and OF device ID tables. For example, an Atmel maXTouch Touchscreen registered by a DT node with compatible "atmel,maxtouch" has the following module alias: $ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias i2c:maxtouch So udev won't be able to auto-load a module for an OF-only device driver. Many OF-only drivers duplicate the OF device ID table entries in an I2C ID table only has a workaround for how the I2C core reports the module alias. This patch changes the I2C core to report an OF related MODALIAS uevent if the device was registered via OF. So for the previous example, after this patch, the reported MODALIAS for the Atmel maXTouch will be the following: $ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias of:NtrackpadT<NULL>Catmel,maxtouch NOTE: This patch may break out-of-tree drivers that were relying on this behavior, and only had an I2C device ID table even when the device was registered via OF. There are no remaining drivers in mainline that do this, but out-of-tree drivers have to be fixed and define a proper OF device ID table to have module auto-loading working. Signed-off-by: Javier Martinez Canillas <[email protected]> Tested-by: Dmitry Mastykin <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent e9d09d9 commit af50371

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/i2c/i2c-core-base.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env)
124124
struct i2c_client *client = to_i2c_client(dev);
125125
int rc;
126126

127+
rc = of_device_uevent_modalias(dev, env);
128+
if (rc != -ENODEV)
129+
return rc;
130+
127131
rc = acpi_device_uevent_modalias(dev, env);
128132
if (rc != -ENODEV)
129133
return rc;
@@ -439,6 +443,10 @@ show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
439443
struct i2c_client *client = to_i2c_client(dev);
440444
int len;
441445

446+
len = of_device_modalias(dev, buf, PAGE_SIZE);
447+
if (len != -ENODEV)
448+
return len;
449+
442450
len = acpi_device_modalias(dev, buf, PAGE_SIZE -1);
443451
if (len != -ENODEV)
444452
return len;

0 commit comments

Comments
 (0)