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

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: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Link: https://lore.kernel.org/r/1612419191-1078-1-git-send-email-jiapeng.chong@linux.alibaba.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Jiapeng Chong and committed by
Dmitry Torokhov
4c47097f 2896a27f

+33 -47
+33 -47
drivers/input/tablet/aiptek.c
··· 1036 1036 { 1037 1037 struct aiptek *aiptek = dev_get_drvdata(dev); 1038 1038 1039 - return snprintf(buf, PAGE_SIZE, "%dx%d\n", 1040 - input_abs_get_max(aiptek->inputdev, ABS_X) + 1, 1041 - input_abs_get_max(aiptek->inputdev, ABS_Y) + 1); 1039 + return sysfs_emit(buf, "%dx%d\n", 1040 + input_abs_get_max(aiptek->inputdev, ABS_X) + 1, 1041 + input_abs_get_max(aiptek->inputdev, ABS_Y) + 1); 1042 1042 } 1043 1043 1044 1044 /* These structs define the sysfs files, param #1 is the name of the ··· 1064 1064 { 1065 1065 struct aiptek *aiptek = dev_get_drvdata(dev); 1066 1066 1067 - return snprintf(buf, PAGE_SIZE, "%s\n", 1068 - map_val_to_str(pointer_mode_map, 1069 - aiptek->curSetting.pointerMode)); 1067 + return sysfs_emit(buf, "%s\n", map_val_to_str(pointer_mode_map, 1068 + aiptek->curSetting.pointerMode)); 1070 1069 } 1071 1070 1072 1071 static ssize_t ··· 1100 1101 { 1101 1102 struct aiptek *aiptek = dev_get_drvdata(dev); 1102 1103 1103 - return snprintf(buf, PAGE_SIZE, "%s\n", 1104 - map_val_to_str(coordinate_mode_map, 1105 - aiptek->curSetting.coordinateMode)); 1104 + return sysfs_emit(buf, "%s\n", map_val_to_str(coordinate_mode_map, 1105 + aiptek->curSetting.coordinateMode)); 1106 1106 } 1107 1107 1108 1108 static ssize_t ··· 1141 1143 { 1142 1144 struct aiptek *aiptek = dev_get_drvdata(dev); 1143 1145 1144 - return snprintf(buf, PAGE_SIZE, "%s\n", 1145 - map_val_to_str(tool_mode_map, 1146 - aiptek->curSetting.toolMode)); 1146 + return sysfs_emit(buf, "%s\n", map_val_to_str(tool_mode_map, 1147 + aiptek->curSetting.toolMode)); 1147 1148 } 1148 1149 1149 1150 static ssize_t ··· 1171 1174 struct aiptek *aiptek = dev_get_drvdata(dev); 1172 1175 1173 1176 if (aiptek->curSetting.xTilt == AIPTEK_TILT_DISABLE) { 1174 - return snprintf(buf, PAGE_SIZE, "disable\n"); 1177 + return sysfs_emit(buf, "disable\n"); 1175 1178 } else { 1176 - return snprintf(buf, PAGE_SIZE, "%d\n", 1177 - aiptek->curSetting.xTilt); 1179 + return sysfs_emit(buf, "%d\n", aiptek->curSetting.xTilt); 1178 1180 } 1179 1181 } 1180 1182 ··· 1212 1216 struct aiptek *aiptek = dev_get_drvdata(dev); 1213 1217 1214 1218 if (aiptek->curSetting.yTilt == AIPTEK_TILT_DISABLE) { 1215 - return snprintf(buf, PAGE_SIZE, "disable\n"); 1219 + return sysfs_emit(buf, "disable\n"); 1216 1220 } else { 1217 - return snprintf(buf, PAGE_SIZE, "%d\n", 1218 - aiptek->curSetting.yTilt); 1221 + return sysfs_emit(buf, "%d\n", aiptek->curSetting.yTilt); 1219 1222 } 1220 1223 } 1221 1224 ··· 1252 1257 { 1253 1258 struct aiptek *aiptek = dev_get_drvdata(dev); 1254 1259 1255 - return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.jitterDelay); 1260 + return sysfs_emit(buf, "%d\n", aiptek->curSetting.jitterDelay); 1256 1261 } 1257 1262 1258 1263 static ssize_t ··· 1281 1286 { 1282 1287 struct aiptek *aiptek = dev_get_drvdata(dev); 1283 1288 1284 - return snprintf(buf, PAGE_SIZE, "%d\n", 1285 - aiptek->curSetting.programmableDelay); 1289 + return sysfs_emit(buf, "%d\n", aiptek->curSetting.programmableDelay); 1286 1290 } 1287 1291 1288 1292 static ssize_t ··· 1310 1316 { 1311 1317 struct aiptek *aiptek = dev_get_drvdata(dev); 1312 1318 1313 - return snprintf(buf, PAGE_SIZE, "%ld\n", aiptek->eventCount); 1319 + return sysfs_emit(buf, "%ld\n", aiptek->eventCount); 1314 1320 } 1315 1321 1316 1322 static DEVICE_ATTR(event_count, S_IRUGO, show_tabletEventsReceived, NULL); ··· 1349 1355 default: 1350 1356 return 0; 1351 1357 } 1352 - return snprintf(buf, PAGE_SIZE, retMsg); 1358 + return sysfs_emit(buf, retMsg); 1353 1359 } 1354 1360 1355 1361 static DEVICE_ATTR(diagnostic, S_IRUGO, show_tabletDiagnosticMessage, NULL); ··· 1369 1375 { 1370 1376 struct aiptek *aiptek = dev_get_drvdata(dev); 1371 1377 1372 - return snprintf(buf, PAGE_SIZE, "%s\n", 1373 - map_val_to_str(stylus_button_map, 1374 - aiptek->curSetting.stylusButtonUpper)); 1378 + return sysfs_emit(buf, "%s\n", map_val_to_str(stylus_button_map, 1379 + aiptek->curSetting.stylusButtonUpper)); 1375 1380 } 1376 1381 1377 1382 static ssize_t ··· 1399 1406 { 1400 1407 struct aiptek *aiptek = dev_get_drvdata(dev); 1401 1408 1402 - return snprintf(buf, PAGE_SIZE, "%s\n", 1403 - map_val_to_str(stylus_button_map, 1404 - aiptek->curSetting.stylusButtonLower)); 1409 + return sysfs_emit(buf, "%s\n", map_val_to_str(stylus_button_map, 1410 + aiptek->curSetting.stylusButtonLower)); 1405 1411 } 1406 1412 1407 1413 static ssize_t ··· 1436 1444 { 1437 1445 struct aiptek *aiptek = dev_get_drvdata(dev); 1438 1446 1439 - return snprintf(buf, PAGE_SIZE, "%s\n", 1440 - map_val_to_str(mouse_button_map, 1441 - aiptek->curSetting.mouseButtonLeft)); 1447 + return sysfs_emit(buf, "%s\n", map_val_to_str(mouse_button_map, 1448 + aiptek->curSetting.mouseButtonLeft)); 1442 1449 } 1443 1450 1444 1451 static ssize_t ··· 1465 1474 { 1466 1475 struct aiptek *aiptek = dev_get_drvdata(dev); 1467 1476 1468 - return snprintf(buf, PAGE_SIZE, "%s\n", 1469 - map_val_to_str(mouse_button_map, 1470 - aiptek->curSetting.mouseButtonMiddle)); 1477 + return sysfs_emit(buf, "%s\n", map_val_to_str(mouse_button_map, 1478 + aiptek->curSetting.mouseButtonMiddle)); 1471 1479 } 1472 1480 1473 1481 static ssize_t ··· 1494 1504 { 1495 1505 struct aiptek *aiptek = dev_get_drvdata(dev); 1496 1506 1497 - return snprintf(buf, PAGE_SIZE, "%s\n", 1498 - map_val_to_str(mouse_button_map, 1499 - aiptek->curSetting.mouseButtonRight)); 1507 + return sysfs_emit(buf, "%s\n", map_val_to_str(mouse_button_map, 1508 + aiptek->curSetting.mouseButtonRight)); 1500 1509 } 1501 1510 1502 1511 static ssize_t ··· 1524 1535 struct aiptek *aiptek = dev_get_drvdata(dev); 1525 1536 1526 1537 if (aiptek->curSetting.wheel == AIPTEK_WHEEL_DISABLE) { 1527 - return snprintf(buf, PAGE_SIZE, "disable\n"); 1538 + return sysfs_emit(buf, "disable\n"); 1528 1539 } else { 1529 - return snprintf(buf, PAGE_SIZE, "%d\n", 1530 - aiptek->curSetting.wheel); 1540 + return sysfs_emit(buf, "%d\n", aiptek->curSetting.wheel); 1531 1541 } 1532 1542 } 1533 1543 ··· 1556 1568 /* There is nothing useful to display, so a one-line manual 1557 1569 * is in order... 1558 1570 */ 1559 - return snprintf(buf, PAGE_SIZE, 1560 - "Write anything to this file to program your tablet.\n"); 1571 + return sysfs_emit(buf, "Write anything to this file to program your tablet.\n"); 1561 1572 } 1562 1573 1563 1574 static ssize_t ··· 1587 1600 { 1588 1601 struct aiptek *aiptek = dev_get_drvdata(dev); 1589 1602 1590 - return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.odmCode); 1603 + return sysfs_emit(buf, "0x%04x\n", aiptek->features.odmCode); 1591 1604 } 1592 1605 1593 1606 static DEVICE_ATTR(odm_code, S_IRUGO, show_tabletODMCode, NULL); ··· 1600 1613 { 1601 1614 struct aiptek *aiptek = dev_get_drvdata(dev); 1602 1615 1603 - return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.modelCode); 1616 + return sysfs_emit(buf, "0x%04x\n", aiptek->features.modelCode); 1604 1617 } 1605 1618 1606 1619 static DEVICE_ATTR(model_code, S_IRUGO, show_tabletModelCode, NULL); ··· 1613 1626 { 1614 1627 struct aiptek *aiptek = dev_get_drvdata(dev); 1615 1628 1616 - return snprintf(buf, PAGE_SIZE, "%04x\n", 1617 - aiptek->features.firmwareCode); 1629 + return sysfs_emit(buf, "%04x\n", aiptek->features.firmwareCode); 1618 1630 } 1619 1631 1620 1632 static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL);