[PATCH V6 1/1] nvme: allow passthru cmd error logging

Christoph Hellwig hch at lst.de
Wed Aug 2 05:01:58 PDT 2023


> +
> +	if (ctrl->passthru_log_err)
> +		return sysfs_emit(buf, "on\n");
> +
> +	return sysfs_emit(buf, "off\n");

	return  sysfs_emit(buf, ctrl->passthru_log_err ? "on" : "off");

> +}
> +
> +static ssize_t nvme_passthru_err_log_store(struct device *dev,
> +		struct device_attribute *attr, const char *buf, size_t count)
> +{
> +	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
> +	int passthru_enable, err;
> +
> +	err = kstrtoint(buf, 10, &passthru_enable);
> +	if (err)
> +		return -EINVAL;
> +
> +	switch (passthru_enable) {
> +	case true:
> +	case false:
> +		ctrl->passthru_log_err = passthru_enable;
> +		break;
> +	default:
> +		pr_err("invlid value %d for admin error logging [on:1 off:0]\n",
> +			passthru_enable);
> +		break;
> +	}
> +	return count;

This should use kstrtobool.

Also I thik the flag feels a bit too sparse.  Why not
something like passthru_err_log_enabled that explains what it does?



More information about the Linux-nvme mailing list