Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Thorsten Blum and committed by
Herbert Xu
6af9914f 33eea63f

+3 -4
+3 -4
drivers/crypto/hifn_795x.c
··· 913 913 else 914 914 pllcfg |= HIFN_PLL_REF_CLK_HBI; 915 915 916 - if (hifn_pll_ref[3] != '\0') 917 - freq = simple_strtoul(hifn_pll_ref + 3, NULL, 10); 918 - else { 916 + if (hifn_pll_ref[3] == '\0' || 917 + kstrtouint(hifn_pll_ref + 3, 10, &freq)) { 919 918 freq = 66; 920 - dev_info(&dev->pdev->dev, "assuming %uMHz clock speed, override with hifn_pll_ref=%.3s<frequency>\n", 919 + dev_info(&dev->pdev->dev, "assuming %u MHz clock speed, override with hifn_pll_ref=%.3s<frequency>\n", 921 920 freq, hifn_pll_ref); 922 921 } 923 922