All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] ACPI: LPSS: Replaced simple_strtol() with kstrtol()
@ 2021-05-24 12:08 Liu Shixin
  2021-05-24 14:33 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Liu Shixin @ 2021-05-24 12:08 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown; +Cc: linux-acpi, linux-kernel, Liu Shixin

The simple_strtol() function is deprecated in some situation since
it does not check for the range overflow. Use kstrtol() instead.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 drivers/acpi/acpi_lpss.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index ca742f16a507..1b46e00cad3a 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -186,13 +186,12 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
 	long uid = 0;
 
 	/* Expected to always be true, but better safe then sorry */
-	if (uid_str)
-		uid = simple_strtol(uid_str, NULL, 10);
-
-	/* Detect I2C bus shared with PUNIT and ignore its d3 status */
-	status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
-	if (ACPI_SUCCESS(status) && shared_host && uid)
-		pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
+	if (uid_str && !kstrtol(uid_str, 10, &uid)) {
+		/* Detect I2C bus shared with PUNIT and ignore its d3 status */
+		status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
+		if (ACPI_SUCCESS(status) && shared_host && uid)
+			pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
+	}
 
 	lpss_deassert_reset(pdata);
 
-- 
2.18.0.huawei.25


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] ACPI: LPSS: Replaced simple_strtol() with kstrtol()
  2021-05-24 12:08 [PATCH -next] ACPI: LPSS: Replaced simple_strtol() with kstrtol() Liu Shixin
@ 2021-05-24 14:33 ` Rafael J. Wysocki
  2021-05-25  2:46   ` Liu Shixin
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2021-05-24 14:33 UTC (permalink / raw)
  To: Liu Shixin
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Mon, May 24, 2021 at 1:35 PM Liu Shixin <liushixin2@huawei.com> wrote:
>
> The simple_strtol() function is deprecated in some situation since
> it does not check for the range overflow. Use kstrtol() instead.
>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
>  drivers/acpi/acpi_lpss.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> index ca742f16a507..1b46e00cad3a 100644
> --- a/drivers/acpi/acpi_lpss.c
> +++ b/drivers/acpi/acpi_lpss.c
> @@ -186,13 +186,12 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
>         long uid = 0;
>
>         /* Expected to always be true, but better safe then sorry */
> -       if (uid_str)
> -               uid = simple_strtol(uid_str, NULL, 10);
> -
> -       /* Detect I2C bus shared with PUNIT and ignore its d3 status */
> -       status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
> -       if (ACPI_SUCCESS(status) && shared_host && uid)
> -               pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
> +       if (uid_str && !kstrtol(uid_str, 10, &uid)) {
> +               /* Detect I2C bus shared with PUNIT and ignore its d3 status */
> +               status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
> +               if (ACPI_SUCCESS(status) && shared_host && uid)
> +                       pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
> +       }

This is not a simple replacement.

Why are you making the other changes?

>
>         lpss_deassert_reset(pdata);
>
> --

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] ACPI: LPSS: Replaced simple_strtol() with kstrtol()
  2021-05-24 14:33 ` Rafael J. Wysocki
@ 2021-05-25  2:46   ` Liu Shixin
  2021-05-25 10:26     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Liu Shixin @ 2021-05-25  2:46 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
	Linux Kernel Mailing List



On 2021/5/24 22:33, Rafael J. Wysocki wrote:
> On Mon, May 24, 2021 at 1:35 PM Liu Shixin <liushixin2@huawei.com> wrote:
>> The simple_strtol() function is deprecated in some situation since
>> it does not check for the range overflow. Use kstrtol() instead.
>>
>> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
>> ---
>>  drivers/acpi/acpi_lpss.c | 13 ++++++-------
>>  1 file changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
>> index ca742f16a507..1b46e00cad3a 100644
>> --- a/drivers/acpi/acpi_lpss.c
>> +++ b/drivers/acpi/acpi_lpss.c
>> @@ -186,13 +186,12 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
>>         long uid = 0;
>>
>>         /* Expected to always be true, but better safe then sorry */
>> -       if (uid_str)
>> -               uid = simple_strtol(uid_str, NULL, 10);
>> -
>> -       /* Detect I2C bus shared with PUNIT and ignore its d3 status */
>> -       status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
>> -       if (ACPI_SUCCESS(status) && shared_host && uid)
>> -               pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
>> +       if (uid_str && !kstrtol(uid_str, 10, &uid)) {
>> +               /* Detect I2C bus shared with PUNIT and ignore its d3 status */
>> +               status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
>> +               if (ACPI_SUCCESS(status) && shared_host && uid)
>> +                       pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
>> +       }
> This is not a simple replacement.
>
> Why are you making the other changes?
The variables status and shared_host are valid only when the uid is not zero(default to zero).
If uid_str is NULL or kstrtol() failed or uid is assigned to zero, we can skip these operations.
>>         lpss_deassert_reset(pdata);
>>
>> --
> .
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] ACPI: LPSS: Replaced simple_strtol() with kstrtol()
  2021-05-25  2:46   ` Liu Shixin
@ 2021-05-25 10:26     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2021-05-25 10:26 UTC (permalink / raw)
  To: Liu Shixin
  Cc: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown,
	ACPI Devel Maling List, Linux Kernel Mailing List

On Tue, May 25, 2021 at 4:46 AM Liu Shixin <liushixin2@huawei.com> wrote:
>
>
>
> On 2021/5/24 22:33, Rafael J. Wysocki wrote:
> > On Mon, May 24, 2021 at 1:35 PM Liu Shixin <liushixin2@huawei.com> wrote:
> >> The simple_strtol() function is deprecated in some situation since
> >> it does not check for the range overflow. Use kstrtol() instead.
> >>
> >> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> >> ---
> >>  drivers/acpi/acpi_lpss.c | 13 ++++++-------
> >>  1 file changed, 6 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> >> index ca742f16a507..1b46e00cad3a 100644
> >> --- a/drivers/acpi/acpi_lpss.c
> >> +++ b/drivers/acpi/acpi_lpss.c
> >> @@ -186,13 +186,12 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
> >>         long uid = 0;
> >>
> >>         /* Expected to always be true, but better safe then sorry */
> >> -       if (uid_str)
> >> -               uid = simple_strtol(uid_str, NULL, 10);
> >> -
> >> -       /* Detect I2C bus shared with PUNIT and ignore its d3 status */
> >> -       status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
> >> -       if (ACPI_SUCCESS(status) && shared_host && uid)
> >> -               pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
> >> +       if (uid_str && !kstrtol(uid_str, 10, &uid)) {
> >> +               /* Detect I2C bus shared with PUNIT and ignore its d3 status */
> >> +               status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
> >> +               if (ACPI_SUCCESS(status) && shared_host && uid)
> >> +                       pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
> >> +       }
> > This is not a simple replacement.
> >
> > Why are you making the other changes?
> The variables status and shared_host are valid only when the uid is not zero(default to zero).
> If uid_str is NULL or kstrtol() failed or uid is assigned to zero, we can skip these operations.

So why don't you write this in the changelog of the patch?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-25 10:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 12:08 [PATCH -next] ACPI: LPSS: Replaced simple_strtol() with kstrtol() Liu Shixin
2021-05-24 14:33 ` Rafael J. Wysocki
2021-05-25  2:46   ` Liu Shixin
2021-05-25 10:26     ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.