public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Anand Ashok Dumbre <ANANDASH@xilinx.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"jic23@kernel.org" <jic23@kernel.org>,
	"lars@metafoo.de" <lars@metafoo.de>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	git <git@xilinx.com>, Michal Simek <michals@xilinx.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"rafael@kernel.org" <rafael@kernel.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"heikki.krogerus@linux.intel.com"
	<heikki.krogerus@linux.intel.com>,
	Manish Narani <MNARANI@xilinx.com>
Subject: Re: [PATCH v10 3/5] iio: adc: Add Xilinx AMS driver
Date: Thu, 18 Nov 2021 17:42:31 +0200	[thread overview]
Message-ID: <YZZ0Z++xlAjBbRtI@smile.fi.intel.com> (raw)
In-Reply-To: <BY5PR02MB6916A1C867FCD6C289E894A2A99B9@BY5PR02MB6916.namprd02.prod.outlook.com>

On Thu, Nov 18, 2021 at 02:14:41PM +0000, Anand Ashok Dumbre wrote:
> > From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Sent: Wednesday 17 November 2021 8:03 PM
> > On Wed, Nov 17, 2021 at 04:10:26PM +0000, Anand Ashok Dumbre wrote:

...

> > > +			ret = ams_read_vcc_reg(ams, chan->address, val);
> > > +			if (ret) {
> > > +				mutex_unlock(&ams->lock);
> > > +				return -EINVAL;
> > 
> > Shadowed error code.
> 
> I don’t understand.

You get an error code in ret variable, but you always return -EINVAL, why?

> > > +			}

...

> > default: ?
> 
> This is limited by hw bits.
> For default I will use the default scan_index value.
> Is that ok?

I think so, you know hardware better, you decide what to put there.

...

> > > +		if (ret || reg > (AMS_PL_MAX_EXT_CHANNEL + 30))
> > 
> > Too many parentheses.
> 
> Is it a good practice to not have parantheses around (AMS_PL_MAX_EXT_CHANNEL + 30) ?

It's minor thing, up to you.

> > > +			continue;

...

> > > +	dev_chan_size = array_size((size_t)num_channels, sizeof(struct
> > iio_chan_spec));
> > > +	if (dev_chan_size == SIZE_MAX)
> > > +		return -EINVAL;
> > 
> > Why is it needed now?
> > 
> > > +	dev_channels = devm_kcalloc(&pdev->dev, (size_t)num_channels,
> > 
> > Why casting?
> > 
> > > +				    sizeof(struct iio_chan_spec), GFP_KERNEL);
> > 
> > sizeof(*dev_channels)
> > 
> > > +	if (!dev_channels) {
> > > +		ret = -ENOMEM;
> > > +		goto free_mem;
> > > +	}
> > 
> > > +	memcpy(dev_channels, ams_channels,
> > > +	       sizeof(*ams_channels) * num_channels);
> > 
> > Hmm... according to the code the num_channels can be less than or equal to
> > num_chan. Hence, what you should use is the devm_krealloc_array().
> > 
> > static inline void *devm_krealloc_aray(...) {
> > 	...see how krealloc_array() is defined...
> > }
> > 
> > No need to copy memory again.
> 
> Will take a look.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2021-11-18 15:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17 16:10 [PATCH v10 0/5] Add Xilinx AMS Driver Anand Ashok Dumbre
2021-11-17 16:10 ` [PATCH v10 1/5] device property: Add fwnode_iomap() Anand Ashok Dumbre
2021-11-17 16:10 ` [PATCH v10 2/5] arm64: zynqmp: DT: Add Xilinx AMS node Anand Ashok Dumbre
2021-11-17 16:10 ` [PATCH v10 3/5] iio: adc: Add Xilinx AMS driver Anand Ashok Dumbre
2021-11-17 19:01   ` kernel test robot
2021-11-17 20:03   ` Andy Shevchenko
2021-11-18  8:07     ` Michal Simek
2021-11-18 14:14     ` Anand Ashok Dumbre
2021-11-18 15:42       ` Andy Shevchenko [this message]
2021-11-21 12:29         ` Anand Ashok Dumbre
2021-11-18 22:25   ` kernel test robot
2021-11-20 16:54   ` Jonathan Cameron
2021-11-21 11:27     ` Anand Ashok Dumbre
2021-11-17 16:10 ` [PATCH v10 4/5] dt-bindings: iio: adc: Add Xilinx AMS binding documentation Anand Ashok Dumbre
2021-11-17 16:10 ` [PATCH v10 5/5] MAINTAINERS: Add maintainer for xilinx-ams Anand Ashok Dumbre
2021-11-17 17:13 ` [PATCH v10 0/5] Add Xilinx AMS Driver Andy Shevchenko
2021-11-18 15:03   ` Anand Ashok Dumbre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YZZ0Z++xlAjBbRtI@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=ANANDASH@xilinx.com \
    --cc=MNARANI@xilinx.com \
    --cc=git@xilinx.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michals@xilinx.com \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox