git: a866a40b9b80 - main - bhnd: Use device_set_descf()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 02 Jun 2024 23:47:14 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=a866a40b9b8095a1a31eb22d575535c1f5fbc080
commit a866a40b9b8095a1a31eb22d575535c1f5fbc080
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-02-04 23:35:02 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-06-02 23:38:40 +0000
bhnd: Use device_set_descf()
Here we are in a device probe routine with no locks held. M_WAITOK
allocations are ok. No functional change intended.
MFC after: 1 week
---
sys/dev/bhnd/bhnd_subr.c | 20 ++------------------
sys/dev/bhnd/cores/chipc/bhnd_pmu_chipc.c | 4 +---
2 files changed, 3 insertions(+), 21 deletions(-)
diff --git a/sys/dev/bhnd/bhnd_subr.c b/sys/dev/bhnd/bhnd_subr.c
index 0d38c1ca8a24..1c456ed1cddf 100644
--- a/sys/dev/bhnd/bhnd_subr.c
+++ b/sys/dev/bhnd/bhnd_subr.c
@@ -1765,18 +1765,10 @@ void
bhnd_set_custom_core_desc(device_t dev, const char *dev_name)
{
const char *vendor_name;
- char *desc;
vendor_name = bhnd_get_vendor_name(dev);
- asprintf(&desc, M_BHND, "%s %s, rev %hhu", vendor_name, dev_name,
+ device_set_descf(dev, "%s %s, rev %hhu", vendor_name, dev_name,
bhnd_get_hwrev(dev));
-
- if (desc != NULL) {
- device_set_desc_copy(dev, desc);
- free(desc, M_BHND);
- } else {
- device_set_desc(dev, dev_name);
- }
}
/**
@@ -1802,7 +1794,6 @@ void
bhnd_set_default_bus_desc(device_t dev, const struct bhnd_chipid *chip_id)
{
const char *bus_name;
- char *desc;
char chip_name[BHND_CHIPID_MAX_NAMELEN];
/* Determine chip type's bus name */
@@ -1827,14 +1818,7 @@ bhnd_set_default_bus_desc(device_t dev, const struct bhnd_chipid *chip_id)
chip_id->chip_id);
/* Format and set device description */
- asprintf(&desc, M_BHND, "%s %s", chip_name, bus_name);
- if (desc != NULL) {
- device_set_desc_copy(dev, desc);
- free(desc, M_BHND);
- } else {
- device_set_desc(dev, bus_name);
- }
-
+ device_set_descf(dev, "%s %s", chip_name, bus_name);
}
/**
diff --git a/sys/dev/bhnd/cores/chipc/bhnd_pmu_chipc.c b/sys/dev/bhnd/cores/chipc/bhnd_pmu_chipc.c
index 95b19d973e26..ce50fcd0ee1f 100644
--- a/sys/dev/bhnd/cores/chipc/bhnd_pmu_chipc.c
+++ b/sys/dev/bhnd/cores/chipc/bhnd_pmu_chipc.c
@@ -62,7 +62,6 @@ bhnd_pmu_chipc_probe(device_t dev)
struct chipc_caps *ccaps;
struct chipc_softc *chipc_sc;
device_t chipc;
- char desc[34];
int error;
uint32_t pcaps;
uint8_t rev;
@@ -87,8 +86,7 @@ bhnd_pmu_chipc_probe(device_t dev)
/* Set description */
rev = BHND_PMU_GET_BITS(pcaps, BHND_PMU_CAP_REV);
- snprintf(desc, sizeof(desc), "Broadcom ChipCommon PMU, rev %hhu", rev);
- device_set_desc_copy(dev, desc);
+ device_set_descf(dev, "Broadcom ChipCommon PMU, rev %hhu", rev);
return (BUS_PROBE_NOWILDCARD);
}