[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231009165741.746184-5-max.kellermann@ionos.com>
Date: Mon, 9 Oct 2023 18:57:38 +0200
From: Max Kellermann <max.kellermann@...os.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>
Cc: Max Kellermann <max.kellermann@...os.com>,
linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org
Subject: [PATCH 5/7] drivers/tty/serial_core: add local variable for newly allocated attribute_group**
This allows the compiler to keep the pointer in a register and
prepares for making the struct field "const".
Signed-off-by: Max Kellermann <max.kellermann@...os.com>
---
drivers/tty/serial/serial_core.c | 11 ++++++-----
include/linux/serial_core.h | 4 ++--
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 7bdc21d5e13b..e253ef474fb4 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -3082,6 +3082,7 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u
struct uart_state *state;
struct tty_port *port;
int ret = 0;
+ const struct attribute_group **tty_groups;
struct device *tty_dev;
int num_groups;
@@ -3132,22 +3133,22 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u
if (uport->attr_group)
num_groups++;
- uport->tty_groups = kcalloc(num_groups, sizeof(*uport->tty_groups),
+ uport->tty_groups = tty_groups = kcalloc(num_groups, sizeof(*tty_groups),
GFP_KERNEL);
- if (!uport->tty_groups) {
+ if (!tty_groups) {
ret = -ENOMEM;
goto out;
}
- uport->tty_groups[0] = &tty_dev_attr_group;
+ tty_groups[0] = &tty_dev_attr_group;
if (uport->attr_group)
- uport->tty_groups[1] = uport->attr_group;
+ tty_groups[1] = uport->attr_group;
/*
* Register the port whether it's detected or not. This allows
* setserial to be used to alter this port's parameters.
*/
tty_dev = tty_port_register_device_attr_serdev(port, drv->tty_driver,
- uport->line, uport->dev, port, uport->tty_groups);
+ uport->line, uport->dev, port, tty_groups);
if (!IS_ERR(tty_dev)) {
device_set_wakeup_capable(tty_dev, 1);
} else {
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index bb6f073bc159..597de109dbf5 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -578,8 +578,8 @@ struct uart_port {
unsigned char suspended;
unsigned char console_reinit;
const char *name; /* port name */
- struct attribute_group *attr_group; /* port specific attributes */
- const struct attribute_group **tty_groups; /* all attributes (serial core use only) */
+ const struct attribute_group *attr_group; /* port specific attributes */
+ const struct attribute_group *const*tty_groups; /* all attributes (serial core use only) */
struct serial_rs485 rs485;
struct serial_rs485 rs485_supported; /* Supported mask for serial_rs485 */
struct gpio_desc *rs485_term_gpio; /* enable RS485 bus termination */
--
2.39.2
Powered by blists - more mailing lists