switching from at91 to gpio driver
Subsystems (2)
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
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->classis not set toI2C_CLASS_HWMONwhereas in case of i2c-at91 it is. Chip driver (e.g. lm92) checks for it inxxx_attach_adapter()function and does not calli2c_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
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 toI2C_CLASS_HWMONfor all buses by default, but that's not very flexible. It would IMHO make more sense to add a field to structi2c_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
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 toI2C_CLASS_HWMONfor all buses by default, but that's not very flexible. It would IMHO make more sense to add a field to structi2c_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(orI2C_CLASS_ALL) ini2c_gpio_probewould be enough.Well, frankly, I cannot understand the purpose of
I2C_CLASS_XXXat all. For example, what is an requirement forI2C_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
Quoted 7 lines · Jean Delvare
I wouldn't recommend setting
I2C_CLASS_ALLin i2c-gpio, as it pretty much voids the idea of i2c classes. But on second thought,I2C_CLASS_HWMONshould 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_HWMONto 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
@@ -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
Quoted 22 lines · Atsushi Nemoto
Quoted 7 lines · Jean Delvare
I wouldn't recommend setting
I2C_CLASS_ALLin i2c-gpio, as it pretty much voids the idea of i2c classes. But on second thought,I2C_CLASS_HWMONshould 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_HWMONto i2c-gpio, I'll take that.OK, done. Please review ;-)
------------------------------------------------------
Subject: i2c: initialize adapter class for i2c-gpio driver.Signed-off-by Atsushi Nemoto <[email protected]>---
drivers/i2c/busses/i2c-gpio.c +0
-0
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
Quoted 1 line · Jean Delvare
Applied, thanks. Does this need to go in 2.6.24?
I don't think so. This is not a regression. But I believe this fix is safe for even stable releases.
---
Atsushi Nemoto
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors