[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6988c5d0-796a-4ab0-88d5-7051c80b5bba@kernel.org>
Date: Sat, 6 Sep 2025 09:34:11 +0200
From: Krzysztof Kozlowski <krzk@...nel.org>
To: Daniel Lezcano <daniel.lezcano@...aro.org>, jic23@...nel.org,
dlechner@...libre.com, nuno.sa@...log.com, andy@...nel.org, robh@...nel.org,
conor+dt@...nel.org, krzk+dt@...nel.org
Cc: linux-iio@...r.kernel.org, s32@....com, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, chester62515@...il.com, mbrugger@...e.com,
ghennadi.procopciuc@....nxp.com
Subject: Re: [PATCH v1 2/2] iio: adc: Add the NXP SAR ADC support for the
s32g2/3 platforms
On 03/09/2025 12:27, Daniel Lezcano wrote:
> +#include <linux/dmaengine.h>
> +#include <linux/interrupt.h>
> +#include <linux/iopoll.h>
> +#include <linux/module.h>
> +#include <linux/of_irq.h>
Unused header
> +#include <linux/of_platform.h>
This as well. OTOH, you actually miss the header you use - of.h.
> +#include <linux/platform_device.h>
> +#include <linux/slab.h>
> +
> +#include <linux/iio/iio.h>
> +#include <linux/iio/triggered_buffer.h>
> +#include <linux/iio/trigger_consumer.h>
> +
> +/* This will be the driver name the kernel reports */
> +#define DRIVER_NAME "nxp-sar-adc"
> +
> +/* SAR ADC registers */
> +#define REG_ADC_CDR(__base, __channel) (((__base) + 0x100) + ((__channel) * 0x4))
> +
> +#define REG_ADC_CDR_CDATA_MASK GENMASK(11, 0)
> +#define REG_ADC_CDR_VALID BIT(19)
> +
> +/* Main Configuration Register */
> +#define REG_ADC_MCR(__base) (__base)
> +
...
> + indio_dev->name = dev_name(dev);
> + indio_dev->info = &nxp_sar_adc_iio_info;
> + indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
> + indio_dev->channels = nxp_sar_adc_iio_channels;
> + indio_dev->num_channels = ARRAY_SIZE(nxp_sar_adc_iio_channels);
> +
> + nxp_sar_adc_set_default_values(info);
> +
> + ret = nxp_sar_adc_calibration(info);
> + if (ret) {
> + dev_err(dev, "Calibration failed: %d\n", ret);
> + return ret;
> + }
> +
> + ret = nxp_sar_adc_dma_probe(dev, info);
> + if (ret) {
> + dev_err(dev, "Failed to initialize the dma\n");
return dev_err_probe
> + return ret;
> + }
> +
> + ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
> + &iio_pollfunc_store_time,
> + &nxp_sar_adc_trigger_handler,
> + &iio_triggered_buffer_setup_ops);
> + if (ret < 0) {
> + dev_err(dev, "Couldn't initialise the buffer\n");
> + return ret;
return dev_err_probe. No need to print ENOMEM errors.
> + }
> +
> + ret = devm_iio_device_register(dev, indio_dev);
> + if (ret) {
> + dev_err(dev, "Couldn't register the device.\n");
return dev_err_probe
> + return ret;
> + }
> +
> + dev_info(dev, "Device initialized successfully.\n");
Drivers should be silent on success and kernel already gives you
information that device probed (or did not).
Drop.
Best regards,
Krzysztof
Powered by blists - more mailing lists