Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

ye xingchen and committed by
Dmitry Torokhov
e50389f2 1864a200

+46 -51
+9 -12
drivers/input/touchscreen/atmel_mxt_ts.c
··· 2818 2818 { 2819 2819 struct mxt_data *data = dev_get_drvdata(dev); 2820 2820 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); 2823 2823 } 2824 2824 2825 2825 /* Hardware Version is returned as FamilyID.VariantID */ ··· 2828 2828 { 2829 2829 struct mxt_data *data = dev_get_drvdata(dev); 2830 2830 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); 2833 2832 } 2834 2833 2835 2834 static ssize_t mxt_show_instance(char *buf, int count, ··· 2838 2839 int i; 2839 2840 2840 2841 if (mxt_obj_instances(object) > 1) 2841 - count += scnprintf(buf + count, PAGE_SIZE - count, 2842 - "Instance %u\n", instance); 2842 + count += sysfs_emit_at(buf, count, "Instance %u\n", instance); 2843 2843 2844 2844 for (i = 0; i < mxt_obj_size(object); i++) 2845 - count += scnprintf(buf + count, PAGE_SIZE - count, 2846 - "\t[%2u]: %02x (%d)\n", i, val[i], val[i]); 2847 - count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); 2845 + count += sysfs_emit_at(buf, count, "\t[%2u]: %02x (%d)\n", 2846 + i, val[i], val[i]); 2847 + count += sysfs_emit_at(buf, count, "\n"); 2848 2848 2849 2849 return count; 2850 2850 } 2851 2851 2852 2852 static ssize_t mxt_object_show(struct device *dev, 2853 - struct device_attribute *attr, char *buf) 2853 + struct device_attribute *attr, char *buf) 2854 2854 { 2855 2855 struct mxt_data *data = dev_get_drvdata(dev); 2856 2856 struct mxt_object *object; ··· 2870 2872 if (!mxt_object_readable(object->type)) 2871 2873 continue; 2872 2874 2873 - count += scnprintf(buf + count, PAGE_SIZE - count, 2874 - "T%u:\n", object->type); 2875 + count += sysfs_emit_at(buf, count, "T%u:\n", object->type); 2875 2876 2876 2877 for (j = 0; j < mxt_obj_instances(object); j++) { 2877 2878 u16 size = mxt_obj_size(object);
+1 -1
drivers/input/touchscreen/edt-ft5x06.c
··· 431 431 *field = val; 432 432 } 433 433 434 - count = scnprintf(buf, PAGE_SIZE, "%d\n", val); 434 + count = sysfs_emit(buf, "%d\n", val); 435 435 out: 436 436 mutex_unlock(&tsdata->mutex); 437 437 return error ?: count;
+2 -4
drivers/input/touchscreen/hideep.c
··· 928 928 ssize_t len; 929 929 930 930 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)); 933 932 mutex_unlock(&ts->dev_mutex); 934 933 935 934 return len; ··· 942 943 ssize_t len; 943 944 944 945 mutex_lock(&ts->dev_mutex); 945 - len = scnprintf(buf, PAGE_SIZE, "%04x\n", 946 - be16_to_cpu(ts->dwz_info.product_id)); 946 + len = sysfs_emit(buf, "%04x\n", be16_to_cpu(ts->dwz_info.product_id)); 947 947 mutex_unlock(&ts->dev_mutex); 948 948 949 949 return len;
+1 -1
drivers/input/touchscreen/hycon-hy46xx.c
··· 202 202 *field = val; 203 203 } 204 204 205 - count = scnprintf(buf, PAGE_SIZE, "%d\n", val); 205 + count = sysfs_emit(buf, "%d\n", val); 206 206 207 207 out: 208 208 mutex_unlock(&tsdata->mutex);
+8 -8
drivers/input/touchscreen/ilitek_ts_i2c.c
··· 512 512 struct i2c_client *client = to_i2c_client(dev); 513 513 struct ilitek_ts_data *ts = i2c_get_clientdata(client); 514 514 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]); 521 521 } 522 522 static DEVICE_ATTR_RO(firmware_version); 523 523 ··· 527 527 struct i2c_client *client = to_i2c_client(dev); 528 528 struct ilitek_ts_data *ts = i2c_get_clientdata(client); 529 529 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); 532 532 } 533 533 static DEVICE_ATTR_RO(product_id); 534 534
+6 -6
drivers/input/touchscreen/iqs5xx.c
··· 943 943 if (!iqs5xx->dev_id_info.bl_status) 944 944 return -ENODATA; 945 945 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]); 952 952 } 953 953 954 954 static DEVICE_ATTR_WO(fw_file);
+6 -6
drivers/input/touchscreen/iqs7211.c
··· 2401 2401 { 2402 2402 struct iqs7211_private *iqs7211 = dev_get_drvdata(dev); 2403 2403 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]); 2410 2410 } 2411 2411 2412 2412 static DEVICE_ATTR_RO(fw_info);
+8 -8
drivers/input/touchscreen/melfas_mip4.c
··· 1336 1336 /* Take lock to prevent racing with firmware update */ 1337 1337 mutex_lock(&ts->input->mutex); 1338 1338 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); 1342 1342 1343 1343 mutex_unlock(&ts->input->mutex); 1344 1344 ··· 1362 1362 * product_name shows the name or version of the hardware 1363 1363 * paired with current firmware in the chip. 1364 1364 */ 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); 1367 1367 1368 1368 mutex_unlock(&ts->input->mutex); 1369 1369 ··· 1382 1382 1383 1383 mutex_lock(&ts->input->mutex); 1384 1384 1385 - count = snprintf(buf, PAGE_SIZE, "%04X\n", ts->product_id); 1385 + count = sysfs_emit(buf, "%04X\n", ts->product_id); 1386 1386 1387 1387 mutex_unlock(&ts->input->mutex); 1388 1388 ··· 1401 1401 1402 1402 mutex_lock(&ts->input->mutex); 1403 1403 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); 1406 1406 1407 1407 mutex_unlock(&ts->input->mutex); 1408 1408
+2 -2
drivers/input/touchscreen/usbtouchscreen.c
··· 456 456 struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); 457 457 struct mtouch_priv *priv = usbtouch->priv; 458 458 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); 461 461 } 462 462 static DEVICE_ATTR(firmware_rev, 0444, mtouch_firmware_rev_show, NULL); 463 463
+3 -3
drivers/input/touchscreen/wdt87xx_i2c.c
··· 887 887 cfg_csum = wdt->param.xmls_id1; 888 888 cfg_csum = (cfg_csum << 16) | wdt->param.xmls_id2; 889 889 890 - return scnprintf(buf, PAGE_SIZE, "%x\n", cfg_csum); 890 + return sysfs_emit(buf, "%x\n", cfg_csum); 891 891 } 892 892 893 893 static ssize_t fw_version_show(struct device *dev, ··· 896 896 struct i2c_client *client = to_i2c_client(dev); 897 897 struct wdt87xx_data *wdt = i2c_get_clientdata(client); 898 898 899 - return scnprintf(buf, PAGE_SIZE, "%x\n", wdt->param.fw_id); 899 + return sysfs_emit(buf, "%x\n", wdt->param.fw_id); 900 900 } 901 901 902 902 static ssize_t plat_id_show(struct device *dev, ··· 905 905 struct i2c_client *client = to_i2c_client(dev); 906 906 struct wdt87xx_data *wdt = i2c_get_clientdata(client); 907 907 908 - return scnprintf(buf, PAGE_SIZE, "%x\n", wdt->param.plat_id); 908 + return sysfs_emit(buf, "%x\n", wdt->param.plat_id); 909 909 } 910 910 911 911 static ssize_t update_config_store(struct device *dev,