[PATCH 2/2] nvme: Expose cntrltype and dctype through sysfs.
Belanger, Martin
Martin.Belanger at dell.com
Thu Feb 3 08:46:59 PST 2022
> >> There is already an interface to update sysfs groups, so in theory
> >> this should do the trick:
> >> --
> >> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> >> index c11cd3a814fd..d86828cf7720 100644
> >> --- a/drivers/nvme/host/core.c
> >> +++ b/drivers/nvme/host/core.c
> >> @@ -3115,6 +3115,11 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl)
> >> return ret;
> >> }
> >>
> >> + ret = sysfs_update_groups(&ctrl->device->kobj,
> >> ctrl->device->groups);
> >> + if (ret)
> >> + return ret;
> >> +
> >> +
> >
> > I just tried this and it works.
>
> Makes sense.
>
> > Martin
> >
> >> ctrl->identified = true;
> >>
> >> return 0;
> >> --
> >>
> >> But probably we want add a nicer interface like
> >> --
> >> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> >> index c11cd3a814fd..8fb94cb15fb0 100644
> >> --- a/drivers/nvme/host/core.c
> >> +++ b/drivers/nvme/host/core.c
> >> @@ -3115,6 +3115,11 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl)
> >> return ret;
> >> }
> >>
> >> + ret = device_update_groups(&ctrl->device);
> >> + if (ret)
> >> + return ret;
> >> +
> >> +
> >> ctrl->identified = true;
> >>
> >> return 0;
> >> --
> >>
> >> Where device_update_groups would be something like:
> >> --
> >> int device_update_groups(struct device *dev) {
> >> struct class *class = dev->class;
> >> const struct device_type *type = dev->type;
> >> int error;
> >>
> >> if (class) {
> >> error = device_update_groups(dev, class->dev_groups);
> >> if (error)
> >> return error;
> >> }
> >>
> >> if (type) {
> >> error = device_update_groups(dev, type->groups);
> >> if (error)
> >> goto err_remove_class_groups;
> >> }
> >>
> >> error = device_update_groups(dev, dev->groups);
> >> if (error)
> >> goto err_remove_type_groups;
>
> This last hunk should probably be:
> return device_update_groups(dev, dev->groups);
>
> >> }
> >> EXPORT_SYMBOL_GPL(device_update_groups);
> >> --
> >
> > Sagi, would you add this function to drivers/base/core.c?
> > Martin
>
> Yes. This would need some more eyeballs though, maybe this should be
> extended to device_update_attrs?
Is the linux-nvme repo even the right place to submit this change?
This is a core kernel file and not just the nvme module.
Submitting this change will probably delay what I'm trying
to release by weeks. Is it OK if I just submit the small change
and leave this bigger change to someone that has more
experience with the kernel?
Martin
Internal Use - Confidential
More information about the Linux-nvme
mailing list