~ubuntu-branches/ubuntu/maverick/hal/maverick

« back to all changes in this revision

Viewing changes to hald/linux/hotplug.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-12-03 01:21:24 UTC
  • mfrom: (1.2.11 upstream) (1.1.17 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091203012124-0ikk10hnsh4b6m5h
Tags: 0.5.14-0ubuntu1
* Merge with Debian svn head, which now has most of our changes. Remaining
  Ubuntu changes:
 - Enable support for X11 input hotplugging:
   + debian/rules: Do not remove 10-x11-input.fdi, we want to install it by
     default.
   + Drop 10-x11-input.fdi from debian/hal.examples, since we install
     it by default.
   This will soon be obsoleted by changing X.org to use udev-based input
   device detection.
 - Add support for smartdimmer backlight control for GeForce 7/8/9 based
   Sony laptops.
   + Add 04_nvidia_brightness.patch.
   + Add smartdimmer recommends.
 - debian/hal.postinst: Do not create plugdev and powerdev groups.
 - Add debian/hal.upstart: Supersedes init script.
* Disable 50_kfreebsd.patch for now; not used in Ubuntu, and does not
  currently apply.

Show diffs side-by-side

added added

removed removed

Lines of Context:
393
393
                for (lp = events; lp; lp = g_list_next (lp)) {
394
394
                        loop_event = (HotplugEvent*) lp->data;
395
395
                        /* skip ourselves and all later events*/
396
 
                        if (loop_event->sysfs.seqnum >= hotplug_event->sysfs.seqnum)
 
396
                        if (loop_event->sysfs.seqnum >= hotplug_event->sysfs.seqnum) {
 
397
                                HAL_DEBUG (("event %s: skip ourselves and all later events", hotplug_event->sysfs.sysfs_path));
397
398
                                break;
 
399
                        }
398
400
                        if (compare_event (hotplug_event, loop_event)) {
399
401
                                HAL_DEBUG (("event %s dependant on %s", hotplug_event->sysfs.sysfs_path, loop_event->sysfs.sysfs_path));
400
402
                                return TRUE;
413
415
        }
414
416
}
415
417
 
 
418
/*
 
419
 * Returns TRUE if @hotplug_event depends on any running event in @events
 
420
 * This function checks if there is a running remove/add event for the same 
 
421
 * sysfs_path/device. (for more see fd.o#23060)
 
422
 */
 
423
static gboolean
 
424
compare_events_running (HotplugEvent *hotplug_event, GList *events)
 
425
{
 
426
        GList *lp;
 
427
        HotplugEvent *loop_event;
 
428
 
 
429
        switch (hotplug_event->type) {
 
430
 
 
431
        /* explicit fallthrough */
 
432
        case HOTPLUG_EVENT_SYSFS:
 
433
        case HOTPLUG_EVENT_SYSFS_DEVICE:
 
434
        case HOTPLUG_EVENT_SYSFS_BLOCK:
 
435
 
 
436
                for (lp = events; lp; lp = g_list_next (lp)) {
 
437
                        loop_event = (HotplugEvent*) lp->data;
 
438
                        /* skip ourselves and all later events*/
 
439
                        if (!strcmp (hotplug_event->sysfs.sysfs_path, loop_event->sysfs.sysfs_path)) {
 
440
                                if (loop_event->action != hotplug_event->action) {
 
441
                                        HAL_DEBUG (("there is still a event running for this device, wait!"));
 
442
                                        return TRUE;
 
443
                                }
 
444
 
 
445
                        }
 
446
                }
 
447
                return FALSE;
 
448
 
 
449
        default:
 
450
                return FALSE;
 
451
        }
 
452
}
 
453
 
 
454
 
416
455
 
417
456
void 
418
457
hotplug_event_process_queue (void)
432
471
        lp = hotplug_event_queue->head;
433
472
        while (lp != NULL) {
434
473
                hotplug_event = lp->data;
435
 
                HAL_INFO (("checking event %s", hotplug_event->sysfs.sysfs_path));
436
 
                if (!compare_events (hotplug_event, hotplug_event_queue->head)
437
 
                 && !compare_events (hotplug_event, hotplug_events_in_progress)) {
 
474
 
 
475
                if (hotplug_event->action == HOTPLUG_ACTION_ADD)
 
476
                        HAL_DEBUG (("checking ADD event %s", hotplug_event->sysfs.sysfs_path));
 
477
                else if (hotplug_event->action == HOTPLUG_ACTION_REMOVE)
 
478
                        HAL_DEBUG (("checking REMOVE event %s", hotplug_event->sysfs.sysfs_path));
 
479
                else 
 
480
                        HAL_DEBUG (("checking event %s, action: %d", hotplug_event->sysfs.sysfs_path, hotplug_event->action));
 
481
 
 
482
                if (!compare_events (hotplug_event, hotplug_event_queue->head) && 
 
483
                    !compare_events (hotplug_event, hotplug_events_in_progress) &&
 
484
                    !compare_events_running (hotplug_event, hotplug_events_in_progress)) {
438
485
                        lp2 = lp->prev;
439
486
                        g_queue_unlink(hotplug_event_queue, lp);
440
487
                        hotplug_events_in_progress = g_list_concat (hotplug_events_in_progress, lp);