Commit e50389f2 authored by ye xingchen's avatar ye xingchen Committed by Dmitry Torokhov

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: default avatarye xingchen <ye.xingchen@zte.com.cn>
Acked-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: default avatarOliver Graute <oliver.graute@kococonnector.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 1864a200
...@@ -2818,8 +2818,8 @@ static ssize_t mxt_fw_version_show(struct device *dev, ...@@ -2818,8 +2818,8 @@ static ssize_t mxt_fw_version_show(struct device *dev,
{ {
struct mxt_data *data = dev_get_drvdata(dev); struct mxt_data *data = dev_get_drvdata(dev);
struct mxt_info *info = data->info; struct mxt_info *info = data->info;
return scnprintf(buf, PAGE_SIZE, "%u.%u.%02X\n", return sysfs_emit(buf, "%u.%u.%02X\n",
info->version >> 4, info->version & 0xf, info->build); info->version >> 4, info->version & 0xf, info->build);
} }
/* Hardware Version is returned as FamilyID.VariantID */ /* Hardware Version is returned as FamilyID.VariantID */
...@@ -2828,8 +2828,7 @@ static ssize_t mxt_hw_version_show(struct device *dev, ...@@ -2828,8 +2828,7 @@ static ssize_t mxt_hw_version_show(struct device *dev,
{ {
struct mxt_data *data = dev_get_drvdata(dev); struct mxt_data *data = dev_get_drvdata(dev);
struct mxt_info *info = data->info; struct mxt_info *info = data->info;
return scnprintf(buf, PAGE_SIZE, "%u.%u\n", return sysfs_emit(buf, "%u.%u\n", info->family_id, info->variant_id);
info->family_id, info->variant_id);
} }
static ssize_t mxt_show_instance(char *buf, int count, static ssize_t mxt_show_instance(char *buf, int count,
...@@ -2839,19 +2838,18 @@ 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; int i;
if (mxt_obj_instances(object) > 1) if (mxt_obj_instances(object) > 1)
count += scnprintf(buf + count, PAGE_SIZE - count, count += sysfs_emit_at(buf, count, "Instance %u\n", instance);
"Instance %u\n", instance);
for (i = 0; i < mxt_obj_size(object); i++) for (i = 0; i < mxt_obj_size(object); i++)
count += scnprintf(buf + count, PAGE_SIZE - count, count += sysfs_emit_at(buf, count, "\t[%2u]: %02x (%d)\n",
"\t[%2u]: %02x (%d)\n", i, val[i], val[i]); i, val[i], val[i]);
count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); count += sysfs_emit_at(buf, count, "\n");
return count; return count;
} }
static ssize_t mxt_object_show(struct device *dev, 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_data *data = dev_get_drvdata(dev);
struct mxt_object *object; struct mxt_object *object;
...@@ -2872,8 +2870,7 @@ static ssize_t mxt_object_show(struct device *dev, ...@@ -2872,8 +2870,7 @@ static ssize_t mxt_object_show(struct device *dev,
if (!mxt_object_readable(object->type)) if (!mxt_object_readable(object->type))
continue; continue;
count += scnprintf(buf + count, PAGE_SIZE - count, count += sysfs_emit_at(buf, count, "T%u:\n", object->type);
"T%u:\n", object->type);
for (j = 0; j < mxt_obj_instances(object); j++) { for (j = 0; j < mxt_obj_instances(object); j++) {
u16 size = mxt_obj_size(object); u16 size = mxt_obj_size(object);
......
...@@ -431,7 +431,7 @@ static ssize_t edt_ft5x06_setting_show(struct device *dev, ...@@ -431,7 +431,7 @@ static ssize_t edt_ft5x06_setting_show(struct device *dev,
*field = val; *field = val;
} }
count = scnprintf(buf, PAGE_SIZE, "%d\n", val); count = sysfs_emit(buf, "%d\n", val);
out: out:
mutex_unlock(&tsdata->mutex); mutex_unlock(&tsdata->mutex);
return error ?: count; return error ?: count;
......
...@@ -928,8 +928,7 @@ static ssize_t hideep_fw_version_show(struct device *dev, ...@@ -928,8 +928,7 @@ static ssize_t hideep_fw_version_show(struct device *dev,
ssize_t len; ssize_t len;
mutex_lock(&ts->dev_mutex); mutex_lock(&ts->dev_mutex);
len = scnprintf(buf, PAGE_SIZE, "%04x\n", len = sysfs_emit(buf, "%04x\n", be16_to_cpu(ts->dwz_info.release_ver));
be16_to_cpu(ts->dwz_info.release_ver));
mutex_unlock(&ts->dev_mutex); mutex_unlock(&ts->dev_mutex);
return len; return len;
...@@ -943,8 +942,7 @@ static ssize_t hideep_product_id_show(struct device *dev, ...@@ -943,8 +942,7 @@ static ssize_t hideep_product_id_show(struct device *dev,
ssize_t len; ssize_t len;
mutex_lock(&ts->dev_mutex); mutex_lock(&ts->dev_mutex);
len = scnprintf(buf, PAGE_SIZE, "%04x\n", len = sysfs_emit(buf, "%04x\n", be16_to_cpu(ts->dwz_info.product_id));
be16_to_cpu(ts->dwz_info.product_id));
mutex_unlock(&ts->dev_mutex); mutex_unlock(&ts->dev_mutex);
return len; return len;
......
...@@ -202,7 +202,7 @@ static ssize_t hycon_hy46xx_setting_show(struct device *dev, ...@@ -202,7 +202,7 @@ static ssize_t hycon_hy46xx_setting_show(struct device *dev,
*field = val; *field = val;
} }
count = scnprintf(buf, PAGE_SIZE, "%d\n", val); count = sysfs_emit(buf, "%d\n", val);
out: out:
mutex_unlock(&tsdata->mutex); mutex_unlock(&tsdata->mutex);
......
...@@ -512,12 +512,12 @@ static ssize_t firmware_version_show(struct device *dev, ...@@ -512,12 +512,12 @@ static ssize_t firmware_version_show(struct device *dev,
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct ilitek_ts_data *ts = i2c_get_clientdata(client); struct ilitek_ts_data *ts = i2c_get_clientdata(client);
return scnprintf(buf, PAGE_SIZE, return sysfs_emit(buf,
"fw version: [%02X%02X.%02X%02X.%02X%02X.%02X%02X]\n", "fw version: [%02X%02X.%02X%02X.%02X%02X.%02X%02X]\n",
ts->firmware_ver[0], ts->firmware_ver[1], ts->firmware_ver[0], ts->firmware_ver[1],
ts->firmware_ver[2], ts->firmware_ver[3], ts->firmware_ver[2], ts->firmware_ver[3],
ts->firmware_ver[4], ts->firmware_ver[5], ts->firmware_ver[4], ts->firmware_ver[5],
ts->firmware_ver[6], ts->firmware_ver[7]); ts->firmware_ver[6], ts->firmware_ver[7]);
} }
static DEVICE_ATTR_RO(firmware_version); static DEVICE_ATTR_RO(firmware_version);
...@@ -527,8 +527,8 @@ static ssize_t product_id_show(struct device *dev, ...@@ -527,8 +527,8 @@ static ssize_t product_id_show(struct device *dev,
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct ilitek_ts_data *ts = i2c_get_clientdata(client); struct ilitek_ts_data *ts = i2c_get_clientdata(client);
return scnprintf(buf, PAGE_SIZE, "product id: [%04X], module: [%s]\n", return sysfs_emit(buf, "product id: [%04X], module: [%s]\n",
ts->mcu_ver, ts->product_id); ts->mcu_ver, ts->product_id);
} }
static DEVICE_ATTR_RO(product_id); static DEVICE_ATTR_RO(product_id);
......
...@@ -943,12 +943,12 @@ static ssize_t fw_info_show(struct device *dev, ...@@ -943,12 +943,12 @@ static ssize_t fw_info_show(struct device *dev,
if (!iqs5xx->dev_id_info.bl_status) if (!iqs5xx->dev_id_info.bl_status)
return -ENODATA; return -ENODATA;
return scnprintf(buf, PAGE_SIZE, "%u.%u.%u.%u:%u.%u\n", 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.prod_num),
be16_to_cpu(iqs5xx->dev_id_info.proj_num), be16_to_cpu(iqs5xx->dev_id_info.proj_num),
iqs5xx->dev_id_info.major_ver, iqs5xx->dev_id_info.major_ver,
iqs5xx->dev_id_info.minor_ver, iqs5xx->dev_id_info.minor_ver,
iqs5xx->exp_file[0], iqs5xx->exp_file[1]); iqs5xx->exp_file[0], iqs5xx->exp_file[1]);
} }
static DEVICE_ATTR_WO(fw_file); static DEVICE_ATTR_WO(fw_file);
......
...@@ -2401,12 +2401,12 @@ static ssize_t fw_info_show(struct device *dev, ...@@ -2401,12 +2401,12 @@ static ssize_t fw_info_show(struct device *dev,
{ {
struct iqs7211_private *iqs7211 = dev_get_drvdata(dev); struct iqs7211_private *iqs7211 = dev_get_drvdata(dev);
return scnprintf(buf, PAGE_SIZE, "%u.%u.%u.%u:%u.%u\n", return sysfs_emit(buf, "%u.%u.%u.%u:%u.%u\n",
le16_to_cpu(iqs7211->ver_info.prod_num), le16_to_cpu(iqs7211->ver_info.prod_num),
le32_to_cpu(iqs7211->ver_info.patch), le32_to_cpu(iqs7211->ver_info.patch),
le16_to_cpu(iqs7211->ver_info.major), le16_to_cpu(iqs7211->ver_info.major),
le16_to_cpu(iqs7211->ver_info.minor), le16_to_cpu(iqs7211->ver_info.minor),
iqs7211->exp_file[1], iqs7211->exp_file[0]); iqs7211->exp_file[1], iqs7211->exp_file[0]);
} }
static DEVICE_ATTR_RO(fw_info); static DEVICE_ATTR_RO(fw_info);
......
...@@ -1336,9 +1336,9 @@ static ssize_t mip4_sysfs_read_fw_version(struct device *dev, ...@@ -1336,9 +1336,9 @@ static ssize_t mip4_sysfs_read_fw_version(struct device *dev,
/* Take lock to prevent racing with firmware update */ /* Take lock to prevent racing with firmware update */
mutex_lock(&ts->input->mutex); mutex_lock(&ts->input->mutex);
count = snprintf(buf, PAGE_SIZE, "%04X %04X %04X %04X\n", count = sysfs_emit(buf, "%04X %04X %04X %04X\n",
ts->fw_version.boot, ts->fw_version.core, ts->fw_version.boot, ts->fw_version.core,
ts->fw_version.app, ts->fw_version.param); ts->fw_version.app, ts->fw_version.param);
mutex_unlock(&ts->input->mutex); mutex_unlock(&ts->input->mutex);
...@@ -1362,8 +1362,8 @@ static ssize_t mip4_sysfs_read_hw_version(struct device *dev, ...@@ -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 * product_name shows the name or version of the hardware
* paired with current firmware in the chip. * paired with current firmware in the chip.
*/ */
count = snprintf(buf, PAGE_SIZE, "%.*s\n", count = sysfs_emit(buf, "%.*s\n",
(int)sizeof(ts->product_name), ts->product_name); (int)sizeof(ts->product_name), ts->product_name);
mutex_unlock(&ts->input->mutex); mutex_unlock(&ts->input->mutex);
...@@ -1382,7 +1382,7 @@ static ssize_t mip4_sysfs_read_product_id(struct device *dev, ...@@ -1382,7 +1382,7 @@ static ssize_t mip4_sysfs_read_product_id(struct device *dev,
mutex_lock(&ts->input->mutex); 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); mutex_unlock(&ts->input->mutex);
...@@ -1401,8 +1401,8 @@ static ssize_t mip4_sysfs_read_ic_name(struct device *dev, ...@@ -1401,8 +1401,8 @@ static ssize_t mip4_sysfs_read_ic_name(struct device *dev,
mutex_lock(&ts->input->mutex); mutex_lock(&ts->input->mutex);
count = snprintf(buf, PAGE_SIZE, "%.*s\n", count = sysfs_emit(buf, "%.*s\n",
(int)sizeof(ts->ic_name), ts->ic_name); (int)sizeof(ts->ic_name), ts->ic_name);
mutex_unlock(&ts->input->mutex); mutex_unlock(&ts->input->mutex);
......
...@@ -456,8 +456,8 @@ static ssize_t mtouch_firmware_rev_show(struct device *dev, ...@@ -456,8 +456,8 @@ static ssize_t mtouch_firmware_rev_show(struct device *dev,
struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
struct mtouch_priv *priv = usbtouch->priv; struct mtouch_priv *priv = usbtouch->priv;
return scnprintf(output, PAGE_SIZE, "%1x.%1x\n", return sysfs_emit(output, "%1x.%1x\n",
priv->fw_rev_major, priv->fw_rev_minor); priv->fw_rev_major, priv->fw_rev_minor);
} }
static DEVICE_ATTR(firmware_rev, 0444, mtouch_firmware_rev_show, NULL); static DEVICE_ATTR(firmware_rev, 0444, mtouch_firmware_rev_show, NULL);
......
...@@ -887,7 +887,7 @@ static ssize_t config_csum_show(struct device *dev, ...@@ -887,7 +887,7 @@ static ssize_t config_csum_show(struct device *dev,
cfg_csum = wdt->param.xmls_id1; cfg_csum = wdt->param.xmls_id1;
cfg_csum = (cfg_csum << 16) | wdt->param.xmls_id2; 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, static ssize_t fw_version_show(struct device *dev,
...@@ -896,7 +896,7 @@ 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 i2c_client *client = to_i2c_client(dev);
struct wdt87xx_data *wdt = i2c_get_clientdata(client); 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, static ssize_t plat_id_show(struct device *dev,
...@@ -905,7 +905,7 @@ 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 i2c_client *client = to_i2c_client(dev);
struct wdt87xx_data *wdt = i2c_get_clientdata(client); 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, static ssize_t update_config_store(struct device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment