diff options
Diffstat (limited to 'drivers/hwmon/lm70.c')
-rw-r--r-- | drivers/hwmon/lm70.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c index 275d392eca61..dd366889ce9b 100644 --- a/drivers/hwmon/lm70.c +++ b/drivers/hwmon/lm70.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #define DRVNAME "lm70" | 37 | #define DRVNAME "lm70" |
38 | 38 | ||
39 | struct lm70 { | 39 | struct lm70 { |
40 | struct class_device *cdev; | 40 | struct device *hwmon_dev; |
41 | struct semaphore sem; | 41 | struct semaphore sem; |
42 | }; | 42 | }; |
43 | 43 | ||
@@ -81,7 +81,7 @@ static ssize_t lm70_sense_temp(struct device *dev, | |||
81 | * So it's equivalent to multiplying by 0.25 * 1000 = 250. | 81 | * So it's equivalent to multiplying by 0.25 * 1000 = 250. |
82 | */ | 82 | */ |
83 | val = ((int)raw/32) * 250; | 83 | val = ((int)raw/32) * 250; |
84 | status = sprintf(buf, "%+d\n", val); /* millidegrees Celsius */ | 84 | status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */ |
85 | out: | 85 | out: |
86 | up(&p_lm70->sem); | 86 | up(&p_lm70->sem); |
87 | return status; | 87 | return status; |
@@ -89,6 +89,14 @@ out: | |||
89 | 89 | ||
90 | static DEVICE_ATTR(temp1_input, S_IRUGO, lm70_sense_temp, NULL); | 90 | static DEVICE_ATTR(temp1_input, S_IRUGO, lm70_sense_temp, NULL); |
91 | 91 | ||
92 | static ssize_t lm70_show_name(struct device *dev, struct device_attribute | ||
93 | *devattr, char *buf) | ||
94 | { | ||
95 | return sprintf(buf, "lm70\n"); | ||
96 | } | ||
97 | |||
98 | static DEVICE_ATTR(name, S_IRUGO, lm70_show_name, NULL); | ||
99 | |||
92 | /*----------------------------------------------------------------------*/ | 100 | /*----------------------------------------------------------------------*/ |
93 | 101 | ||
94 | static int __devinit lm70_probe(struct spi_device *spi) | 102 | static int __devinit lm70_probe(struct spi_device *spi) |
@@ -107,15 +115,16 @@ static int __devinit lm70_probe(struct spi_device *spi) | |||
107 | init_MUTEX(&p_lm70->sem); | 115 | init_MUTEX(&p_lm70->sem); |
108 | 116 | ||
109 | /* sysfs hook */ | 117 | /* sysfs hook */ |
110 | p_lm70->cdev = hwmon_device_register(&spi->dev); | 118 | p_lm70->hwmon_dev = hwmon_device_register(&spi->dev); |
111 | if (IS_ERR(p_lm70->cdev)) { | 119 | if (IS_ERR(p_lm70->hwmon_dev)) { |
112 | dev_dbg(&spi->dev, "hwmon_device_register failed.\n"); | 120 | dev_dbg(&spi->dev, "hwmon_device_register failed.\n"); |
113 | status = PTR_ERR(p_lm70->cdev); | 121 | status = PTR_ERR(p_lm70->hwmon_dev); |
114 | goto out_dev_reg_failed; | 122 | goto out_dev_reg_failed; |
115 | } | 123 | } |
116 | dev_set_drvdata(&spi->dev, p_lm70); | 124 | dev_set_drvdata(&spi->dev, p_lm70); |
117 | 125 | ||
118 | if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input))) { | 126 | if ((status = device_create_file(&spi->dev, &dev_attr_temp1_input)) |
127 | || (status = device_create_file(&spi->dev, &dev_attr_name))) { | ||
119 | dev_dbg(&spi->dev, "device_create_file failure.\n"); | 128 | dev_dbg(&spi->dev, "device_create_file failure.\n"); |
120 | goto out_dev_create_file_failed; | 129 | goto out_dev_create_file_failed; |
121 | } | 130 | } |
@@ -123,7 +132,8 @@ static int __devinit lm70_probe(struct spi_device *spi) | |||
123 | return 0; | 132 | return 0; |
124 | 133 | ||
125 | out_dev_create_file_failed: | 134 | out_dev_create_file_failed: |
126 | hwmon_device_unregister(p_lm70->cdev); | 135 | device_remove_file(&spi->dev, &dev_attr_temp1_input); |
136 | hwmon_device_unregister(p_lm70->hwmon_dev); | ||
127 | out_dev_reg_failed: | 137 | out_dev_reg_failed: |
128 | dev_set_drvdata(&spi->dev, NULL); | 138 | dev_set_drvdata(&spi->dev, NULL); |
129 | kfree(p_lm70); | 139 | kfree(p_lm70); |
@@ -135,7 +145,8 @@ static int __devexit lm70_remove(struct spi_device *spi) | |||
135 | struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev); | 145 | struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev); |
136 | 146 | ||
137 | device_remove_file(&spi->dev, &dev_attr_temp1_input); | 147 | device_remove_file(&spi->dev, &dev_attr_temp1_input); |
138 | hwmon_device_unregister(p_lm70->cdev); | 148 | device_remove_file(&spi->dev, &dev_attr_name); |
149 | hwmon_device_unregister(p_lm70->hwmon_dev); | ||
139 | dev_set_drvdata(&spi->dev, NULL); | 150 | dev_set_drvdata(&spi->dev, NULL); |
140 | kfree(p_lm70); | 151 | kfree(p_lm70); |
141 | 152 | ||