Re: [PATCH net-next v1] devlink: Simplify devlink resources unregister call
From: Leon Romanovsky
Date: Tue Nov 30 2021 - 03:00:42 EST
On Mon, Nov 29, 2021 at 08:14:00PM -0800, Jakub Kicinski wrote:
> On Sun, 28 Nov 2021 14:42:44 +0200 Leon Romanovsky wrote:
> > The devlink_resources_unregister() used second parameter as an
> > entry point for the recursive removal of devlink resources. None
> > of external to devlink users needed to use this field, so lat's
>
> None of the callers outside of devlink core...
> s/lat/let/
>
> > remove it.
>
> > diff --git a/include/net/devlink.h b/include/net/devlink.h
> > index e3c88fabd700..043fcec8b0aa 100644
> > --- a/include/net/devlink.h
> > +++ b/include/net/devlink.h
> > @@ -361,33 +361,6 @@ devlink_resource_size_params_init(struct devlink_resource_size_params *size_para
> >
> > typedef u64 devlink_resource_occ_get_t(void *priv);
> >
> > -/**
> > - * struct devlink_resource - devlink resource
> > - * @name: name of the resource
> > - * @id: id, per devlink instance
> > - * @size: size of the resource
> > - * @size_new: updated size of the resource, reload is needed
> > - * @size_valid: valid in case the total size of the resource is valid
> > - * including its children
> > - * @parent: parent resource
> > - * @size_params: size parameters
> > - * @list: parent list
> > - * @resource_list: list of child resources
> > - */
> > -struct devlink_resource {
> > - const char *name;
> > - u64 id;
> > - u64 size;
> > - u64 size_new;
> > - bool size_valid;
> > - struct devlink_resource *parent;
> > - struct devlink_resource_size_params size_params;
> > - struct list_head list;
> > - struct list_head resource_list;
> > - devlink_resource_occ_get_t *occ_get;
> > - void *occ_get_priv;
> > -};
>
> > diff --git a/net/core/devlink.c b/net/core/devlink.c
> > index fd21022145a3..db3b52110cf2 100644
> > --- a/net/core/devlink.c
> > +++ b/net/core/devlink.c
> > @@ -69,6 +69,35 @@ struct devlink {
> > char priv[] __aligned(NETDEV_ALIGN);
> > };
> >
> > +/**
> > + * struct devlink_resource - devlink resource
> > + * @name: name of the resource
> > + * @id: id, per devlink instance
> > + * @size: size of the resource
> > + * @size_new: updated size of the resource, reload is needed
> > + * @size_valid: valid in case the total size of the resource is valid
> > + * including its children
> > + * @parent: parent resource
> > + * @size_params: size parameters
> > + * @list: parent list
> > + * @resource_list: list of child resources
> > + * @occ_get: occupancy getter callback
> > + * @occ_get_priv: occupancy getter callback priv
> > + */
> > +struct devlink_resource {
> > + const char *name;
> > + u64 id;
> > + u64 size;
> > + u64 size_new;
> > + bool size_valid;
> > + struct devlink_resource *parent;
> > + struct devlink_resource_size_params size_params;
> > + struct list_head list;
> > + struct list_head resource_list;
> > + devlink_resource_occ_get_t *occ_get;
> > + void *occ_get_priv;
> > +};
>
> Hiding struct devlink_resource is not mentioned in the commit message
> and entirely unrelated to removal of the unused argument.
devlink_resources_unregister() was the API function that is declared in
the devlink.h that used "struct devlink_resource". Once we removed extra
parameter from that function, the "struct devlink_resource" left as not
used at all. So this "hiding" is related and part of this simplification
patch.
I will add it to the commit message.
Thanks