si7020.c (064a74637ccdee608eb898ea3e3847b142b261c6) | si7020.c (345b48307d6961183be77748fc0ae5dd660c91a8) |
---|---|
1/* 2 * si7020.c - Silicon Labs Si7013/20/21 Relative Humidity and Temp Sensors 3 * Copyright (c) 2013,2014 Uplogix, Inc. 4 * David Barksdale <dbarksdale@uplogix.com> 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms and conditions of the GNU General Public License, 8 * version 2, as published by the Free Software Foundation. --- 42 unchanged lines hidden (view full) --- 51 switch (mask) { 52 case IIO_CHAN_INFO_RAW: 53 ret = i2c_smbus_read_word_data(*client, 54 chan->type == IIO_TEMP ? 55 SI7020CMD_TEMP_HOLD : 56 SI7020CMD_RH_HOLD); 57 if (ret < 0) 58 return ret; | 1/* 2 * si7020.c - Silicon Labs Si7013/20/21 Relative Humidity and Temp Sensors 3 * Copyright (c) 2013,2014 Uplogix, Inc. 4 * David Barksdale <dbarksdale@uplogix.com> 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms and conditions of the GNU General Public License, 8 * version 2, as published by the Free Software Foundation. --- 42 unchanged lines hidden (view full) --- 51 switch (mask) { 52 case IIO_CHAN_INFO_RAW: 53 ret = i2c_smbus_read_word_data(*client, 54 chan->type == IIO_TEMP ? 55 SI7020CMD_TEMP_HOLD : 56 SI7020CMD_RH_HOLD); 57 if (ret < 0) 58 return ret; |
59 if (chan->type == IIO_TEMP) 60 *val = ret >> 2; 61 else 62 *val = (ret & 0x3FFF) >> 2; | 59 *val = ret >> 2; 60 if (chan->type == IIO_HUMIDITYRELATIVE) 61 *val &= GENMASK(11, 0); |
63 return IIO_VAL_INT; 64 case IIO_CHAN_INFO_SCALE: 65 if (chan->type == IIO_TEMP) 66 *val = 175720; /* = 175.72 * 1000 */ 67 else 68 *val = 125 * 1000; 69 *val2 = 65536 >> 2; 70 return IIO_VAL_FRACTIONAL; --- 57 unchanged lines hidden (view full) --- 128 msleep(15); 129 130 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*client)); 131 if (!indio_dev) 132 return -ENOMEM; 133 134 data = iio_priv(indio_dev); 135 *data = client; | 62 return IIO_VAL_INT; 63 case IIO_CHAN_INFO_SCALE: 64 if (chan->type == IIO_TEMP) 65 *val = 175720; /* = 175.72 * 1000 */ 66 else 67 *val = 125 * 1000; 68 *val2 = 65536 >> 2; 69 return IIO_VAL_FRACTIONAL; --- 57 unchanged lines hidden (view full) --- 127 msleep(15); 128 129 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*client)); 130 if (!indio_dev) 131 return -ENOMEM; 132 133 data = iio_priv(indio_dev); 134 *data = client; |
136 i2c_set_clientdata(client, indio_dev); | |
137 138 indio_dev->dev.parent = &client->dev; 139 indio_dev->name = dev_name(&client->dev); 140 indio_dev->modes = INDIO_DIRECT_MODE; 141 indio_dev->info = &si7020_info; 142 indio_dev->channels = si7020_channels; 143 indio_dev->num_channels = ARRAY_SIZE(si7020_channels); 144 --- 19 unchanged lines hidden --- | 135 136 indio_dev->dev.parent = &client->dev; 137 indio_dev->name = dev_name(&client->dev); 138 indio_dev->modes = INDIO_DIRECT_MODE; 139 indio_dev->info = &si7020_info; 140 indio_dev->channels = si7020_channels; 141 indio_dev->num_channels = ARRAY_SIZE(si7020_channels); 142 --- 19 unchanged lines hidden --- |