From: Thierry Reding <thierry.reding@avionic-design.de>
To: Florian Vaussard <florian.vaussard@epfl.ch>
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>,
Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>,
linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] pwm: Add pwm_cansleep() as exported API to users
Date: Mon, 28 Jan 2013 14:16:23 +0100 [thread overview]
Message-ID: <20130128131622.GA1783@avionic-0098.mockup.avionic-design.de> (raw)
In-Reply-To: <510659A3.7070906@epfl.ch>
[-- Attachment #1: Type: text/plain, Size: 1571 bytes --]
On Mon, Jan 28, 2013 at 11:57:39AM +0100, Florian Vaussard wrote:
> Le 28/01/2013 10:57, Thierry Reding a écrit :
> >On Mon, Jan 28, 2013 at 10:36:07AM +0100, Florian Vaussard wrote:
> >>Hello,
> >>
> >>Le 28/01/2013 09:45, Peter Ujfalusi a écrit :
> >>>hi Thierry,
> >>>
> >>>On 01/26/2013 06:40 AM, Thierry Reding wrote:
> >[...]
> >>>>>+{
> >>>>>+ return pwm->chip->can_sleep;
> >>>>>+}
> >>>>>+EXPORT_SYMBOL_GPL(pwm_cansleep);
> >>>>
> >>>>Would it make sense to check for NULL pointers here? I guess that
> >>>>passing NULL into the function could be considered a programming error
> >>>>and an oops would be okay, but in that case there's no point in making
> >>>>the function return an int. Also see my next comment.
> >>>
> >>>While it is unlikely to happen it is better to be safe, something like this
> >>>will do:
> >>>
> >>>return pwm ? pwm->chip->can_sleep : 0;
> >>>
> >>
> >>Ok. And what about:
> >>
> >>BUG_ON(pwm == NULL);
> >>return pwm->chip->can_sleep;
> >
> >I don't think we need that. In case pwm == NULL, dereferencing it will
> >oops anyway. So either we make it safe and return an error code, or we
> >let it oops without explicit BUG_ON().
> >
>
> Calling this function with a NULL pointer is a programming error, so there
> is no error codes for such errors.
You could return -EINVAL if pwm == NULL.
> I propose to return bool, and let it oops if such case happens.
My point was that it will oops even if you don't use BUG_ON() so there
isn't so much point in using it explicitly.
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-01-28 13:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 13:44 [PATCH v2 0/3] leds-pwm: Defer PWM calls if PWM can sleep Florian Vaussard
2013-01-25 13:44 ` [PATCH v2 1/3] pwm: Add pwm_cansleep() as exported API to users Florian Vaussard
2013-01-25 13:51 ` Peter Ujfalusi
2013-01-26 5:40 ` Thierry Reding
2013-01-28 8:45 ` Peter Ujfalusi
2013-01-28 9:36 ` Florian Vaussard
2013-01-28 9:57 ` Thierry Reding
2013-01-28 10:57 ` Florian Vaussard
2013-01-28 13:16 ` Thierry Reding [this message]
2013-01-28 15:01 ` Russell King - ARM Linux
2013-01-28 15:46 ` Florian Vaussard
2013-01-25 13:44 ` [PATCH v2 2/3] pwm: Add can_sleep property to drivers Florian Vaussard
2013-01-25 13:51 ` Peter Ujfalusi
2013-01-25 13:44 ` [PATCH v2 3/3] leds: leds-pwm: Defer led_pwm_set() if PWM can sleep Florian Vaussard
2013-01-25 13:52 ` Peter Ujfalusi
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=20130128131622.GA1783@avionic-0098.mockup.avionic-design.de \
--to=thierry.reding@avionic-design.de \
--cc=cooloney@gmail.com \
--cc=florian.vaussard@epfl.ch \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=peter.ujfalusi@ti.com \
--cc=rpurdie@rpsys.net \
/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