From: Hans de Goede <hdegoede@redhat.com>
To: Giel van Schijndel <me@mortis.eu>
Cc: Jean Delvare <khali@linux-fr.org>,
Jonathan Cameron <jic23@cam.ac.uk>,
Laurens Leemans <laurens@signips.com>,
lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwmon: f71882fg: properly acquire I/O regions while probing
Date: Wed, 24 Mar 2010 09:14:14 +0100 [thread overview]
Message-ID: <4BA9C9D6.4020903@redhat.com> (raw)
In-Reply-To: <1269353535-23134-1-git-send-email-me@mortis.eu>
Hi,
I don't have any objections against the proposed changes, but there
are 3 unrelated changes in this patch, please break them up in separate
patches:
1) code cleanup: properly using, previously defined, functions rather
than duplicating their code.
2) properly acquire I/O regions while probing
3) Make the addresses to probe an array
And IMHO you might just as well drop number 3, it does not really make
the code any better readable, and the old way is how all superio hwmon
drivers do things.
Regards,
Hans
On 03/23/2010 03:12 PM, Giel van Schijndel wrote:
> Acquire the I/O region for the Super I/O chip while we're working on it.
>
> Further alter the way multiple Super I/O addresses are probed for chips
> such that errors in the probing process are passed on from the module
> initialisation function.
>
> Some code cleanup: properly using, previously defined, functions rather
> than duplicating their code.
> ---
> drivers/hwmon/f71882fg.c | 38 +++++++++++++++++++++++---------------
> 1 files changed, 23 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
> index 4230729..25e1cad 100644
> --- a/drivers/hwmon/f71882fg.c
> +++ b/drivers/hwmon/f71882fg.c
> @@ -856,10 +856,8 @@ static inline int superio_inb(int base, int reg)
> static int superio_inw(int base, int reg)
> {
> int val;
> - outb(reg++, base);
> - val = inb(base + 1)<< 8;
> - outb(reg, base);
> - val |= inb(base + 1);
> + val = superio_inb(base, reg)<< 8;
> + val |= superio_inb(base, reg + 1);
> return val;
> }
>
> @@ -905,10 +903,8 @@ static u16 f71882fg_read16(struct f71882fg_data *data, u8 reg)
> {
> u16 val;
>
> - outb(reg++, data->addr + ADDR_REG_OFFSET);
> - val = inb(data->addr + DATA_REG_OFFSET)<< 8;
> - outb(reg, data->addr + ADDR_REG_OFFSET);
> - val |= inb(data->addr + DATA_REG_OFFSET);
> + val = f71882fg_read8(data, reg)<< 8;
> + val |= f71882fg_read8(data, reg + 1);
>
> return val;
> }
> @@ -921,10 +917,8 @@ static void f71882fg_write8(struct f71882fg_data *data, u8 reg, u8 val)
>
> static void f71882fg_write16(struct f71882fg_data *data, u8 reg, u16 val)
> {
> - outb(reg++, data->addr + ADDR_REG_OFFSET);
> - outb(val>> 8, data->addr + DATA_REG_OFFSET);
> - outb(reg, data->addr + ADDR_REG_OFFSET);
> - outb(val& 255, data->addr + DATA_REG_OFFSET);
> + f71882fg_write8(data, reg, val>> 8);
> + f71882fg_write8(data, reg + 1, val& 0xff);
> }
>
> static u16 f71882fg_read_temp(struct f71882fg_data *data, int nr)
> @@ -2184,6 +2178,13 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address,
> int err = -ENODEV;
> u16 devid;
>
> + /* Don't step on other driver's I/O space by accident */
> + if (!request_region(sioaddr, 2, DRVNAME)) {
> + printk(KERN_ERR DRVNAME ": I/O address 0x%04x already in use\n",
> + (int)sioaddr);
> + return -EIO;
> + }
> +
> superio_enter(sioaddr);
>
> devid = superio_inw(sioaddr, SIO_REG_MANID);
> @@ -2238,6 +2239,7 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address,
> (int)superio_inb(sioaddr, SIO_REG_DEVREV));
> exit:
> superio_exit(sioaddr);
> + release_region(sioaddr, 2);
> return err;
> }
>
> @@ -2289,14 +2291,20 @@ exit_device_put:
>
> static int __init f71882fg_init(void)
> {
> + static const unsigned short addrs[] = { 0x2e, 0x4e };
> int err = -ENODEV;
> - unsigned short address;
> + unsigned short address = /* shut up compiler */ 0;
> struct f71882fg_sio_data sio_data;
> + int i;
>
> memset(&sio_data, 0, sizeof(sio_data));
>
> - if (f71882fg_find(0x2e,&address,&sio_data)&&
> - f71882fg_find(0x4e,&address,&sio_data))
> + for (i = 0; i< ARRAY_SIZE(addrs); i++) {
> + err = f71882fg_find(addrs[i],&address,&sio_data);
> + if (err == 0)
> + break;
> + }
> + if (i == ARRAY_SIZE(addrs))
> goto exit;
>
> err = platform_driver_register(&f71882fg_driver);
next prev parent reply other threads:[~2010-03-24 8:13 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-23 14:12 [PATCH] hwmon: f71882fg: properly acquire I/O regions while probing Giel van Schijndel
2010-03-23 14:17 ` Giel van Schijndel
2010-03-23 23:12 ` [PATCH 1/4] [RFC] hwmon: f71882fg: Add support for the Fintek F71808E Giel van Schijndel
2010-03-23 23:12 ` [PATCH 2/4] hwmon: f71882fg: prepare for addition of watchdog support Giel van Schijndel
2010-03-23 23:12 ` [PATCH 3/4] hwmon: f71882fg: add watchdog detection code Giel van Schijndel
2010-03-23 23:12 ` [PATCH 4/4] [RFC] hwmon: f71882fg: Add watchdog API for F71808E and F71889 Giel van Schijndel
2010-03-23 23:26 ` Giel van Schijndel
2010-03-24 8:37 ` Hans de Goede
2010-03-24 9:36 ` Giel van Schijndel
2010-03-24 10:33 ` Hans de Goede
2010-03-24 15:35 ` Giel van Schijndel
2010-03-24 15:51 ` Alan Cox
2010-03-24 16:20 ` Hans de Goede
2010-03-24 20:35 ` Giel van Schijndel
2010-04-25 21:20 ` [lm-sensors] " Jim Cromie
2010-03-25 8:54 ` Giel van Schijndel
2010-03-25 10:40 ` Giel van Schijndel
2010-03-25 12:50 ` Alan Cox
2010-03-25 13:06 ` Hans de Goede
2010-03-25 13:17 ` [PATCH 1/3] resource: shared I/O region support Giel van Schijndel
2010-03-25 13:17 ` [PATCH 2/3] hwmon: f71882fg: use a muxed resource lock for the Super I/O port Giel van Schijndel
2010-03-25 13:17 ` [PATCH 3/3] [RFC] watchdog: f71808e_wdt: new watchdog driver for Fintek F71808E Giel van Schijndel
2010-03-30 9:06 ` Giel van Schijndel
2010-05-20 7:52 ` Wim Van Sebroeck
2010-05-25 21:08 ` Giel van Schijndel
2010-05-26 7:38 ` Wim Van Sebroeck
2010-07-31 21:36 ` Giel van Schijndel
2010-03-25 21:10 ` [PATCH 2/3] hwmon: f71882fg: use a muxed resource lock for the Super I/O port Hans de Goede
2010-04-25 10:35 ` Giel van Schijndel
2010-07-31 21:21 ` Giel van Schijndel
2010-03-25 15:57 ` [PATCH 1/3] resource: shared I/O region support Alan Cox
2010-03-25 18:03 ` Giel van Schijndel
2010-03-25 18:16 ` Alan Cox
2010-03-29 8:18 ` Giel van Schijndel
2010-03-29 16:07 ` Jesse Barnes
2010-03-29 17:38 ` Giel van Schijndel
2010-03-29 17:44 ` Giel van Schijndel
2010-03-29 17:45 ` H. Peter Anvin
2010-03-29 18:06 ` Jesse Barnes
2010-03-29 18:17 ` H. Peter Anvin
2010-03-29 18:29 ` Alan Cox
2010-04-02 20:29 ` Jesse Barnes
2010-03-29 18:39 ` Alan Cox
2010-03-29 18:56 ` H. Peter Anvin
2010-03-29 17:59 ` Jesse Barnes
2010-03-29 17:59 ` Jesse Barnes
2010-03-24 8:26 ` [PATCH 2/4] hwmon: f71882fg: prepare for addition of watchdog support Hans de Goede
2010-03-24 8:36 ` Hans de Goede
2010-03-24 8:25 ` [PATCH 1/4] [RFC] hwmon: f71882fg: Add support for the Fintek F71808E Hans de Goede
2010-03-24 9:23 ` [PATCH 1/4] " Giel van Schijndel
2010-03-24 10:31 ` Hans de Goede
2010-07-31 23:31 ` Giel van Schijndel
2010-08-01 6:12 ` Hans de Goede
2010-08-01 13:22 ` Giel van Schijndel
2010-08-01 13:30 ` [PATCH] " Giel van Schijndel
2010-08-04 11:36 ` Hans de Goede
2010-08-04 15:44 ` Giel van Schijndel
2010-08-13 10:56 ` Hans de Goede
2010-08-10 19:11 ` Giel van Schijndel
2010-08-13 10:01 ` Hans de Goede
2010-08-18 18:24 ` Andrew Morton
2010-08-22 18:04 ` Hans de Goede
2010-08-22 18:28 ` Giel van Schijndel
2010-08-01 13:30 ` [PATCH 1/2] hwmon: f71882fg: use a muxed resource lock for the Super I/O port Giel van Schijndel
2010-08-01 13:30 ` [PATCH 2/2] watchdog: f71808e_wdt: new watchdog driver for Fintek F71808E and F71882FG Giel van Schijndel
2010-08-04 11:38 ` [PATCH 1/2] hwmon: f71882fg: use a muxed resource lock for the Super I/O port Hans de Goede
2010-10-02 22:59 ` Giel van Schijndel
2010-10-03 1:06 ` Guenter Roeck
2010-10-03 9:01 ` Jean Delvare
2010-10-03 12:09 ` [PATCH] " Giel van Schijndel
2010-10-03 13:31 ` Guenter Roeck
2010-03-23 23:01 ` [PATCH] hwmon: f71882fg: properly acquire I/O regions while probing Giel van Schijndel
2010-03-24 8:14 ` Hans de Goede [this message]
2010-03-24 8:46 ` Giel van Schijndel
2010-03-24 9:09 ` [PATCH] hwmon: f71882fg: code cleanup Giel van Schijndel
2010-03-24 12:54 ` Jean Delvare
2010-03-24 9:09 ` [PATCH] hwmon: f71882fg: acquire I/O regions while we're working with them Giel van Schijndel
2010-03-24 9:28 ` [PATCH] hwmon: f71882fg: properly acquire I/O regions while probing Jean Delvare
2010-03-24 9:29 ` Jean Delvare
2010-03-24 9:34 ` Giel van Schijndel
2010-03-24 12:54 ` Jean Delvare
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BA9C9D6.4020903@redhat.com \
--to=hdegoede@redhat.com \
--cc=jic23@cam.ac.uk \
--cc=khali@linux-fr.org \
--cc=laurens@signips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=me@mortis.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).