Lines Matching defs:uevent
38 #include <cutils/uevent.h>
50 struct uevent {
277 static void parse_event(const char *msg, struct uevent *uevent)
279 uevent->action = "";
280 uevent->path = "";
281 uevent->subsystem = "";
282 uevent->firmware = "";
283 uevent->major = -1;
284 uevent->minor = -1;
285 uevent->partition_name = NULL;
286 uevent->partition_num = -1;
292 uevent->action = msg;
295 uevent->path = msg;
298 uevent->subsystem = msg;
301 uevent->firmware = msg;
304 uevent->major = atoi(msg);
307 uevent->minor = atoi(msg);
310 uevent->partition_num = atoi(msg);
313 uevent->partition_name = msg;
322 uevent->action, uevent->path, uevent->subsystem,
323 uevent->firmware, uevent->major, uevent->minor);
326 static char **get_character_device_symlinks(struct uevent *uevent)
334 if (strncmp(uevent->path, "/devices/platform/", 18))
343 parent = strchr(uevent->path + 18, '/');
361 if (asprintf(&links[link_num], "/dev/usb/%s%.*s", uevent->subsystem, width, parent) > 0)
377 static char **parse_platform_block_device(struct uevent *uevent)
398 path = uevent->path;
408 if (uevent->partition_name) {
409 p = strdup(uevent->partition_name);
418 if (uevent->partition_num >= 0) {
419 if (asprintf(&links[link_num], "%s/by-num/p%d", link_path, uevent->partition_num) > 0)
466 static void handle_platform_device_event(struct uevent *uevent)
468 const char *name = uevent->path + 18; /* length of /devices/platform/ */
470 if (!strcmp(uevent->action, "add"))
472 else if (!strcmp(uevent->action, "remove"))
476 static const char *parse_device_name(struct uevent *uevent, unsigned int len)
481 if((uevent->major < 0) || (uevent->minor < 0))
485 name = strrchr(uevent->path, '/');
497 static void handle_block_device_event(struct uevent *uevent)
504 name = parse_device_name(uevent, 64);
511 if (!strncmp(uevent->path, "/devices/platform/", 18))
512 links = parse_platform_block_device(uevent);
514 handle_device(uevent->action, devpath, uevent->path, 1,
515 uevent->major, uevent->minor, links);
518 static void handle_generic_device_event(struct uevent *uevent)
525 name = parse_device_name(uevent, 64);
529 if (!strncmp(uevent->subsystem, "usb", 3)) {
530 if (!strcmp(uevent->subsystem, "usb")) {
535 int bus_id = uevent->minor / 128 + 1;
536 int device_id = uevent->minor % 128 + 1;
547 } else if (!strncmp(uevent->subsystem, "graphics", 8)) {
550 } else if (!strncmp(uevent->subsystem, "oncrpc", 6)) {
553 } else if (!strncmp(uevent->subsystem, "adsp", 4)) {
556 } else if (!strncmp(uevent->subsystem, "msm_camera", 10)) {
559 } else if(!strncmp(uevent->subsystem, "input", 5)) {
562 } else if(!strncmp(uevent->subsystem, "mtd", 3)) {
565 } else if(!strncmp(uevent->subsystem, "sound", 5)) {
568 } else if(!strncmp(uevent->subsystem, "misc", 4) &&
575 links = get_character_device_symlinks(uevent);
580 handle_device(uevent->action, devpath, uevent->path, 0,
581 uevent->major, uevent->minor, links);
584 static void handle_device_event(struct uevent *uevent)
586 if (!strcmp(uevent->action,"add"))
587 fixup_sys_perms(uevent->path);
589 if (!strncmp(uevent->subsystem, "block", 5)) {
590 handle_block_device_event(uevent);
591 } else if (!strncmp(uevent->subsystem, "platform", 8)) {
592 handle_platform_device_event(uevent);
594 handle_generic_device_event(uevent);
649 static void process_firmware_event(struct uevent *uevent)
656 uevent->firmware, uevent->path);
658 l = asprintf(&root, SYSFS_PREFIX"%s/", uevent->path);
670 l = asprintf(&file1, FIRMWARE_DIR1"/%s", uevent->firmware);
674 l = asprintf(&file2, FIRMWARE_DIR2"/%s", uevent->firmware);
699 INFO("firmware: could not open '%s' %d\n", uevent->firmware, errno);
706 INFO("firmware: copy success { '%s', '%s' }\n", root, uevent->firmware);
708 INFO("firmware: copy failure { '%s', '%s' }\n", root, uevent->firmware);
726 static void handle_firmware_event(struct uevent *uevent)
731 if(strcmp(uevent->subsystem, "firmware"))
734 if(strcmp(uevent->action, "add"))
740 process_firmware_event(uevent);
757 struct uevent uevent;
758 parse_event(msg, &uevent);
760 handle_device_event(&uevent);
761 handle_firmware_event(&uevent);
765 /* Coldboot walks parts of the /sys tree and pokes the uevent files
770 ** we poke another uevent file to make sure we don't overrun the
781 fd = openat(dfd, "uevent", O_WRONLY);