示例#1
0
static int tpmback_probe(struct xenbus_device *dev,
                         const struct xenbus_device_id *id)
{
	int err;
	struct backend_info *be = kzalloc(sizeof(struct backend_info),
	                                  GFP_KERNEL);

	if (!be) {
		xenbus_dev_fatal(dev, -ENOMEM,
		                 "allocating backend structure");
		return -ENOMEM;
	}

	be->is_instance_set = 0;
	be->dev = dev;
	dev->data = be;

	err = xenbus_watch_path2(dev, dev->nodename,
	                        "instance", &be->backend_watch,
	                        backend_changed);
	if (err) {
		goto fail;
	}

	err = xenbus_switch_state(dev, XenbusStateInitWait);
	if (err) {
		goto fail;
	}
	return 0;
fail:
	tpmback_remove(dev);
	return err;
}
示例#2
0
static void frontend_changed(struct xenbus_device *dev,
                             enum xenbus_state frontend_state)
{
	struct backend_info *be = dev->data;
	int err;

	be->frontend_state = frontend_state;

	switch (frontend_state) {
	case XenbusStateInitialising:
	case XenbusStateInitialised:
		break;

	case XenbusStateConnected:
		err = connect_ring(be);
		if (err) {
			return;
		}
		maybe_connect(be);
		break;

	case XenbusStateClosing:
		be->tpmif->tpm_instance = -1;
		break;

	case XenbusStateClosed:
		/*
		 * Notify the vTPM manager about the front-end
		 * having left.
		 */
		tpmif_vtpm_close(be->instance);
		device_unregister(&be->dev->dev);
		tpmback_remove(dev);
		break;

	case XenbusStateUnknown:
	case XenbusStateInitWait:
	default:
		xenbus_dev_fatal(dev, -EINVAL,
		                 "saw state %d at frontend",
		                 frontend_state);
		break;
	}
}
示例#3
0
static void frontend_changed(struct xenbus_device *dev,
			     enum xenbus_state frontend_state)
{
	struct backend_info *be = dev->dev.driver_data;
	int err;

	switch (frontend_state) {
	case XenbusStateInitialising:
	case XenbusStateInitialised:
		break;

	case XenbusStateConnected:
		err = connect_ring(be);
		if (err) {
			return;
		}
		maybe_connect(be);
		break;

	case XenbusStateClosing:
		be->instance = -1;
		break;

	case XenbusStateUnknown:
	case XenbusStateClosed:
		device_unregister(&be->dev->dev);
		tpmback_remove(dev);
		break;

	default:
		xenbus_dev_fatal(dev, -EINVAL,
				 "saw state %d at frontend",
				 frontend_state);
		break;
	}
}