Skip to contentSkip to conversation

switching from at91 to gpio driver

lm-sensors Sergei Sharonov 3 participants 7 messages Nov 15, 2007 – Nov 23, 2007

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

Hi,

I switched from at91 i2c driver (hardware controller) to i2c-gpio driver in kernel 2.6.23.1. All chip drivers failed to hook into i2c-gpio. The problem was traced to the fact that in case of i2c-gpio adapter->class is not set to I2C_CLASS_HWMON whereas in case of i2c-at91 it is. Chip driver (e.g. lm92) checks for it in xxx_attach_adapter() function and does not call i2c_probe() if it is not set.
Skipping the check allows lm92 driver to function.

Now, is it a bug or there is a place where I can tell i2c-gpio driver to set class?

Thanks,

Sergei Sharonov

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw

Hi Sergei,

Quoted 10 lines · Sergei Sharonov

I switched from at91 i2c driver (hardware controller) to i2c-gpio driver in kernel 2.6.23.1. All chip drivers failed to hook into i2c-gpio. The problem was traced to the fact that in case of i2c-gpio adapter->class is not set to I2C_CLASS_HWMON whereas in case of i2c-at91 it is. Chip driver (e.g. lm92) checks for it in xxx_attach_adapter() function and does not call i2c_probe() if it is not set.
Skipping the check allows lm92 driver to function.

Now, is it a bug or there is a place where I can tell i2c-gpio driver to set class?

Thanks for reporting, good catch. I'm adding the i2c list in Cc, as well as the author of the i2c-gpio driver and one of its users.

Indeed there needs to be a way to set the class of i2c-gpio buses to I2C_CLASS_HWMON. We could change the driver to set the class to I2C_CLASS_HWMON for all buses by default, but that's not very flexible. It would IMHO make more sense to add a field to struct i2c_gpio_platform_data, and let each user of i2c-gpio set the class to whatever they want.

Maybe you, Haavard or Atsushi can submit a patch doing this? I'd be happy to review and merge it quickly.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw
In reply to Sergei Sharonov
Quoted 9 lines · Jean Delvare

Indeed there needs to be a way to set the class of i2c-gpio buses to I2C_CLASS_HWMON. We could change the driver to set the class to I2C_CLASS_HWMON for all buses by default, but that's not very flexible. It would IMHO make more sense to add a field to struct i2c_gpio_platform_data, and let each user of i2c-gpio set the class to whatever they want.

Maybe you, Haavard or Atsushi can submit a patch doing this? I'd be happy to review and merge it quickly.

I think just setting I2C_CLASS_HWMON (or I2C_CLASS_ALL) in i2c_gpio_probe would be enough.

Well, frankly, I cannot understand the purpose of I2C_CLASS_XXX at all. For example, what is an requirement for I2C_CLASS_HWMON?

---
Atsushi Nemoto

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw
In reply to Sergei Sharonov

Konbanwa Atsushi-san,

Quoted 8 lines · Atsushi Nemoto
Quoted 7 lines · Jean Delvare

Indeed there needs to be a way to set the class of i2c-gpio buses to I2C_CLASS_HWMON. We could change the driver to set the class to I2C_CLASS_HWMON for all buses by default, but that's not very flexible. It would IMHO make more sense to add a field to struct i2c_gpio_platform_data, and let each user of i2c-gpio set the class to whatever they want.

Quoted 8 lines
Quoted 2 lines

Maybe you, Haavard or Atsushi can submit a patch doing this? I'd be happy to review and merge it quickly.

I think just setting I2C_CLASS_HWMON (or I2C_CLASS_ALL) in i2c_gpio_probe would be enough.

Well, frankly, I cannot understand the purpose of I2C_CLASS_XXX at all. For example, what is an requirement for I2C_CLASS_HWMON?

There are no requirements. Classes are only informative, restricting which i2c buses will be scanned by some categories of i2c chip drivers. For example, hwmon drivers only scan i2c buses with I2C_CLASS_HWMON set.

I wouldn't recommend setting I2C_CLASS_ALL in i2c-gpio, as it pretty much voids the idea of i2c classes. But on second thought, I2C_CLASS_HWMON should work fine. That's what almost all general-purpose i2c bus drivers do after all.

So, if someone sends me a patch adding class I2C_CLASS_HWMON to i2c-gpio, I'll take that.

Arigato,

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#4 lore raw
In reply to Sergei Sharonov
Quoted 7 lines · Jean Delvare

I wouldn't recommend setting I2C_CLASS_ALL in i2c-gpio, as it pretty much voids the idea of i2c classes. But on second thought, I2C_CLASS_HWMON should work fine. That's what almost all general-purpose i2c bus drivers do after all.

So, if someone sends me a patch adding class I2C_CLASS_HWMON to i2c-gpio, I'll take that.

OK, done. Please review ;-)

------------------------------------------------------
Subject: i2c: initialize adapter class for i2c-gpio driver.

---

drivers/i2c/busses/i2c-gpio.c +1 -0
index 44e1cd2..3ca19fc 100644
@@ -140,6 +140,7 @@ static int __init i2c_gpio_probe(struct platform_device *pdev)
 	adap->owner = THIS_MODULE;
 	snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id);
 	adap->algo_data = bit_data;
+	adap->class = I2C_CLASS_HWMON;
 	adap->dev.parent = &pdev->dev;
 
 	/*

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#5 lore raw
In reply to Sergei Sharonov
Quoted 22 lines · Atsushi Nemoto
Quoted 7 lines · Jean Delvare

I wouldn't recommend setting I2C_CLASS_ALL in i2c-gpio, as it pretty much voids the idea of i2c classes. But on second thought, I2C_CLASS_HWMON should work fine. That's what almost all general-purpose i2c bus drivers do after all.

So, if someone sends me a patch adding class I2C_CLASS_HWMON to i2c-gpio, I'll take that.

OK, done. Please review ;-)

------------------------------------------------------
Subject: i2c: initialize adapter class for i2c-gpio driver.

---

drivers/i2c/busses/i2c-gpio.c +0 -0
index 44e1cd2..3ca19fc 100644

drivers/i2c/busses/i2c-gpio.c static int __init i2c_gpio_probe(struct platform_device *pdev) · line 146

Quoted 7 lines
drivers/i2c/busses/i2c-gpio.c +1 -0
@@ -140,6 +140,7 @@ static int __init i2c_gpio_probe(struct platform_device *pdev)
 	adap->owner = THIS_MODULE;
 	snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id);
 	adap->algo_data = bit_data;
+	adap->class = I2C_CLASS_HWMON;
 	adap->dev.parent = &pdev->dev;
 
 	/*

Applied, thanks. Does this need to go in 2.6.24?

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors