]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
Added "chip_info" entry to the /proc/can/channelX, contributed by Sergei Sharonov.
authorppisa <ppisa>
Sun, 26 Mar 2006 23:45:15 +0000 (23:45 +0000)
committerppisa <ppisa>
Sun, 26 Mar 2006 23:45:15 +0000 (23:45 +0000)
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.

lincan/src/proc.c

index e18e55a22a3aee6b113c1a26efa3a7eabcec9275..3957e5f99e80bce64505a81729c1797a4f0c1384 100644 (file)
@@ -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;