From: Andrew Morton <akpm@linux-foundation.org>
To: "Kim, Milo" <Milo.Kim@ti.com>
Cc: Thierry Reding <thierry.reding@avionic-design.de>,
Richard Purdie <rpurdie@rpsys.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] lp855x_bl: use generic PWM functions
Date: Mon, 22 Oct 2012 15:30:12 -0700 [thread overview]
Message-ID: <20121022153012.253a6954.akpm@linux-foundation.org> (raw)
In-Reply-To: <A874F61F95741C4A9BA573A70FE3998F641791BB@DQHE02.ent.ti.com>
On Fri, 19 Oct 2012 08:45:14 +0000
"Kim, Milo" <Milo.Kim@ti.com> wrote:
> > Generally this looks good. Obviously you'll need to update any users of
> > this driver as well. It might make sense to include those changes in
> > this patch to avoid interim build failures.
>
> Thanks for your review.
> So far no usages for this driver in the mainline.
> I've tested it in my own development environment instead.
>
> > Other than that I have just one smaller comment below.
> >
> > > + pwm_config(lp->pwm, duty, period);
> > > + duty == 0 ? pwm_disable(lp->pwm) : pwm_enable(lp->pwm);
> >
> > This is really ugly and should be written explicitly:
> >
> > if (duty == 0)
> > pwm_disable(lp->pwm);
> > else
> > pwm_enable(lp->pwm);
>
> Oh, I prefer using '?' to if-sentence because it looks clear to me.
> But if it's difficult to read/understand, I'll fix it.
> I'd like to have others' opinion.
>
Hey, it's better than
(*(duty ? pwm_enable : pwm_disable))(lp->pwm);
!
But yes, the original code is unusual and I think most kernel people
would have to stare at it for a bit longer than necessary to see
exactly what it's doing.
--- a/drivers/video/backlight/lp855x_bl.c~drivers-video-backlight-lp855x_blc-use-generic-pwm-functions-fix
+++ a/drivers/video/backlight/lp855x_bl.c
@@ -139,7 +139,10 @@ static void lp855x_pwm_ctrl(struct lp855
}
pwm_config(lp->pwm, duty, period);
- duty == 0 ? pwm_disable(lp->pwm) : pwm_enable(lp->pwm);
+ if (duty)
+ pwm_enable(lp->pwm);
+ else
+ pwm_disable(lp->pwm);
}
static int lp855x_bl_update_status(struct backlight_device *bl)
next prev parent reply other threads:[~2012-10-22 22:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-19 8:11 Kim, Milo
2012-10-19 8:21 ` Thierry Reding
2012-10-19 8:45 ` Kim, Milo
2012-10-22 22:30 ` Andrew Morton [this message]
2012-10-24 6:01 ` Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121022153012.253a6954.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=Milo.Kim@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rpurdie@rpsys.net \
--cc=thierry.reding@avionic-design.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome