int a4l_init_proc(void) { int ret = 0; struct proc_dir_entry *entry; /* Creates the global directory */ a4l_proc_root = create_proc_entry("analogy", S_IFDIR, 0); if (a4l_proc_root == NULL) { __a4l_err("a4l_proc_init: " "failed to create /proc/analogy\n"); return -ENOMEM; } /* Creates the devices related file */ entry = create_proc_entry("devices", 0444, a4l_proc_root); if (entry == NULL) { __a4l_err("a4l_proc_init: " "failed to create /proc/analogy/devices\n"); ret = -ENOMEM; goto err_proc_init; } entry->nlink = 1; entry->data = NULL; entry->write_proc = NULL; entry->read_proc = a4l_rdproc_devs; wrap_proc_dir_entry_owner(entry); /* Creates the drivers related file */ entry = create_proc_entry("drivers", 0444, a4l_proc_root); if (entry == NULL) { __a4l_err("a4l_proc_init: " "failed to create /proc/analogy/drivers\n"); ret = -ENOMEM; goto err_proc_init; } entry->nlink = 1; entry->data = NULL; entry->write_proc = NULL; entry->read_proc = a4l_rdproc_drvs; wrap_proc_dir_entry_owner(entry); return 0; err_proc_init: remove_proc_entry("devices", a4l_proc_root); remove_proc_entry("analogy", NULL); return ret; }
int a4l_proc_attach(a4l_cxt_t * cxt) { int ret = 0; a4l_dev_t *dev = a4l_get_dev(cxt); struct proc_dir_entry *entry; char *entry_name, *p; /* Allocates the buffer for the file name */ entry_name = rtdm_malloc(A4L_NAMELEN + 4); if ((p = entry_name) == NULL) { __a4l_err("a4l_proc_attach: failed to allocate buffer\n"); return -ENOMEM; } /* Creates the proc file name */ p += sprintf(p, "%02d-", a4l_get_minor(cxt)); strncpy(p, dev->driver->board_name, A4L_NAMELEN); /* Creates the proc entry */ entry = create_proc_entry(entry_name, 0444, a4l_proc_root); if (entry == NULL) { __a4l_err("a4l_proc_attach: " "failed to create /proc/analogy/%s\n", entry_name); ret = -ENOMEM; goto out_setup_proc_transfer; } entry->nlink = 1; entry->data = &dev->transfer; entry->write_proc = NULL; entry->read_proc = a4l_rdproc_transfer; wrap_proc_dir_entry_owner(entry); out_setup_proc_transfer: /* Frees the file name buffer */ rtdm_free(entry_name); return ret; }