All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Conke Hu <conke.hu@gmail.com>
Cc: Linux-arm-kernel@lists.arm.linux.org.uk,
	Ben Dooks <ben-linux@fluff.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: s3c24xx nand: add command line partition table parsing support (resend)
Date: Thu, 18 Sep 2008 12:27:04 +0100	[thread overview]
Message-ID: <20080918112703.GA25491@flint.arm.linux.org.uk> (raw)
In-Reply-To: <5767b9100809171813u7e26d516x12558a178b78f852@mail.gmail.com>

On Thu, Sep 18, 2008 at 09:13:01AM +0800, Conke Hu wrote:
> @@ -875,7 +890,7 @@ static int s3c24xx_nand_probe(struct platform_device *pdev,
> 
>       /* allocate our information */
> 
> -       size = nr_sets * sizeof(*info->mtds);
> +       size = nr_sets * (sizeof(*info->mtds) + S3C_NAND_NAME_LEN);

Why not make the 'name' part of struct s3c2410_nand_mtd?  IOW:

 struct s3c2410_nand_mtd {
 	struct mtd_info 		mtd;
 	struct nand_chip		chip;
 	struct s3c2410_nand_set 	*set;
 	struct s3c2410_nand_info	*info;
 	int				scan_res;
+       char				name[S3C_NAND_NAME_LEN];
 };

That way you can avoid...

>       info->mtds = kmalloc(size, GFP_KERNEL);
>       if (info->mtds == NULL) {
>               dev_err(&pdev->dev, "failed to allocate mtd storage\n");
> @@ -888,10 +903,15 @@ static int s3c24xx_nand_probe(struct
> platform_device *pdev,
>       /* initialise all possible chips */
> 
>       nmtd = info->mtds;
> +       name = (char *)(info->mtds + nr_sets);

This pointer arithmetic.

> 
>       for (setno = 0; setno < nr_sets; setno++, nmtd++) {
>               pr_debug("initialising set %d (%p, info %p)\n", setno,
> nmtd, info);
> 
> +               sprintf(name, "s3c_nand%d", setno);
> +               nmtd->mtd.name = name;
> +               name += S3C_NAND_NAME_LEN;
> +

And this can become the more safe:

		snprintf(nmtd->name, sizeof(nmtd->name), "s3c_nand%d", setno);
		nmtd->mtd.name = nmtd->name;

>               s3c2410_nand_init_chip(info, nmtd, sets);
> 
>               nmtd->scan_res = nand_scan_ident(&nmtd->mtd,
> 
> -------------------------------------------------------------------
> List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
> FAQ:        http://www.arm.linux.org.uk/mailinglists/faq.php
> Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php

  reply	other threads:[~2008-09-18 11:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-18  1:13 s3c24xx nand: add command line partition table parsing support (resend) Conke Hu
2008-09-18 11:27 ` Russell King - ARM Linux [this message]
2008-09-18 15:55   ` Conke Hu
2008-09-18 15:58     ` Conke Hu
2008-10-09 15:48       ` Conke Hu
2008-10-09 16:26         ` Russell King - ARM Linux
2008-10-09 19:25           ` Conke Hu
2008-10-12 20:09       ` Conke Hu

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=20080918112703.GA25491@flint.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=Linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=ben-linux@fluff.org \
    --cc=conke.hu@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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.