History log of /linux-master/drivers/iio/adc/twl4030-madc.c
Revision Date Author Comments
# 30ff88e9 19-Sep-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

iio: adc: twl4030-madc: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new() which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230919174931.1417681-27-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 4f494028 24-Oct-2022 Dmitry Torokhov <dmitry.torokhov@gmail.com>

iio: adc: twl4030-madc: add missing of.h include

The driver is using of_device_id/of_match_ptr() and therefore needs
to include of.h header. We used to get this definition indirectly via
inclusion of matrix_keypad.h from twl.h, but we are cleaning up
matrix_keypad.h from unnecessary includes.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20220927154611.3330871-3-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 8f2abd48 26-Jan-2022 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

iio: adc: twl4030-madc: Re-use generic struct s16_fract

Instead of custom data type re-use generic struct s16_fract.
No changes intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220126135353.24007-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 2006cf16 17-Jul-2020 Lee Jones <lee.jones@linaro.org>

iio: adc: twl4030-madc: Fix misnamed struct attribute

Fixes the following W=1 kernel build warning(s):

drivers/iio/adc/twl4030-madc.c:170: warning: Function parameter or member 'usb3v1' not described in 'twl4030_madc_data'

Also drop a duplicate description of the lock.

Cc: J Keerthy <j-keerthy@ti.com>
Cc: Mikko Ylinen <mikko.k.ylinen@nokia.com>
Cc: Amit Kucheria <amit.kucheria@canonical.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 8856d5c7 17-Jul-2020 Lee Jones <lee.jones@linaro.org>

iio: adc: twl4030-madc: Remove set but unused variables 'len'

Fixes the following W=1 kernel build warning(s):

drivers/iio/adc/twl4030-madc.c: In function ‘twl4030_madc_threaded_irq_handler’:
drivers/iio/adc/twl4030-madc.c:475:9: warning: variable ‘len’ set but not used [-Wunused-but-set-variable]
475 | int i, len, ret;
| ^~~

Cc: Sebastian Reichel <sre@kernel.org>
Cc: J Keerthy <j-keerthy@ti.com>
Cc: Mikko Ylinen <mikko.k.ylinen@nokia.com>
Cc: Amit Kucheria <amit.kucheria@canonical.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 3593cd53 04-Jul-2020 Alexander A. Klimov <grandmaster@al2klimov.de>

Replace HTTP links with HTTPS ones: drivers/iio

Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
If not .svg:
For each line:
If doesn't contain `\bxmlns\b`:
For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
If both the HTTP and HTTPS versions
return 200 OK and serve the same content:
Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 8cb631cc 13-Jun-2020 Lars-Peter Clausen <lars@metafoo.de>

iio: Remove superfluous of_node assignments

If a driver does not assign an of_node to a IIO device to IIO core will
automatically assign the of_node of the parent device. This automatic
assignment is done in the iio_device_register() function.

There is a fair amount of drivers that currently manually assign the
of_node of the IIO device. All but 4 of them can make use of the automatic
assignment though.

The exceptions are:
* mxs-lradc-adc: Which uses the of_node of the parent of the parent.
* stm32-dfsdm-adc, stm32-adc and stm32-dac: Which reference the of_node
assigned to the IIO device before iio_device_register() is called.

All other drivers are updated to use automatic assignment. This reduces
the amount of boilerplate code involved in setting up the IIO device.

The patch has mostly been auto-generated with the following semantic patch

// <smpl>
@exists@
expression indio_dev;
expression parent;
@@
indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(&parent, ...)
...
-indio_dev->dev.of_node = parent.of_node;

@exists@
expression indio_dev;
expression parent;
@@
indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(parent, ...)
...
-indio_dev->dev.of_node = parent->of_node;
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# d3be8324 22-May-2020 Alexandru Ardelean <alexandru.ardelean@analog.com>

iio: remove explicit IIO device parent assignment

This patch applies the semantic patch:
@@
expression I, P, SP;
@@
I = devm_iio_device_alloc(P, SP);
...
- I->dev.parent = P;

It updates 302 files and does 307 deletions.
This semantic patch also removes some comments like
'/* Establish that the iio_dev is a child of the i2c device */'

But this is is only done in case where the block is left empty.

The patch does not seem to cover all cases. It looks like in some cases a
different variable is used in some cases to assign the parent, but it
points to the same reference.
In other cases, the block covered by ... may be just too big to be covered
by the semantic patch.

However, this looks pretty good as well, as it does cover a big bulk of the
drivers that should remove the parent assignment.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 54f965db 13-Oct-2019 Jonathan Cameron <Jonathan.Cameron@huawei.com>

iio: adc: twl4030: Use false / true instead of 0 / 1 with booleans

Suggestion from coccinelle / coccicheck

CHECK drivers/iio/adc/twl4030-madc.c
drivers/iio/adc/twl4030-madc.c:524:6-15: WARNING: Comparison of 0/1 to bool variable
drivers/iio/adc/twl4030-madc.c:655:1-43: WARNING: Assignment of 0/1 to bool variable
drivers/iio/adc/twl4030-madc.c:659:2-44: WARNING: Assignment of 0/1 to bool variable
drivers/iio/adc/twl4030-madc.c:664:1-43: WARNING: Assignment of 0/1 to bool variable
drivers/iio/adc/twl4030-madc.c:498:2-34: WARNING: Assignment of 0/1 to bool variable
drivers/iio/adc/twl4030-madc.c:510:2-19: WARNING: Assignment of 0/1 to bool variable
drivers/iio/adc/twl4030-madc.c:511:2-11: WARNING: Assignment of 0/1 to bool variable
drivers/iio/adc/twl4030-madc.c:531:2-19: WARNING: Assignment of 0/1 to bool variable
drivers/iio/adc/twl4030-madc.c:532:2-11: WARNING: Assignment of 0/1 to bool variable

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Sebastian Reichel <sre@kernel.org>


# 2b27bdcc 29-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 336

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation this program is
distributed in the hope that it will be useful but without any
warranty without even the implied warranty of merchantability or
fitness for a particular purpose see the gnu general public license
for more details you should have received a copy of the gnu general
public license along with this program if not write to the free
software foundation inc 51 franklin st fifth floor boston ma 02110
1301 usa

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 246 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000436.674189849@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 53063846 23-Sep-2017 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

iio: adc: twl4030: Return an error if we can not enable the vusb3v1 regulator in 'twl4030_madc_probe()'

If we can not enable the regulator, go through the error handling path
instead of silently continuing.

Fixes: 7cc97d77ee8a ("iio: adc: twl4030: Fix ADC[3:6] readings")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 7f70be6e 23-Sep-2017 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

iio: adc: twl4030: Disable the vusb3v1 rugulator in the error handling path of 'twl4030_madc_probe()'

Commit 7cc97d77ee8a has introduced a call to 'regulator_disable()' in the
.remove function.
So we should also have such a call in the .probe function in case of
error after a successful 'regulator_enable()' call.

Add a new label for that and use it.

Fixes: 7cc97d77ee8a ("iio: adc: twl4030: Fix ADC[3:6] readings")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 245a396a 23-Sep-2017 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

iio: adc: twl4030: Fix an error handling path in 'twl4030_madc_probe()'

If 'devm_regulator_get()' fails, we should go through the existing error
handling path instead of returning directly, as done is all the other
error handling paths in this function.

Fixes: 7cc97d77ee8a ("iio: adc: twl4030: Fix ADC[3:6] readings")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# a2054256 14-Aug-2017 Wolfram Sang <wsa@kernel.org>

mfd: twl: Move header file out of I2C realm

include/linux/i2c is not for client devices. Move the header file to a
more appropriate location.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 52b31bcc 23-Jul-2017 Jonathan Cameron <jic23@kernel.org>

iio:adc: drop assign iio_info.driver_module and iio_trigger_ops.owner

The equivalent of both of these are now done via macro magic when
the relevant register calls are made. The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>


# 7af1a067 27-Apr-2017 Sebastian Reichel <sre@kernel.org>

iio: adc: twl4030: Fold twl4030-madc.h into driver

twl4030-madc.h is no longer used by anything outside of
the iio driver, so it can be merged into the driver.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 842eb60b 27-Apr-2017 Sebastian Reichel <sre@kernel.org>

iio: adc: twl4030: Remove twl4030_madc_request.func_cb

This functionality is not used by the IIO subsystem. Due
to removal of legacy API it can also be removed.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 42ab9278 27-Apr-2017 Sebastian Reichel <sre@kernel.org>

iio: adc: twl4030: Unexport twl4030_madc_conversion()

All madc users have been converted to IIO API, so drop the
legacy API. The function is still used inside of the driver.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 6576ff74 27-Apr-2017 Sebastian Reichel <sre@kernel.org>

iio: adc: twl4030: Drop twl4030_get_madc_conversion()

Drop legacy twl4030_get_madc_conversion() method. It has been
used by drivers to get madc data before it conversion to IIO
API. There are no users in the mainline kernel anymore.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 7cc97d77 04-Aug-2015 Adam YH Lee <adam.yh.lee@gmail.com>

iio: adc: twl4030: Fix ADC[3:6] readings

MADC[3:6] reads incorrect values without these two following changes:

- enable the 3v1 bias regulator for ADC[3:6]
- configure ADC[3:6] lines as input, not as USB

Signed-off-by: Adam YH Lee <adam.yh.lee@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# b220da65 24-May-2015 Fabio Estevam <fabio.estevam@freescale.com>

iio: twl4030-madc: Pass the IRQF_ONESHOT flag

Since commit 1c6c69525b40 ("genirq: Reject bogus threaded irq requests")
threaded IRQs without a primary handler need to be requested with
IRQF_ONESHOT, otherwise the request will fail.

So pass the IRQF_ONESHOT flag in this case.

The semantic patch that makes this change is available
in scripts/coccinelle/misc/irqf_oneshot.cocci.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 6c0d48cb 24-May-2015 Fabio Estevam <fabio.estevam@freescale.com>

iio: twl4030-madc: Pass the IRQF_ONESHOT flag

Since commit 1c6c69525b40 ("genirq: Reject bogus threaded irq requests")
threaded IRQs without a primary handler need to be requested with
IRQF_ONESHOT, otherwise the request will fail.

So pass the IRQF_ONESHOT flag in this case.

The semantic patch that makes this change is available
in scripts/coccinelle/misc/irqf_oneshot.cocci.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 994bda83 28-May-2015 H. Nikolaus Schaller <hns@goldelico.com>

iio: adc: twl4030_madc: Fix description of twl4030_madc_set_current_generator()

The @chan parameter can be 0 or 1 and not a bit mask. Fix wrong description.

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Marek Belisko <marek@goldelico.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 0cbb39f1 28-May-2015 H. Nikolaus Schaller <hns@goldelico.com>

iio: adc: twl4030_madc: Fix calculation of the temperature sense current

The bit mask to read the setting of the constant current source
for measuring the NTC voltage was the wrong one. Since default
value is initialized to the lowest level (000 = 10uA) the difference
was probably never noticed in practice.

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Marek Belisko <marek@goldelico.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 81816aff 20-Aug-2014 Sanjeev Sharma <sanjeev_sharma@mentor.com>

iio: remove .owner field for driver using module_platform_driver

This patch removes the .owner field for drivers which use the
platform_driver_register api because this is overriden in
_platform_driver_register.

Signed-off-by: Sanjeev Sharma <Sanjeev_Sharma@mentor.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# e0326be0 24-May-2014 Paul Kocialkowski <contact@paulk.fr>

twl4030-madc: Request processed values in twl4030_get_madc_conversion

Not setting the raw parameter in the request causes it to be randomly
initialized to a value that might be different from zero or zero. This leads to
values that are randomly either raw or processed, making it very difficult to
make reliable use of the values.

Cc: Stable@vger.kernel.org
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Acked-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 3c699105 21-Jan-2014 Paul Gortmaker <paul.gortmaker@windriver.com>

mfd: Delete non-required instances of include <linux/init.h>

None of these files are actually using any __init type directives
and hence don't need to include <linux/init.h>. Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# b2931b98 15-Mar-2014 Sebastian Reichel <sre@kernel.org>

mfd: twl4030-madc: Move driver to drivers/iio/adc

This is a driver for an A/D converter, which belongs into
drivers/iio/adc.

Signed-off-by: Sebastian Reichel <sre@debian.org>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>