linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Pavel Machek <pavel@ucw.cz>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Richard Purdie <rpurdie@rpsys.net>,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Lee Jones <lee.jones@linaro.org>,
	Linux-Next Mailing List <linux-next@vger.kernel.org>
Subject: Re: [PATCH] leds: pm8058: Make ledtype pointer sized type
Date: Fri, 1 Dec 2017 10:14:03 +1100	[thread overview]
Message-ID: <20171201101351.3e57f2b1@canb.auug.org.au> (raw)
In-Reply-To: <20171130223406.GC2808@amd>

Hi Pavel,

On Thu, 30 Nov 2017 23:34:07 +0100 Pavel Machek <pavel@ucw.cz> wrote:
>
> On Thu 2017-11-30 22:58:55, Jacek Anaszewski wrote:
> > On 11/30/2017 10:40 AM, Pavel Machek wrote:  
> > > On Wed 2017-11-29 19:05:43, Bjorn Andersson wrote:  
> > >> The pointer returned by of_device_get_match_data() doesn't have the same
> > >> size as u32 on 64-bit architectures, causing issues when compile testing
> > >> the driver on such platform. Make ledtype unsigned long instead, to
> > >> solve this problem.
> > >>
> > >> Fixes: 7f866986e705 ("leds: add PM8058 LEDs driver")
> > >> Cc: Linus Walleij <linus.walleij@linaro.org>
> > >> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>  
> > > 
> > > Ummm... no?
> > > 
> > > extern const void *of_device_get_match_data(const struct device *dev);
> > > 
> > >   
> > >> diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c
> > >> index a52674327857..cc2afe81720d 100644
> > >> --- a/drivers/leds/leds-pm8058.c
> > >> +++ b/drivers/leds/leds-pm8058.c
> > >> @@ -29,7 +29,7 @@
> > >>  struct pm8058_led {
> > >>  	struct regmap *map;
> > >>  	u32 reg;
> > >> -	u32 ledtype;
> > >> +	unsigned long ledtype;  
> > > 
> > > Make it void *. u32 is buggy. unsigned long is merely ugly code. void
> > > * is not nice, but certainly better than unsigned long.  
> > 
> > unsigned long is correct, see below:
> > 
> > static const struct of_device_id pm8058_leds_id_table[] = {
> >         {
> >                 .compatible = "qcom,pm8058-led",
> >                 .data = (void *)PM8058_LED_TYPE_COMMON
> >         },
> >         {
> >                 .compatible = "qcom,pm8058-keypad-led",
> >                 .data = (void *)PM8058_LED_TYPE_KEYPAD
> >         },
> >         {
> >                 .compatible = "qcom,pm8058-flash-led",
> >                 .data = (void *)PM8058_LED_TYPE_FLASH
> >         },
> >         { },
> > };
> > 
> > of_device_get_match_data will return PM8058_LED_TYPE_*
> > which clearly is a led type identifier.
> > 
> > Thus unsigned long looks reasonable.  
> 
> Hmm. Ok. So u32 would actually make even more sense there (because
> PM8058_LED_TYPE_* does not really need to be 64-bit), but it would
> cause a warning.
> 
> I don't like this. This fix actually makes code waste memory and is
> uglier.
> 
> ...but we get a warning fix. So I don't like the patch, but it is an
> improvement...

I *think* you can get away with (u32)(unsigned long)ptr ...
-- 
Cheers,
Stephen Rothwell

  reply	other threads:[~2017-11-30 23:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30  0:35 linux-next: build warning after merge of the mfd tree Stephen Rothwell
2017-11-30  3:05 ` [PATCH] leds: pm8058: Make ledtype pointer sized type Bjorn Andersson
2017-11-30  8:29   ` Lee Jones
2017-11-30  8:31     ` Lee Jones
2017-11-30 22:02       ` Jacek Anaszewski
2017-12-01  7:56         ` Lee Jones
2017-12-01 20:35           ` Jacek Anaszewski
2017-11-30  9:18   ` Linus Walleij
2017-11-30  9:41     ` Lee Jones
2017-11-30  9:40   ` Pavel Machek
2017-11-30 21:58     ` Jacek Anaszewski
2017-11-30 22:34       ` Pavel Machek
2017-11-30 23:14         ` Stephen Rothwell [this message]
2017-12-01  0:28           ` Pavel Machek
2017-12-01  5:10             ` Bjorn Andersson
2017-11-30 22:18     ` Bjorn Andersson
2017-11-30  8:28 ` linux-next: build warning after merge of the mfd tree Lee Jones
2017-12-01  5:16 ` [PATCH v2] leds: pm8058: Silence pointer to integer size warning Bjorn Andersson
2017-12-01  7:57   ` Lee Jones
2017-12-01  8:36     ` Pavel Machek
2017-12-01  8:56       ` Lee Jones
2017-12-01  8:56   ` Lee Jones
2017-12-01  9:01   ` [GIT PULL] Immutable branch between MFD and LED due for the v4.16 merge window Lee Jones

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=20171201101351.3e57f2b1@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=bjorn.andersson@linaro.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rpurdie@rpsys.net \
    /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).