Home | History | Annotate | Download | only in init

Lines Matching refs:uevent

44 #include <cutils/uevent.h>
62 struct uevent {
388 static void parse_event(const char *msg, struct uevent *uevent)
390 uevent->action = "";
391 uevent->path = "";
392 uevent->subsystem = "";
393 uevent->firmware = "";
394 uevent->major = -1;
395 uevent->minor = -1;
396 uevent->partition_name = NULL;
397 uevent->partition_num = -1;
398 uevent->device_name = NULL;
404 uevent->action = msg;
407 uevent->path = msg;
410 uevent->subsystem = msg;
413 uevent->firmware = msg;
416 uevent->major = atoi(msg);
419 uevent->minor = atoi(msg);
422 uevent->partition_num = atoi(msg);
425 uevent->partition_name = msg;
428 uevent->device_name = msg;
437 uevent->action, uevent->path, uevent->subsystem,
438 uevent->firmware, uevent->major, uevent->minor);
441 static char **get_character_device_symlinks(struct uevent *uevent)
450 pdev = find_platform_device(uevent->path);
460 parent = strchr(uevent->path + pdev->path_len, '/');
478 if (asprintf(&links[link_num], "/dev/usb/%s%.*s", uevent->subsystem, width, parent) > 0)
494 static char **get_block_device_symlinks(struct uevent *uevent)
510 pdev = find_platform_device(uevent->path);
514 } else if (!find_pci_device_prefix(uevent->path, buf, sizeof(buf))) {
530 if (uevent->partition_name) {
531 p = strdup(uevent->partition_name);
533 if (strcmp(uevent->partition_name, p))
534 NOTICE("Linking partition '%s' as '%s'\n", uevent->partition_name, p);
542 if (uevent->partition_num >= 0) {
543 if (asprintf(&links[link_num], "%s/by-num/p%d", link_path, uevent->partition_num) > 0)
549 slash = strrchr(uevent->path, '/');
586 static void handle_platform_device_event(struct uevent *uevent)
588 const char *path = uevent->path;
590 if (!strcmp(uevent->action, "add"))
592 else if (!strcmp(uevent->action, "remove"))
596 static const char *parse_device_name(struct uevent *uevent, unsigned int len)
601 if((uevent->major < 0) || (uevent->minor < 0))
605 name = strrchr(uevent->path, '/');
620 static void handle_block_device_event(struct uevent *uevent)
627 name = parse_device_name(uevent, 64);
634 if (!strncmp(uevent->path, "/devices/", 9))
635 links = get_block_device_symlinks(uevent);
637 handle_device(uevent->action, devpath, uevent->path, 1,
638 uevent->major, uevent->minor, links);
675 static void handle_generic_device_event(struct uevent *uevent)
682 name = parse_device_name(uevent, 64);
687 ueventd_subsystem_find_by_name(uevent->subsystem);
694 devname = uevent->device_name;
703 uevent->subsystem);
710 } else if (!strncmp(uevent->subsystem, "usb", 3)) {
711 if (!strcmp(uevent->subsystem, "usb")) {
712 if (uevent->device_name) {
713 if (!assemble_devpath(devpath, "/dev", uevent->device_name))
722 int bus_id = uevent->minor / 128 + 1;
723 int device_id = uevent->minor % 128 + 1;
735 } else if (!strncmp(uevent->subsystem, "graphics", 8)) {
738 } else if (!strncmp(uevent->subsystem, "drm", 3)) {
741 } else if (!strncmp(uevent->subsystem, "oncrpc", 6)) {
744 } else if (!strncmp(uevent->subsystem, "adsp", 4)) {
747 } else if (!strncmp(uevent->subsystem, "msm_camera", 10)) {
750 } else if(!strncmp(uevent->subsystem, "input", 5)) {
753 } else if(!strncmp(uevent->subsystem, "mtd", 3)) {
756 } else if(!strncmp(uevent->subsystem, "sound", 5)) {
759 } else if(!strncmp(uevent->subsystem, "misc", 4) &&
767 links = get_character_device_symlinks(uevent);
772 handle_device(uevent->action, devpath, uevent->path, 0,
773 uevent->major, uevent->minor, links);
776 static void handle_device_event(struct uevent *uevent)
778 if (!strcmp(uevent->action,"add") || !strcmp(uevent->action, "change") || !strcmp(uevent->action, "online"))
779 fixup_sys_perms(uevent->path);
781 if (!strncmp(uevent->subsystem, "block", 5)) {
782 handle_block_device_event(uevent);
783 } else if (!strncmp(uevent->subsystem, "platform", 8)) {
784 handle_platform_device_event(uevent);
786 handle_generic_device_event(uevent);
841 static void process_firmware_event(struct uevent *uevent)
848 uevent->firmware, uevent->path);
850 l = asprintf(&root, SYSFS_PREFIX"%s/", uevent->path);
862 l = asprintf(&file1, FIRMWARE_DIR1"/%s", uevent->firmware);
866 l = asprintf(&file2, FIRMWARE_DIR2"/%s", uevent->firmware);
870 l = asprintf(&file3, FIRMWARE_DIR3"/%s", uevent->firmware);
897 INFO("firmware: could not open '%s' %d\n", uevent->firmware, errno);
905 INFO("firmware: copy success { '%s', '%s' }\n", root, uevent->firmware);
907 INFO("firmware: copy failure { '%s', '%s' }\n", root, uevent->firmware);
926 static void handle_firmware_event(struct uevent *uevent)
931 if(strcmp(uevent->subsystem, "firmware"))
934 if(strcmp(uevent->action, "add"))
940 process_firmware_event(uevent);
957 struct uevent uevent;
958 parse_event(msg, &uevent);
969 handle_device_event(&uevent);
970 handle_firmware_event(&uevent);
974 /* Coldboot walks parts of the /sys tree and pokes the uevent files
979 ** we poke another uevent file to make sure we don't overrun the
990 fd = openat(dfd, "uevent", O_WRONLY);