tmp006.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) tmp006.c (2bb3b8f69accde535daee238e0f707dec452e0e4)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * tmp006.c - Support for TI TMP006 IR thermopile sensor
4 *
5 * Copyright (c) 2013 Peter Meerwald <pmeerw@pmeerw.net>
6 *
7 * Driver for the Texas Instruments I2C 16-bit IR thermopile sensor
8 *

--- 179 unchanged lines hidden (view full) ---

188
189 did = i2c_smbus_read_word_swapped(client, TMP006_DEVICE_ID);
190 if (did < 0)
191 return false;
192
193 return mid == TMP006_MANUFACTURER_MAGIC && did == TMP006_DEVICE_MAGIC;
194}
195
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * tmp006.c - Support for TI TMP006 IR thermopile sensor
4 *
5 * Copyright (c) 2013 Peter Meerwald <pmeerw@pmeerw.net>
6 *
7 * Driver for the Texas Instruments I2C 16-bit IR thermopile sensor
8 *

--- 179 unchanged lines hidden (view full) ---

188
189 did = i2c_smbus_read_word_swapped(client, TMP006_DEVICE_ID);
190 if (did < 0)
191 return false;
192
193 return mid == TMP006_MANUFACTURER_MAGIC && did == TMP006_DEVICE_MAGIC;
194}
195
196static int tmp006_powerdown(struct tmp006_data *data)
197{
198 return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG,
199 data->config & ~TMP006_CONFIG_MOD_MASK);
200}
201
202static void tmp006_powerdown_cleanup(void *data)
203{
204 tmp006_powerdown(data);
205}
206
196static int tmp006_probe(struct i2c_client *client,
197 const struct i2c_device_id *id)
198{
199 struct iio_dev *indio_dev;
200 struct tmp006_data *data;
201 int ret;
202
203 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))

--- 19 unchanged lines hidden (view full) ---

223 indio_dev->channels = tmp006_channels;
224 indio_dev->num_channels = ARRAY_SIZE(tmp006_channels);
225
226 ret = i2c_smbus_read_word_swapped(data->client, TMP006_CONFIG);
227 if (ret < 0)
228 return ret;
229 data->config = ret;
230
207static int tmp006_probe(struct i2c_client *client,
208 const struct i2c_device_id *id)
209{
210 struct iio_dev *indio_dev;
211 struct tmp006_data *data;
212 int ret;
213
214 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))

--- 19 unchanged lines hidden (view full) ---

234 indio_dev->channels = tmp006_channels;
235 indio_dev->num_channels = ARRAY_SIZE(tmp006_channels);
236
237 ret = i2c_smbus_read_word_swapped(data->client, TMP006_CONFIG);
238 if (ret < 0)
239 return ret;
240 data->config = ret;
241
231 return iio_device_register(indio_dev);
232}
242 ret = devm_add_action(&client->dev, tmp006_powerdown_cleanup, data);
243 if (ret < 0)
244 return ret;
233
245
234static int tmp006_powerdown(struct tmp006_data *data)
235{
236 return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG,
237 data->config & ~TMP006_CONFIG_MOD_MASK);
246 return devm_iio_device_register(&client->dev, indio_dev);
238}
239
247}
248
240static int tmp006_remove(struct i2c_client *client)
241{
242 struct iio_dev *indio_dev = i2c_get_clientdata(client);
243
244 iio_device_unregister(indio_dev);
245 tmp006_powerdown(iio_priv(indio_dev));
246
247 return 0;
248}
249
250#ifdef CONFIG_PM_SLEEP
251static int tmp006_suspend(struct device *dev)
252{
253 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
254 return tmp006_powerdown(iio_priv(indio_dev));
255}
256
257static int tmp006_resume(struct device *dev)

--- 14 unchanged lines hidden (view full) ---

272MODULE_DEVICE_TABLE(i2c, tmp006_id);
273
274static struct i2c_driver tmp006_driver = {
275 .driver = {
276 .name = "tmp006",
277 .pm = &tmp006_pm_ops,
278 },
279 .probe = tmp006_probe,
249#ifdef CONFIG_PM_SLEEP
250static int tmp006_suspend(struct device *dev)
251{
252 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
253 return tmp006_powerdown(iio_priv(indio_dev));
254}
255
256static int tmp006_resume(struct device *dev)

--- 14 unchanged lines hidden (view full) ---

271MODULE_DEVICE_TABLE(i2c, tmp006_id);
272
273static struct i2c_driver tmp006_driver = {
274 .driver = {
275 .name = "tmp006",
276 .pm = &tmp006_pm_ops,
277 },
278 .probe = tmp006_probe,
280 .remove = tmp006_remove,
281 .id_table = tmp006_id,
282};
283module_i2c_driver(tmp006_driver);
284
285MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
286MODULE_DESCRIPTION("TI TMP006 IR thermopile sensor driver");
287MODULE_LICENSE("GPL");
279 .id_table = tmp006_id,
280};
281module_i2c_driver(tmp006_driver);
282
283MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
284MODULE_DESCRIPTION("TI TMP006 IR thermopile sensor driver");
285MODULE_LICENSE("GPL");