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

(-)a/hald/linux/device.c (-29 / +101 lines)
Lines 3346-3351 pseudo_compute_udi (HalDevice *d) Link Here
3346
3346
3347
/*--------------------------------------------------------------------------------------------------------------*/
3347
/*--------------------------------------------------------------------------------------------------------------*/
3348
3348
3349
static HalDevice *
3350
generic_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
3351
{
3352
	HalDevice *d;
3353
3354
	d = hal_device_new ();
3355
3356
	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
3357
3358
	return d;
3359
}
3360
3361
static gboolean
3362
generic_compute_udi (HalDevice *d)
3363
{
3364
	gchar udi[256];
3365
3366
	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi), "%s_%s",
3367
			      hal_device_property_get_string (d, "info.parent"),
3368
			      hal_device_property_get_string (d, "linux.subsystem"));
3369
	hal_device_set_udi (d, udi);
3370
	hal_device_property_set_string (d, "info.udi", udi);
3371
3372
	return TRUE;
3373
}
3374
3375
3376
/*--------------------------------------------------------------------------------------------------------------*/
3377
3349
static gboolean
3378
static gboolean
3350
dev_remove (HalDevice *d)
3379
dev_remove (HalDevice *d)
3351
{
3380
{
Lines 3646-3651 static DevHandler dev_handler_pseudo = { Link Here
3646
	.remove      = dev_remove
3675
	.remove      = dev_remove
3647
};
3676
};
3648
3677
3678
static DevHandler dev_handler_generic = 
3679
{ 
3680
	.subsystem    = "generic",
3681
	.add          = generic_add,
3682
	.compute_udi  = generic_compute_udi,
3683
	.remove       = dev_remove
3684
};
3685
3649
/*--------------------------------------------------------------------------------------------------------------*/
3686
/*--------------------------------------------------------------------------------------------------------------*/
3650
3687
3651
static DevHandler *dev_handlers[] = {
3688
static DevHandler *dev_handlers[] = {
Lines 3824-3829 out: Link Here
3824
  ;
3861
  ;
3825
}
3862
}
3826
3863
3864
static gboolean
3865
dev_add(DevHandler *handler,
3866
		const gchar *subsystem, const gchar *sysfs_path, const gchar *device_file,
3867
		HalDevice *parent_dev, const gchar *parent_path, void *end_token)
3868
{
3869
	HalDevice *d;
3870
3871
	if (strcmp (subsystem, "scsi") == 0)
3872
		if (missing_scsi_host (sysfs_path, (HotplugEvent *)end_token, HOTPLUG_ACTION_ADD))
3873
			return TRUE; // XXX need hotplug_event_end() and FALSE here?
3874
3875
	/* attempt to add the device */
3876
	d = handler->add (sysfs_path, device_file, parent_dev, parent_path);
3877
	if (d == NULL) {
3878
		/* didn't match - there may be a later handler for the device though */
3879
		return FALSE;
3880
	}
3881
3882
	if(!hal_device_has_property(d, "linux.sysfs_path")) {
3883
		hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
3884
	}
3885
3886
	if(!hal_device_has_property(d, "info.parent")) {
3887
		if (parent_dev != NULL) {
3888
			hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
3889
		} else {
3890
			hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
3891
		}
3892
	}
3893
3894
	if(!hal_device_has_property(d, "info.product")) {
3895
		gchar buf[256];
3896
		g_snprintf(buf, sizeof(buf), "%s device %s", subsystem, device_file);
3897
		hal_device_property_set_string (d, "info.product", buf);
3898
	}
3899
3900
	hal_device_property_set_int (d, "linux.hotplug_type", HOTPLUG_EVENT_SYSFS_DEVICE);
3901
	hal_device_property_set_string (d, "linux.subsystem", subsystem);
3902
3903
	if (device_file != NULL && strlen (device_file) > 0)
3904
		hal_device_property_set_string (d, "linux.device_file", device_file);
3905
3906
	/* Add to temporary device store */
3907
	hal_device_store_add (hald_get_tdl (), d);
3908
3909
	/* Process preprobe fdi files */
3910
	di_search_and_merge (d, DEVICE_INFO_TYPE_PREPROBE);
3911
3912
	/* Run preprobe callouts */
3913
	hal_util_callout_device_preprobe (d, dev_callouts_preprobing_done, end_token, handler);
3914
3915
	return TRUE;
3916
}
3917
3827
void
3918
void
3828
hotplug_event_begin_add_dev (const gchar *subsystem, const gchar *sysfs_path, const gchar *device_file,
3919
hotplug_event_begin_add_dev (const gchar *subsystem, const gchar *sysfs_path, const gchar *device_file,
3829
				  HalDevice *parent_dev, const gchar *parent_path,
3920
				  HalDevice *parent_dev, const gchar *parent_path,
Lines 3850-3887 hotplug_event_begin_add_dev (const gchar *subsystem, const gchar *sysfs_path, co Link Here
3850
3941
3851
		handler = dev_handlers[i];
3942
		handler = dev_handlers[i];
3852
		if (strcmp (handler->subsystem, subsystem) == 0) {
3943
		if (strcmp (handler->subsystem, subsystem) == 0) {
3853
			HalDevice *d;
3854
3855
			if (strcmp (subsystem, "scsi") == 0)
3856
				if (missing_scsi_host (sysfs_path, (HotplugEvent *)end_token, HOTPLUG_ACTION_ADD))
3857
					goto out;
3858
3859
			/* attempt to add the device */
3860
			d = handler->add (sysfs_path, device_file, parent_dev, parent_path);
3861
			if (d == NULL) {
3862
				/* didn't match - there may be a later handler for the device though */
3863
				continue;
3864
			}
3865
3866
			hal_device_property_set_int (d, "linux.hotplug_type", HOTPLUG_EVENT_SYSFS_DEVICE);
3867
			hal_device_property_set_string (d, "linux.subsystem", subsystem);
3868
3944
3869
			if (device_file != NULL && strlen (device_file) > 0)
3945
 			if(dev_add(handler, subsystem, sysfs_path,
3870
				hal_device_property_set_string (d, "linux.device_file", device_file);
3946
 					device_file, parent_dev, parent_path, end_token))
3871
3947
				goto out;
3872
			/* Add to temporary device store */
3873
			hal_device_store_add (hald_get_tdl (), d);
3874
3875
			/* Process preprobe fdi files */
3876
			di_search_and_merge (d, DEVICE_INFO_TYPE_PREPROBE);
3877
3878
			/* Run preprobe callouts */
3879
			hal_util_callout_device_preprobe (d, dev_callouts_preprobing_done, end_token, handler);
3880
			goto out;
3881
		}
3948
		}
3882
	}
3949
	}
3883
3950
3884
	/* didn't find anything - thus, ignore this hotplug event */
3951
 	if(dev_handlers[i] == NULL && device_file && strlen(device_file) > 0) {
3952
 		if(dev_add(&dev_handler_generic, subsystem, sysfs_path,
3953
 				device_file, parent_dev, parent_path, end_token))
3954
			goto out;
3955
 	}
3956
3957
	/* if we come here noone wanted the event - thus, ignore this hotplug event */
3885
	hotplug_event_end (end_token);
3958
	hotplug_event_end (end_token);
3886
out:
3959
out:
3887
	;
3960
	;
3888
- 

Return to bug 235059