Message ID | 52D69E57.5020208@intel.com (mailing list archive) |
---|---|
State | RFC, archived |
Headers | show |
On Wed, Jan 15, 2014 at 10:42:31PM +0800, Lan Tianyu wrote: > diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c > index fbf1ace..e98fa83 100644 > --- a/drivers/acpi/battery.c > +++ b/drivers/acpi/battery.c > @@ -770,7 +770,7 @@ static int acpi_battery_add(struct acpi_device *device) > device->driver_data = battery; > mutex_init(&battery->lock); > mutex_init(&battery->sysfs_lock); > - if (acpi_has_method(battery->device->handle, "_BIX")) > + if (acpi_evaluate_object(device->handle, "_BIX", NULL, &buffer);) > set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); Doesn't acpi_evaluate_object() return 0 on success? I think: if (ACPI_SUCESS(acpi_evaluate_object(device->handle, "_BIX", NULL, &buffer)) But maybe we should check for existence first and give an FW_BUG message to indicate an invalid _BIX?
On 01/15/2014 10:47 PM, Matthew Garrett wrote: > On Wed, Jan 15, 2014 at 10:42:31PM +0800, Lan Tianyu wrote: >> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c >> index fbf1ace..e98fa83 100644 >> --- a/drivers/acpi/battery.c >> +++ b/drivers/acpi/battery.c >> @@ -770,7 +770,7 @@ static int acpi_battery_add(struct acpi_device *device) >> device->driver_data = battery; >> mutex_init(&battery->lock); >> mutex_init(&battery->sysfs_lock); >> - if (acpi_has_method(battery->device->handle, "_BIX")) >> + if (acpi_evaluate_object(device->handle, "_BIX", NULL, &buffer);) >> set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); > > Doesn't acpi_evaluate_object() return 0 on success? I think: > > if (ACPI_SUCESS(acpi_evaluate_object(device->handle, "_BIX", NULL, > &buffer)) > Yes, Sorry for oops. > But maybe we should check for existence first and give an FW_BUG message > to indicate an invalid _BIX? Yes, this is a good idea. Another point, the acpi_evaluate_object should return different error code for these two cases(no _BIX and wrong size.). I wonder whether we can use the error code to determine it belong which case? >
SWYgYW4gb2JqZWN0I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KPiA+IG1lc3Nh Z2UgdG8gaW5kaWNhdGUgYW4gaW52YWxpZCBfQklYPw0KPiANCj4gWWVzLCB0aGlzIGlzIGEgZ29v ZCBpZGVhLg0KPiANCj4gQW5vdGhlciBwb2ludCwgdGhlIGFjcGlfZXZhbHVhdGVfb2JqZWN0IHNo b3VsZCByZXR1cm4gZGlmZmVyZW50IGVycm9yIGNvZGUNCj4gZm9yIHRoZXNlIHR3byBjYXNlcyhu byBfQklYIGFuZCB3cm9uZyBzaXplLikuIEkgd29uZGVyIHdoZXRoZXIgd2UgY2FuIHVzZQ0KPiB0 aGUgZXJyb3IgY29kZSB0byBkZXRlcm1pbmUgaXQgYmVsb25nIHdoaWNoIGNhc2U/DQo+ID4NCj4g DQo+IA0KPiAtLQ0KPiBCZXN0IFJlZ2FyZHMNCj4gVGlhbnl1IExhbg0K -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index fbf1ace..e98fa83 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -770,7 +770,7 @@ static int acpi_battery_add(struct acpi_device *device) device->driver_data = battery; mutex_init(&battery->lock); mutex_init(&battery->sysfs_lock); - if (acpi_has_method(battery->device->handle, "_BIX")) + if (acpi_evaluate_object(device->handle, "_BIX", NULL, &buffer);) set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); result = acpi_battery_update(battery); if (result)