Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | lm75.c - Part of lm_sensors, Linux kernel modules for hardware |
| 3 | monitoring |
| 4 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | */ |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/module.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/slab.h> |
| 24 | #include <linux/jiffies.h> |
| 25 | #include <linux/i2c.h> |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 26 | #include <linux/hwmon.h> |
Jean Delvare | 9ca8e40c8 | 2007-05-08 17:22:01 +0200 | [diff] [blame] | 27 | #include <linux/hwmon-sysfs.h> |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 28 | #include <linux/err.h> |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 29 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include "lm75.h" |
| 31 | |
| 32 | |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 33 | /* |
| 34 | * This driver handles the LM75 and compatible digital temperature sensors. |
| 35 | * Compatibles include at least the DS75, DS1775, MCP980x, STDS75, TCN75, |
| 36 | * TMP100, TMP101, TMP75, TMP175, and TMP275. |
| 37 | */ |
| 38 | |
| 39 | /* Addresses scanned by legacy style driver binding */ |
Mark M. Hoffman | 25e9c86 | 2008-02-17 22:28:03 -0500 | [diff] [blame] | 40 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 43 | /* Insmod parameters (only for legacy style driver binding) */ |
Jean Delvare | f4b5026 | 2005-07-31 21:49:03 +0200 | [diff] [blame] | 44 | I2C_CLIENT_INSMOD_1(lm75); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | /* The LM75 registers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define LM75_REG_CONF 0x01 |
Jean Delvare | 9ca8e40c8 | 2007-05-08 17:22:01 +0200 | [diff] [blame] | 49 | static const u8 LM75_REG_TEMP[3] = { |
| 50 | 0x00, /* input */ |
| 51 | 0x03, /* max */ |
| 52 | 0x02, /* hyst */ |
| 53 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | /* Each client has this additional data */ |
| 56 | struct lm75_data { |
| 57 | struct i2c_client client; |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 58 | struct device *hwmon_dev; |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 59 | struct mutex update_lock; |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 60 | char valid; /* !=0 if registers are valid */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | unsigned long last_updated; /* In jiffies */ |
Jean Delvare | 9ca8e40c8 | 2007-05-08 17:22:01 +0200 | [diff] [blame] | 62 | u16 temp[3]; /* Register values, |
| 63 | 0 = input |
| 64 | 1 = max |
| 65 | 2 = hyst */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | static void lm75_init_client(struct i2c_client *client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | static int lm75_read_value(struct i2c_client *client, u8 reg); |
| 70 | static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value); |
| 71 | static struct lm75_data *lm75_update_device(struct device *dev); |
| 72 | |
| 73 | |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 74 | /*-----------------------------------------------------------------------*/ |
| 75 | |
| 76 | /* sysfs attributes for hwmon */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Jean Delvare | 9ca8e40c8 | 2007-05-08 17:22:01 +0200 | [diff] [blame] | 78 | static ssize_t show_temp(struct device *dev, struct device_attribute *da, |
| 79 | char *buf) |
| 80 | { |
| 81 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
| 82 | struct lm75_data *data = lm75_update_device(dev); |
| 83 | return sprintf(buf, "%d\n", |
| 84 | LM75_TEMP_FROM_REG(data->temp[attr->index])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
Jean Delvare | 9ca8e40c8 | 2007-05-08 17:22:01 +0200 | [diff] [blame] | 87 | static ssize_t set_temp(struct device *dev, struct device_attribute *da, |
| 88 | const char *buf, size_t count) |
| 89 | { |
| 90 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
| 91 | struct i2c_client *client = to_i2c_client(dev); |
| 92 | struct lm75_data *data = i2c_get_clientdata(client); |
| 93 | int nr = attr->index; |
Christian Hohnstaedt | 5bfedac | 2007-08-16 11:40:10 +0200 | [diff] [blame] | 94 | long temp = simple_strtol(buf, NULL, 10); |
Jean Delvare | 9ca8e40c8 | 2007-05-08 17:22:01 +0200 | [diff] [blame] | 95 | |
| 96 | mutex_lock(&data->update_lock); |
| 97 | data->temp[nr] = LM75_TEMP_TO_REG(temp); |
| 98 | lm75_write_value(client, LM75_REG_TEMP[nr], data->temp[nr]); |
| 99 | mutex_unlock(&data->update_lock); |
| 100 | return count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Jean Delvare | 9ca8e40c8 | 2007-05-08 17:22:01 +0200 | [diff] [blame] | 103 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, |
| 104 | show_temp, set_temp, 1); |
| 105 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, |
| 106 | show_temp, set_temp, 2); |
| 107 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
Mark M. Hoffman | c1685f6 | 2006-09-24 20:59:49 +0200 | [diff] [blame] | 109 | static struct attribute *lm75_attributes[] = { |
Jean Delvare | 9ca8e40c8 | 2007-05-08 17:22:01 +0200 | [diff] [blame] | 110 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
| 111 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
| 112 | &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, |
Mark M. Hoffman | c1685f6 | 2006-09-24 20:59:49 +0200 | [diff] [blame] | 113 | |
| 114 | NULL |
| 115 | }; |
| 116 | |
| 117 | static const struct attribute_group lm75_group = { |
| 118 | .attrs = lm75_attributes, |
| 119 | }; |
| 120 | |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 121 | /*-----------------------------------------------------------------------*/ |
| 122 | |
| 123 | /* "Legacy" I2C driver binding */ |
| 124 | |
| 125 | static struct i2c_driver lm75_driver; |
| 126 | |
Jean Delvare | 2ed2dc3 | 2005-07-31 21:42:02 +0200 | [diff] [blame] | 127 | /* This function is called by i2c_probe */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) |
| 129 | { |
| 130 | int i; |
| 131 | struct i2c_client *new_client; |
| 132 | struct lm75_data *data; |
| 133 | int err = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
| 136 | I2C_FUNC_SMBUS_WORD_DATA)) |
| 137 | goto exit; |
| 138 | |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 139 | /* OK. For now, we presume we have a valid address. We create the |
| 140 | client structure, even though there may be no sensor present. |
| 141 | But it allows us to use i2c_smbus_read_*_data() calls. */ |
Deepak Saxena | ba9c2e8 | 2005-10-17 23:08:32 +0200 | [diff] [blame] | 142 | if (!(data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | err = -ENOMEM; |
| 144 | goto exit; |
| 145 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
| 147 | new_client = &data->client; |
| 148 | i2c_set_clientdata(new_client, data); |
| 149 | new_client->addr = address; |
| 150 | new_client->adapter = adapter; |
| 151 | new_client->driver = &lm75_driver; |
| 152 | new_client->flags = 0; |
| 153 | |
| 154 | /* Now, we do the remaining detection. There is no identification- |
| 155 | dedicated register so we have to rely on several tricks: |
| 156 | unused bits, registers cycling over 8-address boundaries, |
| 157 | addresses 0x04-0x07 returning the last read value. |
| 158 | The cycling+unused addresses combination is not tested, |
| 159 | since it would significantly slow the detection down and would |
| 160 | hardly add any value. */ |
| 161 | if (kind < 0) { |
| 162 | int cur, conf, hyst, os; |
| 163 | |
| 164 | /* Unused addresses */ |
| 165 | cur = i2c_smbus_read_word_data(new_client, 0); |
| 166 | conf = i2c_smbus_read_byte_data(new_client, 1); |
| 167 | hyst = i2c_smbus_read_word_data(new_client, 2); |
| 168 | if (i2c_smbus_read_word_data(new_client, 4) != hyst |
| 169 | || i2c_smbus_read_word_data(new_client, 5) != hyst |
| 170 | || i2c_smbus_read_word_data(new_client, 6) != hyst |
| 171 | || i2c_smbus_read_word_data(new_client, 7) != hyst) |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 172 | goto exit_free; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | os = i2c_smbus_read_word_data(new_client, 3); |
| 174 | if (i2c_smbus_read_word_data(new_client, 4) != os |
| 175 | || i2c_smbus_read_word_data(new_client, 5) != os |
| 176 | || i2c_smbus_read_word_data(new_client, 6) != os |
| 177 | || i2c_smbus_read_word_data(new_client, 7) != os) |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 178 | goto exit_free; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
| 180 | /* Unused bits */ |
| 181 | if (conf & 0xe0) |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 182 | goto exit_free; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
| 184 | /* Addresses cycling */ |
| 185 | for (i = 8; i < 0xff; i += 8) |
| 186 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf |
| 187 | || i2c_smbus_read_word_data(new_client, i + 2) != hyst |
| 188 | || i2c_smbus_read_word_data(new_client, i + 3) != os) |
| 189 | goto exit_free; |
| 190 | } |
| 191 | |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 192 | /* NOTE: we treat "force=..." and "force_lm75=..." the same. */ |
| 193 | strlcpy(new_client->name, "lm75", I2C_NAME_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
| 195 | /* Fill in the remaining client fields and put it into the global list */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | data->valid = 0; |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 197 | mutex_init(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | |
| 199 | /* Tell the I2C layer a new client has arrived */ |
| 200 | if ((err = i2c_attach_client(new_client))) |
| 201 | goto exit_free; |
| 202 | |
| 203 | /* Initialize the LM75 chip */ |
| 204 | lm75_init_client(new_client); |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 205 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | /* Register sysfs hooks */ |
Mark M. Hoffman | c1685f6 | 2006-09-24 20:59:49 +0200 | [diff] [blame] | 207 | if ((err = sysfs_create_group(&new_client->dev.kobj, &lm75_group))) |
| 208 | goto exit_detach; |
| 209 | |
Tony Jones | 1beeffe | 2007-08-20 13:46:20 -0700 | [diff] [blame] | 210 | data->hwmon_dev = hwmon_device_register(&new_client->dev); |
| 211 | if (IS_ERR(data->hwmon_dev)) { |
| 212 | err = PTR_ERR(data->hwmon_dev); |
Mark M. Hoffman | c1685f6 | 2006-09-24 20:59:49 +0200 | [diff] [blame] | 213 | goto exit_remove; |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 214 | } |
| 215 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | return 0; |
| 217 | |
Mark M. Hoffman | c1685f6 | 2006-09-24 20:59:49 +0200 | [diff] [blame] | 218 | exit_remove: |
| 219 | sysfs_remove_group(&new_client->dev.kobj, &lm75_group); |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 220 | exit_detach: |
| 221 | i2c_detach_client(new_client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | exit_free: |
| 223 | kfree(data); |
| 224 | exit: |
| 225 | return err; |
| 226 | } |
| 227 | |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 228 | static int lm75_attach_adapter(struct i2c_adapter *adapter) |
| 229 | { |
| 230 | if (!(adapter->class & I2C_CLASS_HWMON)) |
| 231 | return 0; |
| 232 | return i2c_probe(adapter, &addr_data, lm75_detect); |
| 233 | } |
| 234 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | static int lm75_detach_client(struct i2c_client *client) |
| 236 | { |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 237 | struct lm75_data *data = i2c_get_clientdata(client); |
Tony Jones | 1beeffe | 2007-08-20 13:46:20 -0700 | [diff] [blame] | 238 | hwmon_device_unregister(data->hwmon_dev); |
Mark M. Hoffman | c1685f6 | 2006-09-24 20:59:49 +0200 | [diff] [blame] | 239 | sysfs_remove_group(&client->dev.kobj, &lm75_group); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | i2c_detach_client(client); |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 241 | kfree(data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | return 0; |
| 243 | } |
| 244 | |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 245 | static struct i2c_driver lm75_driver = { |
| 246 | .driver = { |
| 247 | .name = "lm75", |
| 248 | }, |
| 249 | .attach_adapter = lm75_attach_adapter, |
| 250 | .detach_client = lm75_detach_client, |
| 251 | }; |
| 252 | |
| 253 | /*-----------------------------------------------------------------------*/ |
| 254 | |
| 255 | /* register access */ |
| 256 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | /* All registers are word-sized, except for the configuration register. |
| 258 | LM75 uses a high-byte first convention, which is exactly opposite to |
Jean Delvare | ccd6bef | 2008-02-19 12:42:58 +0100 | [diff] [blame] | 259 | the SMBus standard. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | static int lm75_read_value(struct i2c_client *client, u8 reg) |
| 261 | { |
David Brownell | bcccc3a | 2008-05-03 19:19:16 -0700 | [diff] [blame] | 262 | int value; |
| 263 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | if (reg == LM75_REG_CONF) |
| 265 | return i2c_smbus_read_byte_data(client, reg); |
David Brownell | bcccc3a | 2008-05-03 19:19:16 -0700 | [diff] [blame] | 266 | |
| 267 | value = i2c_smbus_read_word_data(client, reg); |
| 268 | return (value < 0) ? value : swab16(value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) |
| 272 | { |
| 273 | if (reg == LM75_REG_CONF) |
| 274 | return i2c_smbus_write_byte_data(client, reg, value); |
| 275 | else |
| 276 | return i2c_smbus_write_word_data(client, reg, swab16(value)); |
| 277 | } |
| 278 | |
| 279 | static void lm75_init_client(struct i2c_client *client) |
| 280 | { |
Jean Delvare | e647ecf | 2005-07-27 21:28:28 +0200 | [diff] [blame] | 281 | int reg; |
| 282 | |
| 283 | /* Enable if in shutdown mode */ |
| 284 | reg = lm75_read_value(client, LM75_REG_CONF); |
| 285 | if (reg >= 0 && (reg & 0x01)) |
| 286 | lm75_write_value(client, LM75_REG_CONF, reg & 0xfe); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | static struct lm75_data *lm75_update_device(struct device *dev) |
| 290 | { |
| 291 | struct i2c_client *client = to_i2c_client(dev); |
| 292 | struct lm75_data *data = i2c_get_clientdata(client); |
| 293 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 294 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
| 296 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
| 297 | || !data->valid) { |
Jean Delvare | 9ca8e40c8 | 2007-05-08 17:22:01 +0200 | [diff] [blame] | 298 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | dev_dbg(&client->dev, "Starting lm75 update\n"); |
| 300 | |
David Brownell | bcccc3a | 2008-05-03 19:19:16 -0700 | [diff] [blame] | 301 | for (i = 0; i < ARRAY_SIZE(data->temp); i++) { |
| 302 | int status; |
| 303 | |
| 304 | status = lm75_read_value(client, LM75_REG_TEMP[i]); |
| 305 | if (status < 0) |
| 306 | dev_dbg(&client->dev, "reg %d, err %d\n", |
| 307 | LM75_REG_TEMP[i], status); |
| 308 | else |
| 309 | data->temp[i] = status; |
| 310 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | data->last_updated = jiffies; |
| 312 | data->valid = 1; |
| 313 | } |
| 314 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 315 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | |
| 317 | return data; |
| 318 | } |
| 319 | |
David Brownell | 01a5239 | 2008-04-21 12:10:53 -0700 | [diff] [blame^] | 320 | /*-----------------------------------------------------------------------*/ |
| 321 | |
| 322 | /* module glue */ |
| 323 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | static int __init sensors_lm75_init(void) |
| 325 | { |
| 326 | return i2c_add_driver(&lm75_driver); |
| 327 | } |
| 328 | |
| 329 | static void __exit sensors_lm75_exit(void) |
| 330 | { |
| 331 | i2c_del_driver(&lm75_driver); |
| 332 | } |
| 333 | |
| 334 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"); |
| 335 | MODULE_DESCRIPTION("LM75 driver"); |
| 336 | MODULE_LICENSE("GPL"); |
| 337 | |
| 338 | module_init(sensors_lm75_init); |
| 339 | module_exit(sensors_lm75_exit); |