All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: eric miao <eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>,
	Jack Ren <jack.ren-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
	i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
	linux-arm-kernel
	<linux-arm-kernel-xIg/pKzrS19vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
Subject: Re: [PATCH] gpio: max732x: add support for MAX7319, MAX7320-7327 I2C Port Expanders
Date: Fri, 11 Jul 2008 11:31:14 +0200	[thread overview]
Message-ID: <20080711113114.79d80212@hyperion.delvare> (raw)
In-Reply-To: <f17812d70807110157p5e421222sc9ef420ceb80970c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Fri, 11 Jul 2008 16:57:36 +0800, eric miao wrote:
> On Fri, Jul 11, 2008 at 4:29 PM, Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
> > On Thu, 10 Jul 2008 14:13:39 +0800, Eric Miao wrote:
> >> + *   - Group A : by I2C address 0b'110xxxx
> >> + *   - Group B : by I2C address 0b'101xxxx
> >> + *
> >> + * where 'xxxx' is decided by the connections of pin AD2/AD0.
> >
> > AD2-AD0 (assuming there there is an AD1 pin)
> 
> Unfortunately, no AD1 pin

Ah, these are 2 four-state address pins, I get it now.

> >> (...)
> >> +#define PORT_NONE    0x0     /* '/' No Port */
> >
> > You don't use this define anywhere.
> 
> Just defined here to illustrate the purpose of the "0" here means
> NO PORT exist in that bit position, it helps people to better
> understand the port organization and initialization sequence

Could be a comment rather than a define, but up to you.

> >> (...)
> >> +     nr_port = port;
> >
> > Why do you need 2 variables for that?
> 
> Again, better readability :-)
> 
> I can remove that if you mind.

Personally I tend to think that it makes the readability worse not
better. Looking at just the end of the function, I see:

	if (nr_port > 7) {
(...)
	gc->ngpio = port;

And I have to scroll up a bit to find out that "nr_port" and "port"
always have the same value by construction. So indeed I would suggest
to drop "port" and use "nr_port" everywhere for clarity.

Oh, and one more thing as I just notice it:

> +static inline int is_group_a(struct max732x_chip *chip, unsigned off)
> +{
> +	return (1u << off) & chip->mask_group_a;
> +}

Given the way you use it, can't you just define this function as:

static inline int is_group_a(struct max732x_chip *chip, unsigned off)
{
	return (off < 8);
}

? As this is the only place where you use chip->mask_group_a, you would
be able to get rid of it.

-- 
Jean Delvare

_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c

  parent reply	other threads:[~2008-07-11  9:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-10  6:13 [PATCH] gpio: max732x: add support for MAX7319, MAX7320-7327 I2C Port Expanders Eric Miao
     [not found] ` <4875A893.3090402-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-07-11  8:29   ` Jean Delvare
     [not found]     ` <20080711102952.31d2d943-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-11  8:57       ` eric miao
     [not found]         ` <f17812d70807110157p5e421222sc9ef420ceb80970c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-11  9:31           ` Jean Delvare [this message]
     [not found]             ` <20080711113114.79d80212-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-11  9:39               ` eric miao
     [not found]                 ` <f17812d70807110239q6c175f5cn70db966681ae387d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-11  9:48                   ` eric miao
     [not found]                     ` <f17812d70807110248y7fab3328q59ea41084c491df-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-11 11:15                       ` Jean Delvare
2008-07-11 21:25                       ` David Brownell
     [not found]                         ` <200807111425.00961.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-07-12  7:16                           ` Jean Delvare
     [not found]                             ` <20080712091610.4ec242c3-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-12  7:46                               ` David Brownell
     [not found]                                 ` <200807120046.29389.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-07-12  7:53                                   ` Jean Delvare
     [not found]                                     ` <20080712095300.1ba4b3a7-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-12 21:42                                       ` David Brownell
2008-07-13  6:55                                         ` Jean Delvare
2008-07-13  6:04                                   ` eric miao
     [not found]                                     ` <f17812d70807122304o533d8af9k1384db653b264912-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-13  7:20                                       ` Jean Delvare
     [not found]                                         ` <20080713092050.6dffd8d3-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-13  8:53                                           ` eric miao
     [not found]                                             ` <f17812d70807130153g290e17ecq10ab12529effc8d4-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-13  9:13                                               ` Jean Delvare
     [not found]                                                 ` <20080713111306.791bbc41-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-13 13:45                                                   ` eric miao
     [not found]                                                     ` <f17812d70807130645i755c1c62la30d5c515c2d2080-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-13 19:18                                                       ` David Brownell
     [not found]                                                         ` <200807131218.29575.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-07-14  1:35                                                           ` Eric Miao
2008-07-13  9:12                                           ` David Brownell
     [not found]                                             ` <20080713091236.015E920ABDD-ZcXrCSuhvln6VZ3dlLfH/g4gEjPzgfUyLrfjE7I9kuVHxeISYlDBzl6hYfS7NtTn@public.gmane.org>
2008-07-13  9:18                                               ` Jean Delvare
2008-07-13 14:37                                       ` Jean Delvare
2008-07-11  9:54                   ` Jean Delvare
     [not found]                     ` <20080711115436.22134ce7-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-07-11 10:04                       ` eric miao

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=20080711113114.79d80212@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org \
    --cc=eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
    --cc=jack.ren-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-arm-kernel-xIg/pKzrS19vn6HldHNs0ANdhmdF6hFW@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.