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
18 #define ATLAS_EZO_DRV_NAME "atlas-ezo-sensor"
116 struct i2c_client *client = data->client; in atlas_ezo_read_raw()
118 if (chan->type != IIO_CONCENTRATION) in atlas_ezo_read_raw()
119 return -EINVAL; in atlas_ezo_read_raw()
126 mutex_lock(&data->lock); in atlas_ezo_read_raw()
131 mutex_unlock(&data->lock); in atlas_ezo_read_raw()
135 msleep(data->chip->delay); in atlas_ezo_read_raw()
137 tmp = i2c_master_recv(client, data->buffer, sizeof(data->buffer)); in atlas_ezo_read_raw()
139 if (tmp < 0 || data->buffer[0] != 1) { in atlas_ezo_read_raw()
140 mutex_unlock(&data->lock); in atlas_ezo_read_raw()
141 return -EBUSY; in atlas_ezo_read_raw()
145 atlas_ezo_sanitize(data->buffer + 2); in atlas_ezo_read_raw()
147 ret = kstrtol(data->buffer + 1, 10, &tmp); in atlas_ezo_read_raw()
151 mutex_unlock(&data->lock); in atlas_ezo_read_raw()
156 switch (chan->type) { in atlas_ezo_read_raw()
163 return -EINVAL; in atlas_ezo_read_raw()
167 switch (chan->channel2) { in atlas_ezo_read_raw()
176 return -EINVAL; in atlas_ezo_read_raw()
187 { "atlas-co2-ezo", ATLAS_CO2_EZO },
188 { "atlas-o2-ezo", ATLAS_O2_EZO },
189 { "atlas-hum-ezo", ATLAS_HUM_EZO },
195 { .compatible = "atlas,co2-ezo", .data = (void *)ATLAS_CO2_EZO, },
196 { .compatible = "atlas,o2-ezo", .data = (void *)ATLAS_O2_EZO, },
197 { .compatible = "atlas,hum-ezo", .data = (void *)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()
214 of_id = of_match_device(atlas_ezo_dt_ids, &client->dev); in atlas_ezo_probe()
216 chip = &atlas_ezo_devices[id->driver_data]; in atlas_ezo_probe()
218 chip = &atlas_ezo_devices[(unsigned long)of_id->data]; in atlas_ezo_probe()
220 indio_dev->info = &atlas_info; in atlas_ezo_probe()
221 indio_dev->name = ATLAS_EZO_DRV_NAME; in atlas_ezo_probe()
222 indio_dev->channels = chip->channels; in atlas_ezo_probe()
223 indio_dev->num_channels = chip->num_channels; in atlas_ezo_probe()
224 indio_dev->modes = INDIO_DIRECT_MODE; in atlas_ezo_probe()
227 data->client = client; in atlas_ezo_probe()
228 data->chip = chip; in atlas_ezo_probe()
229 mutex_init(&data->lock); in atlas_ezo_probe()
231 return devm_iio_device_register(&client->dev, indio_dev); in atlas_ezo_probe()