From: "Barnabás Pőcze" <pobrn@protonmail.com>
To: platform-driver-x86@vger.kernel.org,
Hans de Goede <hdegoede@redhat.com>,
Mark Gross <mgross@linux.intel.com>,
Ike Panhc <ike.pan@canonical.com>
Subject: [PATCH 04/24] platform/x86: ideapad-laptop: use sysfs_emit()
Date: Wed, 16 Dec 2020 01:39:16 +0000 [thread overview]
Message-ID: <20201216013857.360987-5-pobrn@protonmail.com> (raw)
In-Reply-To: <20201216013857.360987-1-pobrn@protonmail.com>
sysfs_emit() has been introduced to make it less ambiguous which function
is preferred when writing to the output buffer in a device attribute's
show() callback. Convert the ideapad-laptop module to utilize this
new helper function.
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index aefe83996be6..11df791d702c 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -24,6 +24,7 @@
#include <linux/platform_device.h>
#include <linux/rfkill.h>
#include <linux/seq_file.h>
+#include <linux/sysfs.h>
#include <linux/types.h>
#define IDEAPAD_RFKILL_DEV_NUM (3)
@@ -344,8 +345,8 @@ static ssize_t show_ideapad_cam(struct device *dev,
struct ideapad_private *priv = dev_get_drvdata(dev);
if (read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result))
- return sprintf(buf, "-1\n");
- return sprintf(buf, "%lu\n", result);
+ return sysfs_emit(buf, "-1\n");
+ return sysfs_emit(buf, "%lu\n", result);
}
static ssize_t store_ideapad_cam(struct device *dev,
@@ -375,8 +376,8 @@ static ssize_t show_ideapad_fan(struct device *dev,
struct ideapad_private *priv = dev_get_drvdata(dev);
if (read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result))
- return sprintf(buf, "-1\n");
- return sprintf(buf, "%lu\n", result);
+ return sysfs_emit(buf, "-1\n");
+ return sysfs_emit(buf, "%lu\n", result);
}
static ssize_t store_ideapad_fan(struct device *dev,
@@ -408,8 +409,8 @@ static ssize_t touchpad_show(struct device *dev,
unsigned long result;
if (read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result))
- return sprintf(buf, "-1\n");
- return sprintf(buf, "%lu\n", result);
+ return sysfs_emit(buf, "-1\n");
+ return sysfs_emit(buf, "%lu\n", result);
}
/* Switch to RO for now: It might be revisited in the future */
@@ -441,8 +442,8 @@ static ssize_t conservation_mode_show(struct device *dev,
unsigned long result;
if (method_gbmd(priv->adev->handle, &result))
- return sprintf(buf, "-1\n");
- return sprintf(buf, "%u\n", test_bit(BM_CONSERVATION_BIT, &result));
+ return sysfs_emit(buf, "-1\n");
+ return sysfs_emit(buf, "%u\n", test_bit(BM_CONSERVATION_BIT, &result));
}
static ssize_t conservation_mode_store(struct device *dev,
@@ -477,10 +478,10 @@ static ssize_t fn_lock_show(struct device *dev,
int fail = read_method_int(priv->adev->handle, "HALS", &hals);
if (fail)
- return sprintf(buf, "-1\n");
+ return sysfs_emit(buf, "-1\n");
result = hals;
- return sprintf(buf, "%u\n", test_bit(HA_FNLOCK_BIT, &result));
+ return sysfs_emit(buf, "%u\n", test_bit(HA_FNLOCK_BIT, &result));
}
static ssize_t fn_lock_store(struct device *dev,
--
2.29.2
next prev parent reply other threads:[~2020-12-16 1:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-16 1:39 [PATCH 00/24] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
2020-12-16 1:39 ` [PATCH 01/24] platform/x86: ideapad-laptop: remove unnecessary dev_set_drvdata() call Barnabás Pőcze
2020-12-16 1:39 ` [PATCH 02/24] platform/x86: ideapad-laptop: use appropriately typed variable to store the return value of ACPI methods Barnabás Pőcze
2020-12-16 1:39 ` [PATCH 03/24] platform/x86: ideapad-laptop: sort includes lexicographically Barnabás Pőcze
2020-12-16 1:39 ` Barnabás Pőcze [this message]
2020-12-16 1:39 ` [PATCH 05/24] platform/x86: ideapad-laptop: use for_each_set_bit() helper to simplify event processing Barnabás Pőcze
2020-12-16 1:39 ` [PATCH 06/24] platform/x86: ideapad-laptop: use msecs_to_jiffies() helper instead of hand-crafted formula Barnabás Pőcze
2020-12-16 1:39 ` [PATCH 07/24] platform/x86: ideapad-laptop: use dev_{err,warn} or appropriate variant to display log messages Barnabás Pőcze
2020-12-16 1:39 ` [PATCH 08/24] platform/x86: ideapad-laptop: convert ACPI helpers to return -EIO in case of failure Barnabás Pőcze
2020-12-16 1:39 ` [PATCH 09/24] platform/x86: ideapad-laptop: always propagate error codes from device attributes' show() callback Barnabás Pőcze
2020-12-16 1:39 ` [PATCH 10/24] platform/x86: ideapad-laptop: misc. device attribute changes Barnabás Pőcze
2020-12-16 1:39 ` [PATCH 11/24] platform/x86: ideapad-laptop: group and separate (un)related constants into enums Barnabás Pőcze
2020-12-16 1:39 ` [PATCH 12/24] platform/x86: ideapad-laptop: rework and create new ACPI helpers Barnabás Pőcze
2021-01-04 12:03 ` [PATCH 00/24] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
2021-01-04 14:03 ` Hans de Goede
2021-01-04 14:10 ` Barnabás Pőcze
2021-01-06 18:23 ` Hans de Goede
2021-01-06 20:42 ` Barnabás Pőcze
2021-01-06 20:49 ` Barnabás Pőcze
2021-01-06 21:08 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201216013857.360987-5-pobrn@protonmail.com \
--to=pobrn@protonmail.com \
--cc=hdegoede@redhat.com \
--cc=ike.pan@canonical.com \
--cc=mgross@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox