From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
"open list:SERIAL DRIVERS" <linux-serial@vger.kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Vladimir Zapolskiy <vz@mleia.com>,
Russell King <linux@armlinux.org.uk>,
Richard Genoud <richard.genoud@gmail.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Beznea <claudiu.beznea@microchip.com>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Linux Documentation List <linux-doc@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>,
linux-stm32@st-md-mailman.stormreply.com,
Lino Sanfilippo <LinoSanfilippo@gmx.de>
Subject: Re: [PATCH 3/3] serial: Add kserial_rs485 to avoid wasted space due to .padding
Date: Mon, 29 Aug 2022 15:09:09 +0300 (EEST) [thread overview]
Message-ID: <1712a4c5-638-4e63-af29-32bdcbaab443@linux.intel.com> (raw)
In-Reply-To: <CAHp75Vc4NfZE6DxFnfeAS9fxnZHpxMjacHy1TsG8ib+FiCqFLQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1644 bytes --]
On Fri, 26 Aug 2022, Andy Shevchenko wrote:
> On Fri, Aug 26, 2022 at 5:51 PM Ilpo Järvinen
> <ilpo.jarvinen@linux.intel.com> wrote:
>
> > -static int user_rs485_to_kernel_serial_rs485(struct serial_rs485 *rs485,
> > +static int user_rs485_to_kernel_serial_rs485(struct kserial_rs485 *rs485,
> > const struct serial_rs485 __user *rs485_user)
> > {
> > - if (copy_from_user(rs485, rs485_user, sizeof(*rs485)))
> > + struct serial_rs485 rs485_uapi;
> > +
> > + if (copy_from_user(&rs485_uapi, rs485_user, sizeof(*rs485)))
> > return -EFAULT;
>
> > + *rs485 = *((struct kserial_rs485 *)&rs485_uapi);
>
> So with all assets we have we can be sure that on BE64 / BE32 machines
> this will be flawless. Is this assumption correct?
I think so. At worst it could trigger a build fail assuming the kernel
would do some really odd struct layout reordering (which, according to
the build bot, doesn't occur for any currently tested arch).
Now that you highlighted this line though, I started to wonder if it would
be just better to use memcpy() instead as it would avoid those casts.
> > + * padding.
> > + */
> > +struct kserial_rs485 {
> > + __u32 flags; /* RS485 feature flags */
> > + __u32 delay_rts_before_send; /* Delay before send (milliseconds) */
> > + __u32 delay_rts_after_send; /* Delay after send (milliseconds) */
> > + struct {
> > + __u8 addr_recv;
> > + __u8 addr_dest;
> > + };
>
> Btw, can't we convert them to kernel doc?
Yes, why not.
--
i.
next prev parent reply other threads:[~2022-08-29 12:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 14:46 [PATCH 0/3] serial: Create kserial_rs485 to get rid of padding Ilpo Järvinen
2022-08-26 14:46 ` [PATCH 1/3] serial: Rename vars in uart_get_rs485_config() Ilpo Järvinen
2022-08-26 15:39 ` Andy Shevchenko
2022-08-26 14:46 ` [PATCH 2/3] serial: add helpers to copy serial_rs485 from/to userspace Ilpo Järvinen
2022-08-26 15:42 ` Andy Shevchenko
2022-08-26 14:46 ` [PATCH 3/3] serial: Add kserial_rs485 to avoid wasted space due to .padding Ilpo Järvinen
2022-08-26 15:50 ` Andy Shevchenko
2022-08-29 12:09 ` Ilpo Järvinen [this message]
2022-08-29 12:14 ` Andy Shevchenko
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=1712a4c5-638-4e63-af29-32bdcbaab443@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=LinoSanfilippo@gmx.de \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=claudiu.beznea@microchip.com \
--cc=corbet@lwn.net \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=mcoquelin.stm32@gmail.com \
--cc=nicolas.ferre@microchip.com \
--cc=richard.genoud@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=vz@mleia.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