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

Configure Feed

Select the types of activity you want to include in your feed.

extcon: Use sysfs_emit() to instead of sprintf()

Follow the advice of the Documentation/filesystems/sysfs.rst that
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

authored by

Andy Shevchenko and committed by
Chanwoo Choi
6ee0a22e 6e4e8670

+9 -9
+9 -9
drivers/extcon/extcon.c
··· 370 370 struct extcon_dev *edev = dev_get_drvdata(dev); 371 371 372 372 if (edev->max_supported == 0) 373 - return sprintf(buf, "%u\n", edev->state); 373 + return sysfs_emit(buf, "%u\n", edev->state); 374 374 375 375 for (i = 0; i < edev->max_supported; i++) { 376 - count += sprintf(buf + count, "%s=%d\n", 377 - extcon_info[edev->supported_cable[i]].name, 378 - !!(edev->state & BIT(i))); 376 + count += sysfs_emit_at(buf, count, "%s=%d\n", 377 + extcon_info[edev->supported_cable[i]].name, 378 + !!(edev->state & BIT(i))); 379 379 } 380 380 381 381 return count; ··· 387 387 { 388 388 struct extcon_dev *edev = dev_get_drvdata(dev); 389 389 390 - return sprintf(buf, "%s\n", edev->name); 390 + return sysfs_emit(buf, "%s\n", edev->name); 391 391 } 392 392 static DEVICE_ATTR_RO(name); 393 393 ··· 398 398 attr_name); 399 399 int i = cable->cable_index; 400 400 401 - return sprintf(buf, "%s\n", 402 - extcon_info[cable->edev->supported_cable[i]].name); 401 + return sysfs_emit(buf, "%s\n", 402 + extcon_info[cable->edev->supported_cable[i]].name); 403 403 } 404 404 405 405 static ssize_t cable_state_show(struct device *dev, ··· 410 410 411 411 int i = cable->cable_index; 412 412 413 - return sprintf(buf, "%d\n", 414 - extcon_get_state(cable->edev, cable->edev->supported_cable[i])); 413 + return sysfs_emit(buf, "%d\n", 414 + extcon_get_state(cable->edev, cable->edev->supported_cable[i])); 415 415 } 416 416 417 417 /**