Merge tag 'arc-5.10-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupt...
[linux-2.6-microblaze.git] / drivers / hwmon / pc87427.c
index d1a3f20..eaab83d 100644 (file)
@@ -1,17 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  *  pc87427.c - hardware monitoring driver for the
  *              National Semiconductor PC87427 Super-I/O chip
  *  Copyright (C) 2006, 2008, 2010  Jean Delvare <jdelvare@suse.de>
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2 as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
  *  Supports the following chips:
  *
  *  Chip        #vin    #fan    #pwm    #temp   devid
@@ -106,6 +98,13 @@ static const char *logdev_str[2] = { DRVNAME " FMC", DRVNAME " HMC" };
 #define LD_IN          1
 #define LD_TEMP                1
 
+static inline int superio_enter(int sioaddr)
+{
+       if (!request_muxed_region(sioaddr, 2, DRVNAME))
+               return -EBUSY;
+       return 0;
+}
+
 static inline void superio_outb(int sioaddr, int reg, int val)
 {
        outb(reg, sioaddr);
@@ -122,6 +121,7 @@ static inline void superio_exit(int sioaddr)
 {
        outb(0x02, sioaddr);
        outb(0x02, sioaddr + 1);
+       release_region(sioaddr, 2);
 }
 
 /*
@@ -1195,7 +1195,11 @@ static int __init pc87427_find(int sioaddr, struct pc87427_sio_data *sio_data)
 {
        u16 val;
        u8 cfg, cfg_b;
-       int i, err = 0;
+       int i, err;
+
+       err = superio_enter(sioaddr);
+       if (err)
+               return err;
 
        /* Identify device */
        val = force_id ? force_id : superio_inb(sioaddr, SIOREG_DEVID);