ACPI: LPSS: use acpi_dev_uid_match() for matching _UID
PATCH 1/1 ACPI: LPSS: use acpi_dev_uid_match() for matching _UID
Use acpi_dev_uid_match() for matching _UID instead of treating it as an integer.
--- drivers/acpi/acpi_lpss.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/acpi/acpi_lpss.c +2 -6
@@ -167,10 +167,8 @@ static struct pwm_lookup byt_pwm_lookup[] = {static void byt_pwm_setup (struct lpss_private_data *pdata) { -u64 uid; -/* Only call pwm_add_table for the first PWM controller */ -if (acpi_dev_uid_to_integer (pdata->adev, &uid) || uid !=1 ) +if (!acpi_dev_uid_match (pdata->adev,"1" ))return ;pwm_add_table (byt_pwm_lookup,ARRAY_SIZE (byt_pwm_lookup));
@@ -218,10 +216,8 @@ static struct pwm_lookup bsw_pwm_lookup[] = {static void bsw_pwm_setup (struct lpss_private_data *pdata) { -u64 uid; -/* Only call pwm_add_table for the first PWM controller */ -if (acpi_dev_uid_to_integer (pdata->adev, &uid) || uid !=1 ) +if (!acpi_dev_uid_match (pdata->adev,"1" ))return ;pwm_add_table (bsw_pwm_lookup,ARRAY_SIZE (bsw_pwm_lookup));
base-commit: 72d54941cd56ac3fedca6f7ae00a300b33ead29e
Signature · 1 line
2.17.1
Quoted 4 lines · Raag Jadav
Use
acpi_dev_uid_match()for matching_UIDinstead of treating it as an integer.Signed-off-by Raag Jadav <[email protected]>
Rafael J. Wysocki
maintainerQuoted 8 lines · Mika Westerberg
Quoted 4 lines · Raag Jadav
Use
acpi_dev_uid_match()for matching_UIDinstead of treating it as an integer.Signed-off-by Raag Jadav <[email protected]>Acked-by Mika Westerberg <[email protected]>
I was about to apply this, but then I realized that it might change the behavior in a subtle way, because what if the _UID string is something like "01"?
Raag Jadav
Reviewed-by Hans de GoedeQuoted 7 lines · Rafael J. Wysocki
Quoted 5 lines · Mika Westerberg
Quoted 3 lines · Raag Jadav
Use
acpi_dev_uid_match()for matching_UIDinstead of treating it as an integer.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Raag Jadav <[email protected]>Acked-by Mika Westerberg <[email protected]>I was about to apply this, but then I realized that it might change the behavior in a subtle way, because what if the
_UIDstring is something like "01"?
I checked the git history and found below.
commit 2a036e489eb1571810126d6fa47bd8af1e237c08
Author: Andy Shevchenko <[email protected]> Date: Tue Sep 13 19:31:41 2022 +0300
ACPI: LPSS: Refactor _UID handling to use acpi_dev_uid_to_integer()
ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as an integer. Use it instead of custom approach.
drivers/acpi/acpi_lpss.c +2 -2
@@ -167,10 +167,10 @@ static struct pwm_lookup byt_pwm_lookup[] = {static void byt_pwm_setup (struct lpss_private_data *pdata) { -struct acpi_device *adev = pdata->adev; +u64 uid;/* Only call pwm_add_table for the first PWM controller */ -if (!adev->pnp.unique_id ||strcmp (adev->pnp.unique_id,"1" )) +if (acpi_dev_uid_to_integer (pdata->adev, &uid) || uid !=1 )return ;pwm_add_table (byt_pwm_lookup,ARRAY_SIZE (byt_pwm_lookup));
So if we consider the original logic with strcmp, which is more inline with acpi_dev_uid_match(), "01" should not be the case here in my opinion.
Thanks for sharing your concern though.
Raag
Rafael J. Wysocki
maintainerQuoted 50 lines · Raag Jadav
Quoted 7 lines · Rafael J. Wysocki
Quoted 5 lines · Mika Westerberg
Quoted 3 lines · Raag Jadav
Use
acpi_dev_uid_match()for matching_UIDinstead of treating it as an integer.Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Raag Jadav <[email protected]>Acked-by Mika Westerberg <[email protected]>I was about to apply this, but then I realized that it might change the behavior in a subtle way, because what if the
_UIDstring is something like "01"?I checked the git history and found below.
commit
2a036e489eb1571810126d6fa47bd8af1e237c08Author: Andy Shevchenko <[email protected]> Date: Tue Sep 13 19:31:41 2022 +0300ACPI: LPSS: Refactor
_UIDhandling to useacpi_dev_uid_to_integer()ACPI utils provide
acpi_dev_uid_to_integer()helper to extract_UIDas an integer. Use it instead of custom approach.Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Hans de Goede <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>drivers/acpi/acpi_lpss.c +2
-2@@ -167,10 +167,10 @@ static struct pwm_lookup byt_pwm_lookup[] = {static void byt_pwm_setup (struct lpss_private_data *pdata) { -struct acpi_device *adev = pdata->adev; +u64 uid;/* Only call pwm_add_table for the first PWM controller */ -if (!adev->pnp.unique_id ||strcmp (adev->pnp.unique_id,"1" )) +if (acpi_dev_uid_to_integer (pdata->adev, &uid) || uid !=1 )return ;pwm_add_table (byt_pwm_lookup,ARRAY_SIZE (byt_pwm_lookup));
Quoted 4 lines
So if we consider the original logic with strcmp, which is more inline with
acpi_dev_uid_match(), "01" should not be the case here in my opinion.Thanks for sharing your concern though.
Well, this means that what the patch really does is to effectively revert commit 2a036e489eb1571810126d6fa47bd8af1e237c08 and use the new helper instead of the open-coded check that was there before, so all of this information should be present in the changelog.
Quoted 2 lines · Raag Jadav
Use
acpi_dev_uid_match()for matching_UIDinstead of treating it as an integer.
NAK. See below why.
...
drivers/acpi/acpi_lpss.c static struct pwm_lookup byt_pwm_lookup[] = { · line 171
Quoted 7 lines
static void
byt_pwm_setup(struct lpss_private_data *pdata){drivers/acpi/acpi_lpss.c +1
-3-u64 uid; -/* Only call pwm_add_table for the first PWM controller */ -if (acpi_dev_uid_to_integer (pdata->adev, &uid) || uid !=1 ) +if (!acpi_dev_uid_match (pdata->adev,"1" ))
_UID by specification is a type of _string_. Yet, that string may represent an integer number. Now, how many variants of the strings can you imagine that may be interpreted as integer 1? I can tell about dozens.
With your change you restricted the all possible spectre of the 1 representations to a single one. Have you checked ALL of the DSDTs for these platforms to say 'hey, all current tables uses "1" and this is not an issue'? Further question, will you guarantee that new platforms on this chip won't use something different? (Not that big issue, but will require to actively revert your change in the future).
Quoted 13 lines
drivers/acpi/acpi_lpss.c +1
-3return ;pwm_add_table (byt_pwm_lookup,ARRAY_SIZE (byt_pwm_lookup));@@ -218,10 +216,8 @@ static struct pwm_lookup bsw_pwm_lookup[] = {static void bsw_pwm_setup (struct lpss_private_data *pdata) { -u64 uid; -/* Only call pwm_add_table for the first PWM controller */ -if (acpi_dev_uid_to_integer (pdata->adev, &uid) || uid !=1 ) +if (!acpi_dev_uid_match (pdata->adev,"1" ))return ;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 20 lines · Andy Shevchenko
Quoted 2 lines · Raag Jadav
Use
acpi_dev_uid_match()for matching_UIDinstead of treating it as an integer.NAK. See below why.
...
drivers/acpi/acpi_lpss.c static struct pwm_lookup byt_pwm_lookup[] = { · line 171
Quoted 7 lines
static void
byt_pwm_setup(struct lpss_private_data *pdata){drivers/acpi/acpi_lpss.c +1
-3-u64 uid; -/* Only call pwm_add_table for the first PWM controller */ -if (acpi_dev_uid_to_integer (pdata->adev, &uid) || uid !=1 ) +if (!acpi_dev_uid_match (pdata->adev,"1" ))
_UIDby specification is a type of _string_. Yet, that string may represent an integer number. Now, how many variants of the strings can you imagine that may be interpreted as integer 1? I can tell about dozens.
Quoted 4 lines
With your change you restricted the all possible spectre of the 1 representations to a single one. Have you checked ALL of the DSDTs for these platforms to say 'hey, all current tables uses "1" and this is not an issue'?
I'm not sure if I'm following you, this would basically invalidate every usage of acpi_dev_hid_uid_match() helper across the driver.
Raag
Quoted 2 lines · Raag Jadav
Quoted 1 line · Andy Shevchenko
On Wed, Oct 25, 2023 at 11:08:33AM +0530, Raag Jadav wrote:
...
Quoted 12 lines
Quoted 12 lines
drivers/acpi/acpi_lpss.c static struct pwm_lookup byt_pwm_lookup[] = { · line 171
Quoted 7 lines
static void
byt_pwm_setup(struct lpss_private_data *pdata){drivers/acpi/acpi_lpss.c +1
-3-u64 uid; -/* Only call pwm_add_table for the first PWM controller */ -if (acpi_dev_uid_to_integer (pdata->adev, &uid) || uid !=1 ) +if (!acpi_dev_uid_match (pdata->adev,"1" ))
_UIDby specification is a type of _string_. Yet, that string may represent an integer number. Now, how many variants of the strings can you imagine that may be interpreted as integer 1? I can tell about dozens.
Quoted 7 lines
Quoted 4 lines
With your change you restricted the all possible spectre of the 1 representations to a single one. Have you checked ALL of the DSDTs for these platforms to say 'hey, all current tables uses "1" and this is not an issue'?
I'm not sure if I'm following you, this would basically invalidate every usage of
acpi_dev_hid_uid_match()helper across the driver.
It depends.
Signature · 2 lines
With Best Regards, Andy Shevchenko