lm95241.c (8f987768eb99631374f4ab0bb19cd062baf1397d) | lm95241.c (61ec2da506ec6544873f0aba026164e4bdd21751) |
---|---|
1/* 2 * lm95241.c - Part of lm_sensors, Linux kernel modules for hardware 3 * monitoring 4 * Copyright (C) 2008 Davide Rizzo <elpa-rizzo@gmail.com> 5 * 6 * Based on the max1619 driver. The LM95241 is a sensor chip made by National 7 * Semiconductors. 8 * It reports up to three temperatures (its own plus up to --- 114 unchanged lines hidden (view full) --- 123 return strlen(buf); 124} 125 126static ssize_t set_interval(struct device *dev, struct device_attribute *attr, 127 const char *buf, size_t count) 128{ 129 struct i2c_client *client = to_i2c_client(dev); 130 struct lm95241_data *data = i2c_get_clientdata(client); | 1/* 2 * lm95241.c - Part of lm_sensors, Linux kernel modules for hardware 3 * monitoring 4 * Copyright (C) 2008 Davide Rizzo <elpa-rizzo@gmail.com> 5 * 6 * Based on the max1619 driver. The LM95241 is a sensor chip made by National 7 * Semiconductors. 8 * It reports up to three temperatures (its own plus up to --- 114 unchanged lines hidden (view full) --- 123 return strlen(buf); 124} 125 126static ssize_t set_interval(struct device *dev, struct device_attribute *attr, 127 const char *buf, size_t count) 128{ 129 struct i2c_client *client = to_i2c_client(dev); 130 struct lm95241_data *data = i2c_get_clientdata(client); |
131 unsigned long val; |
|
131 | 132 |
132 strict_strtol(buf, 10, &data->interval); 133 data->interval = data->interval * HZ / 1000; | 133 if (strict_strtoul(buf, 10, &val) < 0) 134 return -EINVAL; |
134 | 135 |
136 data->interval = val * HZ / 1000; 137 |
|
135 return count; 136} 137 138#define show_type(flag) \ 139static ssize_t show_type##flag(struct device *dev, \ 140 struct device_attribute *attr, char *buf) \ 141{ \ 142 struct i2c_client *client = to_i2c_client(dev); \ --- 40 unchanged lines hidden (view full) --- 183static ssize_t set_type##flag(struct device *dev, \ 184 struct device_attribute *attr, \ 185 const char *buf, size_t count) \ 186{ \ 187 struct i2c_client *client = to_i2c_client(dev); \ 188 struct lm95241_data *data = i2c_get_clientdata(client); \ 189\ 190 long val; \ | 138 return count; 139} 140 141#define show_type(flag) \ 142static ssize_t show_type##flag(struct device *dev, \ 143 struct device_attribute *attr, char *buf) \ 144{ \ 145 struct i2c_client *client = to_i2c_client(dev); \ --- 40 unchanged lines hidden (view full) --- 186static ssize_t set_type##flag(struct device *dev, \ 187 struct device_attribute *attr, \ 188 const char *buf, size_t count) \ 189{ \ 190 struct i2c_client *client = to_i2c_client(dev); \ 191 struct lm95241_data *data = i2c_get_clientdata(client); \ 192\ 193 long val; \ |
191 strict_strtol(buf, 10, &val); \ | |
192\ | 194\ |
195 if (strict_strtol(buf, 10, &val) < 0) \ 196 return -EINVAL; \ 197\ |
|
193 if ((val == 1) || (val == 2)) { \ 194\ 195 mutex_lock(&data->update_lock); \ 196\ 197 data->trutherm &= ~(TT_MASK << TT##flag##_SHIFT); \ 198 if (val == 1) { \ 199 data->model |= R##flag##MS_MASK; \ 200 data->trutherm |= (TT_ON << TT##flag##_SHIFT); \ --- 21 unchanged lines hidden (view full) --- 222#define set_min(flag) \ 223static ssize_t set_min##flag(struct device *dev, \ 224 struct device_attribute *devattr, const char *buf, size_t count) \ 225{ \ 226 struct i2c_client *client = to_i2c_client(dev); \ 227 struct lm95241_data *data = i2c_get_clientdata(client); \ 228\ 229 long val; \ | 198 if ((val == 1) || (val == 2)) { \ 199\ 200 mutex_lock(&data->update_lock); \ 201\ 202 data->trutherm &= ~(TT_MASK << TT##flag##_SHIFT); \ 203 if (val == 1) { \ 204 data->model |= R##flag##MS_MASK; \ 205 data->trutherm |= (TT_ON << TT##flag##_SHIFT); \ --- 21 unchanged lines hidden (view full) --- 227#define set_min(flag) \ 228static ssize_t set_min##flag(struct device *dev, \ 229 struct device_attribute *devattr, const char *buf, size_t count) \ 230{ \ 231 struct i2c_client *client = to_i2c_client(dev); \ 232 struct lm95241_data *data = i2c_get_clientdata(client); \ 233\ 234 long val; \ |
230 strict_strtol(buf, 10, &val); \ | |
231\ | 235\ |
236 if (strict_strtol(buf, 10, &val) < 0) \ 237 return -EINVAL;\ 238\ |
|
232 mutex_lock(&data->update_lock); \ 233\ 234 if (val < 0) \ 235 data->config |= R##flag##DF_MASK; \ 236 else \ 237 data->config &= ~R##flag##DF_MASK; \ 238\ 239 data->valid = 0; \ --- 11 unchanged lines hidden (view full) --- 251#define set_max(flag) \ 252static ssize_t set_max##flag(struct device *dev, \ 253 struct device_attribute *devattr, const char *buf, size_t count) \ 254{ \ 255 struct i2c_client *client = to_i2c_client(dev); \ 256 struct lm95241_data *data = i2c_get_clientdata(client); \ 257\ 258 long val; \ | 239 mutex_lock(&data->update_lock); \ 240\ 241 if (val < 0) \ 242 data->config |= R##flag##DF_MASK; \ 243 else \ 244 data->config &= ~R##flag##DF_MASK; \ 245\ 246 data->valid = 0; \ --- 11 unchanged lines hidden (view full) --- 258#define set_max(flag) \ 259static ssize_t set_max##flag(struct device *dev, \ 260 struct device_attribute *devattr, const char *buf, size_t count) \ 261{ \ 262 struct i2c_client *client = to_i2c_client(dev); \ 263 struct lm95241_data *data = i2c_get_clientdata(client); \ 264\ 265 long val; \ |
259 strict_strtol(buf, 10, &val); \ | |
260\ | 266\ |
267 if (strict_strtol(buf, 10, &val) < 0) \ 268 return -EINVAL; \ 269\ |
|
261 mutex_lock(&data->update_lock); \ 262\ 263 if (val <= 127000) \ 264 data->config |= R##flag##DF_MASK; \ 265 else \ 266 data->config &= ~R##flag##DF_MASK; \ 267\ 268 data->valid = 0; \ --- 210 unchanged lines hidden --- | 270 mutex_lock(&data->update_lock); \ 271\ 272 if (val <= 127000) \ 273 data->config |= R##flag##DF_MASK; \ 274 else \ 275 data->config &= ~R##flag##DF_MASK; \ 276\ 277 data->valid = 0; \ --- 210 unchanged lines hidden --- |