Re: [RFC PATCH v2 6/6] driver core: add compatible string in sysfs for platform devices

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

 



On Wed, Aug 17, 2022 at 08:35:42PM +0530, Nipun Gupta wrote:
> This change adds compatible string for the platform based
> devices.

What exactly is a "compatible string"?

> 
> Signed-off-by: Nipun Gupta <nipun.gupta@xxxxxxx>
> ---
>  Documentation/ABI/testing/sysfs-bus-platform |  8 +++++++
>  drivers/base/platform.c                      | 23 ++++++++++++++++++++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-platform b/Documentation/ABI/testing/sysfs-bus-platform
> index c4dfe7355c2d..d95ff83d768c 100644
> --- a/Documentation/ABI/testing/sysfs-bus-platform
> +++ b/Documentation/ABI/testing/sysfs-bus-platform
> @@ -54,3 +54,11 @@ Description:
>  		Other platform devices use, instead:
>  
>  			- platform:`driver name`
> +
> +What:		/sys/bus/platform/devices/.../compatible
> +Date:		August 2022
> +Contact:	Nipun Gupta <nipun.gupta@xxxxxxx>
> +Description:
> +		compatible string associated with the device. This is
> +		a read only and is visible if the device have "compatible"
> +		property associated with it.

Where is it defined what a compatible property is?

> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 51bb2289865c..94c33efaa9b8 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -1289,10 +1289,25 @@ static ssize_t driver_override_store(struct device *dev,
>  }
>  static DEVICE_ATTR_RW(driver_override);
>  
> +static ssize_t compatible_show(struct device *dev, struct device_attribute *attr,
> +			      char *buf)
> +{
> +	const char *compat;
> +	int ret;
> +
> +	ret = device_property_read_string(dev, "compatible", &compat);
> +	if (ret != 0)
> +		return 0;

Shouldn't you return an error here?

thanks,

greg k-h



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux