From: David Brownell <david-b@pacbell.net>
To: Andrew Morton <akpm@linux-foundation.org>, linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Subject: [patch 2.6.29-rc6-mmotm] MTD: partitioning utility predicates
Date: Thu, 26 Feb 2009 15:18:16 -0800 [thread overview]
Message-ID: <200902261518.16378.david-b@pacbell.net> (raw)
In-Reply-To: <20090226123341.a2421733.akpm@linux-foundation.org>
From: David Brownell <dbrownell@users.sourceforge.net>
Move mtd_has_partitions() and mtd_has_cmdlinepart() inlines from
a DaVinci-specific driver to the <linux/mtd/partitions.h> header.
Use those to eliminate #ifdefs in two drivers which had their
own definitions of mtd_has_partitions().
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
Quite a lot of other MTD drivers could benefit from using use one
or both of these to remove #ifdeffery. Maybe some Janitors
would like to help?
drivers/mtd/devices/m25p80.c | 17 ++++++-----------
drivers/mtd/devices/mtd_dataflash.c | 16 ++++++----------
drivers/mtd/nand/davinci_nand.c | 13 -------------
include/linux/mtd/partitions.h | 12 ++++++++++++
4 files changed, 24 insertions(+), 34 deletions(-)
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -65,12 +65,6 @@
#define FAST_READ_DUMMY_BYTE 0
#endif
-#ifdef CONFIG_MTD_PARTITIONS
-#define mtd_has_partitions() (1)
-#else
-#define mtd_has_partitions() (0)
-#endif
-
/****************************************************************************/
struct m25p {
@@ -708,12 +702,13 @@ static int __devinit m25p_probe(struct s
struct mtd_partition *parts = NULL;
int nr_parts = 0;
-#ifdef CONFIG_MTD_CMDLINE_PARTS
- static const char *part_probes[] = { "cmdlinepart", NULL, };
+ if (mtd_has_cmdlinepart()) {
+ static const char *part_probes[]
+ = { "cmdlinepart", NULL, };
- nr_parts = parse_mtd_partitions(&flash->mtd,
- part_probes, &parts, 0);
-#endif
+ nr_parts = parse_mtd_partitions(&flash->mtd,
+ part_probes, &parts, 0);
+ }
if (nr_parts <= 0 && data && data->parts) {
parts = data->parts;
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -98,12 +98,6 @@ struct dataflash {
struct mtd_info mtd;
};
-#ifdef CONFIG_MTD_PARTITIONS
-#define mtd_has_partitions() (1)
-#else
-#define mtd_has_partitions() (0)
-#endif
-
/* ......................................................................... */
/*
@@ -682,11 +676,13 @@ add_dataflash_otp(struct spi_device *spi
struct mtd_partition *parts;
int nr_parts = 0;
-#ifdef CONFIG_MTD_CMDLINE_PARTS
- static const char *part_probes[] = { "cmdlinepart", NULL, };
+ if (mtd_has_cmdlinepart()) {
+ static const char *part_probes[]
+ = { "cmdlinepart", NULL, };
- nr_parts = parse_mtd_partitions(device, part_probes, &parts, 0);
-#endif
+ nr_parts = parse_mtd_partitions(device,
+ part_probes, &parts, 0);
+ }
if (nr_parts <= 0 && pdata && pdata->parts) {
parts = pdata->parts;
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -39,19 +39,6 @@
#include <asm/mach-types.h>
-#ifdef CONFIG_MTD_PARTITIONS
-static inline int mtd_has_partitions(void) { return 1; }
-#else
-static inline int mtd_has_partitions(void) { return 0; }
-#endif
-
-#ifdef CONFIG_MTD_CMDLINE_PARTS
-static inline int mtd_has_cmdlinepart(void) { return 1; }
-#else
-static inline int mtd_has_cmdlinepart(void) { return 0; }
-#endif
-
-
/*
* This is a device driver for the NAND flash controller found on the
* various DaVinci family chips. It handles up to four SoC chipselects,
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -76,4 +76,16 @@ int __devinit of_mtd_parse_partitions(st
struct device_node *node,
struct mtd_partition **pparts);
+#ifdef CONFIG_MTD_PARTITIONS
+static inline int mtd_has_partitions(void) { return 1; }
+#else
+static inline int mtd_has_partitions(void) { return 0; }
+#endif
+
+#ifdef CONFIG_MTD_CMDLINE_PARTS
+static inline int mtd_has_cmdlinepart(void) { return 1; }
+#else
+static inline int mtd_has_cmdlinepart(void) { return 0; }
+#endif
+
#endif
prev parent reply other threads:[~2009-02-26 23:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-24 23:09 [patch/RESEND 2.6.29-rc3-git] NAND: davinci_nand driver David Brownell
2009-02-25 1:55 ` Thiago Galesi
2009-02-25 4:12 ` David Brownell
2009-02-25 13:05 ` Thiago Galesi
2009-02-26 20:33 ` Andrew Morton
2009-02-26 23:15 ` David Brownell
2009-02-27 17:52 ` Felipe Balbi
2009-03-02 8:33 ` Rajashekhara, Sudhakar
2009-02-27 22:29 ` Kevin Hilman
2009-02-26 23:18 ` David Brownell [this message]
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=200902261518.16378.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox