2015-04-11 13:18:55

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH 1/3] drm/msm: match wait_for_completion_timeout return type

return type of wait_for_completion_timeout is unsigned long not int, this
patch assigns the return value of wait_for_completion_timeout to an
appropriately typed and named variable.

Signed-off-by: Nicholas Mc Guire <[email protected]>
---

This was compile tested with qcom_defconfig +
CONFIG_DRM=m (implies CONFIG_DRM_MSM=m)

Patch is against 4.0-rc7 (localversion-next is -next-20150410)

drivers/gpu/drm/msm/edp/edp_ctrl.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c b/drivers/gpu/drm/msm/edp/edp_ctrl.c
index 0ec5abd..831acd6 100644
--- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
+++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
@@ -1018,7 +1018,7 @@ static void edp_ctrl_off_worker(struct work_struct *work)
{
struct edp_ctrl *ctrl = container_of(
work, struct edp_ctrl, off_work);
- int ret;
+ unsigned long time_left;

mutex_lock(&ctrl->dev_mutex);

@@ -1030,11 +1030,11 @@ static void edp_ctrl_off_worker(struct work_struct *work)
reinit_completion(&ctrl->idle_comp);
edp_state_ctrl(ctrl, EDP_STATE_CTRL_PUSH_IDLE);

- ret = wait_for_completion_timeout(&ctrl->idle_comp,
+ time_left = wait_for_completion_timeout(&ctrl->idle_comp,
msecs_to_jiffies(500));
- if (ret <= 0)
- DBG("%s: idle pattern timedout, %d\n",
- __func__, ret);
+ if (time_left <= 0)
+ DBG("%s: idle pattern timedout, %lu\n",
+ __func__, time_left);

edp_state_ctrl(ctrl, 0);

--
1.7.10.4


2015-04-11 13:18:54

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH 2/3] drm/msm: wait_for_completion_timeout return is never negative

wait_for_completion_timeout returns >= 0 but never
negative - so the error check should be against equality
to 0 not <= 0.

Signed-off-by: Nicholas Mc Guire <[email protected]>
---

This was compile tested with qcom_defconfig +
CONFIG_DRM=m (implies CONFIG_DRM_MSM=m)

Patch is against 4.0-rc7 (localversion-next is -next-20150410)

drivers/gpu/drm/msm/edp/edp_ctrl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c b/drivers/gpu/drm/msm/edp/edp_ctrl.c
index 831acd6..9ef361c 100644
--- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
+++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
@@ -1032,7 +1032,7 @@ static void edp_ctrl_off_worker(struct work_struct *work)

time_left = wait_for_completion_timeout(&ctrl->idle_comp,
msecs_to_jiffies(500));
- if (time_left <= 0)
+ if (!time_left)
DBG("%s: idle pattern timedout, %lu\n",
__func__, time_left);

--
1.7.10.4

2015-04-11 13:18:56

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH 3/3] drm/msm: drop redundant debug output

wait_for_completion_timeout returns 0 in case of timeout and never
return < 0 so there is no additional information in printing the
value of time_left here as it will always be 0, thus it can be dropped.

Signed-off-by: Nicholas Mc Guire <[email protected]>
---

This was compile tested with qcom_defconfig +
CONFIG_DRM=m (implies CONFIG_DRM_MSM=m)

Patch is against 4.0-rc7 (localversion-next is -next-20150410)

drivers/gpu/drm/msm/edp/edp_ctrl.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c b/drivers/gpu/drm/msm/edp/edp_ctrl.c
index 9ef361c..3739e80 100644
--- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
+++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
@@ -1033,8 +1033,7 @@ static void edp_ctrl_off_worker(struct work_struct *work)
time_left = wait_for_completion_timeout(&ctrl->idle_comp,
msecs_to_jiffies(500));
if (!time_left)
- DBG("%s: idle pattern timedout, %lu\n",
- __func__, time_left);
+ DBG("%s: idle pattern timedout\n", __func__);

edp_state_ctrl(ctrl, 0);

--
1.7.10.4

2015-04-13 13:58:31

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 1/3] drm/msm: match wait_for_completion_timeout return type

On Sat, Apr 11, 2015 at 03:10:36PM +0200, Nicholas Mc Guire wrote:
> return type of wait_for_completion_timeout is unsigned long not int, this
> patch assigns the return value of wait_for_completion_timeout to an
> appropriately typed and named variable.
>
> Signed-off-by: Nicholas Mc Guire <[email protected]>
> ---
>
> This was compile tested with qcom_defconfig +
> CONFIG_DRM=m (implies CONFIG_DRM_MSM=m)
>
> Patch is against 4.0-rc7 (localversion-next is -next-20150410)
>
> drivers/gpu/drm/msm/edp/edp_ctrl.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c b/drivers/gpu/drm/msm/edp/edp_ctrl.c
> index 0ec5abd..831acd6 100644
> --- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
> +++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
> @@ -1018,7 +1018,7 @@ static void edp_ctrl_off_worker(struct work_struct *work)
> {
> struct edp_ctrl *ctrl = container_of(
> work, struct edp_ctrl, off_work);
> - int ret;
> + unsigned long time_left;
>
> mutex_lock(&ctrl->dev_mutex);
>
> @@ -1030,11 +1030,11 @@ static void edp_ctrl_off_worker(struct work_struct *work)
> reinit_completion(&ctrl->idle_comp);
> edp_state_ctrl(ctrl, EDP_STATE_CTRL_PUSH_IDLE);
>
> - ret = wait_for_completion_timeout(&ctrl->idle_comp,
> + time_left = wait_for_completion_timeout(&ctrl->idle_comp,
> msecs_to_jiffies(500));
> - if (ret <= 0)
> - DBG("%s: idle pattern timedout, %d\n",
> - __func__, ret);
> + if (time_left <= 0)

Given that time_left is unsigned now, why bother with the "< 0"?

Thierry


Attachments:
(No filename) (1.53 kB)
(No filename) (819.00 B)
Download all attachments

2015-04-16 07:17:46

by Nicholas Mc Guire

[permalink] [raw]
Subject: Re: [PATCH 1/3] drm/msm: match wait_for_completion_timeout return type

On Mon, 13 Apr 2015, Thierry Reding wrote:

> On Sat, Apr 11, 2015 at 03:10:36PM +0200, Nicholas Mc Guire wrote:
> > return type of wait_for_completion_timeout is unsigned long not int, this
> > patch assigns the return value of wait_for_completion_timeout to an
> > appropriately typed and named variable.
> >
> > Signed-off-by: Nicholas Mc Guire <[email protected]>
> > ---
> >
> > This was compile tested with qcom_defconfig +
> > CONFIG_DRM=m (implies CONFIG_DRM_MSM=m)
> >
> > Patch is against 4.0-rc7 (localversion-next is -next-20150410)
> >
> > drivers/gpu/drm/msm/edp/edp_ctrl.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c b/drivers/gpu/drm/msm/edp/edp_ctrl.c
> > index 0ec5abd..831acd6 100644
> > --- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
> > +++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
> > @@ -1018,7 +1018,7 @@ static void edp_ctrl_off_worker(struct work_struct *work)
> > {
> > struct edp_ctrl *ctrl = container_of(
> > work, struct edp_ctrl, off_work);
> > - int ret;
> > + unsigned long time_left;
> >
> > mutex_lock(&ctrl->dev_mutex);
> >
> > @@ -1030,11 +1030,11 @@ static void edp_ctrl_off_worker(struct work_struct *work)
> > reinit_completion(&ctrl->idle_comp);
> > edp_state_ctrl(ctrl, EDP_STATE_CTRL_PUSH_IDLE);
> >
> > - ret = wait_for_completion_timeout(&ctrl->idle_comp,
> > + time_left = wait_for_completion_timeout(&ctrl->idle_comp,
> > msecs_to_jiffies(500));
> > - if (ret <= 0)
> > - DBG("%s: idle pattern timedout, %d\n",
> > - __func__, ret);
> > + if (time_left <= 0)
>
> Given that time_left is unsigned now, why bother with the "< 0"?
>
Thats in the second patch - I was ask not do do more than one thing in one
patch - so 1/3 fixed the type/name, 2/3 the return check and 3/3 the DBG.

thx!
hofrat