[PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex

Mario Limonciello posted 20 patches 2 weeks, 4 days ago
There is a newer version of this series
[PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex
Posted by Mario Limonciello 2 weeks, 4 days ago
Holding the mutex is not necessary while scanning the string passed into
platform_profile_store().

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/acpi/platform_profile.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 4e8a155589c21..70e7f1ba68676 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev,
 {
 	int err, i;
 
+	/* Scan for a matching profile */
+	i = sysfs_match_string(profile_names, buf);
+	if (i < 0)
+		return -EINVAL;
+
 	err = mutex_lock_interruptible(&profile_lock);
 	if (err)
 		return err;
@@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev,
 		return -ENODEV;
 	}
 
-	/* Scan for a matching profile */
-	i = sysfs_match_string(profile_names, buf);
-	if (i < 0) {
-		mutex_unlock(&profile_lock);
-		return -EINVAL;
-	}
-
 	/* Check that platform supports this profile choice */
 	if (!test_bit(i, cur_profile->choices)) {
 		mutex_unlock(&profile_lock);
-- 
2.43.0
Re: [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex
Posted by Armin Wolf 2 weeks, 4 days ago
Am 05.11.24 um 16:33 schrieb Mario Limonciello:

> Holding the mutex is not necessary while scanning the string passed into
> platform_profile_store().

Reviewed-by: Armin Wolf <W_Armin@gmx.de>

> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   drivers/acpi/platform_profile.c | 12 +++++-------
>   1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 4e8a155589c21..70e7f1ba68676 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev,
>   {
>   	int err, i;
>
> +	/* Scan for a matching profile */
> +	i = sysfs_match_string(profile_names, buf);
> +	if (i < 0)
> +		return -EINVAL;
> +
>   	err = mutex_lock_interruptible(&profile_lock);
>   	if (err)
>   		return err;
> @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev,
>   		return -ENODEV;
>   	}
>
> -	/* Scan for a matching profile */
> -	i = sysfs_match_string(profile_names, buf);
> -	if (i < 0) {
> -		mutex_unlock(&profile_lock);
> -		return -EINVAL;
> -	}
> -
>   	/* Check that platform supports this profile choice */
>   	if (!test_bit(i, cur_profile->choices)) {
>   		mutex_unlock(&profile_lock);
Re: [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex
Posted by Ilpo Järvinen 2 weeks, 4 days ago
On Tue, 5 Nov 2024, Mario Limonciello wrote:

> Holding the mutex is not necessary while scanning the string passed into
> platform_profile_store().
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>  drivers/acpi/platform_profile.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 4e8a155589c21..70e7f1ba68676 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev,
>  {
>  	int err, i;
>  
> +	/* Scan for a matching profile */
> +	i = sysfs_match_string(profile_names, buf);
> +	if (i < 0)
> +		return -EINVAL;
> +
>  	err = mutex_lock_interruptible(&profile_lock);
>  	if (err)
>  		return err;
> @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev,
>  		return -ENODEV;
>  	}
>  
> -	/* Scan for a matching profile */
> -	i = sysfs_match_string(profile_names, buf);
> -	if (i < 0) {
> -		mutex_unlock(&profile_lock);
> -		return -EINVAL;
> -	}
> -
>  	/* Check that platform supports this profile choice */
>  	if (!test_bit(i, cur_profile->choices)) {
>  		mutex_unlock(&profile_lock);
> 

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>


-- 
 i.