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

proc: switch /proc/apm to seq_file interface

Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Len Brown <len.brown@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
647634df 8331438b

+18 -5
+18 -5
drivers/char/apm-emulation.c
··· 14 14 #include <linux/poll.h> 15 15 #include <linux/slab.h> 16 16 #include <linux/proc_fs.h> 17 + #include <linux/seq_file.h> 17 18 #include <linux/miscdevice.h> 18 19 #include <linux/apm_bios.h> 19 20 #include <linux/capability.h> ··· 494 493 * -1: Unknown 495 494 * 8) min = minutes; sec = seconds 496 495 */ 497 - static int apm_get_info(char *buf, char **start, off_t fpos, int length) 496 + static int proc_apm_show(struct seq_file *m, void *v) 498 497 { 499 498 struct apm_power_info info; 500 499 char *units; 501 - int ret; 502 500 503 501 info.ac_line_status = 0xff; 504 502 info.battery_status = 0xff; ··· 515 515 case 1: units = "sec"; break; 516 516 } 517 517 518 - ret = sprintf(buf, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", 518 + seq_printf(m, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", 519 519 driver_version, APM_32_BIT_SUPPORT, 520 520 info.ac_line_status, info.battery_status, 521 521 info.battery_flag, info.battery_life, 522 522 info.time, units); 523 523 524 - return ret; 524 + return 0; 525 525 } 526 + 527 + static int proc_apm_open(struct inode *inode, struct file *file) 528 + { 529 + return single_open(file, proc_apm_show, NULL); 530 + } 531 + 532 + static const struct file_operations apm_proc_fops = { 533 + .owner = THIS_MODULE, 534 + .open = proc_apm_open, 535 + .read = seq_read, 536 + .llseek = seq_lseek, 537 + .release = single_release, 538 + }; 526 539 #endif 527 540 528 541 static int kapmd(void *arg) ··· 606 593 wake_up_process(kapmd_tsk); 607 594 608 595 #ifdef CONFIG_PROC_FS 609 - create_proc_info_entry("apm", 0, NULL, apm_get_info); 596 + proc_create("apm", 0, NULL, &apm_proc_fops); 610 597 #endif 611 598 612 599 ret = misc_register(&apm_device);