From: Johannes Berg <johannes@sipsolutions.net>
To: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Cc: Alan Jenkins <alan-jenkins@tuffmail.co.uk>,
platform-driver-x86@vger.kernel.org, mjg@redhat.com,
don@syst.com.br, rpurdie@rpsys.net
Subject: Re: [PATCH] classmate-laptop: Add RFKILL support.
Date: Wed, 09 Jun 2010 20:32:59 +0200 [thread overview]
Message-ID: <1276108379.14580.23.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <20100609181958.GA2551@barata.holoscopio.com>
On Wed, 2010-06-09 at 15:19 -0300, Thadeu Lima de Souza Cascardo wrote:
> > >+ ipml->rf = rfkill_alloc("cmpc_rfkill", &acpi->dev, RFKILL_TYPE_WLAN,
> > >+ &cmpc_rfkill_ops, acpi->handle);
> > >+ /* rfkill_alloc may fail if RFKILL is disabled. We should still work
> > >+ * anyway. */
> > >+ if (!IS_ERR(ipml->rf)) {
> > >+ retval = rfkill_register(ipml->rf);
> > >+ if (retval) {
> > >+ rfkill_destroy(ipml->rf);
> > >+ ipml->rf = NULL;
> > >+ }
> > >+ } else {
> > >+ ipml->rf = NULL;
> > >+ }
> >
> > I think the comment is wrong, and so is the code it references.
> >
> > rfkill_alloc() is documented as returning NULL on failure, not an
> ERR_PTR. So you're going to pass NULL into rfkill_register() on
> allocation failure, which will BUG out.
> >
>
> Gee! At the time, I only read the RFKILL=n implementation in the
> header.
> It returns ERR_PTR(-ENODEV), while the RFKILL=y implementation does
> indeed return NULL. This is inconsistent interface, and we'd better
> fix it, in my opinion. But for the time, we must fix the users here.
No, it's perfectly consistent. RFKILL=n returns non-NULL on success,
just as RFKILL=y/m. It's just defined to be always successful for
RFKILL=n, with the special case that it's returning an ERR_PTR for its
own checking in rfkill_register.
All the drivers should do is test for NULL, and if non-NULL proceed as
normal.
> I see why eeepc_laptop would still work right now. But I think it's
> risky for the casual driver writer to trust the rfkill device is there
> while it isn't. If this is by design, to bite those driver writers
> that
> do "stupid" things (like not using the right interface) and that they
> should still manipulate hardware as if the rfkill device was there,
> that's OK. But is this really by design or should we fix it? For
> example, eeepc_laptop does all the wlan pci device hotplug stuff and
> also write some ACPI values. And it will do that if RFKILL is disabled
> but will not do it if RFKILL is enabled but device allocation fails.
> So,
> should we document that ERR_PTR(-ENODEV) is not a failure, but a
> "dummy"?
That's the intended outcome, yes, so that drivers need NOT worry about
whether RFKILL is built into the system or not at all.
johannes
next prev parent reply other threads:[~2010-06-09 18:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-27 16:15 [PATCH] classmate-laptop: Add RFKILL support Thadeu Lima de Souza Cascardo
2010-04-27 16:22 ` Matthew Garrett
2010-04-27 16:32 ` Thadeu Lima de Souza Cascardo
2010-05-07 18:18 ` Matthew Garrett
2010-06-09 10:28 ` Alan Jenkins
2010-06-09 18:19 ` Thadeu Lima de Souza Cascardo
2010-06-09 18:32 ` Johannes Berg [this message]
2010-06-09 18:58 ` Thadeu Lima de Souza Cascardo
2010-06-09 19:39 ` [PATCH] classmate-laptop: should check for NULL as retval for rfkill_alloc Thadeu Lima de Souza Cascardo
2010-06-09 19:46 ` Johannes Berg
2010-06-09 19:48 ` Thadeu Lima de Souza Cascardo
2010-06-09 19:49 ` Thadeu Lima de Souza Cascardo
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=1276108379.14580.23.camel@jlt3.sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=alan-jenkins@tuffmail.co.uk \
--cc=cascardo@holoscopio.com \
--cc=don@syst.com.br \
--cc=mjg@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
--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