Skip to content

Commit 41c95ac

Browse files
andy-shevKAGA-KOKO
authored andcommitted
genirq/irqdesc: Use sysfs_emit() to instead of s*printf()
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: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20250416101651.2128688-1-andriy.shevchenko@linux.intel.com
1 parent 0a02e1f commit 41c95ac

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

kernel/irq/irqdesc.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ static ssize_t per_cpu_count_show(struct kobject *kobj,
257257
for_each_possible_cpu(cpu) {
258258
unsigned int c = irq_desc_kstat_cpu(desc, cpu);
259259

260-
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s%u", p, c);
260+
ret += sysfs_emit_at(buf, ret, "%s%u", p, c);
261261
p = ",";
262262
}
263263

264-
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
264+
ret += sysfs_emit_at(buf, ret, "\n");
265265
return ret;
266266
}
267267
IRQ_ATTR_RO(per_cpu_count);
@@ -273,10 +273,8 @@ static ssize_t chip_name_show(struct kobject *kobj,
273273
ssize_t ret = 0;
274274

275275
raw_spin_lock_irq(&desc->lock);
276-
if (desc->irq_data.chip && desc->irq_data.chip->name) {
277-
ret = scnprintf(buf, PAGE_SIZE, "%s\n",
278-
desc->irq_data.chip->name);
279-
}
276+
if (desc->irq_data.chip && desc->irq_data.chip->name)
277+
ret = sysfs_emit(buf, "%s\n", desc->irq_data.chip->name);
280278
raw_spin_unlock_irq(&desc->lock);
281279

282280
return ret;
@@ -291,7 +289,7 @@ static ssize_t hwirq_show(struct kobject *kobj,
291289

292290
raw_spin_lock_irq(&desc->lock);
293291
if (desc->irq_data.domain)
294-
ret = sprintf(buf, "%lu\n", desc->irq_data.hwirq);
292+
ret = sysfs_emit(buf, "%lu\n", desc->irq_data.hwirq);
295293
raw_spin_unlock_irq(&desc->lock);
296294

297295
return ret;
@@ -305,8 +303,7 @@ static ssize_t type_show(struct kobject *kobj,
305303
ssize_t ret = 0;
306304

307305
raw_spin_lock_irq(&desc->lock);
308-
ret = sprintf(buf, "%s\n",
309-
irqd_is_level_type(&desc->irq_data) ? "level" : "edge");
306+
ret = sysfs_emit(buf, "%s\n", irqd_is_level_type(&desc->irq_data) ? "level" : "edge");
310307
raw_spin_unlock_irq(&desc->lock);
311308

312309
return ret;
@@ -321,7 +318,7 @@ static ssize_t wakeup_show(struct kobject *kobj,
321318
ssize_t ret = 0;
322319

323320
raw_spin_lock_irq(&desc->lock);
324-
ret = sprintf(buf, "%s\n", str_enabled_disabled(irqd_is_wakeup_set(&desc->irq_data)));
321+
ret = sysfs_emit(buf, "%s\n", str_enabled_disabled(irqd_is_wakeup_set(&desc->irq_data)));
325322
raw_spin_unlock_irq(&desc->lock);
326323

327324
return ret;
@@ -337,7 +334,7 @@ static ssize_t name_show(struct kobject *kobj,
337334

338335
raw_spin_lock_irq(&desc->lock);
339336
if (desc->name)
340-
ret = scnprintf(buf, PAGE_SIZE, "%s\n", desc->name);
337+
ret = sysfs_emit(buf, "%s\n", desc->name);
341338
raw_spin_unlock_irq(&desc->lock);
342339

343340
return ret;
@@ -354,14 +351,13 @@ static ssize_t actions_show(struct kobject *kobj,
354351

355352
raw_spin_lock_irq(&desc->lock);
356353
for_each_action_of_desc(desc, action) {
357-
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s%s",
358-
p, action->name);
354+
ret += sysfs_emit_at(buf, ret, "%s%s", p, action->name);
359355
p = ",";
360356
}
361357
raw_spin_unlock_irq(&desc->lock);
362358

363359
if (ret)
364-
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n");
360+
ret += sysfs_emit_at(buf, ret, "\n");
365361

366362
return ret;
367363
}

0 commit comments

Comments
 (0)