From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Cc: platform-driver-x86@vger.kernel.org, mjg@redhat.com,
don@syst.com.br, johannes@sipsolutions.net, rpurdie@rpsys.net
Subject: Re: [PATCH] classmate-laptop: Add RFKILL support.
Date: Wed, 09 Jun 2010 11:28:47 +0100 [thread overview]
Message-ID: <4C0F6CDF.9060608@tuffmail.co.uk> (raw)
In-Reply-To: <1272384900-3982-1-git-send-email-cascardo@holoscopio.com>
Thadeu Lima de Souza Cascardo wrote:
> The RFKILL device shares the same ACPI device used for backlight. So, it
> required a new struct sharing both a backlight_device and a rfkill
> device.
>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> ---
Apologies for tardiness. You did ask for review, so I've scanned it for some common rfkill pitfalls.
> drivers/platform/x86/classmate-laptop.c | 170 +++++++++++++++++++++++++++----
> 1 files changed, 148 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
> index 7f9e5dd..3bf399f 100644
> --- a/drivers/platform/x86/classmate-laptop.c
> +++ b/drivers/platform/x86/classmate-laptop.c
> +static const struct rfkill_ops cmpc_rfkill_ops = {
> + .query = cmpc_rfkill_query,
> + .set_block = cmpc_rfkill_block,
> +};
You said down-thread that firmware does not change the state. In that case, I believe the query method is unnecessary
* @query: query the rfkill block state(s) and call exactly one of the
* rfkill_set{,_hw,_sw}_state family of functions. Assign this
* method if input events can cause hardware state changes to make
* the rfkill core query your driver before setting a requested
* block.
Generally, the rfkill core caches the soft blocked state. It doesn't call query() during registration either - it calls set_block() with a default value (usually "unblocked"). query() is only used to minimize a race with the firmware during set_block().
> + 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.
eeepc_laptop tests for NULL here, not ERR_PTR.
If you look at the implementation when RFKILL is disabled, rfkill_register() is designed to accept ERR_PTR(-ENODEV) without complaint. (And the other rfkill functions won't care either; they'll just be completely empty stubs).
Regards
Alan
next prev parent reply other threads:[~2010-06-09 10:29 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 [this message]
2010-06-09 18:19 ` Thadeu Lima de Souza Cascardo
2010-06-09 18:32 ` Johannes Berg
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=4C0F6CDF.9060608@tuffmail.co.uk \
--to=alan-jenkins@tuffmail.co.uk \
--cc=cascardo@holoscopio.com \
--cc=don@syst.com.br \
--cc=johannes@sipsolutions.net \
--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