* [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision
@ 2016-04-13 14:48 Betty Dall
2016-04-26 20:35 ` Rafael J. Wysocki
2016-04-26 20:41 ` Rafael J. Wysocki
0 siblings, 2 replies; 8+ messages in thread
From: Betty Dall @ 2016-04-13 14:48 UTC (permalink / raw)
To: rjw, lenb, linux-acpi; +Cc: linux-kernel, Betty Dall
The ACPI _HRV object on the device is used to supply Linux with
the device's hardware revision. This is an optional object. Add
sysfs support for the _HRV object if it exists on the device.
Signed-off-by: Betty Dall <betty.dall@hpe.com>
---
drivers/acpi/device_sysfs.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index b9afb47..bf12dbe 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -473,6 +473,21 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
+static ssize_t
+acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
+ char *buf) {
+ struct acpi_device *acpi_dev = to_acpi_device(dev);
+ acpi_status status;
+ unsigned long long hrv;
+
+ status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
+ if (ACPI_FAILURE(status))
+ return -ENODEV;
+
+ return sprintf(buf, "%llu\n", hrv);
+}
+static DEVICE_ATTR(hrv, 0444, acpi_device_hrv_show, NULL);
+
static ssize_t status_show(struct device *dev, struct device_attribute *attr,
char *buf) {
struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -541,6 +556,12 @@ int acpi_device_setup_files(struct acpi_device *dev)
goto end;
}
+ if (acpi_has_method(dev->handle, "_HRV")) {
+ result = device_create_file(&dev->dev, &dev_attr_hrv);
+ if (result)
+ goto end;
+ }
+
if (acpi_has_method(dev->handle, "_STA")) {
result = device_create_file(&dev->dev, &dev_attr_status);
if (result)
@@ -604,6 +625,9 @@ void acpi_device_remove_files(struct acpi_device *dev)
if (acpi_has_method(dev->handle, "_SUN"))
device_remove_file(&dev->dev, &dev_attr_sun);
+ if (acpi_has_method(dev->handle, "_HRV"))
+ device_remove_file(&dev->dev, &dev_attr_hrv);
+
if (dev->pnp.unique_id)
device_remove_file(&dev->dev, &dev_attr_uid);
if (dev->pnp.type.bus_address)
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision
2016-04-13 14:48 [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision Betty Dall
@ 2016-04-26 20:35 ` Rafael J. Wysocki
2016-04-27 16:15 ` Dall, Betty
2016-04-26 20:41 ` Rafael J. Wysocki
1 sibling, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2016-04-26 20:35 UTC (permalink / raw)
To: Betty Dall; +Cc: lenb, linux-acpi, linux-kernel
On Wednesday, April 13, 2016 08:48:14 AM Betty Dall wrote:
> The ACPI _HRV object on the device is used to supply Linux with
> the device's hardware revision. This is an optional object. Add
> sysfs support for the _HRV object if it exists on the device.
>
> Signed-off-by: Betty Dall <betty.dall@hpe.com>
The patch itself looks OK to me, but why exactly do we need that thing in sysfs?
Thanks,
Rafael
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision
2016-04-13 14:48 [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision Betty Dall
2016-04-26 20:35 ` Rafael J. Wysocki
@ 2016-04-26 20:41 ` Rafael J. Wysocki
2016-04-27 16:19 ` Dall, Betty
1 sibling, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2016-04-26 20:41 UTC (permalink / raw)
To: Betty Dall; +Cc: lenb, linux-acpi, linux-kernel
On Wednesday, April 13, 2016 08:48:14 AM Betty Dall wrote:
> The ACPI _HRV object on the device is used to supply Linux with
> the device's hardware revision. This is an optional object. Add
> sysfs support for the _HRV object if it exists on the device.
>
> Signed-off-by: Betty Dall <betty.dall@hpe.com>
> ---
> drivers/acpi/device_sysfs.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index b9afb47..bf12dbe 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -473,6 +473,21 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
> }
> static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
>
> +static ssize_t
> +acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
> + char *buf) {
> + struct acpi_device *acpi_dev = to_acpi_device(dev);
> + acpi_status status;
> + unsigned long long hrv;
> +
> + status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
> + if (ACPI_FAILURE(status))
> + return -ENODEV;
Actually, this should be -EIO I think.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision
2016-04-26 20:35 ` Rafael J. Wysocki
@ 2016-04-27 16:15 ` Dall, Betty
2016-04-27 21:19 ` Rafael J. Wysocki
0 siblings, 1 reply; 8+ messages in thread
From: Dall, Betty @ 2016-04-27 16:15 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: lenb@kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org
On 04/26/2016 02:33 PM, Rafael J. Wysocki wrote:
> On Wednesday, April 13, 2016 08:48:14 AM Betty Dall wrote:
>> The ACPI _HRV object on the device is used to supply Linux with
>> the device's hardware revision. This is an optional object. Add
>> sysfs support for the _HRV object if it exists on the device.
>>
>> Signed-off-by: Betty Dall <betty.dall@hpe.com>
>
> The patch itself looks OK to me, but why exactly do we need that thing in sysfs?
>
> Thanks,
> Rafael
>
Hi Rafael,
I am working on a platform where non-PCI hardware is changing quickly
and users want to check what hardware version they are running on. For
example, someone checks out a lab system and wants to see if the device
is the latest version or if it needs to be updated - they could cat the
sysfs hrv file to find the version. It is most useful for non-PCI
devices because lspci can list the hardware version for PCI devices; PCI
devices in my testing don't supply _HRV. But, there is not an easy
solution for non-PCI devices to get the hardware revision from user
space with out this hrv sysfs patch.
Originally, I added the sysfs hrv to my specific device driver. On
review, I thought it would a good improvement for all devices that have
an _HRV.
Thanks,
Betty
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision
2016-04-26 20:41 ` Rafael J. Wysocki
@ 2016-04-27 16:19 ` Dall, Betty
2016-04-27 21:21 ` Rafael J. Wysocki
0 siblings, 1 reply; 8+ messages in thread
From: Dall, Betty @ 2016-04-27 16:19 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: lenb@kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org
On 04/26/2016 02:39 PM, Rafael J. Wysocki wrote:
> On Wednesday, April 13, 2016 08:48:14 AM Betty Dall wrote:
>> The ACPI _HRV object on the device is used to supply Linux with
>> the device's hardware revision. This is an optional object. Add
>> sysfs support for the _HRV object if it exists on the device.
>>
>> Signed-off-by: Betty Dall <betty.dall@hpe.com>
>> ---
>> drivers/acpi/device_sysfs.c | 24 ++++++++++++++++++++++++
>> 1 file changed, 24 insertions(+)
>>
>> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
>> index b9afb47..bf12dbe 100644
>> --- a/drivers/acpi/device_sysfs.c
>> +++ b/drivers/acpi/device_sysfs.c
>> @@ -473,6 +473,21 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
>> }
>> static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
>>
>> +static ssize_t
>> +acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
>> + char *buf) {
>> + struct acpi_device *acpi_dev = to_acpi_device(dev);
>> + acpi_status status;
>> + unsigned long long hrv;
>> +
>> + status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
>> + if (ACPI_FAILURE(status))
>> + return -ENODEV;
>
> Actually, this should be -EIO I think.
>
> Thanks,
> Rafael
Hi Rafael,
I picked -ENODEV because the _SUN and _STA show functions use -ENODEV
for a return value when the acpi_evaluate_integer() fails.
I checked in the sysfs code what the return value is used for and any
negative value is treated the same, that is, the sysfs code is not
looking specifically for -EIO.
Do you still want me to change it to -EIO?
-Betty
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision
2016-04-27 16:15 ` Dall, Betty
@ 2016-04-27 21:19 ` Rafael J. Wysocki
0 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2016-04-27 21:19 UTC (permalink / raw)
To: Dall, Betty
Cc: lenb@kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org
On Wednesday, April 27, 2016 04:15:30 PM Dall, Betty wrote:
> On 04/26/2016 02:33 PM, Rafael J. Wysocki wrote:
> > On Wednesday, April 13, 2016 08:48:14 AM Betty Dall wrote:
> >> The ACPI _HRV object on the device is used to supply Linux with
> >> the device's hardware revision. This is an optional object. Add
> >> sysfs support for the _HRV object if it exists on the device.
> >>
> >> Signed-off-by: Betty Dall <betty.dall@hpe.com>
> >
> > The patch itself looks OK to me, but why exactly do we need that thing in sysfs?
> >
> > Thanks,
> > Rafael
> >
> Hi Rafael,
>
> I am working on a platform where non-PCI hardware is changing quickly
> and users want to check what hardware version they are running on. For
> example, someone checks out a lab system and wants to see if the device
> is the latest version or if it needs to be updated - they could cat the
> sysfs hrv file to find the version. It is most useful for non-PCI
> devices because lspci can list the hardware version for PCI devices; PCI
> devices in my testing don't supply _HRV. But, there is not an easy
> solution for non-PCI devices to get the hardware revision from user
> space with out this hrv sysfs patch.
>
> Originally, I added the sysfs hrv to my specific device driver. On
> review, I thought it would a good improvement for all devices that have
> an _HRV.
OK
Can you please add a motivation paragraph to the patch changelog then?
Thanks,
Rafael
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision
2016-04-27 16:19 ` Dall, Betty
@ 2016-04-27 21:21 ` Rafael J. Wysocki
2016-04-29 13:55 ` Dall, Betty
0 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2016-04-27 21:21 UTC (permalink / raw)
To: Dall, Betty
Cc: lenb@kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org
On Wednesday, April 27, 2016 04:19:45 PM Dall, Betty wrote:
> On 04/26/2016 02:39 PM, Rafael J. Wysocki wrote:
> > On Wednesday, April 13, 2016 08:48:14 AM Betty Dall wrote:
> >> The ACPI _HRV object on the device is used to supply Linux with
> >> the device's hardware revision. This is an optional object. Add
> >> sysfs support for the _HRV object if it exists on the device.
> >>
> >> Signed-off-by: Betty Dall <betty.dall@hpe.com>
> >> ---
> >> drivers/acpi/device_sysfs.c | 24 ++++++++++++++++++++++++
> >> 1 file changed, 24 insertions(+)
> >>
> >> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> >> index b9afb47..bf12dbe 100644
> >> --- a/drivers/acpi/device_sysfs.c
> >> +++ b/drivers/acpi/device_sysfs.c
> >> @@ -473,6 +473,21 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
> >> }
> >> static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
> >>
> >> +static ssize_t
> >> +acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
> >> + char *buf) {
> >> + struct acpi_device *acpi_dev = to_acpi_device(dev);
> >> + acpi_status status;
> >> + unsigned long long hrv;
> >> +
> >> + status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
> >> + if (ACPI_FAILURE(status))
> >> + return -ENODEV;
> >
> > Actually, this should be -EIO I think.
> >
> > Thanks,
> > Rafael
>
> Hi Rafael,
>
> I picked -ENODEV because the _SUN and _STA show functions use -ENODEV
> for a return value when the acpi_evaluate_integer() fails.
Which isn't the best choice.
> I checked in the sysfs code what the return value is used for and any
> negative value is treated the same, that is, the sysfs code is not
> looking specifically for -EIO.
But doesn't it pass the return value up the call chain?
> Do you still want me to change it to -EIO?
I may, depending on the answer to the question above.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision
2016-04-27 21:21 ` Rafael J. Wysocki
@ 2016-04-29 13:55 ` Dall, Betty
0 siblings, 0 replies; 8+ messages in thread
From: Dall, Betty @ 2016-04-29 13:55 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: lenb@kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org
On 04/27/2016 03:19 PM, Rafael J. Wysocki wrote:
> On Wednesday, April 27, 2016 04:19:45 PM Dall, Betty wrote:
>> On 04/26/2016 02:39 PM, Rafael J. Wysocki wrote:
>>> On Wednesday, April 13, 2016 08:48:14 AM Betty Dall wrote:
>>>> The ACPI _HRV object on the device is used to supply Linux with
>>>> the device's hardware revision. This is an optional object. Add
>>>> sysfs support for the _HRV object if it exists on the device.
>>>>
>>>> Signed-off-by: Betty Dall <betty.dall@hpe.com>
>>>> ---
>>>> drivers/acpi/device_sysfs.c | 24 ++++++++++++++++++++++++
>>>> 1 file changed, 24 insertions(+)
>>>>
>>>> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
>>>> index b9afb47..bf12dbe 100644
>>>> --- a/drivers/acpi/device_sysfs.c
>>>> +++ b/drivers/acpi/device_sysfs.c
>>>> @@ -473,6 +473,21 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
>>>> }
>>>> static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
>>>>
>>>> +static ssize_t
>>>> +acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
>>>> + char *buf) {
>>>> + struct acpi_device *acpi_dev = to_acpi_device(dev);
>>>> + acpi_status status;
>>>> + unsigned long long hrv;
>>>> +
>>>> + status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
>>>> + if (ACPI_FAILURE(status))
>>>> + return -ENODEV;
>>>
>>> Actually, this should be -EIO I think.
>>>
>>> Thanks,
>>> Rafael
>>
>> Hi Rafael,
>>
>> I picked -ENODEV because the _SUN and _STA show functions use -ENODEV
>> for a return value when the acpi_evaluate_integer() fails.
>
> Which isn't the best choice.
>
>> I checked in the sysfs code what the return value is used for and any
>> negative value is treated the same, that is, the sysfs code is not
>> looking specifically for -EIO.
>
> But doesn't it pass the return value up the call chain?
Yes, it passes the return up the call chain. I see ENODEV returned from
the read system call by using strace with a hard coded an error return
in my show function. The kernel call chain is:
acpi_device_hrv_show+0x1c/0x48
dev_attr_show+0x20/0x58
sysfs_kf_seq_show+0xc0/0x158
kernfs_seq_show+0x28/0x30
seq_read+0x19c/0x418
kernfs_fop_read+0x104/0x198
__vfs_read+0x1c/0xd8
vfs_read+0x78/0x160
SyS_read+0x44/0xa0
>> Do you still want me to change it to -EIO?
>
> I may, depending on the answer to the question above.
I will change it to EIO. ENODEV makes less sense since the "device"
exists or there wouldn't be a sysfs file. I can do the same for _SUN and
_STA.
Thanks,
-Betty
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-04-29 13:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-13 14:48 [PATCH] ACPI/device_sysfs: Add sysfs support for _HRV hardware revision Betty Dall
2016-04-26 20:35 ` Rafael J. Wysocki
2016-04-27 16:15 ` Dall, Betty
2016-04-27 21:19 ` Rafael J. Wysocki
2016-04-26 20:41 ` Rafael J. Wysocki
2016-04-27 16:19 ` Dall, Betty
2016-04-27 21:21 ` Rafael J. Wysocki
2016-04-29 13:55 ` Dall, Betty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox