Skip to content

Commit e50389f

Browse files
ye xingchendtor
authored andcommitted
Input: touchscreen - use sysfs_emit[_at]() instead of scnprintf()
Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Oliver Graute <oliver.graute@kococonnector.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 1864a20 commit e50389f

10 files changed

Lines changed: 46 additions & 51 deletions

File tree

drivers/input/touchscreen/atmel_mxt_ts.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,8 +2818,8 @@ static ssize_t mxt_fw_version_show(struct device *dev,
28182818
{
28192819
struct mxt_data *data = dev_get_drvdata(dev);
28202820
struct mxt_info *info = data->info;
2821-
return scnprintf(buf, PAGE_SIZE, "%u.%u.%02X\n",
2822-
info->version >> 4, info->version & 0xf, info->build);
2821+
return sysfs_emit(buf, "%u.%u.%02X\n",
2822+
info->version >> 4, info->version & 0xf, info->build);
28232823
}
28242824

28252825
/* Hardware Version is returned as FamilyID.VariantID */
@@ -2828,8 +2828,7 @@ static ssize_t mxt_hw_version_show(struct device *dev,
28282828
{
28292829
struct mxt_data *data = dev_get_drvdata(dev);
28302830
struct mxt_info *info = data->info;
2831-
return scnprintf(buf, PAGE_SIZE, "%u.%u\n",
2832-
info->family_id, info->variant_id);
2831+
return sysfs_emit(buf, "%u.%u\n", info->family_id, info->variant_id);
28332832
}
28342833

28352834
static ssize_t mxt_show_instance(char *buf, int count,
@@ -2839,19 +2838,18 @@ static ssize_t mxt_show_instance(char *buf, int count,
28392838
int i;
28402839

28412840
if (mxt_obj_instances(object) > 1)
2842-
count += scnprintf(buf + count, PAGE_SIZE - count,
2843-
"Instance %u\n", instance);
2841+
count += sysfs_emit_at(buf, count, "Instance %u\n", instance);
28442842

28452843
for (i = 0; i < mxt_obj_size(object); i++)
2846-
count += scnprintf(buf + count, PAGE_SIZE - count,
2847-
"\t[%2u]: %02x (%d)\n", i, val[i], val[i]);
2848-
count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
2844+
count += sysfs_emit_at(buf, count, "\t[%2u]: %02x (%d)\n",
2845+
i, val[i], val[i]);
2846+
count += sysfs_emit_at(buf, count, "\n");
28492847

28502848
return count;
28512849
}
28522850

28532851
static ssize_t mxt_object_show(struct device *dev,
2854-
struct device_attribute *attr, char *buf)
2852+
struct device_attribute *attr, char *buf)
28552853
{
28562854
struct mxt_data *data = dev_get_drvdata(dev);
28572855
struct mxt_object *object;
@@ -2872,8 +2870,7 @@ static ssize_t mxt_object_show(struct device *dev,
28722870
if (!mxt_object_readable(object->type))
28732871
continue;
28742872

2875-
count += scnprintf(buf + count, PAGE_SIZE - count,
2876-
"T%u:\n", object->type);
2873+
count += sysfs_emit_at(buf, count, "T%u:\n", object->type);
28772874

28782875
for (j = 0; j < mxt_obj_instances(object); j++) {
28792876
u16 size = mxt_obj_size(object);

drivers/input/touchscreen/edt-ft5x06.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ static ssize_t edt_ft5x06_setting_show(struct device *dev,
431431
*field = val;
432432
}
433433

434-
count = scnprintf(buf, PAGE_SIZE, "%d\n", val);
434+
count = sysfs_emit(buf, "%d\n", val);
435435
out:
436436
mutex_unlock(&tsdata->mutex);
437437
return error ?: count;

drivers/input/touchscreen/hideep.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,7 @@ static ssize_t hideep_fw_version_show(struct device *dev,
928928
ssize_t len;
929929

930930
mutex_lock(&ts->dev_mutex);
931-
len = scnprintf(buf, PAGE_SIZE, "%04x\n",
932-
be16_to_cpu(ts->dwz_info.release_ver));
931+
len = sysfs_emit(buf, "%04x\n", be16_to_cpu(ts->dwz_info.release_ver));
933932
mutex_unlock(&ts->dev_mutex);
934933

935934
return len;
@@ -943,8 +942,7 @@ static ssize_t hideep_product_id_show(struct device *dev,
943942
ssize_t len;
944943

945944
mutex_lock(&ts->dev_mutex);
946-
len = scnprintf(buf, PAGE_SIZE, "%04x\n",
947-
be16_to_cpu(ts->dwz_info.product_id));
945+
len = sysfs_emit(buf, "%04x\n", be16_to_cpu(ts->dwz_info.product_id));
948946
mutex_unlock(&ts->dev_mutex);
949947

950948
return len;

drivers/input/touchscreen/hycon-hy46xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static ssize_t hycon_hy46xx_setting_show(struct device *dev,
202202
*field = val;
203203
}
204204

205-
count = scnprintf(buf, PAGE_SIZE, "%d\n", val);
205+
count = sysfs_emit(buf, "%d\n", val);
206206

207207
out:
208208
mutex_unlock(&tsdata->mutex);

drivers/input/touchscreen/ilitek_ts_i2c.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,12 +512,12 @@ static ssize_t firmware_version_show(struct device *dev,
512512
struct i2c_client *client = to_i2c_client(dev);
513513
struct ilitek_ts_data *ts = i2c_get_clientdata(client);
514514

515-
return scnprintf(buf, PAGE_SIZE,
516-
"fw version: [%02X%02X.%02X%02X.%02X%02X.%02X%02X]\n",
517-
ts->firmware_ver[0], ts->firmware_ver[1],
518-
ts->firmware_ver[2], ts->firmware_ver[3],
519-
ts->firmware_ver[4], ts->firmware_ver[5],
520-
ts->firmware_ver[6], ts->firmware_ver[7]);
515+
return sysfs_emit(buf,
516+
"fw version: [%02X%02X.%02X%02X.%02X%02X.%02X%02X]\n",
517+
ts->firmware_ver[0], ts->firmware_ver[1],
518+
ts->firmware_ver[2], ts->firmware_ver[3],
519+
ts->firmware_ver[4], ts->firmware_ver[5],
520+
ts->firmware_ver[6], ts->firmware_ver[7]);
521521
}
522522
static DEVICE_ATTR_RO(firmware_version);
523523

@@ -527,8 +527,8 @@ static ssize_t product_id_show(struct device *dev,
527527
struct i2c_client *client = to_i2c_client(dev);
528528
struct ilitek_ts_data *ts = i2c_get_clientdata(client);
529529

530-
return scnprintf(buf, PAGE_SIZE, "product id: [%04X], module: [%s]\n",
531-
ts->mcu_ver, ts->product_id);
530+
return sysfs_emit(buf, "product id: [%04X], module: [%s]\n",
531+
ts->mcu_ver, ts->product_id);
532532
}
533533
static DEVICE_ATTR_RO(product_id);
534534

drivers/input/touchscreen/iqs5xx.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -943,12 +943,12 @@ static ssize_t fw_info_show(struct device *dev,
943943
if (!iqs5xx->dev_id_info.bl_status)
944944
return -ENODATA;
945945

946-
return scnprintf(buf, PAGE_SIZE, "%u.%u.%u.%u:%u.%u\n",
947-
be16_to_cpu(iqs5xx->dev_id_info.prod_num),
948-
be16_to_cpu(iqs5xx->dev_id_info.proj_num),
949-
iqs5xx->dev_id_info.major_ver,
950-
iqs5xx->dev_id_info.minor_ver,
951-
iqs5xx->exp_file[0], iqs5xx->exp_file[1]);
946+
return sysfs_emit(buf, "%u.%u.%u.%u:%u.%u\n",
947+
be16_to_cpu(iqs5xx->dev_id_info.prod_num),
948+
be16_to_cpu(iqs5xx->dev_id_info.proj_num),
949+
iqs5xx->dev_id_info.major_ver,
950+
iqs5xx->dev_id_info.minor_ver,
951+
iqs5xx->exp_file[0], iqs5xx->exp_file[1]);
952952
}
953953

954954
static DEVICE_ATTR_WO(fw_file);

drivers/input/touchscreen/iqs7211.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,12 +2401,12 @@ static ssize_t fw_info_show(struct device *dev,
24012401
{
24022402
struct iqs7211_private *iqs7211 = dev_get_drvdata(dev);
24032403

2404-
return scnprintf(buf, PAGE_SIZE, "%u.%u.%u.%u:%u.%u\n",
2405-
le16_to_cpu(iqs7211->ver_info.prod_num),
2406-
le32_to_cpu(iqs7211->ver_info.patch),
2407-
le16_to_cpu(iqs7211->ver_info.major),
2408-
le16_to_cpu(iqs7211->ver_info.minor),
2409-
iqs7211->exp_file[1], iqs7211->exp_file[0]);
2404+
return sysfs_emit(buf, "%u.%u.%u.%u:%u.%u\n",
2405+
le16_to_cpu(iqs7211->ver_info.prod_num),
2406+
le32_to_cpu(iqs7211->ver_info.patch),
2407+
le16_to_cpu(iqs7211->ver_info.major),
2408+
le16_to_cpu(iqs7211->ver_info.minor),
2409+
iqs7211->exp_file[1], iqs7211->exp_file[0]);
24102410
}
24112411

24122412
static DEVICE_ATTR_RO(fw_info);

drivers/input/touchscreen/melfas_mip4.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,9 +1336,9 @@ static ssize_t mip4_sysfs_read_fw_version(struct device *dev,
13361336
/* Take lock to prevent racing with firmware update */
13371337
mutex_lock(&ts->input->mutex);
13381338

1339-
count = snprintf(buf, PAGE_SIZE, "%04X %04X %04X %04X\n",
1340-
ts->fw_version.boot, ts->fw_version.core,
1341-
ts->fw_version.app, ts->fw_version.param);
1339+
count = sysfs_emit(buf, "%04X %04X %04X %04X\n",
1340+
ts->fw_version.boot, ts->fw_version.core,
1341+
ts->fw_version.app, ts->fw_version.param);
13421342

13431343
mutex_unlock(&ts->input->mutex);
13441344

@@ -1362,8 +1362,8 @@ static ssize_t mip4_sysfs_read_hw_version(struct device *dev,
13621362
* product_name shows the name or version of the hardware
13631363
* paired with current firmware in the chip.
13641364
*/
1365-
count = snprintf(buf, PAGE_SIZE, "%.*s\n",
1366-
(int)sizeof(ts->product_name), ts->product_name);
1365+
count = sysfs_emit(buf, "%.*s\n",
1366+
(int)sizeof(ts->product_name), ts->product_name);
13671367

13681368
mutex_unlock(&ts->input->mutex);
13691369

@@ -1382,7 +1382,7 @@ static ssize_t mip4_sysfs_read_product_id(struct device *dev,
13821382

13831383
mutex_lock(&ts->input->mutex);
13841384

1385-
count = snprintf(buf, PAGE_SIZE, "%04X\n", ts->product_id);
1385+
count = sysfs_emit(buf, "%04X\n", ts->product_id);
13861386

13871387
mutex_unlock(&ts->input->mutex);
13881388

@@ -1401,8 +1401,8 @@ static ssize_t mip4_sysfs_read_ic_name(struct device *dev,
14011401

14021402
mutex_lock(&ts->input->mutex);
14031403

1404-
count = snprintf(buf, PAGE_SIZE, "%.*s\n",
1405-
(int)sizeof(ts->ic_name), ts->ic_name);
1404+
count = sysfs_emit(buf, "%.*s\n",
1405+
(int)sizeof(ts->ic_name), ts->ic_name);
14061406

14071407
mutex_unlock(&ts->input->mutex);
14081408

drivers/input/touchscreen/usbtouchscreen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ static ssize_t mtouch_firmware_rev_show(struct device *dev,
456456
struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
457457
struct mtouch_priv *priv = usbtouch->priv;
458458

459-
return scnprintf(output, PAGE_SIZE, "%1x.%1x\n",
460-
priv->fw_rev_major, priv->fw_rev_minor);
459+
return sysfs_emit(output, "%1x.%1x\n",
460+
priv->fw_rev_major, priv->fw_rev_minor);
461461
}
462462
static DEVICE_ATTR(firmware_rev, 0444, mtouch_firmware_rev_show, NULL);
463463

drivers/input/touchscreen/wdt87xx_i2c.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ static ssize_t config_csum_show(struct device *dev,
887887
cfg_csum = wdt->param.xmls_id1;
888888
cfg_csum = (cfg_csum << 16) | wdt->param.xmls_id2;
889889

890-
return scnprintf(buf, PAGE_SIZE, "%x\n", cfg_csum);
890+
return sysfs_emit(buf, "%x\n", cfg_csum);
891891
}
892892

893893
static ssize_t fw_version_show(struct device *dev,
@@ -896,7 +896,7 @@ static ssize_t fw_version_show(struct device *dev,
896896
struct i2c_client *client = to_i2c_client(dev);
897897
struct wdt87xx_data *wdt = i2c_get_clientdata(client);
898898

899-
return scnprintf(buf, PAGE_SIZE, "%x\n", wdt->param.fw_id);
899+
return sysfs_emit(buf, "%x\n", wdt->param.fw_id);
900900
}
901901

902902
static ssize_t plat_id_show(struct device *dev,
@@ -905,7 +905,7 @@ static ssize_t plat_id_show(struct device *dev,
905905
struct i2c_client *client = to_i2c_client(dev);
906906
struct wdt87xx_data *wdt = i2c_get_clientdata(client);
907907

908-
return scnprintf(buf, PAGE_SIZE, "%x\n", wdt->param.plat_id);
908+
return sysfs_emit(buf, "%x\n", wdt->param.plat_id);
909909
}
910910

911911
static ssize_t update_config_store(struct device *dev,

0 commit comments

Comments
 (0)