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 09/21] treewide: Use dev_add_param_int_ro where possible
Date: Sun,  7 Apr 2013 16:00:43 +0200	[thread overview]
Message-ID: <1365343255-26497-10-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>
---
 arch/arm/boards/at91sam9m10ihd/hw_version.c |  6 ++----
 arch/arm/boards/at91sam9x5ek/hw_version.c   |  6 ++----
 arch/arm/boards/sama5d3xek/hw_version.c     |  6 ++----
 drivers/amba/bus.c                          |  9 ++-------
 drivers/input/qt1070.c                      |  6 ++----
 drivers/mtd/core.c                          | 13 ++++---------
 drivers/net/phy/mdio_bus.c                  |  8 ++------
 drivers/usb/core/usb.c                      | 19 ++++++++++---------
 8 files changed, 26 insertions(+), 47 deletions(-)

diff --git a/arch/arm/boards/at91sam9m10ihd/hw_version.c b/arch/arm/boards/at91sam9m10ihd/hw_version.c
index be910df..8e72901 100644
--- a/arch/arm/boards/at91sam9m10ihd/hw_version.c
+++ b/arch/arm/boards/at91sam9m10ihd/hw_version.c
@@ -194,10 +194,8 @@ static void at91sam9m10ihd_devices_detect_one(const char *name)
 	dev_add_param_fixed(dev, "board", info.board_name);
 	sprintf(str, "%.2s", info.vendor_country);
 	dev_add_param_fixed(dev, "country", str);
-	sprintf(str, "%d", info.year);
-	dev_add_param_fixed(dev, "year", str);
-	sprintf(str, "%d", info.week);
-	dev_add_param_fixed(dev, "week", str);
+	dev_add_param_int_ro(dev, "year", info.year, "%d");
+	dev_add_param_int_ro(dev, "week", info.week, "%d");
 	sprintf(str, "%c", info.revision_code);
 	dev_add_param_fixed(dev, "revision_code", str);
 	sprintf(str, "%c", info.revision_id);
diff --git a/arch/arm/boards/at91sam9x5ek/hw_version.c b/arch/arm/boards/at91sam9x5ek/hw_version.c
index 76d4e1b..91af331 100644
--- a/arch/arm/boards/at91sam9x5ek/hw_version.c
+++ b/arch/arm/boards/at91sam9x5ek/hw_version.c
@@ -219,10 +219,8 @@ static void at91sam9x5ek_devices_detect_one(const char *name)
 	dev_add_param_fixed(dev, "board", info.board_name);
 	sprintf(str, "%.2s", info.vendor_country);
 	dev_add_param_fixed(dev, "country", str);
-	sprintf(str, "%d", info.year);
-	dev_add_param_fixed(dev, "year", str);
-	sprintf(str, "%d", info.week);
-	dev_add_param_fixed(dev, "week", str);
+	dev_add_param_int_ro(dev, "year", info.year, "%d");
+	dev_add_param_int_ro(dev, "week", info.week, "%d");
 	sprintf(str, "%c", info.revision_code);
 	dev_add_param_fixed(dev, "revision_code", str);
 	sprintf(str, "%c", info.revision_id);
diff --git a/arch/arm/boards/sama5d3xek/hw_version.c b/arch/arm/boards/sama5d3xek/hw_version.c
index 79fd63a..450eb9f 100644
--- a/arch/arm/boards/sama5d3xek/hw_version.c
+++ b/arch/arm/boards/sama5d3xek/hw_version.c
@@ -226,10 +226,8 @@ static void at91sama5d3xek_devices_detect_one(const char *name)
 	dev_add_param_fixed(dev, "board", bname);
 	sprintf(str, "%.2s", info.vendor_country);
 	dev_add_param_fixed(dev, "country", str);
-	sprintf(str, "%d", info.year);
-	dev_add_param_fixed(dev, "year", str);
-	sprintf(str, "%d", info.week);
-	dev_add_param_fixed(dev, "week", str);
+	dev_add_param_int_ro(dev, "year", info.year, "%d");
+	dev_add_param_int_ro(dev, "week", info.week, "%d");
 	sprintf(str, "%c", info.revision_board);
 	dev_add_param_fixed(dev, "revision_board", str);
 	sprintf(str, "%c", info.revision_schema);
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 7d7a654..6106252 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -153,14 +153,9 @@ int amba_device_add(struct amba_device *dev)
 	if (ret)
 		goto err_release;
 
-	if (IS_ENABLED(CONFIG_PARAMETER)) {
-		char str[16];
+	dev_add_param_int_ro(&dev->dev, "periphid", dev->periphid, "0x%08x");
 
-		sprintf(str, "0x%08x", dev->periphid);
-		dev_add_param_fixed(&dev->dev, "periphid", str);
-	}
-
-		return ret;
+	return ret;
  err_release:
 	release_region(res);
 	return ret;
diff --git a/drivers/input/qt1070.c b/drivers/input/qt1070.c
index 43ea882..7f51da0 100644
--- a/drivers/input/qt1070.c
+++ b/drivers/input/qt1070.c
@@ -239,10 +239,8 @@ static int qt1070_probe(struct device_d *dev)
 		goto err;
 	}
 
-	sprintf(buf, "0x%x", fw_version);
-	dev_add_param_fixed(dev, "fw_version", buf);
-	sprintf(buf, "0x%x", chip_id);
-	dev_add_param_fixed(dev, "chip_ip", buf);
+	dev_add_param_int_ro(dev, "fw_version", fw_version, "0x%x");
+	dev_add_param_int_ro(dev, "chip_ip", chip_id, "0x%x");
 
 	memcpy(data->code, default_code, sizeof(int) * ARRAY_SIZE(default_code));
 
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index e28d925..61744b6 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -286,7 +286,6 @@ static struct file_operations mtd_ops = {
 
 int add_mtd_device(struct mtd_info *mtd, char *devname)
 {
-	char str[16];
 	struct mtddev_hook *hook;
 
 	if (!devname)
@@ -305,14 +304,10 @@ int add_mtd_device(struct mtd_info *mtd, char *devname)
 	mtd->cdev.mtd = mtd;
 
 	if (IS_ENABLED(CONFIG_PARAMETER)) {
-		sprintf(str, "%u", mtd->size);
-		dev_add_param_fixed(&mtd->class_dev, "size", str);
-		sprintf(str, "%u", mtd->erasesize);
-		dev_add_param_fixed(&mtd->class_dev, "erasesize", str);
-		sprintf(str, "%u", mtd->writesize);
-		dev_add_param_fixed(&mtd->class_dev, "writesize", str);
-		sprintf(str, "%u", mtd->oobsize);
-		dev_add_param_fixed(&mtd->class_dev, "oobsize", str);
+		dev_add_param_int_ro(&mtd->class_dev, "size", mtd->size, "%u");
+		dev_add_param_int_ro(&mtd->class_dev, "erasesize", mtd->erasesize, "%u");
+		dev_add_param_int_ro(&mtd->class_dev, "writesize", mtd->oobsize, "%u");
+		dev_add_param_int_ro(&mtd->class_dev, "oobsize", mtd->oobsize, "%u");
 	}
 
 	devfs_create(&mtd->cdev);
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index e1bb7b1..6163a50 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -152,7 +152,6 @@ static int mdio_bus_probe(struct device_d *_dev)
 	struct phy_driver *drv = to_phy_driver(_dev->driver);
 
 	int ret;
-	char str[16];
 
 	dev->attached_dev->phydev = dev;
 
@@ -192,11 +191,8 @@ static int mdio_bus_probe(struct device_d *_dev)
 	if ((dev->supported & SUPPORTED_Autoneg) == 0)
 		dev->autoneg = AUTONEG_DISABLE;
 
-	sprintf(str, "%d", dev->addr);
-	dev_add_param_fixed(&dev->dev, "phy_addr", str);
-
-	sprintf(str, "0x%08x", dev->phy_id);
-	dev_add_param_fixed(&dev->dev, "phy_id", str);
+	dev_add_param_int_ro(&dev->dev, "phy_addr", dev->addr, "%d");
+	dev_add_param_int_ro(&dev->dev, "phy_id", dev->phy_id, "0x%08x");
 
 	dev->cdev.name = asprintf("phy%d", _dev->id);
 	dev->cdev.size = 64;
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index a813be5..9a0723a 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -439,19 +439,20 @@ static int usb_new_device(struct usb_device *dev)
 	print_usb_device(dev);
 
 	register_device(&dev->dev);
-	sprintf(str, "%d", dev->descriptor->iManufacturer);
-	dev_add_param_fixed(&dev->dev, "iManufacturer", str);
-	sprintf(str, "%d", dev->descriptor->iProduct);
-	dev_add_param_fixed(&dev->dev, "iProduct", str);
-	sprintf(str, "%d", dev->descriptor->iSerialNumber);
+	dev_add_param_int_ro(&dev->dev, "iManufacturer",
+			dev->descriptor->iManufacturer, "%d");
+	dev_add_param_int_ro(&dev->dev, "iProduct",
+			dev->descriptor->iProduct, "%d");
+	dev_add_param_int_ro(&dev->dev, "iSerialNumber",
+			dev->descriptor->iSerialNumber, "%d");
 	dev_add_param_fixed(&dev->dev, "iSerialNumber", str);
 	dev_add_param_fixed(&dev->dev, "Manufacturer", dev->mf);
 	dev_add_param_fixed(&dev->dev, "Product", dev->prod);
 	dev_add_param_fixed(&dev->dev, "SerialNumber", dev->serial);
-	sprintf(str, "%04x", le16_to_cpu(dev->descriptor->idVendor));
-	dev_add_param_fixed(&dev->dev, "idVendor", str);
-	sprintf(str, "%04x", le16_to_cpu(dev->descriptor->idProduct));
-	dev_add_param_fixed(&dev->dev, "idProduct", str);
+	dev_add_param_int_ro(&dev->dev, "idVendor",
+			le16_to_cpu(dev->descriptor->idVendor), "%04x");
+	dev_add_param_int_ro(&dev->dev, "idProduct",
+			le16_to_cpu(dev->descriptor->idProduct), "%04x");
 	list_add_tail(&dev->list, &usb_device_list);
 
 	err = 0;
-- 
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 ` Sascha Hauer [this message]
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 ` [PATCH 18/21] console: Use dev_add_param_int for baudrate parameter Sascha Hauer
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-10-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