aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/hwmon.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-14 15:50:19 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-14 15:50:19 -0400
commit4fa435018d740cb83d74c92306aa1f796da91ddd (patch)
treeb2b5783837be3d17b65b924b051aeb01e6b1fce9 /drivers/hwmon/hwmon.c
parent7441dd12e607651128e676866630a848b664d6e7 (diff)
parenta022fef5a2b19086b329d1cc64a5d78aa83e2908 (diff)
Merge branch 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6
* 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6: (53 commits) hwmon: (vt8231) fix sparse warning hwmon: (sis5595) fix sparse warning hwmon: (w83627hf) don't assume bank 0 hwmon: (w83627hf) Fix setting fan min right after driver load hwmon: (w83627hf) De-macro sysfs callback functions hwmon: Add new combined driver for FSC chips hwmon: (ibmpex) Release IPMI user if hwmon registration fails hwmon: (dme1737) Add sch311x support hwmon: (dme1737) group functions logically hwmon: (dme1737) cleanups hwmon: IBM power meter driver hwmon: (coretemp) Add support for Celeron 4xx hwmon: (lm87) Disable VID when it should be hwmon: (w83781d) Add individual alarm and beep files hwmon: VRM is not read from registers MAINTAINERS: update hwmon subsystem git trees hwmon: Fix the code examples in documentation hwmon: update sysfs interface document - error handling hwmon: (thmc50) Fix a debug message hwmon: (thmc50) Don't create temp3 if not enabled ...
Diffstat (limited to 'drivers/hwmon/hwmon.c')
-rw-r--r--drivers/hwmon/hwmon.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index affcc00764d..3db28450a3b 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -28,17 +28,17 @@ static DEFINE_IDR(hwmon_idr);
28static DEFINE_SPINLOCK(idr_lock); 28static DEFINE_SPINLOCK(idr_lock);
29 29
30/** 30/**
31 * hwmon_device_register - register w/ hwmon sysfs class 31 * hwmon_device_register - register w/ hwmon
32 * @dev: the device to register 32 * @dev: the device to register
33 * 33 *
34 * hwmon_device_unregister() must be called when the class device is no 34 * hwmon_device_unregister() must be called when the device is no
35 * longer needed. 35 * longer needed.
36 * 36 *
37 * Returns the pointer to the new struct class device. 37 * Returns the pointer to the new device.
38 */ 38 */
39struct class_device *hwmon_device_register(struct device *dev) 39struct device *hwmon_device_register(struct device *dev)
40{ 40{
41 struct class_device *cdev; 41 struct device *hwdev;
42 int id, err; 42 int id, err;
43 43
44again: 44again:
@@ -55,34 +55,33 @@ again:
55 return ERR_PTR(err); 55 return ERR_PTR(err);
56 56
57 id = id & MAX_ID_MASK; 57 id = id & MAX_ID_MASK;
58 cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev, 58 hwdev = device_create(hwmon_class, dev, MKDEV(0,0), HWMON_ID_FORMAT, id);
59 HWMON_ID_FORMAT, id);
60 59
61 if (IS_ERR(cdev)) { 60 if (IS_ERR(hwdev)) {
62 spin_lock(&idr_lock); 61 spin_lock(&idr_lock);
63 idr_remove(&hwmon_idr, id); 62 idr_remove(&hwmon_idr, id);
64 spin_unlock(&idr_lock); 63 spin_unlock(&idr_lock);
65 } 64 }
66 65
67 return cdev; 66 return hwdev;
68} 67}
69 68
70/** 69/**
71 * hwmon_device_unregister - removes the previously registered class device 70 * hwmon_device_unregister - removes the previously registered class device
72 * 71 *
73 * @cdev: the class device to destroy 72 * @dev: the class device to destroy
74 */ 73 */
75void hwmon_device_unregister(struct class_device *cdev) 74void hwmon_device_unregister(struct device *dev)
76{ 75{
77 int id; 76 int id;
78 77
79 if (likely(sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1)) { 78 if (likely(sscanf(dev->bus_id, HWMON_ID_FORMAT, &id) == 1)) {
80 class_device_unregister(cdev); 79 device_unregister(dev);
81 spin_lock(&idr_lock); 80 spin_lock(&idr_lock);
82 idr_remove(&hwmon_idr, id); 81 idr_remove(&hwmon_idr, id);
83 spin_unlock(&idr_lock); 82 spin_unlock(&idr_lock);
84 } else 83 } else
85 dev_dbg(cdev->dev, 84 dev_dbg(dev->parent,
86 "hwmon_device_unregister() failed: bad class ID!\n"); 85 "hwmon_device_unregister() failed: bad class ID!\n");
87} 86}
88 87