From: ppisa Date: Sun, 26 Mar 2006 23:45:15 +0000 (+0000) Subject: Added "chip_info" entry to the /proc/can/channelX, contributed by Sergei Sharonov. X-Git-Tag: CLT_COMM_CAN-lincan-0_3_3~5 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/commitdiff_plain/943dd337df47188d361c0f7f37c19184d73481eb Added "chip_info" entry to the /proc/can/channelX, contributed by Sergei Sharonov. Code is compatible with 2.6.x and 2.4.x Linux kernels. It would fail on 2.2.x version. If its functionality is required, can_remove_proc_entry() has to be used on pointer stored in the new field and code emulating create_proc_read_entry() has to be added. --- diff --git a/lincan/src/proc.c b/lincan/src/proc.c index e18e55a..3957e5f 100644 --- a/lincan/src/proc.c +++ b/lincan/src/proc.c @@ -174,6 +174,35 @@ int can_delete_procdir(void) 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",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 +226,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 +245,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;