From: Julian Andres Klode <jak@jak-linux.org>
To: Julian Andres Klode <jak@jak-linux.org>
Cc: Henrique de Moraes Holschuh <ibm-acpi@hmh.eng.br>,
Matthew Garrett <matthew.garrett@nebula.com>,
"open list:THINKPAD ACPI EXT..."
<ibm-acpi-devel@lists.sourceforge.net>,
"open list:THINKPAD ACPI EXT..."
<platform-driver-x86@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] thinkpad_acpi: Add support for controlling charge thresholds
Date: Wed, 13 Nov 2013 14:50:51 +0100 [thread overview]
Message-ID: <20131113135051.GA13304@jak-x230> (raw)
In-Reply-To: <1384178195-12218-2-git-send-email-jak@jak-linux.org>
On Mon, Nov 11, 2013 at 02:56:30PM +0100, Julian Andres Klode wrote:
> +static int __init battery_init(struct ibm_init_struct *iibm)
> + for (i = 0; i < BATTERY_MAX_COUNT; i++) {
> + int j = 0;
> + if (!acpi_evalf(hkey_handle, &state, "BCTG", "qdd", i + 1))
> + continue;
> + /* If the sign bit was set, we could not get the start charge
> + * threshold of that battery. Let's assume that this battery
> + * (and all following ones) do not exist */
> + if (state < 0)
> + break;
> + /* Modify BATTERY_MAX_ATTRS if you add an attribute */
> + batteries[i].attributes[j++] = (struct dev_ext_attribute) {
> + .attr = __ATTR(start_charge_tresh,
> + S_IWUSR | S_IRUGO,
> + battery_start_charge_thresh_show,
> + battery_start_charge_thresh_store),
> + .var = (void *) (unsigned long) (i + 1)
> + };
> + batteries[i].attributes[j++] = (struct dev_ext_attribute) {
> + .attr = __ATTR(stop_charge_tresh,
> + S_IWUSR | S_IRUGO,
> + battery_stop_charge_thresh_show,
> + battery_stop_charge_thresh_store),
> + .var = (void *) (unsigned long) (i + 1)
> + };
> +
> + strncpy(batteries[i].name, "BAT", 3);
> + batteries[i].name[3] = '0' + i;
> + batteries[i].name[4] = '\0';
> + batteries[i].set = create_attr_set(j - 1, batteries[i].name);
> +
There's a bug here that I just noticed: It should be (j) attributes, not (j - 1)
ones. The following patch fixes this. I can squash it into that patch and resubmit
later on if requested.
-- >8 --
Subject: [PATCH] thinkpad_acpi: battery: Fix the size of the battery attribute sets
There are not j - 1, but j attributes.
Signed-off-by: Julian Andres Klode <jak@jak-linux.org>
---
drivers/platform/x86/thinkpad_acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index a9cba4e..6948141 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -8613,7 +8613,7 @@ static int __init battery_init(struct ibm_init_struct *iibm)
strncpy(batteries[i].name, "BAT", 3);
batteries[i].name[3] = '0' + i;
batteries[i].name[4] = '\0';
- batteries[i].set = create_attr_set(j - 1, batteries[i].name);
+ batteries[i].set = create_attr_set(j, batteries[i].name);
for (j = j - 1; j >= 0; j--)
add_to_attr_set(batteries[i].set,
--
1.8.4.2
--
Julian Andres Klode - Debian Developer, Ubuntu Member
See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
Please do not top-post if possible.
next prev parent reply other threads:[~2013-11-13 13:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-11 13:56 [PATCH 0/4] thinkpad_acpi: Add support for controlling charge thresholds Julian Andres Klode
2013-11-11 13:56 ` [PATCH 1/4] " Julian Andres Klode
2013-11-13 13:50 ` Julian Andres Klode [this message]
2013-12-30 13:29 ` Julian Andres Klode
2013-12-30 21:58 ` Henrique de Moraes Holschuh
2013-12-30 22:40 ` Henrique de Moraes Holschuh
2013-12-31 0:01 ` Julian Andres Klode
2013-12-31 12:12 ` [ibm-acpi-devel] " Henrique de Moraes Holschuh
2013-12-31 22:46 ` Julian Andres Klode
2014-04-06 12:14 ` Julian Andres Klode
2014-04-09 18:00 ` Henrique de Moraes Holschuh
2013-11-11 13:56 ` [PATCH 2/4] thinkpad_acpi: battery: Add force_discharge attribute Julian Andres Klode
2013-11-11 13:56 ` [PATCH 3/4] thinkpad_acpi: battery: Add force_discharge_ac_break attribute Julian Andres Klode
2013-11-11 13:56 ` [PATCH 4/4] thinkpad_acpi: battery: Add inhibit_charge_minutes attribute Julian Andres Klode
2013-11-25 14:59 ` [PATCH 0/4] thinkpad_acpi: Add support for controlling charge thresholds Julian Andres Klode
2013-12-28 21:10 ` Julian Andres Klode
2013-12-28 22:10 ` Henrique de Moraes Holschuh
2013-12-30 13:26 ` Julian Andres Klode
2013-12-30 20:06 ` Henrique de Moraes Holschuh
2014-01-20 21:22 ` Pavel Machek
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=20131113135051.GA13304@jak-x230 \
--to=jak@jak-linux.org \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=ibm-acpi@hmh.eng.br \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.garrett@nebula.com \
--cc=platform-driver-x86@vger.kernel.org \
/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