Skip to content

Commit 6ee0a22

Browse files
andy-shevchanwoochoi
authored andcommitted
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>
1 parent 6e4e867 commit 6ee0a22

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/extcon/extcon.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,12 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr,
370370
struct extcon_dev *edev = dev_get_drvdata(dev);
371371

372372
if (edev->max_supported == 0)
373-
return sprintf(buf, "%u\n", edev->state);
373+
return sysfs_emit(buf, "%u\n", edev->state);
374374

375375
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)));
379379
}
380380

381381
return count;
@@ -387,7 +387,7 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr,
387387
{
388388
struct extcon_dev *edev = dev_get_drvdata(dev);
389389

390-
return sprintf(buf, "%s\n", edev->name);
390+
return sysfs_emit(buf, "%s\n", edev->name);
391391
}
392392
static DEVICE_ATTR_RO(name);
393393

@@ -398,8 +398,8 @@ static ssize_t cable_name_show(struct device *dev,
398398
attr_name);
399399
int i = cable->cable_index;
400400

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);
403403
}
404404

405405
static ssize_t cable_state_show(struct device *dev,
@@ -410,8 +410,8 @@ static ssize_t cable_state_show(struct device *dev,
410410

411411
int i = cable->cable_index;
412412

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]));
415415
}
416416

417417
/**

0 commit comments

Comments
 (0)