X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/a4c9ead4b64bd4de307f375c2ff313a7a07a06e0..630df2e744772666f8083739340c1703d146e7ab:/lincan/src/proc.c diff --git a/lincan/src/proc.c b/lincan/src/proc.c index e18e55a..a851830 100644 --- a/lincan/src/proc.c +++ b/lincan/src/proc.c @@ -25,6 +25,12 @@ int remove_object_from_procdir(int chip_nr); static int can_proc_readlink(struct proc_dir_entry *ent, char *page); #endif +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25) +#define CAN_PROC_ROOT (&proc_root) +#else /* >= 2.6.26 */ +#define CAN_PROC_ROOT (NULL) +#endif /* >= 2.6.26 */ + static int cc=0; /* static counter for each CAN chip */ static struct canproc_t can_proc_base; @@ -150,7 +156,7 @@ int can_init_procdir(void) int board; struct candevice_t *candev; base->can_proc_entry = can_create_proc_entry("can", S_IFDIR | S_IRUGO | - S_IXUGO, &proc_root); + S_IXUGO, CAN_PROC_ROOT); if (base->can_proc_entry == NULL) return -ENODEV; @@ -168,12 +174,42 @@ int can_delete_procdir(void) if (remove_channel_from_procdir()) return -ENODEV; /* name: "can" */ - if (can_remove_proc_entry(base->can_proc_entry, &proc_root)) + if (can_remove_proc_entry(base->can_proc_entry, CAN_PROC_ROOT)) return -ENODEV; return 0; } +static int can_chip_procinfo(char *buf, char **start, off_t offset, + int count, int *eof, void *data) +{ + struct canchip_t *chip=data; + int len=0; + + /* Generic chip info */ + len += sprintf(buf+len,"type : %s\n",chip->chip_type); + len += sprintf(buf+len,"index : %d\n",chip->chip_idx); + len += sprintf(buf+len,"irq : %d\n",chip->chip_irq); + len += sprintf(buf+len,"addr : %lu\n", + can_ioptr2ulong(chip->chip_base_addr)); + len += sprintf(buf+len,"config : %s\n", + (chip->flags & CHIP_CONFIGURED) ? "yes":"no"); + len += sprintf(buf+len,"clock : %ld Hz\n",chip->clock); + len += sprintf(buf+len,"baud : %ld\n",chip->baudrate); + len += sprintf(buf+len,"num obj : %d\n",chip->max_objects); + + +#if 0 + /* Chip specific info if available */ + if(chip->chipspecops->get_info) + len += (chip->chipspecops->get_info)(chip,buf+len); +#endif + + *eof = 1; + return len; +} + + int add_channel_to_procdir(struct candevice_t *candev) { int i=0; @@ -197,6 +233,12 @@ int add_channel_to_procdir(struct candevice_t *candev) add_object_to_procdir(cc); + create_proc_read_entry("chip_info", /* proc entry name */ + 0, /* protection mask, 0->default */ + base->channel[cc]->ch_entry, /* parent dir, NULL->/proc */ + can_chip_procinfo, + candev->chip[i]); + cc++; } @@ -210,6 +252,8 @@ int remove_channel_from_procdir(void) cc--; if(!base->channel[cc]) continue; + + remove_proc_entry("chip_info", base->channel[cc]->ch_entry); if (remove_object_from_procdir(cc)) return -ENODEV;