On Thu, 14 Feb 2019 14:51:01 +0100
Pierre Morel <pmorel@xxxxxxxxxxxxx> wrote:
Libudev relies on having a subsystem link for non-root devices. To
avoid libudev (and potentially other userspace tools) choking on the
matrix device let us introduce a vfio_ap bus and with that the vfio_ap
bus subsytem, and make the matrix device reside within it.
How does libudev choke on this? It feels wrong to introduce a bus that
basically does nothing...
...snip...
We restrict the number of allowed devices to a single one.
+++ b/drivers/s390/crypto/vfio_ap_drv.c
@@ -24,8 +24,9 @@ MODULE_LICENSE("GPL v2");
static struct ap_driver vfio_ap_drv;
-static struct device_type vfio_ap_dev_type = {
- .name = VFIO_AP_DEV_TYPE_NAME,
+struct matrix_driver {
+ struct device_driver drv;
+ int device_count;
This counter basically ensures that at most one device may bind with
this driver... you'd still have that device on the bus, though.
};
struct ap_matrix_dev *matrix_dev;
- matrix_dev->device.type = &vfio_ap_dev_type;
dev_set_name(&matrix_dev->device, "%s", VFIO_AP_DEV_NAME);
matrix_dev->device.parent = root_device;
+ matrix_dev->device.bus = &matrix_bus;
matrix_dev->device.release = vfio_ap_matrix_dev_release;
- matrix_dev->device.driver = &vfio_ap_drv.driver;
+ matrix_dev->vfio_ap_drv = &vfio_ap_drv;
Can't you get that structure through matrix_dev->device.driver instead
when you need it in the function below?
ret = device_register(&matrix_dev->device);
if (ret)
goto matrix_reg_err;
+ ret = driver_register(&matrix_driver.drv);
+ if (ret)
+ goto matrix_drv_err;
+
As you already have several structures that can be registered exactly
once (the root device, the bus, the driver, ...), you can already be
sure that there's only one device on the bus, can't you?