Re: [PATCH 3/3] ACPI / device_sysfs: Add eject show attr to monitor eject status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 31, 2019 at 02:56:42PM +0800, Chester Lin wrote:
> An acpi_eject_show attribute for users to monitor current status because
> sometimes it might take time to finish an ejection so we need to know
> whether it is still in progress or not.
> 
> Signed-off-by: Chester Lin <clin@xxxxxxxx>
> ---
>  drivers/acpi/device_sysfs.c | 20 +++++++++++++++++++-
>  drivers/acpi/internal.h     |  1 +
>  drivers/acpi/scan.c         | 27 +++++++++++++++++++++++++++
>  3 files changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index 78c2653bf020..70b22eec6bbc 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -403,7 +403,25 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
>  	return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
>  }
>  
> -static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
> +static ssize_t acpi_eject_show(struct device *d,
> +				struct device_attribute *attr, char *buf)
> +{
> +	struct acpi_device *acpi_device = to_acpi_device(d);
> +	acpi_object_type not_used;
> +	acpi_status status;
> +
> +	if ((!acpi_device->handler || !acpi_device->handler->hotplug.enabled)
> +	    && !acpi_device->driver)
> +		return -ENODEV;
> +
> +	status = acpi_get_type(acpi_device->handle, &not_used);
> +	if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable)
> +		return -ENODEV;
> +
> +	return sprintf(buf, "%s\n", acpi_eject_status_string(acpi_device));
> +}
> +
> +static DEVICE_ATTR(eject, 0644, acpi_eject_show, acpi_eject_store);

DEVICE_ATTR_RW()?

And you need to document the new sysfs file in Documentation/ABI/

thanks,

greg k-h



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux