Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging:
hwmon: f71882fg: use a muxed resource lock for the Super I/O port

+19 -13
+19 -13
drivers/hwmon/f71882fg.c
··· 111 111 /* Super-I/O Function prototypes */ 112 112 static inline int superio_inb(int base, int reg); 113 113 static inline int superio_inw(int base, int reg); 114 - static inline void superio_enter(int base); 114 + static inline int superio_enter(int base); 115 115 static inline void superio_select(int base, int ld); 116 116 static inline void superio_exit(int base); 117 117 ··· 861 861 return val; 862 862 } 863 863 864 - static inline void superio_enter(int base) 864 + static inline int superio_enter(int base) 865 865 { 866 + /* Don't step on other drivers' I/O space by accident */ 867 + if (!request_muxed_region(base, 2, DRVNAME)) { 868 + printk(KERN_ERR DRVNAME ": I/O address 0x%04x already in use\n", 869 + base); 870 + return -EBUSY; 871 + } 872 + 866 873 /* according to the datasheet the key must be send twice! */ 867 874 outb(SIO_UNLOCK_KEY, base); 868 875 outb(SIO_UNLOCK_KEY, base); 876 + 877 + return 0; 869 878 } 870 879 871 880 static inline void superio_select(int base, int ld) ··· 886 877 static inline void superio_exit(int base) 887 878 { 888 879 outb(SIO_LOCK_KEY, base); 880 + release_region(base, 2); 889 881 } 890 882 891 883 static inline int fan_from_reg(u16 reg) ··· 2185 2175 static int __init f71882fg_find(int sioaddr, unsigned short *address, 2186 2176 struct f71882fg_sio_data *sio_data) 2187 2177 { 2188 - int err = -ENODEV; 2189 2178 u16 devid; 2190 - 2191 - /* Don't step on other drivers' I/O space by accident */ 2192 - if (!request_region(sioaddr, 2, DRVNAME)) { 2193 - printk(KERN_ERR DRVNAME ": I/O address 0x%04x already in use\n", 2194 - (int)sioaddr); 2195 - return -EBUSY; 2196 - } 2197 - 2198 - superio_enter(sioaddr); 2179 + int err = superio_enter(sioaddr); 2180 + if (err) 2181 + return err; 2199 2182 2200 2183 devid = superio_inw(sioaddr, SIO_REG_MANID); 2201 2184 if (devid != SIO_FINTEK_ID) { 2202 2185 pr_debug(DRVNAME ": Not a Fintek device\n"); 2186 + err = -ENODEV; 2203 2187 goto exit; 2204 2188 } 2205 2189 ··· 2217 2213 default: 2218 2214 printk(KERN_INFO DRVNAME ": Unsupported Fintek device: %04x\n", 2219 2215 (unsigned int)devid); 2216 + err = -ENODEV; 2220 2217 goto exit; 2221 2218 } 2222 2219 ··· 2228 2223 2229 2224 if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) { 2230 2225 printk(KERN_WARNING DRVNAME ": Device not activated\n"); 2226 + err = -ENODEV; 2231 2227 goto exit; 2232 2228 } 2233 2229 2234 2230 *address = superio_inw(sioaddr, SIO_REG_ADDR); 2235 2231 if (*address == 0) { 2236 2232 printk(KERN_WARNING DRVNAME ": Base address not set\n"); 2233 + err = -ENODEV; 2237 2234 goto exit; 2238 2235 } 2239 2236 *address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */ ··· 2246 2239 (int)superio_inb(sioaddr, SIO_REG_DEVREV)); 2247 2240 exit: 2248 2241 superio_exit(sioaddr); 2249 - release_region(sioaddr, 2); 2250 2242 return err; 2251 2243 } 2252 2244