mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Trent Piepho <tpiepho@kymetacorp.com>
To: Florian Vallee <fvallee@eukrea.fr>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: [PATCH v2] GPIO: add Microchip MCP23017 / MCP23008 GPIO driver
Date: Tue, 15 Dec 2015 19:15:39 +0000	[thread overview]
Message-ID: <1450206947.26955.174.camel@rtred1test09.kymeta.local> (raw)
In-Reply-To: <1450200490-4488-1-git-send-email-fvallee@eukrea.fr>

On Tue, 2015-12-15 at 18:28 +0100, Florian Vallee wrote:
> +
> +/* A given spi_device can represent up to eight mcp23sxx chips
> + * sharing the same chipselect but using different addresses
> + * (e.g. chips #0 and #3 might be populated, but not #1 or $2).
> + * Driver data holds all the per-chip data.
> + */
> +struct mcp23s08_driver_data {
> +	unsigned		ngpio;
> +	struct mcp23s08		*mcp[8];
> +	struct mcp23s08		chip[];
> +};

It doesn't look like anything uses this struct.

> +static int
> +mcp23008_read_regs(struct mcp23s08 *mcp, unsigned reg, u16 *vals, unsigned n)
> +{
> +	while (n--) {
> +		int ret = mcp23008_read(mcp, reg++);

This could use mcp->ops->read(mcp, reg++) instead of mcp23008_read().
Which would make it exactly the same as this function:

> +static int
> +mcp23017_read_regs(struct mcp23s08 *mcp, unsigned reg, u16 *vals, unsigned n)
> +{
> +	while (n--) {
> +		int ret = mcp23017_read(mcp, reg++);
> +		if (ret < 0)
> +			return ret;
> +		*vals++ = ret;
> +	}
> +
> +	return 0;
> +}

So just one read_regs fuction is needed.  Which also would allow
read_regs to be removed from the ops struct since it's the same for both
chips.

> +
> +static const struct mcp23s08_ops mcp23008_ops = {
> +	.read		= mcp23008_read,
> +	.write		= mcp23008_write,
> +	.read_regs	= mcp23008_read_regs,
> +};
> +
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-12-15 19:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-15 17:28 Florian Vallee
2015-12-15 18:16 ` Antony Pavlov
2015-12-15 19:15 ` Trent Piepho [this message]
2015-12-21 11:19   ` Florian Vallée

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=1450206947.26955.174.camel@rtred1test09.kymeta.local \
    --to=tpiepho@kymetacorp.com \
    --cc=barebox@lists.infradead.org \
    --cc=fvallee@eukrea.fr \
    /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