[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200220155159.GB29658@roeck-us.net>
Date: Thu, 20 Feb 2020 07:52:00 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Evan Benn <evanbenn@...omium.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Julius Werner <jwerner@...omium.org>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
Marcin Juszkiewicz <marcin.juszkiewicz@...aro.org>,
Catalin Marinas <catalin.marinas@....com>,
Olof Johansson <olof@...om.net>,
Leonard Crestez <leonard.crestez@....com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Dinh Nguyen <dinguyen@...nel.org>,
linux-arm-kernel@...ts.infradead.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Will Deacon <will@...nel.org>, linux-watchdog@...r.kernel.org,
Rob Herring <robh@...nel.org>,
Wim Van Sebroeck <wim@...ux-watchdog.org>,
Clément Péron <peron.clem@...il.com>,
Shawn Guo <shawnguo@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Anson Huang <Anson.Huang@....com>
Subject: Re: [PATCH 2/2] watchdog: Add new arm_smc_wdt watchdog driver
On Thu, Feb 20, 2020 at 05:50:03PM +1100, Evan Benn wrote:
> > > + if ((int)res->a0 == PSCI_RET_NOT_SUPPORTED)
> > > + return -ENOTSUPP;
> >
> > -ENODEV would be better here.
> >
> > > + if ((int)res->a0 == PSCI_RET_INVALID_PARAMS)
> > > + return -EINVAL;
> > > + if ((int)res->a0 < 0)
> > > + return -EIO;
>
> In fixing this I found drivers/firmware/psci/psci.c:145
> Which also translates psci codes to errno codes, but uses EOPNOTSUPP:
>
> switch (errno) {
> case PSCI_RET_SUCCESS:
> return 0;
> case PSCI_RET_NOT_SUPPORTED:
> return -EOPNOTSUPP;
> case PSCI_RET_INVALID_PARAMS:
> case PSCI_RET_INVALID_ADDRESS:
> return -EINVAL;
> case PSCI_RET_DENIED:
> return -EPERM;
> };
>
> return -EINVAL;
>
> Are these more appropriate?
>
It is customary for driver probe functions to return -ENODEV if the
device is not supported. I don't see a reason why this driver should
behave any different. "but this other driver does it" is never a good
argument.
Having said that, yet, with the exception of -EOPNOTSUPP the other
return values would be more appropriate.
Guenter
Powered by blists - more mailing lists