* s3c24xx nand: add command line partition table parsing support (resend)
@ 2008-09-18 1:13 Conke Hu
2008-09-18 11:27 ` Russell King - ARM Linux
0 siblings, 1 reply; 8+ messages in thread
From: Conke Hu @ 2008-09-18 1:13 UTC (permalink / raw)
To: Linux-arm-kernel, Ben Dooks; +Cc: Linux Kernel Mailing List, linux-arm
Add mtd id and command line partition table parsing support for
s3c24xx nand driver.
Signed-off-by: Conke Hu <conke.hu@gmail.com>
Signed-off-by: Linke Wang <linke.wang@gmail.com>
------------------
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 556139e..bab7216 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -48,6 +48,8 @@
#include <asm/plat-s3c/regs-nand.h>
#include <asm/plat-s3c/nand.h>
+#define S3C_NAND_NAME_LEN 16
+
#ifdef CONFIG_MTD_NAND_S3C2410_HWECC
static int hardware_ecc = 1;
#else
@@ -60,6 +62,9 @@ static int clock_stop = 1;
static const int clock_stop = 0;
#endif
+#ifdef CONFIG_MTD_PARTITIONS
+static const char *s3c_part_probes[] = {"cmdlinepart", NULL};
+#endif
/* new oob placement block for use with hardware ecc generation
*/
@@ -649,6 +654,15 @@ static int s3c2410_nand_add_partition(struct
s3c2410_nand_info *info,
struct s3c2410_nand_mtd *mtd,
struct s3c2410_nand_set *set)
{
+#ifdef CONFIG_MTD_CMDLINE_PARTS
+ int nr_parts;
+ struct mtd_partition *partitions;
+
+ nr_parts = parse_mtd_partitions(&mtd->mtd, s3c_part_probes,
&partitions, 0);
+ if (nr_parts > 0 && partitions != NULL)
+ return add_mtd_partitions(&mtd->mtd, partitions, nr_parts);
+#endif
+
if (set == NULL)
return add_mtd_device(&mtd->mtd);
@@ -808,6 +822,7 @@ static int s3c24xx_nand_probe(struct platform_device *pdev,
int size;
int nr_sets;
int setno;
+ char *name;
pr_debug("s3c2410_nand_probe(%p)\n", pdev);
@@ -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);
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);
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;
+
s3c2410_nand_init_chip(info, nmtd, sets);
nmtd->scan_res = nand_scan_ident(&nmtd->mtd,
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: s3c24xx nand: add command line partition table parsing support (resend)
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
2008-09-18 15:55 ` Conke Hu
0 siblings, 1 reply; 8+ messages in thread
From: Russell King - ARM Linux @ 2008-09-18 11:27 UTC (permalink / raw)
To: Conke Hu; +Cc: Linux-arm-kernel, Ben Dooks, Linux Kernel Mailing List
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: s3c24xx nand: add command line partition table parsing support (resend)
2008-09-18 11:27 ` Russell King - ARM Linux
@ 2008-09-18 15:55 ` Conke Hu
2008-09-18 15:58 ` Conke Hu
0 siblings, 1 reply; 8+ messages in thread
From: Conke Hu @ 2008-09-18 15:55 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Linux-arm-kernel, Ben Dooks, Linux Kernel Mailing List
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
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: s3c24xx nand: add command line partition table parsing support (resend)
2008-09-18 15:55 ` Conke Hu
@ 2008-09-18 15:58 ` Conke Hu
2008-10-09 15:48 ` Conke Hu
2008-10-12 20:09 ` Conke Hu
0 siblings, 2 replies; 8+ messages in thread
From: Conke Hu @ 2008-09-18 15:58 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Linux-arm-kernel, Ben Dooks, Linux Kernel Mailing List
Add mtd id and command line partition table parsing support for
s3c24xx nand driver.
Signed-off-by: Conke Hu <conke.hu@gmail.com>
Signed-off-by: Linke Wang <linke.wang@gmail.com>
------------------
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 556139e..db0d331 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -48,6 +48,8 @@
#include <asm/plat-s3c/regs-nand.h>
#include <asm/plat-s3c/nand.h>
+#define S3C_NAND_NAME_LEN 16
+
#ifdef CONFIG_MTD_NAND_S3C2410_HWECC
static int hardware_ecc = 1;
#else
@@ -60,6 +62,9 @@ static int clock_stop = 1;
static const int clock_stop = 0;
#endif
+#ifdef CONFIG_MTD_PARTITIONS
+static const char *s3c_part_probes[] = {"cmdlinepart", NULL};
+#endif
/* new oob placement block for use with hardware ecc generation
*/
@@ -80,6 +85,7 @@ struct s3c2410_nand_mtd {
struct s3c2410_nand_set *set;
struct s3c2410_nand_info *info;
int scan_res;
+ char name[S3C_NAND_NAME_LEN];
};
enum s3c_cpu_type {
@@ -649,6 +655,15 @@ static int s3c2410_nand_add_partition(struct
s3c2410_nand_info *info,
struct s3c2410_nand_mtd *mtd,
struct s3c2410_nand_set *set)
{
+#ifdef CONFIG_MTD_CMDLINE_PARTS
+ int nr_parts;
+ struct mtd_partition *partitions;
+
+ nr_parts = parse_mtd_partitions(&mtd->mtd, s3c_part_probes, &partitions, 0);
+ if (nr_parts > 0 && partitions != NULL)
+ return add_mtd_partitions(&mtd->mtd, partitions, nr_parts);
+#endif
+
if (set == NULL)
return add_mtd_device(&mtd->mtd);
@@ -892,6 +907,9 @@ static int s3c24xx_nand_probe(struct platform_device *pdev,
for (setno = 0; setno < nr_sets; setno++, nmtd++) {
pr_debug("initialising set %d (%p, info %p)\n", setno, nmtd, info);
+ 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,
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: s3c24xx nand: add command line partition table parsing support (resend)
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-12 20:09 ` Conke Hu
1 sibling, 1 reply; 8+ messages in thread
From: Conke Hu @ 2008-10-09 15:48 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: Linux-arm-kernel, Ben Dooks, Linux Kernel Mailing List
Hi Russel,
Is this one OK? we're looking forward to applying this patch :)
regards,
conke
On Thu, Sep 18, 2008 at 11:58 PM, Conke Hu <conke.hu@gmail.com> wrote:
> Add mtd id and command line partition table parsing support for
> s3c24xx nand driver.
>
> Signed-off-by: Conke Hu <conke.hu@gmail.com>
> Signed-off-by: Linke Wang <linke.wang@gmail.com>
> ------------------
> diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
> index 556139e..db0d331 100644
> --- a/drivers/mtd/nand/s3c2410.c
> +++ b/drivers/mtd/nand/s3c2410.c
> @@ -48,6 +48,8 @@
> #include <asm/plat-s3c/regs-nand.h>
> #include <asm/plat-s3c/nand.h>
>
> +#define S3C_NAND_NAME_LEN 16
> +
> #ifdef CONFIG_MTD_NAND_S3C2410_HWECC
> static int hardware_ecc = 1;
> #else
> @@ -60,6 +62,9 @@ static int clock_stop = 1;
> static const int clock_stop = 0;
> #endif
>
> +#ifdef CONFIG_MTD_PARTITIONS
> +static const char *s3c_part_probes[] = {"cmdlinepart", NULL};
> +#endif
>
> /* new oob placement block for use with hardware ecc generation
> */
> @@ -80,6 +85,7 @@ struct s3c2410_nand_mtd {
> struct s3c2410_nand_set *set;
> struct s3c2410_nand_info *info;
> int scan_res;
> + char name[S3C_NAND_NAME_LEN];
> };
>
> enum s3c_cpu_type {
> @@ -649,6 +655,15 @@ static int s3c2410_nand_add_partition(struct
> s3c2410_nand_info *info,
> struct s3c2410_nand_mtd *mtd,
> struct s3c2410_nand_set *set)
> {
> +#ifdef CONFIG_MTD_CMDLINE_PARTS
> + int nr_parts;
> + struct mtd_partition *partitions;
> +
> + nr_parts = parse_mtd_partitions(&mtd->mtd, s3c_part_probes, &partitions, 0);
> + if (nr_parts > 0 && partitions != NULL)
> + return add_mtd_partitions(&mtd->mtd, partitions, nr_parts);
> +#endif
> +
> if (set == NULL)
> return add_mtd_device(&mtd->mtd);
>
> @@ -892,6 +907,9 @@ static int s3c24xx_nand_probe(struct platform_device *pdev,
> for (setno = 0; setno < nr_sets; setno++, nmtd++) {
> pr_debug("initialising set %d (%p, info %p)\n", setno, nmtd, info);
>
> + 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,
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: s3c24xx nand: add command line partition table parsing support (resend)
2008-10-09 15:48 ` Conke Hu
@ 2008-10-09 16:26 ` Russell King - ARM Linux
2008-10-09 19:25 ` Conke Hu
0 siblings, 1 reply; 8+ messages in thread
From: Russell King - ARM Linux @ 2008-10-09 16:26 UTC (permalink / raw)
To: Conke Hu; +Cc: Linux-arm-kernel, Ben Dooks, Linux Kernel Mailing List
On Thu, Oct 09, 2008 at 11:48:51PM +0800, Conke Hu wrote:
> Hi Russel,
Grr.
> Is this one OK? we're looking forward to applying this patch :)
Better people to ask would be the MTD people and Ben. I'm not a
gateway for every driver just because it's used on an ARM processor.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: s3c24xx nand: add command line partition table parsing support (resend)
2008-10-09 16:26 ` Russell King - ARM Linux
@ 2008-10-09 19:25 ` Conke Hu
0 siblings, 0 replies; 8+ messages in thread
From: Conke Hu @ 2008-10-09 19:25 UTC (permalink / raw)
To: Ben Dooks
Cc: Linux-arm-kernel, Linux Kernel Mailing List,
Russell King - ARM Linux
Hi Ben, could you please check the patch ?
thanks!
On Fri, Oct 10, 2008 at 12:26 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Thu, Oct 09, 2008 at 11:48:51PM +0800, Conke Hu wrote:
>> Hi Russel,
>
> Grr.
>
>> Is this one OK? we're looking forward to applying this patch :)
>
> Better people to ask would be the MTD people and Ben. I'm not a
> gateway for every driver just because it's used on an ARM processor.
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* s3c24xx nand: add command line partition table parsing support (resend)
2008-09-18 15:58 ` Conke Hu
2008-10-09 15:48 ` Conke Hu
@ 2008-10-12 20:09 ` Conke Hu
1 sibling, 0 replies; 8+ messages in thread
From: Conke Hu @ 2008-10-12 20:09 UTC (permalink / raw)
To: Ben Dooks; +Cc: Linux-arm-kernel, Linux Kernel Mailing List
Add mtd id and command line partition table parsing support for
s3c24xx nand driver.
Signed-off-by: Conke Hu <conke.hu@gmail.com>
Signed-off-by: Linke Wang <linke.wang@gmail.com>
------------------
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 556139e..db0d331 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -48,6 +48,8 @@
#include <asm/plat-s3c/regs-nand.h>
#include <asm/plat-s3c/nand.h>
+#define S3C_NAND_NAME_LEN 16
+
#ifdef CONFIG_MTD_NAND_S3C2410_HWECC
static int hardware_ecc = 1;
#else
@@ -60,6 +62,9 @@ static int clock_stop = 1;
static const int clock_stop = 0;
#endif
+#ifdef CONFIG_MTD_PARTITIONS
+static const char *s3c_part_probes[] = {"cmdlinepart", NULL};
+#endif
/* new oob placement block for use with hardware ecc generation
*/
@@ -80,6 +85,7 @@ struct s3c2410_nand_mtd {
struct s3c2410_nand_set *set;
struct s3c2410_nand_info *info;
int scan_res;
+ char name[S3C_NAND_NAME_LEN];
};
enum s3c_cpu_type {
@@ -649,6 +655,15 @@ static int s3c2410_nand_add_partition(struct
s3c2410_nand_info *info,
struct s3c2410_nand_mtd *mtd,
struct s3c2410_nand_set *set)
{
+#ifdef CONFIG_MTD_CMDLINE_PARTS
+ int nr_parts;
+ struct mtd_partition *partitions;
+
+ nr_parts = parse_mtd_partitions(&mtd->mtd, s3c_part_probes,
&partitions, 0);
+ if (nr_parts > 0 && partitions != NULL)
+ return add_mtd_partitions(&mtd->mtd, partitions, nr_parts);
+#endif
+
if (set == NULL)
return add_mtd_device(&mtd->mtd);
@@ -892,6 +907,9 @@ static int s3c24xx_nand_probe(struct platform_device *pdev,
for (setno = 0; setno < nr_sets; setno++, nmtd++) {
pr_debug("initialising set %d (%p, info %p)\n", setno,
nmtd, info);
+ 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,
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-10-12 20:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox