Skip to content

Commit

Permalink
ppc4xx: replace sscanf() by kstrtoul()
Browse files Browse the repository at this point in the history
Fix the checkpatch.pl warning: "Prefer kstrto<type> to single variable sscanf".

Signed-off-by: Salah Triki <[email protected]>
Link: https://lore.kernel.org/r/20210710165432.GA690401@pc
Signed-off-by: Vinod Koul <[email protected]>
  • Loading branch information
salah-triki authored and vinodkoul committed Jul 28, 2021
1 parent 2b5b740 commit 48ae638
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/dma/ppc4xx/adma.c
Original file line number Diff line number Diff line change
Expand Up @@ -4319,6 +4319,7 @@ static ssize_t enable_store(struct device_driver *dev, const char *buf,
size_t count)
{
unsigned long val;
int err;

if (!count || count > 11)
return -EINVAL;
Expand All @@ -4327,7 +4328,10 @@ static ssize_t enable_store(struct device_driver *dev, const char *buf,
return -EFAULT;

/* Write a key */
sscanf(buf, "%lx", &val);
err = kstrtoul(buf, 16, &val);
if (err)
return err;

dcr_write(ppc440spe_mq_dcr_host, DCRN_MQ0_XORBA, val);
isync();

Expand Down Expand Up @@ -4368,7 +4372,7 @@ static ssize_t poly_store(struct device_driver *dev, const char *buf,
size_t count)
{
unsigned long reg, val;

int err;
#ifdef CONFIG_440SP
/* 440SP uses default 0x14D polynomial only */
return -EINVAL;
Expand All @@ -4378,7 +4382,9 @@ static ssize_t poly_store(struct device_driver *dev, const char *buf,
return -EINVAL;

/* e.g., 0x14D or 0x11D */
sscanf(buf, "%lx", &val);
err = kstrtoul(buf, 16, &val);
if (err)
return err;

if (val & ~0x1FF)
return -EINVAL;
Expand Down

0 comments on commit 48ae638

Please sign in to comment.