From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2021-02-26 19:36:51
Currently the ACPI companion and handle are retrieved and checked
a few times in different functions. Instead get ACPI companion only
once and reuse it everywhere.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: used companion indeed everywhere (i2c_hid_acpi_shutdown_tail() included)
drivers/hid/i2c-hid/i2c-hid-acpi.c | 36 +++++++++++++-----------------
1 file changed, 16 insertions(+), 20 deletions(-)
@@ -42,29 +42,22 @@ static const struct acpi_device_id i2c_hid_acpi_blacklist[] = {{},};-staticinti2c_hid_acpi_get_descriptor(structi2c_client*client)+staticinti2c_hid_acpi_get_descriptor(structacpi_device*adev){staticguid_ti2c_hid_guid=GUID_INIT(0x3CDFF6F7,0x4267,0x4555,0xAD,0x05,0xB3,0x0A,0x3D,0x89,0x38,0xDE);+acpi_handlehandle=acpi_device_handle(adev);unionacpi_object*obj;-structacpi_device*adev;-acpi_handlehandle;u16hid_descriptor_address;-handle=ACPI_HANDLE(&client->dev);-if(!handle||acpi_bus_get_device(handle,&adev)){-dev_err(&client->dev,"Error could not get ACPI device\n");-return-ENODEV;-}-if(acpi_match_device_ids(adev,i2c_hid_acpi_blacklist)==0)return-ENODEV;obj=acpi_evaluate_dsm_typed(handle,&i2c_hid_guid,1,1,NULL,ACPI_TYPE_INTEGER);if(!obj){-dev_err(&client->dev,"Error _DSM call to get HID descriptor address failed\n");+acpi_handle_err(handle,"Error _DSM call to get HID descriptor address failed\n");return-ENODEV;}
@@ -76,10 +69,9 @@ static int i2c_hid_acpi_get_descriptor(struct i2c_client *client)staticvoidi2c_hid_acpi_shutdown_tail(structi2chid_ops*ops){-structi2c_hid_acpi*ihid_acpi=-container_of(ops,structi2c_hid_acpi,ops);-structdevice*dev=&ihid_acpi->client->dev;-acpi_device_set_power(ACPI_COMPANION(dev),ACPI_STATE_D3_COLD);+structi2c_hid_acpi*ihid_acpi=container_of(ops,structi2c_hid_acpi,ops);++acpi_device_set_power(ihid_acpi->adev,ACPI_STATE_D3_COLD);}staticinti2c_hid_acpi_probe(structi2c_client*client,
@@ -91,21 +83,25 @@ static int i2c_hid_acpi_probe(struct i2c_client *client,u16hid_descriptor_address;intret;+adev=ACPI_COMPANION(dev);+if(!adev){+dev_err(&client->dev,"Error could not get ACPI device\n");+return-ENODEV;+}+ihid_acpi=devm_kzalloc(&client->dev,sizeof(*ihid_acpi),GFP_KERNEL);if(!ihid_acpi)return-ENOMEM;-ihid_acpi->client=client;+ihid_acpi->adev=adev;ihid_acpi->ops.shutdown_tail=i2c_hid_acpi_shutdown_tail;-ret=i2c_hid_acpi_get_descriptor(client);+ret=i2c_hid_acpi_get_descriptor(adev);if(ret<0)returnret;hid_descriptor_address=ret;-adev=ACPI_COMPANION(dev);-if(adev)-acpi_device_fix_up_power(adev);+acpi_device_fix_up_power(adev);if(acpi_gbl_FADT.flags&ACPI_FADT_LOW_POWER_S0){device_set_wakeup_capable(dev,true);
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2021-02-26 19:36:50
The driver depends on ACPI, ACPI_PTR() resolution is always the same.
Otherwise a compiler may produce a warning.
That said, the rule of thumb either ugly ifdeffery with ACPI_PTR or
none should be used in a driver.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: no changes
drivers/hid/i2c-hid/i2c-hid-acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2021-02-26 19:36:51
Move static GUID variable out of the function and add a comment
how it looks like in the human readable representation.
While at it, include uuid.h since the guid_t type is defined in it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: rebased on top of patch 1 that used to be separate change
drivers/hid/i2c-hid/i2c-hid-acpi.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
From: Benjamin Tissoires <hidden> Date: 2021-03-01 14:40:28
Hi,
On Fri, Feb 26, 2021 at 8:34 PM Andy Shevchenko
[off-list ref] wrote:
The driver depends on ACPI, ACPI_PTR() resolution is always the same.
Otherwise a compiler may produce a warning.
That said, the rule of thumb either ugly ifdeffery with ACPI_PTR or
none should be used in a driver.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks a lot for the series. This indeed cleans things up.
For the series:
Acked-by: Benjamin Tissoires <redacted>
Jiri, I wonder where we want to land this one. This is not strictly
bug fixes, but we could definitively sneak this one in 5.12-rc1.
Well, I should probably run the series on an acpi laptop here before
merging, but I'd like to know if delaying to 5.13 is OK or if we need
this in 5.12.
Cheers,
Benjamin
Hi,
On Fri, Feb 26, 2021 at 8:34 PM Andy Shevchenko
[off-list ref] wrote:
quoted
The driver depends on ACPI, ACPI_PTR() resolution is always the same.
Otherwise a compiler may produce a warning.
That said, the rule of thumb either ugly ifdeffery with ACPI_PTR or
none should be used in a driver.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks a lot for the series. This indeed cleans things up.
Indeed, thanks.
For the series:
Acked-by: Benjamin Tissoires <redacted>
Jiri, I wonder where we want to land this one. This is not strictly
bug fixes, but we could definitively sneak this one in 5.12-rc1.
Well, I should probably run the series on an acpi laptop here before
merging, but I'd like to know if delaying to 5.13 is OK or if we need
this in 5.12.
I'd like to do it the standard way and have it bake in for-next to see if
it really doesn't break anything, so unless there are convicing arguments
for 5.12-rcX, I'd rathre queue this for 5.13.
Thanks,
--
Jiri Kosina
SUSE Labs
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2021-03-01 16:21:40
On Mon, Mar 01, 2021 at 04:34:41PM +0100, Jiri Kosina wrote:
On Mon, 1 Mar 2021, Benjamin Tissoires wrote:
quoted
On Fri, Feb 26, 2021 at 8:34 PM Andy Shevchenko
[off-list ref] wrote:
quoted
The driver depends on ACPI, ACPI_PTR() resolution is always the same.
Otherwise a compiler may produce a warning.
That said, the rule of thumb either ugly ifdeffery with ACPI_PTR or
none should be used in a driver.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks a lot for the series. This indeed cleans things up.
Indeed, thanks.
quoted
For the series:
Acked-by: Benjamin Tissoires <redacted>
Jiri, I wonder where we want to land this one. This is not strictly
bug fixes, but we could definitively sneak this one in 5.12-rc1.
Well, I should probably run the series on an acpi laptop here before
merging, but I'd like to know if delaying to 5.13 is OK or if we need
this in 5.12.
I'd like to do it the standard way and have it bake in for-next to see if
it really doesn't break anything, so unless there are convicing arguments
for 5.12-rcX, I'd rathre queue this for 5.13.
For the record, I'm not in hurry with this, up to you how to proceed.
Thanks!
--
With Best Regards,
Andy Shevchenko
The driver depends on ACPI, ACPI_PTR() resolution is always the same.
Otherwise a compiler may produce a warning.
That said, the rule of thumb either ugly ifdeffery with ACPI_PTR or
none should be used in a driver.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks a lot for the series. This indeed cleans things up.
Indeed, thanks.
quoted
For the series:
Acked-by: Benjamin Tissoires <redacted>
Jiri, I wonder where we want to land this one. This is not strictly
bug fixes, but we could definitively sneak this one in 5.12-rc1.
Well, I should probably run the series on an acpi laptop here before
merging, but I'd like to know if delaying to 5.13 is OK or if we need
this in 5.12.
I'd like to do it the standard way and have it bake in for-next to see if
it really doesn't break anything, so unless there are convicing arguments
for 5.12-rcX, I'd rathre queue this for 5.13.
For the record, I'm not in hurry with this, up to you how to proceed.
Thanks!
Queued in for-5.13/i2c-hid. Thanks,
--
Jiri Kosina
SUSE Labs