Lines Matching +full:client +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only
3 * IIO driver for the MiraMEMS DA280 3-axis accelerometer and
4 * IIO driver for the MiraMEMS DA226 2-axis accelerometer
29 * a value of + or -4096 corresponds to + or - 1G
51 struct i2c_client *client; member
54 static int da280_enable(struct i2c_client *client, bool enable) in da280_enable() argument
58 return i2c_smbus_write_byte_data(client, DA280_REG_MODE_BW, data); in da280_enable()
70 ret = i2c_smbus_read_word_data(data->client, chan->address); in da280_read_raw()
84 return -EINVAL; in da280_read_raw()
94 const struct acpi_device_id *id; in da280_match_acpi_device() local
96 id = acpi_match_device(dev->driver->acpi_match_table, dev); in da280_match_acpi_device()
97 if (!id) in da280_match_acpi_device()
98 return -EINVAL; in da280_match_acpi_device()
100 return (enum da280_chipset) id->driver_data; in da280_match_acpi_device()
103 static int da280_probe(struct i2c_client *client, in da280_probe() argument
104 const struct i2c_device_id *id) in da280_probe() argument
111 ret = i2c_smbus_read_byte_data(client, DA280_REG_CHIP_ID); in da280_probe()
113 return (ret < 0) ? ret : -ENODEV; in da280_probe()
115 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); in da280_probe()
117 return -ENOMEM; in da280_probe()
120 data->client = client; in da280_probe()
121 i2c_set_clientdata(client, indio_dev); in da280_probe()
123 indio_dev->info = &da280_info; in da280_probe()
124 indio_dev->modes = INDIO_DIRECT_MODE; in da280_probe()
125 indio_dev->channels = da280_channels; in da280_probe()
127 if (ACPI_HANDLE(&client->dev)) { in da280_probe()
128 chip = da280_match_acpi_device(&client->dev); in da280_probe()
130 chip = id->driver_data; in da280_probe()
134 indio_dev->name = "da226"; in da280_probe()
135 indio_dev->num_channels = 2; in da280_probe()
137 indio_dev->name = "da280"; in da280_probe()
138 indio_dev->num_channels = 3; in da280_probe()
141 ret = da280_enable(client, true); in da280_probe()
147 dev_err(&client->dev, "device_register failed\n"); in da280_probe()
148 da280_enable(client, false); in da280_probe()
154 static int da280_remove(struct i2c_client *client) in da280_remove() argument
156 struct iio_dev *indio_dev = i2c_get_clientdata(client); in da280_remove()
160 return da280_enable(client, false); in da280_remove()
204 MODULE_DESCRIPTION("MiraMEMS DA280 3-Axis Accelerometer driver");