Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754129AbaFMVqU (ORCPT ); Fri, 13 Jun 2014 17:46:20 -0400 Received: from mail-ig0-f181.google.com ([209.85.213.181]:49155 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754096AbaFMVqO (ORCPT ); Fri, 13 Jun 2014 17:46:14 -0400 Date: Fri, 13 Jun 2014 14:46:11 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Lan Tianyu cc: rjw@rjwysocki.net, lenb@kernel.org, naszar@ya.ru, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] ACPI/Battery: Retry to get Battery information if failed during probing In-Reply-To: <539A60FC.1050301@intel.com> Message-ID: References: <1402552946-14704-1-git-send-email-tianyu.lan@intel.com> <53995488.20308@intel.com> <53996152.2000407@intel.com> <539A60FC.1050301@intel.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 13 Jun 2014, Lan Tianyu wrote: > How about this? > > - result = acpi_battery_update(battery, false); > - if (result) > + > + /* > + * Some machines'(E,G Lenovo Z480) ECs are not stable > + * during boot up and this causes battery driver fails to be > + * probed due to failure of getting battery information > + * from EC sometimes. After several retries, the operation > + * may work. So add retry code here and 20ms sleep between > + * every retries. > + */ > + while (acpi_battery_update(battery, false) && retry--) > + msleep(20); > + if (!retry) { > + result = -ENODEV; > goto fail; > + } > + I think you want --retry and not retry--. Otherwise it's possible for the final call to acpi_battery_update() to succeed and now it's returning -ENODEV. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/