Re: [PATCH v2] driver core: Add sysfs support for physical location of a device
From: Greg Kroah-Hartman
Date: Fri Mar 04 2022 - 13:47:49 EST
On Fri, Mar 04, 2022 at 06:21:52PM +0000, Won Chung wrote:
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-devices-physical_location
> @@ -0,0 +1,42 @@
> +What: /sys/devices/.../physical_location
> +Date: March 2022
> +Contact: Won Chung <wonchung@xxxxxxxxxx>
> +Description:
> + This directory contains information on physical location of
> + the device connection point with respect to the system's
> + housing.
> +
> +What: /sys/devices/.../physical_location/panel
> +Date: March 2022
> +Contact: Won Chung <wonchung@xxxxxxxxxx>
> +Description:
Use tabs everywhere please, stop mixing spaces and tabs in the same file
:(
> +static ssize_t panel_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + const char *panel;
> +
> + switch (dev->location.panel) {
> + case DEVICE_PANEL_TOP:
> + panel = "top";
> + break;
> + case DEVICE_PANEL_BOTTOM:
> + panel = "bottom";
> + break;
> + case DEVICE_PANEL_LEFT:
> + panel = "left";
> + break;
> + case DEVICE_PANEL_RIGHT:
> + panel = "right";
> + break;
> + case DEVICE_PANEL_FRONT:
> + panel = "front";
> + break;
> + case DEVICE_PANEL_BACK:
> + panel = "back";
> + break;
> + default:
> + panel = "unknown";
> + }
> + return sprintf(buf, "%s\n", panel);
Always use sysfs_emit() for new sysfs files.
thanks,
greg k-h