From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Christina Quast <contact@christina-quast.de>
Cc: Greg KH <gregkh@linuxfoundation.org>,
linux-serial <linux-serial@vger.kernel.org>,
Daniel Beer <daniel.beer@igorinstitute.com>
Subject: Re: [PATCH v3 RESEND] hid-ft260: Add serial driver
Date: Tue, 28 Nov 2023 12:13:26 +0200 (EET) [thread overview]
Message-ID: <aa99b5f-6f6e-47c7-5956-5034c681d0d7@linux.intel.com> (raw)
In-Reply-To: <0fb134f7-f72e-4742-9c2d-c68f83b67975@christina-quast.de>
On Sun, 26 Nov 2023, Christina Quast wrote:
> Hi Greg!
>
> Thanks for the comments!
>
> On 11/22/23 11:15, Greg KH wrote:
> > On Wed, Nov 22, 2023 at 10:40:03AM +0100, Christina Quast wrote:
> > > This commit adds a serial interface /dev/FTx which implements the tty
> > > serial driver ops, so that it is possible to set the baudrate, send
> > > and receive data, etc.
> > Why is this a serial device? What type of device is it?
> >
> > And why "FTx"? Where did that name come from? That's not a "normal"
> > tty name.
> I meant /dev/ttyFTx. Since it's a hid device providing a serial interface, in
> theory you could also call it /dev/ttySx or /dev/ttyUSBx, but both feel wrong.
> It's an FTDI device, that functions as a USB to UART / I2C Master. Do you have
> a better name in mind?
> > > +struct ft260_uart_write_request_report {
> > > + u8 report; /* FT260_UART_REPORT */
> > > + u8 length; /* data payload length */
> > > + u8 data[]; /* data payload */
> > Shouldn't this be marked as counted by length?
> Do you mean in the comment?
No, try:
git grep __counted_by
> > > + req.data_bit = FT260_CFG_DATA_BITS_8;
> > > + termios->c_cflag &= ~CSIZE;
> > > + termios->c_cflag |= CS8;
> > > + break;
> > > + default:
> > > + case CS8:
> > > + req.data_bit = FT260_CFG_DATA_BITS_8;
> > > + break;
> > > + }
> > > +
> > > + req.stop_bit = (termios->c_cflag & CSTOPB) ?
> > > + FT260_CFG_STOP_TWO_BIT : FT260_CFG_STOP_ONE_BIT;
> > > +
> > > + if (termios->c_cflag & PARENB) {
> > > + req.parity = (termios->c_cflag & PARODD) ?
> > > + FT260_CFG_PAR_ODD : FT260_CFG_PAR_EVEN;
> > > + } else {
> > > + req.parity = FT260_CFG_PAR_NO;
> > > + }
> > > +
> > > + baud = tty_termios_baud_rate(termios);
> > > + if (baud == 0 || baud < FT260_CFG_BAUD_MIN || baud >
> > > FT260_CFG_BAUD_MAX) {
> > > + struct tty_struct *tty = tty_port_tty_get(&port->port);
> > Blank line needed here.
> >
> > > + hid_err(hdev, "Invalid baud rate %d\n", baud);
> > Again, debug error? And why not report an error instead of just setting
> > it to 9600?
> >
> > And why 9600?
>
> This is a default setting used in the FT260 documentation as default value, so
> it seemed like a sensible value.
>
> The ft260_uart_change_speed function is called in set_termios, which has a
> void return type. So even if I returned an error, that would not be propagated
> to userspace. It looks like the userspace is meant to check what values were
> actually set with a subsequent ioctl call.
Setting termios does not propagate errors (legacy feature, I don't know
the reason).
However, every set termios handling function should ensure if any value
from the input termios is changed because the HW cannot do what has been
requested, the changes should be reflected in the termios so that
userspace knows about them (could check but I don't know if any userspace
application actually does that, and I'm quite skeptical they would).
IIRC, termios is returned also from the setting call.
--
i.
next prev parent reply other threads:[~2023-11-28 10:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 9:40 [PATCH v3 RESEND] hid-ft260: Add serial driver Christina Quast
2023-11-22 10:15 ` Greg KH
2023-11-26 9:53 ` Christina Quast
2023-11-28 10:13 ` Ilpo Järvinen [this message]
2023-11-30 13:38 ` Christina Quast
2023-11-28 10:29 ` Greg KH
2023-11-30 13:55 ` Christina Quast
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=aa99b5f-6f6e-47c7-5956-5034c681d0d7@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=contact@christina-quast.de \
--cc=daniel.beer@igorinstitute.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-serial@vger.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).