linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: mani@kernel.org
Cc: johan@kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, patong.mxl@gmail.com
Subject: Re: [PATCH v3 1/2] usb: serial: Add MaxLinear/Exar USB to Serial driver
Date: Mon, 18 May 2020 08:07:44 +0200	[thread overview]
Message-ID: <20200518060744.GA2845844@kroah.com> (raw)
In-Reply-To: <20200430184924.31690-2-mani@kernel.org>

On Fri, May 01, 2020 at 12:19:23AM +0530, mani@kernel.org wrote:
> +static int xr_set_reg(struct usb_serial_port *port, u8 block, u8 reg,
> +		      u8 val)
> +{
> +	struct usb_serial *serial = port->serial;
> +	int ret = -EINVAL;
> +
> +	/* XR21V141X uses custom command for writing UART registers */
> +	ret = usb_control_msg(serial->dev,
> +			      usb_sndctrlpipe(serial->dev, 0),
> +			      XR_SET_XR21V141X,
> +			      USB_DIR_OUT | USB_TYPE_VENDOR, val,
> +			      reg | (block << 8), NULL, 0,
> +			      USB_CTRL_SET_TIMEOUT);
> +
> +	if (ret < 0)
> +		dev_err(&port->dev, "Failed to set reg 0x%x status: %d\n",
> +			reg, ret);
> +
> +	return ret;
> +}

So if this call is successful, it would return the number of bytes
written in the control message.  Which is 0.  But that's kind of a hack,
right?  Why not just return 0 to make it more obvious and easier to
read, instead of returning 'ret' and making the reader have to realize
that you only are writing 0 bytes?

> +
> +static int xr_get_reg(struct usb_serial_port *port, u8 block, u8 reg,
> +		      u8 *val)
> +{
> +	struct usb_serial *serial = port->serial;
> +	void *dmabuf;

char *dmabuf; ?

> +	int ret = -EINVAL;
> +
> +	dmabuf = kmalloc(1, GFP_KERNEL);
> +	if (!dmabuf)
> +		return -ENOMEM;
> +
> +	/* XR21V141X uses custom command for reading UART registers */
> +	ret = usb_control_msg(serial->dev,
> +			      usb_rcvctrlpipe(serial->dev, 0),
> +			      XR_GET_XR21V141X,
> +			      USB_DIR_IN | USB_TYPE_VENDOR, 0,
> +			      reg | (block << 8), dmabuf, 1,
> +			      USB_CTRL_SET_TIMEOUT);
> +
> +	if (ret == 1) {
> +		memcpy(val, dmabuf, 1);

*val = *dmabuf; ?

> +		ret = 0;
> +	} else {
> +		dev_err(&port->dev, "Failed to get reg 0x%x status: %d\n",
> +			reg, ret);
> +		if (ret >= 0)
> +			ret = -EIO;
> +	}
> +
> +	kfree(dmabuf);
> +
> +	return ret;
> +}

Anyway, other than these minor things, this looks good to me:

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

  reply	other threads:[~2020-05-18  6:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30 18:49 [PATCH v3 0/2] Add support for MaxLinear/Exar USB to serial converters mani
2020-04-30 18:49 ` [PATCH v3 1/2] usb: serial: Add MaxLinear/Exar USB to Serial driver mani
2020-05-18  6:07   ` Greg KH [this message]
2020-05-19 12:33   ` Johan Hovold
2020-06-06 18:45     ` Manivannan Sadhasivam
2020-04-30 18:49 ` [PATCH v3 2/2] usb: serial: xr_serial: Add gpiochip support mani
2020-05-19 13:07   ` Johan Hovold
2020-05-27  3:09     ` Manivannan Sadhasivam
2020-05-29  9:00       ` Johan Hovold
2020-05-16  7:06 ` [PATCH v3 0/2] Add support for MaxLinear/Exar USB to serial converters Manivannan Sadhasivam
2020-06-05 11:13 ` Mauro Carvalho Chehab
2020-06-06 12:27   ` Manivannan Sadhasivam
2020-06-05 12:40 ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200518060744.GA2845844@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=patong.mxl@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).