crypto: hifn_795x - replace simple_strtoul with kstrtouint
PATCH 1/1 crypto: hifn_795x - replace simple_strtoul with kstrtouint
Replace simple_strtoul() with the recommended kstrtouint() for parsing the 'hifn_pll_ref=' module parameter. Unlike simple_strtoul(), which returns an unsigned long, kstrtouint() converts the string directly to an unsigned integer and avoids implicit casting.
Check the return value of kstrtouint() and fall back to 66 MHz if parsing fails. This adds error handling while preserving existing behavior for valid values, and removes use of the deprecated simple_strtoul() helper.
Add a space in the log message to correctly format "66 MHz" while we're at it.
--- drivers/crypto/hifn_795x.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/crypto/hifn_795x.c +3 -4
@@ -913,11 +913,10 @@ static void hifn_init_pll(struct hifn_device *dev)else pllcfg |=HIFN_PLL_REF_CLK_HBI ; -if (hifn_pll_ref[3 ] !='\0' ) - freq =simple_strtoul (hifn_pll_ref +3 ,NULL ,10 ); -else { +if (hifn_pll_ref[3 ] =='\0' || +kstrtouint (hifn_pll_ref +3 ,10 , &freq)) { freq =66 ; -dev_info (&dev->pdev->dev,"assuming %uMHz clock speed, override with hifn_pll_ref=%.3s<frequency>\n" , +dev_info (&dev->pdev->dev,"assuming %u MHz clock speed, override with hifn_pll_ref=%.3s<frequency>\n" , freq, hifn_pll_ref); }
Signature · 1 line
2.51.0
Herbert Xu
maintainerQuoted 10 lines · Thorsten Blum
Replace
simple_strtoul()with the recommendedkstrtouint()for parsing the 'hifn_pll_ref=' module parameter. Unlikesimple_strtoul(), which returns an unsigned long,kstrtouint()converts the string directly to an unsigned integer and avoids implicit casting.Check the return value of
kstrtouint()and fall back to 66 MHz if parsing fails. This adds error handling while preserving existing behavior for valid values, and removes use of the deprecatedsimple_strtoul()helper.
Quoted 7 lines
Add a space in the log message to correctly format "66 MHz" while we're at it.
Signed-off-by Thorsten Blum <[email protected]>--- drivers/crypto/hifn_795x.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt