[PATCH 8/8] nvme: move chardev and sysfs interface to common code
Keith Busch
keith.busch at intel.com
Wed Oct 14 09:03:00 PDT 2015
On Mon, 12 Oct 2015, Christoph Hellwig wrote:
> +static ssize_t nvme_sysfs_reset(struct device *dev,
> + struct device_attribute *attr, const char *buf,
> + size_t count)
> +{
> + struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = ctrl->ops->reset_ctrl(ctrl);
> + if (ret < 0)
> + return ret;
> + return count;
> +}
> +static DEVICE_ATTR(reset_controller, S_IWUSR, NULL, nvme_sysfs_reset);
...
> +int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
> + const struct nvme_ctrl_ops *ops, u16 vendor,
> + unsigned long quirks)
> +{
...
> + get_device(ctrl->device);
> + dev_set_drvdata(ctrl->device, dev);
To match the controller extraction in nvme_sysfs_reset, change the above to:
+ dev_set_drvdata(ctrl->device, ctrl);
> + ret = device_create_file(ctrl->device, &dev_attr_reset_controller);
More information about the Linux-nvme
mailing list