Re: [PATCH v4 1/5] mfd: Add support for Intel LJCA device

From: Greg Kroah-Hartman
Date: Thu Mar 09 2023 - 02:53:51 EST


On Thu, Mar 09, 2023 at 03:10:56PM +0800, Ye Xiang wrote:
> +static int ljca_mng_get_version(struct ljca_stub *stub, char *buf)
> +{
> + struct fw_version version = {};
> + unsigned int len = sizeof(version);
> + int ret;
> +
> + ret = ljca_stub_write(stub, LJCA_MNG_GET_VERSION, NULL, 0, &version, &len, true,
> + LJCA_USB_WRITE_ACK_TIMEOUT_MS);
> + if (ret)
> + return ret;
> +
> + if (len != sizeof(version)) {
> + dev_err(&stub->intf->dev, "get version failed, len:%d\n", len);
> + return -EINVAL;
> + }
> +
> + return sysfs_emit(buf, "%d.%d.%d.%d\n", version.major, version.minor,
> + le16_to_cpu(version.patch), le16_to_cpu(version.build));
> +}

You have sysfs files, yet no Documentation/ABI/ entries? That's not
allowed, you know this :(

> +static ssize_t cmd_store(struct device *dev, struct device_attribute *attr, const char *buf,
> + size_t count)
> +{
> + struct usb_interface *intf = to_usb_interface(dev);
> + struct ljca_dev *ljca_dev = usb_get_intfdata(intf);
> + struct ljca_stub *mng_stub = ljca_stub_find(ljca_dev, LJCA_MNG_STUB);
> + struct ljca_stub *diag_stub = ljca_stub_find(ljca_dev, LJCA_DIAG_STUB);
> +
> + if (sysfs_streq(buf, "dfu"))
> + ljca_mng_set_dfu_mode(mng_stub);
> + else if (sysfs_streq(buf, "debug"))
> + ljca_diag_set_trace_level(diag_stub, 3);

Sorry, but no, you can't do this in a sysfs file.

> +
> + return count;
> +}
> +
> +static ssize_t cmd_show(struct device *dev, struct device_attribute *attr, char *buf)
> +{
> + return sysfs_emit(buf, "%s\n", "supported cmd: [dfu, debug]");

sysfs files do not show "help text".

thanks,

greg k-h