Skip to contentSkip to conversation

of: Request module by alias in of_i2c.c

PATCH Applied David Daney 2 participants 2 messages Nov 16, 2010 – Nov 17, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of: Request module by alias in of_i2c.c

If we are registering an i2c device that has a device tree node like this real-world example:

      rtc@68 {
        compatible = "dallas,ds1337";
        reg = <0x68>;
      };

of_i2c_register_devices() will try to load a module called ds1337.ko. There is no such module, so it will fail. If we look in modules.alias we will find entries like these:

.
.
.
alias i2c:ds1339 rtc_ds1307
alias i2c:ds1338 rtc_ds1307
alias i2c:ds1337 rtc_ds1307
alias i2c:ds1307 rtc_ds1307
alias i2c:ds1374 rtc_ds1374
.
.
.

The module we want is really called rtc_ds1307.ko. If we request a module called "i2c:ds1337", the userspace module loader will do the right thing (unless it is busybox) and load rtc_ds1307.ko. So we add the I2C_MODULE_PREFIX to the request_module() string.

---
 drivers/of/of_i2c.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/of/of_i2c.c +1 -1
index c85d3c7..f37fbeb 100644
@@ -61,7 +61,7 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
 		info.of_node = of_node_get(node);
 		info.archdata = &dev_ad;
 
-		request_module("%s", info.type);
+		request_module("%s%s", I2C_MODULE_PREFIX, info.type);
 
 		result = i2c_new_device(adap, &info);
 		if (result == NULL) {
Signature · 1 line
1.7.2.3
Applied
#1 lore raw
Quoted 24 lines · David Daney

If we are registering an i2c device that has a device tree node like this real-world example:

      rtc@68 {
        compatible = "dallas,ds1337";
        reg = <0x68>;
      };

of_i2c_register_devices() will try to load a module called ds1337.ko. There is no such module, so it will fail. If we look in modules.alias we will find entries like these:

.
.
.
alias i2c:ds1339 rtc_ds1307
alias i2c:ds1338 rtc_ds1307
alias i2c:ds1337 rtc_ds1307
alias i2c:ds1307 rtc_ds1307
alias i2c:ds1374 rtc_ds1374
.
.
.

Quoted 6 lines

The module we want is really called rtc_ds1307.ko. If we request a module called "i2c:ds1337", the userspace module loader will do the right thing (unless it is busybox) and load rtc_ds1307.ko. So we add the I2C_MODULE_PREFIX to the request_module() string.

Applied, thanks.

g.

Quoted 20 lines
---
 drivers/of/of_i2c.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/of/of_i2c.c +1 -1
index c85d3c7..f37fbeb 100644
@@ -61,7 +61,7 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
 		info.of_node = of_node_get(node);
 		info.archdata = &dev_ad;
 
-		request_module("%s", info.type);
+		request_module("%s%s", I2C_MODULE_PREFIX, info.type);
 
 		result = i2c_new_device(adap, &info);
 		if (result == NULL) {
Signature · 1 line
1.7.2.3