public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support
Date: Wed, 25 May 2016 08:10:34 +0200	[thread overview]
Message-ID: <574541DA.6020402@denx.de> (raw)
In-Reply-To: <DB5PR0401MB19289A66144C86CE8F94EA2691400@DB5PR0401MB1928.eurprd04.prod.outlook.com>

Hello Scott,

Am 25.05.2016 um 07:30 schrieb Scott Wood:
> On 05/25/2016 12:07 AM, Heiko Schocher wrote:
>> add for nand devices mtd concat support. Generic MTD concat
>> support is already ported to mainline, and used in the cfi_mtd
>> driver. This patch adds it similiar for nand devices.
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> ---
>>
>>   drivers/mtd/nand/nand.c | 29 +++++++++++++++++++++++++++++
>>   1 file changed, 29 insertions(+)
>>
>> diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
>> index 8f0a921..5413123 100644
>> --- a/drivers/mtd/nand/nand.c
>> +++ b/drivers/mtd/nand/nand.c
>> @@ -9,6 +9,7 @@
>>   #include <common.h>
>>   #include <nand.h>
>>   #include <errno.h>
>> +#include <linux/mtd/concat.h>
>>
>>   #ifndef CONFIG_SYS_NAND_BASE_LIST
>>   #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
>> @@ -30,6 +31,12 @@ static char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];
>>
>>   static unsigned long total_nand_size; /* in kiB */
>>
>> +#ifdef CONFIG_MTD_CONCAT
>> +static int nand_devices_found;
>> +static struct mtd_info *mtd_nand_list[CONFIG_SYS_MAX_NAND_DEVICE];
>> +static char c_mtd_name[16];
>> +#endif
>
> Why is c_mtd_name file-scope rather than local?

fixed.

>> +
>>   /* Register an initialized NAND mtd device with the U-Boot NAND command. */
>>   int nand_register(int devnum)
>>   {
>> @@ -49,6 +56,9 @@ int nand_register(int devnum)
>>   	 * via the mtdcore infrastructure (e.g. ubi).
>>   	 */
>>   	add_mtd_device(mtd);
>> +#ifdef CONFIG_MTD_CONCAT
>> +	mtd_nand_list[nand_devices_found++] = mtd;
>> +#endif
>
> Why do we need another list of NAND devices?  Use nand_info[].

Ah, correct ... struct nand_info_t == struct mtd_info ... Hmm...
why we need a "struct nand_info_t" ?

>>   #endif
>>
>>   	total_nand_size += mtd->size / 1024;
>> @@ -102,4 +112,23 @@ void nand_init(void)
>>   	 */
>>   	board_nand_select_device(nand_info[nand_curr_device].priv, nand_curr_device);
>>   #endif
>> +
>> +#ifdef CONFIG_MTD_CONCAT
>> +	if (nand_devices_found > 1) {
>> +		struct mtd_info *mtd;
>> +
>> +		/*
>> +		 * We detected multiple devices. Concatenate them together.
>> +		 */
>> +		sprintf(c_mtd_name, "nand%d", nand_devices_found);
>> +		mtd = mtd_concat_create(mtd_nand_list, nand_devices_found,
>> +					c_mtd_name);
>> +
>> +		if (mtd == NULL)
>> +			return;
>> +
>> +		if (add_mtd_device(mtd))
>> +			return;
>> +	}
>> +#endif /* CONFIG_MTD_CONCAT */
>>   }
>
> Please don't add new features that depend on the old-style NAND init.

Hmm... my add works for the "#ifdef CONFIG_SYS_NAND_SELF_INIT" case
and the "else" case ... where would be the appropriate place?

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  reply	other threads:[~2016-05-25  6:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25  5:07 [U-Boot] [PATCH v1 0/7] add support for the etamin draco board variant Heiko Schocher
2016-05-25  5:07 ` [U-Boot] [PATCH v1 1/7] siemens,am33x: add ubi fastmap support Heiko Schocher
2016-05-25  5:07 ` [U-Boot] [PATCH v1 2/7] ubi: add new ubi command "ubi dettach" Heiko Schocher
2016-05-25  5:47   ` Scott Wood
2016-05-25  6:28     ` Heiko Schocher
2016-05-25 14:46       ` Scott Wood
2016-05-25  5:07 ` [U-Boot] [PATCH v1 3/7] nand: add nand mtd concat support Heiko Schocher
2016-05-25  5:30   ` Scott Wood
2016-05-25  6:10     ` Heiko Schocher [this message]
2016-05-25 14:51       ` Scott Wood
2016-05-26  4:45         ` Heiko Schocher
2016-05-25  5:07 ` [U-Boot] [PATCH v1 4/7] mtd: nand: omap: allow to switch to BCH16 Heiko Schocher
2016-05-25  5:07 ` [U-Boot] [PATCH v1 5/7] am335x, dxr2: get ECC sType from I2C eeprom Heiko Schocher
2016-05-25  5:07 ` [U-Boot] [PATCH v1 6/7] dfu, nand, ubi: fix erasing after write finish Heiko Schocher
2016-05-25  5:33   ` Scott Wood
2016-05-25  6:21     ` Heiko Schocher
2016-05-30  9:51       ` Lukasz Majewski
2016-05-30 10:15         ` Heiko Schocher
2016-05-30 13:13           ` Lukasz Majewski
2016-05-25  5:07 ` [U-Boot] [PATCH v1 7/7] siemens,am33x: add draco etamin board Heiko Schocher

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=574541DA.6020402@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /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