From: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: dwmw2@infradead.org, computersforpeace@gmail.com,
matthias.bgg@gmail.com, robh@kernel.org,
daniel.thompson@linaro.org, xiaolei.li@mediatek.com,
linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/3] mtd: mediatek: driver for MTK Smart Device Gen1 NAND
Date: Tue, 8 Mar 2016 12:17:06 -0500 [thread overview]
Message-ID: <56DF0912.6060305@linaro.org> (raw)
In-Reply-To: <20160308172437.6eccce05@bbrezillon>
On 03/08/2016 11:24 AM, Boris Brezillon wrote:
Hi Boris,
>> +
>> > +static int mtk_nfc_subpage_done(struct mtk_nfc_host *host, int sectors)
>> > +{
>> > + unsigned long timeout = msecs_to_jiffies(MTK_TIMEOUT);
>> > + u32 val;
>> > +
>> > + timeout += jiffies;
>> > + do {
>> > + val = mtk_nfi_readl(host, MTKSDG1_NFI_BYTELEN);
>> > + val &= CNTR_MASK;
>> > + if (val >= sectors)
>> > + return 0;
>> > + cpu_relax();
>> > +
>> > + } while (time_before(jiffies, timeout));
>> > +
>> > + return -EIO;
>> > +}
>> > +
>> > +static inline int mtk_nfc_data_ready(struct mtk_nfc_host *host)
>> > +{
>> > + unsigned long timeout = msecs_to_jiffies(MTK_TIMEOUT);
>> > + u8 val;
>> > +
>> > + timeout += jiffies;
>> > + do {
>> > + val = mtk_nfi_readw(host, MTKSDG1_NFI_PIO_DIRDY);
>> > + val &= PIO_DI_RDY;
>> > + if (val)
>> > + return 0;
>> > + cpu_relax();
>> > +
>> > + } while (time_before(jiffies, timeout));
>> > +
>> > + /* data _MUST_ not be accessed */
>> > + return -EIO;
>> > +}
> Nitpick: you seem to have a lot of xxx_ready() functions, which are
> pretty much all doing the same thing. Maybe it's worth creating a
> single which would take a register offset and status flags, instead of
> adding one function per event.
>
> Something like:
>
> static inline int mtk_nfc_ready(struct mtk_nfc_host *host, int reg,
> u32 flags)
> {
> /* implem */
> }
>
yes I did notice that as well (and I hate the ugliness) but the issue is that
each of them not only will access different registers but also in different
lengths (readl/readw) and apply different masks and expect a different exit
condition. anyway I'll put some more thought in.
ah thanks for all the other comments in the RFC (both device tree and driver). I
will start working on v2 now.
cheers
next prev parent reply other threads:[~2016-03-08 17:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 17:00 [RFC PATCH 0/3] MTK Smart Device Gen1 NAND support Jorge Ramirez-Ortiz
2016-03-02 17:00 ` [PATCH 1/3] mtd: mediatek: device tree docs for MTK Smart Device Gen1 NAND Jorge Ramirez-Ortiz
2016-03-08 15:00 ` Boris Brezillon
2016-03-08 18:19 ` Brian Norris
2016-03-08 15:15 ` Boris Brezillon
2016-03-02 17:00 ` [PATCH 2/3] mtd: mediatek: driver " Jorge Ramirez-Ortiz
2016-03-08 16:24 ` Boris Brezillon
2016-03-08 17:17 ` Jorge Ramirez-Ortiz [this message]
2016-03-08 18:17 ` Brian Norris
2016-03-08 20:08 ` Jorge Ramirez-Ortiz
2016-03-08 20:20 ` Brian Norris
2016-03-08 20:57 ` Jorge Ramirez-Ortiz
2016-03-08 21:22 ` Brian Norris
2016-03-08 22:02 ` Jorge Ramirez-Ortiz
2016-03-09 10:00 ` Boris Brezillon
2016-03-09 20:01 ` Jorge Ramirez-Ortiz
2016-03-09 20:43 ` Boris Brezillon
2016-03-18 14:00 ` Jorge Ramirez-Ortiz
2016-03-18 14:00 ` Jorge Ramirez-Ortiz
[not found] ` <56EC09F5.5020704-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-03-18 14:24 ` Boris Brezillon
2016-03-18 14:24 ` Boris Brezillon
2016-03-15 12:28 ` Jorge Ramirez-Ortiz
2016-03-15 12:59 ` Boris Brezillon
2016-03-15 13:21 ` Jorge Ramirez-Ortiz
2016-03-15 13:53 ` Boris Brezillon
2016-03-02 17:00 ` [PATCH 3/3] mtd: mediatek: device tree enable NAND in MTK's 2701 evb Jorge Ramirez-Ortiz
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=56DF0912.6060305@linaro.org \
--to=jorge.ramirez-ortiz@linaro.org \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=daniel.thompson@linaro.org \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh@kernel.org \
--cc=xiaolei.li@mediatek.com \
/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.