Input: touchscreen - use sysfs_emit[_at]() instead of scnprintf()
authorye xingchen <ye.xingchen@zte.com.cn>
Wed, 13 Dec 2023 05:53:40 +0000 (21:53 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 14 Dec 2023 05:26:11 +0000 (21:26 -0800)
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>
drivers/input/touchscreen/atmel_mxt_ts.c
drivers/input/touchscreen/edt-ft5x06.c
drivers/input/touchscreen/hideep.c
drivers/input/touchscreen/hycon-hy46xx.c
drivers/input/touchscreen/ilitek_ts_i2c.c
drivers/input/touchscreen/iqs5xx.c
drivers/input/touchscreen/iqs7211.c
drivers/input/touchscreen/melfas_mip4.c
drivers/input/touchscreen/usbtouchscreen.c
drivers/input/touchscreen/wdt87xx_i2c.c

index 20094b9899f093671ed95a1db0a8551449ff3cbb..05dcacf7061b2b29232ae65e00bcabcbc5b44492 100644 (file)
@@ -2818,8 +2818,8 @@ static ssize_t mxt_fw_version_show(struct device *dev,
 {
        struct mxt_data *data = dev_get_drvdata(dev);
        struct mxt_info *info = data->info;
-       return scnprintf(buf, PAGE_SIZE, "%u.%u.%02X\n",
-                        info->version >> 4, info->version & 0xf, info->build);
+       return sysfs_emit(buf, "%u.%u.%02X\n",
+                         info->version >> 4, info->version & 0xf, info->build);
 }
 
 /* Hardware Version is returned as FamilyID.VariantID */
@@ -2828,8 +2828,7 @@ static ssize_t mxt_hw_version_show(struct device *dev,
 {
        struct mxt_data *data = dev_get_drvdata(dev);
        struct mxt_info *info = data->info;
-       return scnprintf(buf, PAGE_SIZE, "%u.%u\n",
-                        info->family_id, info->variant_id);
+       return sysfs_emit(buf, "%u.%u\n", info->family_id, info->variant_id);
 }
 
 static ssize_t mxt_show_instance(char *buf, int count,
@@ -2839,19 +2838,18 @@ static ssize_t mxt_show_instance(char *buf, int count,
        int i;
 
        if (mxt_obj_instances(object) > 1)
-               count += scnprintf(buf + count, PAGE_SIZE - count,
-                                  "Instance %u\n", instance);
+               count += sysfs_emit_at(buf, count, "Instance %u\n", instance);
 
        for (i = 0; i < mxt_obj_size(object); i++)
-               count += scnprintf(buf + count, PAGE_SIZE - count,
-                               "\t[%2u]: %02x (%d)\n", i, val[i], val[i]);
-       count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
+               count += sysfs_emit_at(buf, count, "\t[%2u]: %02x (%d)\n",
+                                      i, val[i], val[i]);
+       count += sysfs_emit_at(buf, count, "\n");
 
        return count;
 }
 
 static ssize_t mxt_object_show(struct device *dev,
-                                   struct device_attribute *attr, char *buf)
+                              struct device_attribute *attr, char *buf)
 {
        struct mxt_data *data = dev_get_drvdata(dev);
        struct mxt_object *object;
@@ -2872,8 +2870,7 @@ static ssize_t mxt_object_show(struct device *dev,
                if (!mxt_object_readable(object->type))
                        continue;
 
-               count += scnprintf(buf + count, PAGE_SIZE - count,
-                               "T%u:\n", object->type);
+               count += sysfs_emit_at(buf, count, "T%u:\n", object->type);
 
                for (j = 0; j < mxt_obj_instances(object); j++) {
                        u16 size = mxt_obj_size(object);
index 3e102bcc4a1c7120428ca4c8a40d396797ae9980..2a1db1134476656e8148dd963d68f72de7d57d55 100644 (file)
@@ -431,7 +431,7 @@ static ssize_t edt_ft5x06_setting_show(struct device *dev,
                *field = val;
        }
 
-       count = scnprintf(buf, PAGE_SIZE, "%d\n", val);
+       count = sysfs_emit(buf, "%d\n", val);
 out:
        mutex_unlock(&tsdata->mutex);
        return error ?: count;
index 0f58258306bfc594e84625f51e56cf7cd963615d..eae90676f4e551b67b2d8565665e86ce94ee74d7 100644 (file)
@@ -928,8 +928,7 @@ static ssize_t hideep_fw_version_show(struct device *dev,
        ssize_t len;
 
        mutex_lock(&ts->dev_mutex);
-       len = scnprintf(buf, PAGE_SIZE, "%04x\n",
-                       be16_to_cpu(ts->dwz_info.release_ver));
+       len = sysfs_emit(buf, "%04x\n", be16_to_cpu(ts->dwz_info.release_ver));
        mutex_unlock(&ts->dev_mutex);
 
        return len;
@@ -943,8 +942,7 @@ static ssize_t hideep_product_id_show(struct device *dev,
        ssize_t len;
 
        mutex_lock(&ts->dev_mutex);
-       len = scnprintf(buf, PAGE_SIZE, "%04x\n",
-                       be16_to_cpu(ts->dwz_info.product_id));
+       len = sysfs_emit(buf, "%04x\n", be16_to_cpu(ts->dwz_info.product_id));
        mutex_unlock(&ts->dev_mutex);
 
        return len;
index d0f257989fd6b728091ff3ee1add1d00777507de..2e01d87977c168ff618220aceaa02da0a132e59a 100644 (file)
@@ -202,7 +202,7 @@ static ssize_t hycon_hy46xx_setting_show(struct device *dev,
                *field = val;
        }
 
-       count = scnprintf(buf, PAGE_SIZE, "%d\n", val);
+       count = sysfs_emit(buf, "%d\n", val);
 
 out:
        mutex_unlock(&tsdata->mutex);
index 90c4934e750a3a3dda59e0688388f8d1f0dcf4b4..fc4e39b6651a4919bea885c5971a04c5dadeeb7f 100644 (file)
@@ -512,12 +512,12 @@ static ssize_t firmware_version_show(struct device *dev,
        struct i2c_client *client = to_i2c_client(dev);
        struct ilitek_ts_data *ts = i2c_get_clientdata(client);
 
-       return scnprintf(buf, PAGE_SIZE,
-                        "fw version: [%02X%02X.%02X%02X.%02X%02X.%02X%02X]\n",
-                        ts->firmware_ver[0], ts->firmware_ver[1],
-                        ts->firmware_ver[2], ts->firmware_ver[3],
-                        ts->firmware_ver[4], ts->firmware_ver[5],
-                        ts->firmware_ver[6], ts->firmware_ver[7]);
+       return sysfs_emit(buf,
+                         "fw version: [%02X%02X.%02X%02X.%02X%02X.%02X%02X]\n",
+                         ts->firmware_ver[0], ts->firmware_ver[1],
+                         ts->firmware_ver[2], ts->firmware_ver[3],
+                         ts->firmware_ver[4], ts->firmware_ver[5],
+                         ts->firmware_ver[6], ts->firmware_ver[7]);
 }
 static DEVICE_ATTR_RO(firmware_version);
 
@@ -527,8 +527,8 @@ static ssize_t product_id_show(struct device *dev,
        struct i2c_client *client = to_i2c_client(dev);
        struct ilitek_ts_data *ts = i2c_get_clientdata(client);
 
-       return scnprintf(buf, PAGE_SIZE, "product id: [%04X], module: [%s]\n",
-                        ts->mcu_ver, ts->product_id);
+       return sysfs_emit(buf, "product id: [%04X], module: [%s]\n",
+                         ts->mcu_ver, ts->product_id);
 }
 static DEVICE_ATTR_RO(product_id);
 
index a3f4fb85bee58bf1e5f73861bd59637eed4e565f..4d226118f3cc2986efd2a8efce6484733c7dc206 100644 (file)
@@ -943,12 +943,12 @@ static ssize_t fw_info_show(struct device *dev,
        if (!iqs5xx->dev_id_info.bl_status)
                return -ENODATA;
 
-       return scnprintf(buf, PAGE_SIZE, "%u.%u.%u.%u:%u.%u\n",
-                        be16_to_cpu(iqs5xx->dev_id_info.prod_num),
-                        be16_to_cpu(iqs5xx->dev_id_info.proj_num),
-                        iqs5xx->dev_id_info.major_ver,
-                        iqs5xx->dev_id_info.minor_ver,
-                        iqs5xx->exp_file[0], iqs5xx->exp_file[1]);
+       return sysfs_emit(buf, "%u.%u.%u.%u:%u.%u\n",
+                         be16_to_cpu(iqs5xx->dev_id_info.prod_num),
+                         be16_to_cpu(iqs5xx->dev_id_info.proj_num),
+                         iqs5xx->dev_id_info.major_ver,
+                         iqs5xx->dev_id_info.minor_ver,
+                         iqs5xx->exp_file[0], iqs5xx->exp_file[1]);
 }
 
 static DEVICE_ATTR_WO(fw_file);
index dc084f873762005b3c129cdf154f1feaa5b6758d..f0a56cde899e48054d5aaf6ec3daef02104fa6c5 100644 (file)
@@ -2401,12 +2401,12 @@ static ssize_t fw_info_show(struct device *dev,
 {
        struct iqs7211_private *iqs7211 = dev_get_drvdata(dev);
 
-       return scnprintf(buf, PAGE_SIZE, "%u.%u.%u.%u:%u.%u\n",
-                        le16_to_cpu(iqs7211->ver_info.prod_num),
-                        le32_to_cpu(iqs7211->ver_info.patch),
-                        le16_to_cpu(iqs7211->ver_info.major),
-                        le16_to_cpu(iqs7211->ver_info.minor),
-                        iqs7211->exp_file[1], iqs7211->exp_file[0]);
+       return sysfs_emit(buf, "%u.%u.%u.%u:%u.%u\n",
+                         le16_to_cpu(iqs7211->ver_info.prod_num),
+                         le32_to_cpu(iqs7211->ver_info.patch),
+                         le16_to_cpu(iqs7211->ver_info.major),
+                         le16_to_cpu(iqs7211->ver_info.minor),
+                         iqs7211->exp_file[1], iqs7211->exp_file[0]);
 }
 
 static DEVICE_ATTR_RO(fw_info);
index aa325486f61825e2e30d36a432fffafd8ddb2cbb..78e1c63e530e06b4cf86801a3feef0a02785879f 100644 (file)
@@ -1336,9 +1336,9 @@ static ssize_t mip4_sysfs_read_fw_version(struct device *dev,
        /* Take lock to prevent racing with firmware update */
        mutex_lock(&ts->input->mutex);
 
-       count = snprintf(buf, PAGE_SIZE, "%04X %04X %04X %04X\n",
-                        ts->fw_version.boot, ts->fw_version.core,
-                        ts->fw_version.app, ts->fw_version.param);
+       count = sysfs_emit(buf, "%04X %04X %04X %04X\n",
+                          ts->fw_version.boot, ts->fw_version.core,
+                          ts->fw_version.app, ts->fw_version.param);
 
        mutex_unlock(&ts->input->mutex);
 
@@ -1362,8 +1362,8 @@ static ssize_t mip4_sysfs_read_hw_version(struct device *dev,
         * product_name shows the name or version of the hardware
         * paired with current firmware in the chip.
         */
-       count = snprintf(buf, PAGE_SIZE, "%.*s\n",
-                        (int)sizeof(ts->product_name), ts->product_name);
+       count = sysfs_emit(buf, "%.*s\n",
+                          (int)sizeof(ts->product_name), ts->product_name);
 
        mutex_unlock(&ts->input->mutex);
 
@@ -1382,7 +1382,7 @@ static ssize_t mip4_sysfs_read_product_id(struct device *dev,
 
        mutex_lock(&ts->input->mutex);
 
-       count = snprintf(buf, PAGE_SIZE, "%04X\n", ts->product_id);
+       count = sysfs_emit(buf, "%04X\n", ts->product_id);
 
        mutex_unlock(&ts->input->mutex);
 
@@ -1401,8 +1401,8 @@ static ssize_t mip4_sysfs_read_ic_name(struct device *dev,
 
        mutex_lock(&ts->input->mutex);
 
-       count = snprintf(buf, PAGE_SIZE, "%.*s\n",
-                        (int)sizeof(ts->ic_name), ts->ic_name);
+       count = sysfs_emit(buf, "%.*s\n",
+                          (int)sizeof(ts->ic_name), ts->ic_name);
 
        mutex_unlock(&ts->input->mutex);
 
index d6d04b9f04fc1cb272c67f3968556d1e8024cd08..60354ebc7242493ed7625db8e647101b28142748 100644 (file)
@@ -456,8 +456,8 @@ static ssize_t mtouch_firmware_rev_show(struct device *dev,
        struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
        struct mtouch_priv *priv = usbtouch->priv;
 
-       return scnprintf(output, PAGE_SIZE, "%1x.%1x\n",
-                        priv->fw_rev_major, priv->fw_rev_minor);
+       return sysfs_emit(output, "%1x.%1x\n",
+                         priv->fw_rev_major, priv->fw_rev_minor);
 }
 static DEVICE_ATTR(firmware_rev, 0444, mtouch_firmware_rev_show, NULL);
 
index 128341a6696bc01943c1b7eb7eb42ecf93417183..32c7be54434cf26444eef7b8a3a34277c40049bd 100644 (file)
@@ -887,7 +887,7 @@ static ssize_t config_csum_show(struct device *dev,
        cfg_csum = wdt->param.xmls_id1;
        cfg_csum = (cfg_csum << 16) | wdt->param.xmls_id2;
 
-       return scnprintf(buf, PAGE_SIZE, "%x\n", cfg_csum);
+       return sysfs_emit(buf, "%x\n", cfg_csum);
 }
 
 static ssize_t fw_version_show(struct device *dev,
@@ -896,7 +896,7 @@ static ssize_t fw_version_show(struct device *dev,
        struct i2c_client *client = to_i2c_client(dev);
        struct wdt87xx_data *wdt = i2c_get_clientdata(client);
 
-       return scnprintf(buf, PAGE_SIZE, "%x\n", wdt->param.fw_id);
+       return sysfs_emit(buf, "%x\n", wdt->param.fw_id);
 }
 
 static ssize_t plat_id_show(struct device *dev,
@@ -905,7 +905,7 @@ static ssize_t plat_id_show(struct device *dev,
        struct i2c_client *client = to_i2c_client(dev);
        struct wdt87xx_data *wdt = i2c_get_clientdata(client);
 
-       return scnprintf(buf, PAGE_SIZE, "%x\n", wdt->param.plat_id);
+       return sysfs_emit(buf, "%x\n", wdt->param.plat_id);
 }
 
 static ssize_t update_config_store(struct device *dev,