All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Sangbeom Kim <sbkim73@samsung.com>,
	Samuel Ortiz <sameo@linux.intel.com>,
	linux-kernel@vger.kernel.org,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [PATCH 1/2] mfd: sec-core: Remove duplicated device type from sec_pmic
Date: Tue, 22 Apr 2014 09:09:39 +0100	[thread overview]
Message-ID: <20140422080939.GE17657@lee--X1> (raw)
In-Reply-To: <1397807684.29800.8.camel@AMDC1943>

> > > +	unsigned long device_type;
> > >  	int ret;
> > >  
> > >  	sec_pmic = devm_kzalloc(&i2c->dev, sizeof(struct sec_pmic_dev),
> > > @@ -262,7 +263,7 @@ static int sec_pmic_probe(struct i2c_client *i2c,
> > >  	sec_pmic->dev = &i2c->dev;
> > >  	sec_pmic->i2c = i2c;
> > >  	sec_pmic->irq = i2c->irq;
> > > -	sec_pmic->type = sec_i2c_get_driver_data(i2c, id);
> > > +	device_type = sec_i2c_get_driver_data(i2c, id);
> > 
> > Better to change the return type of 'sec_i2c_get_driver_data()' than
> > to rely on a cast later on.
> 
> Hmmm... it was like that before Pankaj Dubey change (8f695de515b9).
> Solving that issue (-Wpointer-to-int-cast) along with keeping 'int' as
> return type of sec_i2c_get_driver_data would lead to one of:
> 1. Using temporary variable in ec_i2c_get_driver_data just for cast.
> 
> static inline int sec_i2c_get_driver_data(struct i2c_client *i2c,
> 						const struct i2c_device_id *id)
> {
> 	unsigned long type;
> 
> 	if (i2c->dev.of_node) {
> 		const struct of_device_id *match;
> 		match = of_match_node(sec_dt_match, i2c->dev.of_node);
> 		type = (unsigned long)match->data;
> 	}
> 	type = id->driver_data;
> 
> 	return (int)type;
> }
> 
> or
> 2. Double cast: (int)(unsigned long)match->data;
> 
> For me both are kind a ugly... What do you think?

I'm saying, why don't you change everything; the return value of
sec_i2c_get_driver_data(), pdata->device_type and device_type to long
or unsigned long? Then the only cast you need to do is from void*.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2014-04-22  8:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-14 12:03 [PATCH 1/2] mfd: sec-core: Remove duplicated device type from sec_pmic Krzysztof Kozlowski
2014-04-14 12:03 ` [PATCH 2/2] mfd: sec-core: Update sec_pmic documentation Krzysztof Kozlowski
2014-04-17  8:32   ` Lee Jones
2014-04-18  7:59     ` Krzysztof Kozlowski
2014-04-17  8:26 ` [PATCH 1/2] mfd: sec-core: Remove duplicated device type from sec_pmic Lee Jones
2014-04-18  7:54   ` Krzysztof Kozlowski
2014-04-22  8:09     ` Lee Jones [this message]
2014-04-22  8:41       ` Krzysztof Kozlowski

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=20140422080939.GE17657@lee--X1 \
    --to=lee.jones@linaro.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=k.kozlowski@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=sameo@linux.intel.com \
    --cc=sbkim73@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.