iio:adc:max1363 cleanup and graduation from staging
Subsystems (3)
Jonathan Cameron
maintainercover iio:adc:max1363 cleanup and graduation from staging
Dependent on the multiple buffers series just posted. (only for fuzz though afaik)
I have been a little slack in moving my own drivers out of staging. As ever it's do what I say, not what I do ;)
Anyhow, the big bits here are moving max1363 over kfifo from sw_ring (I've been running this locally for at least 6 months). Given that it has been impossible to build this driver without buffered support for a long time and I have little motivation to make the work again, I've assumed it will never happened and hence consolidated the driver into a single file.
The other patches are straight forward tidying up and moving to cleaner approaches taken in newer drivers + getting rid of some bit rot that had occured by making minimal changes in the driver during core abi changes. This one has been with us from the start so it's hardly suprising that a few corners had gotten messy.
Finally it moves the driver out of staging.
If anyone has time to take a look at these it would be a great help.
Jonathan
Jonathan Cameron (7):
staging:iio:adc:max1363 ring_sw->kfifo conversion staging:iio:adc:max1363 consolidate files. staging:iio:adc:max1363 drop references to 'ring' given now using a
fifo
staging:iio:adc:max1363 make docs match the contents of
max1363_chip_info
staging:iio:adc:max1363 white space cleanup staging:iio:adc:max1363 cleanup regulator handling. iio:adc:max1363 move from staging.
drivers/iio/adc/Kconfig | 18 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/max1363.c | 1700 ++++++++++++++++++++++++++++++++ drivers/staging/iio/adc/Kconfig | 24 - drivers/staging/iio/adc/Makefile | 5 - drivers/staging/iio/adc/max1363.h | 177 ---- drivers/staging/iio/adc/max1363_core.c | 1444 --------------------------- drivers/staging/iio/adc/max1363_ring.c | 139 --- 8 files changed, 1719 insertions(+), 1789 deletions(-) create mode 100644 drivers/iio/adc/max1363.c delete mode 100644 drivers/staging/iio/adc/max1363.h delete mode 100644 drivers/staging/iio/adc/max1363_core.c delete mode 100644 drivers/staging/iio/adc/max1363_ring.c
Signature · 1 line
1.7.12.2
Jonathan Cameron
maintainerPATCH 2/7 staging:iio:adc:max1363 consolidate files.
For a long while now the max1363 core has selected the buffer anyway. For a while I meant to make the separation work again, but given how long it has been it is probably time to conclude it will never happen and settle for tidying up what we have.
--- drivers/staging/iio/adc/Kconfig | 16 +- drivers/staging/iio/adc/Makefile | 3 - drivers/staging/iio/adc/max1363.c | 1705 ++++++++++++++++++++++++++++++++ drivers/staging/iio/adc/max1363.h | 177 ---- drivers/staging/iio/adc/max1363_core.c | 1444 --------------------------- drivers/staging/iio/adc/max1363_ring.c | 139 --- 6 files changed, 1710 insertions(+), 1774 deletions(-)
drivers/staging/iio/adc/Kconfig +5 -11
@@ -153,8 +153,10 @@ config AD7280 config MAX1363 tristate "Maxim max1363 ADC driver" depends on I2C - select IIO_TRIGGER if IIO_BUFFER + select IIO_TRIGGER select MAX1363_RING_BUFFER + select IIO_BUFFER + select IIO_KFIFO_BUF help Say yes here to build support for many Maxim i2c analog to digital converters (ADC). (max1361, max1362, max1363, max1364, max1036,
@@ -163,16 +165,8 @@ config MAX1363 max11602, max11603, max11604, max11605, max11606, max11607, max11608, max11609, max11610, max11611, max11612, max11613, max11614, max11615, max11616, max11617, max11644, max11645, - max11646, max11647) Provides direct access via sysfs. - -config MAX1363_RING_BUFFER - bool "Maxim max1363: use ring buffer" - depends on MAX1363 - select IIO_BUFFER - select IIO_KFIFO_BUF - help - Say yes here to include ring buffer support in the MAX1363 - ADC driver. + max11646, max11647) Provides direct access via sysfs and buffered + data via the iio dev interface. config LPC32XX_ADC tristate "NXP LPC32XX ADC"
drivers/staging/iio/adc/Makefile +0 -3
@@ -2,9 +2,6 @@ # Makefile for industrial I/O ADC drivers # -max1363-y := max1363_core.o -max1363-y += max1363_ring.o - obj-$(CONFIG_MAX1363) += max1363.o ad7606-y := ad7606_core.o
drivers/staging/iio/adc/max1363.c new file +1705 -0
1,705 lines not on this page · raw message
drivers/staging/iio/adc/max1363.h deleted +0 -177
177 lines not on this page · raw message
drivers/staging/iio/adc/max1363_core.c deleted +0 -1444
1,080 lines not on this page · raw message
drivers/staging/iio/adc/max1363_ring.c deleted +0 -139
139 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.12.2
Part of the diff is not shown here. View the raw message.
Jonathan Cameron
maintainerPATCH 5/7 staging:iio:adc:max1363 white space cleanup
In reply to Jonathan Cameron--- drivers/staging/iio/adc/max1363.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/staging/iio/adc/max1363.c +1 -5
@@ -765,9 +765,9 @@ static int max1363_read_event_config(struct iio_dev *indio_dev, u64 event_code) {struct max1363_state *st =iio_priv (indio_dev); -int val;int number =IIO_EVENT_CODE_EXTRACT_CHAN (event_code); +mutex_lock (&indio_dev->mlock);if (IIO_EVENT_CODE_EXTRACT_DIR (event_code) ==IIO_EV_DIR_FALLING ) val = (1 << number) & st->mask_low;
@@ -969,8 +969,6 @@ static struct attribute_group max1363_event_attribute_group = { .name = "events", }; -#define MAX1363_EVENT_FUNCS \ -static int max1363_update_scan_mode (struct iio_dev *indio_dev,const unsigned long *scan_mask) {
@@ -1388,8 +1386,6 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { }, }; - -static int max1363_initial_setup (struct max1363_state *st) { st->setupbyte =MAX1363_SETUP_AIN3_IS_AIN3_REF_IS_VDD
Signature · 1 line
1.7.12.2
Jonathan Cameron
maintainerPATCH 6/7 staging:iio:adc:max1363 cleanup regulator handling.
In reply to Jonathan CameronFor historical reasons the regulator handling was a little clunky. This patch brings it inline with a more standard ordering wrt to allocation of the iio_device.
--- drivers/staging/iio/adc/max1363.c | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
drivers/staging/iio/adc/max1363.c +22 -22
@@ -1531,28 +1531,29 @@ static int __devinit max1363_probe(struct i2c_client *client,int ret;struct max1363_state *st;struct iio_dev *indio_dev; -struct regulator *reg; - - reg =regulator_get (&client->dev,"vcc" ); -if (IS_ERR (reg)) { - ret =PTR_ERR (reg); - goto error_out; - } - - ret =regulator_enable (reg); -if (ret) - goto error_put_reg; indio_dev =iio_device_alloc (sizeof (struct max1363_state ));if (indio_dev ==NULL ) { ret = -ENOMEM ; - goto error_disable_reg; + goto error_out; } + ret =iio_map_array_register (indio_dev, client->dev.platform_data);if (ret <0 ) goto error_free_device; + st =iio_priv (indio_dev); - st->reg = reg; + + st->reg =regulator_get (&client->dev,"vcc" ); +if (IS_ERR (st->reg)) { + ret =PTR_ERR (st->reg); + goto error_unregister_map; + } + + ret =regulator_enable (st->reg); +if (ret) + goto error_put_reg; +/* this is only used for device removal purposes */ i2c_set_clientdata (client, indio_dev);
@@ -1561,7 +1562,7 @@ static int __devinit max1363_probe(struct i2c_client *client, ret =max1363_alloc_scan_masks (indio_dev);if (ret) - goto error_unregister_map; + goto error_disable_reg;/* Estabilish that the iio_dev is a child of the i2c device */ indio_dev->dev.parent = &client->dev;
@@ -1613,12 +1614,12 @@ error_free_available_scan_masks:kfree (indio_dev->available_scan_masks); error_unregister_map:iio_map_array_unregister (indio_dev, client->dev.platform_data); -error_free_device: -iio_device_free (indio_dev); error_disable_reg: -regulator_disable (reg); +regulator_disable (st->reg); error_put_reg: -regulator_put (reg); +regulator_put (st->reg); +error_free_device: +iio_device_free (indio_dev); error_out:return ret; }
@@ -1627,7 +1628,6 @@ static int __devexit max1363_remove(struct i2c_client *client) {struct iio_dev *indio_dev =i2c_get_clientdata (client);struct max1363_state *st =iio_priv (indio_dev); -struct regulator *reg = st->reg;iio_device_unregister (indio_dev);if (client->irq)
@@ -1635,9 +1635,9 @@ static int __devexit max1363_remove(struct i2c_client *client)iio_buffer_unregister (indio_dev);max1363_buffer_cleanup (indio_dev);kfree (indio_dev->available_scan_masks); -if (!IS_ERR (reg)) { -regulator_disable (reg); -regulator_put (reg); +if (!IS_ERR (st->reg)) { +regulator_disable (st->reg); +regulator_put (st->reg); }iio_map_array_unregister (indio_dev, client->dev.platform_data);iio_device_free (indio_dev);
Signature · 1 line
1.7.12.2
Jonathan Cameron
maintainerPATCH 7/7 iio:adc:max1363 move from staging.
In reply to Jonathan CameronNow this driver is using kfifo we can move it out of staging.
--- drivers/iio/adc/Kconfig | 18 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/max1363.c | 1700 +++++++++++++++++++++++++++++++++++++ drivers/staging/iio/adc/Kconfig | 18 - drivers/staging/iio/adc/Makefile | 2 - drivers/staging/iio/adc/max1363.c | 1700 ------------------------------------- 6 files changed, 1719 insertions(+), 1720 deletions(-)
drivers/iio/adc/Kconfig +18 -0
@@ -60,4 +60,22 @@ config LP8788_ADC help Say yes here to build support for TI LP8788 ADC. +config MAX1363 + tristate "Maxim max1363 ADC driver" + depends on I2C + select IIO_TRIGGER + select MAX1363_RING_BUFFER + select IIO_BUFFER + select IIO_KFIFO_BUF + help + Say yes here to build support for many Maxim i2c analog to digital + converters (ADC). (max1361, max1362, max1363, max1364, max1036, + max1037, max1038, max1039, max1136, max1136, max1137, max1138, + max1139, max1236, max1237, max11238, max1239, max11600, max11601, + max11602, max11603, max11604, max11605, max11606, max11607, + max11608, max11609, max11610, max11611, max11612, max11613, + max11614, max11615, max11616, max11617, max11644, max11645, + max11646, max11647) Provides direct access via sysfs and buffered + data via the iio dev interface. + endmenu
drivers/iio/adc/Makefile +1 -0
@@ -8,3 +8,4 @@ obj-$(CONFIG_AD7476) += ad7476.o obj-$(CONFIG_AD7791) += ad7791.o obj-$(CONFIG_AT91_ADC) += at91_adc.o obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o +obj-$(CONFIG_MAX1363) += max1363.o
drivers/iio/adc/max1363.c new file +1700 -0
1,700 lines not on this page · raw message
drivers/staging/iio/adc/Kconfig +0 -18
@@ -150,24 +150,6 @@ config AD7280 To compile this driver as a module, choose M here: the module will be called ad7280a -config MAX1363 - tristate "Maxim max1363 ADC driver" - depends on I2C - select IIO_TRIGGER - select MAX1363_RING_BUFFER - select IIO_BUFFER - select IIO_KFIFO_BUF - help - Say yes here to build support for many Maxim i2c analog to digital - converters (ADC). (max1361, max1362, max1363, max1364, max1036, - max1037, max1038, max1039, max1136, max1136, max1137, max1138, - max1139, max1236, max1237, max11238, max1239, max11600, max11601, - max11602, max11603, max11604, max11605, max11606, max11607, - max11608, max11609, max11610, max11611, max11612, max11613, - max11614, max11615, max11616, max11617, max11644, max11645, - max11646, max11647) Provides direct access via sysfs and buffered - data via the iio dev interface. - config LPC32XX_ADC tristate "NXP LPC32XX ADC" depends on ARCH_LPC32XX
drivers/staging/iio/adc/Makefile +0 -2
@@ -2,8 +2,6 @@ # Makefile for industrial I/O ADC drivers # -obj-$(CONFIG_MAX1363) += max1363.o - ad7606-y := ad7606_core.o ad7606-$(CONFIG_IIO_BUFFER) += ad7606_ring.o ad7606-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o
drivers/staging/iio/adc/max1363.c deleted +0 -1700
1,242 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.12.2
Part of the diff is not shown here. View the raw message.
Jonathan Cameron
maintainerPATCH 1/7 staging:iio:adc:max1363 ring_sw->kfifo conversion
In reply to Jonathan CameronWe are moving towards scrapping ring_sw so this move is necessary.
--- drivers/staging/iio/adc/Kconfig | 2 +- drivers/staging/iio/adc/max1363_ring.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/iio/adc/Kconfig +1 -1
@@ -169,7 +169,7 @@ config MAX1363_RING_BUFFER bool "Maxim max1363: use ring buffer" depends on MAX1363 select IIO_BUFFER - select IIO_SW_RING + select IIO_KFIFO_BUF help Say yes here to include ring buffer support in the MAX1363 ADC driver.
drivers/staging/iio/adc/max1363_ring.c +4 -4
@@ -16,7 +16,7 @@#include <linux/iio/iio.h> #include <linux/iio/buffer.h> -#include "../ring_sw.h" +#include <linux/iio/kfifo_buf.h> #include <linux/iio/trigger_consumer.h> #include "max1363.h"
@@ -101,7 +101,7 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)struct max1363_state *st =iio_priv (indio_dev);int ret =0 ; - indio_dev->buffer =iio_sw_rb_allocate (indio_dev); + indio_dev->buffer =iio_kfifo_allocate (indio_dev);if (!indio_dev->buffer) { ret = -ENOMEM ; goto error_ret;
@@ -126,7 +126,7 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)return 0 ; error_deallocate_sw_rb: -iio_sw_rb_free (indio_dev->buffer); +iio_kfifo_free (indio_dev->buffer); error_ret:return ret; }
@@ -135,5 +135,5 @@ void max1363_ring_cleanup(struct iio_dev *indio_dev) {/* ensure that the trigger has been detached */ iio_dealloc_pollfunc (indio_dev->pollfunc); -iio_sw_rb_free (indio_dev->buffer); +iio_kfifo_free (indio_dev->buffer); }
Signature · 1 line
1.7.12.2
Jonathan Cameron
maintainerPATCH 3/7 staging:iio:adc:max1363 drop references to 'ring' given now using a fifo
In reply to Jonathan CameronSeems worth clearing the old naming out to avoid any confusion in the future.
--- drivers/staging/iio/adc/max1363.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/staging/iio/adc/max1363.c +14 -14
@@ -788,7 +788,7 @@ static int max1363_monitor_mode_update(struct max1363_state *st, int enabled)const long *modemask;if (!enabled) { -/* transition to ring capture is not currently supported */ +/* transition to buffered capture is not currently supported */ st->setupbyte &= ~MAX1363_SETUP_MONITOR_SETUP ; st->configbyte &= ~MAX1363_SCAN_MASK ; st->monitor_on = false;
@@ -1482,13 +1482,13 @@ done:return IRQ_HANDLED ; } -static const struct iio_buffer_setup_ops max1363_ring_setup_ops = { +static const struct iio_buffer_setup_ops max1363_buffered_setup_ops = { .postenable = &iio_triggered_buffer_postenable, .preenable = &iio_sw_buffer_preenable, .predisable = &iio_triggered_buffer_predisable, }; -static int max1363_register_ring_funcs_and_init (struct iio_dev *indio_dev) +static int max1363_register_buffered_funcs_and_init (struct iio_dev *indio_dev) {struct max1363_state *st =iio_priv (indio_dev);int ret =0 ;
@@ -1509,10 +1509,10 @@ static int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev) ret = -ENOMEM ; goto error_deallocate_sw_rb; } -/* Ring buffer functions - here trigger setup related */ - indio_dev->setup_ops = &max1363_ring_setup_ops; +/* Buffer functions - here trigger setup related */ + indio_dev->setup_ops = &max1363_buffered_setup_ops; -/* Flag that polled ring buffering is possible */ +/* Flag that polled buffering is possible */ indio_dev->modes |=INDIO_BUFFER_TRIGGERED ;return 0 ;
@@ -1523,7 +1523,7 @@ error_ret:return ret; } -static void max1363_ring_cleanup (struct iio_dev *indio_dev) +static void max1363_buffer_cleanup (struct iio_dev *indio_dev) {/* ensure that the trigger has been detached */ iio_dealloc_pollfunc (indio_dev->pollfunc);
@@ -1581,7 +1581,7 @@ static int __devinit max1363_probe(struct i2c_client *client,if (ret <0 ) goto error_free_available_scan_masks; - ret =max1363_register_ring_funcs_and_init (indio_dev); + ret =max1363_register_buffered_funcs_and_init (indio_dev);if (ret) goto error_free_available_scan_masks;
@@ -1589,7 +1589,7 @@ static int __devinit max1363_probe(struct i2c_client *client, st->chip_info->channels, st->chip_info->num_channels);if (ret) - goto error_cleanup_ring; + goto error_cleanup_buffer;if (client->irq) { ret = request_threaded_irq(st->client->irq,
@@ -1600,7 +1600,7 @@ static int __devinit max1363_probe(struct i2c_client *client, indio_dev);if (ret) - goto error_uninit_ring; + goto error_uninit_buffer; } ret =iio_device_register (indio_dev);
@@ -1610,10 +1610,10 @@ static int __devinit max1363_probe(struct i2c_client *client,return 0 ; error_free_irq:free_irq (st->client->irq, indio_dev); -error_uninit_ring: +error_uninit_buffer:iio_buffer_unregister (indio_dev); -error_cleanup_ring: -max1363_ring_cleanup (indio_dev); +error_cleanup_buffer: +max1363_buffer_cleanup (indio_dev); error_free_available_scan_masks:kfree (indio_dev->available_scan_masks); error_unregister_map:
@@ -1638,7 +1638,7 @@ static int __devexit max1363_remove(struct i2c_client *client)if (client->irq)free_irq (st->client->irq, indio_dev);iio_buffer_unregister (indio_dev); -max1363_ring_cleanup (indio_dev); +max1363_buffer_cleanup (indio_dev);kfree (indio_dev->available_scan_masks);if (!IS_ERR (reg)) {regulator_disable (reg);
Signature · 1 line
1.7.12.2
Jonathan Cameron
maintainerPATCH 4/7 staging:iio:adc:max1363 make docs match the contents of max1363_chip_info
In reply to Jonathan Cameron--- drivers/staging/iio/adc/max1363.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/staging/iio/adc/max1363.c +6 -7
@@ -127,20 +127,19 @@ enum max1363_modes {/** * struct max1363_chip_info - chip specifc information -* @name: indentification string for chip -* @bits: accuracy of the adc in bits -* @int_vref_mv: the internal reference voltage * @info: iio core function callbacks structure +* @channels: channel specification +* @num_channels: number of channels * @mode_list: array of available scan modes -* @num_modes: the number of scan modes available * @default_mode: the scan mode in which the chip starts up -* @channel: channel specification +* @int_vref_mv: the internal reference voltage * @num_channels: number of channels +* @bits: accuracy of the adc in bits */ struct max1363_chip_info {const struct iio_info *info; -const struct iio_chan_spec *channels; -int num_channels; +const struct iio_chan_spec *channels; +int num_channels;const enum max1363_modes *mode_list;enum max1363_modes default_mode;u16 int_vref_mv;
Signature · 1 line
1.7.12.2