aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/ecard.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@sw.ru>2008-04-29 04:01:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:19 -0400
commit9b0012126ae191c90c88df4b535b0f2ade70ecb6 (patch)
tree68458962efd7d60cac3736301c41a04637cf922a /arch/arm/kernel/ecard.c
parent51251549140f99cc5fbfed8ac542f22cbf067870 (diff)
proc: switch /proc/bus/ecard/devices to seq_file interface
Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Cc: Yani Ioannou <yani.ioannou@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/arm/kernel/ecard.c')
-rw-r--r--arch/arm/kernel/ecard.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
index 2d8ab6b3a586..a53c0aba5c14 100644
--- a/arch/arm/kernel/ecard.c
+++ b/arch/arm/kernel/ecard.c
@@ -37,6 +37,7 @@
37#include <linux/mm.h> 37#include <linux/mm.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/proc_fs.h> 39#include <linux/proc_fs.h>
40#include <linux/seq_file.h>
40#include <linux/device.h> 41#include <linux/device.h>
41#include <linux/init.h> 42#include <linux/init.h>
42#include <linux/mutex.h> 43#include <linux/mutex.h>
@@ -723,17 +724,14 @@ unsigned int __ecard_address(ecard_t *ec, card_type_t type, card_speed_t speed)
723 return address; 724 return address;
724} 725}
725 726
726static int ecard_prints(char *buffer, ecard_t *ec) 727static int ecard_prints(struct seq_file *m, ecard_t *ec)
727{ 728{
728 char *start = buffer; 729 seq_printf(m, " %d: %s ", ec->slot_no, ec->easi ? "EASI" : " ");
729
730 buffer += sprintf(buffer, " %d: %s ", ec->slot_no,
731 ec->easi ? "EASI" : " ");
732 730
733 if (ec->cid.id == 0) { 731 if (ec->cid.id == 0) {
734 struct in_chunk_dir incd; 732 struct in_chunk_dir incd;
735 733
736 buffer += sprintf(buffer, "[%04X:%04X] ", 734 seq_printf(m, "[%04X:%04X] ",
737 ec->cid.manufacturer, ec->cid.product); 735 ec->cid.manufacturer, ec->cid.product);
738 736
739 if (!ec->card_desc && ec->cid.cd && 737 if (!ec->card_desc && ec->cid.cd &&
@@ -744,43 +742,43 @@ static int ecard_prints(char *buffer, ecard_t *ec)
744 strcpy((char *)ec->card_desc, incd.d.string); 742 strcpy((char *)ec->card_desc, incd.d.string);
745 } 743 }
746 744
747 buffer += sprintf(buffer, "%s\n", ec->card_desc ? ec->card_desc : "*unknown*"); 745 seq_printf(m, "%s\n", ec->card_desc ? ec->card_desc : "*unknown*");
748 } else 746 } else
749 buffer += sprintf(buffer, "Simple card %d\n", ec->cid.id); 747 seq_printf(m, "Simple card %d\n", ec->cid.id);
750 748
751 return buffer - start; 749 return 0;
752} 750}
753 751
754static int get_ecard_dev_info(char *buf, char **start, off_t pos, int count) 752static int ecard_devices_proc_show(struct seq_file *m, void *v)
755{ 753{
756 ecard_t *ec = cards; 754 ecard_t *ec = cards;
757 off_t at = 0; 755
758 int len, cnt; 756 while (ec) {
759 757 ecard_prints(m, ec);
760 cnt = 0;
761 while (ec && count > cnt) {
762 len = ecard_prints(buf, ec);
763 at += len;
764 if (at >= pos) {
765 if (!*start) {
766 *start = buf + (pos - (at - len));
767 cnt = at - pos;
768 } else
769 cnt += len;
770 buf += len;
771 }
772 ec = ec->next; 758 ec = ec->next;
773 } 759 }
774 return (count > cnt) ? cnt : count; 760 return 0;
775} 761}
776 762
763static int ecard_devices_proc_open(struct inode *inode, struct file *file)
764{
765 return single_open(file, ecard_devices_proc_show, NULL);
766}
767
768static const struct file_operations bus_ecard_proc_fops = {
769 .owner = THIS_MODULE,
770 .open = ecard_devices_proc_open,
771 .read = seq_read,
772 .llseek = seq_lseek,
773 .release = single_release,
774};
775
777static struct proc_dir_entry *proc_bus_ecard_dir = NULL; 776static struct proc_dir_entry *proc_bus_ecard_dir = NULL;
778 777
779static void ecard_proc_init(void) 778static void ecard_proc_init(void)
780{ 779{
781 proc_bus_ecard_dir = proc_mkdir("bus/ecard", NULL); 780 proc_bus_ecard_dir = proc_mkdir("bus/ecard", NULL);
782 create_proc_info_entry("devices", 0, proc_bus_ecard_dir, 781 proc_create("devices", 0, proc_bus_ecard_dir, &bus_ecard_proc_fops);
783 get_ecard_dev_info);
784} 782}
785 783
786#define ec_set_resource(ec,nr,st,sz) \ 784#define ec_set_resource(ec,nr,st,sz) \