public inbox for dri-devel@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm radeon: Return -EINVAL on wrong pm sysfs access
@ 2011-03-23 15:14 Thomas Renninger
  2011-03-23 16:49 ` Alex Deucher
  2011-03-26 15:38 ` Rafał Miłecki
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Renninger @ 2011-03-23 15:14 UTC (permalink / raw)
  To: dri-devel; +Cc: Alexander.Deucher

drm radeon: Return -EINVAL on wrong pm sysfs access

Throw an error if someone tries to fill this with
wrong data, instead of simply ignoring the input.
Now you get:

echo hello >/sys/../power_method
-bash: echo: write error: Invalid argument

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: Alexander.Deucher@amd.com
CC: dri-devel@lists.freedesktop.org

---
 drivers/gpu/drm/radeon/radeon_pm.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 2aed03b..08de669 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -365,12 +365,14 @@ static ssize_t radeon_set_pm_profile(struct device *dev,
 		else if (strncmp("high", buf, strlen("high")) == 0)
 			rdev->pm.profile = PM_PROFILE_HIGH;
 		else {
-			DRM_ERROR("invalid power profile!\n");
+			count = -EINVAL;
 			goto fail;
 		}
 		radeon_pm_update_profile(rdev);
 		radeon_pm_set_clocks(rdev);
-	}
+	} else
+		count = -EINVAL;
+
 fail:
 	mutex_unlock(&rdev->pm.mutex);
 
@@ -413,7 +415,7 @@ static ssize_t radeon_set_pm_method(struct device *dev,
 		mutex_unlock(&rdev->pm.mutex);
 		cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work);
 	} else {
-		DRM_ERROR("invalid power method!\n");
+		count = -EINVAL;
 		goto fail;
 	}
 	radeon_pm_compute_clocks(rdev);

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

* Re: [PATCH] drm radeon: Return -EINVAL on wrong pm sysfs access
  2011-03-23 15:14 [PATCH] drm radeon: Return -EINVAL on wrong pm sysfs access Thomas Renninger
@ 2011-03-23 16:49 ` Alex Deucher
  2011-03-26 15:38 ` Rafał Miłecki
  1 sibling, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2011-03-23 16:49 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: Alexander.Deucher, dri-devel

On Wed, Mar 23, 2011 at 11:14 AM, Thomas Renninger <trenn@suse.de> wrote:
> drm radeon: Return -EINVAL on wrong pm sysfs access
>
> Throw an error if someone tries to fill this with
> wrong data, instead of simply ignoring the input.
> Now you get:
>
> echo hello >/sys/../power_method
> -bash: echo: write error: Invalid argument
>
> Signed-off-by: Thomas Renninger <trenn@suse.de>
> CC: Alexander.Deucher@amd.com
> CC: dri-devel@lists.freedesktop.org

Looks good to me.

Reviewed-by: Alex Deucher <alexdeucher@gmail.com>

>
> ---
>  drivers/gpu/drm/radeon/radeon_pm.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
> index 2aed03b..08de669 100644
> --- a/drivers/gpu/drm/radeon/radeon_pm.c
> +++ b/drivers/gpu/drm/radeon/radeon_pm.c
> @@ -365,12 +365,14 @@ static ssize_t radeon_set_pm_profile(struct device *dev,
>                else if (strncmp("high", buf, strlen("high")) == 0)
>                        rdev->pm.profile = PM_PROFILE_HIGH;
>                else {
> -                       DRM_ERROR("invalid power profile!\n");
> +                       count = -EINVAL;
>                        goto fail;
>                }
>                radeon_pm_update_profile(rdev);
>                radeon_pm_set_clocks(rdev);
> -       }
> +       } else
> +               count = -EINVAL;
> +
>  fail:
>        mutex_unlock(&rdev->pm.mutex);
>
> @@ -413,7 +415,7 @@ static ssize_t radeon_set_pm_method(struct device *dev,
>                mutex_unlock(&rdev->pm.mutex);
>                cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work);
>        } else {
> -               DRM_ERROR("invalid power method!\n");
> +               count = -EINVAL;
>                goto fail;
>        }
>        radeon_pm_compute_clocks(rdev);
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>

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

* Re: [PATCH] drm radeon: Return -EINVAL on wrong pm sysfs access
  2011-03-23 15:14 [PATCH] drm radeon: Return -EINVAL on wrong pm sysfs access Thomas Renninger
  2011-03-23 16:49 ` Alex Deucher
@ 2011-03-26 15:38 ` Rafał Miłecki
  2011-03-26 15:39   ` Rafał Miłecki
  2011-03-27  9:46   ` Thomas Renninger
  1 sibling, 2 replies; 5+ messages in thread
From: Rafał Miłecki @ 2011-03-26 15:38 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: Alexander.Deucher, dri-devel

2011/3/23 Thomas Renninger <trenn@suse.de>:
> drm radeon: Return -EINVAL on wrong pm sysfs access
>
> Throw an error if someone tries to fill this with
> wrong data, instead of simply ignoring the input.
> Now you get:
>
> echo hello >/sys/../power_method
> -bash: echo: write error: Invalid argument
>
> Signed-off-by: Thomas Renninger <trenn@suse.de>
> CC: Alexander.Deucher@amd.com
> CC: dri-devel@lists.freedesktop.org
>
> ---
>  drivers/gpu/drm/radeon/radeon_pm.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
> index 2aed03b..08de669 100644
> --- a/drivers/gpu/drm/radeon/radeon_pm.c
> +++ b/drivers/gpu/drm/radeon/radeon_pm.c
> @@ -365,12 +365,14 @@ static ssize_t radeon_set_pm_profile(struct device *dev,
>                else if (strncmp("high", buf, strlen("high")) == 0)
>                        rdev->pm.profile = PM_PROFILE_HIGH;
>                else {
> -                       DRM_ERROR("invalid power profile!\n");
> +                       count = -EINVAL;

I think this does not match kernel coding style (braces).

-- 
Rafał
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm radeon: Return -EINVAL on wrong pm sysfs access
  2011-03-26 15:38 ` Rafał Miłecki
@ 2011-03-26 15:39   ` Rafał Miłecki
  2011-03-27  9:46   ` Thomas Renninger
  1 sibling, 0 replies; 5+ messages in thread
From: Rafał Miłecki @ 2011-03-26 15:39 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: Alexander.Deucher, dri-devel

W dniu 26 marca 2011 16:38 użytkownik Rafał Miłecki <zajec5@gmail.com> napisał:
> 2011/3/23 Thomas Renninger <trenn@suse.de>:
>> drm radeon: Return -EINVAL on wrong pm sysfs access
>>
>> Throw an error if someone tries to fill this with
>> wrong data, instead of simply ignoring the input.
>> Now you get:
>>
>> echo hello >/sys/../power_method
>> -bash: echo: write error: Invalid argument
>>
>> Signed-off-by: Thomas Renninger <trenn@suse.de>
>> CC: Alexander.Deucher@amd.com
>> CC: dri-devel@lists.freedesktop.org
>>
>> ---
>>  drivers/gpu/drm/radeon/radeon_pm.c |    8 +++++---
>>  1 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
>> index 2aed03b..08de669 100644
>> --- a/drivers/gpu/drm/radeon/radeon_pm.c
>> +++ b/drivers/gpu/drm/radeon/radeon_pm.c
>> @@ -365,12 +365,14 @@ static ssize_t radeon_set_pm_profile(struct device *dev,
>>                else if (strncmp("high", buf, strlen("high")) == 0)
>>                        rdev->pm.profile = PM_PROFILE_HIGH;
>>                else {
>> -                       DRM_ERROR("invalid power profile!\n");
>> +                       count = -EINVAL;
>
> I think this does not match kernel coding style (braces).

This is not 100% your fault of course, someone put this not proper
style here earlier. Maybe just worth fixing by the way.

-- 
Rafał
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm radeon: Return -EINVAL on wrong pm sysfs access
  2011-03-26 15:38 ` Rafał Miłecki
  2011-03-26 15:39   ` Rafał Miłecki
@ 2011-03-27  9:46   ` Thomas Renninger
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Renninger @ 2011-03-27  9:46 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: Alexander.Deucher, dri-devel

On Saturday 26 March 2011 16:38:22 Rafał Miłecki wrote:
> 2011/3/23 Thomas Renninger <trenn@suse.de>:
> > drm radeon: Return -EINVAL on wrong pm sysfs access
> >
> > Throw an error if someone tries to fill this with
> > wrong data, instead of simply ignoring the input.
> > Now you get:
> >
> > echo hello >/sys/../power_method
> > -bash: echo: write error: Invalid argument
> >
> > Signed-off-by: Thomas Renninger <trenn@suse.de>
> > CC: Alexander.Deucher@amd.com
> > CC: dri-devel@lists.freedesktop.org
> >
> > ---
> >  drivers/gpu/drm/radeon/radeon_pm.c |    8 +++++---
> >  1 files changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
> > index 2aed03b..08de669 100644
> > --- a/drivers/gpu/drm/radeon/radeon_pm.c
> > +++ b/drivers/gpu/drm/radeon/radeon_pm.c
> > @@ -365,12 +365,14 @@ static ssize_t radeon_set_pm_profile(struct device *dev,
> >                else if (strncmp("high", buf, strlen("high")) == 0)
> >                        rdev->pm.profile = PM_PROFILE_HIGH;
> >                else {
> > -                       DRM_ERROR("invalid power profile!\n");
> > +                       count = -EINVAL;
> 
> I think this does not match kernel coding style (braces).
Can you be more specific, please.
I can't see style issues, ./scripts/checkpatch.pl is also happy.

        Thomas
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2011-03-27  9:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-23 15:14 [PATCH] drm radeon: Return -EINVAL on wrong pm sysfs access Thomas Renninger
2011-03-23 16:49 ` Alex Deucher
2011-03-26 15:38 ` Rafał Miłecki
2011-03-26 15:39   ` Rafał Miłecki
2011-03-27  9:46   ` Thomas Renninger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox