[PATCH 13/44] drivers: use dev_add_param_uint32_fixed for IDs
Ahmad Fatoum
a.fatoum at barebox.org
Mon Aug 11 05:27:53 PDT 2025
Cut down on the use of temporary buffers for formatting integers in
fixed parameters by using the dev_add_param_uint32_fixed that's
especially meant for this.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
drivers/mfd/superio.c | 7 ++-----
drivers/pci/bus.c | 16 +++++-----------
drivers/w1/w1.c | 10 +++-------
3 files changed, 10 insertions(+), 23 deletions(-)
diff --git a/drivers/mfd/superio.c b/drivers/mfd/superio.c
index 891c8ace52e2..9917c0ff9a59 100644
--- a/drivers/mfd/superio.c
+++ b/drivers/mfd/superio.c
@@ -68,7 +68,6 @@ void superio_chip_add(struct superio_chip *siochip)
{
struct regmap *regmap;
char *chipname;
- char str[5];
int ret;
chipname = xasprintf("superio-%04x:%04x@%02x",
@@ -79,10 +78,8 @@ void superio_chip_add(struct superio_chip *siochip)
siochip->dev->priv = siochip;
- sprintf(str, "%04x", siochip->vid);
- dev_add_param_fixed(siochip->dev, "vendor", str);
- sprintf(str, "%04x", siochip->devid);
- dev_add_param_fixed(siochip->dev, "device", str);
+ dev_add_param_uint32_fixed(siochip->dev, "vendor", siochip->vid, "%04x");
+ dev_add_param_uint32_fixed(siochip->dev, "device", siochip->devid, "%04x");
regmap = regmap_init(siochip->dev, &superio_regmap_bus, siochip,
&superio_regmap_config);
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index c8f5b592428d..a5da84d282b4 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -133,7 +133,6 @@ int pci_register_driver(struct pci_driver *pdrv)
int pci_register_device(struct pci_dev *pdev)
{
- char str[6];
struct device *dev = &pdev->dev;
int ret;
@@ -149,16 +148,11 @@ int pci_register_device(struct pci_dev *pdev)
if (ret)
return ret;
- sprintf(str, "%02x", pdev->devfn);
- dev_add_param_fixed(dev, "devfn", str);
- sprintf(str, "%04x", (pdev->class >> 8) & 0xffff);
- dev_add_param_fixed(dev, "class", str);
- sprintf(str, "%04x", pdev->vendor);
- dev_add_param_fixed(dev, "vendor", str);
- sprintf(str, "%04x", pdev->device);
- dev_add_param_fixed(dev, "device", str);
- sprintf(str, "%04x", pdev->revision);
- dev_add_param_fixed(dev, "revision", str);
+ dev_add_param_uint32_fixed(dev, "devfn", pdev->devfn, "%02x");
+ dev_add_param_uint32_fixed(dev, "class", (pdev->class >> 8) & 0xffff, "%04x");
+ dev_add_param_uint32_fixed(dev, "vendor", pdev->vendor, "%04x");
+ dev_add_param_uint32_fixed(dev, "device", pdev->device, "%04x");
+ dev_add_param_uint32_fixed(dev, "revision", pdev->revision, "%04x");
return 0;
}
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 61f21ff446b8..3944c4676ee8 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -411,7 +411,6 @@ static bool w1_is_registered(struct w1_bus *bus, u64 rn)
static int w1_device_register(struct w1_bus *bus, struct w1_device *dev)
{
- char str[18];
int ret;
dev_set_name(&dev->dev, "w1-%x-", dev->fid);
@@ -425,12 +424,9 @@ static int w1_device_register(struct w1_bus *bus, struct w1_device *dev)
if (ret)
return ret;
- sprintf(str, "0x%x", dev->fid);
- dev_add_param_fixed(&dev->dev, "fid", str);
- sprintf(str, "0x%llx", dev->id);
- dev_add_param_fixed(&dev->dev, "id", str);
- sprintf(str, "0x%llx", dev->reg_num);
- dev_add_param_fixed(&dev->dev, "reg_num", str);
+ dev_add_param_uint32_fixed(&dev->dev, "fid", dev->fid, "0x%x");
+ dev_add_param_uint64_fixed(&dev->dev, "id", dev->id, "0x%llx");
+ dev_add_param_uint64_fixed(&dev->dev, "reg_num", dev->reg_num, "0x%llx");
return ret;
}
--
2.39.5
More information about the barebox
mailing list