forked from Minki/linux
ed5c2f5fd1
The value returned by an i2c driver's remove function is mostly ignored. (Only an error message is printed if the value is non-zero that the error is ignored.) So change the prototype of the remove function to return no value. This way driver authors are not tempted to assume that passing an error to the upper layer is a good idea. All drivers are adapted accordingly. There is no intended change of behaviour, all callbacks were prepared to return 0 before. Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com> Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au> Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Crt Mori <cmo@melexis.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Marek Behún <kabel@kernel.org> # for leds-turris-omnia Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Petr Machata <petrm@nvidia.com> # for mlxsw Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com> # for surface3_power Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> # for bmc150-accel-i2c + kxcjk-1013 Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> # for media/* + staging/media/* Acked-by: Miguel Ojeda <ojeda@kernel.org> # for auxdisplay/ht16k33 + auxdisplay/lcd2s Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # for versaclock5 Reviewed-by: Ajay Gupta <ajayg@nvidia.com> # for ucsi_ccg Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for iio Acked-by: Peter Rosin <peda@axentia.se> # for i2c-mux-*, max9860 Acked-by: Adrien Grassein <adrien.grassein@gmail.com> # for lontium-lt8912b Reviewed-by: Jean Delvare <jdelvare@suse.de> # for hwmon, i2c-core and i2c/muxes Acked-by: Corey Minyard <cminyard@mvista.com> # for IPMI Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> # for drivers/power Acked-by: Krzysztof Hałasa <khalasa@piap.pl> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfram Sang <wsa@kernel.org>
119 lines
2.6 KiB
C
119 lines
2.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Implements I2C interface for VTI CMA300_D0x Accelerometer driver
|
|
*
|
|
* Copyright (C) 2010 Texas Instruments
|
|
* Author: Hemanth V <hemanthv@ti.com>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/input/cma3000.h>
|
|
#include "cma3000_d0x.h"
|
|
|
|
static int cma3000_i2c_set(struct device *dev,
|
|
u8 reg, u8 val, char *msg)
|
|
{
|
|
struct i2c_client *client = to_i2c_client(dev);
|
|
int ret;
|
|
|
|
ret = i2c_smbus_write_byte_data(client, reg, val);
|
|
if (ret < 0)
|
|
dev_err(&client->dev,
|
|
"%s failed (%s, %d)\n", __func__, msg, ret);
|
|
return ret;
|
|
}
|
|
|
|
static int cma3000_i2c_read(struct device *dev, u8 reg, char *msg)
|
|
{
|
|
struct i2c_client *client = to_i2c_client(dev);
|
|
int ret;
|
|
|
|
ret = i2c_smbus_read_byte_data(client, reg);
|
|
if (ret < 0)
|
|
dev_err(&client->dev,
|
|
"%s failed (%s, %d)\n", __func__, msg, ret);
|
|
return ret;
|
|
}
|
|
|
|
static const struct cma3000_bus_ops cma3000_i2c_bops = {
|
|
.bustype = BUS_I2C,
|
|
#define CMA3000_BUSI2C (0 << 4)
|
|
.ctrl_mod = CMA3000_BUSI2C,
|
|
.read = cma3000_i2c_read,
|
|
.write = cma3000_i2c_set,
|
|
};
|
|
|
|
static int cma3000_i2c_probe(struct i2c_client *client,
|
|
const struct i2c_device_id *id)
|
|
{
|
|
struct cma3000_accl_data *data;
|
|
|
|
data = cma3000_init(&client->dev, client->irq, &cma3000_i2c_bops);
|
|
if (IS_ERR(data))
|
|
return PTR_ERR(data);
|
|
|
|
i2c_set_clientdata(client, data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void cma3000_i2c_remove(struct i2c_client *client)
|
|
{
|
|
struct cma3000_accl_data *data = i2c_get_clientdata(client);
|
|
|
|
cma3000_exit(data);
|
|
}
|
|
|
|
#ifdef CONFIG_PM
|
|
static int cma3000_i2c_suspend(struct device *dev)
|
|
{
|
|
struct i2c_client *client = to_i2c_client(dev);
|
|
struct cma3000_accl_data *data = i2c_get_clientdata(client);
|
|
|
|
cma3000_suspend(data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int cma3000_i2c_resume(struct device *dev)
|
|
{
|
|
struct i2c_client *client = to_i2c_client(dev);
|
|
struct cma3000_accl_data *data = i2c_get_clientdata(client);
|
|
|
|
cma3000_resume(data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct dev_pm_ops cma3000_i2c_pm_ops = {
|
|
.suspend = cma3000_i2c_suspend,
|
|
.resume = cma3000_i2c_resume,
|
|
};
|
|
#endif
|
|
|
|
static const struct i2c_device_id cma3000_i2c_id[] = {
|
|
{ "cma3000_d01", 0 },
|
|
{ },
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, cma3000_i2c_id);
|
|
|
|
static struct i2c_driver cma3000_i2c_driver = {
|
|
.probe = cma3000_i2c_probe,
|
|
.remove = cma3000_i2c_remove,
|
|
.id_table = cma3000_i2c_id,
|
|
.driver = {
|
|
.name = "cma3000_i2c_accl",
|
|
#ifdef CONFIG_PM
|
|
.pm = &cma3000_i2c_pm_ops,
|
|
#endif
|
|
},
|
|
};
|
|
|
|
module_i2c_driver(cma3000_i2c_driver);
|
|
|
|
MODULE_DESCRIPTION("CMA3000-D0x Accelerometer I2C Driver");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_AUTHOR("Hemanth V <hemanthv@ti.com>");
|