public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Buesch <mb@bu3sch.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: sfr@canb.auug.org.au, linux-kernel@vger.kernel.org,
	david-b@pacbell.net, piotr.skamruk@gmail.com,
	drzeus-mmc@drzeus.cx, openwrt-devel@lists.openwrt.org
Subject: Re: [PATCH] Add dynamic MMC-over-SPI-GPIO driver
Date: Tue, 15 Jul 2008 14:58:40 +0200	[thread overview]
Message-ID: <200807151458.41007.mb@bu3sch.de> (raw)
In-Reply-To: <20080714135441.e3ef9b0b.akpm@linux-foundation.org>

On Monday 14 July 2008 22:54:41 Andrew Morton wrote:
> > +static int gpiommc_probe(struct platform_device *pdev)
> > +{
> > +	static int instance;
> > +	struct gpiommc_device *d = platform_get_drvdata(pdev);
> > +	struct spi_gpio_platform_data pdata;
> > +	int err = -ENOMEM;
> > +
> > +	d->spi_pdev = platform_device_alloc("spi-gpio", instance++);
> > +	if (!d->spi_pdev)
> > +		goto out;
> 
> I guess that incrementing `instance' even if the allocation failed is
> somewhat wrong.

Well, I guess it doesn't matter much. The number is pretty random anyway.

> > +static struct gpiommc_device *gpiommc_alloc(struct platform_device *pdev,
> > +					    const char *name,
> > +					    const struct gpiommc_pins *pins,
> > +					    u8 mode)
> > +{
> > +	struct gpiommc_device *d;
> > +
> > +	d = kmalloc(sizeof(*d), GFP_KERNEL);
> > +	if (!d)
> > +		return NULL;
> > +
> > +	strcpy(d->name, name);
> 
> No check for overruns?

The caller checks the length, but it is a good idea to double-check here.
Good catch.

> > +	memcpy(&d->pins, pins, sizeof(d->pins));
> 
> If this had used the typesafe
> 
> 	d->pins = *pins;
> 
> I wouldn't have needed to run all around the place working out if
> overflow/underflow checks were needed here.

Yeah well, can use this.

> > +static ssize_t gpiommc_add_store(struct device_driver *drv,
> > +				 const char *buf, size_t count)
> > +{
> > +	int res, err;
> > +	char name[GPIOMMC_MAX_NAMELEN + 1];
> > +	struct gpiommc_pins pins;
> > +	unsigned int mode;
> > +
> > +	res = sscanf(buf, "%" GPIOMMC_MAX_NAMELEN_STR "s %u,%u,%u,%u %u",
> > +		     name, &pins.gpio_di, &pins.gpio_do,
> > +		     &pins.gpio_clk, &pins.gpio_cs, &mode);
> 
> What's going on here?  So new kernel/userspace ABI.

The whole point of the module is to create a new userspace interface for
creating the device. The module does just glue several modules together
and create an actual device.

> Not documented in 
> changelog, not documented in code comments, not documented in
> Documentation/ABI.  This forces reviewers to reverse-engineer the
> interface design from the implementation and then attempt to review
> that design.  Reviewers not happy!

Yeah well, as I said, I will do docs later. I didn't have any time
to write documentation, yet.
by. ;)

> > +static ssize_t gpiommc_remove_show(struct device_driver *drv,
> > +				   char *buf)
> > +{
> > +	return snprintf(buf, PAGE_SIZE, "write device-name to remove the device\n");
> > +}
> 
> Now that is one weird way in which to document the interface!  What a
> waste of kernel text :(

Yeah, well. Better than nothing ;)
As I already said in the original patch announcement. This is by no way the
final version of the patch. Docs will be moved to Documentation/

-- 
Greetings Michael.

  reply	other threads:[~2008-07-15 12:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-14 19:09 [PATCH] Add dynamic MMC-over-SPI-GPIO driver Michael Buesch
2008-07-14 20:54 ` Andrew Morton
2008-07-15 12:58   ` Michael Buesch [this message]
2008-07-15  5:06 ` Ben Nizette
2008-07-15 13:00   ` Michael Buesch
2008-07-21 20:49   ` David Brownell
2008-07-15 17:42 ` Michael Buesch

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=200807151458.41007.mb@bu3sch.de \
    --to=mb@bu3sch.de \
    --cc=akpm@linux-foundation.org \
    --cc=david-b@pacbell.net \
    --cc=drzeus-mmc@drzeus.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openwrt-devel@lists.openwrt.org \
    --cc=piotr.skamruk@gmail.com \
    --cc=sfr@canb.auug.org.au \
    /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