linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>,
	stewart@linux.vnet.ibm.com,  arnd@arndb.de,
	j.anaszewski81@gmail.com, cooloney@gmail.com, rpurdie@rpsys.net,
	 linuxppc-dev@lists.ozlabs.org, linux-leds@vger.kernel.org,
	 khandual@linux.vnet.ibm.com
Subject: Re: [PATCH v5 3/3] leds/powernv: Add driver for PowerNV platform
Date: Thu, 16 Jul 2015 18:47:08 +1000	[thread overview]
Message-ID: <1437036428.15828.1.camel@ellerman.id.au> (raw)
In-Reply-To: <55A76AF6.2090805@samsung.com>

On Thu, 2015-07-16 at 10:27 +0200, Jacek Anaszewski wrote:
> On 07/16/2015 08:54 AM, Vasant Hegde wrote:
> >>> +static enum led_brightness powernv_led_get(struct led_classdev *led_cdev)
> >>> +{
> >>> +    char *loc_code;
> >>> +    int rc, led_type;
> >>> +    __be64 led_mask, led_value, max_led_type;
> >>> +
> >>> +    led_type = powernv_get_led_type(led_cdev);
> >>> +    if (led_type == -1)
> >>> +        return LED_OFF;
> >>> +
> >>> +    loc_code = powernv_get_location_code(led_cdev);
> >>> +    if (!loc_code)
> >>> +        return LED_OFF;
> >>> +
> >>> +    /* Fetch all LED status */
> >>> +    led_mask = cpu_to_be64(0);
> >>> +    led_value = cpu_to_be64(0);
> >>> +    max_led_type = cpu_to_be64(OPAL_SLOT_LED_TYPE_MAX);
> >>> +
> >>> +    rc = opal_leds_get_ind(loc_code, &led_mask, &led_value, &max_led_type);
> >>> +    if (rc != OPAL_SUCCESS && rc != OPAL_PARTIAL) {
> >>> +        dev_err(led_cdev->dev,
> >>> +            "%s: OPAL get led call failed [rc=%d]\n",
> >>> +            __func__, rc);
> >>> +        goto led_fail;
> >>> +    }
> >>> +
> >>> +    led_mask = be64_to_cpu(led_mask);
> >>> +    led_value = be64_to_cpu(led_value);
> >>
> >> be64_to_cpu result should be assigned to the variable of u64/s64 type.
> >
> > PowerNV platform is capable of running both big/little endian mode.. But
> > presently our firmware is big endian. These variable contains big endian values.
> > Hence I have created as __be64 .. (This is the convention we follow in other
> > places as well).
> 
> It is correct that the argument is of __be64 type, but be64_to_cpu
> returns u64 type, whereas you assign it to  __be64.

Yeah that's wrong. You are using led_mask etc as __be64 when you pass them to
firmware, which is correct, but then you're also using them as the lvalue of
be64_to_cpu() which returns a u64.

Sparse should warn you about that if you use it, please do.

$ apt-get install sparse
$ cd kernel
$ make C=2 CF=-D__CHECK_ENDIAN__


Whether the kernel or OPAL is running big or little endian is irrelevant to all
of this. The OPAL API defines that parameters to OPAL calls are big endian, and
that's all that matters:

  https://github.com/open-power/skiboot/blob/master/doc/opal-spec.txt#L142


Thanks for the review Jacek.

cheers

  reply	other threads:[~2015-07-16  8:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01  8:50 [PATCH v5 0/3] LED driver for PowerNV platform Vasant Hegde
2015-07-01  8:50 ` [PATCH v5 1/3] powerpc/powernv: Add OPAL interfaces for accessing and modifying system LED states Vasant Hegde
2015-07-01  8:50 ` [PATCH v5 2/3] powerpc/powernv: Create LED platform device Vasant Hegde
2015-07-01  8:50 ` [PATCH v5 3/3] leds/powernv: Add driver for PowerNV platform Vasant Hegde
2015-07-14  9:00   ` Jacek Anaszewski
2015-07-16  6:54     ` Vasant Hegde
2015-07-16  8:27       ` Jacek Anaszewski
2015-07-16  8:47         ` Michael Ellerman [this message]
2015-07-17  5:53           ` Vasant Hegde
2015-07-17  5:52         ` Vasant Hegde

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=1437036428.15828.1.camel@ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=arnd@arndb.de \
    --cc=cooloney@gmail.com \
    --cc=hegdevasant@linux.vnet.ibm.com \
    --cc=j.anaszewski81@gmail.com \
    --cc=j.anaszewski@samsung.com \
    --cc=khandual@linux.vnet.ibm.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=rpurdie@rpsys.net \
    --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).