]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
IB/core: Initialize ib_device.dev.parent earlier
authorBart Van Assche <bart.vanassche@sandisk.com>
Fri, 20 Jan 2017 21:04:13 +0000 (13:04 -0800)
committerDoug Ledford <dledford@redhat.com>
Tue, 24 Jan 2017 17:23:35 +0000 (12:23 -0500)
Move the ib_device.dev.parent initialization code from
ib_device_register_sysfs() to ib_register_device(). Additionally,
allow HBA drivers to set ib_device.dev.parent without setting
ib_device.dma_device. This is the first step towards removing
ib_device.dma_device.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/device.c
drivers/infiniband/core/sysfs.c

index 571974cd391981a6009abfdedf6b848029a366c1..d543c43904474036dc406a1320c8c0b10febf85f 100644 (file)
@@ -334,6 +334,14 @@ int ib_register_device(struct ib_device *device,
        struct ib_client *client;
        struct ib_udata uhw = {.outlen = 0, .inlen = 0};
 
+       WARN_ON_ONCE(!device->dev.parent && !device->dma_device);
+       WARN_ON_ONCE(device->dev.parent && device->dma_device
+                    && device->dev.parent != device->dma_device);
+       if (!device->dev.parent)
+               device->dev.parent = device->dma_device;
+       if (!device->dma_device)
+               device->dma_device = device->dev.parent;
+
        mutex_lock(&device_mutex);
 
        if (strchr(device->name, '%')) {
index c1fb545e8d7848218a2a584647e4643eef0fc551..daadf3130c9f5adb985d9b4816675ba298904e03 100644 (file)
@@ -1258,7 +1258,7 @@ int ib_device_register_sysfs(struct ib_device *device,
        int ret;
        int i;
 
-       device->dev.parent = device->dma_device;
+       WARN_ON_ONCE(!device->dev.parent);
        ret = dev_set_name(class_dev, "%s", device->name);
        if (ret)
                return ret;