Skip to content

Commit 4438a81

Browse files
committed
Merge tag 'firewire-updates-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394
Pull firewire updates from Takashi Sakamoto: "Small changes to string processing in device attribute" * tag 'firewire-updates-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394: firewire: core: fix build failure due to the caller of fw_csr_string() firewire: Convert snprintf/sprintf to sysfs_emit firewire: Kill unnecessary buf check in device_attribute.show
2 parents 02c163e + 04f082d commit 4438a81

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

drivers/firewire/core-device.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static ssize_t show_immediate(struct device *dev,
322322
if (value < 0)
323323
return -ENOENT;
324324

325-
return snprintf(buf, buf ? PAGE_SIZE : 0, "0x%06x\n", value);
325+
return sysfs_emit(buf, "0x%06x\n", value);
326326
}
327327

328328
#define IMMEDIATE_ATTR(name, key) \
@@ -334,8 +334,6 @@ static ssize_t show_text_leaf(struct device *dev,
334334
struct config_rom_attribute *attr =
335335
container_of(dattr, struct config_rom_attribute, attr);
336336
const u32 *directories[] = {NULL, NULL};
337-
size_t bufsize;
338-
char dummy_buf[2];
339337
int i, ret = -ENOENT;
340338

341339
down_read(&fw_device_rwsem);
@@ -357,15 +355,9 @@ static ssize_t show_text_leaf(struct device *dev,
357355
}
358356
}
359357

360-
if (buf) {
361-
bufsize = PAGE_SIZE - 1;
362-
} else {
363-
buf = dummy_buf;
364-
bufsize = 1;
365-
}
366-
367358
for (i = 0; i < ARRAY_SIZE(directories) && !!directories[i]; ++i) {
368-
int result = fw_csr_string(directories[i], attr->key, buf, bufsize);
359+
int result = fw_csr_string(directories[i], attr->key, buf,
360+
PAGE_SIZE - 1);
369361
// Detected.
370362
if (result >= 0) {
371363
ret = result;
@@ -374,7 +366,7 @@ static ssize_t show_text_leaf(struct device *dev,
374366
// in the root directory follows to the directory entry for vendor ID
375367
// instead of the immediate value for vendor ID.
376368
result = fw_csr_string(directories[i], CSR_DIRECTORY | attr->key, buf,
377-
bufsize);
369+
PAGE_SIZE - 1);
378370
if (result >= 0)
379371
ret = result;
380372
}
@@ -490,7 +482,7 @@ static ssize_t is_local_show(struct device *dev,
490482
{
491483
struct fw_device *device = fw_device(dev);
492484

493-
return sprintf(buf, "%u\n", device->is_local);
485+
return sysfs_emit(buf, "%u\n", device->is_local);
494486
}
495487

496488
static int units_sprintf(char *buf, const u32 *directory)

0 commit comments

Comments
 (0)