From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Tharunkumar.Pasumarthi@microchip.com
Cc: UNGLinuxDriver@microchip.com, wsa@kernel.org, krzk@kernel.org,
sven@svenpeter.dev, robh@kernel.org, semen.protsenko@linaro.org,
linux-kernel@vger.kernel.org, jarkko.nikula@linux.intel.com,
olof@lixom.net, linux-i2c@vger.kernel.org, jsd@semihalf.com,
arnd@arndb.de, rafal@milecki.pl
Subject: Re: [PATCH v2 i2c-master] i2c: microchip: pci1xxxx: Add driver for I2C host controller in multifunction endpoint of pci1xxxx switch
Date: Fri, 2 Sep 2022 17:08:24 +0300 [thread overview]
Message-ID: <YxIOWMqjP2+k7MPi@smile.fi.intel.com> (raw)
In-Reply-To: <2345b4bcd0c529878307b2a84364ea849005eed9.camel@microchip.com>
On Fri, Sep 02, 2022 at 11:31:11AM +0000, Tharunkumar.Pasumarthi@microchip.com wrote:
> On Thu, 2022-09-01 at 21:47 +0300, Andy Shevchenko wrote:
...
> > > + if (buf)
> > > + memcpy_toio((i2c->i2c_base + SMBUS_MST_BUF), buf,
> > > transferlen);
> >
> > Why do you need buf checks? Is your code can shoot itself in the foot?
>
> Yes, buf will be passed as NULL in some cases. So, this check is required.
Can you show an excerpt of the caller which passes NULL?
...
> > Each long sleep (20 ms is quite long) has to be explained. But this entire
> > loop
> > looks like a band-aid of lack of IRQ or so. Why do you need to poll?
>
> This handling takes care of special case when system is put to suspend when i2c
> transfer is progress in driver. We will wait until transfer completes.
This should be at least a comment in the code.
...
> > > + pci1xxxx_i2c_init(i2c);
> >
> > Here you need to wrap pci1xxxx_i2c_shutdown() to be devm_. See below.
> >
> > > + ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
> > > + if (ret < 0) {
> > > + pci1xxxx_i2c_shutdown(i2c);
>
> I am not getting. Are you suggesting to change API name to
> devm_pci1xxxx_i2c_shutdown?
>
> > > +
> > > + ret = devm_i2c_add_adapter(&pdev->dev, &i2c->adap);
> > > + if (ret) {
> > > + dev_err(&pdev->dev, "i2c add adapter failed = %d\n", ret);
> >
> > > + pci1xxxx_i2c_shutdown(i2c);
> >
> > You can't mix devm_ and non-devm_ in such manner. It's asking for troubles at
> > ->remove() or unbind stages.
>
> I am not getting this comment. Can you kindly explain more.
>
> > > + return ret;
Explanations [1] & [2]. Example how to workaround [3].
[1]: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1949091.html
[2]: https://lore.kernel.org/all/YXktrG1LhK5tj2uF@smile.fi.intel.com/
[3]: https://www.spinics.net/lists/kernel/msg4433985.html
...
> > After fixing above, convert the error messages to use
> >
> > return dev_err_probe(...);
> >
> > pattern.
>
> Okay.
Will be result of above fix.
...
> > > +static void pci1xxxx_i2c_remove_pci(struct pci_dev *pdev)
> > > +{
> > > + struct pci1xxxx_i2c *i2c = pci_get_drvdata(pdev);
> > > +
> > > + pci1xxxx_i2c_shutdown(i2c);
> > > +}
> >
> > This will be gone.
>
> I am not getting this comment also.
See above.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-09-02 14:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 1:36 Tharun Kumar P
2022-09-01 18:47 ` Andy Shevchenko
2022-09-02 11:31 ` Tharunkumar.Pasumarthi
2022-09-02 14:08 ` Andy Shevchenko [this message]
2022-09-05 3:43 ` Tharunkumar.Pasumarthi
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=YxIOWMqjP2+k7MPi@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=Tharunkumar.Pasumarthi@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=arnd@arndb.de \
--cc=jarkko.nikula@linux.intel.com \
--cc=jsd@semihalf.com \
--cc=krzk@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=rafal@milecki.pl \
--cc=robh@kernel.org \
--cc=semen.protsenko@linaro.org \
--cc=sven@svenpeter.dev \
--cc=wsa@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
all inboxes | Powered by JetHome®