Input: mouse: use sysfs_emit() to instead of scnprintf()
Subsystems (2)
PATCH v2 1/1 Input: mouse: use sysfs_emit() to instead of scnprintf()
From: ye xingchen <[email protected]>
Replace the open-code with sysfs_emit() to simplify the code.
Signed-off-by ye xingchen <[email protected]>
---
v1 -> v2
fix the code style.
drivers/input/mouse/cyapa.c | 17 ++++++++--------- drivers/input/mouse/cyapa_gen3.c | 2 +- drivers/input/mouse/cyapa_gen5.c | 2 +- drivers/input/mouse/cyapa_gen6.c | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-)
drivers/input/mouse/cyapa.c +8 -9
@@ -756,15 +756,15 @@ static ssize_t cyapa_show_suspend_scanrate(struct device *dev,switch (pwr_cmd) {case PWR_MODE_BTN_ONLY : - len =scnprintf (buf,PAGE_SIZE ,"%s\n" ,BTN_ONLY_MODE_NAME ); + len =sysfs_emit (buf,"%s\n" ,BTN_ONLY_MODE_NAME );break ;case PWR_MODE_OFF : - len =scnprintf (buf,PAGE_SIZE ,"%s\n" ,OFF_MODE_NAME ); + len =sysfs_emit (buf,"%s\n" ,OFF_MODE_NAME );break ;default : - len =scnprintf (buf,PAGE_SIZE ,"%u\n" , + len =sysfs_emit (buf,"%u\n" , cyapa->gen ==CYAPA_GEN3 ?cyapa_pwr_cmd_to_sleep_time (pwr_cmd) : sleep_time);
@@ -877,8 +877,8 @@ static ssize_t cyapa_show_rt_suspend_scanrate(struct device *dev,mutex_unlock (&cyapa->state_sync_lock); -return scnprintf (buf,PAGE_SIZE ,"%u\n" , - cyapa->gen ==CYAPA_GEN3 ? +return sysfs_emit (buf,"%u\n" , + cyapa->gen ==CYAPA_GEN3 ?cyapa_pwr_cmd_to_sleep_time (pwr_cmd) : sleep_time); }
@@ -988,8 +988,7 @@ static ssize_t cyapa_show_fm_ver(struct device *dev, error =mutex_lock_interruptible (&cyapa->state_sync_lock);if (error)return error; - error =scnprintf (buf,PAGE_SIZE ,"%d.%d\n" , cyapa->fw_maj_ver, - cyapa->fw_min_ver); + error =sysfs_emit (buf,"%d.%d\n" , cyapa->fw_maj_ver, cyapa->fw_min_ver);mutex_unlock (&cyapa->state_sync_lock);return error; }
@@ -1004,7 +1003,7 @@ static ssize_t cyapa_show_product_id(struct device *dev, error =mutex_lock_interruptible (&cyapa->state_sync_lock);if (error)return error; - size =scnprintf (buf,PAGE_SIZE ,"%s\n" , cyapa->product_id); + size =sysfs_emit (buf,"%s\n" , cyapa->product_id);mutex_unlock (&cyapa->state_sync_lock);return size; }
@@ -1209,7 +1208,7 @@ static ssize_t cyapa_show_mode(struct device *dev,if (error)return error; - size =scnprintf (buf,PAGE_SIZE ,"gen%d %s\n" , + size =sysfs_emit (buf,"gen%d %s\n" , cyapa->gen,cyapa_state_to_string (cyapa));mutex_unlock (&cyapa->state_sync_lock);
drivers/input/mouse/cyapa_gen3.c +1 -1
@@ -860,7 +860,7 @@ static ssize_t cyapa_gen3_show_baseline(struct device *dev,dev_dbg (dev,"Baseline report successful. Max: %d Min: %d\n" , max_baseline, min_baseline); - ret =scnprintf (buf,PAGE_SIZE ,"%d %d\n" , max_baseline, min_baseline); + ret =sysfs_emit (buf,"%d %d\n" , max_baseline, min_baseline); out:return ret;
drivers/input/mouse/cyapa_gen5.c +1 -1
@@ -2418,7 +2418,7 @@ static ssize_t cyapa_gen5_show_baseline(struct device *dev,return resume_error ? resume_error : error;/* 12. Output data strings */ - size = scnprintf(buf, PAGE_SIZE, "%d %d %d %d %d %d %d %d %d %d %d ", + size = sysfs_emit(buf, "%d %d %d %d %d %d %d %d %d %d %d ", gidac_mutual_min, gidac_mutual_max, gidac_mutual_ave, lidac_mutual_min, lidac_mutual_max, lidac_mutual_ave, gidac_self_rx, gidac_self_tx,
drivers/input/mouse/cyapa_gen6.c +1 -1
@@ -629,7 +629,7 @@ static ssize_t cyapa_gen6_show_baseline(struct device *dev,if (error) goto resume_scanning; - size = scnprintf(buf, PAGE_SIZE, "%d %d %d %d %d %d ", + size = sysfs_emit(buf, "%d %d %d %d %d %d ", data[0], /* RX Attenuator Mutual */ data[1], /* IDAC Mutual */ data[2], /* RX Attenuator Self RX */
Signature · 1 line
2.25.1
Quoted 5 lines · On Fri, Dec 02, 2022 at 02:53:57PM +0800, [email protected] wrote:
From: ye xingchen <[email protected]>
Replace the open-code with
sysfs_emit()to simplify the code.Signed-off-by ye xingchen <[email protected]>
Applied, thank you.
Signature · 1 line
Dmitry