From: Mugunthan V N <mugunthanvnm@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/9] cmd: nand: abstract global variable usage for dm conversion
Date: Wed, 13 Apr 2016 16:31:53 +0530 [thread overview]
Message-ID: <570E2721.5080007@ti.com> (raw)
In-Reply-To: <1459551426.32510.36.camel@buserror.net>
On Saturday 02 April 2016 04:27 AM, Scott Wood wrote:
> [Please CC me at this address rather than my NXP address]
>
> On Fri, 2016-04-01 at 16:59 +0530, Mugunthan V N wrote:
>> @@ -432,12 +435,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int
>> argc, char * const argv[])
>> * one before these commands can run, even if a partition specifier
>> * for another device is to be used.
>> */
>> - if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE ||
>> - !nand_info[dev].name) {
>> - puts("\nno devices available\n");
>> - return 1;
>> - }
>> - nand = &nand_info[dev];
>> + nand = get_nand_dev_by_index(dev);
>>
>> if (strcmp(cmd, "bad") == 0) {
>
> You eliminated the error check -- now a NULL deref is likely if a bad dev is
> requested. Even if it's checked elsewhere when setting nand_curr_device, it's
> possible that the initial default is bad (no NAND devices present, or device 0
> failed).
Will fix this in my v2.
>
>> printf("\nDevice %d bad blocks:\n", dev);
>> @@ -496,13 +494,13 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int
>> argc, char * const argv[])
>> /* skip first two or three arguments, look for offset and
>> size */
>> if (mtd_arg_off_size(argc - o, argv + o, &dev, &off, &size,
>> &maxsize, MTD_DEV_TYPE_NAND,
>> - nand_info[dev].size) != 0)
>> + nand->size) != 0)
>> return 1;
>>
>> if (set_dev(dev))
>> return 1;
>>
>> - nand = &nand_info[dev];
>> + nand = get_nand_dev_by_index(dev);
>
> Maybe have set_dev return the dev pointer?
>
> Or have a global for the pointer rather than just the index, saving a bunch of
> these calls.
>
Taking the same to global pointer can be done as a separate patch.
Regards
Mugunthan V N
next prev parent reply other threads:[~2016-04-13 11:01 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-01 11:29 [U-Boot] [PATCH 0/9] device model bringup of nand on am335x gp evm and am437x gp evm Mugunthan V N
2016-04-01 11:29 ` [U-Boot] [PATCH 1/9] include: nand: move endif to end of file Mugunthan V N
2016-04-01 12:51 ` Tom Rini
2016-04-20 14:39 ` Simon Glass
2016-04-01 11:29 ` [U-Boot] [PATCH 2/9] cmd: nand: abstract global variable usage for dm conversion Mugunthan V N
2016-04-01 12:51 ` Tom Rini
2016-04-01 22:57 ` Scott Wood
2016-04-13 11:01 ` Mugunthan V N [this message]
2016-04-14 11:50 ` Mugunthan V N
2016-04-01 11:29 ` [U-Boot] [PATCH 3/9] drivers: nand: Kconfig: add NAND as Kconfig option Mugunthan V N
2016-04-01 12:51 ` Tom Rini
2016-04-01 14:57 ` Mugunthan V N
2016-04-01 23:07 ` Scott Wood
2016-04-01 23:41 ` Tom Rini
2016-04-01 23:45 ` Scott Wood
2016-04-02 0:25 ` Tom Rini
2016-04-05 8:37 ` Mugunthan V N
2016-04-08 19:45 ` Tom Rini
2016-04-17 1:38 ` Scott Wood
2016-04-01 11:29 ` [U-Boot] [PATCH 4/9] drivers: nand: implement a NAND uclass Mugunthan V N
2016-04-01 12:51 ` Tom Rini
2016-04-01 14:59 ` Mugunthan V N
2016-04-01 23:25 ` Scott Wood
2016-04-01 23:31 ` Scott Wood
2016-04-05 8:27 ` Mugunthan V N
2016-04-20 14:39 ` Simon Glass
2016-04-21 5:55 ` Mugunthan V N
2016-04-21 14:11 ` Simon Glass
2016-04-22 5:06 ` Mugunthan V N
2016-04-01 11:29 ` [U-Boot] [PATCH 5/9] drivers: nand: omap_gpmc: convert driver to adopt driver model Mugunthan V N
2016-04-01 12:51 ` Tom Rini
2016-04-04 17:22 ` Scott Wood
2016-04-05 8:41 ` Mugunthan V N
2016-04-01 11:29 ` [U-Boot] [PATCH 6/9] am43xx_evm: nand: do not define DM_NAND for spl Mugunthan V N
2016-04-01 12:51 ` Tom Rini
2016-04-20 14:39 ` Simon Glass
2016-04-01 11:29 ` [U-Boot] [PATCH 7/9] defconfig: am437x_gp_evm: enable NAND driver model Mugunthan V N
2016-04-01 12:52 ` Tom Rini
2016-04-20 14:39 ` Simon Glass
2016-04-01 11:29 ` [U-Boot] [PATCH 8/9] am335x_evm: nand: do not define DM_NAND for spl Mugunthan V N
2016-04-01 12:52 ` Tom Rini
2016-04-20 14:39 ` Simon Glass
2016-04-01 11:29 ` [U-Boot] [PATCH 9/9] defconfig: am335x_gp_evm: enable NAND driver model Mugunthan V N
2016-04-20 14:39 ` Simon Glass
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=570E2721.5080007@ti.com \
--to=mugunthanvnm@ti.com \
--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