1217494e5SDenis CIOCCA /* 2217494e5SDenis CIOCCA * STMicroelectronics pressures driver 3217494e5SDenis CIOCCA * 4217494e5SDenis CIOCCA * Copyright 2013 STMicroelectronics Inc. 5217494e5SDenis CIOCCA * 6217494e5SDenis CIOCCA * Denis Ciocca <denis.ciocca@st.com> 7217494e5SDenis CIOCCA * 8217494e5SDenis CIOCCA * Licensed under the GPL-2. 9217494e5SDenis CIOCCA */ 10217494e5SDenis CIOCCA 11217494e5SDenis CIOCCA #include <linux/kernel.h> 12217494e5SDenis CIOCCA #include <linux/module.h> 13217494e5SDenis CIOCCA #include <linux/slab.h> 14217494e5SDenis CIOCCA #include <linux/i2c.h> 15217494e5SDenis CIOCCA #include <linux/iio/iio.h> 16217494e5SDenis CIOCCA 17217494e5SDenis CIOCCA #include <linux/iio/common/st_sensors.h> 18217494e5SDenis CIOCCA #include <linux/iio/common/st_sensors_i2c.h> 19217494e5SDenis CIOCCA #include "st_pressure.h" 20217494e5SDenis CIOCCA 21217494e5SDenis CIOCCA static int st_press_i2c_probe(struct i2c_client *client, 22217494e5SDenis CIOCCA const struct i2c_device_id *id) 23217494e5SDenis CIOCCA { 24217494e5SDenis CIOCCA struct iio_dev *indio_dev; 25217494e5SDenis CIOCCA struct st_sensor_data *pdata; 26217494e5SDenis CIOCCA int err; 27217494e5SDenis CIOCCA 28d0fe8c8bSSachin Kamat indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*pdata)); 29d0fe8c8bSSachin Kamat if (!indio_dev) 30d0fe8c8bSSachin Kamat return -ENOMEM; 31217494e5SDenis CIOCCA 32217494e5SDenis CIOCCA pdata = iio_priv(indio_dev); 33217494e5SDenis CIOCCA pdata->dev = &client->dev; 34217494e5SDenis CIOCCA 35217494e5SDenis CIOCCA st_sensors_i2c_configure(indio_dev, client, pdata); 36217494e5SDenis CIOCCA 3723cde4d6SDenis CIOCCA err = st_press_common_probe(indio_dev, client->dev.platform_data); 38217494e5SDenis CIOCCA if (err < 0) 39d0fe8c8bSSachin Kamat return err; 40217494e5SDenis CIOCCA 41217494e5SDenis CIOCCA return 0; 42217494e5SDenis CIOCCA } 43217494e5SDenis CIOCCA 44217494e5SDenis CIOCCA static int st_press_i2c_remove(struct i2c_client *client) 45217494e5SDenis CIOCCA { 46217494e5SDenis CIOCCA st_press_common_remove(i2c_get_clientdata(client)); 47217494e5SDenis CIOCCA 48217494e5SDenis CIOCCA return 0; 49217494e5SDenis CIOCCA } 50217494e5SDenis CIOCCA 51217494e5SDenis CIOCCA static const struct i2c_device_id st_press_id_table[] = { 52*7885a8ceSLee Jones { LPS001WP_PRESS_DEV_NAME }, 53217494e5SDenis CIOCCA { LPS331AP_PRESS_DEV_NAME }, 54217494e5SDenis CIOCCA {}, 55217494e5SDenis CIOCCA }; 56217494e5SDenis CIOCCA MODULE_DEVICE_TABLE(i2c, st_press_id_table); 57217494e5SDenis CIOCCA 58217494e5SDenis CIOCCA static struct i2c_driver st_press_driver = { 59217494e5SDenis CIOCCA .driver = { 60217494e5SDenis CIOCCA .owner = THIS_MODULE, 61217494e5SDenis CIOCCA .name = "st-press-i2c", 62217494e5SDenis CIOCCA }, 63217494e5SDenis CIOCCA .probe = st_press_i2c_probe, 64217494e5SDenis CIOCCA .remove = st_press_i2c_remove, 65217494e5SDenis CIOCCA .id_table = st_press_id_table, 66217494e5SDenis CIOCCA }; 67217494e5SDenis CIOCCA module_i2c_driver(st_press_driver); 68217494e5SDenis CIOCCA 69217494e5SDenis CIOCCA MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>"); 70217494e5SDenis CIOCCA MODULE_DESCRIPTION("STMicroelectronics pressures i2c driver"); 71217494e5SDenis CIOCCA MODULE_LICENSE("GPL v2"); 72