linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups
@ 2022-03-07  8:08 ` Krzysztof Kozlowski
  2022-03-07  8:08   ` [PATCH v2 1/7] tty: serial: samsung: embed s3c24xx_uart_info in parent structure Krzysztof Kozlowski
                     ` (8 more replies)
  0 siblings, 9 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:08 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

Hi,

Changes since v1:
1. Patch 3: remove unneeded parenthesis and module alias change (Jiri).
2. Patch 3: move unrelated "constify" bits to patch 6.
3. Patch 5: fix typo.
4. Add review tags.

Best regards,
Krzysztof

Krzysztof Kozlowski (7):
  tty: serial: samsung: embed s3c24xx_uart_info in parent structure
  tty: serial: samsung: embed s3c2410_uartcfg in parent structure
  tty: serial: samsung: constify s3c24xx_serial_drv_data
  tty: serial: samsung: constify UART name
  tty: serial: samsung: constify s3c24xx_serial_drv_data members
  tty: serial: samsung: constify variables and pointers
  tty: serial: samsung: simplify getting OF match data

 drivers/tty/serial/samsung_tty.c | 225 +++++++++++++++----------------
 1 file changed, 109 insertions(+), 116 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 1/7] tty: serial: samsung: embed s3c24xx_uart_info in parent structure
  2022-03-07  8:08 ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Krzysztof Kozlowski
@ 2022-03-07  8:08   ` Krzysztof Kozlowski
  2022-03-07  8:08   ` Krzysztof Kozlowski
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:08 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

Embed "struct s3c24xx_uart_info" directly as a member of "struct
s3c24xx_serial_drv_data" instead of keeping it as a pointer.  This makes
the code clearer (obvious ownership of "struct s3c24xx_serial_drv_data")
and saves one pointer.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
---
 drivers/tty/serial/samsung_tty.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index d002a4e48ed9..aa5678d03704 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -85,7 +85,7 @@ struct s3c24xx_uart_info {
 };
 
 struct s3c24xx_serial_drv_data {
-	struct s3c24xx_uart_info	*info;
+	struct s3c24xx_uart_info	info;
 	struct s3c2410_uartcfg		*def_cfg;
 	unsigned int			fifosize[CONFIG_SERIAL_SAMSUNG_UARTS];
 };
@@ -2197,7 +2197,7 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
 	}
 
 	ourport->baudclk = ERR_PTR(-EINVAL);
-	ourport->info = ourport->drv_data->info;
+	ourport->info = &ourport->drv_data->info;
 	ourport->cfg = (dev_get_platdata(&pdev->dev)) ?
 			dev_get_platdata(&pdev->dev) :
 			ourport->drv_data->def_cfg;
@@ -2616,7 +2616,7 @@ static struct console s3c24xx_serial_console = {
 
 #ifdef CONFIG_CPU_S3C2410
 static struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Samsung S3C2410 UART",
 		.type		= TYPE_S3C24XX,
 		.port_type	= PORT_S3C2410,
@@ -2644,7 +2644,7 @@ static struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
 
 #ifdef CONFIG_CPU_S3C2412
 static struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Samsung S3C2412 UART",
 		.type		= TYPE_S3C24XX,
 		.port_type	= PORT_S3C2412,
@@ -2674,7 +2674,7 @@ static struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
 #if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2416) || \
 	defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2442)
 static struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Samsung S3C2440 UART",
 		.type		= TYPE_S3C24XX,
 		.port_type	= PORT_S3C2440,
@@ -2704,7 +2704,7 @@ static struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
 
 #if defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410)
 static struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Samsung S3C6400 UART",
 		.type		= TYPE_S3C6400,
 		.port_type	= PORT_S3C6400,
@@ -2733,7 +2733,7 @@ static struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
 
 #ifdef CONFIG_CPU_S5PV210
 static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Samsung S5PV210 UART",
 		.type		= TYPE_S3C6400,
 		.port_type	= PORT_S3C6400,
@@ -2762,7 +2762,7 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
 
 #if defined(CONFIG_ARCH_EXYNOS)
 #define EXYNOS_COMMON_SERIAL_DRV_DATA()				\
-	.info = &(struct s3c24xx_uart_info) {			\
+	.info = {						\
 		.name		= "Samsung Exynos UART",	\
 		.type		= TYPE_S3C6400,			\
 		.port_type	= PORT_S3C6400,			\
@@ -2811,7 +2811,7 @@ static struct s3c24xx_serial_drv_data exynos850_serial_drv_data = {
 
 #ifdef CONFIG_ARCH_APPLE
 static struct s3c24xx_serial_drv_data s5l_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Apple S5L UART",
 		.type		= TYPE_APPLE_S5L,
 		.port_type	= PORT_8250,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 1/7] tty: serial: samsung: embed s3c24xx_uart_info in parent structure
  2022-03-07  8:08 ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Krzysztof Kozlowski
  2022-03-07  8:08   ` [PATCH v2 1/7] tty: serial: samsung: embed s3c24xx_uart_info in parent structure Krzysztof Kozlowski
@ 2022-03-07  8:08   ` Krzysztof Kozlowski
  2022-03-07  8:10     ` Krzysztof Kozlowski
  2022-03-07  8:09   ` [PATCH v2 2/7] tty: serial: samsung: embed s3c2410_uartcfg " Krzysztof Kozlowski
                     ` (6 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:08 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

Embed "struct s3c24xx_uart_info" directly as a member of "struct
s3c24xx_serial_drv_data" instead of keeping it as a pointer.  This makes
the code clearer (obvious ownership of "struct s3c24xx_serial_drv_data")
and saves one pointer.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
---
 drivers/tty/serial/samsung_tty.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index d002a4e48ed9..aa5678d03704 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -85,7 +85,7 @@ struct s3c24xx_uart_info {
 };
 
 struct s3c24xx_serial_drv_data {
-	struct s3c24xx_uart_info	*info;
+	struct s3c24xx_uart_info	info;
 	struct s3c2410_uartcfg		*def_cfg;
 	unsigned int			fifosize[CONFIG_SERIAL_SAMSUNG_UARTS];
 };
@@ -2197,7 +2197,7 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
 	}
 
 	ourport->baudclk = ERR_PTR(-EINVAL);
-	ourport->info = ourport->drv_data->info;
+	ourport->info = &ourport->drv_data->info;
 	ourport->cfg = (dev_get_platdata(&pdev->dev)) ?
 			dev_get_platdata(&pdev->dev) :
 			ourport->drv_data->def_cfg;
@@ -2616,7 +2616,7 @@ static struct console s3c24xx_serial_console = {
 
 #ifdef CONFIG_CPU_S3C2410
 static struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Samsung S3C2410 UART",
 		.type		= TYPE_S3C24XX,
 		.port_type	= PORT_S3C2410,
@@ -2644,7 +2644,7 @@ static struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
 
 #ifdef CONFIG_CPU_S3C2412
 static struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Samsung S3C2412 UART",
 		.type		= TYPE_S3C24XX,
 		.port_type	= PORT_S3C2412,
@@ -2674,7 +2674,7 @@ static struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
 #if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2416) || \
 	defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2442)
 static struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Samsung S3C2440 UART",
 		.type		= TYPE_S3C24XX,
 		.port_type	= PORT_S3C2440,
@@ -2704,7 +2704,7 @@ static struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
 
 #if defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410)
 static struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Samsung S3C6400 UART",
 		.type		= TYPE_S3C6400,
 		.port_type	= PORT_S3C6400,
@@ -2733,7 +2733,7 @@ static struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
 
 #ifdef CONFIG_CPU_S5PV210
 static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Samsung S5PV210 UART",
 		.type		= TYPE_S3C6400,
 		.port_type	= PORT_S3C6400,
@@ -2762,7 +2762,7 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
 
 #if defined(CONFIG_ARCH_EXYNOS)
 #define EXYNOS_COMMON_SERIAL_DRV_DATA()				\
-	.info = &(struct s3c24xx_uart_info) {			\
+	.info = {						\
 		.name		= "Samsung Exynos UART",	\
 		.type		= TYPE_S3C6400,			\
 		.port_type	= PORT_S3C6400,			\
@@ -2811,7 +2811,7 @@ static struct s3c24xx_serial_drv_data exynos850_serial_drv_data = {
 
 #ifdef CONFIG_ARCH_APPLE
 static struct s3c24xx_serial_drv_data s5l_serial_drv_data = {
-	.info = &(struct s3c24xx_uart_info) {
+	.info = {
 		.name		= "Apple S5L UART",
 		.type		= TYPE_APPLE_S5L,
 		.port_type	= PORT_8250,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 2/7] tty: serial: samsung: embed s3c2410_uartcfg in parent structure
  2022-03-07  8:08 ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Krzysztof Kozlowski
  2022-03-07  8:08   ` [PATCH v2 1/7] tty: serial: samsung: embed s3c24xx_uart_info in parent structure Krzysztof Kozlowski
  2022-03-07  8:08   ` Krzysztof Kozlowski
@ 2022-03-07  8:09   ` Krzysztof Kozlowski
  2022-03-07  8:09   ` [PATCH v2 3/7] tty: serial: samsung: constify s3c24xx_serial_drv_data Krzysztof Kozlowski
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

Embed "struct s3c2410_uartcfg" directly as a member of "struct
s3c24xx_serial_drv_data" instead of keeping it as a pointer.  This makes
the code clearer (obvious ownership of "s3c2410_uartcfg
s3c24xx_serial_drv_data") and saves one pointer.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
---
 drivers/tty/serial/samsung_tty.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index aa5678d03704..a9a75b5b9705 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -86,7 +86,7 @@ struct s3c24xx_uart_info {
 
 struct s3c24xx_serial_drv_data {
 	struct s3c24xx_uart_info	info;
-	struct s3c2410_uartcfg		*def_cfg;
+	struct s3c2410_uartcfg		def_cfg;
 	unsigned int			fifosize[CONFIG_SERIAL_SAMSUNG_UARTS];
 };
 
@@ -2200,7 +2200,7 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
 	ourport->info = &ourport->drv_data->info;
 	ourport->cfg = (dev_get_platdata(&pdev->dev)) ?
 			dev_get_platdata(&pdev->dev) :
-			ourport->drv_data->def_cfg;
+			&ourport->drv_data->def_cfg;
 
 	switch (ourport->info->type) {
 	case TYPE_S3C24XX:
@@ -2632,7 +2632,7 @@ static struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
 		.clksel_mask	= S3C2410_UCON_CLKMASK,
 		.clksel_shift	= S3C2410_UCON_CLKSHIFT,
 	},
-	.def_cfg = &(struct s3c2410_uartcfg) {
+	.def_cfg = {
 		.ucon		= S3C2410_UCON_DEFAULT,
 		.ufcon		= S3C2410_UFCON_DEFAULT,
 	},
@@ -2661,7 +2661,7 @@ static struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
 		.clksel_mask	= S3C2412_UCON_CLKMASK,
 		.clksel_shift	= S3C2412_UCON_CLKSHIFT,
 	},
-	.def_cfg = &(struct s3c2410_uartcfg) {
+	.def_cfg = {
 		.ucon		= S3C2410_UCON_DEFAULT,
 		.ufcon		= S3C2410_UFCON_DEFAULT,
 	},
@@ -2692,7 +2692,7 @@ static struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
 		.clksel_shift	= S3C2412_UCON_CLKSHIFT,
 		.ucon_mask	= S3C2440_UCON0_DIVMASK,
 	},
-	.def_cfg = &(struct s3c2410_uartcfg) {
+	.def_cfg = {
 		.ucon		= S3C2410_UCON_DEFAULT,
 		.ufcon		= S3C2410_UFCON_DEFAULT,
 	},
@@ -2721,7 +2721,7 @@ static struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
 		.clksel_mask	= S3C6400_UCON_CLKMASK,
 		.clksel_shift	= S3C6400_UCON_CLKSHIFT,
 	},
-	.def_cfg = &(struct s3c2410_uartcfg) {
+	.def_cfg = {
 		.ucon		= S3C2410_UCON_DEFAULT,
 		.ufcon		= S3C2410_UFCON_DEFAULT,
 	},
@@ -2749,7 +2749,7 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
 		.clksel_mask	= S5PV210_UCON_CLKMASK,
 		.clksel_shift	= S5PV210_UCON_CLKSHIFT,
 	},
-	.def_cfg = &(struct s3c2410_uartcfg) {
+	.def_cfg = {
 		.ucon		= S5PV210_UCON_DEFAULT,
 		.ufcon		= S5PV210_UFCON_DEFAULT,
 	},
@@ -2778,7 +2778,7 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
 		.clksel_mask	= 0,				\
 		.clksel_shift	= 0,				\
 	},							\
-	.def_cfg = &(struct s3c2410_uartcfg) {			\
+	.def_cfg = {						\
 		.ucon		= S5PV210_UCON_DEFAULT,		\
 		.ufcon		= S5PV210_UFCON_DEFAULT,	\
 		.has_fracval	= 1,				\
@@ -2827,7 +2827,7 @@ static struct s3c24xx_serial_drv_data s5l_serial_drv_data = {
 		.clksel_mask	= 0,
 		.clksel_shift	= 0,
 	},
-	.def_cfg = &(struct s3c2410_uartcfg) {
+	.def_cfg = {
 		.ucon		= APPLE_S5L_UCON_DEFAULT,
 		.ufcon		= S3C2410_UFCON_DEFAULT,
 	},
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 3/7] tty: serial: samsung: constify s3c24xx_serial_drv_data
  2022-03-07  8:08 ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Krzysztof Kozlowski
                     ` (2 preceding siblings ...)
  2022-03-07  8:09   ` [PATCH v2 2/7] tty: serial: samsung: embed s3c2410_uartcfg " Krzysztof Kozlowski
@ 2022-03-07  8:09   ` Krzysztof Kozlowski
  2022-03-07  8:33     ` Jiri Slaby
  2022-03-07 18:18     ` Alim Akhtar
  2022-03-07  8:09   ` [PATCH v2 4/7] tty: serial: samsung: constify UART name Krzysztof Kozlowski
                     ` (4 subsequent siblings)
  8 siblings, 2 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

The driver data (struct s3c24xx_serial_drv_data) is only used to
initialize the driver properly and is not modified.  Make it const.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/tty/serial/samsung_tty.c | 130 +++++++++++++++----------------
 1 file changed, 65 insertions(+), 65 deletions(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index a9a75b5b9705..c4b13f2d6e26 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -136,14 +136,14 @@ struct s3c24xx_uart_port {
 	unsigned int			tx_mode;
 	unsigned int			rx_mode;
 
-	struct s3c24xx_uart_info	*info;
+	const struct s3c24xx_uart_info	*info;
 	struct clk			*clk;
 	struct clk			*baudclk;
 	struct uart_port		port;
-	struct s3c24xx_serial_drv_data	*drv_data;
+	const struct s3c24xx_serial_drv_data	*drv_data;
 
 	/* reference to platform data */
-	struct s3c2410_uartcfg		*cfg;
+	const struct s3c2410_uartcfg	*cfg;
 
 	struct s3c24xx_uart_dma		*dma;
 
@@ -221,7 +221,7 @@ static inline void s3c24xx_clear_bit(struct uart_port *port, int idx,
 	local_irq_restore(flags);
 }
 
-static inline struct s3c24xx_uart_port *to_ourport(struct uart_port *port)
+static inline struct s3c24xx_uart_port *to_ourport(const struct uart_port *port)
 {
 	return container_of(port, struct s3c24xx_uart_port, port);
 }
@@ -573,13 +573,13 @@ static void s3c24xx_serial_stop_rx(struct uart_port *port)
 	}
 }
 
-static inline struct s3c24xx_uart_info
+static inline const struct s3c24xx_uart_info
 	*s3c24xx_port_to_info(struct uart_port *port)
 {
 	return to_ourport(port)->info;
 }
 
-static inline struct s3c2410_uartcfg
+static inline const struct s3c2410_uartcfg
 	*s3c24xx_port_to_cfg(struct uart_port *port)
 {
 	struct s3c24xx_uart_port *ourport;
@@ -594,7 +594,7 @@ static inline struct s3c2410_uartcfg
 static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport,
 				     unsigned long ufstat)
 {
-	struct s3c24xx_uart_info *info = ourport->info;
+	const struct s3c24xx_uart_info *info = ourport->info;
 
 	if (ufstat & info->rx_fifofull)
 		return ourport->port.fifosize;
@@ -986,7 +986,7 @@ static irqreturn_t apple_serial_handle_irq(int irq, void *id)
 
 static unsigned int s3c24xx_serial_tx_empty(struct uart_port *port)
 {
-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
 	unsigned long ufstat = rd_regl(port, S3C2410_UFSTAT);
 	unsigned long ufcon = rd_regl(port, S3C2410_UFCON);
 
@@ -1405,7 +1405,7 @@ static void s3c24xx_serial_pm(struct uart_port *port, unsigned int level,
 
 static inline int s3c24xx_serial_getsource(struct uart_port *port)
 {
-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
 	unsigned int ucon;
 
 	if (info->num_clks == 1)
@@ -1419,7 +1419,7 @@ static inline int s3c24xx_serial_getsource(struct uart_port *port)
 static void s3c24xx_serial_setsource(struct uart_port *port,
 			unsigned int clk_sel)
 {
-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
 	unsigned int ucon;
 
 	if (info->num_clks == 1)
@@ -1438,7 +1438,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport,
 			unsigned int req_baud, struct clk **best_clk,
 			unsigned int *clk_num)
 {
-	struct s3c24xx_uart_info *info = ourport->info;
+	const struct s3c24xx_uart_info *info = ourport->info;
 	struct clk *clk;
 	unsigned long rate;
 	unsigned int cnt, baud, quot, best_quot = 0;
@@ -1522,7 +1522,7 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
 				       struct ktermios *termios,
 				       struct ktermios *old)
 {
-	struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
+	const struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
 	struct s3c24xx_uart_port *ourport = to_ourport(port);
 	struct clk *clk = ERR_PTR(-EINVAL);
 	unsigned long flags;
@@ -1691,7 +1691,7 @@ static const char *s3c24xx_serial_type(struct uart_port *port)
 
 static void s3c24xx_serial_config_port(struct uart_port *port, int flags)
 {
-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
 
 	if (flags & UART_CONFIG_TYPE)
 		port->type = info->port_type;
@@ -1703,7 +1703,7 @@ static void s3c24xx_serial_config_port(struct uart_port *port, int flags)
 static int
 s3c24xx_serial_verify_port(struct uart_port *port, struct serial_struct *ser)
 {
-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
 
 	if (ser->type != PORT_UNKNOWN && ser->type != info->port_type)
 		return -EINVAL;
@@ -1873,9 +1873,9 @@ s3c24xx_serial_ports[CONFIG_SERIAL_SAMSUNG_UARTS] = {
  */
 
 static void s3c24xx_serial_resetport(struct uart_port *port,
-				   struct s3c2410_uartcfg *cfg)
+				     const struct s3c2410_uartcfg *cfg)
 {
-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
 	unsigned long ucon = rd_regl(port, S3C2410_UCON);
 
 	ucon &= (info->clksel_mask | info->ucon_mask);
@@ -1979,7 +1979,7 @@ s3c24xx_serial_cpufreq_deregister(struct s3c24xx_uart_port *port)
 static int s3c24xx_serial_enable_baudclk(struct s3c24xx_uart_port *ourport)
 {
 	struct device *dev = ourport->port.dev;
-	struct s3c24xx_uart_info *info = ourport->info;
+	const struct s3c24xx_uart_info *info = ourport->info;
 	char clk_name[MAX_CLK_NAME_LENGTH];
 	unsigned int clk_sel;
 	struct clk *clk;
@@ -2021,7 +2021,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
 				    struct platform_device *platdev)
 {
 	struct uart_port *port = &ourport->port;
-	struct s3c2410_uartcfg *cfg = ourport->cfg;
+	const struct s3c2410_uartcfg *cfg = ourport->cfg;
 	struct resource *res;
 	int ret;
 
@@ -2156,7 +2156,7 @@ static const struct of_device_id s3c24xx_uart_dt_match[];
 
 static int probe_index;
 
-static inline struct s3c24xx_serial_drv_data *
+static inline const struct s3c24xx_serial_drv_data *
 s3c24xx_get_driver_data(struct platform_device *pdev)
 {
 #ifdef CONFIG_OF
@@ -2419,7 +2419,7 @@ static struct uart_port *cons_uart;
 static int
 s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned int ufcon)
 {
-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
 	unsigned long ufstat, utrstat;
 
 	if (ufcon & S3C2410_UFCON_FIFOMODE) {
@@ -2615,7 +2615,7 @@ static struct console s3c24xx_serial_console = {
 #endif /* CONFIG_SERIAL_SAMSUNG_CONSOLE */
 
 #ifdef CONFIG_CPU_S3C2410
-static struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
+static const struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
 	.info = {
 		.name		= "Samsung S3C2410 UART",
 		.type		= TYPE_S3C24XX,
@@ -2637,13 +2637,13 @@ static struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
 		.ufcon		= S3C2410_UFCON_DEFAULT,
 	},
 };
-#define S3C2410_SERIAL_DRV_DATA ((kernel_ulong_t)&s3c2410_serial_drv_data)
+#define S3C2410_SERIAL_DRV_DATA (&s3c2410_serial_drv_data)
 #else
-#define S3C2410_SERIAL_DRV_DATA (kernel_ulong_t)NULL
+#define S3C2410_SERIAL_DRV_DATA NULL
 #endif
 
 #ifdef CONFIG_CPU_S3C2412
-static struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
+static const struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
 	.info = {
 		.name		= "Samsung S3C2412 UART",
 		.type		= TYPE_S3C24XX,
@@ -2666,14 +2666,14 @@ static struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
 		.ufcon		= S3C2410_UFCON_DEFAULT,
 	},
 };
-#define S3C2412_SERIAL_DRV_DATA ((kernel_ulong_t)&s3c2412_serial_drv_data)
+#define S3C2412_SERIAL_DRV_DATA (&s3c2412_serial_drv_data)
 #else
-#define S3C2412_SERIAL_DRV_DATA (kernel_ulong_t)NULL
+#define S3C2412_SERIAL_DRV_DATA NULL
 #endif
 
 #if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2416) || \
 	defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2442)
-static struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
+static const struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
 	.info = {
 		.name		= "Samsung S3C2440 UART",
 		.type		= TYPE_S3C24XX,
@@ -2697,13 +2697,13 @@ static struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
 		.ufcon		= S3C2410_UFCON_DEFAULT,
 	},
 };
-#define S3C2440_SERIAL_DRV_DATA ((kernel_ulong_t)&s3c2440_serial_drv_data)
+#define S3C2440_SERIAL_DRV_DATA (&s3c2440_serial_drv_data)
 #else
-#define S3C2440_SERIAL_DRV_DATA (kernel_ulong_t)NULL
+#define S3C2440_SERIAL_DRV_DATA NULL
 #endif
 
 #if defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410)
-static struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
+static const struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
 	.info = {
 		.name		= "Samsung S3C6400 UART",
 		.type		= TYPE_S3C6400,
@@ -2726,13 +2726,13 @@ static struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
 		.ufcon		= S3C2410_UFCON_DEFAULT,
 	},
 };
-#define S3C6400_SERIAL_DRV_DATA ((kernel_ulong_t)&s3c6400_serial_drv_data)
+#define S3C6400_SERIAL_DRV_DATA (&s3c6400_serial_drv_data)
 #else
-#define S3C6400_SERIAL_DRV_DATA (kernel_ulong_t)NULL
+#define S3C6400_SERIAL_DRV_DATA NULL
 #endif
 
 #ifdef CONFIG_CPU_S5PV210
-static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
+static const struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
 	.info = {
 		.name		= "Samsung S5PV210 UART",
 		.type		= TYPE_S3C6400,
@@ -2755,9 +2755,9 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
 	},
 	.fifosize = { 256, 64, 16, 16 },
 };
-#define S5PV210_SERIAL_DRV_DATA ((kernel_ulong_t)&s5pv210_serial_drv_data)
+#define S5PV210_SERIAL_DRV_DATA (&s5pv210_serial_drv_data)
 #else
-#define S5PV210_SERIAL_DRV_DATA	(kernel_ulong_t)NULL
+#define S5PV210_SERIAL_DRV_DATA	NULL
 #endif
 
 #if defined(CONFIG_ARCH_EXYNOS)
@@ -2784,33 +2784,33 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
 		.has_fracval	= 1,				\
 	}							\
 
-static struct s3c24xx_serial_drv_data exynos4210_serial_drv_data = {
+static const struct s3c24xx_serial_drv_data exynos4210_serial_drv_data = {
 	EXYNOS_COMMON_SERIAL_DRV_DATA(),
 	.fifosize = { 256, 64, 16, 16 },
 };
 
-static struct s3c24xx_serial_drv_data exynos5433_serial_drv_data = {
+static const struct s3c24xx_serial_drv_data exynos5433_serial_drv_data = {
 	EXYNOS_COMMON_SERIAL_DRV_DATA(),
 	.fifosize = { 64, 256, 16, 256 },
 };
 
-static struct s3c24xx_serial_drv_data exynos850_serial_drv_data = {
+static const struct s3c24xx_serial_drv_data exynos850_serial_drv_data = {
 	EXYNOS_COMMON_SERIAL_DRV_DATA(),
 	.fifosize = { 256, 64, 64, 64 },
 };
 
-#define EXYNOS4210_SERIAL_DRV_DATA ((kernel_ulong_t)&exynos4210_serial_drv_data)
-#define EXYNOS5433_SERIAL_DRV_DATA ((kernel_ulong_t)&exynos5433_serial_drv_data)
-#define EXYNOS850_SERIAL_DRV_DATA ((kernel_ulong_t)&exynos850_serial_drv_data)
+#define EXYNOS4210_SERIAL_DRV_DATA (&exynos4210_serial_drv_data)
+#define EXYNOS5433_SERIAL_DRV_DATA (&exynos5433_serial_drv_data)
+#define EXYNOS850_SERIAL_DRV_DATA (&exynos850_serial_drv_data)
 
 #else
-#define EXYNOS4210_SERIAL_DRV_DATA ((kernel_ulong_t)NULL)
-#define EXYNOS5433_SERIAL_DRV_DATA ((kernel_ulong_t)NULL)
-#define EXYNOS850_SERIAL_DRV_DATA ((kernel_ulong_t)NULL)
+#define EXYNOS4210_SERIAL_DRV_DATA NULL
+#define EXYNOS5433_SERIAL_DRV_DATA NULL
+#define EXYNOS850_SERIAL_DRV_DATA NULL
 #endif
 
 #ifdef CONFIG_ARCH_APPLE
-static struct s3c24xx_serial_drv_data s5l_serial_drv_data = {
+static const struct s3c24xx_serial_drv_data s5l_serial_drv_data = {
 	.info = {
 		.name		= "Apple S5L UART",
 		.type		= TYPE_APPLE_S5L,
@@ -2832,39 +2832,39 @@ static struct s3c24xx_serial_drv_data s5l_serial_drv_data = {
 		.ufcon		= S3C2410_UFCON_DEFAULT,
 	},
 };
-#define S5L_SERIAL_DRV_DATA ((kernel_ulong_t)&s5l_serial_drv_data)
+#define S5L_SERIAL_DRV_DATA (&s5l_serial_drv_data)
 #else
-#define S5L_SERIAL_DRV_DATA ((kernel_ulong_t)NULL)
+#define S5L_SERIAL_DRV_DATA NULL
 #endif
 
 static const struct platform_device_id s3c24xx_serial_driver_ids[] = {
 	{
 		.name		= "s3c2410-uart",
-		.driver_data	= S3C2410_SERIAL_DRV_DATA,
+		.driver_data	= (kernel_ulong_t)S3C2410_SERIAL_DRV_DATA,
 	}, {
 		.name		= "s3c2412-uart",
-		.driver_data	= S3C2412_SERIAL_DRV_DATA,
+		.driver_data	= (kernel_ulong_t)S3C2412_SERIAL_DRV_DATA,
 	}, {
 		.name		= "s3c2440-uart",
-		.driver_data	= S3C2440_SERIAL_DRV_DATA,
+		.driver_data	= (kernel_ulong_t)S3C2440_SERIAL_DRV_DATA,
 	}, {
 		.name		= "s3c6400-uart",
-		.driver_data	= S3C6400_SERIAL_DRV_DATA,
+		.driver_data	= (kernel_ulong_t)S3C6400_SERIAL_DRV_DATA,
 	}, {
 		.name		= "s5pv210-uart",
-		.driver_data	= S5PV210_SERIAL_DRV_DATA,
+		.driver_data	= (kernel_ulong_t)S5PV210_SERIAL_DRV_DATA,
 	}, {
 		.name		= "exynos4210-uart",
-		.driver_data	= EXYNOS4210_SERIAL_DRV_DATA,
+		.driver_data	= (kernel_ulong_t)EXYNOS4210_SERIAL_DRV_DATA,
 	}, {
 		.name		= "exynos5433-uart",
-		.driver_data	= EXYNOS5433_SERIAL_DRV_DATA,
+		.driver_data	= (kernel_ulong_t)EXYNOS5433_SERIAL_DRV_DATA,
 	}, {
 		.name		= "s5l-uart",
-		.driver_data	= S5L_SERIAL_DRV_DATA,
+		.driver_data	= (kernel_ulong_t)S5L_SERIAL_DRV_DATA,
 	}, {
 		.name		= "exynos850-uart",
-		.driver_data	= EXYNOS850_SERIAL_DRV_DATA,
+		.driver_data	= (kernel_ulong_t)EXYNOS850_SERIAL_DRV_DATA,
 	},
 	{ },
 };
@@ -2873,23 +2873,23 @@ MODULE_DEVICE_TABLE(platform, s3c24xx_serial_driver_ids);
 #ifdef CONFIG_OF
 static const struct of_device_id s3c24xx_uart_dt_match[] = {
 	{ .compatible = "samsung,s3c2410-uart",
-		.data = (void *)S3C2410_SERIAL_DRV_DATA },
+		.data = S3C2410_SERIAL_DRV_DATA },
 	{ .compatible = "samsung,s3c2412-uart",
-		.data = (void *)S3C2412_SERIAL_DRV_DATA },
+		.data = S3C2412_SERIAL_DRV_DATA },
 	{ .compatible = "samsung,s3c2440-uart",
-		.data = (void *)S3C2440_SERIAL_DRV_DATA },
+		.data = S3C2440_SERIAL_DRV_DATA },
 	{ .compatible = "samsung,s3c6400-uart",
-		.data = (void *)S3C6400_SERIAL_DRV_DATA },
+		.data = S3C6400_SERIAL_DRV_DATA },
 	{ .compatible = "samsung,s5pv210-uart",
-		.data = (void *)S5PV210_SERIAL_DRV_DATA },
+		.data = S5PV210_SERIAL_DRV_DATA },
 	{ .compatible = "samsung,exynos4210-uart",
-		.data = (void *)EXYNOS4210_SERIAL_DRV_DATA },
+		.data = EXYNOS4210_SERIAL_DRV_DATA },
 	{ .compatible = "samsung,exynos5433-uart",
-		.data = (void *)EXYNOS5433_SERIAL_DRV_DATA },
+		.data = EXYNOS5433_SERIAL_DRV_DATA },
 	{ .compatible = "apple,s5l-uart",
-		.data = (void *)S5L_SERIAL_DRV_DATA },
+		.data = S5L_SERIAL_DRV_DATA },
 	{ .compatible = "samsung,exynos850-uart",
-		.data = (void *)EXYNOS850_SERIAL_DRV_DATA },
+		.data = EXYNOS850_SERIAL_DRV_DATA },
 	{},
 };
 MODULE_DEVICE_TABLE(of, s3c24xx_uart_dt_match);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 4/7] tty: serial: samsung: constify UART name
  2022-03-07  8:08 ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Krzysztof Kozlowski
                     ` (3 preceding siblings ...)
  2022-03-07  8:09   ` [PATCH v2 3/7] tty: serial: samsung: constify s3c24xx_serial_drv_data Krzysztof Kozlowski
@ 2022-03-07  8:09   ` Krzysztof Kozlowski
  2022-03-07  8:09   ` [PATCH v2 5/7] tty: serial: samsung: constify s3c24xx_serial_drv_data members Krzysztof Kozlowski
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

The UART name from driver data holds only string literals.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
---
 drivers/tty/serial/samsung_tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index c4b13f2d6e26..7025306f76b7 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -63,7 +63,7 @@ enum s3c24xx_port_type {
 };
 
 struct s3c24xx_uart_info {
-	char			*name;
+	const char		*name;
 	enum s3c24xx_port_type	type;
 	unsigned int		port_type;
 	unsigned int		fifosize;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 5/7] tty: serial: samsung: constify s3c24xx_serial_drv_data members
  2022-03-07  8:08 ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Krzysztof Kozlowski
                     ` (4 preceding siblings ...)
  2022-03-07  8:09   ` [PATCH v2 4/7] tty: serial: samsung: constify UART name Krzysztof Kozlowski
@ 2022-03-07  8:09   ` Krzysztof Kozlowski
  2022-03-07  8:09   ` [PATCH v2 6/7] tty: serial: samsung: constify variables and pointers Krzysztof Kozlowski
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

The driver data (struct s3c24xx_serial_drv_data) is never modified, so
also its members can be made const.  Except code style this has no
impact because the structure itself is always a const.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
---
 drivers/tty/serial/samsung_tty.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index 7025306f76b7..b9783d8fb440 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -85,9 +85,9 @@ struct s3c24xx_uart_info {
 };
 
 struct s3c24xx_serial_drv_data {
-	struct s3c24xx_uart_info	info;
-	struct s3c2410_uartcfg		def_cfg;
-	unsigned int			fifosize[CONFIG_SERIAL_SAMSUNG_UARTS];
+	const struct s3c24xx_uart_info	info;
+	const struct s3c2410_uartcfg	def_cfg;
+	const unsigned int		fifosize[CONFIG_SERIAL_SAMSUNG_UARTS];
 };
 
 struct s3c24xx_uart_dma {
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 6/7] tty: serial: samsung: constify variables and pointers
  2022-03-07  8:08 ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Krzysztof Kozlowski
                     ` (5 preceding siblings ...)
  2022-03-07  8:09   ` [PATCH v2 5/7] tty: serial: samsung: constify s3c24xx_serial_drv_data members Krzysztof Kozlowski
@ 2022-03-07  8:09   ` Krzysztof Kozlowski
  2022-03-07  8:09   ` [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match data Krzysztof Kozlowski
  2022-03-07 18:21   ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Alim Akhtar
  8 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

Constify variables, data pointed by several pointers and
"udivslot_table" static array.  This makes code a bit safer.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
---
 drivers/tty/serial/samsung_tty.c | 46 ++++++++++++++++----------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index b9783d8fb440..3ffae912217c 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -164,7 +164,7 @@ static void s3c24xx_serial_tx_chars(struct s3c24xx_uart_port *ourport);
 #define portaddrl(port, reg) \
 	((unsigned long *)(unsigned long)((port)->membase + (reg)))
 
-static u32 rd_reg(struct uart_port *port, u32 reg)
+static u32 rd_reg(const struct uart_port *port, u32 reg)
 {
 	switch (port->iotype) {
 	case UPIO_MEM:
@@ -179,7 +179,7 @@ static u32 rd_reg(struct uart_port *port, u32 reg)
 
 #define rd_regl(port, reg) (readl_relaxed(portaddr(port, reg)))
 
-static void wr_reg(struct uart_port *port, u32 reg, u32 val)
+static void wr_reg(const struct uart_port *port, u32 reg, u32 val)
 {
 	switch (port->iotype) {
 	case UPIO_MEM:
@@ -195,7 +195,7 @@ static void wr_reg(struct uart_port *port, u32 reg, u32 val)
 
 /* Byte-order aware bit setting/clearing functions. */
 
-static inline void s3c24xx_set_bit(struct uart_port *port, int idx,
+static inline void s3c24xx_set_bit(const struct uart_port *port, int idx,
 				   unsigned int reg)
 {
 	unsigned long flags;
@@ -208,7 +208,7 @@ static inline void s3c24xx_set_bit(struct uart_port *port, int idx,
 	local_irq_restore(flags);
 }
 
-static inline void s3c24xx_clear_bit(struct uart_port *port, int idx,
+static inline void s3c24xx_clear_bit(const struct uart_port *port, int idx,
 				     unsigned int reg)
 {
 	unsigned long flags;
@@ -221,19 +221,19 @@ static inline void s3c24xx_clear_bit(struct uart_port *port, int idx,
 	local_irq_restore(flags);
 }
 
-static inline struct s3c24xx_uart_port *to_ourport(const struct uart_port *port)
+static inline struct s3c24xx_uart_port *to_ourport(struct uart_port *port)
 {
 	return container_of(port, struct s3c24xx_uart_port, port);
 }
 
 /* translate a port to the device name */
 
-static inline const char *s3c24xx_serial_portname(struct uart_port *port)
+static inline const char *s3c24xx_serial_portname(const struct uart_port *port)
 {
 	return to_platform_device(port->dev)->name;
 }
 
-static int s3c24xx_serial_txempty_nofifo(struct uart_port *port)
+static int s3c24xx_serial_txempty_nofifo(const struct uart_port *port)
 {
 	return rd_regl(port, S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE;
 }
@@ -358,7 +358,7 @@ static void s3c24xx_serial_tx_dma_complete(void *args)
 
 static void enable_tx_dma(struct s3c24xx_uart_port *ourport)
 {
-	struct uart_port *port = &ourport->port;
+	const struct uart_port *port = &ourport->port;
 	u32 ucon;
 
 	/* Mask Tx interrupt */
@@ -387,7 +387,7 @@ static void enable_tx_dma(struct s3c24xx_uart_port *ourport)
 
 static void enable_tx_pio(struct s3c24xx_uart_port *ourport)
 {
-	struct uart_port *port = &ourport->port;
+	const struct uart_port *port = &ourport->port;
 	u32 ucon, ufcon;
 
 	/* Set ufcon txtrig */
@@ -580,9 +580,9 @@ static inline const struct s3c24xx_uart_info
 }
 
 static inline const struct s3c2410_uartcfg
-	*s3c24xx_port_to_cfg(struct uart_port *port)
+	*s3c24xx_port_to_cfg(const struct uart_port *port)
 {
-	struct s3c24xx_uart_port *ourport;
+	const struct s3c24xx_uart_port *ourport;
 
 	if (port->dev == NULL)
 		return NULL;
@@ -591,7 +591,7 @@ static inline const struct s3c2410_uartcfg
 	return ourport->cfg;
 }
 
-static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport,
+static int s3c24xx_serial_rx_fifocnt(const struct s3c24xx_uart_port *ourport,
 				     unsigned long ufstat)
 {
 	const struct s3c24xx_uart_info *info = ourport->info;
@@ -947,8 +947,8 @@ static irqreturn_t s3c24xx_serial_tx_irq(int irq, void *id)
 /* interrupt handler for s3c64xx and later SoC's.*/
 static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
 {
-	struct s3c24xx_uart_port *ourport = id;
-	struct uart_port *port = &ourport->port;
+	const struct s3c24xx_uart_port *ourport = id;
+	const struct uart_port *port = &ourport->port;
 	unsigned int pend = rd_regl(port, S3C64XX_UINTP);
 	irqreturn_t ret = IRQ_HANDLED;
 
@@ -966,8 +966,8 @@ static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
 /* interrupt handler for Apple SoC's.*/
 static irqreturn_t apple_serial_handle_irq(int irq, void *id)
 {
-	struct s3c24xx_uart_port *ourport = id;
-	struct uart_port *port = &ourport->port;
+	const struct s3c24xx_uart_port *ourport = id;
+	const struct uart_port *port = &ourport->port;
 	unsigned int pend = rd_regl(port, S3C2410_UTRSTAT);
 	irqreturn_t ret = IRQ_NONE;
 
@@ -1499,7 +1499,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport,
  * This table takes the fractional value of the baud divisor and gives
  * the recommended setting for the UDIVSLOT register.
  */
-static u16 udivslot_table[16] = {
+static const u16 udivslot_table[16] = {
 	[0] = 0x0000,
 	[1] = 0x0080,
 	[2] = 0x0808,
@@ -1675,7 +1675,7 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
 
 static const char *s3c24xx_serial_type(struct uart_port *port)
 {
-	struct s3c24xx_uart_port *ourport = to_ourport(port);
+	const struct s3c24xx_uart_port *ourport = to_ourport(port);
 
 	switch (ourport->info->type) {
 	case TYPE_S3C24XX:
@@ -2450,7 +2450,7 @@ s3c24xx_port_configured(unsigned int ucon)
 
 static int s3c24xx_serial_get_poll_char(struct uart_port *port)
 {
-	struct s3c24xx_uart_port *ourport = to_ourport(port);
+	const struct s3c24xx_uart_port *ourport = to_ourport(port);
 	unsigned int ufstat;
 
 	ufstat = rd_regl(port, S3C2410_UFSTAT);
@@ -2935,7 +2935,7 @@ module_exit(samsung_serial_exit);
  * Early console.
  */
 
-static void wr_reg_barrier(struct uart_port *port, u32 reg, u32 val)
+static void wr_reg_barrier(const struct uart_port *port, u32 reg, u32 val)
 {
 	switch (port->iotype) {
 	case UPIO_MEM:
@@ -2951,15 +2951,15 @@ struct samsung_early_console_data {
 	u32 txfull_mask;
 };
 
-static void samsung_early_busyuart(struct uart_port *port)
+static void samsung_early_busyuart(const struct uart_port *port)
 {
 	while (!(readl(port->membase + S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXFE))
 		;
 }
 
-static void samsung_early_busyuart_fifo(struct uart_port *port)
+static void samsung_early_busyuart_fifo(const struct uart_port *port)
 {
-	struct samsung_early_console_data *data = port->private_data;
+	const struct samsung_early_console_data *data = port->private_data;
 
 	while (readl(port->membase + S3C2410_UFSTAT) & data->txfull_mask)
 		;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match data
  2022-03-07  8:08 ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Krzysztof Kozlowski
                     ` (6 preceding siblings ...)
  2022-03-07  8:09   ` [PATCH v2 6/7] tty: serial: samsung: constify variables and pointers Krzysztof Kozlowski
@ 2022-03-07  8:09   ` Krzysztof Kozlowski
  2022-03-07 18:16     ` Alim Akhtar
  2022-03-07 20:24     ` Andy Shevchenko
  2022-03-07 18:21   ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Alim Akhtar
  8 siblings, 2 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

Simplify the code with of_device_get_match_data().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/tty/serial/samsung_tty.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index 3ffae912217c..61c530bb377f 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -2150,23 +2150,16 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
 
 /* Device driver serial port probe */
 
-#ifdef CONFIG_OF
-static const struct of_device_id s3c24xx_uart_dt_match[];
-#endif
-
 static int probe_index;
 
 static inline const struct s3c24xx_serial_drv_data *
 s3c24xx_get_driver_data(struct platform_device *pdev)
 {
 #ifdef CONFIG_OF
-	if (pdev->dev.of_node) {
-		const struct of_device_id *match;
-
-		match = of_match_node(s3c24xx_uart_dt_match, pdev->dev.of_node);
-		return (struct s3c24xx_serial_drv_data *)match->data;
-	}
+	if (pdev->dev.of_node)
+		return of_device_get_match_data(&pdev->dev);
 #endif
+
 	return (struct s3c24xx_serial_drv_data *)
 			platform_get_device_id(pdev)->driver_data;
 }
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 1/7] tty: serial: samsung: embed s3c24xx_uart_info in parent structure
  2022-03-07  8:08   ` Krzysztof Kozlowski
@ 2022-03-07  8:10     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:10 UTC (permalink / raw)
  To: Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby, linux-arm-kernel,
	linux-samsung-soc, linux-serial, linux-kernel

On 07/03/2022 09:08, Krzysztof Kozlowski wrote:
> Embed "struct s3c24xx_uart_info" directly as a member of "struct
> s3c24xx_serial_drv_data" instead of keeping it as a pointer.  This makes
> the code clearer (obvious ownership of "struct s3c24xx_serial_drv_data")
> and saves one pointer.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
> ---

I had SMTP troubles when sending so this one duplicated itself. Sorry
for the noise.


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/7] tty: serial: samsung: constify s3c24xx_serial_drv_data
  2022-03-07  8:09   ` [PATCH v2 3/7] tty: serial: samsung: constify s3c24xx_serial_drv_data Krzysztof Kozlowski
@ 2022-03-07  8:33     ` Jiri Slaby
  2022-03-07  8:40       ` Krzysztof Kozlowski
  2022-03-07 18:18     ` Alim Akhtar
  1 sibling, 1 reply; 18+ messages in thread
From: Jiri Slaby @ 2022-03-07  8:33 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar, Greg Kroah-Hartman,
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

On 07. 03. 22, 9:09, Krzysztof Kozlowski wrote:
> The driver data (struct s3c24xx_serial_drv_data) is only used to
> initialize the driver properly and is not modified.  Make it const.
...
> @@ -2755,9 +2755,9 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
>   	},
>   	.fifosize = { 256, 64, 16, 16 },
>   };
> -#define S5PV210_SERIAL_DRV_DATA ((kernel_ulong_t)&s5pv210_serial_drv_data)
> +#define S5PV210_SERIAL_DRV_DATA (&s5pv210_serial_drv_data)
>   #else
> -#define S5PV210_SERIAL_DRV_DATA	(kernel_ulong_t)NULL
> +#define S5PV210_SERIAL_DRV_DATA	NULL

Yet, I still don't see why the switch from ulong->ptr happens in this 
"constify it" patch?

thanks,
-- 
-- 
js
suse labs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/7] tty: serial: samsung: constify s3c24xx_serial_drv_data
  2022-03-07  8:33     ` Jiri Slaby
@ 2022-03-07  8:40       ` Krzysztof Kozlowski
  2022-03-08  8:06         ` Krzysztof Kozlowski
  0 siblings, 1 reply; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07  8:40 UTC (permalink / raw)
  To: Jiri Slaby, Alim Akhtar, Greg Kroah-Hartman, linux-arm-kernel,
	linux-samsung-soc, linux-serial, linux-kernel

On 07/03/2022 09:33, Jiri Slaby wrote:
> On 07. 03. 22, 9:09, Krzysztof Kozlowski wrote:
>> The driver data (struct s3c24xx_serial_drv_data) is only used to
>> initialize the driver properly and is not modified.  Make it const.
> ...
>> @@ -2755,9 +2755,9 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
>>   	},
>>   	.fifosize = { 256, 64, 16, 16 },
>>   };
>> -#define S5PV210_SERIAL_DRV_DATA ((kernel_ulong_t)&s5pv210_serial_drv_data)
>> +#define S5PV210_SERIAL_DRV_DATA (&s5pv210_serial_drv_data)
>>   #else
>> -#define S5PV210_SERIAL_DRV_DATA	(kernel_ulong_t)NULL
>> +#define S5PV210_SERIAL_DRV_DATA	NULL
> 
> Yet, I still don't see why the switch from ulong->ptr happens in this 
> "constify it" patch?

All these defines S5PV210_SERIAL_DRV_DATA and so on are now const and
are assigned to of_device_id.data (s3c24xx_uart_dt_match). Before, these
were assigned with a cast:

static const struct of_device_id s3c24xx_uart_dt_match[] = {
	{ .compatible = "samsung,s5pv210-uart",

	.data = (void *)S5PV210_SERIAL_DRV_DATA }

but since the actual data structure is const, I want to drop the cast.
Casting const via (void *) might hide some possible issues, e.g. if
of_device_id.data becomes actually non-const. There is no particular
issue here, because of_device_id.data and S5PV210_SERIAL_DRV_DATA are
const. But also because they are both const now, I want to drop the cast
via void *.

When (void *) is dropped, the S5PV210_SERIAL_DRV_DATA cannot be
kernel_ulong_t:

../drivers/tty/serial/samsung_tty.c:2753:33: warning: initialization of
‘const void *’ from ‘long unsigned int’ makes pointer from integer
without a cast [-Wint-conversion]

 2753 | #define S5PV210_SERIAL_DRV_DATA (kernel_ulong_t)NULL



Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match data
  2022-03-07  8:09   ` [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match data Krzysztof Kozlowski
@ 2022-03-07 18:16     ` Alim Akhtar
  2022-03-07 20:24     ` Andy Shevchenko
  1 sibling, 0 replies; 18+ messages in thread
From: Alim Akhtar @ 2022-03-07 18:16 UTC (permalink / raw)
  To: 'Krzysztof Kozlowski', 'Greg Kroah-Hartman',
	'Jiri Slaby',
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel



>-----Original Message-----
>From: Krzysztof Kozlowski [mailto:krzysztof.kozlowski@canonical.com]
>Sent: Monday, March 7, 2022 1:39 PM
>To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>; Alim Akhtar
><alim.akhtar@samsung.com>; Greg Kroah-Hartman
><gregkh@linuxfoundation.org>; Jiri Slaby <jirislaby@kernel.org>; linux-arm-
>kernel@lists.infradead.org; linux-samsung-soc@vger.kernel.org; linux-
>serial@vger.kernel.org; linux-kernel@vger.kernel.org
>Subject: [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match
data
>
>Simplify the code with of_device_get_match_data().
>
>Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
>---

Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>


> drivers/tty/serial/samsung_tty.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
>diff --git a/drivers/tty/serial/samsung_tty.c
>b/drivers/tty/serial/samsung_tty.c
>index 3ffae912217c..61c530bb377f 100644
>--- a/drivers/tty/serial/samsung_tty.c
>+++ b/drivers/tty/serial/samsung_tty.c
>@@ -2150,23 +2150,16 @@ static int s3c24xx_serial_init_port(struct
>s3c24xx_uart_port *ourport,
>
> /* Device driver serial port probe */
>
>-#ifdef CONFIG_OF
>-static const struct of_device_id s3c24xx_uart_dt_match[]; -#endif
>-
> static int probe_index;
>
> static inline const struct s3c24xx_serial_drv_data *
>s3c24xx_get_driver_data(struct platform_device *pdev)  {  #ifdef CONFIG_OF
>-	if (pdev->dev.of_node) {
>-		const struct of_device_id *match;
>-
>-		match = of_match_node(s3c24xx_uart_dt_match, pdev-
>>dev.of_node);
>-		return (struct s3c24xx_serial_drv_data *)match->data;
>-	}
>+	if (pdev->dev.of_node)
>+		return of_device_get_match_data(&pdev->dev);
> #endif
>+
> 	return (struct s3c24xx_serial_drv_data *)
> 			platform_get_device_id(pdev)->driver_data;
> }
>--
>2.32.0



^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [PATCH v2 3/7] tty: serial: samsung: constify s3c24xx_serial_drv_data
  2022-03-07  8:09   ` [PATCH v2 3/7] tty: serial: samsung: constify s3c24xx_serial_drv_data Krzysztof Kozlowski
  2022-03-07  8:33     ` Jiri Slaby
@ 2022-03-07 18:18     ` Alim Akhtar
  1 sibling, 0 replies; 18+ messages in thread
From: Alim Akhtar @ 2022-03-07 18:18 UTC (permalink / raw)
  To: 'Krzysztof Kozlowski', 'Greg Kroah-Hartman',
	'Jiri Slaby',
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel



>-----Original Message-----
>From: Krzysztof Kozlowski [mailto:krzysztof.kozlowski@canonical.com]
>Sent: Monday, March 7, 2022 1:39 PM
>To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>; Alim Akhtar
><alim.akhtar@samsung.com>; Greg Kroah-Hartman
><gregkh@linuxfoundation.org>; Jiri Slaby <jirislaby@kernel.org>; linux-arm-
>kernel@lists.infradead.org; linux-samsung-soc@vger.kernel.org; linux-
>serial@vger.kernel.org; linux-kernel@vger.kernel.org
>Subject: [PATCH v2 3/7] tty: serial: samsung: constify
s3c24xx_serial_drv_data
>
>The driver data (struct s3c24xx_serial_drv_data) is only used to initialize
the
>driver properly and is not modified.  Make it const.
>
>Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
>---

Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>

> drivers/tty/serial/samsung_tty.c | 130 +++++++++++++++----------------
> 1 file changed, 65 insertions(+), 65 deletions(-)
>
>diff --git a/drivers/tty/serial/samsung_tty.c
>b/drivers/tty/serial/samsung_tty.c
>index a9a75b5b9705..c4b13f2d6e26 100644
>--- a/drivers/tty/serial/samsung_tty.c
>+++ b/drivers/tty/serial/samsung_tty.c
>@@ -136,14 +136,14 @@ struct s3c24xx_uart_port {
> 	unsigned int			tx_mode;
> 	unsigned int			rx_mode;
>
>-	struct s3c24xx_uart_info	*info;
>+	const struct s3c24xx_uart_info	*info;
> 	struct clk			*clk;
> 	struct clk			*baudclk;
> 	struct uart_port		port;
>-	struct s3c24xx_serial_drv_data	*drv_data;
>+	const struct s3c24xx_serial_drv_data	*drv_data;
>
> 	/* reference to platform data */
>-	struct s3c2410_uartcfg		*cfg;
>+	const struct s3c2410_uartcfg	*cfg;
>
> 	struct s3c24xx_uart_dma		*dma;
>
>@@ -221,7 +221,7 @@ static inline void s3c24xx_clear_bit(struct uart_port
>*port, int idx,
> 	local_irq_restore(flags);
> }
>
>-static inline struct s3c24xx_uart_port *to_ourport(struct uart_port *port)
>+static inline struct s3c24xx_uart_port *to_ourport(const struct
>+uart_port *port)
> {
> 	return container_of(port, struct s3c24xx_uart_port, port);  } @@ -
>573,13 +573,13 @@ static void s3c24xx_serial_stop_rx(struct uart_port
*port)
> 	}
> }
>
>-static inline struct s3c24xx_uart_info
>+static inline const struct s3c24xx_uart_info
> 	*s3c24xx_port_to_info(struct uart_port *port)  {
> 	return to_ourport(port)->info;
> }
>
>-static inline struct s3c2410_uartcfg
>+static inline const struct s3c2410_uartcfg
> 	*s3c24xx_port_to_cfg(struct uart_port *port)  {
> 	struct s3c24xx_uart_port *ourport;
>@@ -594,7 +594,7 @@ static inline struct s3c2410_uartcfg  static int
>s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport,
> 				     unsigned long ufstat)
> {
>-	struct s3c24xx_uart_info *info = ourport->info;
>+	const struct s3c24xx_uart_info *info = ourport->info;
>
> 	if (ufstat & info->rx_fifofull)
> 		return ourport->port.fifosize;
>@@ -986,7 +986,7 @@ static irqreturn_t apple_serial_handle_irq(int irq,
void
>*id)
>
> static unsigned int s3c24xx_serial_tx_empty(struct uart_port *port)  {
>-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
>+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
> 	unsigned long ufstat = rd_regl(port, S3C2410_UFSTAT);
> 	unsigned long ufcon = rd_regl(port, S3C2410_UFCON);
>
>@@ -1405,7 +1405,7 @@ static void s3c24xx_serial_pm(struct uart_port
>*port, unsigned int level,
>
> static inline int s3c24xx_serial_getsource(struct uart_port *port)  {
>-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
>+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
> 	unsigned int ucon;
>
> 	if (info->num_clks == 1)
>@@ -1419,7 +1419,7 @@ static inline int s3c24xx_serial_getsource(struct
>uart_port *port)  static void s3c24xx_serial_setsource(struct uart_port
*port,
> 			unsigned int clk_sel)
> {
>-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
>+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
> 	unsigned int ucon;
>
> 	if (info->num_clks == 1)
>@@ -1438,7 +1438,7 @@ static unsigned int s3c24xx_serial_getclk(struct
>s3c24xx_uart_port *ourport,
> 			unsigned int req_baud, struct clk **best_clk,
> 			unsigned int *clk_num)
> {
>-	struct s3c24xx_uart_info *info = ourport->info;
>+	const struct s3c24xx_uart_info *info = ourport->info;
> 	struct clk *clk;
> 	unsigned long rate;
> 	unsigned int cnt, baud, quot, best_quot = 0; @@ -1522,7 +1522,7 @@
>static void s3c24xx_serial_set_termios(struct uart_port *port,
> 				       struct ktermios *termios,
> 				       struct ktermios *old)
> {
>-	struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
>+	const struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
> 	struct s3c24xx_uart_port *ourport = to_ourport(port);
> 	struct clk *clk = ERR_PTR(-EINVAL);
> 	unsigned long flags;
>@@ -1691,7 +1691,7 @@ static const char *s3c24xx_serial_type(struct
>uart_port *port)
>
> static void s3c24xx_serial_config_port(struct uart_port *port, int flags)
{
>-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
>+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
>
> 	if (flags & UART_CONFIG_TYPE)
> 		port->type = info->port_type;
>@@ -1703,7 +1703,7 @@ static void s3c24xx_serial_config_port(struct
>uart_port *port, int flags)  static int  s3c24xx_serial_verify_port(struct
>uart_port *port, struct serial_struct *ser)  {
>-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
>+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
>
> 	if (ser->type != PORT_UNKNOWN && ser->type != info->port_type)
> 		return -EINVAL;
>@@ -1873,9 +1873,9 @@
>s3c24xx_serial_ports[CONFIG_SERIAL_SAMSUNG_UARTS] = {
>  */
>
> static void s3c24xx_serial_resetport(struct uart_port *port,
>-				   struct s3c2410_uartcfg *cfg)
>+				     const struct s3c2410_uartcfg *cfg)
> {
>-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
>+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
> 	unsigned long ucon = rd_regl(port, S3C2410_UCON);
>
> 	ucon &= (info->clksel_mask | info->ucon_mask); @@ -1979,7 +1979,7
>@@ s3c24xx_serial_cpufreq_deregister(struct s3c24xx_uart_port *port)
>static int s3c24xx_serial_enable_baudclk(struct s3c24xx_uart_port *ourport)
>{
> 	struct device *dev = ourport->port.dev;
>-	struct s3c24xx_uart_info *info = ourport->info;
>+	const struct s3c24xx_uart_info *info = ourport->info;
> 	char clk_name[MAX_CLK_NAME_LENGTH];
> 	unsigned int clk_sel;
> 	struct clk *clk;
>@@ -2021,7 +2021,7 @@ static int s3c24xx_serial_init_port(struct
>s3c24xx_uart_port *ourport,
> 				    struct platform_device *platdev)  {
> 	struct uart_port *port = &ourport->port;
>-	struct s3c2410_uartcfg *cfg = ourport->cfg;
>+	const struct s3c2410_uartcfg *cfg = ourport->cfg;
> 	struct resource *res;
> 	int ret;
>
>@@ -2156,7 +2156,7 @@ static const struct of_device_id
>s3c24xx_uart_dt_match[];
>
> static int probe_index;
>
>-static inline struct s3c24xx_serial_drv_data *
>+static inline const struct s3c24xx_serial_drv_data *
> s3c24xx_get_driver_data(struct platform_device *pdev)  {  #ifdef
>CONFIG_OF @@ -2419,7 +2419,7 @@ static struct uart_port *cons_uart;
>static int  s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned
int
>ufcon)  {
>-	struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
>+	const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
> 	unsigned long ufstat, utrstat;
>
> 	if (ufcon & S3C2410_UFCON_FIFOMODE) {
>@@ -2615,7 +2615,7 @@ static struct console s3c24xx_serial_console = {
>#endif /* CONFIG_SERIAL_SAMSUNG_CONSOLE */
>
> #ifdef CONFIG_CPU_S3C2410
>-static struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
>+static const struct s3c24xx_serial_drv_data s3c2410_serial_drv_data = {
> 	.info = {
> 		.name		= "Samsung S3C2410 UART",
> 		.type		= TYPE_S3C24XX,
>@@ -2637,13 +2637,13 @@ static struct s3c24xx_serial_drv_data
>s3c2410_serial_drv_data = {
> 		.ufcon		= S3C2410_UFCON_DEFAULT,
> 	},
> };
>-#define S3C2410_SERIAL_DRV_DATA
>((kernel_ulong_t)&s3c2410_serial_drv_data)
>+#define S3C2410_SERIAL_DRV_DATA (&s3c2410_serial_drv_data)
> #else
>-#define S3C2410_SERIAL_DRV_DATA (kernel_ulong_t)NULL
>+#define S3C2410_SERIAL_DRV_DATA NULL
> #endif
>
> #ifdef CONFIG_CPU_S3C2412
>-static struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
>+static const struct s3c24xx_serial_drv_data s3c2412_serial_drv_data = {
> 	.info = {
> 		.name		= "Samsung S3C2412 UART",
> 		.type		= TYPE_S3C24XX,
>@@ -2666,14 +2666,14 @@ static struct s3c24xx_serial_drv_data
>s3c2412_serial_drv_data = {
> 		.ufcon		= S3C2410_UFCON_DEFAULT,
> 	},
> };
>-#define S3C2412_SERIAL_DRV_DATA
>((kernel_ulong_t)&s3c2412_serial_drv_data)
>+#define S3C2412_SERIAL_DRV_DATA (&s3c2412_serial_drv_data)
> #else
>-#define S3C2412_SERIAL_DRV_DATA (kernel_ulong_t)NULL
>+#define S3C2412_SERIAL_DRV_DATA NULL
> #endif
>
> #if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2416) || \
> 	defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2442) -
>static struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
>+static const struct s3c24xx_serial_drv_data s3c2440_serial_drv_data = {
> 	.info = {
> 		.name		= "Samsung S3C2440 UART",
> 		.type		= TYPE_S3C24XX,
>@@ -2697,13 +2697,13 @@ static struct s3c24xx_serial_drv_data
>s3c2440_serial_drv_data = {
> 		.ufcon		= S3C2410_UFCON_DEFAULT,
> 	},
> };
>-#define S3C2440_SERIAL_DRV_DATA
>((kernel_ulong_t)&s3c2440_serial_drv_data)
>+#define S3C2440_SERIAL_DRV_DATA (&s3c2440_serial_drv_data)
> #else
>-#define S3C2440_SERIAL_DRV_DATA (kernel_ulong_t)NULL
>+#define S3C2440_SERIAL_DRV_DATA NULL
> #endif
>
> #if defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410) -
>static struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
>+static const struct s3c24xx_serial_drv_data s3c6400_serial_drv_data = {
> 	.info = {
> 		.name		= "Samsung S3C6400 UART",
> 		.type		= TYPE_S3C6400,
>@@ -2726,13 +2726,13 @@ static struct s3c24xx_serial_drv_data
>s3c6400_serial_drv_data = {
> 		.ufcon		= S3C2410_UFCON_DEFAULT,
> 	},
> };
>-#define S3C6400_SERIAL_DRV_DATA
>((kernel_ulong_t)&s3c6400_serial_drv_data)
>+#define S3C6400_SERIAL_DRV_DATA (&s3c6400_serial_drv_data)
> #else
>-#define S3C6400_SERIAL_DRV_DATA (kernel_ulong_t)NULL
>+#define S3C6400_SERIAL_DRV_DATA NULL
> #endif
>
> #ifdef CONFIG_CPU_S5PV210
>-static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
>+static const struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
> 	.info = {
> 		.name		= "Samsung S5PV210 UART",
> 		.type		= TYPE_S3C6400,
>@@ -2755,9 +2755,9 @@ static struct s3c24xx_serial_drv_data
>s5pv210_serial_drv_data = {
> 	},
> 	.fifosize = { 256, 64, 16, 16 },
> };
>-#define S5PV210_SERIAL_DRV_DATA
>((kernel_ulong_t)&s5pv210_serial_drv_data)
>+#define S5PV210_SERIAL_DRV_DATA (&s5pv210_serial_drv_data)
> #else
>-#define S5PV210_SERIAL_DRV_DATA	(kernel_ulong_t)NULL
>+#define S5PV210_SERIAL_DRV_DATA	NULL
> #endif
>
> #if defined(CONFIG_ARCH_EXYNOS)
>@@ -2784,33 +2784,33 @@ static struct s3c24xx_serial_drv_data
>s5pv210_serial_drv_data = {
> 		.has_fracval	= 1,				\
> 	}							\
>
>-static struct s3c24xx_serial_drv_data exynos4210_serial_drv_data = {
>+static const struct s3c24xx_serial_drv_data exynos4210_serial_drv_data
>+= {
> 	EXYNOS_COMMON_SERIAL_DRV_DATA(),
> 	.fifosize = { 256, 64, 16, 16 },
> };
>
>-static struct s3c24xx_serial_drv_data exynos5433_serial_drv_data = {
>+static const struct s3c24xx_serial_drv_data exynos5433_serial_drv_data
>+= {
> 	EXYNOS_COMMON_SERIAL_DRV_DATA(),
> 	.fifosize = { 64, 256, 16, 256 },
> };
>
>-static struct s3c24xx_serial_drv_data exynos850_serial_drv_data = {
>+static const struct s3c24xx_serial_drv_data exynos850_serial_drv_data =
>+{
> 	EXYNOS_COMMON_SERIAL_DRV_DATA(),
> 	.fifosize = { 256, 64, 64, 64 },
> };
>
>-#define EXYNOS4210_SERIAL_DRV_DATA
>((kernel_ulong_t)&exynos4210_serial_drv_data)
>-#define EXYNOS5433_SERIAL_DRV_DATA
>((kernel_ulong_t)&exynos5433_serial_drv_data)
>-#define EXYNOS850_SERIAL_DRV_DATA
>((kernel_ulong_t)&exynos850_serial_drv_data)
>+#define EXYNOS4210_SERIAL_DRV_DATA (&exynos4210_serial_drv_data)
>+#define EXYNOS5433_SERIAL_DRV_DATA (&exynos5433_serial_drv_data)
>+#define EXYNOS850_SERIAL_DRV_DATA (&exynos850_serial_drv_data)
>
> #else
>-#define EXYNOS4210_SERIAL_DRV_DATA ((kernel_ulong_t)NULL) -#define
>EXYNOS5433_SERIAL_DRV_DATA ((kernel_ulong_t)NULL) -#define
>EXYNOS850_SERIAL_DRV_DATA ((kernel_ulong_t)NULL)
>+#define EXYNOS4210_SERIAL_DRV_DATA NULL #define
>+EXYNOS5433_SERIAL_DRV_DATA NULL #define
>EXYNOS850_SERIAL_DRV_DATA NULL
> #endif
>
> #ifdef CONFIG_ARCH_APPLE
>-static struct s3c24xx_serial_drv_data s5l_serial_drv_data = {
>+static const struct s3c24xx_serial_drv_data s5l_serial_drv_data = {
> 	.info = {
> 		.name		= "Apple S5L UART",
> 		.type		= TYPE_APPLE_S5L,
>@@ -2832,39 +2832,39 @@ static struct s3c24xx_serial_drv_data
>s5l_serial_drv_data = {
> 		.ufcon		= S3C2410_UFCON_DEFAULT,
> 	},
> };
>-#define S5L_SERIAL_DRV_DATA ((kernel_ulong_t)&s5l_serial_drv_data)
>+#define S5L_SERIAL_DRV_DATA (&s5l_serial_drv_data)
> #else
>-#define S5L_SERIAL_DRV_DATA ((kernel_ulong_t)NULL)
>+#define S5L_SERIAL_DRV_DATA NULL
> #endif
>
> static const struct platform_device_id s3c24xx_serial_driver_ids[] = {
> 	{
> 		.name		= "s3c2410-uart",
>-		.driver_data	= S3C2410_SERIAL_DRV_DATA,
>+		.driver_data	=
>(kernel_ulong_t)S3C2410_SERIAL_DRV_DATA,
> 	}, {
> 		.name		= "s3c2412-uart",
>-		.driver_data	= S3C2412_SERIAL_DRV_DATA,
>+		.driver_data	=
>(kernel_ulong_t)S3C2412_SERIAL_DRV_DATA,
> 	}, {
> 		.name		= "s3c2440-uart",
>-		.driver_data	= S3C2440_SERIAL_DRV_DATA,
>+		.driver_data	=
>(kernel_ulong_t)S3C2440_SERIAL_DRV_DATA,
> 	}, {
> 		.name		= "s3c6400-uart",
>-		.driver_data	= S3C6400_SERIAL_DRV_DATA,
>+		.driver_data	=
>(kernel_ulong_t)S3C6400_SERIAL_DRV_DATA,
> 	}, {
> 		.name		= "s5pv210-uart",
>-		.driver_data	= S5PV210_SERIAL_DRV_DATA,
>+		.driver_data	=
>(kernel_ulong_t)S5PV210_SERIAL_DRV_DATA,
> 	}, {
> 		.name		= "exynos4210-uart",
>-		.driver_data	= EXYNOS4210_SERIAL_DRV_DATA,
>+		.driver_data	=
>(kernel_ulong_t)EXYNOS4210_SERIAL_DRV_DATA,
> 	}, {
> 		.name		= "exynos5433-uart",
>-		.driver_data	= EXYNOS5433_SERIAL_DRV_DATA,
>+		.driver_data	=
>(kernel_ulong_t)EXYNOS5433_SERIAL_DRV_DATA,
> 	}, {
> 		.name		= "s5l-uart",
>-		.driver_data	= S5L_SERIAL_DRV_DATA,
>+		.driver_data	= (kernel_ulong_t)S5L_SERIAL_DRV_DATA,
> 	}, {
> 		.name		= "exynos850-uart",
>-		.driver_data	= EXYNOS850_SERIAL_DRV_DATA,
>+		.driver_data	=
>(kernel_ulong_t)EXYNOS850_SERIAL_DRV_DATA,
> 	},
> 	{ },
> };
>@@ -2873,23 +2873,23 @@ MODULE_DEVICE_TABLE(platform,
>s3c24xx_serial_driver_ids);  #ifdef CONFIG_OF  static const struct
>of_device_id s3c24xx_uart_dt_match[] = {
> 	{ .compatible = "samsung,s3c2410-uart",
>-		.data = (void *)S3C2410_SERIAL_DRV_DATA },
>+		.data = S3C2410_SERIAL_DRV_DATA },
> 	{ .compatible = "samsung,s3c2412-uart",
>-		.data = (void *)S3C2412_SERIAL_DRV_DATA },
>+		.data = S3C2412_SERIAL_DRV_DATA },
> 	{ .compatible = "samsung,s3c2440-uart",
>-		.data = (void *)S3C2440_SERIAL_DRV_DATA },
>+		.data = S3C2440_SERIAL_DRV_DATA },
> 	{ .compatible = "samsung,s3c6400-uart",
>-		.data = (void *)S3C6400_SERIAL_DRV_DATA },
>+		.data = S3C6400_SERIAL_DRV_DATA },
> 	{ .compatible = "samsung,s5pv210-uart",
>-		.data = (void *)S5PV210_SERIAL_DRV_DATA },
>+		.data = S5PV210_SERIAL_DRV_DATA },
> 	{ .compatible = "samsung,exynos4210-uart",
>-		.data = (void *)EXYNOS4210_SERIAL_DRV_DATA },
>+		.data = EXYNOS4210_SERIAL_DRV_DATA },
> 	{ .compatible = "samsung,exynos5433-uart",
>-		.data = (void *)EXYNOS5433_SERIAL_DRV_DATA },
>+		.data = EXYNOS5433_SERIAL_DRV_DATA },
> 	{ .compatible = "apple,s5l-uart",
>-		.data = (void *)S5L_SERIAL_DRV_DATA },
>+		.data = S5L_SERIAL_DRV_DATA },
> 	{ .compatible = "samsung,exynos850-uart",
>-		.data = (void *)EXYNOS850_SERIAL_DRV_DATA },
>+		.data = EXYNOS850_SERIAL_DRV_DATA },
> 	{},
> };
> MODULE_DEVICE_TABLE(of, s3c24xx_uart_dt_match);
>--
>2.32.0



^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups
  2022-03-07  8:08 ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Krzysztof Kozlowski
                     ` (7 preceding siblings ...)
  2022-03-07  8:09   ` [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match data Krzysztof Kozlowski
@ 2022-03-07 18:21   ` Alim Akhtar
  8 siblings, 0 replies; 18+ messages in thread
From: Alim Akhtar @ 2022-03-07 18:21 UTC (permalink / raw)
  To: 'Krzysztof Kozlowski', 'Greg Kroah-Hartman',
	'Jiri Slaby',
	linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel

Hi Krzysztof

>-----Original Message-----
>From: Krzysztof Kozlowski [mailto:krzysztof.kozlowski@canonical.com]
>Sent: Monday, March 7, 2022 1:38 PM
>To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>; Alim Akhtar
><alim.akhtar@samsung.com>; Greg Kroah-Hartman
><gregkh@linuxfoundation.org>; Jiri Slaby <jirislaby@kernel.org>; linux-arm-
>kernel@lists.infradead.org; linux-samsung-soc@vger.kernel.org; linux-
>serial@vger.kernel.org; linux-kernel@vger.kernel.org
>Subject: [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups
>
>Hi,
>
>Changes since v1:
>1. Patch 3: remove unneeded parenthesis and module alias change (Jiri).
>2. Patch 3: move unrelated "constify" bits to patch 6.
>3. Patch 5: fix typo.
>4. Add review tags.
>
>Best regards,
>Krzysztof
>
>Krzysztof Kozlowski (7):
>  tty: serial: samsung: embed s3c24xx_uart_info in parent structure
>  tty: serial: samsung: embed s3c2410_uartcfg in parent structure
>  tty: serial: samsung: constify s3c24xx_serial_drv_data
>  tty: serial: samsung: constify UART name
>  tty: serial: samsung: constify s3c24xx_serial_drv_data members
>  tty: serial: samsung: constify variables and pointers
>  tty: serial: samsung: simplify getting OF match data
>
> drivers/tty/serial/samsung_tty.c | 225 +++++++++++++++----------------
> 1 file changed, 109 insertions(+), 116 deletions(-)
>

For this series feel free to add
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>

Sanity tested on Exynos7 Espresso board, boot log and other console prints
after boot looks fine, so

Tested-by: Alim Akhtar <alim.akhtar@samsung.com>

>--
>2.32.0



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match data
  2022-03-07  8:09   ` [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match data Krzysztof Kozlowski
  2022-03-07 18:16     ` Alim Akhtar
@ 2022-03-07 20:24     ` Andy Shevchenko
  2022-03-08  7:19       ` Krzysztof Kozlowski
  1 sibling, 1 reply; 18+ messages in thread
From: Andy Shevchenko @ 2022-03-07 20:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm Mailing List, Linux Samsung SOC,
	open list:SERIAL DRIVERS, Linux Kernel Mailing List

On Mon, Mar 7, 2022 at 11:20 AM Krzysztof Kozlowski
<krzysztof.kozlowski@canonical.com> wrote:
>
> Simplify the code with of_device_get_match_data().

You may get rid of ugly ifdeffery as well.

...

>  static inline const struct s3c24xx_serial_drv_data *
>  s3c24xx_get_driver_data(struct platform_device *pdev)
>  {
>  #ifdef CONFIG_OF
> -       if (pdev->dev.of_node) {
> -               const struct of_device_id *match;
> -
> -               match = of_match_node(s3c24xx_uart_dt_match, pdev->dev.of_node);
> -               return (struct s3c24xx_serial_drv_data *)match->data;
> -       }

> +       if (pdev->dev.of_node)

I believe it's never true when CONFIG_OF=n,

> +               return of_device_get_match_data(&pdev->dev);
>  #endif
> +
>         return (struct s3c24xx_serial_drv_data *)
>                         platform_get_device_id(pdev)->driver_data;
>  }

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match data
  2022-03-07 20:24     ` Andy Shevchenko
@ 2022-03-08  7:19       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-08  7:19 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Alim Akhtar, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm Mailing List, Linux Samsung SOC,
	open list:SERIAL DRIVERS, Linux Kernel Mailing List

On 07/03/2022 21:24, Andy Shevchenko wrote:
> On Mon, Mar 7, 2022 at 11:20 AM Krzysztof Kozlowski
> <krzysztof.kozlowski@canonical.com> wrote:
>>
>> Simplify the code with of_device_get_match_data().
> 
> You may get rid of ugly ifdeffery as well.
> 
> ...
> 
>>  static inline const struct s3c24xx_serial_drv_data *
>>  s3c24xx_get_driver_data(struct platform_device *pdev)
>>  {
>>  #ifdef CONFIG_OF
>> -       if (pdev->dev.of_node) {
>> -               const struct of_device_id *match;
>> -
>> -               match = of_match_node(s3c24xx_uart_dt_match, pdev->dev.of_node);
>> -               return (struct s3c24xx_serial_drv_data *)match->data;
>> -       }
> 
>> +       if (pdev->dev.of_node)
> 
> I believe it's never true when CONFIG_OF=n,

Right, I can use dev_of_node() helper for that purpose as well. Thanks!


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/7] tty: serial: samsung: constify s3c24xx_serial_drv_data
  2022-03-07  8:40       ` Krzysztof Kozlowski
@ 2022-03-08  8:06         ` Krzysztof Kozlowski
  0 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-08  8:06 UTC (permalink / raw)
  To: Jiri Slaby, Alim Akhtar, Greg Kroah-Hartman, linux-arm-kernel,
	linux-samsung-soc, linux-serial, linux-kernel

On 07/03/2022 09:40, Krzysztof Kozlowski wrote:
> On 07/03/2022 09:33, Jiri Slaby wrote:
>> On 07. 03. 22, 9:09, Krzysztof Kozlowski wrote:
>>> The driver data (struct s3c24xx_serial_drv_data) is only used to
>>> initialize the driver properly and is not modified.  Make it const.
>> ...
>>> @@ -2755,9 +2755,9 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
>>>   	},
>>>   	.fifosize = { 256, 64, 16, 16 },
>>>   };
>>> -#define S5PV210_SERIAL_DRV_DATA ((kernel_ulong_t)&s5pv210_serial_drv_data)
>>> +#define S5PV210_SERIAL_DRV_DATA (&s5pv210_serial_drv_data)
>>>   #else
>>> -#define S5PV210_SERIAL_DRV_DATA	(kernel_ulong_t)NULL
>>> +#define S5PV210_SERIAL_DRV_DATA	NULL
>>
>> Yet, I still don't see why the switch from ulong->ptr happens in this 
>> "constify it" patch?
> 
> All these defines S5PV210_SERIAL_DRV_DATA and so on are now const and
> are assigned to of_device_id.data (s3c24xx_uart_dt_match). Before, these
> were assigned with a cast:
> 
> static const struct of_device_id s3c24xx_uart_dt_match[] = {
> 	{ .compatible = "samsung,s5pv210-uart",
> 
> 	.data = (void *)S5PV210_SERIAL_DRV_DATA }
> 
> but since the actual data structure is const, I want to drop the cast.
> Casting const via (void *) might hide some possible issues, e.g. if
> of_device_id.data becomes actually non-const. There is no particular
> issue here, because of_device_id.data and S5PV210_SERIAL_DRV_DATA are
> const. But also because they are both const now, I want to drop the cast
> via void *.
> 
> When (void *) is dropped, the S5PV210_SERIAL_DRV_DATA cannot be
> kernel_ulong_t:
> 
> ../drivers/tty/serial/samsung_tty.c:2753:33: warning: initialization of
> ‘const void *’ from ‘long unsigned int’ makes pointer from integer
> without a cast [-Wint-conversion]
> 
>  2753 | #define S5PV210_SERIAL_DRV_DATA (kernel_ulong_t)NULL
> 

I will split the casts removal to separate patch. I hope this clarifies
a bit.


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-03-08  8:07 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20220307080826epcas5p13d71054f6b461cff91edbbb2cf42491a@epcas5p1.samsung.com>
2022-03-07  8:08 ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Krzysztof Kozlowski
2022-03-07  8:08   ` [PATCH v2 1/7] tty: serial: samsung: embed s3c24xx_uart_info in parent structure Krzysztof Kozlowski
2022-03-07  8:08   ` Krzysztof Kozlowski
2022-03-07  8:10     ` Krzysztof Kozlowski
2022-03-07  8:09   ` [PATCH v2 2/7] tty: serial: samsung: embed s3c2410_uartcfg " Krzysztof Kozlowski
2022-03-07  8:09   ` [PATCH v2 3/7] tty: serial: samsung: constify s3c24xx_serial_drv_data Krzysztof Kozlowski
2022-03-07  8:33     ` Jiri Slaby
2022-03-07  8:40       ` Krzysztof Kozlowski
2022-03-08  8:06         ` Krzysztof Kozlowski
2022-03-07 18:18     ` Alim Akhtar
2022-03-07  8:09   ` [PATCH v2 4/7] tty: serial: samsung: constify UART name Krzysztof Kozlowski
2022-03-07  8:09   ` [PATCH v2 5/7] tty: serial: samsung: constify s3c24xx_serial_drv_data members Krzysztof Kozlowski
2022-03-07  8:09   ` [PATCH v2 6/7] tty: serial: samsung: constify variables and pointers Krzysztof Kozlowski
2022-03-07  8:09   ` [PATCH v2 7/7] tty: serial: samsung: simplify getting OF match data Krzysztof Kozlowski
2022-03-07 18:16     ` Alim Akhtar
2022-03-07 20:24     ` Andy Shevchenko
2022-03-08  7:19       ` Krzysztof Kozlowski
2022-03-07 18:21   ` [PATCH v2 0/7] tty: serial: samsung: minor fixes/cleanups Alim Akhtar

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).