[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAOtMz3Nf6jpX8dGMEr9tGgp-AJdOPx605NS+aPOMn2ryRYwsqw@mail.gmail.com>
Date: Thu, 10 Mar 2022 22:57:24 +0100
From: Jan Dąbroś <jsd@...ihalf.com>
To: Jarkko Nikula <jarkko.nikula@...ux.intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-i2c <linux-i2c@...r.kernel.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Wolfram Sang <wsa@...nel.org>, upstream@...ihalf.com
Subject: Re: [PATCH -next] i2c: designware: Add helper to remove redundancy
czw., 10 mar 2022 o 15:52 Jarkko Nikula
<jarkko.nikula@...ux.intel.com> napisał(a):
>
> On 3/10/22 16:22, Jan Dabros wrote:
> > Simplify code by adding an extra static function for sending I2C
> > requests and verifying results.
> >
> > Signed-off-by: Jan Dabros <jsd@...ihalf.com>
> > ---
> > drivers/i2c/busses/i2c-designware-amdpsp.c | 44 ++++++++++++----------
> > 1 file changed, 24 insertions(+), 20 deletions(-)
> >
> Do I remember correctly was this suggested by Andy? I.e. to give kudos
> to him if that was the case:
>
> Suggested-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Definitely! Actually I wasn't aware of such a tag, will add this in v2.
>
> > diff --git a/drivers/i2c/busses/i2c-designware-amdpsp.c b/drivers/i2c/busses/i2c-designware-amdpsp.c
> > index c64e459afb5c..cc758792f150 100644
> > --- a/drivers/i2c/busses/i2c-designware-amdpsp.c
> > +++ b/drivers/i2c/busses/i2c-designware-amdpsp.c
> > @@ -229,6 +229,26 @@ static int psp_send_i2c_req(enum psp_i2c_req_type i2c_req_type)
> > return ret;
> > }
> >
> > +static int psp_send_i2c_req_check_err(enum psp_i2c_req_type request)
> > +{
> > + int status;
> > +
> > + status = psp_send_i2c_req(request);
> > + if (status) {
> > + if (status == -ETIMEDOUT)
> > + dev_err(psp_i2c_dev, "Timed out waiting for PSP to %s I2C bus\n",
> > + (request == PSP_I2C_REQ_ACQUIRE) ?
> > + "release" : "acquire");
> > + else
> > + dev_err(psp_i2c_dev, "PSP communication error\n");
> > +
> > + dev_err(psp_i2c_dev, "Assume i2c bus is for exclusive host usage\n");
> > + psp_i2c_mbox_fail = true;
> > + }
> > +
>
> Does it make sense to have these inside the psp_send_i2c_req() and get
> rid of this new middle function? I mean psp_send_i2c_req() is called now
> only from here so can it do these common error prints and set
> "psp_i2c_mbox_fail = true"?
I like this idea, please take a look at v2.
Best Regards,
Jan
Powered by blists - more mailing lists