All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: "Chew, Chiau Ee" <chiau.ee.chew@intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Alan Cox <alan@linux.intel.com>,
	"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pwm_lpss: Add support for PCI devices
Date: Tue, 15 Apr 2014 12:03:32 +0300	[thread overview]
Message-ID: <20140415090332.GO19349@intel.com> (raw)
In-Reply-To: <604BF5F4C5D71041942BC7E84ED659EA01570E28@PGSMSX103.gar.corp.intel.com>

On Tue, Apr 15, 2014 at 08:41:02AM +0000, Chew, Chiau Ee wrote:
> 
> 
> > > +static struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev,
> > > +			struct resource *r, struct pwm_lpss_boardinfo *info)
> > >  {
> > >  	struct pwm_lpss_chip *lpwm;
> > > -	struct resource *r;
> > >  	int ret;
> > >
> > > -	lpwm = devm_kzalloc(&pdev->dev, sizeof(*lpwm), GFP_KERNEL);
> > > +	lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL);
> > >  	if (!lpwm)
> > > -		return -ENOMEM;
> > > -
> > > -	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > +		return ERR_PTR(-ENOMEM);
> > >
> > > -	lpwm->regs = devm_ioremap_resource(&pdev->dev, r);
> > > +	lpwm->regs = devm_ioremap_resource(dev, r);
> > >  	if (IS_ERR(lpwm->regs))
> > > -		return PTR_ERR(lpwm->regs);
> > > -
> > > -	lpwm->clk = devm_clk_get(&pdev->dev, NULL);
> > > -	if (IS_ERR(lpwm->clk)) {
> > > -		dev_err(&pdev->dev, "failed to get PWM clock\n");
> > > -		return PTR_ERR(lpwm->clk);
> > > +		return lpwm->regs;
> > > +
> > > +	if (info) {
> > > +		lpwm->clk_rate = info->clk_rate;
> > > +	} else {
> > > +		lpwm->clk = devm_clk_get(dev, NULL);
> > > +		if (IS_ERR(lpwm->clk)) {
> > > +			dev_err(dev, "failed to get PWM clock\n");
> > > +			return (void *)lpwm->clk;
> > 
> > Why the cast here?
> 
> Alan, please do correct me if I describe wrongly on the purpose that you add the cast here.
> 
> As you can see, pwm_lpss_probe() is expected to return a pointer of type struct pwm_lpss_chip.  On the other hand,   
> the return of devm_clk_get() would be a pointer of type struct clk. So if were to use lpwm->clk as the return value of pwm_lpss_probe() , 
> a cast would be needed since the pointer type is different from the expected one. The compiler would complain on " warning: return from incompatible pointer type"
> if without the cast.

I think you can use ERR_CAST() here.

  reply	other threads:[~2014-04-15  9:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-12 13:58 [PATCH] pwm_lpss: Add support for PCI devices Chew Chiau Ee
2014-04-13 10:32 ` Li, Aubrey
2014-04-14  2:05   ` Chew, Chiau Ee
2014-04-14  2:05     ` Chew, Chiau Ee
2014-04-14  8:59     ` Mika Westerberg
2014-04-15  8:59       ` Chew, Chiau Ee
2014-04-14  8:18 ` Mika Westerberg
2014-04-15  8:41   ` Chew, Chiau Ee
2014-04-15  9:03     ` Mika Westerberg [this message]
2014-04-15  9:06       ` Chew, Chiau Ee
2014-05-12 23:18 ` Darren Hart
2014-05-13  6:59   ` Thierry Reding

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=20140415090332.GO19349@intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=alan@linux.intel.com \
    --cc=chiau.ee.chew@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.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.