Re: [PATCH v9 1/7] mfd: Add core driver for Nuvoton NCT6694
From: Krzysztof Kozlowski
Date: Thu Apr 10 2025 - 02:05:09 EST
On 09/04/2025 10:27, a0282524688@xxxxxxxxx wrote:
> +
> +static int nct6694_response_err_handling(struct nct6694 *nct6694,
> + unsigned char err_status)
> +{
> + switch (err_status) {
> + case NCT6694_NO_ERROR:
> + return 0;
> + case NCT6694_NOT_SUPPORT_ERROR:
> + dev_err(nct6694->dev, "Command is not supported!\n");
> + break;
> + case NCT6694_NO_RESPONSE_ERROR:
> + dev_warn(nct6694->dev, "Command received no response!\n");
> + break;
> + case NCT6694_TIMEOUT_ERROR:
> + dev_warn(nct6694->dev, "Command timed out!\n");
> + break;
> + case NCT6694_PENDING:
> + dev_err(nct6694->dev, "Command is pending!\n");
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + return -EIO;
> +}
> +
Missing Kconfig. Exported functions are supposed to have it.
> +int nct6694_read_msg(struct nct6694 *nct6694, const struct nct6694_cmd_header *cmd_hd, void *buf)
> +{
> + union nct6694_usb_msg *msg = nct6694->usb_msg;
> + struct usb_device *udev = nct6694->udev;
> + int tx_len, rx_len, ret;
> +
> + guard(mutex)(&nct6694->access_lock);
> +
> + memcpy(&msg->cmd_header, cmd_hd, sizeof(*cmd_hd));
> + msg->cmd_header.hctrl = NCT6694_HCTRL_GET;
> +
> + /* Send command packet to USB device */
> + ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, NCT6694_BULK_OUT_EP), &msg->cmd_header,
> + sizeof(*msg), &tx_len, NCT6694_URB_TIMEOUT);
> + if (ret)
> + return ret;
> +
> + /* Receive response packet from USB device */
> + ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, NCT6694_BULK_IN_EP), &msg->response_header,
> + sizeof(*msg), &rx_len, NCT6694_URB_TIMEOUT);
> + if (ret)
> + return ret;
> +
> + /* Receive data packet from USB device */
> + ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, NCT6694_BULK_IN_EP), buf,
> + le16_to_cpu(cmd_hd->len), &rx_len, NCT6694_URB_TIMEOUT);
> + if (ret)
> + return ret;
> +
> + if (rx_len != le16_to_cpu(cmd_hd->len)) {
> + dev_err(nct6694->dev, "Expected received length %d, but got %d\n",
> + le16_to_cpu(cmd_hd->len), rx_len);
> + return -EIO;
> + }
> +
> + return nct6694_response_err_handling(nct6694, msg->response_header.sts);
> +}
> +EXPORT_SYMBOL(nct6694_read_msg);
GPL
> +
> +int nct6694_write_msg(struct nct6694 *nct6694, const struct nct6694_cmd_header *cmd_hd, void *buf)
> +{
> + union nct6694_usb_msg *msg = nct6694->usb_msg;
> + struct usb_device *udev = nct6694->udev;
> + int tx_len, rx_len, ret;
> +
> + guard(mutex)(&nct6694->access_lock);
> +
> + memcpy(&msg->cmd_header, cmd_hd, sizeof(*cmd_hd));
> + msg->cmd_header.hctrl = NCT6694_HCTRL_SET;
> +
> + /* Send command packet to USB device */
> + ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, NCT6694_BULK_OUT_EP), &msg->cmd_header,
> + sizeof(*msg), &tx_len, NCT6694_URB_TIMEOUT);
> + if (ret)
> + return ret;
> +
> + /* Send data packet to USB device */
> + ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, NCT6694_BULK_OUT_EP), buf,
> + le16_to_cpu(cmd_hd->len), &tx_len, NCT6694_URB_TIMEOUT);
> + if (ret)
> + return ret;
> +
> + /* Receive response packet from USB device */
> + ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, NCT6694_BULK_IN_EP), &msg->response_header,
> + sizeof(*msg), &rx_len, NCT6694_URB_TIMEOUT);
> + if (ret)
> + return ret;
> +
> + /* Receive data packet from USB device */
> + ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, NCT6694_BULK_IN_EP), buf,
> + le16_to_cpu(cmd_hd->len), &rx_len, NCT6694_URB_TIMEOUT);
> + if (ret)
> + return ret;
> +
> + if (rx_len != le16_to_cpu(cmd_hd->len)) {
> + dev_err(nct6694->dev, "Expected transmitted length %d, but got %d\n",
> + le16_to_cpu(cmd_hd->len), rx_len);
> + return -EIO;
> + }
> +
> + return nct6694_response_err_handling(nct6694, msg->response_header.sts);
> +}
> +EXPORT_SYMBOL(nct6694_write_msg);
> +
Same comments.
Best regards,
Krzysztof