* [lm-sensors] [PATCH] hwmon: (w83791d) Clean up detect function
@ 2009-10-06 18:11 Jean Delvare
2009-10-09 8:37 ` Marc Hulsman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jean Delvare @ 2009-10-06 18:11 UTC (permalink / raw)
To: lm-sensors
As kind is now hard-coded to -1, there is room for code clean-ups.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Marc Hulsman <m.hulsman@tudelft.nl>
---
drivers/hwmon/w83791d.c | 60 ++++++++++++++---------------------------------
1 file changed, 18 insertions(+), 42 deletions(-)
--- linux-2.6.32-rc3.orig/drivers/hwmon/w83791d.c 2009-10-06 10:33:15.000000000 +0200
+++ linux-2.6.32-rc3/drivers/hwmon/w83791d.c 2009-10-06 12:13:28.000000000 +0200
@@ -1270,56 +1270,32 @@ static int w83791d_detect(struct i2c_cli
return -ENODEV;
}
- /* The w83791d may be stuck in some other bank than bank 0. This may
- make reading other information impossible. Specify a force=...
- parameter, and the Winbond will be reset to the right bank. */
- if (kind < 0) {
- if (w83791d_read(client, W83791D_REG_CONFIG) & 0x80) {
- return -ENODEV;
- }
- val1 = w83791d_read(client, W83791D_REG_BANK);
- val2 = w83791d_read(client, W83791D_REG_CHIPMAN);
- /* Check for Winbond ID if in bank 0 */
- if (!(val1 & 0x07)) {
- /* yes it is Bank0 */
- if (((!(val1 & 0x80)) && (val2 != 0xa3)) ||
- ((val1 & 0x80) && (val2 != 0x5c))) {
- return -ENODEV;
- }
- }
- /* If Winbond chip, address of chip and W83791D_REG_I2C_ADDR
- should match */
- if (w83791d_read(client, W83791D_REG_I2C_ADDR) != address) {
+ if (w83791d_read(client, W83791D_REG_CONFIG) & 0x80)
+ return -ENODEV;
+
+ val1 = w83791d_read(client, W83791D_REG_BANK);
+ val2 = w83791d_read(client, W83791D_REG_CHIPMAN);
+ /* Check for Winbond ID if in bank 0 */
+ if (!(val1 & 0x07)) {
+ if ((!(val1 & 0x80) && val2 != 0xa3) ||
+ ( (val1 & 0x80) && val2 != 0x5c)) {
return -ENODEV;
}
}
+ /* If Winbond chip, address of chip and W83791D_REG_I2C_ADDR
+ should match */
+ if (w83791d_read(client, W83791D_REG_I2C_ADDR) != address)
+ return -ENODEV;
- /* We either have a force parameter or we have reason to
- believe it is a Winbond chip. Either way, we want bank 0 and
- Vendor ID high byte */
+ /* We want bank 0 and Vendor ID high byte */
val1 = w83791d_read(client, W83791D_REG_BANK) & 0x78;
w83791d_write(client, W83791D_REG_BANK, val1 | 0x80);
/* Verify it is a Winbond w83791d */
- if (kind <= 0) {
- /* get vendor ID */
- val2 = w83791d_read(client, W83791D_REG_CHIPMAN);
- if (val2 != 0x5c) { /* the vendor is NOT Winbond */
- return -ENODEV;
- }
- val1 = w83791d_read(client, W83791D_REG_WCHIPID);
- if (val1 = 0x71) {
- kind = w83791d;
- } else {
- if (kind = 0)
- dev_warn(&adapter->dev,
- "w83791d: Ignoring 'force' parameter "
- "for unknown chip at adapter %d, "
- "address 0x%02x\n",
- i2c_adapter_id(adapter), address);
- return -ENODEV;
- }
- }
+ val1 = w83791d_read(client, W83791D_REG_WCHIPID);
+ val2 = w83791d_read(client, W83791D_REG_CHIPMAN);
+ if (val1 != 0x71 || val2 != 0x5c)
+ return -ENODEV;
strlcpy(info->type, "w83791d", I2C_NAME_SIZE);
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (w83791d) Clean up detect function
2009-10-06 18:11 [lm-sensors] [PATCH] hwmon: (w83791d) Clean up detect function Jean Delvare
@ 2009-10-09 8:37 ` Marc Hulsman
2009-10-09 8:49 ` Jean Delvare
2009-10-09 20:12 ` Marc Hulsman
2 siblings, 0 replies; 4+ messages in thread
From: Marc Hulsman @ 2009-10-09 8:37 UTC (permalink / raw)
To: lm-sensors
Hi Jean,
On Tuesday 06 October 2009 20:11:01 Jean Delvare wrote:
> As kind is now hard-coded to -1, there is room for code clean-ups.
>
> Signed-off-by: Jean Delvare <khali@linux-fr.org>
> Cc: Marc Hulsman <m.hulsman@tudelft.nl>
> ---
Looks good,
Acked-by: Marc Hulsman <m.hulsman@tudelft.nl>
Thanks,
Marc
> drivers/hwmon/w83791d.c | 60
> ++++++++++++++--------------------------------- 1 file changed, 18
> insertions(+), 42 deletions(-)
>
> --- linux-2.6.32-rc3.orig/drivers/hwmon/w83791d.c 2009-10-06
> 10:33:15.000000000 +0200 +++
> linux-2.6.32-rc3/drivers/hwmon/w83791d.c 2009-10-06 12:13:28.000000000
> +0200 @@ -1270,56 +1270,32 @@ static int w83791d_detect(struct i2c_cli
> return -ENODEV;
> }
>
> - /* The w83791d may be stuck in some other bank than bank 0. This may
> - make reading other information impossible. Specify a force=...
> - parameter, and the Winbond will be reset to the right bank. */
> - if (kind < 0) {
> - if (w83791d_read(client, W83791D_REG_CONFIG) & 0x80) {
> - return -ENODEV;
> - }
> - val1 = w83791d_read(client, W83791D_REG_BANK);
> - val2 = w83791d_read(client, W83791D_REG_CHIPMAN);
> - /* Check for Winbond ID if in bank 0 */
> - if (!(val1 & 0x07)) {
> - /* yes it is Bank0 */
> - if (((!(val1 & 0x80)) && (val2 != 0xa3)) ||
> - ((val1 & 0x80) && (val2 != 0x5c))) {
> - return -ENODEV;
> - }
> - }
> - /* If Winbond chip, address of chip and W83791D_REG_I2C_ADDR
> - should match */
> - if (w83791d_read(client, W83791D_REG_I2C_ADDR) != address) {
> + if (w83791d_read(client, W83791D_REG_CONFIG) & 0x80)
> + return -ENODEV;
> +
> + val1 = w83791d_read(client, W83791D_REG_BANK);
> + val2 = w83791d_read(client, W83791D_REG_CHIPMAN);
> + /* Check for Winbond ID if in bank 0 */
> + if (!(val1 & 0x07)) {
> + if ((!(val1 & 0x80) && val2 != 0xa3) ||
> + ( (val1 & 0x80) && val2 != 0x5c)) {
> return -ENODEV;
> }
> }
> + /* If Winbond chip, address of chip and W83791D_REG_I2C_ADDR
> + should match */
> + if (w83791d_read(client, W83791D_REG_I2C_ADDR) != address)
> + return -ENODEV;
>
> - /* We either have a force parameter or we have reason to
> - believe it is a Winbond chip. Either way, we want bank 0 and
> - Vendor ID high byte */
> + /* We want bank 0 and Vendor ID high byte */
> val1 = w83791d_read(client, W83791D_REG_BANK) & 0x78;
> w83791d_write(client, W83791D_REG_BANK, val1 | 0x80);
>
> /* Verify it is a Winbond w83791d */
> - if (kind <= 0) {
> - /* get vendor ID */
> - val2 = w83791d_read(client, W83791D_REG_CHIPMAN);
> - if (val2 != 0x5c) { /* the vendor is NOT Winbond */
> - return -ENODEV;
> - }
> - val1 = w83791d_read(client, W83791D_REG_WCHIPID);
> - if (val1 = 0x71) {
> - kind = w83791d;
> - } else {
> - if (kind = 0)
> - dev_warn(&adapter->dev,
> - "w83791d: Ignoring 'force' parameter "
> - "for unknown chip at adapter %d, "
> - "address 0x%02x\n",
> - i2c_adapter_id(adapter), address);
> - return -ENODEV;
> - }
> - }
> + val1 = w83791d_read(client, W83791D_REG_WCHIPID);
> + val2 = w83791d_read(client, W83791D_REG_CHIPMAN);
> + if (val1 != 0x71 || val2 != 0x5c)
> + return -ENODEV;
>
> strlcpy(info->type, "w83791d", I2C_NAME_SIZE);
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (w83791d) Clean up detect function
2009-10-06 18:11 [lm-sensors] [PATCH] hwmon: (w83791d) Clean up detect function Jean Delvare
2009-10-09 8:37 ` Marc Hulsman
@ 2009-10-09 8:49 ` Jean Delvare
2009-10-09 20:12 ` Marc Hulsman
2 siblings, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2009-10-09 8:49 UTC (permalink / raw)
To: lm-sensors
Hi Marc,
On Fri, 9 Oct 2009 10:37:35 +0200, Marc Hulsman wrote:
> Hi Jean,
>
> On Tuesday 06 October 2009 20:11:01 Jean Delvare wrote:
> > As kind is now hard-coded to -1, there is room for code clean-ups.
> >
> > Signed-off-by: Jean Delvare <khali@linux-fr.org>
> > Cc: Marc Hulsman <m.hulsman@tudelft.nl>
> > ---
> Looks good,
>
> Acked-by: Marc Hulsman <m.hulsman@tudelft.nl>
Thanks. Can you please also test it? Just to make sure I didn't mess it
up.
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (w83791d) Clean up detect function
2009-10-06 18:11 [lm-sensors] [PATCH] hwmon: (w83791d) Clean up detect function Jean Delvare
2009-10-09 8:37 ` Marc Hulsman
2009-10-09 8:49 ` Jean Delvare
@ 2009-10-09 20:12 ` Marc Hulsman
2 siblings, 0 replies; 4+ messages in thread
From: Marc Hulsman @ 2009-10-09 20:12 UTC (permalink / raw)
To: lm-sensors
Hi Jean,
On Friday 09 October 2009 10:49:03 Jean Delvare wrote:
> > > As kind is now hard-coded to -1, there is room for code clean-ups.
> > >
> > > Signed-off-by: Jean Delvare <khali@linux-fr.org>
> > > Cc: Marc Hulsman <m.hulsman@tudelft.nl>
> > > ---
> >
> > Looks good,
> >
> > Acked-by: Marc Hulsman <m.hulsman@tudelft.nl>
>
> Thanks. Can you please also test it? Just to make sure I didn't mess it
> up.
Unfortunately, I do not have access to the w83791d right now (maybe in two
weeks). However, I did check the patch quite thoroughly, so I'm reasonably
sure its ok.
Best regards,
Marc
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-09 20:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-06 18:11 [lm-sensors] [PATCH] hwmon: (w83791d) Clean up detect function Jean Delvare
2009-10-09 8:37 ` Marc Hulsman
2009-10-09 8:49 ` Jean Delvare
2009-10-09 20:12 ` Marc Hulsman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.