Merge branch 'blktrace' of git://brick.kernel.dk/data/git/linux-2.6-block
authorLinus Torvalds <torvalds@g5.osdl.org>
Fri, 24 Mar 2006 00:24:24 +0000 (16:24 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 24 Mar 2006 00:24:24 +0000 (16:24 -0800)
* 'blktrace' of git://brick.kernel.dk/data/git/linux-2.6-block:
  [PATCH] Block queue IO tracing support (blktrace) as of 2006-03-23
  [PATCH] relay: consolidate sendfile() and read() code
  [PATCH] relay: add sendfile() support
  [PATCH] relay: migrate from relayfs to a generic relay API

227 files changed:
Documentation/feature-removal-schedule.txt
Documentation/hwmon/w83627hf
Documentation/hwmon/w83781d
Documentation/i2c/busses/i2c-piix4
Documentation/i2c/busses/scx200_acb
Documentation/kernel-parameters.txt
Documentation/networking/pktgen.txt
arch/i386/kernel/efi.c
arch/i386/kernel/setup.c
arch/i386/pci/Makefile
arch/i386/pci/common.c
arch/i386/pci/direct.c
arch/i386/pci/init.c [new file with mode: 0644]
arch/i386/pci/mmconfig.c
arch/i386/pci/pcbios.c
arch/i386/pci/pci.h
arch/x86_64/pci/Makefile
drivers/acpi/Kconfig
drivers/acpi/ibm_acpi.c
drivers/acpi/scan.c
drivers/hwmon/Kconfig
drivers/hwmon/adm1021.c
drivers/hwmon/adm1025.c
drivers/hwmon/adm1026.c
drivers/hwmon/adm1031.c
drivers/hwmon/adm9240.c
drivers/hwmon/asb100.c
drivers/hwmon/atxp1.c
drivers/hwmon/ds1621.c
drivers/hwmon/f71805f.c
drivers/hwmon/fscher.c
drivers/hwmon/fscpos.c
drivers/hwmon/gl518sm.c
drivers/hwmon/gl520sm.c
drivers/hwmon/hdaps.c
drivers/hwmon/hwmon-vid.c
drivers/hwmon/hwmon.c
drivers/hwmon/it87.c
drivers/hwmon/lm63.c
drivers/hwmon/lm75.c
drivers/hwmon/lm77.c
drivers/hwmon/lm78.c
drivers/hwmon/lm80.c
drivers/hwmon/lm83.c
drivers/hwmon/lm85.c
drivers/hwmon/lm87.c
drivers/hwmon/lm90.c
drivers/hwmon/lm92.c
drivers/hwmon/max1619.c
drivers/hwmon/pc87360.c
drivers/hwmon/sis5595.c
drivers/hwmon/smsc47b397.c
drivers/hwmon/smsc47m1.c
drivers/hwmon/via686a.c
drivers/hwmon/vt8231.c
drivers/hwmon/w83627ehf.c
drivers/hwmon/w83627hf.c
drivers/hwmon/w83781d.c
drivers/hwmon/w83792d.c
drivers/hwmon/w83l785ts.c
drivers/i2c/busses/Kconfig
drivers/i2c/busses/i2c-ali1535.c
drivers/i2c/busses/i2c-amd756-s4882.c
drivers/i2c/busses/i2c-frodo.c [deleted file]
drivers/i2c/busses/i2c-isa.c
drivers/i2c/busses/i2c-ite.c
drivers/i2c/busses/i2c-ixp4xx.c
drivers/i2c/busses/i2c-piix4.c
drivers/i2c/busses/i2c-pxa.c
drivers/i2c/busses/scx200_acb.c
drivers/i2c/chips/ds1374.c
drivers/i2c/chips/eeprom.c
drivers/i2c/chips/isp1301_omap.c
drivers/i2c/chips/m41t00.c
drivers/i2c/chips/max6875.c
drivers/i2c/chips/pcf8591.c
drivers/i2c/chips/tps65010.c
drivers/i2c/i2c-core.c
drivers/media/video/adv7170.c
drivers/media/video/adv7175.c
drivers/media/video/bt819.c
drivers/media/video/bt856.c
drivers/media/video/cpia.c
drivers/media/video/saa7110.c
drivers/media/video/saa7111.c
drivers/media/video/saa7114.c
drivers/media/video/saa711x.c
drivers/media/video/saa7185.c
drivers/media/video/vpx3220.c
drivers/media/video/zoran.h
drivers/media/video/zoran_card.c
drivers/media/video/zoran_driver.c
drivers/net/bnx2.c
drivers/net/bnx2.h
drivers/net/tg3.c
drivers/net/tg3.h
drivers/pci/Kconfig
drivers/pci/hotplug/Makefile
drivers/pci/hotplug/acpi_pcihp.c [moved from drivers/pci/hotplug/shpchprm_acpi.c with 55% similarity]
drivers/pci/hotplug/acpiphp.h
drivers/pci/hotplug/acpiphp_core.c
drivers/pci/hotplug/acpiphp_dock.c [new file with mode: 0644]
drivers/pci/hotplug/acpiphp_glue.c
drivers/pci/hotplug/cpci_hotplug_core.c
drivers/pci/hotplug/cpqphp.h
drivers/pci/hotplug/cpqphp_core.c
drivers/pci/hotplug/cpqphp_ctrl.c
drivers/pci/hotplug/fakephp.c
drivers/pci/hotplug/ibmphp.h
drivers/pci/hotplug/ibmphp_core.c
drivers/pci/hotplug/ibmphp_ebda.c
drivers/pci/hotplug/ibmphp_hpc.c
drivers/pci/hotplug/ibmphp_pci.c
drivers/pci/hotplug/ibmphp_res.c
drivers/pci/hotplug/pci_hotplug.h
drivers/pci/hotplug/pciehp.h
drivers/pci/hotplug/pciehp_core.c
drivers/pci/hotplug/pciehp_ctrl.c
drivers/pci/hotplug/pciehp_hpc.c
drivers/pci/hotplug/pciehprm_acpi.c [deleted file]
drivers/pci/hotplug/pciehprm_nonacpi.c [deleted file]
drivers/pci/hotplug/pcihp_skeleton.c
drivers/pci/hotplug/rpaphp_slot.c
drivers/pci/hotplug/sgi_hotplug.c
drivers/pci/hotplug/shpchp.h
drivers/pci/hotplug/shpchp_core.c
drivers/pci/hotplug/shpchp_ctrl.c
drivers/pci/hotplug/shpchp_hpc.c
drivers/pci/hotplug/shpchp_pci.c
drivers/pci/hotplug/shpchprm_legacy.c [deleted file]
drivers/pci/hotplug/shpchprm_nonacpi.c [deleted file]
drivers/pci/msi.c
drivers/pci/pci-driver.c
drivers/pci/pci-sysfs.c
drivers/pci/pci.c
drivers/pci/pci.h
drivers/pci/pcie/portdrv.h
drivers/pci/pcie/portdrv_core.c
drivers/pci/pcie/portdrv_pci.c
drivers/pci/probe.c
drivers/pci/proc.c
drivers/pci/quirks.c
drivers/pci/search.c
fs/xfs/Makefile-linux-2.6
fs/xfs/linux-2.6/kmem.h
fs/xfs/linux-2.6/xfs_aops.c
fs/xfs/linux-2.6/xfs_aops.h
fs/xfs/linux-2.6/xfs_buf.c
fs/xfs/linux-2.6/xfs_export.c
fs/xfs/linux-2.6/xfs_file.c
fs/xfs/linux-2.6/xfs_fs_subr.c
fs/xfs/linux-2.6/xfs_ioctl.c
fs/xfs/linux-2.6/xfs_ioctl32.c
fs/xfs/linux-2.6/xfs_ioctl32.h
fs/xfs/linux-2.6/xfs_iops.c
fs/xfs/linux-2.6/xfs_iops.h
fs/xfs/linux-2.6/xfs_linux.h
fs/xfs/linux-2.6/xfs_lrw.c
fs/xfs/linux-2.6/xfs_super.c
fs/xfs/linux-2.6/xfs_super.h
fs/xfs/linux-2.6/xfs_vfs.c
fs/xfs/linux-2.6/xfs_vfs.h
fs/xfs/linux-2.6/xfs_vnode.c
fs/xfs/linux-2.6/xfs_vnode.h
fs/xfs/quota/xfs_dquot_item.c
fs/xfs/quota/xfs_qm.c
fs/xfs/quota/xfs_qm_bhv.c
fs/xfs/support/ktrace.c
fs/xfs/support/uuid.c
fs/xfs/xfs_acl.h
fs/xfs/xfs_attr.c
fs/xfs/xfs_attr_leaf.c
fs/xfs/xfs_attr_leaf.h
fs/xfs/xfs_attr_sf.h
fs/xfs/xfs_bmap.c
fs/xfs/xfs_bmap.h
fs/xfs/xfs_bmap_btree.c
fs/xfs/xfs_bmap_btree.h
fs/xfs/xfs_clnt.h
fs/xfs/xfs_da_btree.c
fs/xfs/xfs_da_btree.h
fs/xfs/xfs_dfrag.c
fs/xfs/xfs_dir.c
fs/xfs/xfs_dir2.h
fs/xfs/xfs_dir2_block.c
fs/xfs/xfs_dir2_block.h
fs/xfs/xfs_dir2_data.c
fs/xfs/xfs_dir2_data.h
fs/xfs/xfs_dir2_leaf.c
fs/xfs/xfs_dir2_leaf.h
fs/xfs/xfs_dir2_node.c
fs/xfs/xfs_dir2_node.h
fs/xfs/xfs_dir2_sf.c
fs/xfs/xfs_dir_leaf.c
fs/xfs/xfs_dir_sf.h
fs/xfs/xfs_dmapi.h
fs/xfs/xfs_fsops.c
fs/xfs/xfs_ialloc.c
fs/xfs/xfs_iget.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h
fs/xfs/xfs_iomap.c
fs/xfs/xfs_itable.c
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_rw.h
fs/xfs/xfs_trans.c
fs/xfs/xfs_trans.h
fs/xfs/xfs_vfsops.c
fs/xfs/xfs_vnodeops.c
include/acpi/acpi_bus.h
include/linux/hwmon-sysfs.h
include/linux/i2c-id.h
include/linux/i2c.h
include/linux/pci.h
include/linux/pci_ids.h
include/linux/rtnetlink.h
net/core/pktgen.c
net/ipv4/fib_rules.c
net/ipv6/ip6_output.c
net/sched/cls_u32.c
sound/oss/dmasound/dmasound_awacs.c
sound/ppc/daca.c
sound/ppc/keywest.c
sound/ppc/toonie.c
sound/ppc/tumbler.c

index afeaf6218ea2808adca3e28a5228924294d824b3..c7a4d0faab228ab63d3700ee9f2cc2ae730009f3 100644 (file)
@@ -158,13 +158,6 @@ Who:    Adrian Bunk <bunk@stusta.de>
 
 ---------------------------
 
-What:  Legacy /proc/pci interface (PCI_LEGACY_PROC)
-When:  March 2006
-Why:   deprecated since 2.5.53 in favor of lspci(8)
-Who:   Adrian Bunk <bunk@stusta.de>
-
----------------------------
-
 What:  pci_module_init(driver)
 When:  January 2007
 Why:   Is replaced by pci_register_driver(pci_driver).
index bbeaba68044352e3442bb31721156a1c9c5e105e..7922319212413c5e3a32be74495b18f339fc1e25 100644 (file)
@@ -18,6 +18,10 @@ Supported chips:
     Prefix: 'w83637hf'
     Addresses scanned: ISA address retrieved from Super I/O registers
     Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf
+  * Winbond W83687THF
+    Prefix: 'w83687thf'
+    Addresses scanned: ISA address retrieved from Super I/O registers
+    Datasheet: Provided by Winbond on request
 
 Authors:
         Frodo Looijaard <frodol@dds.nl>,
index e5459333ba681041e7693ac21917c5f0350b15d3..b1e9f80098ee55af95aab64d26564f7fdfefa7f0 100644 (file)
@@ -36,6 +36,11 @@ Module parameters
   Use 'init=0' to bypass initializing the chip.
   Try this if your computer crashes when you load the module.
 
+* reset int
+  (default 0)
+  The driver used to reset the chip on load, but does no more. Use
+  'reset=1' to restore the old behavior. Report if you need to do this.
+
 force_subclients=bus,caddr,saddr,saddr
   This is used to force the i2c addresses for subclients of
   a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b'
@@ -123,6 +128,25 @@ When an alarm goes off, you can be warned by a beeping signal through
 your computer speaker. It is possible to enable all beeping globally,
 or only the beeping for some alarms.
 
+Individual alarm and beep bits:
+
+0x000001: in0
+0x000002: in1
+0x000004: in2
+0x000008: in3
+0x000010: temp1
+0x000020: temp2 (+temp3 on W83781D)
+0x000040: fan1
+0x000080: fan2
+0x000100: in4
+0x000200: in5
+0x000400: in6
+0x000800: fan3
+0x001000: chassis
+0x002000: temp3 (W83782D and W83627HF only)
+0x010000: in7 (W83782D and W83627HF only)
+0x020000: in8 (W83782D and W83627HF only)
+
 If an alarm triggers, it will remain triggered until the hardware register
 is read at least once. This means that the cause for the alarm may
 already have disappeared! Note that in the current implementation, all
index 856b4b8b962cccd08dbdf5c10a6a45aed2b63e5a..a1c8f581afeda64a9265f66da067efc35446d2b2 100644 (file)
@@ -4,7 +4,7 @@ Supported adapters:
   * Intel 82371AB PIIX4 and PIIX4E
   * Intel 82443MX (440MX)
     Datasheet: Publicly available at the Intel website
-  * ServerWorks OSB4, CSB5 and CSB6 southbridges
+  * ServerWorks OSB4, CSB5, CSB6 and HT-1000 southbridges
     Datasheet: Only available via NDA from ServerWorks
   * Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge
     Datasheet: Publicly available at the SMSC website http://www.smsc.com
index 08c8cd1df60c505eb5328c2028a38e73ef45a5fe..f50e69981ec6570357acdfd6a6a825609f9fe6c7 100644 (file)
@@ -6,9 +6,10 @@ Module Parameters
 -----------------
 
 * base: int
-  Base addresses for the ACCESS.bus controllers
+  Base addresses for the ACCESS.bus controllers on SCx200 and SC1100 devices
 
 Description
 -----------
 
-Enable the use of the ACCESS.bus controllers of a SCx200 processor.
+Enable the use of the ACCESS.bus controller on the Geode SCx200 and
+SC1100 processors and the CS5535 and CS5536 Geode companion devices.
index 7b7382d0f75889c788a75ad05fddc34f7a37f914..44a25f3f51d11cf5977c0542c1db71d4b501b75d 100644 (file)
@@ -49,6 +49,7 @@ restrictions referred to are that the relevant option is valid if:
        MCA     MCA bus support is enabled.
        MDA     MDA console support is enabled.
        MOUSE   Appropriate mouse support is enabled.
+       MSI     Message Signaled Interrupts (PCI).
        MTD     MTD support is enabled.
        NET     Appropriate network support is enabled.
        NUMA    NUMA support is enabled.
@@ -1152,6 +1153,9 @@ running once the system is up.
                                Mechanism 2.
                nommconf        [IA-32,X86_64] Disable use of MMCONFIG for PCI
                                Configuration
+               nomsi           [MSI] If the PCI_MSI kernel config parameter is
+                               enabled, this kernel boot option can be used to
+                               disable the use of MSI interrupts system-wide.
                nosort          [IA-32] Don't sort PCI devices according to
                                order given by the PCI BIOS. This sorting is
                                done to get a device order compatible with
index cc4b4d04129c7ffea1c0a3d936b1f16bd2268d8a..278771c9ad99eda54420ca1d9d3c8a88e778d807 100644 (file)
@@ -109,6 +109,22 @@ Examples:
                          cycle through the port range.
  pgset "udp_dst_max 9"   set UDP destination port max.
 
+ pgset "mpls 0001000a,0002000a,0000000a" set MPLS labels (in this example
+                                         outer label=16,middle label=32,
+                                        inner label=0 (IPv4 NULL)) Note that
+                                        there must be no spaces between the
+                                        arguments. Leading zeros are required.
+                                        Do not set the bottom of stack bit,
+                                        thats done automatically. If you do
+                                        set the bottom of stack bit, that
+                                        indicates that you want to randomly
+                                        generate that address and the flag
+                                        MPLS_RND will be turned on. You
+                                        can have any mix of random and fixed
+                                        labels in the label stack.
+
+ pgset "mpls 0"                  turn off mpls (or any invalid argument works too!)
+
  pgset stop                      aborts injection. Also, ^C aborts generator.
 
 
@@ -167,6 +183,8 @@ pkt_size
 min_pkt_size
 max_pkt_size
 
+mpls
+
 udp_src_min
 udp_src_max
 
@@ -211,4 +229,4 @@ Grant Grundler for testing on IA-64 and parisc, Harald Welte,  Lennert Buytenhek
 Stephen Hemminger, Andi Kleen, Dave Miller and many others.
 
 
-Good luck with the linux net-development.
\ No newline at end of file
+Good luck with the linux net-development.
index aeabb41968610f3aedce1fbff43fad4e3bbebd35..7ec6cfa01fb30d093e1c2fd7fd35e854e55a00d2 100644 (file)
@@ -543,7 +543,7 @@ efi_initialize_iomem_resources(struct resource *code_resource,
                if ((md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) >
                    0x100000000ULL)
                        continue;
-               res = alloc_bootmem_low(sizeof(struct resource));
+               res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
                switch (md->type) {
                case EFI_RESERVED_TYPE:
                        res->name = "Reserved Memory";
index 2d8782960f41dbb074675d705ebf16db61057c2d..d313a11acafade034a57212b0018f17bdbb8ccd0 100644 (file)
@@ -1288,7 +1288,7 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat
                struct resource *res;
                if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
                        continue;
-               res = alloc_bootmem_low(sizeof(struct resource));
+               res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
                switch (e820.map[i].type) {
                case E820_RAM:  res->name = "System RAM"; break;
                case E820_ACPI: res->name = "ACPI Tables"; break;
@@ -1316,13 +1316,15 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat
 
 /*
  * Request address space for all standard resources
+ *
+ * This is called just before pcibios_assign_resources(), which is also
+ * an fs_initcall, but is linked in later (in arch/i386/pci/i386.c).
  */
-static void __init register_memory(void)
+static int __init request_standard_resources(void)
 {
-       unsigned long gapstart, gapsize, round;
-       unsigned long long last;
-       int           i;
+       int i;
 
+       printk("Setting up standard PCI resources\n");
        if (efi_enabled)
                efi_initialize_iomem_resources(&code_resource, &data_resource);
        else
@@ -1334,6 +1336,16 @@ static void __init register_memory(void)
        /* request I/O space for devices used on all i[345]86 PCs */
        for (i = 0; i < STANDARD_IO_RESOURCES; i++)
                request_resource(&ioport_resource, &standard_io_resources[i]);
+       return 0;
+}
+
+fs_initcall(request_standard_resources);
+
+static void __init register_memory(void)
+{
+       unsigned long gapstart, gapsize, round;
+       unsigned long long last;
+       int i;
 
        /*
         * Search for the bigest gap in the low 32 bits of the e820
index 5461d4d5ea1e414b1e607b9a5066d183831a1fa1..62ad75c57e6ae41047a40d480814fabdfdb28b5a 100644 (file)
@@ -1,4 +1,4 @@
-obj-y                          := i386.o
+obj-y                          := i386.o init.o
 
 obj-$(CONFIG_PCI_BIOS)         += pcbios.o
 obj-$(CONFIG_PCI_MMCONFIG)     += mmconfig.o direct.o
index f6bc48da4d2a08b4bb48da2ccd32ae228e12a926..dbece776c5b281f4a95d97eab3016a069446bb60 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/pci.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
+#include <linux/dmi.h>
 
 #include <asm/acpi.h>
 #include <asm/segment.h>
@@ -120,11 +121,42 @@ void __devinit  pcibios_fixup_bus(struct pci_bus *b)
        pci_read_bridge_bases(b);
 }
 
+/*
+ * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
+ */
+#ifdef __i386__
+static int __devinit assign_all_busses(struct dmi_system_id *d)
+{
+       pci_probe |= PCI_ASSIGN_ALL_BUSSES;
+       printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
+                       " (pci=assign-busses)\n", d->ident);
+       return 0;
+}
+#endif
+
+/*
+ * Laptops which need pci=assign-busses to see Cardbus cards
+ */
+static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
+#ifdef __i386__
+       {
+               .callback = assign_all_busses,
+               .ident = "Samsung X20 Laptop",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"),
+               },
+       },
+#endif         /* __i386__ */
+       {}
+};
 
 struct pci_bus * __devinit pcibios_scan_root(int busnum)
 {
        struct pci_bus *bus = NULL;
 
+       dmi_check_system(pciprobe_dmi_table);
+
        while ((bus = pci_find_next_bus(bus)) != NULL) {
                if (bus->number == busnum) {
                        /* Already scanned */
index e3ac502bf2fbac541cf57f52bef2a5a7300b881f..99012b93bd12b9f66e853eb08706be58e301171e 100644 (file)
@@ -245,7 +245,7 @@ static int __init pci_check_type2(void)
        return works;
 }
 
-static int __init pci_direct_init(void)
+void __init pci_direct_init(void)
 {
        struct resource *region, *region2;
 
@@ -258,16 +258,16 @@ static int __init pci_direct_init(void)
        if (pci_check_type1()) {
                printk(KERN_INFO "PCI: Using configuration type 1\n");
                raw_pci_ops = &pci_direct_conf1;
-               return 0;
+               return;
        }
        release_resource(region);
 
  type2:
        if ((pci_probe & PCI_PROBE_CONF2) == 0)
-               goto out;
+               return;
        region = request_region(0xCF8, 4, "PCI conf2");
        if (!region)
-               goto out;
+               return;
        region2 = request_region(0xC000, 0x1000, "PCI conf2");
        if (!region2)
                goto fail2;
@@ -275,15 +275,10 @@ static int __init pci_direct_init(void)
        if (pci_check_type2()) {
                printk(KERN_INFO "PCI: Using configuration type 2\n");
                raw_pci_ops = &pci_direct_conf2;
-               return 0;
+               return;
        }
 
        release_resource(region2);
  fail2:
        release_resource(region);
-
- out:
-       return 0;
 }
-
-arch_initcall(pci_direct_init);
diff --git a/arch/i386/pci/init.c b/arch/i386/pci/init.c
new file mode 100644 (file)
index 0000000..f9156d3
--- /dev/null
@@ -0,0 +1,25 @@
+#include <linux/config.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include "pci.h"
+
+/* arch_initcall has too random ordering, so call the initializers
+   in the right sequence from here. */
+static __init int pci_access_init(void)
+{
+#ifdef CONFIG_PCI_MMCONFIG
+       pci_mmcfg_init();
+#endif
+       if (raw_pci_ops)
+               return 0;
+#ifdef CONFIG_PCI_BIOS
+       pci_pcbios_init();
+#endif
+       if (raw_pci_ops)
+               return 0;
+#ifdef CONFIG_PCI_DIRECT
+       pci_direct_init();
+#endif
+       return 0;
+}
+arch_initcall(pci_access_init);
index 0ee8a983708c078b0e3e8f9b7c27548cd1936845..613789071f30dde13eec78efed2412ae3c399d90 100644 (file)
@@ -172,25 +172,20 @@ static __init void unreachable_devices(void)
        }
 }
 
-static int __init pci_mmcfg_init(void)
+void __init pci_mmcfg_init(void)
 {
        if ((pci_probe & PCI_PROBE_MMCONF) == 0)
-               goto out;
+               return;
 
        acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
        if ((pci_mmcfg_config_num == 0) ||
            (pci_mmcfg_config == NULL) ||
            (pci_mmcfg_config[0].base_address == 0))
-               goto out;
+               return;
 
        printk(KERN_INFO "PCI: Using MMCONFIG\n");
        raw_pci_ops = &pci_mmcfg;
        pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
 
        unreachable_devices();
-
- out:
-       return 0;
 }
-
-arch_initcall(pci_mmcfg_init);
index b9d65f0bc2d161411322d5a94d1456919f66b81f..1eec0868f4b3449df1f22aeb68926ffa2e8dc547 100644 (file)
@@ -476,14 +476,12 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
 }
 EXPORT_SYMBOL(pcibios_set_irq_routing);
 
-static int __init pci_pcbios_init(void)
+void __init pci_pcbios_init(void)
 {
        if ((pci_probe & PCI_PROBE_BIOS) 
                && ((raw_pci_ops = pci_find_bios()))) {
                pci_probe |= PCI_BIOS_SORT;
                pci_bios_present = 1;
        }
-       return 0;
 }
 
-arch_initcall(pci_pcbios_init);
index f550781ec3105f48d517b2ed09fcc80ddc5cba24..12035e29108b445889006bb5aa842057ad9d5bb3 100644 (file)
@@ -80,4 +80,7 @@ extern int pci_conf1_write(unsigned int seg, unsigned int bus,
 extern int pci_conf1_read(unsigned int seg, unsigned int bus,
                          unsigned int devfn, int reg, int len, u32 *value);
 
+extern void pci_direct_init(void);
+extern void pci_pcbios_init(void);
+extern void pci_mmcfg_init(void);
 
index a8f75a2a0f6f0a328eb7b24d336615982310b10d..a3f6ad570179d9a511a242a176a08922da3175bf 100644 (file)
@@ -7,7 +7,7 @@ CFLAGS += -Iarch/i386/pci
 
 obj-y          := i386.o
 obj-$(CONFIG_PCI_DIRECT)+= direct.o
-obj-y          += fixup.o
+obj-y          += fixup.o init.o
 obj-$(CONFIG_ACPI)     += acpi.o
 obj-y                  += legacy.o irq.o common.o
 # mmconfig has a 64bit special
@@ -22,3 +22,4 @@ irq-y    += ../../i386/pci/irq.o
 common-y += ../../i386/pci/common.o
 fixup-y  += ../../i386/pci/fixup.o
 i386-y  += ../../i386/pci/i386.o
+init-y += ../../i386/pci/init.o
index 33e2ca847a261434faf3ca8b0dca05883f80e256..82710ae392283a376d7552310d68b7672c3ca0e8 100644 (file)
@@ -205,6 +205,18 @@ config ACPI_IBM
 
          If you have an IBM ThinkPad laptop, say Y or M here.
 
+config ACPI_IBM_DOCK
+       bool "Legacy Docking Station Support"
+       depends on ACPI_IBM
+       default n
+       ---help---
+         Allows the ibm_acpi driver to handle docking station events.
+         This support is obsoleted by CONFIG_HOTPLUG_PCI_ACPI.  It will
+         allow locking and removing the laptop from the docking station,
+         but will not properly connect PCI devices.
+
+         If you are not sure, say N here.
+
 config ACPI_TOSHIBA
        tristate "Toshiba Laptop Extras"
        depends on X86
index 5cc090326ddc3c134d3550074dbab8e130f077e6..262b1f41335ab1db8943e75bcf0d3f4616285c88 100644 (file)
@@ -160,13 +160,13 @@ IBM_HANDLE(cmos, root, "\\UCMS",  /* R50, R50e, R50p, R51, T4x, X31, X40 */
           "\\CMOS",            /* A3x, G4x, R32, T23, T30, X22-24, X30 */
           "\\CMS",             /* R40, R40e */
     );                         /* all others */
-
+#ifdef CONFIG_ACPI_IBM_DOCK
 IBM_HANDLE(dock, root, "\\_SB.GDCK",   /* X30, X31, X40 */
           "\\_SB.PCI0.DOCK",   /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */
           "\\_SB.PCI0.PCI1.DOCK",      /* all others */
           "\\_SB.PCI.ISA.SLCE",        /* 570 */
     );                         /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */
-
+#endif
 IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST",       /* 570 */
           "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */
           "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */
@@ -844,7 +844,7 @@ static int _sta(acpi_handle handle)
 
        return status;
 }
-
+#ifdef CONFIG_ACPI_IBM_DOCK
 #define dock_docked() (_sta(dock_handle) & 1)
 
 static int dock_read(char *p)
@@ -907,6 +907,7 @@ static void dock_notify(struct ibm_struct *ibm, u32 event)
                acpi_bus_generate_event(ibm->device, event, 0); /* unknown */
        }
 }
+#endif
 
 static int bay_status_supported;
 static int bay_status2_supported;
@@ -1574,6 +1575,7 @@ static struct ibm_struct ibms[] = {
         .read = light_read,
         .write = light_write,
         },
+#ifdef CONFIG_ACPI_IBM_DOCK
        {
         .name = "dock",
         .read = dock_read,
@@ -1589,6 +1591,7 @@ static struct ibm_struct ibms[] = {
         .handle = &pci_handle,
         .type = ACPI_SYSTEM_NOTIFY,
         },
+#endif
        {
         .name = "bay",
         .init = bay_init,
@@ -1880,7 +1883,9 @@ IBM_PARAM(hotkey);
 IBM_PARAM(bluetooth);
 IBM_PARAM(video);
 IBM_PARAM(light);
+#ifdef CONFIG_ACPI_IBM_DOCK
 IBM_PARAM(dock);
+#endif
 IBM_PARAM(bay);
 IBM_PARAM(cmos);
 IBM_PARAM(led);
@@ -1927,7 +1932,9 @@ static int __init acpi_ibm_init(void)
        IBM_HANDLE_INIT(hkey);
        IBM_HANDLE_INIT(lght);
        IBM_HANDLE_INIT(cmos);
+#ifdef CONFIG_ACPI_IBM_DOCK
        IBM_HANDLE_INIT(dock);
+#endif
        IBM_HANDLE_INIT(pci);
        IBM_HANDLE_INIT(bay);
        if (bay_handle)
index 9271e5209ac1a310521d47e7213e9d6822b42547..a0ab828b2cc5fc589335fe9ffe1c1462985288eb 100644 (file)
@@ -23,7 +23,6 @@ static LIST_HEAD(acpi_device_list);
 DEFINE_SPINLOCK(acpi_device_lock);
 LIST_HEAD(acpi_wakeup_device_list);
 
-static int acpi_bus_trim(struct acpi_device *start, int rmdevice);
 
 static void acpi_device_release(struct kobject *kobj)
 {
@@ -1284,7 +1283,7 @@ int acpi_bus_start(struct acpi_device *device)
 
 EXPORT_SYMBOL(acpi_bus_start);
 
-static int acpi_bus_trim(struct acpi_device *start, int rmdevice)
+int acpi_bus_trim(struct acpi_device *start, int rmdevice)
 {
        acpi_status status;
        struct acpi_device *parent, *child;
@@ -1337,6 +1336,8 @@ static int acpi_bus_trim(struct acpi_device *start, int rmdevice)
        }
        return err;
 }
+EXPORT_SYMBOL_GPL(acpi_bus_trim);
+
 
 static int acpi_bus_scan_fixed(struct acpi_device *root)
 {
index 7230d4e081964e79fb2963273311a17a83e30b85..99cdc612d2c6a49ef32af53ca11b0342af587102 100644 (file)
@@ -406,13 +406,14 @@ config SENSORS_W83L785TS
          will be called w83l785ts.
 
 config SENSORS_W83627HF
-       tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF"
-       depends on HWMON && I2C && EXPERIMENTAL
+       tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF"
+       depends on HWMON && I2C
        select I2C_ISA
        select HWMON_VID
        help
          If you say yes here you get support for the Winbond W836X7 series
-         of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF
+         of sensor chips: the W83627HF, W83627THF, W83637HF, W83687THF and
+         W83697HF.
 
          This driver can also be built as a module.  If so, the module
          will be called w83627hf.
index 665612729cb9b15a2bebaa1cd0f3e5ecaa71363c..2b6e74dd4a82079c6eb18b44719846c33ae961ed 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 
 /* Addresses to scan */
@@ -92,7 +93,7 @@ struct adm1021_data {
        struct class_device *class_dev;
        enum chips type;
 
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
 
@@ -162,10 +163,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
        struct adm1021_data *data = i2c_get_clientdata(client); \
        int temp = simple_strtoul(buf, NULL, 10);               \
                                                                \
-       down(&data->update_lock);                               \
+       mutex_lock(&data->update_lock);                         \
        data->value = TEMP_TO_REG(temp);                        \
        adm1021_write_value(client, reg, data->value);          \
-       up(&data->update_lock);                                 \
+       mutex_unlock(&data->update_lock);                       \
        return count;                                           \
 }
 set(temp_max, ADM1021_REG_TOS_W);
@@ -275,7 +276,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
        strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
        data->type = kind;
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -351,7 +352,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1021_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
            || !data->valid) {
@@ -375,7 +376,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index 9331c56d2ba6d6acfd022880a8be90d8dbc94560..a4c859c9fbf82c3f6ef09649e621441c6842044d 100644 (file)
@@ -53,6 +53,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /*
  * Addresses to scan
@@ -133,7 +134,7 @@ static struct i2c_driver adm1025_driver = {
 struct adm1025_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
 
@@ -207,11 +208,11 @@ static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute
        struct adm1025_data *data = i2c_get_clientdata(client); \
        long val = simple_strtol(buf, NULL, 10); \
  \
-       down(&data->update_lock); \
+       mutex_lock(&data->update_lock); \
        data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \
        i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \
                                  data->in_min[offset]); \
-       up(&data->update_lock); \
+       mutex_unlock(&data->update_lock); \
        return count; \
 } \
 static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
@@ -221,11 +222,11 @@ static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute
        struct adm1025_data *data = i2c_get_clientdata(client); \
        long val = simple_strtol(buf, NULL, 10); \
  \
-       down(&data->update_lock); \
+       mutex_lock(&data->update_lock); \
        data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \
        i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \
                                  data->in_max[offset]); \
-       up(&data->update_lock); \
+       mutex_unlock(&data->update_lock); \
        return count; \
 } \
 static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
@@ -247,11 +248,11 @@ static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribut
        struct adm1025_data *data = i2c_get_clientdata(client); \
        long val = simple_strtol(buf, NULL, 10); \
  \
-       down(&data->update_lock); \
+       mutex_lock(&data->update_lock); \
        data->temp_min[offset-1] = TEMP_TO_REG(val); \
        i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \
                                  data->temp_min[offset-1]); \
-       up(&data->update_lock); \
+       mutex_unlock(&data->update_lock); \
        return count; \
 } \
 static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
@@ -261,11 +262,11 @@ static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribut
        struct adm1025_data *data = i2c_get_clientdata(client); \
        long val = simple_strtol(buf, NULL, 10); \
  \
-       down(&data->update_lock); \
+       mutex_lock(&data->update_lock); \
        data->temp_max[offset-1] = TEMP_TO_REG(val); \
        i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \
                                  data->temp_max[offset-1]); \
-       up(&data->update_lock); \
+       mutex_unlock(&data->update_lock); \
        return count; \
 } \
 static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
@@ -404,7 +405,7 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
        /* We can fill in the remaining client fields */
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -523,7 +524,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct adm1025_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
                int i;
@@ -558,7 +559,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index fefe6e74fd02d477dbc900a76d3024db2cec9fe0..6d4f8b8d358edde71408f52554555aafcd21e594 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -260,10 +261,10 @@ struct pwm_data {
 struct adm1026_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore lock;
+       struct mutex lock;
        enum chips type;
 
-       struct semaphore update_lock;
+       struct mutex update_lock;
        int valid;              /* !=0 if following fields are valid */
        unsigned long last_reading;     /* In jiffies */
        unsigned long last_config;      /* In jiffies */
@@ -298,9 +299,8 @@ static int adm1026_attach_adapter(struct i2c_adapter *adapter);
 static int adm1026_detect(struct i2c_adapter *adapter, int address,
        int kind);
 static int adm1026_detach_client(struct i2c_client *client);
-static int adm1026_read_value(struct i2c_client *client, u8 register);
-static int adm1026_write_value(struct i2c_client *client, u8 register,
-       int value); 
+static int adm1026_read_value(struct i2c_client *client, u8 reg);
+static int adm1026_write_value(struct i2c_client *client, u8 reg, int value);
 static void adm1026_print_gpio(struct i2c_client *client);
 static void adm1026_fixup_gpio(struct i2c_client *client); 
 static struct adm1026_data *adm1026_update_device(struct device *dev);
@@ -575,7 +575,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)
        int i;
        long value, alarms, gpio;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        if (!data->valid
            || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) {
                /* Things that change quickly */
@@ -710,7 +710,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)
        dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n");
        data->vid = (data->gpio >> 11) & 0x1f;
        data->valid = 1;
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return data;
 }
 
@@ -739,10 +739,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[nr] = INS_TO_REG(nr, val);
        adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count; 
 }
 static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
@@ -762,10 +762,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[nr] = INS_TO_REG(nr, val);
        adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -813,10 +813,10 @@ static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, c
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET);
        adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count; 
 }
 static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf)
@@ -831,10 +831,10 @@ static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, c
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET);
        adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -874,11 +874,11 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]);
        adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr),
                data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -939,7 +939,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
        if (new_div == 0) {
                return -EINVAL;
        }
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        orig_div = data->fan_div[nr];
        data->fan_div[nr] = DIV_FROM_REG(new_div);
 
@@ -958,7 +958,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
        if (data->fan_div[nr] != orig_div) {
                fixup_fan_min(dev,nr,orig_div);
        }
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -1001,11 +1001,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_min[nr] = TEMP_TO_REG(val);
        adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr],
                data->temp_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
@@ -1025,11 +1025,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_max[nr] = TEMP_TO_REG(val);
        adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr],
                data->temp_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -1064,11 +1064,11 @@ static ssize_t set_temp_offset(struct device *dev,
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_offset[nr] = TEMP_TO_REG(val);
        adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr],
                data->temp_offset[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -1115,11 +1115,11 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev,
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_tmin[nr] = TEMP_TO_REG(val);
        adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr],
                data->temp_tmin[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -1150,11 +1150,11 @@ static ssize_t set_temp_crit_enable(struct device *dev,
        int val = simple_strtol(buf, NULL, 10);
 
        if ((val == 1) || (val==0)) {
-               down(&data->update_lock);
+               mutex_lock(&data->update_lock);
                data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4);
                adm1026_write_value(client, ADM1026_REG_CONFIG1, 
                        data->config1);
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
        }
        return count;
 }
@@ -1184,11 +1184,11 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_crit[nr] = TEMP_TO_REG(val);
        adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr],
                data->temp_crit[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -1212,10 +1212,10 @@ static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *a
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->analog_out = DAC_TO_REG(val);
        adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -1267,7 +1267,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr,
        int val = simple_strtol(buf, NULL, 10);
        unsigned long mask;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->alarm_mask = val & 0x7fffffff;
        mask = data->alarm_mask
                | (data->gpio_mask & 0x10000 ? 0x80000000 : 0);
@@ -1282,7 +1282,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr,
        mask >>= 8;
        adm1026_write_value(client, ADM1026_REG_MASK4,
                mask & 0xff);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -1303,7 +1303,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const
        int val = simple_strtol(buf, NULL, 10);
        long   gpio;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->gpio = val & 0x1ffff;
        gpio = data->gpio;
        adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff);
@@ -1311,7 +1311,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const
        adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff);
        gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f);
        adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -1331,7 +1331,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr,
        int val = simple_strtol(buf, NULL, 10);
        long   mask;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->gpio_mask = val & 0x1ffff;
        mask = data->gpio_mask;
        adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff);
@@ -1339,7 +1339,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr,
        adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff);
        mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f);
        adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -1359,10 +1359,10 @@ static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, co
        if (data->pwm1.enable == 1) {
                int val = simple_strtol(buf, NULL, 10);
 
-               down(&data->update_lock);
+               mutex_lock(&data->update_lock);
                data->pwm1.pwm = PWM_TO_REG(val);
                adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm);
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
        }
        return count;
 }
@@ -1378,14 +1378,14 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att
        struct adm1026_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255);
        if (data->pwm1.enable == 2) { /* apply immediately */
                data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) |
                        PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); 
                adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm);
        }
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf)
@@ -1406,7 +1406,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
        int     old_enable;
 
        if ((val >= 0) && (val < 3)) {
-               down(&data->update_lock);
+               mutex_lock(&data->update_lock);
                old_enable = data->pwm1.enable;
                data->pwm1.enable = val;
                data->config1 = (data->config1 & ~CFG1_PWM_AFC)
@@ -1424,7 +1424,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
                        adm1026_write_value(client, ADM1026_REG_PWM, 
                                data->pwm1.pwm);
                }
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
        }
        return count;
 }
@@ -1541,7 +1541,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
        /* Fill in the remaining client fields */
        data->type = kind;
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
index d0639796608140276f1f67b39652de0c4b1e5a76..3bf2da621aedb39f548f139c31f17ab8d88bac81 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /* Following macros takes channel parameter starting from 0 to 2 */
 #define ADM1031_REG_FAN_SPEED(nr)      (0x08 + (nr))
@@ -70,7 +71,7 @@ typedef u8 auto_chan_table_t[8][2];
 struct adm1031_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        int chip_type;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
@@ -262,10 +263,10 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
 
        old_fan_mode = data->conf1;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        
        if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, &reg))) {
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
                return ret;
        }
        if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^ 
@@ -288,7 +289,7 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
        }
        data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1);
        adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -329,11 +330,11 @@ set_auto_temp_min(struct device *dev, const char *buf, size_t count, int nr)
        struct adm1031_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]);
        adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
                            data->auto_temp[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr)
@@ -349,11 +350,11 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr)
        struct adm1031_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]);
        adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
                            data->temp_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -405,11 +406,11 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
        int val = simple_strtol(buf, NULL, 10);
        int reg;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) && 
            (((val>>4) & 0xf) != 5)) {
                /* In automatic mode, the only PWM accepted is 33% */
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
                return -EINVAL;
        }
        data->pwm[nr] = PWM_TO_REG(val);
@@ -417,7 +418,7 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
        adm1031_write_value(client, ADM1031_REG_PWM,
                            nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf)
                            : (data->pwm[nr] & 0xf) | (reg & 0xf0));
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -511,7 +512,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr)
        struct adm1031_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        if (val) {
                data->fan_min[nr] = 
                        FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr]));
@@ -519,7 +520,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr)
                data->fan_min[nr] = 0xff;
        }
        adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t
@@ -540,7 +541,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
        if (tmp == 0xff)
                return -EINVAL;
        
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        old_div = FAN_DIV_FROM_REG(data->fan_div[nr]);
        data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]);
        new_min = data->fan_min[nr] * old_div / 
@@ -553,7 +554,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
                            data->fan_div[nr]);
        adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), 
                            data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -627,11 +628,11 @@ set_temp_min(struct device *dev, const char *buf, size_t count, int nr)
 
        val = simple_strtol(buf, NULL, 10);
        val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_min[nr] = TEMP_TO_REG(val);
        adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr),
                            data->temp_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t
@@ -643,11 +644,11 @@ set_temp_max(struct device *dev, const char *buf, size_t count, int nr)
 
        val = simple_strtol(buf, NULL, 10);
        val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_max[nr] = TEMP_TO_REG(val);
        adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr),
                            data->temp_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t
@@ -659,11 +660,11 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr)
 
        val = simple_strtol(buf, NULL, 10);
        val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_crit[nr] = TEMP_TO_REG(val);
        adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr),
                            data->temp_crit[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -778,7 +779,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
 
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -891,7 +892,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
        struct adm1031_data *data = i2c_get_clientdata(client);
        int chan;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
            || !data->valid) {
@@ -965,7 +966,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index 5ddc22fea4a37e665180a3591a680e0c5f62f0c0..43f6991b588c6792b3e988f879afbce8c24cd3a1 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
@@ -150,7 +151,7 @@ struct adm9240_data {
        enum chips type;
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;
        unsigned long last_updated_measure;
        unsigned long last_updated_config;
@@ -195,11 +196,11 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr,
        struct adm9240_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_max[attr->index] = TEMP_TO_REG(val);
        i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index),
                        data->temp_max[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -246,11 +247,11 @@ static ssize_t set_in_min(struct device *dev,
        struct adm9240_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[attr->index] = IN_TO_REG(val, attr->index);
        i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index),
                        data->in_min[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -263,11 +264,11 @@ static ssize_t set_in_max(struct device *dev,
        struct adm9240_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[attr->index] = IN_TO_REG(val, attr->index);
        i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index),
                        data->in_max[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -350,7 +351,7 @@ static ssize_t set_fan_min(struct device *dev,
        int nr = attr->index;
        u8 new_div;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (!val) {
                data->fan_min[nr] = 255;
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct device *dev,
        i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr),
                        data->fan_min[nr]);
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -439,10 +440,10 @@ static ssize_t set_aout(struct device *dev,
        struct adm9240_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->aout = AOUT_TO_REG(val);
        i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
@@ -539,7 +540,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
        /* fill in the remaining client fields and attach */
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->type = kind;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        if ((err = i2c_attach_client(new_client)))
                goto exit_free;
@@ -691,7 +692,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
        struct adm9240_data *data = i2c_get_clientdata(client);
        int i;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        /* minimum measurement cycle: 1.75 seconds */
        if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4))
@@ -771,7 +772,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
                data->last_updated_config = jiffies;
                data->valid = 1;
        }
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return data;
 }
 
index ae9de63cf2e066b55e9bc3869b1bb7344c4dd9f9..65b2709f750c710ebff6d37a5bec225059a62b2d 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/jiffies.h>
+#include <linux/mutex.h>
 #include "lm75.h"
 
 /*
@@ -182,10 +183,10 @@ static u8 DIV_TO_REG(long val)
 struct asb100_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore lock;
+       struct mutex lock;
        enum chips type;
 
-       struct semaphore update_lock;
+       struct mutex update_lock;
        unsigned long last_updated;     /* In jiffies */
 
        /* array of 2 pointers to subclients */
@@ -245,11 +246,11 @@ static ssize_t set_in_##reg(struct device *dev, const char *buf, \
        struct asb100_data *data = i2c_get_clientdata(client); \
        unsigned long val = simple_strtoul(buf, NULL, 10); \
  \
-       down(&data->update_lock); \
+       mutex_lock(&data->update_lock); \
        data->in_##reg[nr] = IN_TO_REG(val); \
        asb100_write_value(client, ASB100_REG_IN_##REG(nr), \
                data->in_##reg[nr]); \
-       up(&data->update_lock); \
+       mutex_unlock(&data->update_lock); \
        return count; \
 }
 
@@ -331,10 +332,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
        struct asb100_data *data = i2c_get_clientdata(client);
        u32 val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
        asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -351,7 +352,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        unsigned long val = simple_strtoul(buf, NULL, 10);
        int reg;
        
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        min = FAN_FROM_REG(data->fan_min[nr],
                        DIV_FROM_REG(data->fan_div[nr]));
@@ -381,7 +382,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
                FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
        asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
@@ -461,7 +462,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
        struct asb100_data *data = i2c_get_clientdata(client); \
        unsigned long val = simple_strtoul(buf, NULL, 10); \
  \
-       down(&data->update_lock); \
+       mutex_lock(&data->update_lock); \
        switch (nr) { \
        case 1: case 2: \
                data->reg[nr] = LM75_TEMP_TO_REG(val); \
@@ -472,7 +473,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
        } \
        asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \
                        data->reg[nr]); \
-       up(&data->update_lock); \
+       mutex_unlock(&data->update_lock); \
        return count; \
 }
 
@@ -574,11 +575,11 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const
        struct asb100_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->pwm &= 0x80; /* keep the enable bit */
        data->pwm |= (0x0f & ASB100_PWM_TO_REG(val));
        asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -595,11 +596,11 @@ static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr
        struct asb100_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->pwm &= 0x0f; /* keep the duty cycle bits */
        data->pwm |= (val ? 0x80 : 0x00);
        asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -729,7 +730,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
        }
 
        new_client = &data->client;
-       init_MUTEX(&data->lock);
+       mutex_init(&data->lock);
        i2c_set_clientdata(new_client, data);
        new_client->addr = address;
        new_client->adapter = adapter;
@@ -789,7 +790,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
        data->type = kind;
 
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -885,7 +886,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
        struct i2c_client *cl;
        int res, bank;
 
-       down(&data->lock);
+       mutex_lock(&data->lock);
 
        bank = (reg >> 8) & 0x0f;
        if (bank > 2)
@@ -919,7 +920,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
        if (bank > 2)
                i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
 
-       up(&data->lock);
+       mutex_unlock(&data->lock);
 
        return res;
 }
@@ -930,7 +931,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
        struct i2c_client *cl;
        int bank;
 
-       down(&data->lock);
+       mutex_lock(&data->lock);
 
        bank = (reg >> 8) & 0x0f;
        if (bank > 2)
@@ -960,7 +961,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
        if (bank > 2)
                i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
 
-       up(&data->lock);
+       mutex_unlock(&data->lock);
 }
 
 static void asb100_init_client(struct i2c_client *client)
@@ -984,7 +985,7 @@ static struct asb100_data *asb100_update_device(struct device *dev)
        struct asb100_data *data = i2c_get_clientdata(client);
        int i;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
                || !data->valid) {
@@ -1042,7 +1043,7 @@ static struct asb100_data *asb100_update_device(struct device *dev)
                dev_dbg(&client->dev, "... device update complete\n");
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index b0c490073c8e19c92142e706f976403e2ce50526..728a1e8b91904fe570e6767322d6e0a69dc84e2b 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
@@ -60,7 +61,7 @@ static struct i2c_driver atxp1_driver = {
 struct atxp1_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        unsigned long last_updated;
        u8 valid;
        struct {
@@ -80,7 +81,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
        client = to_i2c_client(dev);
        data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
 
@@ -93,7 +94,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return(data);
 }
@@ -309,7 +310,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
 
        data->valid = 0;
 
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        err = i2c_attach_client(new_client);
 
index 203f9c7abb20a78825de40e7d502d1c5a05d133a..478eb4bb8570958464f57f582c8ee6d52c4edadb 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 #include "lm75.h"
 
 /* Addresses to scan */
@@ -72,7 +73,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
 struct ds1621_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;                     /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
 
@@ -156,10 +157,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at
        struct ds1621_data *data = ds1621_update_client(dev);           \
        u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10));      \
                                                                        \
-       down(&data->update_lock);                                       \
+       mutex_lock(&data->update_lock);                                 \
        data->value = val;                                              \
        ds1621_write_value(client, reg, data->value);                   \
-       up(&data->update_lock);                                         \
+       mutex_unlock(&data->update_lock);                               \
        return count;                                                   \
 }
 
@@ -242,7 +243,7 @@ static int ds1621_detect(struct i2c_adapter *adapter, int address,
        /* Fill in remaining client fields and put it into the global list */
        strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -297,7 +298,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
        struct ds1621_data *data = i2c_get_clientdata(client);
        u8 new_conf;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
            || !data->valid) {
@@ -327,7 +328,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index e029e0a94eccc0e447cd86766498189648dd7ba5..885465df6e6a68db40f89c0d1b64c87efaf089c7 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 #include <asm/io.h>
 
 static struct platform_device *pdev;
@@ -131,10 +132,10 @@ static struct resource f71805f_resource __initdata = {
 struct f71805f_data {
        unsigned short addr;
        const char *name;
-       struct semaphore lock;
+       struct mutex lock;
        struct class_device *class_dev;
 
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
        unsigned long last_limits;      /* In jiffies */
@@ -224,20 +225,20 @@ static u8 f71805f_read8(struct f71805f_data *data, u8 reg)
 {
        u8 val;
 
-       down(&data->lock);
+       mutex_lock(&data->lock);
        outb(reg, data->addr + ADDR_REG_OFFSET);
        val = inb(data->addr + DATA_REG_OFFSET);
-       up(&data->lock);
+       mutex_unlock(&data->lock);
 
        return val;
 }
 
 static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val)
 {
-       down(&data->lock);
+       mutex_lock(&data->lock);
        outb(reg, data->addr + ADDR_REG_OFFSET);
        outb(val, data->addr + DATA_REG_OFFSET);
-       up(&data->lock);
+       mutex_unlock(&data->lock);
 }
 
 /* It is important to read the MSB first, because doing so latches the
@@ -246,24 +247,24 @@ static u16 f71805f_read16(struct f71805f_data *data, u8 reg)
 {
        u16 val;
 
-       down(&data->lock);
+       mutex_lock(&data->lock);
        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);
-       up(&data->lock);
+       mutex_unlock(&data->lock);
 
        return val;
 }
 
 static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val)
 {
-       down(&data->lock);
+       mutex_lock(&data->lock);
        outb(reg, data->addr + ADDR_REG_OFFSET);
        outb(val >> 8, data->addr + DATA_REG_OFFSET);
        outb(++reg, data->addr + ADDR_REG_OFFSET);
        outb(val & 0xff, data->addr + DATA_REG_OFFSET);
-       up(&data->lock);
+       mutex_unlock(&data->lock);
 }
 
 static struct f71805f_data *f71805f_update_device(struct device *dev)
@@ -271,7 +272,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev)
        struct f71805f_data *data = dev_get_drvdata(dev);
        int nr;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        /* Limit registers cache is refreshed after 60 seconds */
        if (time_after(jiffies, data->last_updated + 60 * HZ)
@@ -323,7 +324,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
@@ -362,10 +363,10 @@ static ssize_t set_in0_max(struct device *dev, struct device_attribute
        struct f71805f_data *data = dev_get_drvdata(dev);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_high[0] = in0_to_reg(val);
        f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
@@ -376,18 +377,14 @@ static ssize_t set_in0_min(struct device *dev, struct device_attribute
        struct f71805f_data *data = dev_get_drvdata(dev);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_low[0] = in0_to_reg(val);
        f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
 
-static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL);
-static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max);
-static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min);
-
 static ssize_t show_in(struct device *dev, struct device_attribute *devattr,
                       char *buf)
 {
@@ -426,10 +423,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute
        int nr = attr->index;
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_high[nr] = in_to_reg(val);
        f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
@@ -442,31 +439,14 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute
        int nr = attr->index;
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_low[nr] = in_to_reg(val);
        f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
 
-#define sysfs_in(offset)                                       \
-static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO,         \
-               show_in, NULL, offset);                         \
-static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
-               show_in_max, set_in_max, offset);               \
-static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
-               show_in_min, set_in_min, offset)
-
-sysfs_in(1);
-sysfs_in(2);
-sysfs_in(3);
-sysfs_in(4);
-sysfs_in(5);
-sysfs_in(6);
-sysfs_in(7);
-sysfs_in(8);
-
 static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
                        char *buf)
 {
@@ -495,24 +475,14 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute
        int nr = attr->index;
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_low[nr] = fan_to_reg(val);
        f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
 
-#define sysfs_fan(offset)                                      \
-static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO,                \
-               show_fan, NULL, offset - 1);                    \
-static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR,        \
-               show_fan_min, set_fan_min, offset - 1)
-
-sysfs_fan(1);
-sysfs_fan(2);
-sysfs_fan(3);
-
 static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
                         char *buf)
 {
@@ -562,10 +532,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute
        int nr = attr->index;
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_high[nr] = temp_to_reg(val);
        f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
@@ -578,28 +548,14 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute
        int nr = attr->index;
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_hyst[nr] = temp_to_reg(val);
        f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
 
-#define sysfs_temp(offset)                                             \
-static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO,               \
-               show_temp, NULL, offset - 1);                           \
-static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR,       \
-               show_temp_max, set_temp_max, offset - 1);               \
-static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR,  \
-               show_temp_hyst, set_temp_hyst, offset - 1);             \
-static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO,                        \
-               show_temp_type, NULL, offset - 1)
-
-sysfs_temp(1);
-sysfs_temp(2);
-sysfs_temp(3);
-
 static ssize_t show_alarms_in(struct device *dev, struct device_attribute
                              *devattr, char *buf)
 {
@@ -625,10 +581,6 @@ static ssize_t show_alarms_temp(struct device *dev, struct device_attribute
        return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07);
 }
 
-static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL);
-static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL);
-static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL);
-
 static ssize_t show_name(struct device *dev, struct device_attribute
                         *devattr, char *buf)
 {
@@ -637,7 +589,89 @@ static ssize_t show_name(struct device *dev, struct device_attribute
        return sprintf(buf, "%s\n", data->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
+static struct device_attribute f71805f_dev_attr[] = {
+       __ATTR(in0_input, S_IRUGO, show_in0, NULL),
+       __ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max),
+       __ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min),
+       __ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL),
+       __ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL),
+       __ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL),
+       __ATTR(name, S_IRUGO, show_name, NULL),
+};
+
+static struct sensor_device_attribute f71805f_sensor_attr[] = {
+       SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1),
+       SENSOR_ATTR(in1_max, S_IRUGO | S_IWUSR,
+                   show_in_max, set_in_max, 1),
+       SENSOR_ATTR(in1_min, S_IRUGO | S_IWUSR,
+                   show_in_min, set_in_min, 1),
+       SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2),
+       SENSOR_ATTR(in2_max, S_IRUGO | S_IWUSR,
+                   show_in_max, set_in_max, 2),
+       SENSOR_ATTR(in2_min, S_IRUGO | S_IWUSR,
+                   show_in_min, set_in_min, 2),
+       SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3),
+       SENSOR_ATTR(in3_max, S_IRUGO | S_IWUSR,
+                   show_in_max, set_in_max, 3),
+       SENSOR_ATTR(in3_min, S_IRUGO | S_IWUSR,
+                   show_in_min, set_in_min, 3),
+       SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4),
+       SENSOR_ATTR(in4_max, S_IRUGO | S_IWUSR,
+                   show_in_max, set_in_max, 4),
+       SENSOR_ATTR(in4_min, S_IRUGO | S_IWUSR,
+                   show_in_min, set_in_min, 4),
+       SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5),
+       SENSOR_ATTR(in5_max, S_IRUGO | S_IWUSR,
+                   show_in_max, set_in_max, 5),
+       SENSOR_ATTR(in5_min, S_IRUGO | S_IWUSR,
+                   show_in_min, set_in_min, 5),
+       SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6),
+       SENSOR_ATTR(in6_max, S_IRUGO | S_IWUSR,
+                   show_in_max, set_in_max, 6),
+       SENSOR_ATTR(in6_min, S_IRUGO | S_IWUSR,
+                   show_in_min, set_in_min, 6),
+       SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7),
+       SENSOR_ATTR(in7_max, S_IRUGO | S_IWUSR,
+                   show_in_max, set_in_max, 7),
+       SENSOR_ATTR(in7_min, S_IRUGO | S_IWUSR,
+                   show_in_min, set_in_min, 7),
+       SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8),
+       SENSOR_ATTR(in8_max, S_IRUGO | S_IWUSR,
+                   show_in_max, set_in_max, 8),
+       SENSOR_ATTR(in8_min, S_IRUGO | S_IWUSR,
+                   show_in_min, set_in_min, 8),
+
+       SENSOR_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0),
+       SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR,
+                   show_temp_max, set_temp_max, 0),
+       SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
+                   show_temp_hyst, set_temp_hyst, 0),
+       SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0),
+       SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1),
+       SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR,
+                   show_temp_max, set_temp_max, 1),
+       SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR,
+                   show_temp_hyst, set_temp_hyst, 1),
+       SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1),
+       SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2),
+       SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR,
+                   show_temp_max, set_temp_max, 2),
+       SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR,
+                   show_temp_hyst, set_temp_hyst, 2),
+       SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2),
+};
+
+static struct sensor_device_attribute f71805f_fan_attr[] = {
+       SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0),
+       SENSOR_ATTR(fan1_min, S_IRUGO | S_IWUSR,
+                   show_fan_min, set_fan_min, 0),
+       SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1),
+       SENSOR_ATTR(fan2_min, S_IRUGO | S_IWUSR,
+                   show_fan_min, set_fan_min, 1),
+       SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2),
+       SENSOR_ATTR(fan3_min, S_IRUGO | S_IWUSR,
+                   show_fan_min, set_fan_min, 2),
+};
 
 /*
  * Device registration and initialization
@@ -668,7 +702,7 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
 {
        struct f71805f_data *data;
        struct resource *res;
-       int err;
+       int i, err;
 
        if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) {
                err = -ENOMEM;
@@ -678,9 +712,9 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_IO, 0);
        data->addr = res->start;
-       init_MUTEX(&data->lock);
+       mutex_init(&data->lock);
        data->name = "f71805f";
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        platform_set_drvdata(pdev, data);
 
@@ -695,76 +729,31 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
        f71805f_init_device(data);
 
        /* Register sysfs interface files */
-       device_create_file(&pdev->dev, &dev_attr_in0_input);
-       device_create_file(&pdev->dev, &dev_attr_in0_max);
-       device_create_file(&pdev->dev, &dev_attr_in0_min);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in1_input.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in2_input.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in3_input.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in4_input.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in5_input.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in6_input.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in7_input.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in8_input.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in1_max.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in2_max.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in3_max.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in4_max.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in5_max.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in6_max.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in7_max.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in8_max.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in1_min.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in2_min.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in3_min.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in4_min.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in5_min.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in6_min.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in7_min.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_in8_min.dev_attr);
-       if (data->fan_enabled & (1 << 0)) {
-               device_create_file(&pdev->dev,
-                                  &sensor_dev_attr_fan1_input.dev_attr);
-               device_create_file(&pdev->dev,
-                                  &sensor_dev_attr_fan1_min.dev_attr);
+       for (i = 0; i < ARRAY_SIZE(f71805f_dev_attr); i++) {
+               err = device_create_file(&pdev->dev, &f71805f_dev_attr[i]);
+               if (err)
+                       goto exit_class;
        }
-       if (data->fan_enabled & (1 << 1)) {
-               device_create_file(&pdev->dev,
-                                  &sensor_dev_attr_fan2_input.dev_attr);
-               device_create_file(&pdev->dev,
-                                  &sensor_dev_attr_fan2_min.dev_attr);
+       for (i = 0; i < ARRAY_SIZE(f71805f_sensor_attr); i++) {
+               err = device_create_file(&pdev->dev,
+                                        &f71805f_sensor_attr[i].dev_attr);
+               if (err)
+                       goto exit_class;
        }
-       if (data->fan_enabled & (1 << 2)) {
-               device_create_file(&pdev->dev,
-                                  &sensor_dev_attr_fan3_input.dev_attr);
-               device_create_file(&pdev->dev,
-                                  &sensor_dev_attr_fan3_min.dev_attr);
+       for (i = 0; i < ARRAY_SIZE(f71805f_fan_attr); i++) {
+               if (!(data->fan_enabled & (1 << (i / 2))))
+                       continue;
+               err = device_create_file(&pdev->dev,
+                                        &f71805f_fan_attr[i].dev_attr);
+               if (err)
+                       goto exit_class;
        }
-       device_create_file(&pdev->dev,
-                          &sensor_dev_attr_temp1_input.dev_attr);
-       device_create_file(&pdev->dev,
-                          &sensor_dev_attr_temp2_input.dev_attr);
-       device_create_file(&pdev->dev,
-                          &sensor_dev_attr_temp3_input.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_temp1_max.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_temp2_max.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_temp3_max.dev_attr);
-       device_create_file(&pdev->dev,
-                          &sensor_dev_attr_temp1_max_hyst.dev_attr);
-       device_create_file(&pdev->dev,
-                          &sensor_dev_attr_temp2_max_hyst.dev_attr);
-       device_create_file(&pdev->dev,
-                          &sensor_dev_attr_temp3_max_hyst.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_temp1_type.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_temp2_type.dev_attr);
-       device_create_file(&pdev->dev, &sensor_dev_attr_temp3_type.dev_attr);
-       device_create_file(&pdev->dev, &dev_attr_alarms_in);
-       device_create_file(&pdev->dev, &dev_attr_alarms_fan);
-       device_create_file(&pdev->dev, &dev_attr_alarms_temp);
-       device_create_file(&pdev->dev, &dev_attr_name);
 
        return 0;
 
+exit_class:
+       dev_err(&pdev->dev, "Sysfs interface creation failed\n");
+       hwmon_device_unregister(data->class_dev);
 exit_free:
        kfree(data);
 exit:
index 25409181d1eb87940ef69f6166cd46f4f7ff9678..6bc76b407636d8a1a8199669d588d51f96bd9b8e 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /*
  * Addresses to scan
@@ -133,7 +134,7 @@ static struct i2c_driver fscher_driver = {
 struct fscher_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
 
@@ -332,7 +333,7 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
         * global list */
        strlcpy(new_client->name, "fscher", I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -417,7 +418,7 @@ static struct fscher_data *fscher_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct fscher_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
 
@@ -457,7 +458,7 @@ static struct fscher_data *fscher_update_device(struct device *dev)
                data->valid = 1;                 
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
@@ -472,10 +473,10 @@ static ssize_t set_fan_status(struct i2c_client *client, struct fscher_data *dat
        /* bits 0..1, 3..7 reserved => mask with 0x04 */  
        unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04;
        
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v;
        fscher_write_value(client, reg, v);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -490,10 +491,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscher_data *data,
 {
        unsigned long v = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v;
        fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -518,14 +519,14 @@ static ssize_t set_fan_div(struct i2c_client *client, struct fscher_data *data,
                return -EINVAL;
        }
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        /* bits 2..7 reserved => mask with 0x03 */
        data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03;
        data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v;
 
        fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -552,10 +553,10 @@ static ssize_t set_temp_status(struct i2c_client *client, struct fscher_data *da
        /* bits 2..7 reserved, 0 read only => mask with 0x02 */  
        unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v;
        fscher_write_value(client, reg, v);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -609,10 +610,10 @@ static ssize_t set_control(struct i2c_client *client, struct fscher_data *data,
        /* bits 1..7 reserved => mask with 0x01 */  
        unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->global_control &= ~v;
        fscher_write_value(client, reg, v);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -631,11 +632,11 @@ static ssize_t set_watchdog_control(struct i2c_client *client, struct
        /* bits 0..3 reserved => mask with 0xf0 */  
        unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->watchdog[2] &= ~0xf0;
        data->watchdog[2] |= v;
        fscher_write_value(client, reg, data->watchdog[2]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -651,10 +652,10 @@ static ssize_t set_watchdog_status(struct i2c_client *client, struct fscher_data
        /* bits 0, 2..7 reserved => mask with 0x02 */  
        unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->watchdog[1] &= ~v;
        fscher_write_value(client, reg, v);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -669,10 +670,10 @@ static ssize_t set_watchdog_preset(struct i2c_client *client, struct fscher_data
 {
        unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff;
        
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->watchdog[0] = v;
        fscher_write_value(client, reg, data->watchdog[0]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
index 6d0146b570201533d99b346e4aa1612c4fbcd06c..6dc4846b9eebb98ce6d661dfd49b40edfdc28536 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/init.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /*
  * Addresses to scan
@@ -89,8 +90,8 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter);
 static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind);
 static int fscpos_detach_client(struct i2c_client *client);
 
-static int fscpos_read_value(struct i2c_client *client, u8 register);
-static int fscpos_write_value(struct i2c_client *client, u8 register, u8 value);
+static int fscpos_read_value(struct i2c_client *client, u8 reg);
+static int fscpos_write_value(struct i2c_client *client, u8 reg, u8 value);
 static struct fscpos_data *fscpos_update_device(struct device *dev);
 static void fscpos_init_client(struct i2c_client *client);
 
@@ -114,7 +115,7 @@ static struct i2c_driver fscpos_driver = {
 struct fscpos_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;             /* 0 until following fields are valid */
        unsigned long last_updated;     /* In jiffies */
 
@@ -208,13 +209,13 @@ static ssize_t set_fan_ripple(struct i2c_client *client, struct fscpos_data
                return -EINVAL;
        }
        
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        /* bits 2..7 reserved => mask with 0x03 */
        data->fan_ripple[nr - 1] &= ~0x03;
        data->fan_ripple[nr - 1] |= v;
        
        fscpos_write_value(client, reg, data->fan_ripple[nr - 1]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -232,10 +233,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscpos_data *data,
        if (v < 0) v = 0;
        if (v > 255) v = 255;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->pwm[nr - 1] = v;
        fscpos_write_value(client, reg, data->pwm[nr - 1]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -278,11 +279,11 @@ static ssize_t set_wdog_control(struct i2c_client *client, struct fscpos_data
        /* bits 0..3 reserved => mask with 0xf0 */
        unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->wdog_control &= ~0xf0;
        data->wdog_control |= v;
        fscpos_write_value(client, reg, data->wdog_control);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -304,10 +305,10 @@ static ssize_t set_wdog_state(struct i2c_client *client, struct fscpos_data
                return -EINVAL;
        }
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->wdog_state &= ~v;
        fscpos_write_value(client, reg, v);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -321,10 +322,10 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data
 {
        unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->wdog_preset = v;
        fscpos_write_value(client, reg, data->wdog_preset);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -483,7 +484,7 @@ static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
        strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE);
 
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -579,7 +580,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct fscpos_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
                int i;
@@ -625,7 +626,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev)
                data->last_updated = jiffies;
                data->valid = 1;
        }
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return data;
 }
 
index 9e685e3a3bc97ea911c10853e835f6b8f2de4422..6606aabdb49d5d7b7d3125a496a5a496ceb0e0b8 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
@@ -120,7 +121,7 @@ struct gl518_data {
        struct class_device *class_dev;
        enum chips type;
 
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
 
@@ -212,10 +213,10 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c
        struct gl518_data *data = i2c_get_clientdata(client);           \
        long val = simple_strtol(buf, NULL, 10);                        \
                                                                        \
-       down(&data->update_lock);                                       \
+       mutex_lock(&data->update_lock);                                 \
        data->value = type##_TO_REG(val);                               \
        gl518_write_value(client, reg, data->value);                    \
-       up(&data->update_lock);                                         \
+       mutex_unlock(&data->update_lock);                               \
        return count;                                                   \
 }
 
@@ -228,12 +229,12 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c
        int regvalue;                                                   \
        unsigned long val = simple_strtoul(buf, NULL, 10);              \
                                                                        \
-       down(&data->update_lock);                                       \
+       mutex_lock(&data->update_lock);                                 \
        regvalue = gl518_read_value(client, reg);                       \
        data->value = type##_TO_REG(val);                               \
        regvalue = (regvalue & ~mask) | (data->value << shift);         \
        gl518_write_value(client, reg, regvalue);                       \
-       up(&data->update_lock);                                         \
+       mutex_unlock(&data->update_lock);                               \
        return count;                                                   \
 }
 
@@ -265,7 +266,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c
        int regvalue;
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT);
        data->fan_min[0] = FAN_TO_REG(val,
                DIV_FROM_REG(data->fan_div[0]));
@@ -280,7 +281,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c
        data->beep_mask &= data->alarm_mask;
        gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -291,7 +292,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c
        int regvalue;
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT);
        data->fan_min[1] = FAN_TO_REG(val,
                DIV_FROM_REG(data->fan_div[1]));
@@ -306,7 +307,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c
        data->beep_mask &= data->alarm_mask;
        gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -407,7 +408,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
        strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE);
        data->type = kind;
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -525,7 +526,7 @@ static struct gl518_data *gl518_update_device(struct device *dev)
        struct gl518_data *data = i2c_get_clientdata(client);
        int val;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
            || !data->valid) {
@@ -586,7 +587,7 @@ static struct gl518_data *gl518_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index baee60e44b521c25ca5f0fe1009503759ea3fe38..47b4d49f75c6a3393136fd50e9eecaf429bb33b9 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /* Type of the extra sensor */
 static unsigned short extra_sensor_type;
@@ -121,7 +122,7 @@ static struct i2c_driver gl520_driver = {
 struct gl520_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;             /* zero until the following fields are valid */
        unsigned long last_updated;     /* in jiffies */
 
@@ -303,7 +304,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co
        long v = simple_strtol(buf, NULL, 10);
        u8 r;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (n == 0)
                r = VDD_TO_REG(v);
@@ -317,7 +318,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co
        else
                gl520_write_value(client, reg, r);
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -331,7 +332,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co
        else
                r = IN_TO_REG(v);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        data->in_max[n] = r;
 
@@ -340,7 +341,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co
        else
                gl520_write_value(client, reg, r);
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -373,7 +374,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c
        unsigned long v = simple_strtoul(buf, NULL, 10);
        u8 r;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        r = FAN_TO_REG(v, data->fan_div[n - 1]);
        data->fan_min[n - 1] = r;
 
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c
        data->beep_mask &= data->alarm_mask;
        gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask);
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -409,7 +410,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c
                return -EINVAL;
        }
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_div[n - 1] = r;
 
        if (n == 1)
@@ -417,7 +418,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c
        else
                gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4));
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -425,10 +426,10 @@ static ssize_t set_fan_off(struct i2c_client *client, struct gl520_data *data, c
 {
        u8 r = simple_strtoul(buf, NULL, 10)?1:0;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_off = r;
        gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2));
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -454,10 +455,10 @@ static ssize_t set_temp_max(struct i2c_client *client, struct gl520_data *data,
 {
        long v = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_max[n - 1] = TEMP_TO_REG(v);;
        gl520_write_value(client, reg, data->temp_max[n - 1]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -465,10 +466,10 @@ static ssize_t set_temp_max_hyst(struct i2c_client *client, struct gl520_data *d
 {
        long v = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_max_hyst[n - 1] = TEMP_TO_REG(v);
        gl520_write_value(client, reg, data->temp_max_hyst[n - 1]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -491,10 +492,10 @@ static ssize_t set_beep_enable(struct i2c_client *client, struct gl520_data *dat
 {
        u8 r = simple_strtoul(buf, NULL, 10)?0:1;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->beep_enable = !r;
        gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2));
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -502,11 +503,11 @@ static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data,
 {
        u8 r = simple_strtoul(buf, NULL, 10);
        
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        r &= data->alarm_mask;
        data->beep_mask = r;
        gl520_write_value(client, reg, r);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -561,7 +562,7 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
        /* Fill in the remaining client fields */
        strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -685,7 +686,7 @@ static struct gl520_data *gl520_update_device(struct device *dev)
        struct gl520_data *data = i2c_get_clientdata(client);
        int val;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
 
@@ -750,7 +751,7 @@ static struct gl520_data *gl520_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index 23a9e1ea8e321e218acc42de271e8e157191764f..7636c1a58f9c7ac5a9a1cd9bcf7af5b8d9cecd9a 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/module.h>
 #include <linux/timer.h>
 #include <linux/dmi.h>
+#include <linux/mutex.h>
 #include <asm/io.h>
 
 #define HDAPS_LOW_PORT         0x1600  /* first port used by hdaps */
@@ -70,10 +71,10 @@ static u8 km_activity;
 static int rest_x;
 static int rest_y;
 
-static DECLARE_MUTEX(hdaps_sem);
+static DEFINE_MUTEX(hdaps_mutex);
 
 /*
- * __get_latch - Get the value from a given port.  Callers must hold hdaps_sem.
+ * __get_latch - Get the value from a given port.  Callers must hold hdaps_mutex.
  */
 static inline u8 __get_latch(u16 port)
 {
@@ -82,7 +83,7 @@ static inline u8 __get_latch(u16 port)
 
 /*
  * __check_latch - Check a port latch for a given value.  Returns zero if the
- * port contains the given value.  Callers must hold hdaps_sem.
+ * port contains the given value.  Callers must hold hdaps_mutex.
  */
 static inline int __check_latch(u16 port, u8 val)
 {
@@ -93,7 +94,7 @@ static inline int __check_latch(u16 port, u8 val)
 
 /*
  * __wait_latch - Wait up to 100us for a port latch to get a certain value,
- * returning zero if the value is obtained.  Callers must hold hdaps_sem.
+ * returning zero if the value is obtained.  Callers must hold hdaps_mutex.
  */
 static int __wait_latch(u16 port, u8 val)
 {
@@ -110,7 +111,7 @@ static int __wait_latch(u16 port, u8 val)
 
 /*
  * __device_refresh - request a refresh from the accelerometer.  Does not wait
- * for refresh to complete.  Callers must hold hdaps_sem.
+ * for refresh to complete.  Callers must hold hdaps_mutex.
  */
 static void __device_refresh(void)
 {
@@ -124,7 +125,7 @@ static void __device_refresh(void)
 /*
  * __device_refresh_sync - request a synchronous refresh from the
  * accelerometer.  We wait for the refresh to complete.  Returns zero if
- * successful and nonzero on error.  Callers must hold hdaps_sem.
+ * successful and nonzero on error.  Callers must hold hdaps_mutex.
  */
 static int __device_refresh_sync(void)
 {
@@ -134,7 +135,7 @@ static int __device_refresh_sync(void)
 
 /*
  * __device_complete - indicate to the accelerometer that we are done reading
- * data, and then initiate an async refresh.  Callers must hold hdaps_sem.
+ * data, and then initiate an async refresh.  Callers must hold hdaps_mutex.
  */
 static inline void __device_complete(void)
 {
@@ -152,7 +153,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
 {
        int ret;
 
-       down(&hdaps_sem);
+       mutex_lock(&hdaps_mutex);
 
        /* do a sync refresh -- we need to be sure that we read fresh data */
        ret = __device_refresh_sync();
@@ -163,7 +164,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
        __device_complete();
 
 out:
-       up(&hdaps_sem);
+       mutex_unlock(&hdaps_mutex);
        return ret;
 }
 
@@ -198,9 +199,9 @@ static int hdaps_read_pair(unsigned int port1, unsigned int port2,
 {
        int ret;
 
-       down(&hdaps_sem);
+       mutex_lock(&hdaps_mutex);
        ret = __hdaps_read_pair(port1, port2, val1, val2);
-       up(&hdaps_sem);
+       mutex_unlock(&hdaps_mutex);
 
        return ret;
 }
@@ -213,7 +214,7 @@ static int hdaps_device_init(void)
 {
        int total, ret = -ENXIO;
 
-       down(&hdaps_sem);
+       mutex_lock(&hdaps_mutex);
 
        outb(0x13, 0x1610);
        outb(0x01, 0x161f);
@@ -279,7 +280,7 @@ static int hdaps_device_init(void)
        }
 
 out:
-       up(&hdaps_sem);
+       mutex_unlock(&hdaps_mutex);
        return ret;
 }
 
@@ -313,7 +314,7 @@ static struct platform_driver hdaps_driver = {
 };
 
 /*
- * hdaps_calibrate - Set our "resting" values.  Callers must hold hdaps_sem.
+ * hdaps_calibrate - Set our "resting" values.  Callers must hold hdaps_mutex.
  */
 static void hdaps_calibrate(void)
 {
@@ -325,7 +326,7 @@ static void hdaps_mousedev_poll(unsigned long unused)
        int x, y;
 
        /* Cannot sleep.  Try nonblockingly.  If we fail, try again later. */
-       if (down_trylock(&hdaps_sem)) {
+       if (!mutex_trylock(&hdaps_mutex)) {
                mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD);
                return;
        }
@@ -340,7 +341,7 @@ static void hdaps_mousedev_poll(unsigned long unused)
        mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD);
 
 out:
-       up(&hdaps_sem);
+       mutex_unlock(&hdaps_mutex);
 }
 
 
@@ -420,9 +421,9 @@ static ssize_t hdaps_calibrate_store(struct device *dev,
                                     struct device_attribute *attr,
                                     const char *buf, size_t count)
 {
-       down(&hdaps_sem);
+       mutex_lock(&hdaps_mutex);
        hdaps_calibrate();
-       up(&hdaps_sem);
+       mutex_unlock(&hdaps_mutex);
 
        return count;
 }
index e497274916cec468f26db872be05c76a6051c3c3..a74a44f16f51764e4dad6adff1652a83a7b89720 100644 (file)
     (IMVP-II). You can find more information in the datasheet of Max1718
     http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452
 
+    The 13 specification corresponds to the Intel Pentium M series. There
+    doesn't seem to be any named specification for these. The conversion
+    tables are detailed directly in the various Pentium M datasheets:
+    http://www.intel.com/design/intarch/pentiumm/docs_pentiumm.htm
 */
 
 /* vrm is the VRM/VRD document version multiplied by 10.
@@ -100,6 +104,8 @@ int vid_from_reg(int val, u8 vrm)
        case 17:                /* Intel IMVP-II */
                return(val & 0x10 ? 975 - (val & 0xF) * 25 :
                                    1750 - val * 50);
+       case 13:
+               return(1708 - (val & 0x3f) * 16);
        default:                /* report 0 for unknown */
                printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n");
                return 0;
@@ -129,8 +135,9 @@ struct vrm_model {
 static struct vrm_model vrm_models[] = {
        {X86_VENDOR_AMD, 0x6, ANY, ANY, 90},            /* Athlon Duron etc */
        {X86_VENDOR_AMD, 0xF, ANY, ANY, 24},            /* Athlon 64, Opteron and above VRM 24 */
-       {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85},          /* 0.13um too */
+       {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 13},          /* Pentium M (130 nm) */
        {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85},          /* Tualatin */
+       {X86_VENDOR_INTEL, 0x6, 0xD, ANY, 13},          /* Pentium M (90 nm) */
        {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82},          /* any P6 */
        {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0},           /* Itanium */
        {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90},          /* P4 */
index dddd3eb9b3870ef060e84db9d8db4e099303c71d..106fa01cdb6069717c61ee6a596e94d1ad38bf98 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/idr.h>
 #include <linux/hwmon.h>
 #include <linux/gfp.h>
+#include <linux/spinlock.h>
 
 #define HWMON_ID_PREFIX "hwmon"
 #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d"
@@ -24,6 +25,7 @@
 static struct class *hwmon_class;
 
 static DEFINE_IDR(hwmon_idr);
+static DEFINE_SPINLOCK(idr_lock);
 
 /**
  * hwmon_device_register - register w/ hwmon sysfs class
@@ -37,20 +39,30 @@ static DEFINE_IDR(hwmon_idr);
 struct class_device *hwmon_device_register(struct device *dev)
 {
        struct class_device *cdev;
-       int id;
+       int id, err;
 
-       if (idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0)
+again:
+       if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0))
                return ERR_PTR(-ENOMEM);
 
-       if (idr_get_new(&hwmon_idr, NULL, &id) < 0)
-               return ERR_PTR(-ENOMEM);
+       spin_lock(&idr_lock);
+       err = idr_get_new(&hwmon_idr, NULL, &id);
+       spin_unlock(&idr_lock);
+
+       if (unlikely(err == -EAGAIN))
+               goto again;
+       else if (unlikely(err))
+               return ERR_PTR(err);
 
        id = id & MAX_ID_MASK;
        cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev,
                                        HWMON_ID_FORMAT, id);
 
-       if (IS_ERR(cdev))
+       if (IS_ERR(cdev)) {
+               spin_lock(&idr_lock);
                idr_remove(&hwmon_idr, id);
+               spin_unlock(&idr_lock);
+       }
 
        return cdev;
 }
@@ -64,9 +76,11 @@ void hwmon_device_unregister(struct class_device *cdev)
 {
        int id;
 
-       if (sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1) {
+       if (likely(sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1)) {
                class_device_unregister(cdev);
+               spin_lock(&idr_lock);
                idr_remove(&hwmon_idr, id);
+               spin_unlock(&idr_lock);
        } else
                dev_dbg(cdev->dev,
                        "hwmon_device_unregister() failed: bad class ID!\n");
index d7a9401600bb968ec3f81435734b2f0f618a4284..06df92b3ee492ccbfe3db607e1bd221e65a48b87 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 #include <asm/io.h>
 
 
@@ -194,10 +195,10 @@ static int DIV_TO_REG(int val)
 struct it87_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore lock;
+       struct mutex lock;
        enum chips type;
 
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
 
@@ -224,9 +225,8 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter);
 static int it87_detect(struct i2c_adapter *adapter, int address, int kind);
 static int it87_detach_client(struct i2c_client *client);
 
-static int it87_read_value(struct i2c_client *client, u8 register);
-static int it87_write_value(struct i2c_client *client, u8 register,
-                       u8 value);
+static int it87_read_value(struct i2c_client *client, u8 reg);
+static int it87_write_value(struct i2c_client *client, u8 reg, u8 value);
 static struct it87_data *it87_update_device(struct device *dev);
 static int it87_check_pwm(struct i2c_client *client);
 static void it87_init_client(struct i2c_client *client, struct it87_data *data);
@@ -290,11 +290,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
        struct it87_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[nr] = IN_TO_REG(val);
        it87_write_value(client, IT87_REG_VIN_MIN(nr), 
                        data->in_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
@@ -307,11 +307,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
        struct it87_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[nr] = IN_TO_REG(val);
        it87_write_value(client, IT87_REG_VIN_MAX(nr), 
                        data->in_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -381,10 +381,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
        struct it87_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_high[nr] = TEMP_TO_REG(val);
        it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
@@ -397,10 +397,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
        struct it87_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_low[nr] = TEMP_TO_REG(val);
        it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 #define show_temp_offset(offset)                                       \
@@ -440,7 +440,7 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
        struct it87_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        data->sensor &= ~(1 << nr);
        data->sensor &= ~(8 << nr);
@@ -450,11 +450,11 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
        else if (val == 2)
            data->sensor |= 8 << nr;
        else if (val != 0) {
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
                return -EINVAL;
        }
        it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 #define show_sensor_offset(offset)                                     \
@@ -524,7 +524,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
        int val = simple_strtol(buf, NULL, 10);
        u8 reg = it87_read_value(client, IT87_REG_FAN_DIV);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        switch (nr) {
        case 0: data->fan_div[nr] = reg & 0x07; break;
        case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break;
@@ -533,7 +533,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
 
        data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
        it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
@@ -548,7 +548,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
        int i, min[3];
        u8 old;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        old = it87_read_value(client, IT87_REG_FAN_DIV);
 
        for (i = 0; i < 3; i++)
@@ -576,7 +576,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
                data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i]));
                it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]);
        }
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_pwm_enable(struct device *dev,
@@ -589,7 +589,7 @@ static ssize_t set_pwm_enable(struct device *dev,
        struct it87_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (val == 0) {
                int tmp;
@@ -606,11 +606,11 @@ static ssize_t set_pwm_enable(struct device *dev,
                /* set saved pwm value, clear FAN_CTLX PWM mode bit */
                it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr]));
        } else {
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
                return -EINVAL;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
@@ -626,11 +626,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
        if (val < 0 || val > 255)
                return -EINVAL;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->manual_pwm_ctl[nr] = val;
        if (data->fan_main_ctrl & (1 << nr))
                it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr]));
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -776,7 +776,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
 
        new_client = &data->client;
        if (is_isa)
-               init_MUTEX(&data->lock);
+               mutex_init(&data->lock);
        i2c_set_clientdata(new_client, data);
        new_client->addr = address;
        new_client->adapter = adapter;
@@ -823,7 +823,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->type = kind;
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -950,10 +950,10 @@ static int it87_read_value(struct i2c_client *client, u8 reg)
 
        int res;
        if (i2c_is_isa_client(client)) {
-               down(&data->lock);
+               mutex_lock(&data->lock);
                outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
                res = inb_p(client->addr + IT87_DATA_REG_OFFSET);
-               up(&data->lock);
+               mutex_unlock(&data->lock);
                return res;
        } else
                return i2c_smbus_read_byte_data(client, reg);
@@ -969,10 +969,10 @@ static int it87_write_value(struct i2c_client *client, u8 reg, u8 value)
        struct it87_data *data = i2c_get_clientdata(client);
 
        if (i2c_is_isa_client(client)) {
-               down(&data->lock);
+               mutex_lock(&data->lock);
                outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
                outb_p(value, client->addr + IT87_DATA_REG_OFFSET);
-               up(&data->lock);
+               mutex_unlock(&data->lock);
                return 0;
        } else
                return i2c_smbus_write_byte_data(client, reg, value);
@@ -1098,7 +1098,7 @@ static struct it87_data *it87_update_device(struct device *dev)
        struct it87_data *data = i2c_get_clientdata(client);
        int i;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
            || !data->valid) {
@@ -1160,7 +1160,7 @@ static struct it87_data *it87_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index 6b1aa7ef552e23cc290dfa4ae14d35f4696798e2..071f0fc6adecef40ba8022cd93eacfa7951540d6 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /*
  * Addresses to scan
@@ -153,7 +154,7 @@ static struct i2c_driver lm63_driver = {
 struct lm63_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
 
@@ -192,13 +193,13 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *dummy,
        struct lm63_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan[1] = FAN_TO_REG(val);
        i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB,
                                  data->fan[1] & 0xFF);
        i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB,
                                  data->fan[1] >> 8);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -222,12 +223,12 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
                return -EPERM;
 
        val = simple_strtoul(buf, NULL, 10);
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->pwm1_value = val <= 0 ? 0 :
                           val >= 255 ? 2 * data->pwm1_freq :
                           (val * data->pwm1_freq * 2 + 127) / 255;
        i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -253,10 +254,10 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy,
        struct lm63_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp8[1] = TEMP8_TO_REG(val);
        i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -284,13 +285,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
        long val = simple_strtol(buf, NULL, 10);
        int nr = attr->index;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp11[nr] = TEMP11_TO_REG(val);
        i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
                                  data->temp11[nr] >> 8);
        i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
                                  data->temp11[nr] & 0xff);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -314,11 +315,11 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *
        long val = simple_strtol(buf, NULL, 10);
        long hyst;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        hyst = TEMP8_FROM_REG(data->temp8[2]) - val;
        i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST,
                                  HYST_TO_REG(hyst));
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -427,7 +428,7 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
 
        strlcpy(new_client->name, "lm63", I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -530,7 +531,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct lm63_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
                if (data->config & 0x04) { /* tachometer enabled  */
@@ -582,7 +583,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index 74ca2c8c61c3ae4996a46bcf523dba87b26f2561..fc25b90ec24a5ec5d0cda40cd335ff0bc7e1aa24 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 #include "lm75.h"
 
 
@@ -47,7 +48,7 @@ I2C_CLIENT_INSMOD_1(lm75);
 struct lm75_data {
        struct i2c_client       client;
        struct class_device *class_dev;
-       struct semaphore        update_lock;
+       struct mutex            update_lock;
        char                    valid;          /* !=0 if following fields are valid */
        unsigned long           last_updated;   /* In jiffies */
        u16                     temp_input;     /* Register values */
@@ -91,10 +92,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
        struct lm75_data *data = i2c_get_clientdata(client);    \
        int temp = simple_strtoul(buf, NULL, 10);               \
                                                                \
-       down(&data->update_lock);                               \
+       mutex_lock(&data->update_lock);                         \
        data->value = LM75_TEMP_TO_REG(temp);                   \
        lm75_write_value(client, reg, data->value);             \
-       up(&data->update_lock);                                 \
+       mutex_unlock(&data->update_lock);                                       \
        return count;                                           \
 }
 set(temp_max, LM75_REG_TEMP_OS);
@@ -188,7 +189,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
        /* Fill in the remaining client fields and put it into the global list */
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -264,7 +265,7 @@ static struct lm75_data *lm75_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct lm75_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
            || !data->valid) {
@@ -277,7 +278,7 @@ static struct lm75_data *lm75_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index df9e02aaa70a98703290d079e5b61f1a7b8acbf2..459cc977380a33fc36dbae7bdb968734b1a85cd9 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END };
@@ -51,7 +52,7 @@ I2C_CLIENT_INSMOD_1(lm77);
 struct lm77_data {
        struct i2c_client       client;
        struct class_device *class_dev;
-       struct semaphore        update_lock;
+       struct mutex            update_lock;
        char                    valid;
        unsigned long           last_updated;   /* In jiffies */
        int                     temp_input;     /* Temperatures */
@@ -139,10 +140,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
        struct lm77_data *data = i2c_get_clientdata(client);                    \
        long val = simple_strtoul(buf, NULL, 10);                               \
                                                                                \
-       down(&data->update_lock);                                               \
+       mutex_lock(&data->update_lock);                                         \
        data->value = val;                              \
        lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value));           \
-       up(&data->update_lock);                                                 \
+       mutex_unlock(&data->update_lock);                                       \
        return count;                                                           \
 }
 
@@ -157,11 +158,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev, struct device_attribute *a
        struct lm77_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_hyst = data->temp_crit - val;
        lm77_write_value(client, LM77_REG_TEMP_HYST,
                         LM77_TEMP_TO_REG(data->temp_hyst));
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -173,7 +174,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
        long val = simple_strtoul(buf, NULL, 10);
        int oldcrithyst;
        
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        oldcrithyst = data->temp_crit - data->temp_hyst;
        data->temp_crit = val;
        data->temp_hyst = data->temp_crit - oldcrithyst;
@@ -181,7 +182,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
                         LM77_TEMP_TO_REG(data->temp_crit));
        lm77_write_value(client, LM77_REG_TEMP_HYST,
                         LM77_TEMP_TO_REG(data->temp_hyst));
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -306,7 +307,7 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
        /* Fill in the remaining client fields and put it into the global list */
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -380,7 +381,7 @@ static struct lm77_data *lm77_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct lm77_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
            || !data->valid) {
@@ -406,7 +407,7 @@ static struct lm77_data *lm77_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index e404001e20daaee2b8f9e9aaaa387f170c6df389..94be3d797e611a7817b84304764db6a7d7714c18 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 #include <asm/io.h>
 
 /* Addresses to scan */
@@ -131,10 +132,10 @@ static inline int TEMP_FROM_REG(s8 val)
 struct lm78_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore lock;
+       struct mutex lock;
        enum chips type;
 
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
 
@@ -157,8 +158,8 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter);
 static int lm78_detect(struct i2c_adapter *adapter, int address, int kind);
 static int lm78_detach_client(struct i2c_client *client);
 
-static int lm78_read_value(struct i2c_client *client, u8 register);
-static int lm78_write_value(struct i2c_client *client, u8 register, u8 value);
+static int lm78_read_value(struct i2c_client *client, u8 reg);
+static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value);
 static struct lm78_data *lm78_update_device(struct device *dev);
 static void lm78_init_client(struct i2c_client *client);
 
@@ -207,10 +208,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
        struct lm78_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[nr] = IN_TO_REG(val);
        lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -221,10 +222,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
        struct lm78_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[nr] = IN_TO_REG(val);
        lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
        
@@ -288,10 +289,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
        struct lm78_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_over = TEMP_TO_REG(val);
        lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -307,10 +308,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
        struct lm78_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_hyst = TEMP_TO_REG(val);
        lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -342,10 +343,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
        struct lm78_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
        lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -368,7 +369,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        unsigned long min;
        u8 reg;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        min = FAN_FROM_REG(data->fan_min[nr],
                           DIV_FROM_REG(data->fan_div[nr]));
 
@@ -380,7 +381,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        default:
                dev_err(&client->dev, "fan_div value %ld not "
                        "supported. Choose one of 1, 2, 4 or 8!\n", val);
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
                return -EINVAL;
        }
 
@@ -398,7 +399,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        data->fan_min[nr] =
                FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
        lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
@@ -548,7 +549,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
 
        new_client = &data->client;
        if (is_isa)
-               init_MUTEX(&data->lock);
+               mutex_init(&data->lock);
        i2c_set_clientdata(new_client, data);
        new_client->addr = address;
        new_client->adapter = adapter;
@@ -598,7 +599,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
        data->type = kind;
 
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -697,10 +698,10 @@ static int lm78_read_value(struct i2c_client *client, u8 reg)
        int res;
        if (i2c_is_isa_client(client)) {
                struct lm78_data *data = i2c_get_clientdata(client);
-               down(&data->lock);
+               mutex_lock(&data->lock);
                outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
                res = inb_p(client->addr + LM78_DATA_REG_OFFSET);
-               up(&data->lock);
+               mutex_unlock(&data->lock);
                return res;
        } else
                return i2c_smbus_read_byte_data(client, reg);
@@ -717,10 +718,10 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
 {
        if (i2c_is_isa_client(client)) {
                struct lm78_data *data = i2c_get_clientdata(client);
-               down(&data->lock);
+               mutex_lock(&data->lock);
                outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
                outb_p(value, client->addr + LM78_DATA_REG_OFFSET);
-               up(&data->lock);
+               mutex_unlock(&data->lock);
                return 0;
        } else
                return i2c_smbus_write_byte_data(client, reg, value);
@@ -742,7 +743,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
        struct lm78_data *data = i2c_get_clientdata(client);
        int i;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
            || !data->valid) {
@@ -786,7 +787,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
                data->fan_div[2] = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index c9a7cdea7bd722a6412595f098e9687c3f656cbd..f72120d08c4ced3f377181a9a5b020f3d9353255 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
@@ -108,7 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp)
 struct lm80_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
 
@@ -191,10 +192,10 @@ static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr
        struct lm80_data *data = i2c_get_clientdata(client); \
        long val = simple_strtol(buf, NULL, 10); \
  \
-       down(&data->update_lock);\
+       mutex_lock(&data->update_lock);\
        data->value = IN_TO_REG(val); \
        lm80_write_value(client, reg, data->value); \
-       up(&data->update_lock);\
+       mutex_unlock(&data->update_lock);\
        return count; \
 }
 set_in(min0, in_min[0], LM80_REG_IN_MIN(0));
@@ -241,10 +242,10 @@ static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *att
        struct lm80_data *data = i2c_get_clientdata(client); \
        long val = simple_strtoul(buf, NULL, 10); \
  \
-       down(&data->update_lock);\
+       mutex_lock(&data->update_lock);\
        data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \
        lm80_write_value(client, reg, data->value); \
-       up(&data->update_lock);\
+       mutex_unlock(&data->update_lock);\
        return count; \
 }
 set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]);
@@ -263,7 +264,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        u8 reg;
 
        /* Save fan_min */
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        min = FAN_FROM_REG(data->fan_min[nr],
                           DIV_FROM_REG(data->fan_div[nr]));
 
@@ -275,7 +276,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        default:
                dev_err(&client->dev, "fan_div value %ld not "
                        "supported. Choose one of 1, 2, 4 or 8!\n", val);
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
                return -EINVAL;
        }
 
@@ -286,7 +287,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        /* Restore fan_min */
        data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
        lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
@@ -325,10 +326,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at
        struct lm80_data *data = i2c_get_clientdata(client); \
        long val = simple_strtoul(buf, NULL, 10); \
  \
-       down(&data->update_lock); \
+       mutex_lock(&data->update_lock); \
        data->value = TEMP_LIMIT_TO_REG(val); \
        lm80_write_value(client, reg, data->value); \
-       up(&data->update_lock); \
+       mutex_unlock(&data->update_lock); \
        return count; \
 }
 set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX);
@@ -437,7 +438,7 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
        /* Fill in the remaining client fields and put it into the global list */
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -545,7 +546,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
        struct lm80_data *data = i2c_get_clientdata(client);
        int i;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
                dev_dbg(&client->dev, "Starting lm80 update\n");
@@ -585,7 +586,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index 26dfa9e216c2814f9419b318ed8289e46f6b8a21..aac4ec2bf69499c79cc70ed4229c75e1ae08d272 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /*
  * Addresses to scan
@@ -139,7 +140,7 @@ static struct i2c_driver lm83_driver = {
 struct lm83_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
 
@@ -171,11 +172,11 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
        long val = simple_strtol(buf, NULL, 10);
        int nr = attr->index;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp[nr] = TEMP_TO_REG(val);
        i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4],
                                  data->temp[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -300,7 +301,7 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
        /* We can fill in the remaining client fields */
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -373,7 +374,7 @@ static struct lm83_data *lm83_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct lm83_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
                int nr;
@@ -393,7 +394,7 @@ static struct lm83_data *lm83_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index 7389a0127547cef2e49d66b5f6cee5fc645b0048..342e9663119d45ef9d7c14a9ab240110ca554523 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /* Addresses to scan */
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -331,10 +332,10 @@ struct lm85_autofan {
 struct lm85_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore lock;
+       struct mutex lock;
        enum chips type;
 
-       struct semaphore update_lock;
+       struct mutex update_lock;
        int valid;              /* !=0 if following fields are valid */
        unsigned long last_reading;     /* In jiffies */
        unsigned long last_config;      /* In jiffies */
@@ -373,8 +374,8 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
                        int kind);
 static int lm85_detach_client(struct i2c_client *client);
 
-static int lm85_read_value(struct i2c_client *client, u8 register);
-static int lm85_write_value(struct i2c_client *client, u8 register, int value);
+static int lm85_read_value(struct i2c_client *client, u8 reg);
+static int lm85_write_value(struct i2c_client *client, u8 reg, int value);
 static struct lm85_data *lm85_update_device(struct device *dev);
 static void lm85_init_client(struct i2c_client *client);
 
@@ -407,10 +408,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_min[nr] = FAN_TO_REG(val);
        lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -499,10 +500,10 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->pwm[nr] = PWM_TO_REG(val);
        lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr)
@@ -559,10 +560,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[nr] = INS_TO_REG(nr, val);
        lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_in_max(struct device *dev, char *buf, int nr)
@@ -577,10 +578,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[nr] = INS_TO_REG(nr, val);
        lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 #define show_in_reg(offset)                                            \
@@ -640,10 +641,10 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_min[nr] = TEMP_TO_REG(val);
        lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
@@ -658,10 +659,10 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);        
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_max[nr] = TEMP_TO_REG(val);
        lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 #define show_temp_reg(offset)                                          \
@@ -713,12 +714,12 @@ static ssize_t set_pwm_auto_channels(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);   
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->autofan[nr].config = (data->autofan[nr].config & (~0xe0))
                | ZONE_TO_REG(val) ;
        lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr),
                data->autofan[nr].config);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr)
@@ -733,11 +734,11 @@ static ssize_t set_pwm_auto_pwm_min(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->autofan[nr].min_pwm = PWM_TO_REG(val);
        lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr),
                data->autofan[nr].min_pwm);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr)
@@ -752,7 +753,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->autofan[nr].min_off = val;
        lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0]
                | data->syncpwm3
@@ -760,7 +761,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
                | (data->autofan[1].min_off ? 0x40 : 0)
                | (data->autofan[2].min_off ? 0x80 : 0)
        );
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr)
@@ -775,13 +776,13 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->autofan[nr].freq = FREQ_TO_REG(val);
        lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
                (data->zone[nr].range << 4)
                | data->autofan[nr].freq
        ); 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 #define pwm_auto(offset)                                               \
@@ -857,7 +858,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
        int min;
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        min = TEMP_FROM_REG(data->zone[nr].limit);
        data->zone[nr].off_desired = TEMP_TO_REG(val);
        data->zone[nr].hyst = HYST_TO_REG(min - val);
@@ -871,7 +872,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
                        (data->zone[2].hyst << 4)
                );
        }
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr)
@@ -886,7 +887,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->zone[nr].limit = TEMP_TO_REG(val);
        lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr),
                data->zone[nr].limit);
@@ -913,7 +914,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
                        (data->zone[2].hyst << 4)
                );
        }
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr)
@@ -930,7 +931,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
        int min;
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        min = TEMP_FROM_REG(data->zone[nr].limit);
        data->zone[nr].max_desired = TEMP_TO_REG(val);
        data->zone[nr].range = RANGE_TO_REG(
@@ -938,7 +939,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
        lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
                ((data->zone[nr].range & 0x0f) << 4)
                | (data->autofan[nr].freq & 0x07));
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr)
@@ -953,11 +954,11 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf,
        struct lm85_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->zone[nr].critical = TEMP_TO_REG(val);
        lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr),
                data->zone[nr].critical);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 #define temp_auto(offset)                                              \
@@ -1149,7 +1150,7 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
        /* Fill in the remaining client fields */
        data->type = kind;
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -1368,7 +1369,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
        struct lm85_data *data = i2c_get_clientdata(client);
        int i;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if ( !data->valid ||
             time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) {
@@ -1571,7 +1572,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
 
        data->valid = 1;
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index 6ba34c302d8d3315f53f038af876f152d16ad055..e229daf666dedf4584f6617f3e5364c301cb5d34 100644 (file)
@@ -60,6 +60,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /*
  * Addresses to scan
@@ -176,7 +177,7 @@ static struct i2c_driver lm87_driver = {
 struct lm87_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* In jiffies */
 
@@ -253,11 +254,11 @@ static void set_in_min(struct device *dev, const char *buf, int nr)
        struct lm87_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]);
        lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) :
                         LM87_REG_AIN_MIN(nr-6), data->in_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 }
 
 static void set_in_max(struct device *dev, const char *buf, int nr)
@@ -266,11 +267,11 @@ static void set_in_max(struct device *dev, const char *buf, int nr)
        struct lm87_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]);
        lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) :
                         LM87_REG_AIN_MAX(nr-6), data->in_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 }
 
 #define set_in(offset) \
@@ -327,10 +328,10 @@ static void set_temp_low(struct device *dev, const char *buf, int nr)
        struct lm87_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_low[nr] = TEMP_TO_REG(val);
        lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 }
 
 static void set_temp_high(struct device *dev, const char *buf, int nr)
@@ -339,10 +340,10 @@ static void set_temp_high(struct device *dev, const char *buf, int nr)
        struct lm87_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_high[nr] = TEMP_TO_REG(val);
        lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 }
 
 #define set_temp(offset) \
@@ -411,11 +412,11 @@ static void set_fan_min(struct device *dev, const char *buf, int nr)
        struct lm87_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_min[nr] = FAN_TO_REG(val,
                            FAN_DIV_FROM_REG(data->fan_div[nr]));
        lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 }
 
 /* Note: we save and restore the fan minimum here, because its value is
@@ -431,7 +432,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        unsigned long min;
        u8 reg;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        min = FAN_FROM_REG(data->fan_min[nr],
                           FAN_DIV_FROM_REG(data->fan_div[nr]));
 
@@ -441,7 +442,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        case 4: data->fan_div[nr] = 2; break;
        case 8: data->fan_div[nr] = 3; break;
        default:
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
                return -EINVAL;
        }
 
@@ -459,7 +460,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        data->fan_min[nr] = FAN_TO_REG(min, val);
        lm87_write_value(client, LM87_REG_FAN_MIN(nr),
                         data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
@@ -522,10 +523,10 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const
        struct lm87_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->aout = AOUT_TO_REG(val);
        lm87_write_value(client, LM87_REG_AOUT, data->aout);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
@@ -589,7 +590,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
        /* We can fill in the remaining client fields */
        strlcpy(new_client->name, "lm87", I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -744,7 +745,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct lm87_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
                int i, j;
@@ -813,7 +814,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index 5679464447cc0140bbeddf6ac07897301cc1f22d..d9eeaf7585bd3be3d171ba2d8f33a3b9393564e3 100644 (file)
@@ -78,6 +78,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /*
  * Addresses to scan
@@ -201,7 +202,7 @@ static struct i2c_driver lm90_driver = {
 struct lm90_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
        int kind;
@@ -247,13 +248,13 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
        long val = simple_strtol(buf, NULL, 10);
        int nr = attr->index;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        if (data->kind == adt7461)
                data->temp8[nr] = TEMP1_TO_REG_ADT7461(val);
        else
                data->temp8[nr] = TEMP1_TO_REG(val);
        i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -281,7 +282,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
        long val = simple_strtol(buf, NULL, 10);
        int nr = attr->index;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        if (data->kind == adt7461)
                data->temp11[nr] = TEMP2_TO_REG_ADT7461(val);
        else
@@ -290,7 +291,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
                                  data->temp11[nr] >> 8);
        i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
                                  data->temp11[nr] & 0xff);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -311,11 +312,11 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,
        long val = simple_strtol(buf, NULL, 10);
        long hyst;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        hyst = TEMP1_FROM_REG(data->temp8[3]) - val;
        i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST,
                                  HYST_TO_REG(hyst));
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -558,7 +559,7 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->valid = 0;
        data->kind = kind;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -646,7 +647,7 @@ static struct lm90_data *lm90_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct lm90_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
                u8 oldh, newh, l;
@@ -692,7 +693,7 @@ static struct lm90_data *lm90_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index b0c4cb730a7e1b724eb8720b1fcfe6caffa7e1bc..197f77226dc478a4d440700659d46d06da90e74d 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 /* The LM92 and MAX6635 have 2 two-state pins for address selection,
    resulting in 4 possible addresses. */
@@ -96,7 +97,7 @@ static struct i2c_driver lm92_driver;
 struct lm92_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
 
@@ -114,7 +115,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct lm92_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ)
         || !data->valid) {
@@ -134,7 +135,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
@@ -158,10 +159,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
        struct lm92_data *data = i2c_get_clientdata(client); \
        long val = simple_strtol(buf, NULL, 10); \
  \
-       down(&data->update_lock); \
+       mutex_lock(&data->update_lock); \
        data->value = TEMP_TO_REG(val); \
        i2c_smbus_write_word_data(client, reg, swab16(data->value)); \
-       up(&data->update_lock); \
+       mutex_unlock(&data->update_lock); \
        return count; \
 }
 set_temp(temp1_crit, LM92_REG_TEMP_CRIT);
@@ -194,11 +195,11 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *
        struct lm92_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val;
        i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST,
                                  swab16(TEMP_TO_REG(data->temp1_hyst)));
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -348,7 +349,7 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
        /* Fill in the remaining client fields */
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the i2c subsystem a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
index 3abe330b22ce1d8b3d32a15618cf0926c3084c84..b4135b5971f4d67d25404532c75c9472132f4ff2 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 
 static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
                                        0x29, 0x2a, 0x2b,
@@ -104,7 +105,7 @@ static struct i2c_driver max1619_driver = {
 struct max1619_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid; /* zero until following fields are valid */
        unsigned long last_updated; /* in jiffies */
 
@@ -141,10 +142,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
        struct max1619_data *data = i2c_get_clientdata(client); \
        long val = simple_strtol(buf, NULL, 10); \
  \
-       down(&data->update_lock); \
+       mutex_lock(&data->update_lock); \
        data->value = TEMP_TO_REG(val); \
        i2c_smbus_write_byte_data(client, reg, data->value); \
-       up(&data->update_lock); \
+       mutex_unlock(&data->update_lock); \
        return count; \
 }
 
@@ -262,7 +263,7 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
        /* We can fill in the remaining client fields */
        strlcpy(new_client->name, name, I2C_NAME_SIZE);
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(new_client)))
@@ -330,7 +331,7 @@ static struct max1619_data *max1619_update_device(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct max1619_data *data = i2c_get_clientdata(client);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
                dev_dbg(&client->dev, "Updating max1619 data.\n");
@@ -353,7 +354,7 @@ static struct max1619_data *max1619_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index f161e88e3bb67db35cc0bcf2fd88fadf89c6044a..ae05e483a77877673ea47825960d955e4c2162c7 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 #include <asm/io.h>
 
 static u8 devid;
@@ -183,8 +184,8 @@ static inline u8 PWM_TO_REG(int val, int inv)
 struct pc87360_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore lock;
-       struct semaphore update_lock;
+       struct mutex lock;
+       struct mutex update_lock;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
 
@@ -283,7 +284,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr,
        struct pc87360_data *data = i2c_get_clientdata(client);
        long fan_min = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index]));
 
        /* If it wouldn't fit, change clock divisor */
@@ -300,23 +301,31 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr,
        /* Write new divider, preserve alarm bits */
        pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index),
                            data->fan_status[attr->index] & 0xF9);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return count;
 }
 
-#define show_and_set_fan(offset) \
-static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
-       show_fan_input, NULL, offset-1); \
-static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \
-       show_fan_min, set_fan_min, offset-1); \
-static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
-       show_fan_div, NULL, offset-1); \
-static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \
-       show_fan_status, NULL, offset-1);
-show_and_set_fan(1)
-show_and_set_fan(2)
-show_and_set_fan(3)
+static struct sensor_device_attribute fan_input[] = {
+       SENSOR_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0),
+       SENSOR_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1),
+       SENSOR_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2),
+};
+static struct sensor_device_attribute fan_status[] = {
+       SENSOR_ATTR(fan1_status, S_IRUGO, show_fan_status, NULL, 0),
+       SENSOR_ATTR(fan2_status, S_IRUGO, show_fan_status, NULL, 1),
+       SENSOR_ATTR(fan3_status, S_IRUGO, show_fan_status, NULL, 2),
+};
+static struct sensor_device_attribute fan_div[] = {
+       SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0),
+       SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1),
+       SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2),
+};
+static struct sensor_device_attribute fan_min[] = {
+       SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 0),
+       SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 1),
+       SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2),
+};
 
 static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf)
 {
@@ -335,21 +344,20 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, con
        struct pc87360_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->pwm[attr->index] = PWM_TO_REG(val,
                              FAN_CONFIG_INVERT(data->fan_conf, attr->index));
        pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index),
                            data->pwm[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
-#define show_and_set_pwm(offset) \
-static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \
-       show_pwm, set_pwm, offset-1);
-show_and_set_pwm(1)
-show_and_set_pwm(2)
-show_and_set_pwm(3)
+static struct sensor_device_attribute pwm[] = {
+       SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0),
+       SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1),
+       SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2),
+};
 
 static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf)
 {
@@ -386,11 +394,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr,
        struct pc87360_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
        pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN,
                            data->in_min[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -401,35 +409,67 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr,
        struct pc87360_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[attr->index] = IN_TO_REG(val,
                               data->in_vref);
        pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX,
                            data->in_max[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
-#define show_and_set_in(offset) \
-static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
-       show_in_input, NULL, offset); \
-static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
-       show_in_min, set_in_min, offset); \
-static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \
-       show_in_max, set_in_max, offset); \
-static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \
-       show_in_status, NULL, offset);
-show_and_set_in(0)
-show_and_set_in(1)
-show_and_set_in(2)
-show_and_set_in(3)
-show_and_set_in(4)
-show_and_set_in(5)
-show_and_set_in(6)
-show_and_set_in(7)
-show_and_set_in(8)
-show_and_set_in(9)
-show_and_set_in(10)
+static struct sensor_device_attribute in_input[] = {
+       SENSOR_ATTR(in0_input, S_IRUGO, show_in_input, NULL, 0),
+       SENSOR_ATTR(in1_input, S_IRUGO, show_in_input, NULL, 1),
+       SENSOR_ATTR(in2_input, S_IRUGO, show_in_input, NULL, 2),
+       SENSOR_ATTR(in3_input, S_IRUGO, show_in_input, NULL, 3),
+       SENSOR_ATTR(in4_input, S_IRUGO, show_in_input, NULL, 4),
+       SENSOR_ATTR(in5_input, S_IRUGO, show_in_input, NULL, 5),
+       SENSOR_ATTR(in6_input, S_IRUGO, show_in_input, NULL, 6),
+       SENSOR_ATTR(in7_input, S_IRUGO, show_in_input, NULL, 7),
+       SENSOR_ATTR(in8_input, S_IRUGO, show_in_input, NULL, 8),
+       SENSOR_ATTR(in9_input, S_IRUGO, show_in_input, NULL, 9),
+       SENSOR_ATTR(in10_input, S_IRUGO, show_in_input, NULL, 10),
+};
+static struct sensor_device_attribute in_status[] = {
+       SENSOR_ATTR(in0_status, S_IRUGO, show_in_status, NULL, 0),
+       SENSOR_ATTR(in1_status, S_IRUGO, show_in_status, NULL, 1),
+       SENSOR_ATTR(in2_status, S_IRUGO, show_in_status, NULL, 2),
+       SENSOR_ATTR(in3_status, S_IRUGO, show_in_status, NULL, 3),
+       SENSOR_ATTR(in4_status, S_IRUGO, show_in_status, NULL, 4),
+       SENSOR_ATTR(in5_status, S_IRUGO, show_in_status, NULL, 5),
+       SENSOR_ATTR(in6_status, S_IRUGO, show_in_status, NULL, 6),
+       SENSOR_ATTR(in7_status, S_IRUGO, show_in_status, NULL, 7),
+       SENSOR_ATTR(in8_status, S_IRUGO, show_in_status, NULL, 8),
+       SENSOR_ATTR(in9_status, S_IRUGO, show_in_status, NULL, 9),
+       SENSOR_ATTR(in10_status, S_IRUGO, show_in_status, NULL, 10),
+};
+static struct sensor_device_attribute in_min[] = {
+       SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 0),
+       SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 1),
+       SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 2),
+       SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 3),
+       SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 4),
+       SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 5),
+       SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 6),
+       SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 7),
+       SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 8),
+       SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 9),
+       SENSOR_ATTR(in10_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 10),
+};
+static struct sensor_device_attribute in_max[] = {
+       SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 0),
+       SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 1),
+       SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 2),
+       SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 3),
+       SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 4),
+       SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 5),
+       SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 6),
+       SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 7),
+       SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 8),
+       SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 9),
+       SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10),
+};
 
 static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf)
 {
@@ -473,11 +513,11 @@ static ssize_t set_therm_min(struct device *dev, struct device_attribute *devatt
        struct pc87360_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
        pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN,
                            data->in_min[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -488,11 +528,11 @@ static ssize_t set_therm_max(struct device *dev, struct device_attribute *devatt
        struct pc87360_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[attr->index] = IN_TO_REG(val, data->in_vref);
        pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX,
                            data->in_max[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -503,28 +543,51 @@ static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devat
        struct pc87360_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref);
        pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT,
                            data->in_crit[attr->index-11]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
-#define show_and_set_therm(offset) \
-static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
-       show_therm_input, NULL, 11+offset-4); \
-static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
-       show_therm_min, set_therm_min, 11+offset-4); \
-static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
-       show_therm_max, set_therm_max, 11+offset-4); \
-static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
-       show_therm_crit, set_therm_crit, 11+offset-4); \
-static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
-       show_therm_status, NULL, 11+offset-4);
-show_and_set_therm(4)
-show_and_set_therm(5)
-show_and_set_therm(6)
+/* the +11 term below reflects the fact that VLM units 11,12,13 are
+   used in the chip to measure voltage across the thermistors
+*/
+static struct sensor_device_attribute therm_input[] = {
+       SENSOR_ATTR(temp4_input, S_IRUGO, show_therm_input, NULL, 0+11),
+       SENSOR_ATTR(temp5_input, S_IRUGO, show_therm_input, NULL, 1+11),
+       SENSOR_ATTR(temp6_input, S_IRUGO, show_therm_input, NULL, 2+11),
+};
+static struct sensor_device_attribute therm_status[] = {
+       SENSOR_ATTR(temp4_status, S_IRUGO, show_therm_status, NULL, 0+11),
+       SENSOR_ATTR(temp5_status, S_IRUGO, show_therm_status, NULL, 1+11),
+       SENSOR_ATTR(temp6_status, S_IRUGO, show_therm_status, NULL, 2+11),
+};
+static struct sensor_device_attribute therm_min[] = {
+       SENSOR_ATTR(temp4_min, S_IRUGO | S_IWUSR,
+                   show_therm_min, set_therm_min, 0+11),
+       SENSOR_ATTR(temp5_min, S_IRUGO | S_IWUSR,
+                   show_therm_min, set_therm_min, 1+11),
+       SENSOR_ATTR(temp6_min, S_IRUGO | S_IWUSR,
+                   show_therm_min, set_therm_min, 2+11),
+};
+static struct sensor_device_attribute therm_max[] = {
+       SENSOR_ATTR(temp4_max, S_IRUGO | S_IWUSR,
+                   show_therm_max, set_therm_max, 0+11),
+       SENSOR_ATTR(temp5_max, S_IRUGO | S_IWUSR,
+                   show_therm_max, set_therm_max, 1+11),
+       SENSOR_ATTR(temp6_max, S_IRUGO | S_IWUSR,
+                   show_therm_max, set_therm_max, 2+11),
+};
+static struct sensor_device_attribute therm_crit[] = {
+       SENSOR_ATTR(temp4_crit, S_IRUGO | S_IWUSR,
+                   show_therm_crit, set_therm_crit, 0+11),
+       SENSOR_ATTR(temp5_crit, S_IRUGO | S_IWUSR,
+                   show_therm_crit, set_therm_crit, 1+11),
+       SENSOR_ATTR(temp6_crit, S_IRUGO | S_IWUSR,
+                   show_therm_crit, set_therm_crit, 2+11),
+};
 
 static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -592,11 +655,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr
        struct pc87360_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_min[attr->index] = TEMP_TO_REG(val);
        pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN,
                            data->temp_min[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -607,11 +670,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr
        struct pc87360_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_max[attr->index] = TEMP_TO_REG(val);
        pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX,
                            data->temp_max[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -622,28 +685,48 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devatt
        struct pc87360_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_crit[attr->index] = TEMP_TO_REG(val);
        pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT,
                            data->temp_crit[attr->index]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
-#define show_and_set_temp(offset) \
-static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
-       show_temp_input, NULL, offset-1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
-       show_temp_min, set_temp_min, offset-1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
-       show_temp_max, set_temp_max, offset-1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
-       show_temp_crit, set_temp_crit, offset-1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
-       show_temp_status, NULL, offset-1);
-show_and_set_temp(1)
-show_and_set_temp(2)
-show_and_set_temp(3)
+static struct sensor_device_attribute temp_input[] = {
+       SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0),
+       SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1),
+       SENSOR_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2),
+};
+static struct sensor_device_attribute temp_status[] = {
+       SENSOR_ATTR(temp1_status, S_IRUGO, show_temp_status, NULL, 0),
+       SENSOR_ATTR(temp2_status, S_IRUGO, show_temp_status, NULL, 1),
+       SENSOR_ATTR(temp3_status, S_IRUGO, show_temp_status, NULL, 2),
+};
+static struct sensor_device_attribute temp_min[] = {
+       SENSOR_ATTR(temp1_min, S_IRUGO | S_IWUSR,
+                   show_temp_min, set_temp_min, 0),
+       SENSOR_ATTR(temp2_min, S_IRUGO | S_IWUSR,
+                   show_temp_min, set_temp_min, 1),
+       SENSOR_ATTR(temp3_min, S_IRUGO | S_IWUSR,
+                   show_temp_min, set_temp_min, 2),
+};
+static struct sensor_device_attribute temp_max[] = {
+       SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR,
+                   show_temp_max, set_temp_max, 0),
+       SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR,
+                   show_temp_max, set_temp_max, 1),
+       SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR,
+                   show_temp_max, set_temp_max, 2),
+};
+static struct sensor_device_attribute temp_crit[] = {
+       SENSOR_ATTR(temp1_crit, S_IRUGO | S_IWUSR,
+                   show_temp_crit, set_temp_crit, 0),
+       SENSOR_ATTR(temp2_crit, S_IRUGO | S_IWUSR,
+                   show_temp_crit, set_temp_crit, 1),
+       SENSOR_ATTR(temp3_crit, S_IRUGO | S_IWUSR,
+                   show_temp_crit, set_temp_crit, 2),
+};
 
 static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -749,22 +832,24 @@ static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses
 static int pc87360_detect(struct i2c_adapter *adapter)
 {
        int i;
-       struct i2c_client *new_client;
+       struct i2c_client *client;
        struct pc87360_data *data;
        int err = 0;
        const char *name = "pc87360";
        int use_thermistors = 0;
+       struct device *dev;
 
        if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
                return -ENOMEM;
 
-       new_client = &data->client;
-       i2c_set_clientdata(new_client, data);
-       new_client->addr = address;
-       init_MUTEX(&data->lock);
-       new_client->adapter = adapter;
-       new_client->driver = &pc87360_driver;
-       new_client->flags = 0;
+       client = &data->client;
+       dev = &client->dev;
+       i2c_set_clientdata(client, data);
+       client->addr = address;
+       mutex_init(&data->lock);
+       client->adapter = adapter;
+       client->driver = &pc87360_driver;
+       client->flags = 0;
 
        data->fannr = 2;
        data->innr = 0;
@@ -792,15 +877,15 @@ static int pc87360_detect(struct i2c_adapter *adapter)
                break;
        }
 
-       strcpy(new_client->name, name);
+       strlcpy(client->name, name, sizeof(client->name));
        data->valid = 0;
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        for (i = 0; i < 3; i++) {
                if (((data->address[i] = extra_isa[i]))
                 && !request_region(extra_isa[i], PC87360_EXTENT,
                                    pc87360_driver.driver.name)) {
-                       dev_err(&new_client->dev, "Region 0x%x-0x%x already "
+                       dev_err(&client->dev, "Region 0x%x-0x%x already "
                                "in use!\n", extra_isa[i],
                                extra_isa[i]+PC87360_EXTENT-1);
                        for (i--; i >= 0; i--)
@@ -814,7 +899,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
        if (data->fannr)
                data->fan_conf = confreg[0] | (confreg[1] << 8);
 
-       if ((err = i2c_attach_client(new_client)))
+       if ((err = i2c_attach_client(client)))
                goto ERROR2;
 
        /* Use the correct reference voltage
@@ -828,7 +913,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
                                                PC87365_REG_TEMP_CONFIG);
                }
                data->in_vref = (i&0x02) ? 3025 : 2966;
-               dev_dbg(&new_client->dev, "Using %s reference voltage\n",
+               dev_dbg(&client->dev, "Using %s reference voltage\n",
                        (i&0x02) ? "external" : "internal");
 
                data->vid_conf = confreg[3];
@@ -847,154 +932,64 @@ static int pc87360_detect(struct i2c_adapter *adapter)
                if (devid == 0xe9 && data->address[1]) /* PC87366 */
                        use_thermistors = confreg[2] & 0x40;
 
-               pc87360_init_client(new_client, use_thermistors);
+               pc87360_init_client(client, use_thermistors);
        }
 
        /* Register sysfs hooks */
-       data->class_dev = hwmon_device_register(&new_client->dev);
+       data->class_dev = hwmon_device_register(&client->dev);
        if (IS_ERR(data->class_dev)) {
                err = PTR_ERR(data->class_dev);
                goto ERROR3;
        }
 
        if (data->innr) {
-               device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in0_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in1_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in2_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in3_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in4_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in5_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in6_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in7_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in8_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in9_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_in10_status.dev_attr);
-
-               device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
-               device_create_file(&new_client->dev, &dev_attr_vrm);
-               device_create_file(&new_client->dev, &dev_attr_alarms_in);
+               for (i = 0; i < 11; i++) {
+                       device_create_file(dev, &in_input[i].dev_attr);
+                       device_create_file(dev, &in_min[i].dev_attr);
+                       device_create_file(dev, &in_max[i].dev_attr);
+                       device_create_file(dev, &in_status[i].dev_attr);
+               }
+               device_create_file(dev, &dev_attr_cpu0_vid);
+               device_create_file(dev, &dev_attr_vrm);
+               device_create_file(dev, &dev_attr_alarms_in);
        }
 
        if (data->tempnr) {
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp1_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp2_status.dev_attr);
-
-               device_create_file(&new_client->dev, &dev_attr_alarms_temp);
-       }
-       if (data->tempnr == 3) {
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp3_status.dev_attr);
-       }
-       if (data->innr == 14) {
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp4_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp5_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp6_input.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp4_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp5_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp6_min.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp4_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp5_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp6_max.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp4_crit.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp5_crit.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp6_crit.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp4_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp5_status.dev_attr);
-               device_create_file(&new_client->dev, &sensor_dev_attr_temp6_status.dev_attr);
-       }
-
-       if (data->fannr) {
-               if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) {
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan1_input.dev_attr);
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan1_min.dev_attr);
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan1_div.dev_attr);
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan1_status.dev_attr);
+               for (i = 0; i < data->tempnr; i++) {
+                       device_create_file(dev, &temp_input[i].dev_attr);
+                       device_create_file(dev, &temp_min[i].dev_attr);
+                       device_create_file(dev, &temp_max[i].dev_attr);
+                       device_create_file(dev, &temp_crit[i].dev_attr);
+                       device_create_file(dev, &temp_status[i].dev_attr);
                }
+               device_create_file(dev, &dev_attr_alarms_temp);
+       }
 
-               if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) {
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan2_input.dev_attr);
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan2_min.dev_attr);
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan2_div.dev_attr);
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan2_status.dev_attr);
+       if (data->innr == 14) {
+               for (i = 0; i < 3; i++) {
+                       device_create_file(dev, &therm_input[i].dev_attr);
+                       device_create_file(dev, &therm_min[i].dev_attr);
+                       device_create_file(dev, &therm_max[i].dev_attr);
+                       device_create_file(dev, &therm_crit[i].dev_attr);
+                       device_create_file(dev, &therm_status[i].dev_attr);
                }
-
-               if (FAN_CONFIG_CONTROL(data->fan_conf, 0))
-                       device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr);
-               if (FAN_CONFIG_CONTROL(data->fan_conf, 1))
-                       device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr);
        }
-       if (data->fannr == 3) {
-               if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) {
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan3_input.dev_attr);
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan3_min.dev_attr);
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan3_div.dev_attr);
-                       device_create_file(&new_client->dev,
-                                          &sensor_dev_attr_fan3_status.dev_attr);
-               }
 
-               if (FAN_CONFIG_CONTROL(data->fan_conf, 2))
-                       device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr);
+       for (i = 0; i < data->fannr; i++) {
+               if (FAN_CONFIG_MONITOR(data->fan_conf, i)) {
+                       device_create_file(dev, &fan_input[i].dev_attr);
+                       device_create_file(dev, &fan_min[i].dev_attr);
+                       device_create_file(dev, &fan_div[i].dev_attr);
+                       device_create_file(dev, &fan_status[i].dev_attr);
+               }
+               if (FAN_CONFIG_CONTROL(data->fan_conf, i))
+                       device_create_file(dev, &pwm[i].dev_attr);
        }
 
        return 0;
 
 ERROR3:
-       i2c_detach_client(new_client);
+       i2c_detach_client(client);
 ERROR2:
        for (i = 0; i < 3; i++) {
                if (data->address[i]) {
@@ -1033,11 +1028,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
 {
        int res;
 
-       down(&(data->lock));
+       mutex_lock(&(data->lock));
        if (bank != NO_BANK)
                outb_p(bank, data->address[ldi] + PC87365_REG_BANK);
        res = inb_p(data->address[ldi] + reg);
-       up(&(data->lock));
+       mutex_unlock(&(data->lock));
 
        return res;
 }
@@ -1045,11 +1040,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
 static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank,
                                u8 reg, u8 value)
 {
-       down(&(data->lock));
+       mutex_lock(&(data->lock));
        if (bank != NO_BANK)
                outb_p(bank, data->address[ldi] + PC87365_REG_BANK);
        outb_p(value, data->address[ldi] + reg);
-       up(&(data->lock));
+       mutex_unlock(&(data->lock));
 }
 
 static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
@@ -1071,7 +1066,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
        }
 
        nr = data->innr < 11 ? data->innr : 11;
-       for (i=0; i<nr; i++) {
+       for (i = 0; i < nr; i++) {
                if (init >= init_in[i]) {
                        /* Forcibly enable voltage channel */
                        reg = pc87360_read_value(data, LD_IN, i,
@@ -1088,14 +1083,14 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
 
        /* We can't blindly trust the Super-I/O space configuration bit,
           most BIOS won't set it properly */
-       for (i=11; i<data->innr; i++) {
+       for (i = 11; i < data->innr; i++) {
                reg = pc87360_read_value(data, LD_IN, i,
                                         PC87365_REG_TEMP_STATUS);
                use_thermistors = use_thermistors || (reg & 0x01);
        }
 
        i = use_thermistors ? 2 : 0;
-       for (; i<data->tempnr; i++) {
+       for (; i < data->tempnr; i++) {
                if (init >= init_temp[i]) {
                        /* Forcibly enable temperature channel */
                        reg = pc87360_read_value(data, LD_TEMP, i,
@@ -1111,7 +1106,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
        }
 
        if (use_thermistors) {
-               for (i=11; i<data->innr; i++) {
+               for (i = 11; i < data->innr; i++) {
                        if (init >= init_in[i]) {
                                /* The pin may already be used by thermal
                                   diodes */
@@ -1221,7 +1216,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev)
        struct pc87360_data *data = i2c_get_clientdata(client);
        u8 i;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
                dev_dbg(&client->dev, "Data update\n");
@@ -1321,7 +1316,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
index 8be5189d9bd9edda783f4f44f038702ad881a461..6f3fda73f70c25ecd6d3a7e8f293755fb7126f70 100644 (file)
@@ -60,6 +60,7 @@
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/jiffies.h>
+#include <linux/mutex.h>
 #include <asm/io.h>
 
 
@@ -167,9 +168,9 @@ static inline u8 DIV_TO_REG(int val)
 struct sis5595_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct semaphore lock;
+       struct mutex lock;
 
-       struct semaphore update_lock;
+       struct mutex update_lock;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
        char maxins;            /* == 3 if temp enabled, otherwise == 4 */
@@ -192,8 +193,8 @@ static struct pci_dev *s_bridge;    /* pointer to the (only) sis5595 */
 static int sis5595_detect(struct i2c_adapter *adapter);
 static int sis5595_detach_client(struct i2c_client *client);
 
-static int sis5595_read_value(struct i2c_client *client, u8 register);
-static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value);
+static int sis5595_read_value(struct i2c_client *client, u8 reg);
+static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value);
 static struct sis5595_data *sis5595_update_device(struct device *dev);
 static void sis5595_init_client(struct i2c_client *client);
 
@@ -231,10 +232,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
        struct sis5595_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[nr] = IN_TO_REG(val);
        sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -245,10 +246,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
        struct sis5595_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[nr] = IN_TO_REG(val);
        sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -310,10 +311,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
        struct sis5595_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_over = TEMP_TO_REG(val);
        sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -329,10 +330,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
        struct sis5595_data *data = i2c_get_clientdata(client);
        long val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_hyst = TEMP_TO_REG(val);
        sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -364,10 +365,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
        struct sis5595_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
        sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -390,7 +391,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        unsigned long val = simple_strtoul(buf, NULL, 10);
        int reg;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        min = FAN_FROM_REG(data->fan_min[nr],
                        DIV_FROM_REG(data->fan_div[nr]));
        reg = sis5595_read_value(client, SIS5595_REG_FANDIV);
@@ -403,7 +404,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        default:
                dev_err(&client->dev, "fan_div value %ld not "
                        "supported. Choose one of 1, 2, 4 or 8!\n", val);
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
                return -EINVAL;
        }
        
@@ -419,7 +420,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
        data->fan_min[nr] =
                FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
        sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -527,7 +528,7 @@ static int sis5595_detect(struct i2c_adapter *adapter)
 
        new_client = &data->client;
        new_client->addr = address;
-