Lines Matching +full:co2 +full:- +full:sensor
1 // SPDX-License-Identifier: GPL-2.0+
3 * atlas-ezo-sensor.c - Support for Atlas Scientific EZO sensors
20 #define ATLAS_EZO_DRV_NAME "atlas-ezo-sensor"
118 struct i2c_client *client = data->client; in atlas_ezo_read_raw()
120 if (chan->type != IIO_CONCENTRATION) in atlas_ezo_read_raw()
121 return -EINVAL; in atlas_ezo_read_raw()
128 mutex_lock(&data->lock); in atlas_ezo_read_raw()
133 mutex_unlock(&data->lock); in atlas_ezo_read_raw()
137 msleep(data->chip->delay); in atlas_ezo_read_raw()
139 tmp = i2c_master_recv(client, data->buffer, sizeof(data->buffer)); in atlas_ezo_read_raw()
141 if (tmp < 0 || data->buffer[0] != 1) { in atlas_ezo_read_raw()
142 mutex_unlock(&data->lock); in atlas_ezo_read_raw()
143 return -EBUSY; in atlas_ezo_read_raw()
147 atlas_ezo_sanitize(data->buffer + 2); in atlas_ezo_read_raw()
149 ret = kstrtol(data->buffer + 1, 10, &tmp); in atlas_ezo_read_raw()
153 mutex_unlock(&data->lock); in atlas_ezo_read_raw()
158 switch (chan->type) { in atlas_ezo_read_raw()
165 return -EINVAL; in atlas_ezo_read_raw()
169 switch (chan->channel2) { in atlas_ezo_read_raw()
178 return -EINVAL; in atlas_ezo_read_raw()
189 { "atlas-co2-ezo", (kernel_ulong_t)&atlas_ezo_devices[ATLAS_CO2_EZO] },
190 { "atlas-o2-ezo", (kernel_ulong_t)&atlas_ezo_devices[ATLAS_O2_EZO] },
191 { "atlas-hum-ezo", (kernel_ulong_t)&atlas_ezo_devices[ATLAS_HUM_EZO] },
197 { .compatible = "atlas,co2-ezo", .data = &atlas_ezo_devices[ATLAS_CO2_EZO], },
198 { .compatible = "atlas,o2-ezo", .data = &atlas_ezo_devices[ATLAS_O2_EZO], },
199 { .compatible = "atlas,hum-ezo", .data = &atlas_ezo_devices[ATLAS_HUM_EZO], },
210 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); in atlas_ezo_probe()
212 return -ENOMEM; in atlas_ezo_probe()
216 return -EINVAL; in atlas_ezo_probe()
218 indio_dev->info = &atlas_info; in atlas_ezo_probe()
219 indio_dev->name = ATLAS_EZO_DRV_NAME; in atlas_ezo_probe()
220 indio_dev->channels = chip->channels; in atlas_ezo_probe()
221 indio_dev->num_channels = chip->num_channels; in atlas_ezo_probe()
222 indio_dev->modes = INDIO_DIRECT_MODE; in atlas_ezo_probe()
225 data->client = client; in atlas_ezo_probe()
226 data->chip = chip; in atlas_ezo_probe()
227 mutex_init(&data->lock); in atlas_ezo_probe()
229 return devm_iio_device_register(&client->dev, indio_dev); in atlas_ezo_probe()