From: Aniroop Mathur <aniroop.mathur@gmail.com>
To: Jason Gerecke <killertofu@gmail.com>,
Ping Cheng <pingc@wacom.com>, Jiri Kosina <jkosina@suse.cz>
Cc: "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
linux-kernel@vger.kernel.org, a.mathur@samsung.com
Subject: Re: [PATCH] hid: Initialize battery_no to -1 & correct its format string
Date: Tue, 6 Jan 2015 20:02:50 +0530 [thread overview]
Message-ID: <CADYu308MmdGeajFTDt38zZSy7K2VKbDppuqmiJn=1ZwL5d1vmw@mail.gmail.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1412291302470.1680@pobox.suse.cz>
Dear Mr. Jason and Mr. Ping,
Please update about below patch.
Except avoiding subtraction, there is also a need to avoid negative
battery name which may come due to %ld, so need to change to %lu.
Thanks,
Aniroop
On Mon, Dec 29, 2014 at 5:33 PM, Jiri Kosina <jkosina@suse.cz> wrote:
> On Sun, 28 Dec 2014, Aniroop Mathur wrote:
>
>> From: Aniroop Mathur <a.mathur@samsung.com>
>>
>> This patch initializes battery_no to -1 to avoid extra subtraction
>> operation performed everytime wacom battery is initialized
>
> This is so femto-optimization, that I don't really care deeply. Adding
> Jason and Ping to CC. If they want this, I'll apply the patch.
>
>> and correct format string of unsigned long from %ld to %lu.
>>
>> Signed-off-by: Aniroop Mathur <a.mathur@samsung.com>
>> ---
>> drivers/hid/wacom_sys.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
>> index 129fd33..4b5ff84 100644
>> --- a/drivers/hid/wacom_sys.c
>> +++ b/drivers/hid/wacom_sys.c
>> @@ -919,17 +919,17 @@ static int wacom_ac_get_property(struct power_supply *psy,
>>
>> static int wacom_initialize_battery(struct wacom *wacom)
>> {
>> - static atomic_t battery_no = ATOMIC_INIT(0);
>> + static atomic_t battery_no = ATOMIC_INIT(-1);
>> int error;
>> unsigned long n;
>>
>> if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) {
>> - n = atomic_inc_return(&battery_no) - 1;
>> + n = atomic_inc_return(&battery_no);
>>
>> wacom->battery.properties = wacom_battery_props;
>> wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props);
>> wacom->battery.get_property = wacom_battery_get_property;
>> - sprintf(wacom->wacom_wac.bat_name, "wacom_battery_%ld", n);
>> + sprintf(wacom->wacom_wac.bat_name, "wacom_battery_%lu", n);
>> wacom->battery.name = wacom->wacom_wac.bat_name;
>> wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY;
>> wacom->battery.use_for_apm = 0;
>> @@ -937,7 +937,7 @@ static int wacom_initialize_battery(struct wacom *wacom)
>> wacom->ac.properties = wacom_ac_props;
>> wacom->ac.num_properties = ARRAY_SIZE(wacom_ac_props);
>> wacom->ac.get_property = wacom_ac_get_property;
>> - sprintf(wacom->wacom_wac.ac_name, "wacom_ac_%ld", n);
>> + sprintf(wacom->wacom_wac.ac_name, "wacom_ac_%lu", n);
>> wacom->ac.name = wacom->wacom_wac.ac_name;
>> wacom->ac.type = POWER_SUPPLY_TYPE_MAINS;
>> wacom->ac.use_for_apm = 0;
>> --
>> 1.9.1
>>
>
> --
> Jiri Kosina
> SUSE Labs
next prev parent reply other threads:[~2015-01-06 14:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-28 16:07 [PATCH] hid: Initialize battery_no to -1 & correct its format string Aniroop Mathur
2014-12-29 12:03 ` Jiri Kosina
2015-01-06 14:32 ` Aniroop Mathur [this message]
2015-01-07 0:50 ` Ping Cheng
2015-01-07 1:50 ` Benjamin Tissoires
2015-01-09 12:33 ` Aniroop Mathur
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='CADYu308MmdGeajFTDt38zZSy7K2VKbDppuqmiJn=1ZwL5d1vmw@mail.gmail.com' \
--to=aniroop.mathur@gmail.com \
--cc=a.mathur@samsung.com \
--cc=jkosina@suse.cz \
--cc=killertofu@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pingc@wacom.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;
as well as URLs for NNTP newsgroup(s).