All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Christophe Kerello <christophe.kerello@st.com>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, marex@denx.de,
	vigneshr@ti.com, gregkh@linuxfoundation.org, richard@nod.at,
	linux-kernel@vger.kernel.org, robh+dt@kernel.org,
	linux-mtd@lists.infradead.org, boris.brezillon@collabora.com,
	linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v4 10/10] mtd: rawnand: stm32_fmc2: get resources from parent node
Date: Mon, 11 May 2020 11:18:55 +0200	[thread overview]
Message-ID: <20200511111855.48216940@xps13> (raw)
In-Reply-To: <1588756279-17289-11-git-send-email-christophe.kerello@st.com>

Hi Christophe,

Christophe Kerello <christophe.kerello@st.com> wrote on Wed, 6 May 2020
11:11:19 +0200:

> FMC2 EBI support has been added. Common resources (registers base
> and clock) are now shared between the 2 drivers. It means that the
> common resources should now be found in the parent device when EBI
> node is available.
> 
> Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
> ---

[...]

> +
> +static bool stm32_fmc2_nfc_check_for_parent(struct platform_device *pdev)
> +{
> +	u32 i;
> +	int nb_resources = 0;
> +
> +	/* Count the number of resources in reg property */
> +	for (i = 0; i < pdev->num_resources; i++) {
> +		struct resource *res = &pdev->resource[i];
> +
> +		if (resource_type(res) == IORESOURCE_MEM)
> +			nb_resources++;
> +	}
> +
> +	/* Each CS needs 3 resources defined (data, cmd and addr) */
> +	if (nb_resources % 3)
> +		return false;
> +
> +	return true;
> +}

This function looks fragile. Why not just checking the compatible
string of the parent node?

> +
>  static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -1824,8 +1865,8 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>  	struct resource *res;
>  	struct mtd_info *mtd;
>  	struct nand_chip *chip;
> -	void __iomem *mmio;
>  	int chip_cs, mem_region, ret, irq;
> +	int num_region = 1;
>  
>  	nfc = devm_kzalloc(dev, sizeof(*nfc), GFP_KERNEL);
>  	if (!nfc)
> @@ -1834,23 +1875,19 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>  	nfc->dev = dev;
>  	nand_controller_init(&nfc->base);
>  	nfc->base.ops = &stm32_fmc2_nfc_controller_ops;
> +	nfc->has_parent = stm32_fmc2_nfc_check_for_parent(pdev);
> +	if (nfc->has_parent)
> +		num_region = 0;
>  
>  	ret = stm32_fmc2_nfc_parse_dt(nfc);
>  	if (ret)
>  		return ret;
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	mmio = devm_ioremap_resource(dev, res);
> -	if (IS_ERR(mmio))
> -		return PTR_ERR(mmio);
> -
> -	nfc->regmap = devm_regmap_init_mmio(dev, mmio, &stm32_fmc2_regmap_cfg);
> -	if (IS_ERR(nfc->regmap))
> -		return PTR_ERR(nfc->regmap);
> -
> -	nfc->io_phys_addr = res->start;
> +	ret = stm32_fmc2_nfc_set_regmap_clk(pdev, nfc);
> +	if (ret)
> +		return ret;

Are you sure this driver sill works without the EBI block?

This change looks suspect.

>  
> -	for (chip_cs = 0, mem_region = 1; chip_cs < FMC2_MAX_CE;
> +	for (chip_cs = 0, mem_region = num_region; chip_cs < FMC2_MAX_CE;
>  	     chip_cs++, mem_region += 3) {
>  		if (!(nfc->cs_assigned & BIT(chip_cs)))
>  			continue;
> @@ -1888,10 +1925,6 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>  
>  	init_completion(&nfc->complete);
>  
> -	nfc->clk = devm_clk_get(dev, NULL);
> -	if (IS_ERR(nfc->clk))
> -		return PTR_ERR(nfc->clk);
> -

Same here

>  	ret = clk_prepare_enable(nfc->clk);
>  	if (ret) {
>  		dev_err(dev, "can not enable the clock\n");


______________________________________________________
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@bootlin.com>
To: Christophe Kerello <christophe.kerello@st.com>
Cc: <richard@nod.at>, <vigneshr@ti.com>, <robh+dt@kernel.org>,
	<mark.rutland@arm.com>, <gregkh@linuxfoundation.org>,
	<boris.brezillon@collabora.com>, <linux-mtd@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<devicetree@vger.kernel.org>, <marex@denx.de>
Subject: Re: [PATCH v4 10/10] mtd: rawnand: stm32_fmc2: get resources from parent node
Date: Mon, 11 May 2020 11:18:55 +0200	[thread overview]
Message-ID: <20200511111855.48216940@xps13> (raw)
In-Reply-To: <1588756279-17289-11-git-send-email-christophe.kerello@st.com>

Hi Christophe,

Christophe Kerello <christophe.kerello@st.com> wrote on Wed, 6 May 2020
11:11:19 +0200:

> FMC2 EBI support has been added. Common resources (registers base
> and clock) are now shared between the 2 drivers. It means that the
> common resources should now be found in the parent device when EBI
> node is available.
> 
> Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
> ---

[...]

> +
> +static bool stm32_fmc2_nfc_check_for_parent(struct platform_device *pdev)
> +{
> +	u32 i;
> +	int nb_resources = 0;
> +
> +	/* Count the number of resources in reg property */
> +	for (i = 0; i < pdev->num_resources; i++) {
> +		struct resource *res = &pdev->resource[i];
> +
> +		if (resource_type(res) == IORESOURCE_MEM)
> +			nb_resources++;
> +	}
> +
> +	/* Each CS needs 3 resources defined (data, cmd and addr) */
> +	if (nb_resources % 3)
> +		return false;
> +
> +	return true;
> +}

This function looks fragile. Why not just checking the compatible
string of the parent node?

> +
>  static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -1824,8 +1865,8 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>  	struct resource *res;
>  	struct mtd_info *mtd;
>  	struct nand_chip *chip;
> -	void __iomem *mmio;
>  	int chip_cs, mem_region, ret, irq;
> +	int num_region = 1;
>  
>  	nfc = devm_kzalloc(dev, sizeof(*nfc), GFP_KERNEL);
>  	if (!nfc)
> @@ -1834,23 +1875,19 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>  	nfc->dev = dev;
>  	nand_controller_init(&nfc->base);
>  	nfc->base.ops = &stm32_fmc2_nfc_controller_ops;
> +	nfc->has_parent = stm32_fmc2_nfc_check_for_parent(pdev);
> +	if (nfc->has_parent)
> +		num_region = 0;
>  
>  	ret = stm32_fmc2_nfc_parse_dt(nfc);
>  	if (ret)
>  		return ret;
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	mmio = devm_ioremap_resource(dev, res);
> -	if (IS_ERR(mmio))
> -		return PTR_ERR(mmio);
> -
> -	nfc->regmap = devm_regmap_init_mmio(dev, mmio, &stm32_fmc2_regmap_cfg);
> -	if (IS_ERR(nfc->regmap))
> -		return PTR_ERR(nfc->regmap);
> -
> -	nfc->io_phys_addr = res->start;
> +	ret = stm32_fmc2_nfc_set_regmap_clk(pdev, nfc);
> +	if (ret)
> +		return ret;

Are you sure this driver sill works without the EBI block?

This change looks suspect.

>  
> -	for (chip_cs = 0, mem_region = 1; chip_cs < FMC2_MAX_CE;
> +	for (chip_cs = 0, mem_region = num_region; chip_cs < FMC2_MAX_CE;
>  	     chip_cs++, mem_region += 3) {
>  		if (!(nfc->cs_assigned & BIT(chip_cs)))
>  			continue;
> @@ -1888,10 +1925,6 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>  
>  	init_completion(&nfc->complete);
>  
> -	nfc->clk = devm_clk_get(dev, NULL);
> -	if (IS_ERR(nfc->clk))
> -		return PTR_ERR(nfc->clk);
> -

Same here

>  	ret = clk_prepare_enable(nfc->clk);
>  	if (ret) {
>  		dev_err(dev, "can not enable the clock\n");


  reply	other threads:[~2020-05-11  9:19 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  9:11 [PATCH v4 00/10] add STM32 FMC2 EBI controller driver Christophe Kerello
2020-05-06  9:11 ` Christophe Kerello
2020-05-06  9:11 ` [PATCH v4 01/10] mtd: rawnand: stm32_fmc2: manage all errors cases at probe time Christophe Kerello
2020-05-06  9:11   ` Christophe Kerello
2020-05-11 20:29   ` Miquel Raynal
2020-05-11 20:29     ` Miquel Raynal
2020-05-06  9:11 ` [PATCH v4 02/10] mtd: rawnand: stm32_fmc2: remove useless inline comments Christophe Kerello
2020-05-06  9:11   ` Christophe Kerello
2020-05-11 20:29   ` Miquel Raynal
2020-05-11 20:29     ` Miquel Raynal
2020-05-06  9:11 ` [PATCH v4 03/10] mtd: rawnand: stm32_fmc2: use FMC2_TIMEOUT_MS for timeouts Christophe Kerello
2020-05-06  9:11   ` Christophe Kerello
2020-05-11 20:29   ` Miquel Raynal
2020-05-11 20:29     ` Miquel Raynal
2020-05-06  9:11 ` [PATCH v4 04/10] mtd: rawnand: stm32_fmc2: cleanup Christophe Kerello
2020-05-06  9:11   ` Christophe Kerello
2020-05-11 20:39   ` Miquel Raynal
2020-05-11 20:39     ` Miquel Raynal
2020-05-12  6:49     ` Christophe Kerello
2020-05-12  6:49       ` Christophe Kerello
2020-05-12  6:59       ` Miquel Raynal
2020-05-12  6:59         ` Miquel Raynal
2020-05-06  9:11 ` [PATCH v4 05/10] mtd: rawnand: stm32_fmc2: use FIELD_PREP/FIELD_GET macros Christophe Kerello
2020-05-06  9:11   ` Christophe Kerello
2020-05-11 20:29   ` Miquel Raynal
2020-05-11 20:29     ` Miquel Raynal
2020-05-06  9:11 ` [PATCH v4 06/10] dt-bindings: mtd: update STM32 FMC2 NAND controller documentation Christophe Kerello
2020-05-06  9:11   ` Christophe Kerello
2020-05-14 15:00   ` Rob Herring
2020-05-14 15:00     ` Rob Herring
2020-05-14 16:34     ` Christophe Kerello
2020-05-14 16:34       ` Christophe Kerello
2020-05-14 17:55       ` Rob Herring
2020-05-14 17:55         ` Rob Herring
2020-05-15  9:02         ` Christophe Kerello
2020-05-15  9:02           ` Christophe Kerello
2020-05-06  9:11 ` [PATCH v4 07/10] dt-bindings: memory-controller: add STM32 FMC2 EBI " Christophe Kerello
2020-05-06  9:11   ` Christophe Kerello
2020-05-14 15:07   ` Rob Herring
2020-05-14 15:07     ` Rob Herring
2020-05-14 16:37     ` Christophe Kerello
2020-05-14 16:37       ` Christophe Kerello
2020-05-06  9:11 ` [PATCH v4 08/10] memory: stm32-fmc2-ebi: add STM32 FMC2 EBI controller driver Christophe Kerello
2020-05-06  9:11   ` Christophe Kerello
2020-05-06  9:11 ` [PATCH v4 09/10] mtd: rawnand: stm32_fmc2: use regmap APIs Christophe Kerello
2020-05-06  9:11   ` Christophe Kerello
2020-05-06  9:11 ` [PATCH v4 10/10] mtd: rawnand: stm32_fmc2: get resources from parent node Christophe Kerello
2020-05-06  9:11   ` Christophe Kerello
2020-05-11  9:18   ` Miquel Raynal [this message]
2020-05-11  9:18     ` Miquel Raynal
2020-05-11 10:21     ` Christophe Kerello
2020-05-11 10:21       ` Christophe Kerello
2020-05-11 11:59       ` Miquel Raynal
2020-05-11 11:59         ` Miquel Raynal
2020-05-11 12:47         ` Christophe Kerello
2020-05-11 12:47           ` Christophe Kerello
2020-05-11 12:58           ` Miquel Raynal
2020-05-11 12:58             ` Miquel Raynal
2020-05-11 14:19             ` Christophe Kerello
2020-05-11 14:19               ` Christophe Kerello
2020-05-11 14:45               ` Miquel Raynal
2020-05-11 14:45                 ` Miquel Raynal
2020-05-11 17:02                 ` Christophe Kerello
2020-05-11 17:02                   ` Christophe Kerello
2020-05-11 20:28                   ` Miquel Raynal
2020-05-11 20:28                     ` Miquel Raynal
2020-05-11  9:22 ` [PATCH v4 00/10] add STM32 FMC2 EBI controller driver Miquel Raynal
2020-05-11  9:22   ` Miquel Raynal
2020-05-11 10:26   ` Christophe Kerello
2020-05-11 10:26     ` Christophe Kerello

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=20200511111855.48216940@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=boris.brezillon@collabora.com \
    --cc=christophe.kerello@st.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=marex@denx.de \
    --cc=mark.rutland@arm.com \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    --cc=vigneshr@ti.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.