RE: [PATCH rdma-core 04/10] providers: Use the new match_device and allocate_device ops

Amrani, Ram
2017-09-24T13:44:58Z

> diff --git a/providers/qedr/qelr_main.c b/providers/qedr/qelr_main.c
> index 0be4a8c82a1e05..4d1b92f40a413a 100644
> --- a/providers/qedr/qelr_main.c
> +++ b/providers/qedr/qelr_main.c
> @@ -227,53 +227,50 @@ static void qelr_free_context(struct ibv_context *ibctx)
> free(ctx);
> }
>
> -static struct verbs_device *qelr_driver_init(const char *uverbs_sys_path,
> - int abi_version)
> +static bool qedr_device_match(struct verbs_sysfs_dev *sysfs_dev)
> {
> + const char *uverbs_sys_path = sysfs_dev->sysfs_path;
> char value[16];
> - struct qelr_device *dev;
> unsigned int vendor, device;
> int i;
>
> if (ibv_read_sysfs_file(uverbs_sys_path, "device/vendor",
> value, sizeof(value)) < 0)
> - return NULL;
> + return false;
>
> sscanf(value, "%i", &vendor);
>
> if (ibv_read_sysfs_file(uverbs_sys_path, "device/device",
> value, sizeof(value)) < 0)
> - return NULL;
> + return false;
>
> sscanf(value, "%i", &device);
>
> for (i = 0; i < sizeof(hca_table) / sizeof(hca_table[0]); ++i)
> if (vendor == hca_table[i].vendor &&
> device == hca_table[i].device)
> - goto found;
> + return true;
>
> - return NULL;
> -found:
> - if (abi_version != QELR_ABI_VERSION) {
> - fprintf(stderr,
> - "Fatal: libqedr ABI version %d of %s is not supported.\n",
> - abi_version, uverbs_sys_path);
> - return NULL;
> - }
> + return false;
> +}
> +
> +static struct verbs_device *qedr_device_alloc(struct verbs_sysfs_dev *sysfs_dev)
> +{
> + struct qelr_device *dev;
>
> dev = calloc(1, sizeof(*dev));
> - if (!dev) {
> - qelr_err("%s() Fatal: fail allocate device for libqedr\n",
> - __func__);
> + if (!dev)
> return NULL;
> - }
>
> return &dev->ibv_dev;
> }
>
> static const struct verbs_device_ops qelr_dev_ops = {
> .name = "qelr",
> - .init_device = qelr_driver_init,
> + .match_min_abi_version = QELR_ABI_VERSION,
> + .match_max_abi_version = QELR_ABI_VERSION,
> + .match_device = qedr_device_match,
> + .alloc_device = qedr_device_alloc,
> .uninit_device = qelr_uninit_device,
> .alloc_context = qelr_alloc_context,
> .free_context = qelr_free_context,

Please use qelr_ prefix for the functions.
There shouldn't be any qedr in this file except for a comment, maybe.

Other than that:
Signed-off-by: Ram Amrani <Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>