Commit b35814a3 authored by Szilard Fabian's avatar Szilard Fabian Committed by Hans de Goede

platform/x86/fujitsu-laptop: Replace sprintf() with sysfs_emit()

As suggested by Documentation/filesystems/sysfs.rst sysfs_emit() should be
used when formatting the value to be returned to user space.
Signed-off-by: default avatarSzilard Fabian <szfabian@bluemarch.art>
Link: https://lore.kernel.org/r/20240428192548.113261-1-szfabian@bluemarch.artAcked-by: default avatarJonathan Woithe <jwoithe@just42.net>
Reviewed-by: default avatarKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 5cfac5ab
......@@ -386,11 +386,11 @@ static ssize_t lid_show(struct device *dev, struct device_attribute *attr,
struct fujitsu_laptop *priv = dev_get_drvdata(dev);
if (!(priv->flags_supported & FLAG_LID))
return sprintf(buf, "unknown\n");
return sysfs_emit(buf, "unknown\n");
if (priv->flags_state & FLAG_LID)
return sprintf(buf, "open\n");
return sysfs_emit(buf, "open\n");
else
return sprintf(buf, "closed\n");
return sysfs_emit(buf, "closed\n");
}
static ssize_t dock_show(struct device *dev, struct device_attribute *attr,
......@@ -399,11 +399,11 @@ static ssize_t dock_show(struct device *dev, struct device_attribute *attr,
struct fujitsu_laptop *priv = dev_get_drvdata(dev);
if (!(priv->flags_supported & FLAG_DOCK))
return sprintf(buf, "unknown\n");
return sysfs_emit(buf, "unknown\n");
if (priv->flags_state & FLAG_DOCK)
return sprintf(buf, "docked\n");
return sysfs_emit(buf, "docked\n");
else
return sprintf(buf, "undocked\n");
return sysfs_emit(buf, "undocked\n");
}
static ssize_t radios_show(struct device *dev, struct device_attribute *attr,
......@@ -412,11 +412,11 @@ static ssize_t radios_show(struct device *dev, struct device_attribute *attr,
struct fujitsu_laptop *priv = dev_get_drvdata(dev);
if (!(priv->flags_supported & FLAG_RFKILL))
return sprintf(buf, "unknown\n");
return sysfs_emit(buf, "unknown\n");
if (priv->flags_state & FLAG_RFKILL)
return sprintf(buf, "on\n");
return sysfs_emit(buf, "on\n");
else
return sprintf(buf, "killed\n");
return sysfs_emit(buf, "killed\n");
}
static DEVICE_ATTR_RO(lid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment