diff options
author | Bart Van Assche <bart.vanassche@sandisk.com> | 2017-01-20 16:04:13 -0500 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2017-01-24 12:23:35 -0500 |
commit | 97a9ea848016fef86e4a42dc6a65f4384eed32cd (patch) | |
tree | 29739706ac1a5718bd7ba49fd4ffaae0d9dce779 | |
parent | 5f0cb80134a0035829bf7580126ea371c4aefec5 (diff) |
IB/core: Initialize ib_device.dev.parent earlier
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>
-rw-r--r-- | drivers/infiniband/core/device.c | 8 | ||||
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 571974cd3919..d543c4390447 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c | |||
@@ -334,6 +334,14 @@ int ib_register_device(struct ib_device *device, | |||
334 | struct ib_client *client; | 334 | struct ib_client *client; |
335 | struct ib_udata uhw = {.outlen = 0, .inlen = 0}; | 335 | struct ib_udata uhw = {.outlen = 0, .inlen = 0}; |
336 | 336 | ||
337 | WARN_ON_ONCE(!device->dev.parent && !device->dma_device); | ||
338 | WARN_ON_ONCE(device->dev.parent && device->dma_device | ||
339 | && device->dev.parent != device->dma_device); | ||
340 | if (!device->dev.parent) | ||
341 | device->dev.parent = device->dma_device; | ||
342 | if (!device->dma_device) | ||
343 | device->dma_device = device->dev.parent; | ||
344 | |||
337 | mutex_lock(&device_mutex); | 345 | mutex_lock(&device_mutex); |
338 | 346 | ||
339 | if (strchr(device->name, '%')) { | 347 | if (strchr(device->name, '%')) { |
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index c1fb545e8d78..daadf3130c9f 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -1258,7 +1258,7 @@ int ib_device_register_sysfs(struct ib_device *device, | |||
1258 | int ret; | 1258 | int ret; |
1259 | int i; | 1259 | int i; |
1260 | 1260 | ||
1261 | device->dev.parent = device->dma_device; | 1261 | WARN_ON_ONCE(!device->dev.parent); |
1262 | ret = dev_set_name(class_dev, "%s", device->name); | 1262 | ret = dev_set_name(class_dev, "%s", device->name); |
1263 | if (ret) | 1263 | if (ret) |
1264 | return ret; | 1264 | return ret; |