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;
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;
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;
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++;
}
cc--;
if(!base->channel[cc]) continue;
+
+ remove_proc_entry("chip_info", base->channel[cc]->ch_entry);
if (remove_object_from_procdir(cc))
return -ENODEV;