Skip to content

Commit 921d2eb

Browse files
author
Damien Le Moal
committed
ata: sata_fsl: fix sscanf() and sysfs_emit() format strings
Use the %u format for unsigned int parameters handling with sscanf() and sysfs_emit() to avoid compilation warnings. In fsl_sata_rx_watermark_store(), the call to sscanf() to parse a single argument is replaced with a call to kstrtouint(). While at it, also replace the printk(KERN_ERR) calls with dev_err() calls and fix blank lines in fsl_sata_rx_watermark_store(). Reported-by: kernel test robot <[email protected]> Signed-off-by: Damien Le Moal <[email protected]>
1 parent fda17af commit 921d2eb

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

drivers/ata/sata_fsl.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static void fsl_sata_set_irq_coalescing(struct ata_host *host,
322322
static ssize_t fsl_sata_intr_coalescing_show(struct device *dev,
323323
struct device_attribute *attr, char *buf)
324324
{
325-
return sysfs_emit(buf, "%d %d\n",
325+
return sysfs_emit(buf, "%u %u\n",
326326
intr_coalescing_count, intr_coalescing_ticks);
327327
}
328328

@@ -332,10 +332,8 @@ static ssize_t fsl_sata_intr_coalescing_store(struct device *dev,
332332
{
333333
unsigned int coalescing_count, coalescing_ticks;
334334

335-
if (sscanf(buf, "%d%d",
336-
&coalescing_count,
337-
&coalescing_ticks) != 2) {
338-
printk(KERN_ERR "fsl-sata: wrong parameter format.\n");
335+
if (sscanf(buf, "%u%u", &coalescing_count, &coalescing_ticks) != 2) {
336+
dev_err(dev, "fsl-sata: wrong parameter format.\n");
339337
return -EINVAL;
340338
}
341339

@@ -359,7 +357,7 @@ static ssize_t fsl_sata_rx_watermark_show(struct device *dev,
359357
rx_watermark &= 0x1f;
360358
spin_unlock_irqrestore(&host->lock, flags);
361359

362-
return sysfs_emit(buf, "%d\n", rx_watermark);
360+
return sysfs_emit(buf, "%u\n", rx_watermark);
363361
}
364362

365363
static ssize_t fsl_sata_rx_watermark_store(struct device *dev,
@@ -373,17 +371,17 @@ static ssize_t fsl_sata_rx_watermark_store(struct device *dev,
373371
void __iomem *csr_base = host_priv->csr_base;
374372
u32 temp;
375373

376-
if (sscanf(buf, "%d", &rx_watermark) != 1) {
377-
printk(KERN_ERR "fsl-sata: wrong parameter format.\n");
374+
if (kstrtouint(buf, 10, &rx_watermark) < 0) {
375+
dev_err(dev, "fsl-sata: wrong parameter format.\n");
378376
return -EINVAL;
379377
}
380378

381379
spin_lock_irqsave(&host->lock, flags);
382380
temp = ioread32(csr_base + TRANSCFG);
383381
temp &= 0xffffffe0;
384382
iowrite32(temp | rx_watermark, csr_base + TRANSCFG);
385-
386383
spin_unlock_irqrestore(&host->lock, flags);
384+
387385
return strlen(buf);
388386
}
389387

0 commit comments

Comments
 (0)