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 18/21] console: Use dev_add_param_int for baudrate parameter
Date: Sun,  7 Apr 2013 16:00:52 +0200	[thread overview]
Message-ID: <1365343255-26497-19-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1365343255-26497-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/console.c       | 26 ++++++++------------------
 drivers/mci/mci-core.c | 15 ++++++++-------
 include/console.h      |  2 ++
 3 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/common/console.c b/common/console.c
index beb37bd..a0a06f6 100644
--- a/common/console.c
+++ b/common/console.c
@@ -99,33 +99,22 @@ static int console_std_set(struct device_d *dev, struct param_d *param,
 	return 0;
 }
 
-static int console_baudrate_set(struct device_d *dev, struct param_d *param,
-		const char *val)
+static int console_baudrate_set(struct param_d *param, void *priv)
 {
-	struct console_device *cdev = to_console_dev(dev);
-	int baudrate;
-	char baudstr[16];
+	struct console_device *cdev = priv;
 	unsigned char c;
 
-	if (!val)
-		dev_param_set_generic(dev, param, NULL);
-
-	baudrate = simple_strtoul(val, NULL, 10);
-
 	if (cdev->f_active) {
 		printf("## Switch baudrate to %d bps and press ENTER ...\n",
-			baudrate);
+			cdev->baudrate);
 		mdelay(50);
-		cdev->setbrg(cdev, baudrate);
+		cdev->setbrg(cdev, cdev->baudrate);
 		mdelay(50);
 		do {
 			c = getc();
 		} while (c != '\r' && c != '\n');
 	} else
-		cdev->setbrg(cdev, baudrate);
-
-	sprintf(baudstr, "%d", baudrate);
-	dev_param_set_generic(dev, param, baudstr);
+		cdev->setbrg(cdev, cdev->baudrate);
 
 	return 0;
 }
@@ -155,8 +144,9 @@ int console_register(struct console_device *newcdev)
 	platform_device_register(dev);
 
 	if (newcdev->setbrg) {
-		dev_add_param(dev, "baudrate", console_baudrate_set, NULL, 0);
-		dev_set_param(dev, "baudrate", __stringify(CONFIG_BAUDRATE));
+		newcdev->baudrate = CONFIG_BAUDRATE;
+		dev_add_param_int(dev, "baudrate", console_baudrate_set,
+			NULL, &newcdev->baudrate, "%u", newcdev);
 	}
 
 	dev_add_param(dev, "active", console_std_set, NULL, 0);
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 059e635..86e8d5d 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1461,15 +1461,16 @@ static int mci_set_probe(struct param_d *param, void *priv)
 	struct mci *mci = priv;
 	int rc;
 
+	if (!mci->probe)
+		return 0;
+
 	rc = mci_check_if_already_initialized(mci);
 	if (rc != 0)
 		return 0;
 
-	if (mci->probe) {
-		rc = mci_card_probe(mci);
-		if (rc != 0)
-			return rc;
-	}
+	rc = mci_card_probe(mci);
+	if (rc != 0)
+		return rc;
 
 	return 0;
 }
@@ -1494,8 +1495,8 @@ static int mci_probe(struct device_d *mci_dev)
 
 	dev_info(mci->host->hw_dev, "registered as %s\n", dev_name(mci_dev));
 
-	mci->param_probe = dev_add_param_int(mci_dev, "probe",
-			mci_set_probe, NULL, &mci->probe, "%d", mci);
+	mci->param_probe = dev_add_param_bool(mci_dev, "probe",
+			mci_set_probe, NULL, &mci->probe, mci);
 
 	if (IS_ERR(mci->param_probe)) {
 		dev_dbg(mci->mci_dev, "Failed to add 'probe' parameter to the MCI device\n");
diff --git a/include/console.h b/include/console.h
index c45feb4..72cf99f 100644
--- a/include/console.h
+++ b/include/console.h
@@ -42,6 +42,8 @@ struct console_device {
 
 	unsigned char f_caps;
 	unsigned char f_active;
+
+	unsigned int baudrate;
 };
 
 int console_register(struct console_device *cdev);
-- 
1.8.2.rc2


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

  parent reply	other threads:[~2013-04-07 14:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-07 14:00 [PATCH] Add device parameter convenience helpers Sascha Hauer
2013-04-07 14:00 ` [PATCH 01/21] param: Add dev member to struct param_d Sascha Hauer
2013-04-07 14:00 ` [PATCH 02/21] param: refactor __dev_add_param Sascha Hauer
2013-04-07 14:00 ` [PATCH 03/21] param: Add integer and boolean parameter helpers Sascha Hauer
2013-04-07 14:00 ` [PATCH 04/21] param: Add ip address convenience function Sascha Hauer
2013-04-07 14:00 ` [PATCH 05/21] net: ksz8864: Use dev_add_param_bool for enable parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 06/21] net: store ethernet device parameters in device Sascha Hauer
2013-04-07 14:00 ` [PATCH 07/21] netconsole: use dev_add_param_* helpers Sascha Hauer
2013-04-07 14:00 ` [PATCH 08/21] param: remove now unused dev_[gs]et_param_ip Sascha Hauer
2013-04-07 14:00 ` [PATCH 09/21] treewide: Use dev_add_param_int_ro where possible Sascha Hauer
2013-04-07 14:00 ` [PATCH 10/21] mci: Use dev_add_param_int for probe parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 11/21] ata: Use dev_add_param_bool " Sascha Hauer
2013-04-07 14:00 ` [PATCH 12/21] fb: Use dev_add_param_bool for enable parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 13/21] fb: imxfb: Use dev_add_param_int for alpha parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 14/21] fb: imx-ipu-fb: " Sascha Hauer
2013-04-07 14:00 ` [PATCH 15/21] param: pass param to dev_remove_param Sascha Hauer
2013-04-07 14:00 ` [PATCH 16/21] pwm: Use dev_add_param_int for pwm parameters Sascha Hauer
2013-04-07 14:00 ` [PATCH 17/21] ARM: i.MX: iim: Use dev_add_param_bool for parameters Sascha Hauer
2013-04-07 14:00 ` Sascha Hauer [this message]
2013-04-07 14:00 ` [PATCH 19/21] mtd: Nand: Use dev_add_param_bool for erasebad parameter Sascha Hauer
2013-04-07 22:35   ` Alexander Aring
2013-04-08  8:11     ` Sascha Hauer
2013-04-08 10:15       ` Alexander Aring
2013-04-07 14:00 ` [PATCH 20/21] USB gadget at91: Use dev_add_param_bool for vbus parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 21/21] ARM: MXS: ocotp: Use dev_add_param_bool for parameter 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=1365343255-26497-19-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