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@xxxxxxxxxxxxx> --- 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. ------------------------------------------------------------------------------ DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk _______________________________________________ ibm-acpi-devel mailing list ibm-acpi-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel