From: Joe Perches <joe@perches.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Sujith Thomas <sujith.thomas@intel.com>,
Darren Hart <dvhart@infradead.org>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] intel_menlow: reduce code duplication
Date: Sat, 26 Mar 2016 16:53:03 -0700 [thread overview]
Message-ID: <1459036383.23450.12.camel@perches.com> (raw)
In-Reply-To: <1459028427-4053-1-git-send-email-linux@rasmusvillemoes.dk>
On Sat, 2016-03-26 at 22:40 +0100, Rasmus Villemoes wrote:
> aux0_show and aux1_show consists of almost identical code. Pull that
> into a common helper and make them thin wrappers. Similarly for
> _store.
Seems sensible, thanks
> diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
[]
> @@ -306,33 +306,32 @@ static int sensor_set_auxtrip(acpi_handle handle, int index, int value)
> #define to_intel_menlow_attr(_attr) \
> container_of(_attr, struct intel_menlow_attribute, attr)
>
> -static ssize_t aux0_show(struct device *dev,
> - struct device_attribute *dev_attr, char *buf)
> +static ssize_t aux_show(struct device *dev, struct device_attribute *dev_attr,
> + char *buf, int idx)
> {
> struct intel_menlow_attribute *attr = to_intel_menlow_attr(dev_attr);
> unsigned long long value;
> int result;
>
> - result = sensor_get_auxtrip(attr->handle, 0, &value);
> + result = sensor_get_auxtrip(attr->handle, idx, &value);
>
> return result ? result : sprintf(buf, "%lu", DECI_KELVIN_TO_CELSIUS(value));
While not something you've done differently than the
existing code, perhaps this would be more common
without the ternary operator like:
result = sensor_get_auxtrip(attr->handle, idx, &value);
if (result < 0)
return result;
return sprintf(buf, "%lu", DECI_KELVIN_TO_CELSIUS(value));
next prev parent reply other threads:[~2016-03-26 23:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-26 21:40 Rasmus Villemoes
2016-03-26 23:53 ` Joe Perches [this message]
2016-05-23 21:36 ` Darren Hart
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=1459036383.23450.12.camel@perches.com \
--to=joe@perches.com \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=platform-driver-x86@vger.kernel.org \
--cc=sujith.thomas@intel.com \
/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®