public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Bryan Wu <bryan.wu@canonical.com>,
	Richard Purdie <rpurdie@rpsys.net>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	Grant Likely <grant.likely@secretlab.ca>,
	Linus Walleij <linus.walleij@stericsson.com>
Subject: Re: [PATCH v3] leds: Add MAX6956 driver
Date: Thu, 24 May 2012 18:17:20 +0200	[thread overview]
Message-ID: <20120524161720.GT3710@pengutronix.de> (raw)
In-Reply-To: <CACRpkdYJyUE-gM+wnOQvqW4Txuf65kEJsUbdJcBhkzRZYCxYDQ@mail.gmail.com>

On Mon, May 21, 2012 at 11:30:28PM +0200, Linus Walleij wrote:
> On Mon, May 21, 2012 at 9:33 PM, Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> 
> > +config LEDS_MAX6956
> > +       tristate "LED support for MAX6956 LED Display Driver and I/O Expander"
> > +       depends on LEDS_CLASS
> > +       depends on GPIOLIB
> 
> Shouldn't this be select GPIOLIB?
> 
> You seem to require it when using this driver.
> 
> Better than hiding it if not selecting GPIOLIB somewhere else?
I don't care much, but:

$ git ls-files | grep Kconfig | xargs grep '\<GPIOLIB\>' | grep -c select
7
$ git ls-files | grep Kconfig | xargs grep '\<GPIOLIB\>' | grep -c depends
39

Is it save to select GPIOLIB on a machine that provides its own
gpio-API?

> > +struct max6956_ddata {
> > +       struct device *dev;
> > +
> > +       struct mutex lock;
> > +
> > +       struct regmap *regmap;
> > +
> > +       struct gpio_chip gpio_chip;
> > +
> > +       struct max6956_pdata pdata;
> > +
> > +       struct max6956_led_ddata leds[32];
> > +
> > +       const char *gpio_names[32];
> > +};
> 
> You can never have enough whitespace? ;-)
> 
> Anyway, so this thing has a gpio_chip and leds.
> 
> The archaic way is to create mfd/max-6956.c and have this
> MFD device spawn two cells, one for GPIO landing in
> driver/gpio/gpio-max6956.c and one for LED landing in
> leds/leds-max6956.c, then mediate register read/writes and
> regmap in the MFD driver.
> 
> The MFD driver decide using platform data whether each
> line should be used for a LED or GPIO.
> 
> Is there some problem with this design pattern?
I thought about that, too, but I think it's overkill to create an mfd
driver. The mfd driver would have essentially the same functions as the
driver I posted. Then add all the oneline wrappers for these added in
drivers/gpio/ and drivers/leds/. I'd expect the SLOC to double even if I
remove all the whitespace above. Moreover it increases complexity for a
driver that is quite simple otherwise.

There are two other drivers that handle gpios below drivers/leds
(leds-pca9532 and leds-tca6507). Are these bad examples? The chip can
only do leds and gpio so the argument won't change in the future.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2012-05-24 16:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-18 15:45 [PATCH] ARM: leds: Add MAX6956 driver Uwe Kleine-König
2012-05-18 19:37 ` Shuah Khan
2012-05-21  6:41   ` Sascha Hauer
2012-05-21  4:50 ` Bryan Wu
2012-05-21  8:26   ` Uwe Kleine-König
2012-05-21  9:41     ` [PATCH v2] " Uwe Kleine-König
2012-05-21 19:33       ` [PATCH v3] " Uwe Kleine-König
2012-05-21 21:30         ` Linus Walleij
2012-05-24 16:17           ` Uwe Kleine-König [this message]
2012-05-25  6:55             ` Linus Walleij
2012-06-22  6:06         ` Uwe Kleine-König
2012-05-21 16:12     ` [PATCH] ARM: " Shuah Khan

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=20120524161720.GT3710@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=bryan.wu@canonical.com \
    --cc=grant.likely@secretlab.ca \
    --cc=kernel@pengutronix.de \
    --cc=linus.walleij@linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    --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