Patchwork [02/44] mtd: lart.c: use mtd_device_parse_register

login
register
mail settings
Submitter Dmitry Eremin-Solenikov
Date June 7, 2011, 1:36 p.m.
Message ID <1307453803-31950-3-git-send-email-dbaryshkov@gmail.com>
Download mbox | patch
Permalink /patch/99166/
State New
Headers show

Comments

Dmitry Eremin-Solenikov - June 7, 2011, 1:36 p.m.
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/devices/lart.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
Artem Bityutskiy - June 8, 2011, 8:59 a.m.
On Tue, 2011-06-07 at 17:36 +0400, Dmitry Eremin-Solenikov wrote:
> Replace custom invocations of parse_mtd_partitions and mtd_device_register
> with common mtd_device_parse_register call. This would bring: standard
> handling of all errors, fallback to default partitions, etc.
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

Sorry, but the code does not match the description: you do not use
'mtd_device_parse_register(); there.

> ---
>  drivers/mtd/devices/lart.c |   12 ++++--------
>  1 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c
> index 772a0ff..48b513f 100644
> --- a/drivers/mtd/devices/lart.c
> +++ b/drivers/mtd/devices/lart.c
> @@ -619,6 +619,10 @@ static struct mtd_partition lart_partitions[] = {
>  		.size	= INITRD_LEN,		/* MTDPART_SIZ_FULL */
>  	}
>  };
> +#define NUM_PARTITIONS ARRAY_SIZE(lart_partitions)
> +#else
> +#define lart_partitions NULL
> +#define NUM_PARTITIONS 0
>  #endif
>  
>  static int __init lart_flash_init (void)
> @@ -683,23 +687,15 @@ static int __init lart_flash_init (void)
>  #endif
>  #endif
>  
> -#ifndef HAVE_PARTITIONS
> -   result = mtd_device_register(&mtd, NULL, 0);
> -#else
>     result = mtd_device_register(&mtd, lart_partitions,
>                                  ARRAY_SIZE(lart_partitions));
> -#endif
>  
>     return (result);
>  }
>  
>  static void __exit lart_flash_exit (void)
>  {
> -#ifndef HAVE_PARTITIONS
>     mtd_device_unregister(&mtd);
> -#else
> -   mtd_device_unregister(&mtd);
> -#endif
>  }
>  
>  module_init (lart_flash_init);

Patch

diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c
index 772a0ff..48b513f 100644
--- a/drivers/mtd/devices/lart.c
+++ b/drivers/mtd/devices/lart.c
@@ -619,6 +619,10 @@  static struct mtd_partition lart_partitions[] = {
 		.size	= INITRD_LEN,		/* MTDPART_SIZ_FULL */
 	}
 };
+#define NUM_PARTITIONS ARRAY_SIZE(lart_partitions)
+#else
+#define lart_partitions NULL
+#define NUM_PARTITIONS 0
 #endif
 
 static int __init lart_flash_init (void)
@@ -683,23 +687,15 @@  static int __init lart_flash_init (void)
 #endif
 #endif
 
-#ifndef HAVE_PARTITIONS
-   result = mtd_device_register(&mtd, NULL, 0);
-#else
    result = mtd_device_register(&mtd, lart_partitions,
                                 ARRAY_SIZE(lart_partitions));
-#endif
 
    return (result);
 }
 
 static void __exit lart_flash_exit (void)
 {
-#ifndef HAVE_PARTITIONS
    mtd_device_unregister(&mtd);
-#else
-   mtd_device_unregister(&mtd);
-#endif
 }
 
 module_init (lart_flash_init);