From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754758Ab0CYVKT (ORCPT ); Thu, 25 Mar 2010 17:10:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26892 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752053Ab0CYVKR (ORCPT ); Thu, 25 Mar 2010 17:10:17 -0400 Message-ID: <4BABD149.2050001@redhat.com> Date: Thu, 25 Mar 2010 22:10:33 +0100 From: Hans de Goede User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.7) Gecko/20100120 Fedora/3.0.1-1.fc13 Thunderbird/3.0.1 MIME-Version: 1.0 To: Giel van Schijndel CC: Jean Delvare , Jonathan Cameron , Laurens Leemans , lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] hwmon: f71882fg: use a muxed resource lock for the Super I/O port References: <20100325125005.6d58cfaf@lxorguk.ukuu.org.uk> <1269523063-30346-1-git-send-email-me@mortis.eu> <1269523063-30346-2-git-send-email-me@mortis.eu> In-Reply-To: <1269523063-30346-2-git-send-email-me@mortis.eu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 03/25/2010 02:17 PM, Giel van Schijndel wrote: > Sleep while acquiring a resource lock on the Super I/O port. This should > prevent collisions from causing the hardware probe to fail with -EBUSY. > Looks good to me (assuming the previous patch in the series gets applied). Acked-by: Hans de Goede Regards, hans > Signed-off-by: Giel van Schijndel > --- > drivers/hwmon/f71882fg.c | 28 +++++++++++++++------------- > 1 files changed, 15 insertions(+), 13 deletions(-) > > diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c > index 7857ed3..e09416d 100644 > --- a/drivers/hwmon/f71882fg.c > +++ b/drivers/hwmon/f71882fg.c > @@ -113,7 +113,7 @@ static struct platform_device *f71882fg_pdev; > /* Super-I/O Function prototypes */ > static inline int superio_inb(int base, int reg); > static inline int superio_inw(int base, int reg); > -static inline void superio_enter(int base); > +static inline int superio_enter(int base); > static inline void superio_select(int base, int ld); > static inline void superio_exit(int base); > > @@ -883,11 +883,20 @@ static int superio_inw(int base, int reg) > return val; > } > > -static inline void superio_enter(int base) > +static inline int superio_enter(int base) > { > + /* Don't step on other drivers' I/O space by accident */ > + if (!request_muxed_region(base, 2, DRVNAME)) { > + printk(KERN_ERR DRVNAME ": I/O address 0x%04x already in use\n", > + (int)base); > + return -EBUSY; > + } > + > /* according to the datasheet the key must be send twice! */ > outb(SIO_UNLOCK_KEY, base); > outb(SIO_UNLOCK_KEY, base); > + > + return 0; > } > > static inline void superio_select(int base, int ld) > @@ -899,6 +908,7 @@ static inline void superio_select(int base, int ld) > static inline void superio_exit(int base) > { > outb(SIO_LOCK_KEY, base); > + release_region(base, 2); > } > > static inline int fan_from_reg(u16 reg) > @@ -2239,17 +2249,10 @@ static int f71882fg_remove(struct platform_device *pdev) > static int __init f71882fg_find(int sioaddr, unsigned short *address, > struct f71882fg_sio_data *sio_data) > { > - int err = -ENODEV; > u16 devid; > - > - /* Don't step on other drivers' 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 -EBUSY; > - } > - > - superio_enter(sioaddr); > + int err = superio_enter(sioaddr); > + if (err) > + return err; > > devid = superio_inw(sioaddr, SIO_REG_MANID); > if (devid != SIO_FINTEK_ID) { > @@ -2306,7 +2309,6 @@ 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; > } > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hans de Goede Date: Thu, 25 Mar 2010 21:10:33 +0000 Subject: Re: [lm-sensors] [PATCH 2/3] hwmon: f71882fg: use a muxed resource Message-Id: <4BABD149.2050001@redhat.com> List-Id: References: <20100325125005.6d58cfaf@lxorguk.ukuu.org.uk> <1269523063-30346-1-git-send-email-me@mortis.eu> <1269523063-30346-2-git-send-email-me@mortis.eu> In-Reply-To: <1269523063-30346-2-git-send-email-me@mortis.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Giel van Schijndel Cc: Jean Delvare , Jonathan Cameron , Laurens Leemans , lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org Hi, On 03/25/2010 02:17 PM, Giel van Schijndel wrote: > Sleep while acquiring a resource lock on the Super I/O port. This should > prevent collisions from causing the hardware probe to fail with -EBUSY. > Looks good to me (assuming the previous patch in the series gets applied). Acked-by: Hans de Goede Regards, hans > Signed-off-by: Giel van Schijndel > --- > drivers/hwmon/f71882fg.c | 28 +++++++++++++++------------- > 1 files changed, 15 insertions(+), 13 deletions(-) > > diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c > index 7857ed3..e09416d 100644 > --- a/drivers/hwmon/f71882fg.c > +++ b/drivers/hwmon/f71882fg.c > @@ -113,7 +113,7 @@ static struct platform_device *f71882fg_pdev; > /* Super-I/O Function prototypes */ > static inline int superio_inb(int base, int reg); > static inline int superio_inw(int base, int reg); > -static inline void superio_enter(int base); > +static inline int superio_enter(int base); > static inline void superio_select(int base, int ld); > static inline void superio_exit(int base); > > @@ -883,11 +883,20 @@ static int superio_inw(int base, int reg) > return val; > } > > -static inline void superio_enter(int base) > +static inline int superio_enter(int base) > { > + /* Don't step on other drivers' I/O space by accident */ > + if (!request_muxed_region(base, 2, DRVNAME)) { > + printk(KERN_ERR DRVNAME ": I/O address 0x%04x already in use\n", > + (int)base); > + return -EBUSY; > + } > + > /* according to the datasheet the key must be send twice! */ > outb(SIO_UNLOCK_KEY, base); > outb(SIO_UNLOCK_KEY, base); > + > + return 0; > } > > static inline void superio_select(int base, int ld) > @@ -899,6 +908,7 @@ static inline void superio_select(int base, int ld) > static inline void superio_exit(int base) > { > outb(SIO_LOCK_KEY, base); > + release_region(base, 2); > } > > static inline int fan_from_reg(u16 reg) > @@ -2239,17 +2249,10 @@ static int f71882fg_remove(struct platform_device *pdev) > static int __init f71882fg_find(int sioaddr, unsigned short *address, > struct f71882fg_sio_data *sio_data) > { > - int err = -ENODEV; > u16 devid; > - > - /* Don't step on other drivers' 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 -EBUSY; > - } > - > - superio_enter(sioaddr); > + int err = superio_enter(sioaddr); > + if (err) > + return err; > > devid = superio_inw(sioaddr, SIO_REG_MANID); > if (devid != SIO_FINTEK_ID) { > @@ -2306,7 +2309,6 @@ 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; > } > _______________________________________________ lm-sensors mailing list lm-sensors@lm-sensors.org http://lists.lm-sensors.org/mailman/listinfo/lm-sensors