Messages in this thread | | | Date | Thu, 18 Sep 2008 23:55:48 +0800 | From | "Conke Hu" <> | Subject | Re: s3c24xx nand: add command line partition table parsing support (resend) |
| |
Thanks! I'd re-write and resend the patch
On 9/18/08, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote: > 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 >
| |