From: Cedric Le Goater <clg@fr.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>, linuxppc-dev@lists.ozlabs.org
Cc: Stewart Smith <stewart@linux.vnet.ibm.com>,
Neelesh Gupta <neelegup@linux.vnet.ibm.com>,
skiboot@lists.ozlabs.org
Subject: Re: [v2,1/3] powerpc/powernv: convert codes returned by OPAL calls
Date: Fri, 27 Mar 2015 11:45:00 +0100 [thread overview]
Message-ID: <551534AC.4080204@fr.ibm.com> (raw)
In-Reply-To: <20150327095936.50A921400A0@ozlabs.org>
On 03/27/2015 10:59 AM, Michael Ellerman wrote:
> On Thu, 2015-26-03 at 16:04:45 UTC, =?utf-8?q?C=C3=A9dric_Le_Goater?= wrote:
>> OPAL has its own list of return codes. The patch provides a translation
>> of such codes in errnos for the opal_sensor_read call.
>>
>> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
>> ---
>> arch/powerpc/platforms/powernv/opal-sensor.c | 37 ++++++++++++++++++++++++++-
>> 1 file changed, 36 insertions(+), 1 deletion(-)
>>
>> Index: linux.git/arch/powerpc/platforms/powernv/opal-sensor.c
>> ===================================================================
>> --- linux.git.orig/arch/powerpc/platforms/powernv/opal-sensor.c
>> +++ linux.git/arch/powerpc/platforms/powernv/opal-sensor.c
>> @@ -26,6 +26,38 @@
>
>> +static int convert_opal_code(int ret)
>> +{
>> + switch (ret) {
>> + case OPAL_SUCCESS: return 0;
>> + case OPAL_PARAMETER: return -EINVAL;
>> + case OPAL_UNSUPPORTED: return -ENOSYS;
>> + case OPAL_ASYNC_COMPLETION: return -EAGAIN;
>> + case OPAL_BUSY_EVENT: return -EBUSY;
>> + case OPAL_NO_MEM: return -ENOMEM;
>> + case OPAL_HARDWARE: return -ENOENT;
>> + case OPAL_INTERNAL_ERROR: return -EIO;
>> + default: return -EIO;
>> + }
>> +}
>
> That looks a bit familiar :)
Ah ! I only looked in opal ...
> static int rtas_error_rc(int rtas_rc)
> {
> int rc;
>
> switch (rtas_rc) {
> case -1: /* Hardware Error */
> rc = -EIO;
> break;
> case -3: /* Bad indicator/domain/etc */
> rc = -EINVAL;
> break;
> case -9000: /* Isolation error */
> rc = -EFAULT;
> break;
> case -9001: /* Outstanding TCE/PTE */
> rc = -EEXIST;
> break;
> case -9002: /* No usable slot */
> rc = -ENODEV;
> break;
> default:
> printk(KERN_ERR "%s: unexpected RTAS error %d\n",
> __func__, rtas_rc);
> rc = -ERANGE;
this a better code default value.
> break;
> }
> return rc;
> }
>
>
> But I guess we still should have it.
>
> Can you put it in opal.h and give it a better name, maybe opal_error_code() ?
Sure. I will change the name but opal.c looks better, knowing that opal.h is
shared with skiboot.
>
>> /*
>> * This will return sensor information to driver based on the requested sensor
>> * handle. A handle is an opaque id for the powernv, read by the driver from the
>> @@ -46,8 +78,10 @@ int opal_get_sensor_data(u32 sensor_hndl
>>
>> mutex_lock(&opal_sensor_mutex);
>> ret = opal_sensor_read(sensor_hndl, token, &data);
>> - if (ret != OPAL_ASYNC_COMPLETION)
>> + if (ret != OPAL_ASYNC_COMPLETION) {
>> + ret = convert_opal_code(ret);
>> goto out_token;
>> + }
>>
>> ret = opal_async_wait_response(token, &msg);
>> if (ret) {
>> @@ -58,6 +92,7 @@ int opal_get_sensor_data(u32 sensor_hndl
>>
>> *sensor_data = be32_to_cpu(data);
>> ret = be64_to_cpu(msg.params[1]);
>> + ret = convert_opal_code(ret);
>
> I'd do:
> ret = convert_opal_code(be64_to_cpu(msg.params[1]));
Yes. the double 'ret =' is ugly.
Thanks,
C.
next prev parent reply other threads:[~2015-03-27 10:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-25 17:50 [PATCH] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Cédric Le Goater
2015-03-25 23:07 ` Stewart Smith
2015-03-26 9:44 ` Cedric Le Goater
2015-03-26 12:58 ` Cedric Le Goater
2015-03-26 16:04 ` [PATCH v2 1/3] powerpc/powernv: convert codes returned by OPAL calls Cédric Le Goater
2015-03-26 16:04 ` [PATCH v2 2/3] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Cédric Le Goater
2015-03-26 16:04 ` [PATCH v2 3/3] powerpc/powernv: remove opal_sensor_mutex Cédric Le Goater
2015-03-27 9:59 ` [v2,1/3] powerpc/powernv: convert codes returned by OPAL calls Michael Ellerman
2015-03-27 10:36 ` [Skiboot] [v2, 1/3] " Benjamin Herrenschmidt
2015-03-27 10:39 ` Cedric Le Goater
2015-03-27 10:45 ` Cedric Le Goater [this message]
2015-03-27 16:39 ` [PATCH v3 " Cédric Le Goater
2015-03-30 2:05 ` Michael Ellerman
2015-03-30 6:37 ` Cedric Le Goater
2015-03-30 6:54 ` Michael Ellerman
2015-03-30 6:56 ` Cedric Le Goater
2015-03-30 10:06 ` [PATCH v4 1/2] " Cédric Le Goater
2015-03-30 10:06 ` [PATCH v4 2/2] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Cédric Le Goater
2015-03-27 16:39 ` [PATCH v3 2/3] " Cédric Le Goater
2015-03-27 16:39 ` [PATCH v3 3/3] powerpc/powernv: remove opal_sensor_mutex Cédric Le Goater
2015-03-30 2:09 ` Michael Ellerman
2015-03-30 6:51 ` Cedric Le Goater
2015-03-30 6:59 ` Michael Ellerman
2015-03-30 10:05 ` Cedric Le Goater
2015-03-27 6:05 ` [PATCH] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Stewart Smith
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=551534AC.4080204@fr.ibm.com \
--to=clg@fr.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=neelegup@linux.vnet.ibm.com \
--cc=skiboot@lists.ozlabs.org \
--cc=stewart@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).