linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Dooks <ben@trinity.fluff.org>
To: Gregory Bean <gbean@codeaurora.org>
Cc: Ben Dooks <ben-linux@fluff.org>,
	akpm@linux-foundation.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Joe Perches <joe@perches.com>,
	"David S. Miller" <davem@davemloft.net>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Randy Dunlap <randy.dunlap@oracle.com>,
	Michael Hennerich <michael.hennerich@analog.com>,
	Mike Frysinger <vapier@gentoo.org>,
	David Brown <davidb@codeaurora.org>,
	Daniel Walker <dwalker@codeaurora.org>,
	Bryan Huntsman <bryanh@codeaurora.org>
Subject: Re: [PATCH 1/2] gpio: msm7200a: Add gpiolib support for MSM chips.
Date: Sun, 13 Jun 2010 06:30:15 +0100	[thread overview]
Message-ID: <20100613053015.GL3498@trinity.fluff.org> (raw)
In-Reply-To: <4C131D0E.60109@codeaurora.org>

On Fri, Jun 11, 2010 at 10:37:18PM -0700, Gregory Bean wrote:
>> Why not put this under arch/arm?
>
> Is there an appropriate place for loadable device drivers under  
> arch/arm?  I don't know of one.
>
>>> +static inline void set_gpio_bit(unsigned n, void __iomem *reg)
>>> +{
>>> +	writel(readl(reg) | bit(n), reg);
>>> +}
>>> +
>>> +/*
>>> + * This function assumes that msm_gpio_dev::lock is held.
>>> + */
>>> +static inline void clr_gpio_bit(unsigned n, void __iomem *reg)
>>> +{
>>> +	writel(readl(reg)&  ~bit(n), reg);
>>> +}
>>> +
>>> +/*
>>> + * This function assumes that msm_gpio_dev::lock is held.
>>> + */
>>> +static inline void
>>> +msm_gpio_write(struct msm_gpio_dev *dev, unsigned n, unsigned on)
>>> +{
>>> +	if (on)
>>> +		set_gpio_bit(n, dev->regs.out);
>>> +	else
>>> +		clr_gpio_bit(n, dev->regs.out);
>>> +}
>>
>> wouldn't it be easier to inline a set_to function and just role the
>> set and clr bit functions into it, since they pretty much do the
>> same thing. even better, on arm the code won't require a branch.
>
> I'm not sure I understand you.  Can you clarify?  set_ and clr_gpio_bit  
> are used in more places than just here, so they can't just be rolled  
> into msm_gpio_write and disappear.

Hmm, thought the compiler was clever enough to inline and sort that
out, I'll have a check later into whether this is true or not for
a few versions of gcc.

>>> +static int msm_gpio_remove(struct platform_device *dev)
>>> +{
>>> +	struct msm_gpio_dev *msm_gpio = platform_get_drvdata(dev);
>>> +	int ret = gpiochip_remove(&msm_gpio->gpio_chip);
>>> +
>>> +	if (ret == 0)
>>> +		kfree(msm_gpio);
>>
>> hmm, not sure if you really need to check the result here before
>> kfrree() the memory.
>
> I feel that this is important.  If any clients are still holding gpio  
> lines, gpiochip_remove will fail.  In those circumstances, is it not  
> important that the device not be freed (which would leave clients with  
> stale references) and that the remove call return a proper failure code?

Right, confused holding onto the module to holding onto the device too.

Maybe devices should be refcounted too so that holding an open gpio on
via the driver would force the driver core to refuse to remove the device.

-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.


  reply	other threads:[~2010-06-13  5:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-11 19:58 [PATCH 0/2] Add gpiolib support for MSM chips Gregory Bean
2010-06-11 19:58 ` [PATCH 1/2] gpio: msm7200a: " Gregory Bean
2010-06-12  2:12   ` Ben Dooks
2010-06-12  2:34     ` Bryan Huntsman
2010-06-12  5:37     ` Gregory Bean
2010-06-13  5:30       ` Ben Dooks [this message]
2010-06-11 19:58 ` [PATCH 2/2] gpio: msm7200a: Add irq support to msm-gpiolib Gregory Bean
2010-06-11 23:12   ` Daniel Walker
2010-06-11 23:23     ` Greg Bean
2010-06-12  2:24   ` Ben Dooks

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=20100613053015.GL3498@trinity.fluff.org \
    --to=ben@trinity.fluff.org \
    --cc=akpm@linux-foundation.org \
    --cc=ben-linux@fluff.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=bryanh@codeaurora.org \
    --cc=davem@davemloft.net \
    --cc=davidb@codeaurora.org \
    --cc=dwalker@codeaurora.org \
    --cc=gbean@codeaurora.org \
    --cc=joe@perches.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=randy.dunlap@oracle.com \
    --cc=sameo@linux.intel.com \
    --cc=vapier@gentoo.org \
    /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).