Skip to contentSkip to conversation

Cleanup ATA sysfs attribute show functions

PATCH New Damien Le Moal 1 participant 6 messages Dec 2, 2021 libata

lore
Share & tools
lore
#0 lore raw

cover Cleanup ATA sysfs attribute show functions

Convert remaining sysfs attribute show() functions to use sysfs_emit() instead of s[n]printf().

Damien Le Moal (4):
ata: libata-sata: use sysfs_emit()
ata: libata-scsi: use sysfs_emit()
ata: ahci: use sysfs_emit()
ata: sata_fsl: use sysfs_emit()

 drivers/ata/ahci.c        | 2 +-
 drivers/ata/libata-sata.c | 4 ++--
 drivers/ata/libata-scsi.c | 2 +-
 drivers/ata/sata_fsl.c    | 6 +++---
 4 files changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/1 ata: ahci_ceva: Fix sparse warning in ceva_ahci_read_id()

Fix the following sparse warning:

drivers/ata/ahci_ceva.c:107:33: warning: invalid assignment: &=
drivers/ata/ahci_ceva.c:107:33: left side has type unsigned short
drivers/ata/ahci_ceva.c:107:33: right side has type restricted __le16

---
 drivers/ata/ahci_ceva.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ata/ahci_ceva.c +2 -1
index 50b56cd0039d..e9c7c07fd84c 100644
@@ -94,6 +94,7 @@ struct ceva_ahci_priv {
 static unsigned int ceva_ahci_read_id(struct ata_device *dev,
 					struct ata_taskfile *tf, u16 *id)
 {
+	__le16 *__id = (__le16 *)id;
 	u32 err_mask;
 
 	err_mask = ata_do_dev_read_id(dev, tf, id);
@@ -103,7 +104,7 @@ static unsigned int ceva_ahci_read_id(struct ata_device *dev,
 	 * Since CEVA controller does not support device sleep feature, we
 	 * need to clear DEVSLP (bit 8) in word78 of the IDENTIFY DEVICE data.
 	 */
-	id[ATA_ID_FEATURE_SUPP] &= cpu_to_le16(~(1 << 8));
+	__id[ATA_ID_FEATURE_SUPP] &= cpu_to_le16(~(1 << 8));
 
 	return 0;
 }
Signature · 1 line
2.31.1
#2 lore raw

PATCH 1/4 ata: libata-sata: use sysfs_emit()

In reply to Damien Le Moal

Use sysfs_emit() instead of snprintf() in sysfs attibute show() functions.

---
 drivers/ata/libata-sata.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/libata-sata.c +2 -2
index b9c77885b872..eddd33a3cb5f 100644
@@ -876,7 +876,7 @@ static ssize_t ata_ncq_prio_enable_show(struct device *device,
 		ncq_prio_enable = dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE;
 	spin_unlock_irq(ap->lock);
 
-	return rc ? rc : snprintf(buf, 20, "%u\n", ncq_prio_enable);
+	return rc ? rc : sysfs_emit(buf, "%u\n", ncq_prio_enable);
 }
 
 static ssize_t ata_ncq_prio_enable_store(struct device *device,
@@ -972,7 +972,7 @@ ata_scsi_em_message_type_show(struct device *dev, struct device_attribute *attr,
 	struct Scsi_Host *shost = class_to_shost(dev);
 	struct ata_port *ap = ata_shost_to_port(shost);
 
-	return snprintf(buf, 23, "%d\n", ap->em_message_type);
+	return sysfs_emit(buf, "%d\n", ap->em_message_type);
 }
 DEVICE_ATTR(em_message_type, S_IRUGO,
 		  ata_scsi_em_message_type_show, NULL);
Signature · 1 line
2.31.1
#3 lore raw

PATCH 2/4 ata: libata-scsi: use sysfs_emit()

In reply to Damien Le Moal

Use sysfs_emit() instead of snprintf() in ata_scsi_park_show().

---
 drivers/ata/libata-scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-scsi.c +1 -1
index 1b84d5526d77..0fc47b2e0c41 100644
@@ -121,7 +121,7 @@ static ssize_t ata_scsi_park_show(struct device *device,
 unlock:
 	spin_unlock_irq(ap->lock);
 
-	return rc ? rc : snprintf(buf, 20, "%u\n", msecs);
+	return rc ? rc : sysfs_emit(buf, "%u\n", msecs);
 }
 
 static ssize_t ata_scsi_park_store(struct device *device,
Signature · 1 line
2.31.1
#4 lore raw

PATCH 3/4 ata: ahci: use sysfs_emit()

In reply to Damien Le Moal

Use sysfs_emit() instead of sprintf in remapped_nvme_show().

---
 drivers/ata/ahci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/ahci.c +1 -1
index 1e1167e725a4..98d04a780458 100644
@@ -1657,7 +1657,7 @@ static ssize_t remapped_nvme_show(struct device *dev,
 	struct ata_host *host = dev_get_drvdata(dev);
 	struct ahci_host_priv *hpriv = host->private_data;
 
-	return sprintf(buf, "%u\n", hpriv->remapped_nvme);
+	return sysfs_emit(buf, "%u\n", hpriv->remapped_nvme);
 }
 
 static DEVICE_ATTR_RO(remapped_nvme);
Signature · 1 line
2.31.1
#5 lore raw

PATCH 4/4 ata: sata_fsl: use sysfs_emit()

In reply to Damien Le Moal

Use sysfs_emit() instead of sprintf() in fsl_sata_intr_coalescing_show() and fsl_sata_rx_watermark_show().

---
 drivers/ata/sata_fsl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/ata/sata_fsl.c +3 -3
index c5a2c1e9ed6b..ec52511ae60f 100644
@@ -322,7 +322,7 @@ static void fsl_sata_set_irq_coalescing(struct ata_host *host,
 static ssize_t fsl_sata_intr_coalescing_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
-	return sprintf(buf, "%d	%d\n",
+	return sysfs_emit(buf, "%d	%d\n",
 			intr_coalescing_count, intr_coalescing_ticks);
 }
 
@@ -357,9 +357,9 @@ static ssize_t fsl_sata_rx_watermark_show(struct device *dev,
 	spin_lock_irqsave(&host->lock, flags);
 	rx_watermark = ioread32(csr_base + TRANSCFG);
 	rx_watermark &= 0x1f;
-
 	spin_unlock_irqrestore(&host->lock, flags);
-	return sprintf(buf, "%d\n", rx_watermark);
+
+	return sysfs_emit(buf, "%d\n", rx_watermark);
 }
 
 static ssize_t fsl_sata_rx_watermark_store(struct device *dev,
Signature · 1 line
2.31.1