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

s390/vfio-ap: Switch over to sysfs_emit()

Per Documentation/filesystems/sysfs.rst, sysfs_emit() is preferred for
presenting attributes to user space in sysfs. Convert the left-over uses
in the vfio_ap code.

Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Tested-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>

authored by

Mete Durlu and committed by
Heiko Carstens
5c77c5d1 a6a56aec

+12 -33
+12 -33
drivers/s390/crypto/vfio_ap_ops.c
··· 1521 1521 char *buf) 1522 1522 { 1523 1523 unsigned long id; 1524 - int nchars = 0; 1525 - int n; 1526 - char *bufpos = buf; 1527 1524 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); 1528 1525 unsigned long max_domid = matrix_mdev->matrix.adm_max; 1526 + int nchars = 0; 1529 1527 1530 1528 mutex_lock(&matrix_dev->mdevs_lock); 1531 - for_each_set_bit_inv(id, matrix_mdev->matrix.adm, max_domid + 1) { 1532 - n = sprintf(bufpos, "%04lx\n", id); 1533 - bufpos += n; 1534 - nchars += n; 1535 - } 1529 + for_each_set_bit_inv(id, matrix_mdev->matrix.adm, max_domid + 1) 1530 + nchars += sysfs_emit_at(buf, nchars, "%04lx\n", id); 1536 1531 mutex_unlock(&matrix_dev->mdevs_lock); 1537 1532 1538 1533 return nchars; ··· 1536 1541 1537 1542 static ssize_t vfio_ap_mdev_matrix_show(struct ap_matrix *matrix, char *buf) 1538 1543 { 1539 - char *bufpos = buf; 1540 1544 unsigned long apid; 1541 1545 unsigned long apqi; 1542 1546 unsigned long apid1; ··· 1543 1549 unsigned long napm_bits = matrix->apm_max + 1; 1544 1550 unsigned long naqm_bits = matrix->aqm_max + 1; 1545 1551 int nchars = 0; 1546 - int n; 1547 1552 1548 1553 apid1 = find_first_bit_inv(matrix->apm, napm_bits); 1549 1554 apqi1 = find_first_bit_inv(matrix->aqm, naqm_bits); 1550 1555 1551 1556 if ((apid1 < napm_bits) && (apqi1 < naqm_bits)) { 1552 1557 for_each_set_bit_inv(apid, matrix->apm, napm_bits) { 1553 - for_each_set_bit_inv(apqi, matrix->aqm, 1554 - naqm_bits) { 1555 - n = sprintf(bufpos, "%02lx.%04lx\n", apid, 1556 - apqi); 1557 - bufpos += n; 1558 - nchars += n; 1559 - } 1558 + for_each_set_bit_inv(apqi, matrix->aqm, naqm_bits) 1559 + nchars += sysfs_emit_at(buf, nchars, "%02lx.%04lx\n", apid, apqi); 1560 1560 } 1561 1561 } else if (apid1 < napm_bits) { 1562 - for_each_set_bit_inv(apid, matrix->apm, napm_bits) { 1563 - n = sprintf(bufpos, "%02lx.\n", apid); 1564 - bufpos += n; 1565 - nchars += n; 1566 - } 1562 + for_each_set_bit_inv(apid, matrix->apm, napm_bits) 1563 + nchars += sysfs_emit_at(buf, nchars, "%02lx.\n", apid); 1567 1564 } else if (apqi1 < naqm_bits) { 1568 - for_each_set_bit_inv(apqi, matrix->aqm, naqm_bits) { 1569 - n = sprintf(bufpos, ".%04lx\n", apqi); 1570 - bufpos += n; 1571 - nchars += n; 1572 - } 1565 + for_each_set_bit_inv(apqi, matrix->aqm, naqm_bits) 1566 + nchars += sysfs_emit_at(buf, nchars, ".%04lx\n", apqi); 1573 1567 } 1574 1568 1575 1569 return nchars; ··· 2245 2263 if (matrix_mdev->kvm && 2246 2264 test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && 2247 2265 test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) 2248 - nchars = scnprintf(buf, PAGE_SIZE, "%s\n", 2249 - AP_QUEUE_IN_USE); 2266 + nchars = sysfs_emit(buf, "%s\n", AP_QUEUE_IN_USE); 2250 2267 else 2251 - nchars = scnprintf(buf, PAGE_SIZE, "%s\n", 2252 - AP_QUEUE_ASSIGNED); 2268 + nchars = sysfs_emit(buf, "%s\n", AP_QUEUE_ASSIGNED); 2253 2269 } else { 2254 - nchars = scnprintf(buf, PAGE_SIZE, "%s\n", 2255 - AP_QUEUE_UNASSIGNED); 2270 + nchars = sysfs_emit(buf, "%s\n", AP_QUEUE_UNASSIGNED); 2256 2271 } 2257 2272 2258 2273 mutex_unlock(&matrix_dev->mdevs_lock);