Home | History | Annotate | Download | only in init

Lines Matching defs:uevent

43 #include <cutils/uevent.h>
58 struct uevent {
316 static void parse_event(const char *msg, struct uevent *uevent)
318 uevent->action = "";
319 uevent->path = "";
320 uevent->subsystem = "";
321 uevent->firmware = "";
322 uevent->major = -1;
323 uevent->minor = -1;
324 uevent->partition_name = NULL;
325 uevent->partition_num = -1;
326 uevent->device_name = NULL;
332 uevent->action = msg;
335 uevent->path = msg;
338 uevent->subsystem = msg;
341 uevent->firmware = msg;
344 uevent->major = atoi(msg);
347 uevent->minor = atoi(msg);
350 uevent->partition_num = atoi(msg);
353 uevent->partition_name = msg;
356 uevent->device_name = msg;
365 uevent->action, uevent->path, uevent->subsystem,
366 uevent->firmware, uevent->major, uevent->minor);
369 static char **get_character_device_symlinks(struct uevent *uevent)
378 pdev = find_platform_device(uevent->path);
388 parent = strchr(uevent->path + pdev->path_len, '/');
406 if (asprintf(&links[link_num], "/dev/usb/%s%.*s", uevent->subsystem, width, parent) > 0)
422 static char **parse_platform_block_device(struct uevent *uevent)
437 pdev = find_platform_device(uevent->path);
451 if (uevent->partition_name) {
452 p = strdup(uevent->partition_name);
454 if (strcmp(uevent->partition_name, p))
455 NOTICE("Linking partition '%s' as '%s'\n", uevent->partition_name, p);
463 if (uevent->partition_num >= 0) {
464 if (asprintf(&links[link_num], "%s/by-num/p%d", link_path, uevent->partition_num) > 0)
470 slash = strrchr(uevent->path, '/');
507 static void handle_platform_device_event(struct uevent *uevent)
509 const char *path = uevent->path;
511 if (!strcmp(uevent->action, "add"))
513 else if (!strcmp(uevent->action, "remove"))
517 static const char *parse_device_name(struct uevent *uevent, unsigned int len)
522 if((uevent->major < 0) || (uevent->minor < 0))
526 name = strrchr(uevent->path, '/');
538 static void handle_block_device_event(struct uevent *uevent)
545 name = parse_device_name(uevent, 64);
552 if (!strncmp(uevent->path, "/devices/", 9))
553 links = parse_platform_block_device(uevent);
555 handle_device(uevent->action, devpath, uevent->path, 1,
556 uevent->major, uevent->minor, links);
559 static void handle_generic_device_event(struct uevent *uevent)
566 name = parse_device_name(uevent, 64);
570 if (!strncmp(uevent->subsystem, "usb", 3)) {
571 if (!strcmp(uevent->subsystem, "usb")) {
572 if (uevent->device_name) {
578 snprintf(devpath, sizeof(devpath), "/dev/%s", uevent->device_name);
596 int bus_id = uevent->minor / 128 + 1;
597 int device_id = uevent->minor % 128 + 1;
609 } else if (!strncmp(uevent->subsystem, "graphics", 8)) {
612 uevent->subsystem, "drm", 3)) {
615 } else if (!strncmp(uevent->subsystem, "oncrpc", 6)) {
618 } else if (!strncmp(uevent->subsystem, "adsp", 4)) {
621 } else if (!strncmp(uevent->subsystem, "msm_camera", 10)) {
624 } else if(!strncmp(uevent->subsystem, "input", 5)) {
627 } else if(!strncmp(uevent->subsystem, "mtd", 3)) {
630 } else if(!strncmp(uevent->subsystem, "sound", 5)) {
633 } else if(!strncmp(uevent->subsystem, "misc", 4) &&
640 links = get_character_device_symlinks(uevent);
645 handle_device(uevent->action, devpath, uevent->path, 0,
646 uevent->major, uevent->minor, links);
649 static void handle_device_event(struct uevent *uevent)
651 if (!strcmp(uevent->action,"add") || !strcmp(uevent->action, "change"))
652 fixup_sys_perms(uevent->path);
654 if (!strncmp(uevent->subsystem, "block", 5)) {
655 handle_block_device_event(uevent);
656 } else if (!strncmp(uevent->subsystem, "platform", 8)) {
657 handle_platform_device_event(uevent);
659 handle_generic_device_event(uevent);
714 static void process_firmware_event(struct uevent *uevent)
721 uevent->firmware, uevent->path);
723 l = asprintf(&root, SYSFS_PREFIX"%s/", uevent->path);
735 l = asprintf(&file1, FIRMWARE_DIR1"/%s", uevent->firmware);
739 l = asprintf(&file2, FIRMWARE_DIR2"/%s", uevent->firmware);
743 l = asprintf(&file3, FIRMWARE_DIR3"/%s", uevent->firmware);
770 INFO("firmware: could not open '%s' %d\n", uevent->firmware, errno);
778 INFO("firmware: copy success { '%s', '%s' }\n", root, uevent->firmware);
780 INFO("firmware: copy failure { '%s', '%s' }\n", root, uevent->firmware);
799 static void handle_firmware_event(struct uevent *uevent)
804 if(strcmp(uevent->subsystem, "firmware"))
807 if(strcmp(uevent->action, "add"))
813 process_firmware_event(uevent);
830 struct uevent uevent;
831 parse_event(msg, &uevent);
833 handle_device_event(&uevent);
834 handle_firmware_event(&uevent);
838 /* Coldboot walks parts of the /sys tree and pokes the uevent files
843 ** we poke another uevent file to make sure we don't overrun the
854 fd = openat(dfd, "uevent", O_WRONLY);