Commit 4c47097f authored by Jiapeng Chong's avatar Jiapeng Chong Committed by Dmitry Torokhov

Input: aiptek - convert sysfs sprintf/snprintf family to sysfs_emit

Fix the following coccicheck warning:

./drivers/input/tablet/aiptek.c:1629:8-16: WARNING: use scnprintf or
sprintf.

Reported-by: Abaci Robot<abaci@linux.alibaba.com>
Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
Link: https://lore.kernel.org/r/1612419191-1078-1-git-send-email-jiapeng.chong@linux.alibaba.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 2896a27f
...@@ -1036,9 +1036,9 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr ...@@ -1036,9 +1036,9 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%dx%d\n", return sysfs_emit(buf, "%dx%d\n",
input_abs_get_max(aiptek->inputdev, ABS_X) + 1, input_abs_get_max(aiptek->inputdev, ABS_X) + 1,
input_abs_get_max(aiptek->inputdev, ABS_Y) + 1); input_abs_get_max(aiptek->inputdev, ABS_Y) + 1);
} }
/* These structs define the sysfs files, param #1 is the name of the /* These structs define the sysfs files, param #1 is the name of the
...@@ -1064,9 +1064,8 @@ static ssize_t show_tabletPointerMode(struct device *dev, struct device_attribut ...@@ -1064,9 +1064,8 @@ static ssize_t show_tabletPointerMode(struct device *dev, struct device_attribut
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", return sysfs_emit(buf, "%s\n", map_val_to_str(pointer_mode_map,
map_val_to_str(pointer_mode_map, aiptek->curSetting.pointerMode));
aiptek->curSetting.pointerMode));
} }
static ssize_t static ssize_t
...@@ -1101,9 +1100,8 @@ static ssize_t show_tabletCoordinateMode(struct device *dev, struct device_attri ...@@ -1101,9 +1100,8 @@ static ssize_t show_tabletCoordinateMode(struct device *dev, struct device_attri
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", return sysfs_emit(buf, "%s\n", map_val_to_str(coordinate_mode_map,
map_val_to_str(coordinate_mode_map, aiptek->curSetting.coordinateMode));
aiptek->curSetting.coordinateMode));
} }
static ssize_t static ssize_t
...@@ -1143,9 +1141,8 @@ static ssize_t show_tabletToolMode(struct device *dev, struct device_attribute * ...@@ -1143,9 +1141,8 @@ static ssize_t show_tabletToolMode(struct device *dev, struct device_attribute *
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", return sysfs_emit(buf, "%s\n", map_val_to_str(tool_mode_map,
map_val_to_str(tool_mode_map, aiptek->curSetting.toolMode));
aiptek->curSetting.toolMode));
} }
static ssize_t static ssize_t
...@@ -1174,10 +1171,9 @@ static ssize_t show_tabletXtilt(struct device *dev, struct device_attribute *att ...@@ -1174,10 +1171,9 @@ static ssize_t show_tabletXtilt(struct device *dev, struct device_attribute *att
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek->curSetting.xTilt == AIPTEK_TILT_DISABLE) { if (aiptek->curSetting.xTilt == AIPTEK_TILT_DISABLE) {
return snprintf(buf, PAGE_SIZE, "disable\n"); return sysfs_emit(buf, "disable\n");
} else { } else {
return snprintf(buf, PAGE_SIZE, "%d\n", return sysfs_emit(buf, "%d\n", aiptek->curSetting.xTilt);
aiptek->curSetting.xTilt);
} }
} }
...@@ -1216,10 +1212,9 @@ static ssize_t show_tabletYtilt(struct device *dev, struct device_attribute *att ...@@ -1216,10 +1212,9 @@ static ssize_t show_tabletYtilt(struct device *dev, struct device_attribute *att
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek->curSetting.yTilt == AIPTEK_TILT_DISABLE) { if (aiptek->curSetting.yTilt == AIPTEK_TILT_DISABLE) {
return snprintf(buf, PAGE_SIZE, "disable\n"); return sysfs_emit(buf, "disable\n");
} else { } else {
return snprintf(buf, PAGE_SIZE, "%d\n", return sysfs_emit(buf, "%d\n", aiptek->curSetting.yTilt);
aiptek->curSetting.yTilt);
} }
} }
...@@ -1257,7 +1252,7 @@ static ssize_t show_tabletJitterDelay(struct device *dev, struct device_attribut ...@@ -1257,7 +1252,7 @@ static ssize_t show_tabletJitterDelay(struct device *dev, struct device_attribut
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.jitterDelay); return sysfs_emit(buf, "%d\n", aiptek->curSetting.jitterDelay);
} }
static ssize_t static ssize_t
...@@ -1286,8 +1281,7 @@ static ssize_t show_tabletProgrammableDelay(struct device *dev, struct device_at ...@@ -1286,8 +1281,7 @@ static ssize_t show_tabletProgrammableDelay(struct device *dev, struct device_at
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%d\n", return sysfs_emit(buf, "%d\n", aiptek->curSetting.programmableDelay);
aiptek->curSetting.programmableDelay);
} }
static ssize_t static ssize_t
...@@ -1316,7 +1310,7 @@ static ssize_t show_tabletEventsReceived(struct device *dev, struct device_attri ...@@ -1316,7 +1310,7 @@ static ssize_t show_tabletEventsReceived(struct device *dev, struct device_attri
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%ld\n", aiptek->eventCount); return sysfs_emit(buf, "%ld\n", aiptek->eventCount);
} }
static DEVICE_ATTR(event_count, S_IRUGO, show_tabletEventsReceived, NULL); static DEVICE_ATTR(event_count, S_IRUGO, show_tabletEventsReceived, NULL);
...@@ -1355,7 +1349,7 @@ static ssize_t show_tabletDiagnosticMessage(struct device *dev, struct device_at ...@@ -1355,7 +1349,7 @@ static ssize_t show_tabletDiagnosticMessage(struct device *dev, struct device_at
default: default:
return 0; return 0;
} }
return snprintf(buf, PAGE_SIZE, retMsg); return sysfs_emit(buf, retMsg);
} }
static DEVICE_ATTR(diagnostic, S_IRUGO, show_tabletDiagnosticMessage, NULL); static DEVICE_ATTR(diagnostic, S_IRUGO, show_tabletDiagnosticMessage, NULL);
...@@ -1375,9 +1369,8 @@ static ssize_t show_tabletStylusUpper(struct device *dev, struct device_attribut ...@@ -1375,9 +1369,8 @@ static ssize_t show_tabletStylusUpper(struct device *dev, struct device_attribut
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", return sysfs_emit(buf, "%s\n", map_val_to_str(stylus_button_map,
map_val_to_str(stylus_button_map, aiptek->curSetting.stylusButtonUpper));
aiptek->curSetting.stylusButtonUpper));
} }
static ssize_t static ssize_t
...@@ -1406,9 +1399,8 @@ static ssize_t show_tabletStylusLower(struct device *dev, struct device_attribut ...@@ -1406,9 +1399,8 @@ static ssize_t show_tabletStylusLower(struct device *dev, struct device_attribut
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", return sysfs_emit(buf, "%s\n", map_val_to_str(stylus_button_map,
map_val_to_str(stylus_button_map, aiptek->curSetting.stylusButtonLower));
aiptek->curSetting.stylusButtonLower));
} }
static ssize_t static ssize_t
...@@ -1444,9 +1436,8 @@ static ssize_t show_tabletMouseLeft(struct device *dev, struct device_attribute ...@@ -1444,9 +1436,8 @@ static ssize_t show_tabletMouseLeft(struct device *dev, struct device_attribute
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", return sysfs_emit(buf, "%s\n", map_val_to_str(mouse_button_map,
map_val_to_str(mouse_button_map, aiptek->curSetting.mouseButtonLeft));
aiptek->curSetting.mouseButtonLeft));
} }
static ssize_t static ssize_t
...@@ -1474,9 +1465,8 @@ static ssize_t show_tabletMouseMiddle(struct device *dev, struct device_attribut ...@@ -1474,9 +1465,8 @@ static ssize_t show_tabletMouseMiddle(struct device *dev, struct device_attribut
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", return sysfs_emit(buf, "%s\n", map_val_to_str(mouse_button_map,
map_val_to_str(mouse_button_map, aiptek->curSetting.mouseButtonMiddle));
aiptek->curSetting.mouseButtonMiddle));
} }
static ssize_t static ssize_t
...@@ -1504,9 +1494,8 @@ static ssize_t show_tabletMouseRight(struct device *dev, struct device_attribute ...@@ -1504,9 +1494,8 @@ static ssize_t show_tabletMouseRight(struct device *dev, struct device_attribute
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%s\n", return sysfs_emit(buf, "%s\n", map_val_to_str(mouse_button_map,
map_val_to_str(mouse_button_map, aiptek->curSetting.mouseButtonRight));
aiptek->curSetting.mouseButtonRight));
} }
static ssize_t static ssize_t
...@@ -1535,10 +1524,9 @@ static ssize_t show_tabletWheel(struct device *dev, struct device_attribute *att ...@@ -1535,10 +1524,9 @@ static ssize_t show_tabletWheel(struct device *dev, struct device_attribute *att
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
if (aiptek->curSetting.wheel == AIPTEK_WHEEL_DISABLE) { if (aiptek->curSetting.wheel == AIPTEK_WHEEL_DISABLE) {
return snprintf(buf, PAGE_SIZE, "disable\n"); return sysfs_emit(buf, "disable\n");
} else { } else {
return snprintf(buf, PAGE_SIZE, "%d\n", return sysfs_emit(buf, "%d\n", aiptek->curSetting.wheel);
aiptek->curSetting.wheel);
} }
} }
...@@ -1568,8 +1556,7 @@ static ssize_t show_tabletExecute(struct device *dev, struct device_attribute *a ...@@ -1568,8 +1556,7 @@ static ssize_t show_tabletExecute(struct device *dev, struct device_attribute *a
/* There is nothing useful to display, so a one-line manual /* There is nothing useful to display, so a one-line manual
* is in order... * is in order...
*/ */
return snprintf(buf, PAGE_SIZE, return sysfs_emit(buf, "Write anything to this file to program your tablet.\n");
"Write anything to this file to program your tablet.\n");
} }
static ssize_t static ssize_t
...@@ -1600,7 +1587,7 @@ static ssize_t show_tabletODMCode(struct device *dev, struct device_attribute *a ...@@ -1600,7 +1587,7 @@ static ssize_t show_tabletODMCode(struct device *dev, struct device_attribute *a
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.odmCode); return sysfs_emit(buf, "0x%04x\n", aiptek->features.odmCode);
} }
static DEVICE_ATTR(odm_code, S_IRUGO, show_tabletODMCode, NULL); static DEVICE_ATTR(odm_code, S_IRUGO, show_tabletODMCode, NULL);
...@@ -1613,7 +1600,7 @@ static ssize_t show_tabletModelCode(struct device *dev, struct device_attribute ...@@ -1613,7 +1600,7 @@ static ssize_t show_tabletModelCode(struct device *dev, struct device_attribute
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.modelCode); return sysfs_emit(buf, "0x%04x\n", aiptek->features.modelCode);
} }
static DEVICE_ATTR(model_code, S_IRUGO, show_tabletModelCode, NULL); static DEVICE_ATTR(model_code, S_IRUGO, show_tabletModelCode, NULL);
...@@ -1626,8 +1613,7 @@ static ssize_t show_firmwareCode(struct device *dev, struct device_attribute *at ...@@ -1626,8 +1613,7 @@ static ssize_t show_firmwareCode(struct device *dev, struct device_attribute *at
{ {
struct aiptek *aiptek = dev_get_drvdata(dev); struct aiptek *aiptek = dev_get_drvdata(dev);
return snprintf(buf, PAGE_SIZE, "%04x\n", return sysfs_emit(buf, "%04x\n", aiptek->features.firmwareCode);
aiptek->features.firmwareCode);
} }
static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL); static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL);
......
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