Content-Type: multipart/mixed; boundary="===============7796797504540255886==" MIME-Version: 1.0 From: ramesh.thomas at intel.com Subject: [Accel-config] [PATCH v1 2/6] accel-config: Allow other functionality if mdev support unavailable Date: Sat, 23 Jan 2021 00:35:38 -0500 Message-ID: <20210123053542.615622-3-ramesh.thomas@intel.com> In-Reply-To: 20210123053542.615622-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============7796797504540255886== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ramesh Thomas In older drivers mdev is not supported. To provide backward compatibility disable mdev if not supported and allow other functionality. Signed-off-by: Ramesh Thomas --- accfg/lib/libaccfg.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c index b1de896..69f0f71 100644 --- a/accfg/lib/libaccfg.c +++ b/accfg/lib/libaccfg.c @@ -568,7 +568,11 @@ static void *add_device(void *parent, int id, const ch= ar *ctl_base, char *dev_pr goto err_dev_path; } free(device->mdev_path); - device->mdev_path =3D p; + if (access(p, R_OK)) { + free(p); + device->mdev_path =3D NULL; + } else + device->mdev_path =3D p; = device->device_buf =3D calloc(1, strlen(device->device_path) + MAX_PARAM_LEN); @@ -583,7 +587,7 @@ static void *add_device(void *parent, int id, const cha= r *ctl_base, char *dev_pr if (rc < 0) goto err_dev_path; = - if (add_device_mdevs(ctx, device)) + if (device->mdev_path && add_device_mdevs(ctx, device)) goto err_dev_path; = list_add_tail(&ctx->devices, &device->list); @@ -1012,6 +1016,9 @@ ACCFG_EXPORT int accfg_create_mdev(struct accfg_devic= e *device, unsigned int version; int rc; = + if (!device->mdev_path) + return -ENOENT; + if (type >=3D ACCFG_MDEV_TYPE_UNKNOWN || type < 0) return -EINVAL; = @@ -1069,6 +1076,9 @@ ACCFG_EXPORT int accfg_remove_mdev(struct accfg_devic= e *device, uuid_t uuid) struct accfg_device_mdev *entry, *next; int rc, all; = + if (!device->mdev_path) + return -ENOENT; + /* remove all mdevs if null uuid is passed */ all =3D uuid_is_null(uuid); list_for_each_safe(&device->mdev_list, entry, next, list) { -- = 2.26.2 --===============7796797504540255886==--