From: Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>,
spi-devel-list
<spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: [PATCH v3] spi: enable spi_board_info to be registered after spi_master
Date: Mon, 2 Aug 2010 14:25:43 +0800 [thread overview]
Message-ID: <20100802142543.6b139c4b@feng-i7> (raw)
In-Reply-To: <AANLkTi=dEQ9oRi-NOi=oyab3yBeX7HWDOqs+pS5=-Bix-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Mon, 2 Aug 2010 13:53:25 +0800
Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:
> > /**
> > @@ -365,6 +370,24 @@ struct spi_device *spi_new_device(struct
> > spi_master *master, }
> > EXPORT_SYMBOL_GPL(spi_new_device);
> >
> > +/* Has to be called when board_lock is acquired */
> > +static void spi_scan_masterlist(struct spi_board_info *bi)
> > +{
> > + struct spi_master *master;
> > + struct spi_device *dev;
> > +
> > + list_for_each_entry(master, &spi_master_list, list) {
> > + if (master->bus_num != bi->bus_num)
> > + continue;
> > +
> > + dev = spi_new_device(master, bi);
> > + if (!dev)
> > + dev_err(master->dev.parent,
> > + "can't create new device for %s\n",
> > + bi->modalias);
> > + }
> > +}
> > +
>
> The abstraction isn't quite at the right place because the same code
> block is now duplicated twice. Consider the following instead:
>
> static void spi_match_master_to_boardinfo(struct spi_master *master,
> struct spi_board_info *bi)
> {
> struct spi_device *dev;
>
> if (master->bus_num != bi->bus_num)
> return;
>
> dev = spi_new_device(master, bi);
> if (!dev)
> dev_err(master->dev.parent, "can't create new device
> for %s\n", bi->modalias);
> }
>
> And then from spi_register_board_info, do:
>
> list_for_each_entry(master, &spi_master_list, list)
> spi_match_master_to_boardinfo(master, &bi->boardinfo);
>
> And in spi_register_master, do:
>
> list_for_each_entry(bi, &board_list, list)
> spi_match_master_to_boardinfo(master, &bi->boardinfo);
>
> It will be less code that way.
>
> Otherwise, this patch looks good to me. Unfortunately, it's too late
> for 2.6.36, but I'll pick it up into my test branch in prep for the
> 2.6.37 cycle.
>
> Cheers,
> g.
Yeah, make much sense! Thanks for the thorough reviews.
- Feng
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
prev parent reply other threads:[~2010-08-02 6:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-02 5:47 [PATCH v3] spi: enable spi_board_info to be registered after spi_master Feng Tang
2010-08-02 5:53 ` Grant Likely
[not found] ` <AANLkTi=dEQ9oRi-NOi=oyab3yBeX7HWDOqs+pS5=-Bix-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-02 6:25 ` Feng Tang [this message]
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=20100802142543.6b139c4b@feng-i7 \
--to=feng.tang-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org \
--cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@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.