ina2xx-adc.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) | ina2xx-adc.c (17395ce299211a8148ee45d1d71eb740a3fec48d) |
---|---|
1/* 2 * INA2XX Current and Power Monitors 3 * 4 * Copyright 2015 Baylibre SAS. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. --- 939 unchanged lines hidden (view full) --- 948 return ina2xx_set_calibration(chip); 949} 950 951static int ina2xx_probe(struct i2c_client *client, 952 const struct i2c_device_id *id) 953{ 954 struct ina2xx_chip_info *chip; 955 struct iio_dev *indio_dev; | 1/* 2 * INA2XX Current and Power Monitors 3 * 4 * Copyright 2015 Baylibre SAS. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. --- 939 unchanged lines hidden (view full) --- 948 return ina2xx_set_calibration(chip); 949} 950 951static int ina2xx_probe(struct i2c_client *client, 952 const struct i2c_device_id *id) 953{ 954 struct ina2xx_chip_info *chip; 955 struct iio_dev *indio_dev; |
956 struct iio_buffer *buffer; | |
957 unsigned int val; 958 enum ina2xx_ids type; 959 int ret; 960 961 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); 962 if (!indio_dev) 963 return -ENOMEM; 964 --- 47 unchanged lines hidden (view full) --- 1012 } 1013 1014 ret = ina2xx_init(chip, val); 1015 if (ret) { 1016 dev_err(&client->dev, "error configuring the device\n"); 1017 return ret; 1018 } 1019 | 956 unsigned int val; 957 enum ina2xx_ids type; 958 int ret; 959 960 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); 961 if (!indio_dev) 962 return -ENOMEM; 963 --- 47 unchanged lines hidden (view full) --- 1011 } 1012 1013 ret = ina2xx_init(chip, val); 1014 if (ret) { 1015 dev_err(&client->dev, "error configuring the device\n"); 1016 return ret; 1017 } 1018 |
1020 indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; | 1019 indio_dev->modes = INDIO_DIRECT_MODE; |
1021 if (id->driver_data == ina226) { 1022 indio_dev->channels = ina226_channels; 1023 indio_dev->num_channels = ARRAY_SIZE(ina226_channels); 1024 indio_dev->info = &ina226_info; 1025 } else { 1026 indio_dev->channels = ina219_channels; 1027 indio_dev->num_channels = ARRAY_SIZE(ina219_channels); 1028 indio_dev->info = &ina219_info; 1029 } 1030 indio_dev->name = id->name; | 1020 if (id->driver_data == ina226) { 1021 indio_dev->channels = ina226_channels; 1022 indio_dev->num_channels = ARRAY_SIZE(ina226_channels); 1023 indio_dev->info = &ina226_info; 1024 } else { 1025 indio_dev->channels = ina219_channels; 1026 indio_dev->num_channels = ARRAY_SIZE(ina219_channels); 1027 indio_dev->info = &ina219_info; 1028 } 1029 indio_dev->name = id->name; |
1031 indio_dev->setup_ops = &ina2xx_setup_ops; | |
1032 | 1030 |
1033 buffer = devm_iio_kfifo_allocate(&indio_dev->dev); 1034 if (!buffer) 1035 return -ENOMEM; | 1031 ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev, 1032 INDIO_BUFFER_SOFTWARE, 1033 &ina2xx_setup_ops); 1034 if (ret) 1035 return ret; |
1036 | 1036 |
1037 iio_device_attach_buffer(indio_dev, buffer); 1038 | |
1039 return iio_device_register(indio_dev); 1040} 1041 1042static int ina2xx_remove(struct i2c_client *client) 1043{ 1044 struct iio_dev *indio_dev = i2c_get_clientdata(client); 1045 struct ina2xx_chip_info *chip = iio_priv(indio_dev); 1046 --- 56 unchanged lines hidden --- | 1037 return iio_device_register(indio_dev); 1038} 1039 1040static int ina2xx_remove(struct i2c_client *client) 1041{ 1042 struct iio_dev *indio_dev = i2c_get_clientdata(client); 1043 struct ina2xx_chip_info *chip = iio_priv(indio_dev); 1044 --- 56 unchanged lines hidden --- |