From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Johan Jonker <jbx6244@gmail.com>
Cc: Yifeng Zhao <yifeng.zhao@rock-chips.com>,
richard@nod.at, vigneshr@ti.com, robh+dt@kernel.org,
devicetree@vger.kernel.org, linux-mtd@lists.infradead.org,
heiko@sntech.de, linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v5 2/7] mtd: rawnand: rockchip: NFC drivers for RK3308, RK3188 and others
Date: Wed, 29 Apr 2020 19:04:28 +0200 [thread overview]
Message-ID: <20200429190428.33ca0523@xps13> (raw)
In-Reply-To: <4dbe907c-a6c2-a163-0cab-234b08336b5c@gmail.com>
Hi Yifeng,
Johan Jonker <jbx6244@gmail.com> wrote on Wed, 29 Apr 2020 17:55:56
+0200:
> Hi Yifeng,
>
> A few more comments below for now (part 2).
>
> On 4/26/20 12:02 PM, Yifeng Zhao wrote:
>
> [..]
>
> > +#define THIS_NAME "rk-nand"
>
> > +static int rk_nfc_nand_chip_init(struct device *dev, struct rk_nfc *nfc,
> > + struct device_node *np)
> > +{
> > + struct rk_nfc_nand_chip *nand;
> > + struct nand_chip *chip;
> > + struct mtd_info *mtd;
> > + int nsels;
> > + u32 tmp;
> > + int ret;
> > + int i;
> > +
> > + if (!of_get_property(np, "reg", &nsels))
> > + return -ENODEV;
> > + nsels /= sizeof(u32);
> > + if (!nsels || nsels > NFC_MAX_NSELS) {
> > + dev_err(dev, "invalid reg property size %d\n", nsels);
> > + return -EINVAL;
> > + }
> > +
> > + nand = devm_kzalloc(dev, sizeof(*nand) + nsels * sizeof(u8),
> > + GFP_KERNEL);
> > + if (!nand)
> > + return -ENOMEM;
> > +
> > + nand->nsels = nsels;
> > + for (i = 0; i < nsels; i++) {
> > + ret = of_property_read_u32_index(np, "reg", i, &tmp);
> > + if (ret) {
> > + dev_err(dev, "reg property failure : %d\n", ret);
> > + return ret;
> > + }
> > +
> > + if (tmp >= NFC_MAX_NSELS) {
> > + dev_err(dev, "invalid CS: %u\n", tmp);
> > + return -EINVAL;
> > + }
> > +
> > + if (test_and_set_bit(tmp, &nfc->assigned_cs)) {
> > + dev_err(dev, "CS %u already assigned\n", tmp);
> > + return -EINVAL;
> > + }
> > +
> > + nand->sels[i] = tmp;
> > + }
> > +
> > + chip = &nand->chip;
> > + chip->controller = &nfc->controller;
> > +
> > + nand_set_flash_node(chip, np);
> > + nand_set_controller_data(chip, nfc);
> > +
> > + chip->options |= NAND_USE_BOUNCE_BUFFER | NAND_NO_SUBPAGE_WRITE;
> > + chip->bbt_options = NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
> > +
> > + /* set default mode in case dt entry is missing */
> > + chip->ecc.mode = NAND_ECC_HW;
> > +
> > + mtd = nand_to_mtd(chip);
> > + mtd->owner = THIS_MODULE;
> > + mtd->dev.parent = dev;
>
> > + mtd->name = THIS_NAME;
>
> The 'mtd->name' shows up somewhere in file tree.
Good catch.
> The rk3288 has 2 nfc's. In theory 2 probes and also 2 device names, so I
> think that we shouldn't use a fixed define for 'mtd->name'.
> Maybe use something like this:
Yifeng, please use the NAND chip "label" DT property, which is parsed
by the core automatically and will give you meaningful names for every
chip:
nand_set_flash_node(chip, np);
if (!mtd->name) {
dev_err(nfc->dev, "NAND label property is mandatory\n");
return -EINVAL;
}
Thanks,
Miquèl
next prev parent reply other threads:[~2020-04-29 17:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-26 10:02 [PATCH v5 0/7] Add Rockchip NFC drivers for RK3308 and others Yifeng Zhao
2020-04-26 10:02 ` [PATCH v5 1/7] dt-bindings: mtd: Describe Rockchip RK3xxx NAND flash controller Yifeng Zhao
2020-04-28 15:01 ` Rob Herring
2020-04-29 3:56 ` Re: [PATCH v5 1/7] dt-bindings: mtd: Describe Rockchip RK3xxx NAND flash controller【请注意,邮件由robherring2@gmail.com代发】 赵仪峰
2020-04-29 8:53 ` [PATCH v5 1/7] dt-bindings: mtd: Describe Rockchip RK3xxx NAND flash controller Johan Jonker
2020-04-29 9:13 ` Miquel Raynal
2020-04-29 9:28 ` Johan Jonker
2020-04-30 13:02 ` 赵仪峰
2020-05-01 11:47 ` Johan Jonker
2020-04-26 10:02 ` [PATCH v5 2/7] mtd: rawnand: rockchip: NFC drivers for RK3308, RK3188 and others Yifeng Zhao
2020-04-26 15:59 ` Johan Jonker
2020-04-29 11:02 ` Re: [PATCH v5 2/7] mtd: rawnand: rockchip: NFC drivers for RK3308, RK3188 and others【请注意,邮件由linux-rockchip-bounces+yifeng.zhao=rock-chips.com@lists.infradead.org代发】 赵仪峰
2020-04-29 15:55 ` [PATCH v5 2/7] mtd: rawnand: rockchip: NFC drivers for RK3308, RK3188 and others Johan Jonker
2020-04-29 17:04 ` Miquel Raynal [this message]
2020-04-26 10:02 ` [PATCH v5 3/7] MAINTAINERS: add maintainers to rockchip nfc Yifeng Zhao
2020-04-26 13:40 ` Johan Jonker
2020-04-26 10:02 ` [PATCH v5 4/7] arm64: dts: rockchip: Add nfc dts for RK3308 SOC Yifeng Zhao
2020-04-26 10:11 ` [PATCH v5 5/7] arm64: dts: rockchip: Add nfc dts for PX30 SOC Yifeng Zhao
2020-04-26 10:11 ` [PATCH v5 6/7] xarm: dts: rockchip: Add nfc dts for RV1108 SOC Yifeng Zhao
2020-04-26 10:11 ` [PATCH v5 7/7] arm: dts: rockchip: Add nfc dts for RK3066 and RK3188 SOC Yifeng Zhao
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=20200429190428.33ca0523@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=jbx6244@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=richard@nod.at \
--cc=robh+dt@kernel.org \
--cc=vigneshr@ti.com \
--cc=yifeng.zhao@rock-chips.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).