From: "József Horváth" <info@ministro.hu>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: '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: Tue, 5 Jan 2021 10:12:11 +0000 [thread overview]
Message-ID: <20210105101211.GA9717@dev> (raw)
In-Reply-To: <fcbd72c2-e3a1-241e-a34b-7aecc41c8964@kernel.org>
On Wed, Dec 16, 2020 at 09:25:47AM +0100, Jiri Slaby wrote:
> 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
Thank you for suggestions.
Üdvözlettel / Best regards:
József Horváth
prev parent reply other threads:[~2021-01-05 10:13 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
2021-01-05 10:12 ` József Horváth [this message]
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=20210105101211.GA9717@dev \
--to=info@ministro.hu \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.