gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / iio / pressure / mpl115_i2c.c
blobac1f12bcb65e9f9da21f8fd179198badaed97503
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Freescale MPL115A2 pressure/temperature sensor
5 * Copyright (c) 2014 Peter Meerwald <pmeerw@pmeerw.net>
7 * (7-bit I2C slave address 0x60)
9 * Datasheet: http://www.nxp.com/files/sensors/doc/data_sheet/MPL115A2.pdf
12 #include <linux/module.h>
13 #include <linux/i2c.h>
15 #include "mpl115.h"
17 static int mpl115_i2c_init(struct device *dev)
19 return 0;
22 static int mpl115_i2c_read(struct device *dev, u8 address)
24 return i2c_smbus_read_word_swapped(to_i2c_client(dev), address);
27 static int mpl115_i2c_write(struct device *dev, u8 address, u8 value)
29 return i2c_smbus_write_byte_data(to_i2c_client(dev), address, value);
32 static const struct mpl115_ops mpl115_i2c_ops = {
33 .init = mpl115_i2c_init,
34 .read = mpl115_i2c_read,
35 .write = mpl115_i2c_write,
38 static int mpl115_i2c_probe(struct i2c_client *client,
39 const struct i2c_device_id *id)
41 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
42 return -EOPNOTSUPP;
44 return mpl115_probe(&client->dev, id->name, &mpl115_i2c_ops);
47 static const struct i2c_device_id mpl115_i2c_id[] = {
48 { "mpl115", 0 },
49 { }
51 MODULE_DEVICE_TABLE(i2c, mpl115_i2c_id);
53 static struct i2c_driver mpl115_i2c_driver = {
54 .driver = {
55 .name = "mpl115",
57 .probe = mpl115_i2c_probe,
58 .id_table = mpl115_i2c_id,
60 module_i2c_driver(mpl115_i2c_driver);
62 MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
63 MODULE_DESCRIPTION("Freescale MPL115A2 pressure/temperature driver");
64 MODULE_LICENSE("GPL");