[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZHoBXxM80aqvLZNt@smile.fi.intel.com>
Date:   Fri, 2 Jun 2023 17:49:03 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Maksim Kiselev <bigunclemax@...il.com>
Cc:     linux-iio@...r.kernel.org, Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Conor Dooley <conor+dt@...nel.org>,
        Chen-Yu Tsai <wens@...e.org>,
        Jernej Skrabec <jernej.skrabec@...il.com>,
        Samuel Holland <samuel@...lland.org>,
        Paul Walmsley <paul.walmsley@...ive.com>,
        Palmer Dabbelt <palmer@...belt.com>,
        Albert Ou <aou@...s.berkeley.edu>,
        Philipp Zabel <p.zabel@...gutronix.de>,
        Cristian Ciocaltea <cristian.ciocaltea@...labora.com>,
        Cosmin Tanislav <demonsingur@...il.com>,
        Miquel Raynal <miquel.raynal@...tlin.com>,
        ChiaEn Wu <chiaen_wu@...htek.com>,
        Arnd Bergmann <arnd@...db.de>,
        Ramona Bolboaca <ramona.bolboaca@...log.com>,
        Caleb Connolly <caleb.connolly@...aro.org>,
        ChiYuan Huang <cy_huang@...htek.com>,
        Ibrahim Tilki <Ibrahim.Tilki@...log.com>,
        William Breathitt Gray <william.gray@...aro.org>,
        Leonard Göhrs <l.goehrs@...gutronix.de>,
        Haibo Chen <haibo.chen@....com>,
        Hugo Villeneuve <hvilleneuve@...onoff.com>,
        Mike Looijmans <mike.looijmans@...ic.nl>,
        devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-sunxi@...ts.linux.dev, linux-kernel@...r.kernel.org,
        linux-riscv@...ts.infradead.org
Subject: Re: [PATCH v2 1/3] iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs
 GPADC
On Fri, Jun 02, 2023 at 01:30:39AM +0300, Maksim Kiselev wrote:
> From: Maxim Kiselev <bigunclemax@...il.com>
> 
> The General Purpose ADC (GPADC) can convert the external signal into
> a certain proportion of digital value, to realize the measurement of
> analog signal, which can be applied to power detection and key detection.
> 
> Theoretically, this ADC can support up to 16 channels. All SoCs below
> contain this GPADC IP. The only difference between them is the number
> of available channels:
> 
>  T113 - 1 channel
>  D1   - 2 channels
>  R329 - 4 channels
>  T507 - 4 channels
...
> +struct sun20i_gpadc_iio {
> +	struct regmap		*regmap;
> +	struct completion	completion;
> +	struct mutex		lock;
The locks should be explained (what are they for? what do they protect?).
> +	int			lastch;
> +};
...
> +static const struct regmap_config sun20i_gpadc_regmap_config = {
> +	.reg_bits = 32,
> +	.val_bits = 32,
> +	.reg_stride = 4,
> +	.fast_io = true,
I forgot if I asked about regmap lock do you need it?
> +};
...
> +	if (!wait_for_completion_timeout(&info->completion,
> +					 msecs_to_jiffies(100))) {
Dunno if it's better to have this parameter to be defined with self-explanatory
name.
> +		ret = -ETIMEDOUT;
> +		goto err;
> +	}
...
> +err:
err_unlock:
> +	mutex_unlock(&info->lock);
> +
> +	return ret;
...
> +	switch (mask) {
> +	case IIO_CHAN_INFO_RAW:
> +		ret = sun20i_gpadc_adc_read(info, chan, val);
> +		return ret;
		return sun...;
> +	case IIO_CHAN_INFO_SCALE:
> +		/* value in mv = 1800mV / 4096 raw */
> +		*val = 1800;
> +		*val2 = 12;
> +		return IIO_VAL_FRACTIONAL_LOG2;
> +	default:
> +		return -EINVAL;
> +	}
...
> +	if (num_channels > SUN20I_GPADC_MAX_CHANNELS) {
> +		dev_err(dev, "num of channel children out of range");
> +		return -EINVAL;
> +	}
Is it really critical error?
...
> +	channels = devm_kcalloc(dev, num_channels,
> +				sizeof(*channels), GFP_KERNEL);
At least one more parameter can be located on the previous line.
> +	if (!channels)
> +		return -ENOMEM;
...
> +err_child_out:
err_put_child:
The goto labels should be self-explanatory of what to expect when goto.
> +	fwnode_handle_put(node);
> +
> +	return ret;
...
> +	ret = devm_request_irq(dev, irq, sun20i_gpadc_irq_handler,
> +			       0, dev_name(dev), info);
> +	if (ret < 0)
Here...
> +		return dev_err_probe(dev, ret,
> +				     "failed requesting irq %d\n", irq);
...
> +	ret = devm_iio_device_register(dev, indio_dev);
> +	if (ret < 0)
...and here, do the positive returned values even possible?
> +		return dev_err_probe(dev, ret,
> +				     "could not register the device\n");
...
> +	{ .compatible = "allwinner,sun20i-d1-gpadc", },
Inner comma is not needed.
-- 
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists