diff options
author | Eric Andersson <eric.andersson@unixphere.com> | 2012-04-09 16:16:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-18 17:56:04 -0400 |
commit | e939ca0a63627d6b2205dd945833ee7da4fc181a (patch) | |
tree | 0b0a261016016dc50364efcba75344b07d864478 /drivers/misc | |
parent | 0ed0d579cb19e00acda762bad0d526477833c4e7 (diff) |
misc: clean up bmp085 driver
This patch includes various cleaning of the bmp085 driver including:
- Whitespaces and alignment fixes
- Minor typos
- Consistency fixes
Reviewed-by: Stefan Nilsson <stefan.nilsson@unixphere.com>
Signed-off-by: Eric Andersson <eric.andersson@unixphere.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/bmp085.c | 206 |
1 files changed, 103 insertions, 103 deletions
diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c index 76c3064629f1..6f572bc21879 100644 --- a/drivers/misc/bmp085.c +++ b/drivers/misc/bmp085.c | |||
@@ -1,62 +1,63 @@ | |||
1 | /* Copyright (c) 2010 Christoph Mair <christoph.mair@gmail.com> | 1 | /* Copyright (c) 2010 Christoph Mair <christoph.mair@gmail.com> |
2 | 2 | * Copyright (c) 2012 Bosch Sensortec GmbH | |
3 | This driver supports the bmp085 digital barometric pressure | 3 | * Copyright (c) 2012 Unixphere AB |
4 | and temperature sensor from Bosch Sensortec. The datasheet | 4 | * |
5 | is available from their website: | 5 | * This driver supports the bmp085 digital barometric pressure |
6 | http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf | 6 | * and temperature sensor from Bosch Sensortec. The datasheet |
7 | 7 | * is available from their website: | |
8 | A pressure measurement is issued by reading from pressure0_input. | 8 | * http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf |
9 | The return value ranges from 30000 to 110000 pascal with a resulution | 9 | * |
10 | of 1 pascal (0.01 millibar) which enables measurements from 9000m above | 10 | * A pressure measurement is issued by reading from pressure0_input. |
11 | to 500m below sea level. | 11 | * The return value ranges from 30000 to 110000 pascal with a resulution |
12 | 12 | * of 1 pascal (0.01 millibar) which enables measurements from 9000m above | |
13 | The temperature can be read from temp0_input. Values range from | 13 | * to 500m below sea level. |
14 | -400 to 850 representing the ambient temperature in degree celsius | 14 | * |
15 | multiplied by 10.The resolution is 0.1 celsius. | 15 | * The temperature can be read from temp0_input. Values range from |
16 | 16 | * -400 to 850 representing the ambient temperature in degree celsius | |
17 | Because ambient pressure is temperature dependent, a temperature | 17 | * multiplied by 10.The resolution is 0.1 celsius. |
18 | measurement will be executed automatically even if the user is reading | 18 | * |
19 | from pressure0_input. This happens if the last temperature measurement | 19 | * Because ambient pressure is temperature dependent, a temperature |
20 | has been executed more then one second ago. | 20 | * measurement will be executed automatically even if the user is reading |
21 | 21 | * from pressure0_input. This happens if the last temperature measurement | |
22 | To decrease RMS noise from pressure measurements, the bmp085 can | 22 | * has been executed more then one second ago. |
23 | autonomously calculate the average of up to eight samples. This is | 23 | * |
24 | set up by writing to the oversampling sysfs file. Accepted values | 24 | * To decrease RMS noise from pressure measurements, the bmp085 can |
25 | are 0, 1, 2 and 3. 2^x when x is the value written to this file | 25 | * autonomously calculate the average of up to eight samples. This is |
26 | specifies the number of samples used to calculate the ambient pressure. | 26 | * set up by writing to the oversampling sysfs file. Accepted values |
27 | RMS noise is specified with six pascal (without averaging) and decreases | 27 | * are 0, 1, 2 and 3. 2^x when x is the value written to this file |
28 | down to 3 pascal when using an oversampling setting of 3. | 28 | * specifies the number of samples used to calculate the ambient pressure. |
29 | 29 | * RMS noise is specified with six pascal (without averaging) and decreases | |
30 | This program is free software; you can redistribute it and/or modify | 30 | * down to 3 pascal when using an oversampling setting of 3. |
31 | it under the terms of the GNU General Public License as published by | 31 | * |
32 | the Free Software Foundation; either version 2 of the License, or | 32 | * This program is free software; you can redistribute it and/or modify |
33 | (at your option) any later version. | 33 | * it under the terms of the GNU General Public License as published by |
34 | 34 | * the Free Software Foundation; either version 2 of the License, or | |
35 | This program is distributed in the hope that it will be useful, | 35 | * (at your option) any later version. |
36 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 36 | * |
37 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 37 | * This program is distributed in the hope that it will be useful, |
38 | GNU General Public License for more details. | 38 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
39 | 39 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
40 | You should have received a copy of the GNU General Public License | 40 | * GNU General Public License for more details. |
41 | along with this program; if not, write to the Free Software | 41 | * |
42 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 42 | * You should have received a copy of the GNU General Public License |
43 | */ | 43 | * along with this program; if not, write to the Free Software |
44 | 44 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
45 | */ | ||
45 | 46 | ||
46 | #include <linux/module.h> | 47 | #include <linux/module.h> |
48 | #include <linux/device.h> | ||
47 | #include <linux/init.h> | 49 | #include <linux/init.h> |
48 | #include <linux/i2c.h> | 50 | #include <linux/i2c.h> |
49 | #include <linux/slab.h> | 51 | #include <linux/slab.h> |
50 | #include <linux/delay.h> | 52 | #include <linux/delay.h> |
51 | 53 | ||
52 | 54 | #define BMP085_NAME "bmp085" | |
53 | #define BMP085_I2C_ADDRESS 0x77 | 55 | #define BMP085_I2C_ADDRESS 0x77 |
54 | #define BMP085_CHIP_ID 0x55 | 56 | #define BMP085_CHIP_ID 0x55 |
55 | 57 | ||
56 | #define BMP085_CALIBRATION_DATA_START 0xAA | 58 | #define BMP085_CALIBRATION_DATA_START 0xAA |
57 | #define BMP085_CALIBRATION_DATA_LENGTH 11 /* 16 bit values */ | 59 | #define BMP085_CALIBRATION_DATA_LENGTH 11 /* 16 bit values */ |
58 | #define BMP085_CHIP_ID_REG 0xD0 | 60 | #define BMP085_CHIP_ID_REG 0xD0 |
59 | #define BMP085_VERSION_REG 0xD1 | ||
60 | #define BMP085_CTRL_REG 0xF4 | 61 | #define BMP085_CTRL_REG 0xF4 |
61 | #define BMP085_TEMP_MEASUREMENT 0x2E | 62 | #define BMP085_TEMP_MEASUREMENT 0x2E |
62 | #define BMP085_PRESSURE_MEASUREMENT 0x34 | 63 | #define BMP085_PRESSURE_MEASUREMENT 0x34 |
@@ -65,9 +66,6 @@ | |||
65 | #define BMP085_CONVERSION_REGISTER_XLSB 0xF8 | 66 | #define BMP085_CONVERSION_REGISTER_XLSB 0xF8 |
66 | #define BMP085_TEMP_CONVERSION_TIME 5 | 67 | #define BMP085_TEMP_CONVERSION_TIME 5 |
67 | 68 | ||
68 | #define BMP085_CLIENT_NAME "bmp085" | ||
69 | |||
70 | |||
71 | static const unsigned short normal_i2c[] = { BMP085_I2C_ADDRESS, | 69 | static const unsigned short normal_i2c[] = { BMP085_I2C_ADDRESS, |
72 | I2C_CLIENT_END }; | 70 | I2C_CLIENT_END }; |
73 | 71 | ||
@@ -78,20 +76,18 @@ struct bmp085_calibration_data { | |||
78 | s16 MB, MC, MD; | 76 | s16 MB, MC, MD; |
79 | }; | 77 | }; |
80 | 78 | ||
81 | |||
82 | /* Each client has this additional data */ | ||
83 | struct bmp085_data { | 79 | struct bmp085_data { |
84 | struct i2c_client *client; | 80 | struct i2c_client *client; |
85 | struct mutex lock; | 81 | struct mutex lock; |
86 | struct bmp085_calibration_data calibration; | 82 | struct bmp085_calibration_data calibration; |
87 | u32 raw_temperature; | 83 | u8 oversampling_setting; |
88 | u32 raw_pressure; | 84 | u32 raw_temperature; |
89 | unsigned char oversampling_setting; | 85 | u32 raw_pressure; |
86 | u32 temp_measurement_period; | ||
90 | unsigned long last_temp_measurement; | 87 | unsigned long last_temp_measurement; |
91 | s32 b6; /* calculated temperature correction coefficient */ | 88 | s32 b6; /* calculated temperature correction coefficient */ |
92 | }; | 89 | }; |
93 | 90 | ||
94 | |||
95 | static s32 bmp085_read_calibration_data(struct i2c_client *client) | 91 | static s32 bmp085_read_calibration_data(struct i2c_client *client) |
96 | { | 92 | { |
97 | u16 tmp[BMP085_CALIBRATION_DATA_LENGTH]; | 93 | u16 tmp[BMP085_CALIBRATION_DATA_LENGTH]; |
@@ -99,12 +95,12 @@ static s32 bmp085_read_calibration_data(struct i2c_client *client) | |||
99 | struct bmp085_calibration_data *cali = &(data->calibration); | 95 | struct bmp085_calibration_data *cali = &(data->calibration); |
100 | s32 status = i2c_smbus_read_i2c_block_data(client, | 96 | s32 status = i2c_smbus_read_i2c_block_data(client, |
101 | BMP085_CALIBRATION_DATA_START, | 97 | BMP085_CALIBRATION_DATA_START, |
102 | BMP085_CALIBRATION_DATA_LENGTH*sizeof(u16), | 98 | (BMP085_CALIBRATION_DATA_LENGTH << 1), |
103 | (u8 *)tmp); | 99 | (u8 *)tmp); |
104 | if (status < 0) | 100 | if (status < 0) |
105 | return status; | 101 | return status; |
106 | 102 | ||
107 | if (status != BMP085_CALIBRATION_DATA_LENGTH*sizeof(u16)) | 103 | if (status != (BMP085_CALIBRATION_DATA_LENGTH << 1)) |
108 | return -EIO; | 104 | return -EIO; |
109 | 105 | ||
110 | cali->AC1 = be16_to_cpu(tmp[0]); | 106 | cali->AC1 = be16_to_cpu(tmp[0]); |
@@ -121,7 +117,6 @@ static s32 bmp085_read_calibration_data(struct i2c_client *client) | |||
121 | return 0; | 117 | return 0; |
122 | } | 118 | } |
123 | 119 | ||
124 | |||
125 | static s32 bmp085_update_raw_temperature(struct bmp085_data *data) | 120 | static s32 bmp085_update_raw_temperature(struct bmp085_data *data) |
126 | { | 121 | { |
127 | u16 tmp; | 122 | u16 tmp; |
@@ -130,7 +125,7 @@ static s32 bmp085_update_raw_temperature(struct bmp085_data *data) | |||
130 | mutex_lock(&data->lock); | 125 | mutex_lock(&data->lock); |
131 | status = i2c_smbus_write_byte_data(data->client, BMP085_CTRL_REG, | 126 | status = i2c_smbus_write_byte_data(data->client, BMP085_CTRL_REG, |
132 | BMP085_TEMP_MEASUREMENT); | 127 | BMP085_TEMP_MEASUREMENT); |
133 | if (status != 0) { | 128 | if (status < 0) { |
134 | dev_err(&data->client->dev, | 129 | dev_err(&data->client->dev, |
135 | "Error while requesting temperature measurement.\n"); | 130 | "Error while requesting temperature measurement.\n"); |
136 | goto exit; | 131 | goto exit; |
@@ -163,8 +158,9 @@ static s32 bmp085_update_raw_pressure(struct bmp085_data *data) | |||
163 | 158 | ||
164 | mutex_lock(&data->lock); | 159 | mutex_lock(&data->lock); |
165 | status = i2c_smbus_write_byte_data(data->client, BMP085_CTRL_REG, | 160 | status = i2c_smbus_write_byte_data(data->client, BMP085_CTRL_REG, |
166 | BMP085_PRESSURE_MEASUREMENT + (data->oversampling_setting<<6)); | 161 | BMP085_PRESSURE_MEASUREMENT + |
167 | if (status != 0) { | 162 | (data->oversampling_setting << 6)); |
163 | if (status < 0) { | ||
168 | dev_err(&data->client->dev, | 164 | dev_err(&data->client->dev, |
169 | "Error while requesting pressure measurement.\n"); | 165 | "Error while requesting pressure measurement.\n"); |
170 | goto exit; | 166 | goto exit; |
@@ -193,7 +189,6 @@ exit: | |||
193 | return status; | 189 | return status; |
194 | } | 190 | } |
195 | 191 | ||
196 | |||
197 | /* | 192 | /* |
198 | * This function starts the temperature measurement and returns the value | 193 | * This function starts the temperature measurement and returns the value |
199 | * in tenth of a degree celsius. | 194 | * in tenth of a degree celsius. |
@@ -205,7 +200,7 @@ static s32 bmp085_get_temperature(struct bmp085_data *data, int *temperature) | |||
205 | int status; | 200 | int status; |
206 | 201 | ||
207 | status = bmp085_update_raw_temperature(data); | 202 | status = bmp085_update_raw_temperature(data); |
208 | if (status != 0) | 203 | if (status < 0) |
209 | goto exit; | 204 | goto exit; |
210 | 205 | ||
211 | x1 = ((data->raw_temperature - cali->AC6) * cali->AC5) >> 15; | 206 | x1 = ((data->raw_temperature - cali->AC6) * cali->AC5) >> 15; |
@@ -222,8 +217,10 @@ exit: | |||
222 | /* | 217 | /* |
223 | * This function starts the pressure measurement and returns the value | 218 | * This function starts the pressure measurement and returns the value |
224 | * in millibar. Since the pressure depends on the ambient temperature, | 219 | * in millibar. Since the pressure depends on the ambient temperature, |
225 | * a temperature measurement is executed if the last known value is older | 220 | * a temperature measurement is executed according to the given temperature |
226 | * than one second. | 221 | * measurement period (default is 1 sec boundary). This period could vary |
222 | * and needs to be adjusted according to the sensor environment, i.e. if big | ||
223 | * temperature variations then the temperature needs to be read out often. | ||
227 | */ | 224 | */ |
228 | static s32 bmp085_get_pressure(struct bmp085_data *data, int *pressure) | 225 | static s32 bmp085_get_pressure(struct bmp085_data *data, int *pressure) |
229 | { | 226 | { |
@@ -234,16 +231,16 @@ static s32 bmp085_get_pressure(struct bmp085_data *data, int *pressure) | |||
234 | int status; | 231 | int status; |
235 | 232 | ||
236 | /* alt least every second force an update of the ambient temperature */ | 233 | /* alt least every second force an update of the ambient temperature */ |
237 | if (data->last_temp_measurement == 0 || | 234 | if ((data->last_temp_measurement == 0) || |
238 | time_is_before_jiffies(data->last_temp_measurement + 1*HZ)) { | 235 | time_is_before_jiffies(data->last_temp_measurement + 1*HZ)) { |
239 | status = bmp085_get_temperature(data, NULL); | 236 | status = bmp085_get_temperature(data, NULL); |
240 | if (status != 0) | 237 | if (status < 0) |
241 | goto exit; | 238 | return status; |
242 | } | 239 | } |
243 | 240 | ||
244 | status = bmp085_update_raw_pressure(data); | 241 | status = bmp085_update_raw_pressure(data); |
245 | if (status != 0) | 242 | if (status < 0) |
246 | goto exit; | 243 | return status; |
247 | 244 | ||
248 | x1 = (data->b6 * data->b6) >> 12; | 245 | x1 = (data->b6 * data->b6) >> 12; |
249 | x1 *= cali->B2; | 246 | x1 *= cali->B2; |
@@ -274,15 +271,14 @@ static s32 bmp085_get_pressure(struct bmp085_data *data, int *pressure) | |||
274 | 271 | ||
275 | *pressure = p; | 272 | *pressure = p; |
276 | 273 | ||
277 | exit: | 274 | return 0; |
278 | return status; | ||
279 | } | 275 | } |
280 | 276 | ||
281 | /* | 277 | /* |
282 | * This function sets the chip-internal oversampling. Valid values are 0..3. | 278 | * This function sets the chip-internal oversampling. Valid values are 0..3. |
283 | * The chip will use 2^oversampling samples for internal averaging. | 279 | * The chip will use 2^oversampling samples for internal averaging. |
284 | * This influences the measurement time and the accuracy; larger values | 280 | * This influences the measurement time and the accuracy; larger values |
285 | * increase both. The datasheet gives on overview on how measurement time, | 281 | * increase both. The datasheet gives an overview on how measurement time, |
286 | * accuracy and noise correlate. | 282 | * accuracy and noise correlate. |
287 | */ | 283 | */ |
288 | static void bmp085_set_oversampling(struct bmp085_data *data, | 284 | static void bmp085_set_oversampling(struct bmp085_data *data, |
@@ -309,12 +305,16 @@ static ssize_t set_oversampling(struct device *dev, | |||
309 | struct i2c_client *client = to_i2c_client(dev); | 305 | struct i2c_client *client = to_i2c_client(dev); |
310 | struct bmp085_data *data = i2c_get_clientdata(client); | 306 | struct bmp085_data *data = i2c_get_clientdata(client); |
311 | unsigned long oversampling; | 307 | unsigned long oversampling; |
312 | int success = strict_strtoul(buf, 10, &oversampling); | 308 | int err = kstrtoul(buf, 10, &oversampling); |
313 | if (success == 0) { | 309 | |
310 | if (err == 0) { | ||
311 | mutex_lock(&data->lock); | ||
314 | bmp085_set_oversampling(data, oversampling); | 312 | bmp085_set_oversampling(data, oversampling); |
313 | mutex_unlock(&data->lock); | ||
315 | return count; | 314 | return count; |
316 | } | 315 | } |
317 | return success; | 316 | |
317 | return err; | ||
318 | } | 318 | } |
319 | 319 | ||
320 | static ssize_t show_oversampling(struct device *dev, | 320 | static ssize_t show_oversampling(struct device *dev, |
@@ -322,6 +322,7 @@ static ssize_t show_oversampling(struct device *dev, | |||
322 | { | 322 | { |
323 | struct i2c_client *client = to_i2c_client(dev); | 323 | struct i2c_client *client = to_i2c_client(dev); |
324 | struct bmp085_data *data = i2c_get_clientdata(client); | 324 | struct bmp085_data *data = i2c_get_clientdata(client); |
325 | |||
325 | return sprintf(buf, "%u\n", bmp085_get_oversampling(data)); | 326 | return sprintf(buf, "%u\n", bmp085_get_oversampling(data)); |
326 | } | 327 | } |
327 | static DEVICE_ATTR(oversampling, S_IWUSR | S_IRUGO, | 328 | static DEVICE_ATTR(oversampling, S_IWUSR | S_IRUGO, |
@@ -337,7 +338,7 @@ static ssize_t show_temperature(struct device *dev, | |||
337 | struct bmp085_data *data = i2c_get_clientdata(client); | 338 | struct bmp085_data *data = i2c_get_clientdata(client); |
338 | 339 | ||
339 | status = bmp085_get_temperature(data, &temperature); | 340 | status = bmp085_get_temperature(data, &temperature); |
340 | if (status != 0) | 341 | if (status < 0) |
341 | return status; | 342 | return status; |
342 | else | 343 | else |
343 | return sprintf(buf, "%d\n", temperature); | 344 | return sprintf(buf, "%d\n", temperature); |
@@ -354,7 +355,7 @@ static ssize_t show_pressure(struct device *dev, | |||
354 | struct bmp085_data *data = i2c_get_clientdata(client); | 355 | struct bmp085_data *data = i2c_get_clientdata(client); |
355 | 356 | ||
356 | status = bmp085_get_pressure(data, &pressure); | 357 | status = bmp085_get_pressure(data, &pressure); |
357 | if (status != 0) | 358 | if (status < 0) |
358 | return status; | 359 | return status; |
359 | else | 360 | else |
360 | return sprintf(buf, "%d\n", pressure); | 361 | return sprintf(buf, "%d\n", pressure); |
@@ -386,25 +387,23 @@ static int bmp085_detect(struct i2c_client *client, struct i2c_board_info *info) | |||
386 | 387 | ||
387 | static int bmp085_init_client(struct i2c_client *client) | 388 | static int bmp085_init_client(struct i2c_client *client) |
388 | { | 389 | { |
389 | unsigned char version; | ||
390 | int status; | ||
391 | struct bmp085_data *data = i2c_get_clientdata(client); | 390 | struct bmp085_data *data = i2c_get_clientdata(client); |
391 | int status = bmp085_read_calibration_data(client); | ||
392 | |||
393 | if (status < 0) | ||
394 | return status; | ||
395 | |||
392 | data->client = client; | 396 | data->client = client; |
393 | status = bmp085_read_calibration_data(client); | ||
394 | if (status != 0) | ||
395 | goto exit; | ||
396 | version = i2c_smbus_read_byte_data(client, BMP085_VERSION_REG); | ||
397 | data->last_temp_measurement = 0; | 397 | data->last_temp_measurement = 0; |
398 | data->temp_measurement_period = 1*HZ; | ||
398 | data->oversampling_setting = 3; | 399 | data->oversampling_setting = 3; |
399 | mutex_init(&data->lock); | 400 | mutex_init(&data->lock); |
400 | dev_info(&data->client->dev, "BMP085 ver. %d.%d found.\n", | 401 | |
401 | (version & 0x0F), (version & 0xF0) >> 4); | 402 | return 0; |
402 | exit: | ||
403 | return status; | ||
404 | } | 403 | } |
405 | 404 | ||
406 | static int __devinit bmp085_probe(struct i2c_client *client, | 405 | static int __devinit bmp085_probe(struct i2c_client *client, |
407 | const struct i2c_device_id *id) | 406 | const struct i2c_device_id *id) |
408 | { | 407 | { |
409 | struct bmp085_data *data; | 408 | struct bmp085_data *data; |
410 | int err = 0; | 409 | int err = 0; |
@@ -415,14 +414,11 @@ static int __devinit bmp085_probe(struct i2c_client *client, | |||
415 | goto exit; | 414 | goto exit; |
416 | } | 415 | } |
417 | 416 | ||
418 | /* default settings after POR */ | ||
419 | data->oversampling_setting = 0x00; | ||
420 | |||
421 | i2c_set_clientdata(client, data); | 417 | i2c_set_clientdata(client, data); |
422 | 418 | ||
423 | /* Initialize the BMP085 chip */ | 419 | /* Initialize the BMP085 chip */ |
424 | err = bmp085_init_client(client); | 420 | err = bmp085_init_client(client); |
425 | if (err != 0) | 421 | if (err < 0) |
426 | goto exit_free; | 422 | goto exit_free; |
427 | 423 | ||
428 | /* Register sysfs hooks */ | 424 | /* Register sysfs hooks */ |
@@ -430,8 +426,9 @@ static int __devinit bmp085_probe(struct i2c_client *client, | |||
430 | if (err) | 426 | if (err) |
431 | goto exit_free; | 427 | goto exit_free; |
432 | 428 | ||
433 | dev_info(&data->client->dev, "Successfully initialized bmp085!\n"); | 429 | dev_info(&client->dev, "Successfully initialized %s!\n", BMP085_NAME); |
434 | goto exit; | 430 | |
431 | return 0; | ||
435 | 432 | ||
436 | exit_free: | 433 | exit_free: |
437 | kfree(data); | 434 | kfree(data); |
@@ -441,13 +438,16 @@ exit: | |||
441 | 438 | ||
442 | static int __devexit bmp085_remove(struct i2c_client *client) | 439 | static int __devexit bmp085_remove(struct i2c_client *client) |
443 | { | 440 | { |
441 | struct bmp085_data *data = i2c_get_clientdata(client); | ||
442 | |||
444 | sysfs_remove_group(&client->dev.kobj, &bmp085_attr_group); | 443 | sysfs_remove_group(&client->dev.kobj, &bmp085_attr_group); |
445 | kfree(i2c_get_clientdata(client)); | 444 | kfree(data); |
445 | |||
446 | return 0; | 446 | return 0; |
447 | } | 447 | } |
448 | 448 | ||
449 | static const struct i2c_device_id bmp085_id[] = { | 449 | static const struct i2c_device_id bmp085_id[] = { |
450 | { "bmp085", 0 }, | 450 | { BMP085_NAME, 0 }, |
451 | { } | 451 | { } |
452 | }; | 452 | }; |
453 | MODULE_DEVICE_TABLE(i2c, bmp085_id); | 453 | MODULE_DEVICE_TABLE(i2c, bmp085_id); |
@@ -455,7 +455,7 @@ MODULE_DEVICE_TABLE(i2c, bmp085_id); | |||
455 | static struct i2c_driver bmp085_driver = { | 455 | static struct i2c_driver bmp085_driver = { |
456 | .driver = { | 456 | .driver = { |
457 | .owner = THIS_MODULE, | 457 | .owner = THIS_MODULE, |
458 | .name = "bmp085" | 458 | .name = BMP085_NAME |
459 | }, | 459 | }, |
460 | .id_table = bmp085_id, | 460 | .id_table = bmp085_id, |
461 | .probe = bmp085_probe, | 461 | .probe = bmp085_probe, |
@@ -467,6 +467,6 @@ static struct i2c_driver bmp085_driver = { | |||
467 | 467 | ||
468 | module_i2c_driver(bmp085_driver); | 468 | module_i2c_driver(bmp085_driver); |
469 | 469 | ||
470 | MODULE_AUTHOR("Christoph Mair <christoph.mair@gmail.com"); | 470 | MODULE_AUTHOR("Christoph Mair <christoph.mair@gmail.com>"); |
471 | MODULE_DESCRIPTION("BMP085 driver"); | 471 | MODULE_DESCRIPTION("BMP085 driver"); |
472 | MODULE_LICENSE("GPL"); | 472 | MODULE_LICENSE("GPL"); |