From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Henrik Rydberg <rydberg@euromail.se>
Cc: Jean Delvare <khali@linux-fr.org>,
"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 04/11] hwmon: applesmc: Introduce a register lookup table (rev2)
Date: Tue, 9 Nov 2010 11:04:29 -0800 [thread overview]
Message-ID: <1289329469.22931.221.camel@groeck-laptop> (raw)
In-Reply-To: <1289315711-3011-5-git-send-email-rydberg@euromail.se>
On Tue, 2010-11-09 at 10:15 -0500, Henrik Rydberg wrote:
> One main problem with the current driver is the inability to quickly
> search for supported keys, resulting in detailed feature maps per
> machine model which are cumbersome to maintain.
>
> This patch adds a register lookup table, which enables binary search
> for supported keys. The lookup also reduces the io frequency, so the
> original mutex is replaced by locks around the actual io.
>
> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Hi Henrik,
looks pretty good now. Couple of additional comments.
> ---
> drivers/hwmon/applesmc.c | 528 +++++++++++++++++++++++++---------------------
> 1 files changed, 286 insertions(+), 242 deletions(-)
>
> diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
> index 5f67e39..623f71c 100644
> --- a/drivers/hwmon/applesmc.c
> +++ b/drivers/hwmon/applesmc.c
[ ... ]
> +/*
> + * applesmc_init_smcreg_try - Try to initialize register cache. Idempotent.
> + */
> +static int applesmc_init_smcreg_try(void)
> +{
> + struct applesmc_registers *s = &smcreg;
> + int ret;
> +
> + if (s->init_complete)
> + return 0;
> +
> + mutex_init(&s->mutex);
> +
I am a bit concerned that mutex_init() can be called multiple times. Are
you sure this is safe ?
> + ret = read_register_count(&s->key_count);
> + if (ret)
> + return ret;
> +
> + if (!s->cache)
> + s->cache = kcalloc(s->key_count, sizeof(*s->cache), GFP_KERNEL);
> + if (!s->cache)
> + return -ENOMEM;
> +
> + s->init_complete = true;
> +
> + pr_info("key=%d\n", s->key_count);
> +
Hope that means more to macbook users than it does to me ;).
> + return 0;
> +}
> +
> +/*
> + * applesmc_init_smcreg - Initialize register cache.
> + *
> + * Retries until initialization is successful, or the operation times out.
> + *
> + */
> +static int applesmc_init_smcreg(void)
> +{
> + int ms, ret;
> +
> + for (ms = 0; ms < INIT_TIMEOUT_MSECS; ms += INIT_WAIT_MSECS) {
> + ret = applesmc_init_smcreg_try();
> + if (!ret)
> + return 0;
> + pr_warn("slow init, retrying\n");
INIT_WAIT_MS is 50ms, so you issue this warning every 50ms for up to
five seconds. Pretty noisy... sure that is what you want ? Also, does it
really make sense to retry if the error is ENOMEM ?
Thanks,
Guenter
next prev parent reply other threads:[~2010-11-09 19:05 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-09 15:15 [PATCH 00/11] hwmon: applesmc: Dynamic configuration rewrite (rev2) Henrik Rydberg
2010-11-09 15:15 ` [PATCH 01/11] hwmon: applesmc: Add MacBookAir3,1(3,2) support Henrik Rydberg
2010-11-09 18:56 ` Guenter Roeck
2010-11-09 15:15 ` [PATCH 02/11] hwmon: applesmc: Relax the severity of device init failure (rev2) Henrik Rydberg
2010-11-09 18:57 ` Guenter Roeck
2010-11-09 15:15 ` [PATCH 03/11] drivers/hwmon/applesmc.c: Use pr_fmt and pr_<level> Henrik Rydberg
2010-11-09 18:57 ` Guenter Roeck
2010-11-09 15:15 ` [PATCH 04/11] hwmon: applesmc: Introduce a register lookup table (rev2) Henrik Rydberg
2010-11-09 19:04 ` Guenter Roeck [this message]
2010-11-09 19:32 ` Henrik Rydberg
2010-11-09 20:53 ` Guenter Roeck
2010-11-10 10:57 ` Henrik Rydberg
2010-11-10 15:42 ` Guenter Roeck
2010-11-10 17:14 ` Henrik Rydberg
2010-11-10 17:57 ` Guenter Roeck
2010-11-09 22:15 ` Guenter Roeck
2010-11-09 15:15 ` [PATCH 05/11] hwmon: applesmc: Dynamic creation of temperature files (rev2) Henrik Rydberg
2010-11-09 15:15 ` [PATCH 06/11] hwmon: applesmc: Handle new temperature format (rev2) Henrik Rydberg
2010-11-10 18:07 ` Guenter Roeck
2010-11-09 15:15 ` [PATCH 07/11] hwmon: applesmc: Extract all features generically (rev2) Henrik Rydberg
2010-11-09 15:15 ` [PATCH 08/11] hwmon: applesmc: Dynamic creation of fan files (rev2) Henrik Rydberg
2010-11-10 18:09 ` Guenter Roeck
2010-11-09 15:15 ` [PATCH 09/11] hwmon: applesmc: Simplify feature sysfs handling (rev2) Henrik Rydberg
2010-11-10 18:10 ` Guenter Roeck
2010-11-09 15:15 ` [PATCH 10/11] hwmon: applesmc: Silence driver Henrik Rydberg
2010-11-10 18:10 ` Guenter Roeck
2010-11-09 15:15 ` [PATCH 11/11] hwmon: applesmc: Update copyright information Henrik Rydberg
2010-11-10 18:10 ` Guenter Roeck
2010-11-10 18:22 ` Henrik Rydberg
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=1289329469.22931.221.camel@groeck-laptop \
--to=guenter.roeck@ericsson.com \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=rydberg@euromail.se \
/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
all inboxes | Powered by JetHome®