Content-Type: multipart/mixed; boundary="===============6542249409364306865==" MIME-Version: 1.0 From: Jiang, Dave Subject: [Accel-config] Re: [PATCH v1 01/11] accel-config: Add mdev path to device context Date: Fri, 04 Dec 2020 23:36:29 +0000 Message-ID: <1f0bf7f8715842708e4f6140669b0bf9@intel.com> In-Reply-To: 20201202193057.299615-2-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============6542249409364306865== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: ramesh.thomas(a)intel.com > Sent: Wednesday, December 2, 2020 12:31 PM > To: accel-config(a)lists.01.org > Cc: Thomas, Ramesh ; Luck, Tony > ; Jiang, Dave > Subject: [PATCH v1 01/11] accel-config: Add mdev path to device context > = > From: Ramesh Thomas > = > /sys/class/mdev_bus/ is used often to access mdevs associated with > the device. Generate and store in device so it need not be constructed > everytime. > = > Signed-off-by: Ramesh Thomas Reviewed-by: Dave Jiang Does private.h have a spacing issue? The diff looks rather odd. > --- > accfg/lib/libaccfg.c | 17 +++++++++++++++++ accfg/lib/private.h | 1 + > 2 files changed, 18 insertions(+) > = > diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c index cd9da42..9= b5615a > 100644 > --- a/accfg/lib/libaccfg.c > +++ b/accfg/lib/libaccfg.c > @@ -194,6 +194,7 @@ static void free_device(struct accfg_device *device, > struct list_head *head) > list_del_from(head, &device->list); > free(device->device_path); > free(device->device_buf); > + free(device->mdev_path); > free(device); > } > = > @@ -413,6 +414,7 @@ static void *add_device(void *parent, int id, const > char *ctl_base, char *dev_pr > char *path; > int dfd; > int rc; > + char *p; > = > path =3D calloc(1, strlen(ctl_base) + MAX_PARAM_LEN); > if (!path) { > @@ -470,6 +472,20 @@ static void *add_device(void *parent, int id, const > char *ctl_base, char *dev_pr > goto err_dev_path; > } > = > + device->mdev_path =3D strdup(device->device_path); > + if (!device->mdev_path) { > + err(ctx, "strdup of device_path failed\n"); > + goto err_dev_path; > + } > + > + if (asprintf(&p, "%s/%s", MDEV_BUS, > + basename(dirname(device->mdev_path))) < 0) { > + err(ctx, "device mdev_path allocation failed\n"); > + goto err_dev_path; > + } > + free(device->mdev_path); > + device->mdev_path =3D p; > + > device->device_buf =3D calloc(1, strlen(device->device_path) + > MAX_PARAM_LEN); > if (!device->device_buf) { > @@ -490,6 +506,7 @@ static void *add_device(void *parent, int id, const > char *ctl_base, char *dev_pr > err_dev_path: > err_read: > free(device->device_buf); > + free(device->mdev_path); > free(device); > err_device: > free(path); > diff --git a/accfg/lib/private.h b/accfg/lib/private.h index f38ff23..365= d484 > 100644 > --- a/accfg/lib/private.h > +++ b/accfg/lib/private.h > @@ -30,6 +30,7 @@ struct accfg_device { > struct list_node list; > int group_init; > char *device_path; > + char *mdev_path; > char *device_buf; > char *device_type_str; > enum accfg_device_type type; > -- > 2.26.2 --===============6542249409364306865==--