mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 15/17] mtd: omap gpmc: Use dev_add_param_enum
Date: Fri, 22 Nov 2013 15:48:59 +0100	[thread overview]
Message-ID: <1385131741-28280-16-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1385131741-28280-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/nand_omap_gpmc.c | 36 ++++++++++--------------------------
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index 448e7b9..3053a8e 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -90,7 +90,7 @@
 
 int omap_gpmc_decode_bch(int select_4_8, unsigned char *ecc, unsigned int *err_loc);
 
-static char *ecc_mode_strings[] = {
+static const char *ecc_mode_strings[] = {
 	"software",
 	"hamming_hw_romcode",
 	"bch4_hw",
@@ -861,29 +861,11 @@ static int omap_gpmc_eccmode(struct gpmc_nand_info *oinfo,
 	return 0;
 }
 
-static int omap_gpmc_eccmode_set(struct device_d *dev, struct param_d *param, const char *val)
+static int omap_gpmc_eccmode_set(struct param_d *param, void *priv)
 {
-	struct gpmc_nand_info *oinfo = dev->priv;
-	int i;
-
-	if (!val)
-		return 0;
-
-	for (i = 0; i < ARRAY_SIZE(ecc_mode_strings); i++)
-		if (!strcmp(ecc_mode_strings[i], val))
-			break;
+	struct gpmc_nand_info *oinfo = priv;
 
-	if (i == ARRAY_SIZE(ecc_mode_strings)) {
-		dev_err(dev, "invalid ecc mode '%s'\n", val);
-		printf("valid modes:\n");
-		for (i = 0; i < ARRAY_SIZE(ecc_mode_strings); i++)
-			printf("%s\n", ecc_mode_strings[i]);
-		return -EINVAL;
-	}
-
-	dev_param_set_generic(dev, param, ecc_mode_strings[i]);
-
-	return omap_gpmc_eccmode(oinfo, i);
+	return omap_gpmc_eccmode(oinfo, oinfo->ecc_mode);
 }
 
 static int gpmc_set_buswidth(struct nand_chip *chip, int buswidth)
@@ -1062,11 +1044,13 @@ static int gpmc_nand_probe(struct device_d *pdev)
 
 	nand->options |= NAND_SKIP_BBTSCAN;
 
-	dev_add_param(pdev, "eccmode", omap_gpmc_eccmode_set, NULL, 0);
-	dev_set_param(pdev, "eccmode", ecc_mode_strings[pdata->ecc_mode]);
+	oinfo->ecc_mode = pdata->ecc_mode;
+
+	dev_add_param_enum(pdev, "eccmode",
+			omap_gpmc_eccmode_set, NULL, (int *)&oinfo->ecc_mode,
+			ecc_mode_strings, ARRAY_SIZE(ecc_mode_strings), oinfo);
 
-	if (! IS_ENABLED(CONFIG_PARAMETER))
-		omap_gpmc_eccmode(oinfo, pdata->ecc_mode);
+	omap_gpmc_eccmode(oinfo, oinfo->ecc_mode);
 
 	/* We are all set to register with the system now! */
 	err = add_mtd_nand_device(minfo, "nand");
-- 
1.8.4.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-11-22 14:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-22 14:48 Add devicetree support to OMAP drivers Sascha Hauer
2013-11-22 14:48 ` [PATCH 01/17] serial: ns16550: Add device ids for omap Sascha Hauer
2013-11-22 14:48 ` [PATCH 02/17] pinctrl: Add pinctrl-single driver Sascha Hauer
2013-11-22 14:48 ` [PATCH 03/17] spi: omap: encode register offset into device_id Sascha Hauer
2013-11-22 14:48 ` [PATCH 04/17] spi: omap: Add devicetree probe support Sascha Hauer
2013-11-22 14:48 ` [PATCH 05/17] i2c: omap: Add devicetree support Sascha Hauer
2013-11-22 14:48 ` [PATCH 06/17] net: cpsw: inline slave_data Sascha Hauer
2013-11-22 14:48 ` [PATCH 07/17] cpsw: Add devicetree probe support Sascha Hauer
2013-11-22 14:48 ` [PATCH 08/17] net: cpsw: move eth_device into slave Sascha Hauer
2013-11-22 14:48 ` [PATCH 09/17] net: cpsw: drop for_each_slave Sascha Hauer
2013-11-22 14:48 ` [PATCH 10/17] net: cpsw: attach slave to edev->priv Sascha Hauer
2013-11-22 14:48 ` [PATCH 11/17] net: cpsw: straighten error path Sascha Hauer
2013-11-22 14:48 ` [PATCH 12/17] gpio: omap: move to drivers/gpio/ Sascha Hauer
2013-11-22 14:48 ` [PATCH 13/17] omap: gpmc: some refactoring Sascha Hauer
2013-11-22 14:48 ` [PATCH 14/17] gpio: omap: Add devicetree probe support Sascha Hauer
2013-11-22 14:48 ` Sascha Hauer [this message]
2013-11-22 14:49 ` [PATCH 16/17] bus: Add omap gpmc driver Sascha Hauer
2013-11-22 14:49 ` [PATCH 17/17] mmc: omap: Add devicetree support Sascha Hauer

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=1385131741-28280-16-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@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