From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Walleij Date: Mon, 03 Nov 2014 13:43:21 +0000 Subject: Re: [PATCH 02/15] GPIO: port LoCoMo gpio support from old driver Message-Id: List-Id: References: <1414454528-24240-1-git-send-email-dbaryshkov@gmail.com> <1414454528-24240-3-git-send-email-dbaryshkov@gmail.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Dmitry Eremin-Solenikov Cc: "linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org" , "linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Linux Input , "linux-leds-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-fbdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org" , Andrea Adami , Russell King , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Alexandre Courbot , Dmitry Torokhov , Bryan Wu , Richard Purdie , Samuel Ortiz , Lee Jones , Mark Brown , Jingoo On Fri, Oct 31, 2014 at 10:39 AM, Dmitry Eremin-Solenikov wrote: > 2014-10-31 10:48 GMT+03:00 Linus Walleij : >> On Tue, Oct 28, 2014 at 1:01 AM, Dmitry Eremin-Solenikov >> wrote: >> >>> Add gpiolib driver for gpio pins placed on the LoCoMo GA. >>> >>> Signed-off-by: Dmitry Eremin-Solenikov >> > > [skipped] > >> (etc, everywhere this pattern occurs). >>> +static void locomo_gpio_set(struct gpio_chip *chip, >>> + unsigned offset, int value) >>> +{ >>> + struct locomo_gpio *lg = container_of(chip, struct locomo_gpio, gpio); >>> + unsigned long flags; >>> + >>> + spin_lock_irqsave(&lg->lock, flags); >>> + >>> + __locomo_gpio_set(chip, offset, value); >>> + >>> + spin_unlock_irqrestore(&lg->lock, flags); >> >> If you actually always have to be getting and releasing a spin lock around >> the register writes, contemplate using regmap-mmio because that >> is part of what it does. >> >> But is this locking really necessary? > > I have a custom of doing such locking and never having to think about > somebody breaking into RMW cycles. > > Also isn't regmap an overkill here? Wouldn't regmap also do a lock/unlock > around each register read/write/RMW? Yes that's the point: if you use regmap mmio you get the RMW-locking for free, with the regmap implementation. Yours, Linus Walleij