From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/4] mtdparts: regroup calls to get_mtd_device_nm
Date: Wed, 2 Jun 2010 09:06:35 +0200 [thread overview]
Message-ID: <201006020906.35552.sr@denx.de> (raw)
In-Reply-To: <1275423827-5803-2-git-send-email-bengardiner@nanometrics.ca>
On Tuesday 01 June 2010 22:23:44 Ben Gardiner wrote:
> The get_mtd_device_nm function is called in a couple places and the string
> that is passed to it is not really used after the calls.
>
> This patch regroups the calls to this function into a new function,
> get_mtd_info.
Thanks. Some nitpicking comments below.
> Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
> ---
> common/cmd_mtdparts.c | 43 ++++++++++++++++++++++++++++---------------
> 1 files changed, 28 insertions(+), 15 deletions(-)
>
> diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
> index 116e637..7a9768f 100644
> --- a/common/cmd_mtdparts.c
> +++ b/common/cmd_mtdparts.c
> @@ -286,6 +286,27 @@ static void current_save(void)
> index_partitions();
> }
>
> +
> +/** Produce a mtd_info given a type and num
> + * @param type mtd type
> + * @param num mtd number
> + * @param mtd a pointer to an mtd_info instance (output)
> + * @return 0 if device is valid, 1 otherwise
> + */
> +static int get_mtd_info(u8 type, u8 num, struct mtd_info **mtd)
> +{
> + char mtd_dev[16];
> +
> + sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(type), num);
> + *mtd = get_mtd_device_nm(mtd_dev);
> + if (IS_ERR(*mtd)) {
> + printf("Device %s not found!\n", mtd_dev);
> + return 1;
> + }
> +
> + return 0;
> +}
> +
> /**
> * Performs sanity check for supplied flash partition.
> * Table of existing MTD flash devices is searched and partition device
> @@ -297,17 +318,12 @@ static void current_save(void)
> */
> static int part_validate_eraseblock(struct mtdids *id, struct part_info
> *part) {
> - struct mtd_info *mtd;
> - char mtd_dev[16];
> + struct mtd_info *mtd = NULL;
> int i, j;
> ulong start;
>
> - sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(id->type), id->num);
> - mtd = get_mtd_device_nm(mtd_dev);
> - if (IS_ERR(mtd)) {
> - printf("Partition %s not found on device %s!\n", part->name,
mtd_dev);
> + if(get_mtd_info(id->type, id->num, &mtd))
Space after "if" please.
> return 1;
> - }
>
> part->sector_size = mtd->erasesize;
>
> @@ -684,20 +700,17 @@ static int part_parse(const char *const partdef,
> const char **ret, struct part_i /**
> * Check device number to be within valid range for given device type.
> *
> - * @param dev device to validate
> + * @param type mtd type
> + * @param num mtd number
> + * @param size a pointer to the size of the mtd device (output)
> * @return 0 if device is valid, 1 otherwise
> */
> int mtd_device_validate(u8 type, u8 num, u32 *size)
> {
> - struct mtd_info *mtd;
> - char mtd_dev[16];
> + struct mtd_info *mtd = NULL;
>
> - sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(type), num);
> - mtd = get_mtd_device_nm(mtd_dev);
> - if (IS_ERR(mtd)) {
> - printf("Device %s not found!\n", mtd_dev);
> + if(get_mtd_info(type, num, &mtd))
Again, space after "if".
Please respin this patch and add my:
Acked-by: Stefan Roese <sr@denx.de>
Thanks.
Cheers,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
next prev parent reply other threads:[~2010-06-02 7:06 UTC|newest]
Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-06 16:28 [U-Boot-Users] [PATCH, resend] Support dynamic/patched NAND ENV offset Harald Welte
2008-07-07 18:47 ` Scott Wood
2008-07-08 0:09 ` Harald Welte
2008-07-08 16:05 ` Scott Wood
2008-07-08 21:12 ` Wolfgang Denk
2008-07-09 0:23 ` Harald Welte
2008-07-09 7:05 ` Wolfgang Denk
2008-07-09 7:25 ` Harald Welte
2008-07-09 8:04 ` Wolfgang Denk
2008-07-09 12:13 ` Harald Welte
2010-06-01 20:23 ` [U-Boot] mtdparts: add bad-block skipping Ben Gardiner
2010-06-01 22:20 ` Wolfgang Denk
2010-06-01 22:34 ` Wolfgang Denk
2010-06-02 5:08 ` Ben Gardiner
2010-06-02 15:58 ` [U-Boot] [PATCH 0/4 v2] " Ben Gardiner
2010-07-05 21:43 ` [U-Boot] [PATCH v3 0/4] " Ben Gardiner
2010-07-12 19:06 ` Ben Gardiner
2010-08-09 20:43 ` [U-Boot] [PATCH v4 " Ben Gardiner
2010-08-30 17:38 ` [U-Boot] [PATCH v5 0/5] " Ben Gardiner
2010-08-30 17:38 ` [U-Boot] [PATCH v5 2/5] mtd: add an mtd method for get_len_incl_bad() Ben Gardiner
2010-08-30 20:57 ` Scott Wood
2010-08-31 13:50 ` Ben Gardiner
2010-08-31 21:48 ` [U-Boot] [PATCH v6 " Ben Gardiner
[not found] ` <1283185640-0-git-send-email-bengardiner@nanometrics.ca>
2010-08-30 17:38 ` [U-Boot] [PATCH v5 3/5] mtdparts: show net size in mtdparts list Ben Gardiner
2010-08-30 20:50 ` Scott Wood
2010-08-31 13:51 ` Ben Gardiner
2010-08-31 15:57 ` Scott Wood
2010-08-31 21:48 ` [U-Boot] [PATCH v6 " Ben Gardiner
2010-08-31 21:47 ` [U-Boot] [PATCH v6 0/5] mtdparts: add bad-block skipping Ben Gardiner
2010-09-09 20:54 ` Scott Wood
2010-08-09 20:43 ` [U-Boot] [PATCH v4 1/4] mtdparts: regroup calls to get_mtd_device_nm Ben Gardiner
2010-08-09 20:43 ` [U-Boot] [PATCH v4 2/4] mtdparts: show net size in mtdparts list Ben Gardiner
2010-08-26 18:57 ` Scott Wood
2010-08-27 13:51 ` Ben Gardiner
2010-08-27 15:44 ` Ben Gardiner
2010-08-27 16:02 ` Scott Wood
2010-08-27 16:45 ` Ben Gardiner
2010-08-09 20:43 ` [U-Boot] [PATCH v4 3/4] mtdparts: add new sub-command "spread" Ben Gardiner
2010-08-26 21:12 ` Scott Wood
2010-08-27 13:51 ` Ben Gardiner
2010-08-27 21:36 ` Ben Gardiner
2010-08-27 21:46 ` Scott Wood
2010-08-27 21:52 ` Ben Gardiner
2010-08-27 21:59 ` Scott Wood
2010-08-28 3:59 ` Ben Gardiner
2010-08-30 20:24 ` Scott Wood
2010-08-30 20:30 ` Ben Gardiner
2010-08-30 17:38 ` [U-Boot] [PATCH v5 4/5] " Ben Gardiner
2010-08-30 21:01 ` Scott Wood
2010-08-30 21:05 ` Scott Wood
2010-08-31 13:51 ` Ben Gardiner
2010-08-31 21:48 ` [U-Boot] [PATCH v6 " Ben Gardiner
2010-08-09 20:44 ` [U-Boot] [PATCH v4 4/4] mtdparts: new add.spread: add part skipping bad blocks Ben Gardiner
2010-08-26 22:26 ` Scott Wood
2010-08-27 13:52 ` Ben Gardiner
2010-08-30 17:39 ` [U-Boot] [PATCH v5 5/5] " Ben Gardiner
2010-08-31 21:48 ` [U-Boot] [PATCH v6 " Ben Gardiner
2010-07-05 21:43 ` [U-Boot] [PATCH v3 1/4] mtdparts: regroup calls to get_mtd_device_nm Ben Gardiner
2010-08-30 17:38 ` [U-Boot] [PATCH v5 1/5] " Ben Gardiner
2010-08-31 21:48 ` [U-Boot] [PATCH v6 " Ben Gardiner
2010-07-05 21:43 ` [U-Boot] [PATCH v3 2/4] mtdparts: show net size in mtdparts list Ben Gardiner
2010-08-07 20:08 ` Wolfgang Denk
2010-08-08 4:06 ` Harald Welte
2010-08-08 13:16 ` Wolfgang Denk
2010-08-09 14:45 ` Ben Gardiner
2010-09-18 19:42 ` Wolfgang Denk
2010-07-05 21:43 ` [U-Boot] [PATCH v3 3/4] mtdparts: add new sub-command "spread" Ben Gardiner
2010-08-07 20:12 ` Wolfgang Denk
2010-07-05 21:43 ` [U-Boot] [PATCH v3 4/4] mtdparts: new add.e: add part skipping bad blocks Ben Gardiner
2010-08-07 20:16 ` Wolfgang Denk
2010-06-02 15:58 ` [U-Boot] [PATCH 1/4 v2] mtdparts: regroup calls to get_mtd_device_nm Ben Gardiner
2010-06-02 15:58 ` [U-Boot] [PATCH 2/4 v2] mtdparts: show net size in mtdparts list Ben Gardiner
2010-06-02 15:58 ` [U-Boot] [PATCH 3/4 v2] mtdparts: add new sub-command "spread" Ben Gardiner
2010-06-02 15:58 ` [U-Boot] [PATCH 4/4 v2] mtdparts: new add.e: add part skipping bad blocks Ben Gardiner
2010-08-09 18:25 ` Scott Wood
2010-08-09 18:39 ` Ben Gardiner
2010-08-09 18:51 ` Scott Wood
2010-06-01 20:23 ` [U-Boot] [PATCH 1/4] mtdparts: regroup calls to get_mtd_device_nm Ben Gardiner
2010-06-02 7:06 ` Stefan Roese [this message]
2010-06-01 20:23 ` [U-Boot] [PATCH 2/4] mtdparts: show net size in mtdparts list Ben Gardiner
2010-06-02 7:15 ` Stefan Roese
2010-06-01 20:23 ` [U-Boot] [PATCH 3/4] mtdparts: add new sub-command "spread" Ben Gardiner
2010-06-01 20:23 ` [U-Boot] [PATCH 4/4] mtdparts: new add.e: add part skipping bad blocks Ben Gardiner
2008-07-09 0:18 ` [U-Boot-Users] [PATCH, resend] Support dynamic/patched NAND ENV offset Harald Welte
2008-07-09 5:28 ` Harald Welte
2008-07-09 7:07 ` Harald Welte
2008-07-09 8:11 ` [U-Boot-Users] [PATCH] " Harald Welte
2008-07-11 17:28 ` Scott Wood
2010-05-17 21:04 ` [U-Boot] [PATCH] NAND: Support dynamic location of enviromnent (CONFIG_ENV_OFFSET_OOB) Ben Gardiner
2010-05-26 22:58 ` Scott Wood
2010-05-26 23:38 ` Ben Gardiner
2010-05-31 21:29 ` [U-Boot] [PATCH v2] NAND: environment offset in OOB (CONFIG_ENV_OFFSET_OOB) Ben Gardiner
2010-06-30 21:32 ` [U-Boot] [PATCH v3] " Ben Gardiner
2010-06-30 21:41 ` Wolfgang Denk
2010-07-01 4:09 ` Ben Gardiner
2010-07-01 3:37 ` Vipin KUMAR
2010-07-01 5:29 ` Ben Gardiner
2010-07-01 7:17 ` Harald Welte
2010-07-05 13:57 ` Ben Gardiner
2010-07-05 17:27 ` [U-Boot] [PATCH v4] " Ben Gardiner
2010-07-12 16:17 ` Ben Gardiner
2010-07-12 16:19 ` Scott Wood
2010-07-13 19:26 ` Scott Wood
2010-07-13 21:17 ` Ben Gardiner
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=201006020906.35552.sr@denx.de \
--to=sr@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