git: bad36a49985c - main - acpi: Use device_set_descf()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Sun, 02 Jun 2024 23:47:21 UTC
The branch main has been updated by markj:

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

commit bad36a49985c3cd7bfcb1b35ce3ae37f007843ce
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-02-04 23:51:27 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-06-02 23:38:41 +0000

    acpi: Use device_set_descf()
    
    No functional change intended.
    
    MFC after:      1 week
---
 sys/dev/acpi_support/acpi_asus.c    | 22 +++++-----------------
 sys/dev/acpi_support/acpi_fujitsu.c |  4 +---
 sys/dev/acpica/acpi_ec.c            |  8 +++-----
 sys/dev/acpica/acpi_pci_link.c      |  9 ++++-----
 sys/dev/acpica/acpi_timer.c         |  4 +---
 5 files changed, 14 insertions(+), 33 deletions(-)

diff --git a/sys/dev/acpi_support/acpi_asus.c b/sys/dev/acpi_support/acpi_asus.c
index 6e63d8fabab1..b9ba6650d2b7 100644
--- a/sys/dev/acpi_support/acpi_asus.c
+++ b/sys/dev/acpi_support/acpi_asus.c
@@ -43,7 +43,6 @@
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <sys/bus.h>
-#include <sys/sbuf.h>
 
 #include <contrib/dev/acpica/include/acpi.h>
 #include <contrib/dev/acpica/include/accommon.h>
@@ -535,7 +534,6 @@ acpi_asus_probe(device_t dev)
 {
 	struct acpi_asus_model	*model;
 	struct acpi_asus_softc	*sc;
-	struct sbuf		*sb;
 	ACPI_BUFFER		Buf;
 	ACPI_OBJECT		Arg, *Obj;
 	ACPI_OBJECT_LIST	Args;
@@ -599,24 +597,17 @@ acpi_asus_probe(device_t dev)
 		}
 	}
 
-	sb = sbuf_new_auto();
-	if (sb == NULL)
-		return (ENOMEM);
-
 	/*
 	 * Asus laptops are simply identified by name, easy!
 	 */
 	for (model = acpi_asus_models; model->name != NULL; model++) {
 		if (strncmp(Obj->String.Pointer, model->name, 3) == 0) {
 good:
-			sbuf_printf(sb, "Asus %s Laptop Extras",
-			    Obj->String.Pointer);
-			sbuf_finish(sb);
-
 			sc->model = model;
-			device_set_desc_copy(dev, sbuf_data(sb));
 
-			sbuf_delete(sb);
+			device_set_descf(dev, "Asus %s Laptop Extras",
+			    Obj->String.Pointer);
+
 			AcpiOsFree(Buf.Pointer);
 			return (rv);
 		}
@@ -695,12 +686,9 @@ good:
 		}
 	}
 
-	sbuf_printf(sb, "Unsupported Asus laptop: %s\n", Obj->String.Pointer);
-	sbuf_finish(sb);
-
-	device_printf(dev, "%s", sbuf_data(sb));
+	device_printf(dev, "Unsupported Asus laptop: %s\n",
+	    Obj->String.Pointer);
 
-	sbuf_delete(sb);
 	AcpiOsFree(Buf.Pointer);
 
 	return (ENXIO);
diff --git a/sys/dev/acpi_support/acpi_fujitsu.c b/sys/dev/acpi_support/acpi_fujitsu.c
index 2d3c6f17dfe2..1649f74d873c 100644
--- a/sys/dev/acpi_support/acpi_fujitsu.c
+++ b/sys/dev/acpi_support/acpi_fujitsu.c
@@ -222,14 +222,12 @@ static int
 acpi_fujitsu_probe(device_t dev)
 {
 	char *name;
-	char buffer[64];
 	int rv;
 
 	rv =  ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids, &name);
 	if (acpi_disabled("fujitsu") || rv > 0 || device_get_unit(dev) > 1)
 		return (ENXIO);
-	sprintf(buffer, "Fujitsu Function Hotkeys %s", name);
-	device_set_desc_copy(dev, buffer);
+	device_set_descf(dev, "Fujitsu Function Hotkeys %s", name);
 
 	return (rv);
 }
diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c
index d27b7caee9e6..8ee7bc54f304 100644
--- a/sys/dev/acpica/acpi_ec.c
+++ b/sys/dev/acpica/acpi_ec.c
@@ -339,7 +339,6 @@ acpi_ec_probe(device_t dev)
     ACPI_OBJECT *obj;
     ACPI_STATUS status;
     device_t	peer;
-    char	desc[64];
     int		ecdt;
     int		ret, rc;
     struct acpi_ec_params *params;
@@ -444,10 +443,9 @@ acpi_ec_probe(device_t dev)
     ret = rc;
 out:
     if (ret <= 0) {
-	snprintf(desc, sizeof(desc), "Embedded Controller: GPE %#x%s%s",
-		 params->gpe_bit, (params->glk) ? ", GLK" : "",
-		 ecdt ? ", ECDT" : "");
-	device_set_desc_copy(dev, desc);
+	device_set_descf(dev, "Embedded Controller: GPE %#x%s%s",
+			 params->gpe_bit, (params->glk) ? ", GLK" : "",
+			 ecdt ? ", ECDT" : "");
     } else
 	free(params, M_TEMP);
 
diff --git a/sys/dev/acpica/acpi_pci_link.c b/sys/dev/acpica/acpi_pci_link.c
index dac07a07ae7d..d9807876c443 100644
--- a/sys/dev/acpica/acpi_pci_link.c
+++ b/sys/dev/acpica/acpi_pci_link.c
@@ -143,7 +143,7 @@ acpi_short_name(ACPI_HANDLE handle, char *buffer, size_t buflen)
 static int
 acpi_pci_link_probe(device_t dev)
 {
-	char descr[28], name[12];
+	char name[12];
 	int rv;
 
 	/*
@@ -157,10 +157,9 @@ acpi_pci_link_probe(device_t dev)
 	  return (rv);
 
 	if (ACPI_SUCCESS(acpi_short_name(acpi_get_handle(dev), name,
-	    sizeof(name)))) {
-		snprintf(descr, sizeof(descr), "ACPI PCI Link %s", name);
-		device_set_desc_copy(dev, descr);
-	} else
+	    sizeof(name))))
+		device_set_descf(dev, "ACPI PCI Link %s", name);
+	else
 		device_set_desc(dev, "ACPI PCI Link");
 	device_quiet(dev);
 	return (rv);
diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c
index 8b362f52047a..e78b4728749a 100644
--- a/sys/dev/acpica/acpi_timer.c
+++ b/sys/dev/acpica/acpi_timer.c
@@ -159,7 +159,6 @@ acpi_timer_identify(driver_t *driver, device_t parent)
 static int
 acpi_timer_probe(device_t dev)
 {
-    char desc[40];
     int i, j, rid, rtype;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@@ -219,10 +218,9 @@ acpi_timer_probe(device_t dev)
     }
     tc_init(&acpi_timer_timecounter);
 
-    sprintf(desc, "%d-bit timer at %u.%06uMHz",
+    device_set_descf(dev, "%d-bit timer at %u.%06uMHz",
 	(AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) != 0 ? 32 : 24,
 	acpi_timer_frequency / 1000000, acpi_timer_frequency % 1000000);
-    device_set_desc_copy(dev, desc);
 
     /* Release the resource, we'll allocate it again during attach. */
     bus_release_resource(dev, rtype, rid, acpi_timer_reg);