git: 18468b225ce4 - stable/14 - bhnd: Use device_set_descf()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Sun, 09 Jun 2024 14:12:03 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=18468b225ce45a97a4c7ea70e7741fc8022b0b3a

commit 18468b225ce45a97a4c7ea70e7741fc8022b0b3a
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-02-04 23:35:02 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-06-09 13:37:49 +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
    
    (cherry picked from commit a866a40b9b8095a1a31eb22d575535c1f5fbc080)
---
 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 df2474f57659..c29122c38759 100644
--- a/sys/dev/bhnd/bhnd_subr.c
+++ b/sys/dev/bhnd/bhnd_subr.c
@@ -1766,18 +1766,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);
-	}
 }
 
 /**
@@ -1803,7 +1795,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 */
@@ -1828,14 +1819,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);
 }