devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: "József Horváth" <info@ministro.hu>,
	"'Greg Kroah-Hartman'" <gregkh@linuxfoundation.org>,
	"'Rob Herring'" <robh+dt@kernel.org>,
	linux-serial@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6] Serial: silabs si4455 serial driver
Date: Wed, 16 Dec 2020 09:25:47 +0100	[thread overview]
Message-ID: <fcbd72c2-e3a1-241e-a34b-7aecc41c8964@kernel.org> (raw)
In-Reply-To: <20201215181506.GA20057@dev>

On 15. 12. 20, 19:15, József Horváth wrote:
> --- /dev/null
> +++ b/drivers/tty/serial/si4455.c
> @@ -0,0 +1,1372 @@
...
> +static int si4455_write_data(struct uart_port *port, u8 command, int poll,
> +			     int length, const u8 *data)
> +{
> +	int ret = 0;
> +	u8 *data_out;
> +
> +	if (poll) {
> +		ret = si4455_poll_cts(port);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	data_out = kzalloc(1 + length, GFP_KERNEL);
> +	if (!data_out)
> +		return -ENOMEM;
> +
> +	data_out[0] = command;
> +	memcpy(&data_out[1], data, length);
> +	ret = spi_write(to_spi_device(port->dev), data_out, 1 + length);
> +	if (ret) {
> +		dev_err(port->dev,
> +			"%s: spi_write error (%i)\n", __func__, ret);
> +	}
> +
> +	kfree(data_out);
> +
> +	return ret;
> +}
> +
> +static void si4455_set_power(struct si4455_port *priv, int on)

"on" can be bool here. And "poll" in earlier functions. And "on" in 
later ones.

> +{
> +	if (!priv->shdn_gpio)
> +		return;
> +	if (on) {
> +		gpiod_direction_output(priv->shdn_gpio, 0);
> +		usleep_range(4000, 5000);
> +		gpiod_set_value(priv->shdn_gpio, 1);
> +		usleep_range(4000, 5000);
> +	} else {
> +		gpiod_direction_output(priv->shdn_gpio, 0);
> +	}

The above can be simpler:

gpiod_direction_output(priv->shdn_gpio, 0);

if (on) {
	usleep_range(4000, 5000);
	gpiod_set_value(priv->shdn_gpio, 1);
	usleep_range(4000, 5000);
}

> +static void si4455_handle_rx_pend(struct si4455_port *s)
> +{
> +	struct uart_port *port = &s->port;
> +	u8 *data = NULL;

Unused initialization.

> +	int sret = 0;
> +	int i = 0;
> +
> +	if (s->package_size == 0) {
> +		//TODO: variable packet length
> +		dev_err(port->dev, "%s: variable packet length is not supported by the driver\n",
> +			__func__);
> +		return;
> +	}
> +
> +	data = kzalloc(s->package_size, GFP_KERNEL);

Missing check of data.

> +	sret = si4455_end_rx(port, s->package_size, data);
> +	if (sret) {
> +		dev_err(port->dev, "%s: si4455_end_rx error (%i)\n",
> +			__func__, sret);
> +	} else {
> +		for (i = 0; i < s->package_size; i++) {
> +			uart_insert_char(port, 0, 0, data[i], TTY_NORMAL);
> +			port->icount.rx++;
> +		}
> +		tty_flip_buffer_push(&port->state->port);
> +	}
> +	kfree(data);
> +}
...
thanks,
-- 
js
suse labs

  reply	other threads:[~2020-12-16  8:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-15 18:15 [PATCH v6] Serial: silabs si4455 serial driver József Horváth
2020-12-16  8:25 ` Jiri Slaby [this message]
2021-01-05 10:12   ` József Horváth

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=fcbd72c2-e3a1-241e-a34b-7aecc41c8964@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=info@ministro.hu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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).