git: 19d87088173a - stable/14 - ata: Use device_set_descf()

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

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

commit 19d87088173ae670a977561561e3876fa5524419
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-02-04 23:33:05 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-06-09 13:37:48 +0000

    ata: Use device_set_descf()
    
    No functional change intended.
    
    MFC after:      1 week
    
    (cherry picked from commit 25b839dfd2aa60640c7b92abc69b11c107a95020)
---
 sys/dev/ata/ata-pci.c                |  8 ++------
 sys/dev/ata/chipsets/ata-highpoint.c | 15 +++++++--------
 sys/dev/ata/chipsets/ata-jmicron.c   |  4 +---
 sys/dev/ata/chipsets/ata-promise.c   | 14 ++++++--------
 sys/dev/ata/chipsets/ata-sis.c       | 13 ++++++-------
 5 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/sys/dev/ata/ata-pci.c b/sys/dev/ata/ata-pci.c
index 767467cef656..71a58a21df39 100644
--- a/sys/dev/ata/ata-pci.c
+++ b/sys/dev/ata/ata-pci.c
@@ -61,7 +61,6 @@ int
 ata_pci_probe(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(dev);
-    char buffer[64];
 
     /* is this a storage class device ? */
     if (pci_get_class(dev) != PCIC_STORAGE)
@@ -71,8 +70,7 @@ ata_pci_probe(device_t dev)
     if (pci_get_subclass(dev) != PCIS_STORAGE_IDE)
 	return (ENXIO);
     
-    sprintf(buffer, "%s ATA controller", ata_pcivendor2str(dev));
-    device_set_desc_copy(dev, buffer);
+    device_set_descf(dev, "%s ATA controller", ata_pcivendor2str(dev));
     ctlr->chipinit = ata_generic_chipinit;
 
     /* we are a low priority handler */
@@ -836,12 +834,10 @@ void
 ata_set_desc(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(dev);
-    char buffer[128];
 
-    sprintf(buffer, "%s %s %s controller",
+    device_set_descf(dev, "%s %s %s controller",
             ata_pcivendor2str(dev), ctlr->chip->text, 
             ata_mode2str(ctlr->chip->max_dma));
-    device_set_desc_copy(dev, buffer);
 }
 
 const struct ata_chip_id *
diff --git a/sys/dev/ata/chipsets/ata-highpoint.c b/sys/dev/ata/chipsets/ata-highpoint.c
index 7b9619907281..3f7de04659bf 100644
--- a/sys/dev/ata/chipsets/ata-highpoint.c
+++ b/sys/dev/ata/chipsets/ata-highpoint.c
@@ -82,7 +82,7 @@ ata_highpoint_probe(device_t dev)
      { ATA_HPT366, 0x00, HPT_366, HPT_OLD, ATA_UDMA4, "HPT366" },
      { ATA_HPT302, 0x01, HPT_372, 0,       ATA_UDMA6, "HPT302" },
      { 0, 0, 0, 0, 0, 0}};
-    char buffer[64];
+    const char *channel;
 
     if (pci_get_vendor(dev) != ATA_HIGHPOINT_ID)
         return ENXIO;
@@ -90,16 +90,15 @@ ata_highpoint_probe(device_t dev)
     if (!(idx = ata_match_chip(dev, ids)))
 	return ENXIO;
 
-    strcpy(buffer, "HighPoint ");
-    strcat(buffer, idx->text);
+    channel = "";
     if (idx->cfg1 == HPT_374) {
 	if (pci_get_function(dev) == 0)
-	    strcat(buffer, " (channel 0+1)");
-	if (pci_get_function(dev) == 1)
-	    strcat(buffer, " (channel 2+3)");
+	    channel = " (channel 0+1)";
+	else if (pci_get_function(dev) == 1)
+	    channel = " (channel 2+3)";
     }
-    sprintf(buffer, "%s %s controller", buffer, ata_mode2str(idx->max_dma));
-    device_set_desc_copy(dev, buffer);
+    device_set_descf(dev, "Highpoint %s%s %s controller",
+	idx->text, channel, ata_mode2str(idx->max_dma));
     ctlr->chip = idx;
     ctlr->chipinit = ata_highpoint_chipinit;
     return (BUS_PROBE_LOW_PRIORITY);
diff --git a/sys/dev/ata/chipsets/ata-jmicron.c b/sys/dev/ata/chipsets/ata-jmicron.c
index 8d0cc46ac0b2..1a7d3d514454 100644
--- a/sys/dev/ata/chipsets/ata-jmicron.c
+++ b/sys/dev/ata/chipsets/ata-jmicron.c
@@ -73,7 +73,6 @@ ata_jmicron_probe(device_t dev)
      { ATA_JMB368, 0, 0, 1, ATA_UDMA6, "JMB368" },
      { ATA_JMB368_2, 0, 0, 1, ATA_UDMA6, "JMB368" },
      { 0, 0, 0, 0, 0, 0}};
-    char buffer[64];
 
     if (pci_get_vendor(dev) != ATA_JMICRON_ID)
 	return ENXIO;
@@ -81,9 +80,8 @@ ata_jmicron_probe(device_t dev)
     if (!(idx = ata_match_chip(dev, ids)))
         return ENXIO;
 
-    sprintf(buffer, "JMicron %s %s controller",
+    device_set_descf(dev, "JMicron %s %s controller",
 	idx->text, ata_mode2str(idx->max_dma));
-    device_set_desc_copy(dev, buffer);
     ctlr->chip = idx;
     ctlr->chipinit = ata_jmicron_chipinit;
     return (BUS_PROBE_LOW_PRIORITY);
diff --git a/sys/dev/ata/chipsets/ata-promise.c b/sys/dev/ata/chipsets/ata-promise.c
index 94c96d00f9de..c59f23ea66c7 100644
--- a/sys/dev/ata/chipsets/ata-promise.c
+++ b/sys/dev/ata/chipsets/ata-promise.c
@@ -167,7 +167,7 @@ ata_promise_probe(device_t dev)
      { ATA_PDC40719,  0, PR_MIO, PR_SATA2, ATA_SA300, "PDC40719" },
      { ATA_PDC40779,  0, PR_MIO, PR_SATA2, ATA_SA300, "PDC40779" },
      { 0, 0, 0, 0, 0, 0}};
-    char buffer[64];
+    const char *channel;
     uintptr_t devid = 0;
 
     if (pci_get_vendor(dev) != ATA_PROMISE_ID)
@@ -183,10 +183,8 @@ ata_promise_probe(device_t dev)
 	devid == ATA_I960RM) 
 	return ENXIO;
 
-    strcpy(buffer, "Promise ");
-    strcat(buffer, idx->text);
-
     /* if we are on a FastTrak TX4, adjust the interrupt resource */
+    channel = NULL;
     if ((idx->cfg2 & PR_TX4) && pci_get_class(GRANDPARENT(dev))==PCIC_BRIDGE &&
 	!BUS_READ_IVAR(device_get_parent(GRANDPARENT(dev)),
 		       GRANDPARENT(dev), PCI_IVAR_DEVID, &devid) &&
@@ -195,18 +193,18 @@ ata_promise_probe(device_t dev)
 
 	if (pci_get_slot(dev) == 1) {
 	    bus_get_resource(dev, SYS_RES_IRQ, 0, &start, &end);
-	    strcat(buffer, " (channel 0+1)");
+	    channel = " (channel 0+1)";
 	}
 	else if (pci_get_slot(dev) == 2 && start && end) {
 	    bus_set_resource(dev, SYS_RES_IRQ, 0, start, end);
-	    strcat(buffer, " (channel 2+3)");
+	    channel = " (channel 2+3)";
 	}
 	else {
 	    start = end = 0;
 	}
     }
-    sprintf(buffer, "%s %s controller", buffer, ata_mode2str(idx->max_dma));
-    device_set_desc_copy(dev, buffer);
+    device_set_descf(dev, "Promise %s%s %s controller", idx->text,
+	channel == NULL ? "" : channel, ata_mode2str(idx->max_dma));
     ctlr->chip = idx;
     ctlr->chipinit = ata_promise_chipinit;
     return (BUS_PROBE_LOW_PRIORITY);
diff --git a/sys/dev/ata/chipsets/ata-sis.c b/sys/dev/ata/chipsets/ata-sis.c
index 039fe6c06e9e..3cc10291d66d 100644
--- a/sys/dev/ata/chipsets/ata-sis.c
+++ b/sys/dev/ata/chipsets/ata-sis.c
@@ -102,7 +102,6 @@ ata_sis_probe(device_t dev)
      { 0, 0, 0, 0, 0, 0 }};
     static struct ata_chip_id id[] =
     {{ ATA_SISSOUTH, 0x10, 0, 0, 0, "" }, { 0, 0, 0, 0, 0, 0 }};
-    char buffer[64];
     int found = 0;
 
     if (pci_get_class(dev) != PCIC_STORAGE)
@@ -123,8 +122,8 @@ ata_sis_probe(device_t dev)
     	    memcpy(&id[0], idx, sizeof(id[0]));
 	    id[0].cfg1 = SIS_133NEW;
 	    id[0].max_dma = ATA_UDMA6;
-	    sprintf(buffer, "SiS 962/963 %s controller",
-		    ata_mode2str(idx->max_dma));
+	    device_set_descf(dev, "SiS 962/963 %s controller",
+		ata_mode2str(idx->max_dma));
 	}
 	pci_write_config(dev, 0x57, reg57, 1);
     }
@@ -141,17 +140,17 @@ ata_sis_probe(device_t dev)
 		id[0].cfg1 = SIS_100NEW;
 		id[0].max_dma = ATA_UDMA5;
 	    }
-	    sprintf(buffer, "SiS 961 %s controller",ata_mode2str(idx->max_dma));
+	    device_set_descf(dev, "SiS 961 %s controller",
+		ata_mode2str(idx->max_dma));
 	}
 	pci_write_config(dev, 0x4a, reg4a, 1);
     }
     if (!found)
-	sprintf(buffer,"SiS %s %s controller",
-		idx->text, ata_mode2str(idx->max_dma));
+	device_set_descf(dev, "SiS %s %s controller",
+	    idx->text, ata_mode2str(idx->max_dma));
     else
 	idx = &id[0];
 
-    device_set_desc_copy(dev, buffer);
     ctlr->chip = idx;
     ctlr->chipinit = ata_sis_chipinit;
     return (BUS_PROBE_LOW_PRIORITY);