diff options
-rw-r--r-- | drivers/hwmon/lm93.c | 154 |
1 files changed, 66 insertions, 88 deletions
diff --git a/drivers/hwmon/lm93.c b/drivers/hwmon/lm93.c index 6c2df576f253..90bb04858117 100644 --- a/drivers/hwmon/lm93.c +++ b/drivers/hwmon/lm93.c | |||
@@ -207,7 +207,7 @@ struct block1_t { | |||
207 | * Client-specific data | 207 | * Client-specific data |
208 | */ | 208 | */ |
209 | struct lm93_data { | 209 | struct lm93_data { |
210 | struct device *hwmon_dev; | 210 | struct i2c_client *client; |
211 | 211 | ||
212 | struct mutex update_lock; | 212 | struct mutex update_lock; |
213 | unsigned long last_updated; /* In jiffies */ | 213 | unsigned long last_updated; /* In jiffies */ |
@@ -919,8 +919,8 @@ static void lm93_read_block(struct i2c_client *client, u8 fbn, u8 *values) | |||
919 | 919 | ||
920 | static struct lm93_data *lm93_update_device(struct device *dev) | 920 | static struct lm93_data *lm93_update_device(struct device *dev) |
921 | { | 921 | { |
922 | struct i2c_client *client = to_i2c_client(dev); | 922 | struct lm93_data *data = dev_get_drvdata(dev); |
923 | struct lm93_data *data = i2c_get_clientdata(client); | 923 | struct i2c_client *client = data->client; |
924 | const unsigned long interval = HZ + (HZ / 2); | 924 | const unsigned long interval = HZ + (HZ / 2); |
925 | 925 | ||
926 | mutex_lock(&data->update_lock); | 926 | mutex_lock(&data->update_lock); |
@@ -1158,8 +1158,8 @@ static ssize_t store_in_min(struct device *dev, struct device_attribute *attr, | |||
1158 | const char *buf, size_t count) | 1158 | const char *buf, size_t count) |
1159 | { | 1159 | { |
1160 | int nr = (to_sensor_dev_attr(attr))->index; | 1160 | int nr = (to_sensor_dev_attr(attr))->index; |
1161 | struct i2c_client *client = to_i2c_client(dev); | 1161 | struct lm93_data *data = dev_get_drvdata(dev); |
1162 | struct lm93_data *data = i2c_get_clientdata(client); | 1162 | struct i2c_client *client = data->client; |
1163 | int vccp = nr - 6; | 1163 | int vccp = nr - 6; |
1164 | long vid; | 1164 | long vid; |
1165 | unsigned long val; | 1165 | unsigned long val; |
@@ -1239,8 +1239,8 @@ static ssize_t store_in_max(struct device *dev, struct device_attribute *attr, | |||
1239 | const char *buf, size_t count) | 1239 | const char *buf, size_t count) |
1240 | { | 1240 | { |
1241 | int nr = (to_sensor_dev_attr(attr))->index; | 1241 | int nr = (to_sensor_dev_attr(attr))->index; |
1242 | struct i2c_client *client = to_i2c_client(dev); | 1242 | struct lm93_data *data = dev_get_drvdata(dev); |
1243 | struct lm93_data *data = i2c_get_clientdata(client); | 1243 | struct i2c_client *client = data->client; |
1244 | int vccp = nr - 6; | 1244 | int vccp = nr - 6; |
1245 | long vid; | 1245 | long vid; |
1246 | unsigned long val; | 1246 | unsigned long val; |
@@ -1323,8 +1323,8 @@ static ssize_t store_temp_min(struct device *dev, struct device_attribute *attr, | |||
1323 | const char *buf, size_t count) | 1323 | const char *buf, size_t count) |
1324 | { | 1324 | { |
1325 | int nr = (to_sensor_dev_attr(attr))->index; | 1325 | int nr = (to_sensor_dev_attr(attr))->index; |
1326 | struct i2c_client *client = to_i2c_client(dev); | 1326 | struct lm93_data *data = dev_get_drvdata(dev); |
1327 | struct lm93_data *data = i2c_get_clientdata(client); | 1327 | struct i2c_client *client = data->client; |
1328 | long val; | 1328 | long val; |
1329 | int err; | 1329 | int err; |
1330 | 1330 | ||
@@ -1358,8 +1358,8 @@ static ssize_t store_temp_max(struct device *dev, struct device_attribute *attr, | |||
1358 | const char *buf, size_t count) | 1358 | const char *buf, size_t count) |
1359 | { | 1359 | { |
1360 | int nr = (to_sensor_dev_attr(attr))->index; | 1360 | int nr = (to_sensor_dev_attr(attr))->index; |
1361 | struct i2c_client *client = to_i2c_client(dev); | 1361 | struct lm93_data *data = dev_get_drvdata(dev); |
1362 | struct lm93_data *data = i2c_get_clientdata(client); | 1362 | struct i2c_client *client = data->client; |
1363 | long val; | 1363 | long val; |
1364 | int err; | 1364 | int err; |
1365 | 1365 | ||
@@ -1394,8 +1394,8 @@ static ssize_t store_temp_auto_base(struct device *dev, | |||
1394 | const char *buf, size_t count) | 1394 | const char *buf, size_t count) |
1395 | { | 1395 | { |
1396 | int nr = (to_sensor_dev_attr(attr))->index; | 1396 | int nr = (to_sensor_dev_attr(attr))->index; |
1397 | struct i2c_client *client = to_i2c_client(dev); | 1397 | struct lm93_data *data = dev_get_drvdata(dev); |
1398 | struct lm93_data *data = i2c_get_clientdata(client); | 1398 | struct i2c_client *client = data->client; |
1399 | long val; | 1399 | long val; |
1400 | int err; | 1400 | int err; |
1401 | 1401 | ||
@@ -1430,8 +1430,8 @@ static ssize_t store_temp_auto_boost(struct device *dev, | |||
1430 | const char *buf, size_t count) | 1430 | const char *buf, size_t count) |
1431 | { | 1431 | { |
1432 | int nr = (to_sensor_dev_attr(attr))->index; | 1432 | int nr = (to_sensor_dev_attr(attr))->index; |
1433 | struct i2c_client *client = to_i2c_client(dev); | 1433 | struct lm93_data *data = dev_get_drvdata(dev); |
1434 | struct lm93_data *data = i2c_get_clientdata(client); | 1434 | struct i2c_client *client = data->client; |
1435 | long val; | 1435 | long val; |
1436 | int err; | 1436 | int err; |
1437 | 1437 | ||
@@ -1469,8 +1469,8 @@ static ssize_t store_temp_auto_boost_hyst(struct device *dev, | |||
1469 | const char *buf, size_t count) | 1469 | const char *buf, size_t count) |
1470 | { | 1470 | { |
1471 | int nr = (to_sensor_dev_attr(attr))->index; | 1471 | int nr = (to_sensor_dev_attr(attr))->index; |
1472 | struct i2c_client *client = to_i2c_client(dev); | 1472 | struct lm93_data *data = dev_get_drvdata(dev); |
1473 | struct lm93_data *data = i2c_get_clientdata(client); | 1473 | struct i2c_client *client = data->client; |
1474 | unsigned long val; | 1474 | unsigned long val; |
1475 | int err; | 1475 | int err; |
1476 | 1476 | ||
@@ -1520,8 +1520,8 @@ static ssize_t store_temp_auto_offset(struct device *dev, | |||
1520 | struct sensor_device_attribute_2 *s_attr = to_sensor_dev_attr_2(attr); | 1520 | struct sensor_device_attribute_2 *s_attr = to_sensor_dev_attr_2(attr); |
1521 | int nr = s_attr->index; | 1521 | int nr = s_attr->index; |
1522 | int ofs = s_attr->nr; | 1522 | int ofs = s_attr->nr; |
1523 | struct i2c_client *client = to_i2c_client(dev); | 1523 | struct lm93_data *data = dev_get_drvdata(dev); |
1524 | struct lm93_data *data = i2c_get_clientdata(client); | 1524 | struct i2c_client *client = data->client; |
1525 | unsigned long val; | 1525 | unsigned long val; |
1526 | int err; | 1526 | int err; |
1527 | 1527 | ||
@@ -1632,8 +1632,8 @@ static ssize_t store_temp_auto_pwm_min(struct device *dev, | |||
1632 | const char *buf, size_t count) | 1632 | const char *buf, size_t count) |
1633 | { | 1633 | { |
1634 | int nr = (to_sensor_dev_attr(attr))->index; | 1634 | int nr = (to_sensor_dev_attr(attr))->index; |
1635 | struct i2c_client *client = to_i2c_client(dev); | 1635 | struct lm93_data *data = dev_get_drvdata(dev); |
1636 | struct lm93_data *data = i2c_get_clientdata(client); | 1636 | struct i2c_client *client = data->client; |
1637 | u8 reg, ctl4; | 1637 | u8 reg, ctl4; |
1638 | unsigned long val; | 1638 | unsigned long val; |
1639 | int err; | 1639 | int err; |
@@ -1680,8 +1680,8 @@ static ssize_t store_temp_auto_offset_hyst(struct device *dev, | |||
1680 | const char *buf, size_t count) | 1680 | const char *buf, size_t count) |
1681 | { | 1681 | { |
1682 | int nr = (to_sensor_dev_attr(attr))->index; | 1682 | int nr = (to_sensor_dev_attr(attr))->index; |
1683 | struct i2c_client *client = to_i2c_client(dev); | 1683 | struct lm93_data *data = dev_get_drvdata(dev); |
1684 | struct lm93_data *data = i2c_get_clientdata(client); | 1684 | struct i2c_client *client = data->client; |
1685 | u8 reg; | 1685 | u8 reg; |
1686 | unsigned long val; | 1686 | unsigned long val; |
1687 | int err; | 1687 | int err; |
@@ -1741,8 +1741,8 @@ static ssize_t store_fan_min(struct device *dev, struct device_attribute *attr, | |||
1741 | const char *buf, size_t count) | 1741 | const char *buf, size_t count) |
1742 | { | 1742 | { |
1743 | int nr = (to_sensor_dev_attr(attr))->index; | 1743 | int nr = (to_sensor_dev_attr(attr))->index; |
1744 | struct i2c_client *client = to_i2c_client(dev); | 1744 | struct lm93_data *data = dev_get_drvdata(dev); |
1745 | struct lm93_data *data = i2c_get_clientdata(client); | 1745 | struct i2c_client *client = data->client; |
1746 | unsigned long val; | 1746 | unsigned long val; |
1747 | int err; | 1747 | int err; |
1748 | 1748 | ||
@@ -1824,8 +1824,8 @@ static ssize_t store_fan_smart_tach(struct device *dev, | |||
1824 | const char *buf, size_t count) | 1824 | const char *buf, size_t count) |
1825 | { | 1825 | { |
1826 | int nr = (to_sensor_dev_attr(attr))->index; | 1826 | int nr = (to_sensor_dev_attr(attr))->index; |
1827 | struct i2c_client *client = to_i2c_client(dev); | 1827 | struct lm93_data *data = dev_get_drvdata(dev); |
1828 | struct lm93_data *data = i2c_get_clientdata(client); | 1828 | struct i2c_client *client = data->client; |
1829 | unsigned long val; | 1829 | unsigned long val; |
1830 | int err; | 1830 | int err; |
1831 | 1831 | ||
@@ -1880,8 +1880,8 @@ static ssize_t store_pwm(struct device *dev, struct device_attribute *attr, | |||
1880 | const char *buf, size_t count) | 1880 | const char *buf, size_t count) |
1881 | { | 1881 | { |
1882 | int nr = (to_sensor_dev_attr(attr))->index; | 1882 | int nr = (to_sensor_dev_attr(attr))->index; |
1883 | struct i2c_client *client = to_i2c_client(dev); | 1883 | struct lm93_data *data = dev_get_drvdata(dev); |
1884 | struct lm93_data *data = i2c_get_clientdata(client); | 1884 | struct i2c_client *client = data->client; |
1885 | u8 ctl2, ctl4; | 1885 | u8 ctl2, ctl4; |
1886 | unsigned long val; | 1886 | unsigned long val; |
1887 | int err; | 1887 | int err; |
@@ -1928,8 +1928,8 @@ static ssize_t store_pwm_enable(struct device *dev, | |||
1928 | const char *buf, size_t count) | 1928 | const char *buf, size_t count) |
1929 | { | 1929 | { |
1930 | int nr = (to_sensor_dev_attr(attr))->index; | 1930 | int nr = (to_sensor_dev_attr(attr))->index; |
1931 | struct i2c_client *client = to_i2c_client(dev); | 1931 | struct lm93_data *data = dev_get_drvdata(dev); |
1932 | struct lm93_data *data = i2c_get_clientdata(client); | 1932 | struct i2c_client *client = data->client; |
1933 | u8 ctl2; | 1933 | u8 ctl2; |
1934 | unsigned long val; | 1934 | unsigned long val; |
1935 | int err; | 1935 | int err; |
@@ -2006,8 +2006,8 @@ static ssize_t store_pwm_freq(struct device *dev, | |||
2006 | const char *buf, size_t count) | 2006 | const char *buf, size_t count) |
2007 | { | 2007 | { |
2008 | int nr = (to_sensor_dev_attr(attr))->index; | 2008 | int nr = (to_sensor_dev_attr(attr))->index; |
2009 | struct i2c_client *client = to_i2c_client(dev); | 2009 | struct lm93_data *data = dev_get_drvdata(dev); |
2010 | struct lm93_data *data = i2c_get_clientdata(client); | 2010 | struct i2c_client *client = data->client; |
2011 | u8 ctl4; | 2011 | u8 ctl4; |
2012 | unsigned long val; | 2012 | unsigned long val; |
2013 | int err; | 2013 | int err; |
@@ -2046,8 +2046,8 @@ static ssize_t store_pwm_auto_channels(struct device *dev, | |||
2046 | const char *buf, size_t count) | 2046 | const char *buf, size_t count) |
2047 | { | 2047 | { |
2048 | int nr = (to_sensor_dev_attr(attr))->index; | 2048 | int nr = (to_sensor_dev_attr(attr))->index; |
2049 | struct i2c_client *client = to_i2c_client(dev); | 2049 | struct lm93_data *data = dev_get_drvdata(dev); |
2050 | struct lm93_data *data = i2c_get_clientdata(client); | 2050 | struct i2c_client *client = data->client; |
2051 | unsigned long val; | 2051 | unsigned long val; |
2052 | int err; | 2052 | int err; |
2053 | 2053 | ||
@@ -2087,8 +2087,8 @@ static ssize_t store_pwm_auto_spinup_min(struct device *dev, | |||
2087 | const char *buf, size_t count) | 2087 | const char *buf, size_t count) |
2088 | { | 2088 | { |
2089 | int nr = (to_sensor_dev_attr(attr))->index; | 2089 | int nr = (to_sensor_dev_attr(attr))->index; |
2090 | struct i2c_client *client = to_i2c_client(dev); | 2090 | struct lm93_data *data = dev_get_drvdata(dev); |
2091 | struct lm93_data *data = i2c_get_clientdata(client); | 2091 | struct i2c_client *client = data->client; |
2092 | u8 ctl3, ctl4; | 2092 | u8 ctl3, ctl4; |
2093 | unsigned long val; | 2093 | unsigned long val; |
2094 | int err; | 2094 | int err; |
@@ -2130,8 +2130,8 @@ static ssize_t store_pwm_auto_spinup_time(struct device *dev, | |||
2130 | const char *buf, size_t count) | 2130 | const char *buf, size_t count) |
2131 | { | 2131 | { |
2132 | int nr = (to_sensor_dev_attr(attr))->index; | 2132 | int nr = (to_sensor_dev_attr(attr))->index; |
2133 | struct i2c_client *client = to_i2c_client(dev); | 2133 | struct lm93_data *data = dev_get_drvdata(dev); |
2134 | struct lm93_data *data = i2c_get_clientdata(client); | 2134 | struct i2c_client *client = data->client; |
2135 | u8 ctl3; | 2135 | u8 ctl3; |
2136 | unsigned long val; | 2136 | unsigned long val; |
2137 | int err; | 2137 | int err; |
@@ -2168,8 +2168,8 @@ static ssize_t store_pwm_auto_prochot_ramp(struct device *dev, | |||
2168 | struct device_attribute *attr, | 2168 | struct device_attribute *attr, |
2169 | const char *buf, size_t count) | 2169 | const char *buf, size_t count) |
2170 | { | 2170 | { |
2171 | struct i2c_client *client = to_i2c_client(dev); | 2171 | struct lm93_data *data = dev_get_drvdata(dev); |
2172 | struct lm93_data *data = i2c_get_clientdata(client); | 2172 | struct i2c_client *client = data->client; |
2173 | u8 ramp; | 2173 | u8 ramp; |
2174 | unsigned long val; | 2174 | unsigned long val; |
2175 | int err; | 2175 | int err; |
@@ -2202,8 +2202,8 @@ static ssize_t store_pwm_auto_vrdhot_ramp(struct device *dev, | |||
2202 | struct device_attribute *attr, | 2202 | struct device_attribute *attr, |
2203 | const char *buf, size_t count) | 2203 | const char *buf, size_t count) |
2204 | { | 2204 | { |
2205 | struct i2c_client *client = to_i2c_client(dev); | 2205 | struct lm93_data *data = dev_get_drvdata(dev); |
2206 | struct lm93_data *data = i2c_get_clientdata(client); | 2206 | struct i2c_client *client = data->client; |
2207 | u8 ramp; | 2207 | u8 ramp; |
2208 | unsigned long val; | 2208 | unsigned long val; |
2209 | int err; | 2209 | int err; |
@@ -2270,8 +2270,8 @@ static ssize_t store_prochot_max(struct device *dev, | |||
2270 | const char *buf, size_t count) | 2270 | const char *buf, size_t count) |
2271 | { | 2271 | { |
2272 | int nr = (to_sensor_dev_attr(attr))->index; | 2272 | int nr = (to_sensor_dev_attr(attr))->index; |
2273 | struct i2c_client *client = to_i2c_client(dev); | 2273 | struct lm93_data *data = dev_get_drvdata(dev); |
2274 | struct lm93_data *data = i2c_get_clientdata(client); | 2274 | struct i2c_client *client = data->client; |
2275 | unsigned long val; | 2275 | unsigned long val; |
2276 | int err; | 2276 | int err; |
2277 | 2277 | ||
@@ -2308,8 +2308,8 @@ static ssize_t store_prochot_override(struct device *dev, | |||
2308 | const char *buf, size_t count) | 2308 | const char *buf, size_t count) |
2309 | { | 2309 | { |
2310 | int nr = (to_sensor_dev_attr(attr))->index; | 2310 | int nr = (to_sensor_dev_attr(attr))->index; |
2311 | struct i2c_client *client = to_i2c_client(dev); | 2311 | struct lm93_data *data = dev_get_drvdata(dev); |
2312 | struct lm93_data *data = i2c_get_clientdata(client); | 2312 | struct i2c_client *client = data->client; |
2313 | unsigned long val; | 2313 | unsigned long val; |
2314 | int err; | 2314 | int err; |
2315 | 2315 | ||
@@ -2351,8 +2351,8 @@ static ssize_t store_prochot_interval(struct device *dev, | |||
2351 | const char *buf, size_t count) | 2351 | const char *buf, size_t count) |
2352 | { | 2352 | { |
2353 | int nr = (to_sensor_dev_attr(attr))->index; | 2353 | int nr = (to_sensor_dev_attr(attr))->index; |
2354 | struct i2c_client *client = to_i2c_client(dev); | 2354 | struct lm93_data *data = dev_get_drvdata(dev); |
2355 | struct lm93_data *data = i2c_get_clientdata(client); | 2355 | struct i2c_client *client = data->client; |
2356 | u8 tmp; | 2356 | u8 tmp; |
2357 | unsigned long val; | 2357 | unsigned long val; |
2358 | int err; | 2358 | int err; |
@@ -2390,8 +2390,8 @@ static ssize_t store_prochot_override_duty_cycle(struct device *dev, | |||
2390 | struct device_attribute *attr, | 2390 | struct device_attribute *attr, |
2391 | const char *buf, size_t count) | 2391 | const char *buf, size_t count) |
2392 | { | 2392 | { |
2393 | struct i2c_client *client = to_i2c_client(dev); | 2393 | struct lm93_data *data = dev_get_drvdata(dev); |
2394 | struct lm93_data *data = i2c_get_clientdata(client); | 2394 | struct i2c_client *client = data->client; |
2395 | unsigned long val; | 2395 | unsigned long val; |
2396 | int err; | 2396 | int err; |
2397 | 2397 | ||
@@ -2423,8 +2423,8 @@ static ssize_t store_prochot_short(struct device *dev, | |||
2423 | struct device_attribute *attr, | 2423 | struct device_attribute *attr, |
2424 | const char *buf, size_t count) | 2424 | const char *buf, size_t count) |
2425 | { | 2425 | { |
2426 | struct i2c_client *client = to_i2c_client(dev); | 2426 | struct lm93_data *data = dev_get_drvdata(dev); |
2427 | struct lm93_data *data = i2c_get_clientdata(client); | 2427 | struct i2c_client *client = data->client; |
2428 | unsigned long val; | 2428 | unsigned long val; |
2429 | int err; | 2429 | int err; |
2430 | 2430 | ||
@@ -2631,9 +2631,7 @@ static struct attribute *lm93_attrs[] = { | |||
2631 | NULL | 2631 | NULL |
2632 | }; | 2632 | }; |
2633 | 2633 | ||
2634 | static struct attribute_group lm93_attr_grp = { | 2634 | ATTRIBUTE_GROUPS(lm93); |
2635 | .attrs = lm93_attrs, | ||
2636 | }; | ||
2637 | 2635 | ||
2638 | static void lm93_init_client(struct i2c_client *client) | 2636 | static void lm93_init_client(struct i2c_client *client) |
2639 | { | 2637 | { |
@@ -2726,61 +2724,42 @@ static int lm93_detect(struct i2c_client *client, struct i2c_board_info *info) | |||
2726 | static int lm93_probe(struct i2c_client *client, | 2724 | static int lm93_probe(struct i2c_client *client, |
2727 | const struct i2c_device_id *id) | 2725 | const struct i2c_device_id *id) |
2728 | { | 2726 | { |
2727 | struct device *dev = &client->dev; | ||
2729 | struct lm93_data *data; | 2728 | struct lm93_data *data; |
2730 | int err, func; | 2729 | struct device *hwmon_dev; |
2730 | int func; | ||
2731 | void (*update)(struct lm93_data *, struct i2c_client *); | 2731 | void (*update)(struct lm93_data *, struct i2c_client *); |
2732 | 2732 | ||
2733 | /* choose update routine based on bus capabilities */ | 2733 | /* choose update routine based on bus capabilities */ |
2734 | func = i2c_get_functionality(client->adapter); | 2734 | func = i2c_get_functionality(client->adapter); |
2735 | if (((LM93_SMBUS_FUNC_FULL & func) == LM93_SMBUS_FUNC_FULL) && | 2735 | if (((LM93_SMBUS_FUNC_FULL & func) == LM93_SMBUS_FUNC_FULL) && |
2736 | (!disable_block)) { | 2736 | (!disable_block)) { |
2737 | dev_dbg(&client->dev, "using SMBus block data transactions\n"); | 2737 | dev_dbg(dev, "using SMBus block data transactions\n"); |
2738 | update = lm93_update_client_full; | 2738 | update = lm93_update_client_full; |
2739 | } else if ((LM93_SMBUS_FUNC_MIN & func) == LM93_SMBUS_FUNC_MIN) { | 2739 | } else if ((LM93_SMBUS_FUNC_MIN & func) == LM93_SMBUS_FUNC_MIN) { |
2740 | dev_dbg(&client->dev, | 2740 | dev_dbg(dev, "disabled SMBus block data transactions\n"); |
2741 | "disabled SMBus block data transactions\n"); | ||
2742 | update = lm93_update_client_min; | 2741 | update = lm93_update_client_min; |
2743 | } else { | 2742 | } else { |
2744 | dev_dbg(&client->dev, | 2743 | dev_dbg(dev, "detect failed, smbus byte and/or word data not supported!\n"); |
2745 | "detect failed, smbus byte and/or word data not supported!\n"); | ||
2746 | return -ENODEV; | 2744 | return -ENODEV; |
2747 | } | 2745 | } |
2748 | 2746 | ||
2749 | data = devm_kzalloc(&client->dev, sizeof(struct lm93_data), GFP_KERNEL); | 2747 | data = devm_kzalloc(dev, sizeof(struct lm93_data), GFP_KERNEL); |
2750 | if (!data) | 2748 | if (!data) |
2751 | return -ENOMEM; | 2749 | return -ENOMEM; |
2752 | i2c_set_clientdata(client, data); | ||
2753 | 2750 | ||
2754 | /* housekeeping */ | 2751 | /* housekeeping */ |
2752 | data->client = client; | ||
2755 | data->update = update; | 2753 | data->update = update; |
2756 | mutex_init(&data->update_lock); | 2754 | mutex_init(&data->update_lock); |
2757 | 2755 | ||
2758 | /* initialize the chip */ | 2756 | /* initialize the chip */ |
2759 | lm93_init_client(client); | 2757 | lm93_init_client(client); |
2760 | 2758 | ||
2761 | err = sysfs_create_group(&client->dev.kobj, &lm93_attr_grp); | 2759 | hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, |
2762 | if (err) | 2760 | data, |
2763 | return err; | 2761 | lm93_groups); |
2764 | 2762 | return PTR_ERR_OR_ZERO(hwmon_dev); | |
2765 | /* Register hwmon driver class */ | ||
2766 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
2767 | if (!IS_ERR(data->hwmon_dev)) | ||
2768 | return 0; | ||
2769 | |||
2770 | err = PTR_ERR(data->hwmon_dev); | ||
2771 | dev_err(&client->dev, "error registering hwmon device.\n"); | ||
2772 | sysfs_remove_group(&client->dev.kobj, &lm93_attr_grp); | ||
2773 | return err; | ||
2774 | } | ||
2775 | |||
2776 | static int lm93_remove(struct i2c_client *client) | ||
2777 | { | ||
2778 | struct lm93_data *data = i2c_get_clientdata(client); | ||
2779 | |||
2780 | hwmon_device_unregister(data->hwmon_dev); | ||
2781 | sysfs_remove_group(&client->dev.kobj, &lm93_attr_grp); | ||
2782 | |||
2783 | return 0; | ||
2784 | } | 2763 | } |
2785 | 2764 | ||
2786 | static const struct i2c_device_id lm93_id[] = { | 2765 | static const struct i2c_device_id lm93_id[] = { |
@@ -2796,7 +2775,6 @@ static struct i2c_driver lm93_driver = { | |||
2796 | .name = "lm93", | 2775 | .name = "lm93", |
2797 | }, | 2776 | }, |
2798 | .probe = lm93_probe, | 2777 | .probe = lm93_probe, |
2799 | .remove = lm93_remove, | ||
2800 | .id_table = lm93_id, | 2778 | .id_table = lm93_id, |
2801 | .detect = lm93_detect, | 2779 | .detect = lm93_detect, |
2802 | .address_list = normal_i2c, | 2780 | .address_list = normal_i2c, |