Skip to contentSkip to conversation

iio: adc: max9611: fix module auto-loading

PATCH Superseded Dmitry Mastykin 3 participants 3 messages Dec 29, 2017 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: max9611: fix module auto-loading

Module auto-load doesn't work because i2c table is not exported.

---
 drivers/iio/adc/max9611.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/iio/adc/max9611.c +8 -1
index b1dd17c..7924b5c 100644
@@ -516,13 +516,20 @@ static int max9611_init(struct max9611_dev *max9611)
 	return 0;
 }
 
+static const struct i2c_device_id max9611_id[] = {
+	{ "max9611", 0 },
+	{ "max9612", 0 },
+	{ },
+ };
+MODULE_DEVICE_TABLE(i2c, max9611_id);
+
 static const struct of_device_id max9611_of_table[] = {
 	{.compatible = "maxim,max9611", .data = "max9611"},
 	{.compatible = "maxim,max9612", .data = "max9612"},
 	{ },
 };
-
 MODULE_DEVICE_TABLE(of, max9611_of_table);
+
 static int max9611_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
Signature · 1 line
2.7.4
#1 lore raw

Hi Dmitry,

Quoted 12 lines · Dmitry Mastykin

Module auto-load doesn't work because i2c table is not exported.

---
 drivers/iio/adc/max9611.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/iio/adc/max9611.c +0 -0
index b1dd17c..7924b5c 100644

drivers/iio/adc/max9611.c static int max9611_init(struct max9611_dev *max9611) · line 525

Quoted 10 lines
drivers/iio/adc/max9611.c +7 -0
@@ -516,13 +516,20 @@ static int max9611_init(struct max9611_dev *max9611)
 	return 0;
 }
 
+static const struct i2c_device_id max9611_id[] = {
+	{ "max9611", 0 },
+	{ "max9612", 0 },
+	{ },
+ };
+MODULE_DEVICE_TABLE(i2c, max9611_id);
+

Wouldn't you need to also set the "id_table" field of "struct i2c_driver" to point this?

Thanks
j

Quoted 14 lines
drivers/iio/adc/max9611.c +1 -2
 static const struct of_device_id max9611_of_table[] = {
 	{.compatible = "maxim,max9611", .data = "max9611"},
 	{.compatible = "maxim,max9612", .data = "max9612"},
 	{ },
 };
-
 MODULE_DEVICE_TABLE(of, max9611_of_table);
+
 static int max9611_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
--

2.7.4

#2 lore raw
In reply to Dmitry Mastykin
Quoted 2 lines · Dmitry Mastykin

Module auto-load doesn't work because i2c table is not exported.

The simplest fix is to move to ->probe_new() since the driver is not used out of DT/ACPI enumeration.

Quoted 34 lines
---
 drivers/iio/adc/max9611.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/iio/adc/max9611.c +8 -2
index b1dd17c..7924b5c 100644
@@ -516,13 +516,20 @@ static int max9611_init(struct max9611_dev *max9611)
        return 0;
 }
 
+static const struct i2c_device_id max9611_id[] = {
+       { "max9611", 0 },
+       { "max9612", 0 },
+       { },
+ };
+MODULE_DEVICE_TABLE(i2c, max9611_id);
+
 static const struct of_device_id max9611_of_table[] = {
        {.compatible = "maxim,max9611", .data = "max9611"},
        {.compatible = "maxim,max9612", .data = "max9612"},
        { },
 };
-
 MODULE_DEVICE_TABLE(of, max9611_of_table);
+
 static int max9611_probe(struct i2c_client *client,
                         const struct i2c_device_id *id)
 {
--

2.7.4

Signature · 2 lines
With Best Regards,
Andy Shevchenko