[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fcbd72c2-e3a1-241e-a34b-7aecc41c8964@kernel.org>
Date: Wed, 16 Dec 2020 09:25:47 +0100
From: Jiri Slaby <jirislaby@...nel.org>
To: József Horváth <info@...istro.hu>,
'Greg Kroah-Hartman' <gregkh@...uxfoundation.org>,
'Rob Herring' <robh+dt@...nel.org>,
linux-serial@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v6] Serial: silabs si4455 serial driver
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
Powered by blists - more mailing lists