View | Details | Raw Unified | Return to bug 235059
Collapse All | Expand All

(-)hal-0.5.8_git20061106/hald/linux/device.c (-22 / +95 lines)
Lines 2385-2390 pseudo_compute_udi (HalDevice *d) Link Here
2385
2385
2386
/*--------------------------------------------------------------------------------------------------------------*/
2386
/*--------------------------------------------------------------------------------------------------------------*/
2387
2387
2388
static HalDevice *
2389
generic_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
2390
{
2391
	HalDevice *d;
2392
2393
	d = hal_device_new ();
2394
2395
	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
2396
2397
	return d;
2398
}
2399
2400
static gboolean
2401
generic_compute_udi (HalDevice *d)
2402
{
2403
	gchar udi[256];
2404
2405
	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi), "%s_%s",
2406
			      hal_device_property_get_string (d, "info.parent"),
2407
			      hal_device_property_get_string (d, "linux.subsystem"));
2408
	hal_device_set_udi (d, udi);
2409
	hal_device_property_set_string (d, "info.udi", udi);
2410
2411
	return TRUE;
2412
}
2413
2414
2415
/*--------------------------------------------------------------------------------------------------------------*/
2416
2388
static gboolean
2417
static gboolean
2389
dev_remove (HalDevice *d)
2418
dev_remove (HalDevice *d)
2390
{
2419
{
Lines 2656-2661 static DevHandler dev_handler_pseudo = { Link Here
2656
	.remove      = dev_remove
2685
	.remove      = dev_remove
2657
};
2686
};
2658
2687
2688
static DevHandler dev_handler_generic = 
2689
{ 
2690
	.subsystem    = "generic",
2691
	.add          = generic_add,
2692
	.compute_udi  = generic_compute_udi,
2693
	.remove       = dev_remove
2694
};
2695
2659
/*--------------------------------------------------------------------------------------------------------------*/
2696
/*--------------------------------------------------------------------------------------------------------------*/
2660
2697
2661
static DevHandler *dev_handlers[] = {
2698
static DevHandler *dev_handlers[] = {
Lines 2829-2834 out: Link Here
2829
  ;
2866
  ;
2830
}
2867
}
2831
2868
2869
static void
2870
dev_add(DevHandler *handler,
2871
		const gchar *subsystem, const gchar *sysfs_path, const gchar *device_file,
2872
		HalDevice *parent_dev, const gchar *parent_path, void *end_token)
2873
{
2874
	HalDevice *d;
2875
2876
	/* attempt to add the device */
2877
	d = handler->add (sysfs_path, device_file, parent_dev, parent_path);
2878
	if (d == NULL) {
2879
		/* didn't find anything - thus, ignore this hotplug event */
2880
		hotplug_event_end (end_token);
2881
		return;
2882
	}
2883
2884
	if(!hal_device_has_property(d, "linux.sysfs_path")) {
2885
		hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
2886
	}
2887
2888
	if(!hal_device_has_property(d, "info.parent")) {
2889
		if (parent_dev != NULL) {
2890
			hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
2891
		} else {
2892
			hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
2893
		}
2894
	}
2895
2896
	if(!hal_device_has_property(d, "info.product")) {
2897
		gchar buf[256];
2898
		g_snprintf(buf, sizeof(buf), "%s device %s", subsystem, device_file);
2899
		hal_device_property_set_string (d, "info.product", buf);
2900
	}
2901
2902
	hal_device_property_set_int (d, "linux.hotplug_type", HOTPLUG_EVENT_SYSFS_DEVICE);
2903
	hal_device_property_set_string (d, "linux.subsystem", subsystem);
2904
2905
	if (device_file != NULL && strlen (device_file) > 0)
2906
		hal_device_property_set_string (d, "linux.device_file", device_file);
2907
2908
	/* Add to temporary device store */
2909
	hal_device_store_add (hald_get_tdl (), d);
2910
2911
	/* Process preprobe fdi files */
2912
	di_search_and_merge (d, DEVICE_INFO_TYPE_PREPROBE);
2913
2914
	/* Run preprobe callouts */
2915
	hal_util_callout_device_preprobe (d, dev_callouts_preprobing_done, end_token, handler);
2916
}
2917
2832
void
2918
void
2833
hotplug_event_begin_add_dev (const gchar *subsystem, const gchar *sysfs_path, const gchar *device_file,
2919
hotplug_event_begin_add_dev (const gchar *subsystem, const gchar *sysfs_path, const gchar *device_file,
2834
				  HalDevice *parent_dev, const gchar *parent_path,
2920
				  HalDevice *parent_dev, const gchar *parent_path,
Lines 2855-2887 hotplug_event_begin_add_dev (const gchar Link Here
2855
2941
2856
		handler = dev_handlers[i];
2942
		handler = dev_handlers[i];
2857
		if (strcmp (handler->subsystem, subsystem) == 0) {
2943
		if (strcmp (handler->subsystem, subsystem) == 0) {
2858
			HalDevice *d;
2859
2860
			/* attempt to add the device */
2861
			d = handler->add (sysfs_path, device_file, parent_dev, parent_path);
2862
			if (d == NULL) {
2863
				/* didn't find anything - thus, ignore this hotplug event */
2864
				hotplug_event_end (end_token);
2865
				goto out;
2866
			}
2867
2868
			hal_device_property_set_int (d, "linux.hotplug_type", HOTPLUG_EVENT_SYSFS_DEVICE);
2869
			hal_device_property_set_string (d, "linux.subsystem", subsystem);
2870
			
2944
			
2871
			if (device_file != NULL && strlen (device_file) > 0)
2945
			dev_add(handler, subsystem, sysfs_path,
2872
				hal_device_property_set_string (d, "linux.device_file", device_file);
2946
					device_file, parent_dev, parent_path, end_token);
2873
2947
2874
			/* Add to temporary device store */
2875
			hal_device_store_add (hald_get_tdl (), d);
2876
2877
			/* Process preprobe fdi files */
2878
			di_search_and_merge (d, DEVICE_INFO_TYPE_PREPROBE);
2879
2880
			/* Run preprobe callouts */
2881
			hal_util_callout_device_preprobe (d, dev_callouts_preprobing_done, end_token, handler);
2882
			goto out;
2948
			goto out;
2883
		}
2949
		}
2884
	}
2950
	}
2951
	
2952
	if(dev_handlers[i] == NULL && device_file && strlen(device_file) > 0) {
2953
		dev_add(&dev_handler_generic, subsystem, sysfs_path,
2954
				device_file, parent_dev, parent_path, end_token);
2955
2956
		goto out;
2957
	}
2885
2958
2886
	/* didn't find anything - thus, ignore this hotplug event */
2959
	/* didn't find anything - thus, ignore this hotplug event */
2887
	hotplug_event_end (end_token);
2960
	hotplug_event_end (end_token);

Return to bug 235059