From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Johan Jonker <jbx6244@gmail.com>
Cc: devicetree@vger.kernel.org, vigneshr@ti.com, richard@nod.at,
Yifeng Zhao <yifeng.zhao@rock-chips.com>,
linux-rockchip@lists.infradead.org, robh+dt@kernel.org,
linux-mtd@lists.infradead.org, heiko@sntech.de
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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>
To: Johan Jonker <jbx6244-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Yifeng Zhao <yifeng.zhao-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
richard-/L3Ra7n9ekc@public.gmane.org,
vigneshr-l0cyMroinI0@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Hi Yifeng,
Johan Jonker <jbx6244-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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
WARNING: multiple messages have this Message-ID (diff)
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: 57+ 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 ` Yifeng Zhao
2020-04-26 10:02 ` Yifeng Zhao
2020-04-26 10:02 ` [PATCH v5 1/7] dt-bindings: mtd: Describe Rockchip RK3xxx NAND flash controller Yifeng Zhao
2020-04-26 10:02 ` Yifeng Zhao
2020-04-26 10:02 ` Yifeng Zhao
2020-04-28 15:01 ` Rob Herring
2020-04-28 15:01 ` Rob Herring
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 3:56 ` 赵仪峰
2020-04-29 8:53 ` [PATCH v5 1/7] dt-bindings: mtd: Describe Rockchip RK3xxx NAND flash controller Johan Jonker
2020-04-29 8:53 ` Johan Jonker
2020-04-29 8:53 ` Johan Jonker
2020-04-29 9:13 ` Miquel Raynal
2020-04-29 9:13 ` Miquel Raynal
2020-04-29 9:13 ` Miquel Raynal
2020-04-29 9:28 ` Johan Jonker
2020-04-29 9:28 ` Johan Jonker
2020-04-29 9:28 ` Johan Jonker
2020-04-30 13:02 ` 赵仪峰
2020-04-30 13:02 ` 赵仪峰
2020-04-30 13:02 ` 赵仪峰
2020-05-01 11:47 ` Johan Jonker
2020-05-01 11:47 ` Johan Jonker
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 10:02 ` Yifeng Zhao
2020-04-26 15:59 ` Johan Jonker
2020-04-26 15:59 ` Johan Jonker
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 11:02 ` 赵仪峰
2020-04-29 15:55 ` [PATCH v5 2/7] mtd: rawnand: rockchip: NFC drivers for RK3308, RK3188 and others Johan Jonker
2020-04-29 15:55 ` Johan Jonker
2020-04-29 15:55 ` Johan Jonker
2020-04-29 17:04 ` Miquel Raynal [this message]
2020-04-29 17:04 ` Miquel Raynal
2020-04-29 17:04 ` Miquel Raynal
2020-04-26 10:02 ` [PATCH v5 3/7] MAINTAINERS: add maintainers to rockchip nfc Yifeng Zhao
2020-04-26 10:02 ` Yifeng Zhao
2020-04-26 10:02 ` Yifeng Zhao
2020-04-26 13:40 ` Johan Jonker
2020-04-26 13:40 ` Johan Jonker
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:02 ` Yifeng Zhao
2020-04-26 10:02 ` 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 ` Yifeng Zhao
2020-04-26 10:11 ` 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 ` Yifeng Zhao
2020-04-26 10:11 ` Yifeng Zhao
2020-04-26 10:11 ` [PATCH v5 7/7] arm: dts: rockchip: Add nfc dts for RK3066 and RK3188 SOC Yifeng Zhao
2020-04-26 10:11 ` Yifeng Zhao
2020-04-26 10:11 ` 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 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.