mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] serial: cpm_uart: use irq variable for platform_get_irq()
@ 2026-09-25 18:15 Rosen Penev
  2026-10-01  8:46 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Rosen Penev @ 2026-09-25 18:15 UTC (permalink / raw)
  To: linux-serial
  Cc: Greg Kroah-Hartman, Jiri Slaby, Rosen Penev,
	open list:TTY LAYER AND SERIAL DRIVERS

struct uart_port has its irq member as an unsigned int, which does not
work when platform_get_irq() returns an error.

Use a local irq variable to handle this and write to struct uart_port's
irq member when platform_get_irq() succeeds. On success, it returns an
IRQ >= 0, which is representable by unsigned int.

Fixes: 831603b3e8aa ("serial: cpm_uart: replace irq_of_parse_and_map with platform_get_irq")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202609251916.1XlVHLwd-lkp@intel.com/
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/tty/serial/cpm_uart.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart.c b/drivers/tty/serial/cpm_uart.c
index 39f54bb7b485..ca0acccd3dd8 100644
--- a/drivers/tty/serial/cpm_uart.c
+++ b/drivers/tty/serial/cpm_uart.c
@@ -1517,6 +1517,7 @@ static int cpm_uart_probe(struct platform_device *ofdev)
 {
 	int index = probe_index++;
 	struct uart_cpm_port *pinfo = &cpm_uart_ports[index];
+	int irq;
 	int ret;
 
 	pinfo->port.line = index;
@@ -1524,14 +1525,15 @@ static int cpm_uart_probe(struct platform_device *ofdev)
 	if (index >= UART_NR)
 		return -ENODEV;
 
+	irq = platform_get_irq(ofdev, 0);
+	if (irq < 0)
+		return irq;
+
 	platform_set_drvdata(ofdev, pinfo);
 
 	/* initialize the device pointer for the port */
 	pinfo->port.dev = &ofdev->dev;
-
-	pinfo->port.irq = platform_get_irq(ofdev, 0);
-	if (pinfo->port.irq < 0)
-		return pinfo->port.irq;
+	pinfo->port.irq = irq;
 
 	ret = cpm_uart_init_port(ofdev->dev.of_node, pinfo);
 	if (!ret)
-- 
2.55.0


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

* Re: [PATCH] serial: cpm_uart: use irq variable for platform_get_irq()
  2026-09-25 18:15 [PATCH] serial: cpm_uart: use irq variable for platform_get_irq() Rosen Penev
@ 2026-10-01  8:46 ` Greg Kroah-Hartman
  2026-10-01 20:38   ` Rosen Penev
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-10-01  8:46 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-serial, Jiri Slaby, open list:TTY LAYER AND SERIAL DRIVERS

On Fri, Sep 25, 2026 at 11:15:30AM -0700, Rosen Penev wrote:
> struct uart_port has its irq member as an unsigned int, which does not
> work when platform_get_irq() returns an error.
> 
> Use a local irq variable to handle this and write to struct uart_port's
> irq member when platform_get_irq() succeeds. On success, it returns an
> IRQ >= 0, which is representable by unsigned int.
> 
> Fixes: 831603b3e8aa ("serial: cpm_uart: replace irq_of_parse_and_map with platform_get_irq")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202609251916.1XlVHLwd-lkp@intel.com/
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/tty/serial/cpm_uart.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/cpm_uart.c b/drivers/tty/serial/cpm_uart.c
> index 39f54bb7b485..ca0acccd3dd8 100644
> --- a/drivers/tty/serial/cpm_uart.c
> +++ b/drivers/tty/serial/cpm_uart.c
> @@ -1517,6 +1517,7 @@ static int cpm_uart_probe(struct platform_device *ofdev)
>  {
>  	int index = probe_index++;
>  	struct uart_cpm_port *pinfo = &cpm_uart_ports[index];
> +	int irq;
>  	int ret;
>  
>  	pinfo->port.line = index;
> @@ -1524,14 +1525,15 @@ static int cpm_uart_probe(struct platform_device *ofdev)
>  	if (index >= UART_NR)
>  		return -ENODEV;
>  
> +	irq = platform_get_irq(ofdev, 0);
> +	if (irq < 0)
> +		return irq;
> +
>  	platform_set_drvdata(ofdev, pinfo);
>  
>  	/* initialize the device pointer for the port */
>  	pinfo->port.dev = &ofdev->dev;
> -
> -	pinfo->port.irq = platform_get_irq(ofdev, 0);
> -	if (pinfo->port.irq < 0)
> -		return pinfo->port.irq;
> +	pinfo->port.irq = irq;

Why did you move where platform_get_irq() is called?

thanks,

greg k-h

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

* Re: [PATCH] serial: cpm_uart: use irq variable for platform_get_irq()
  2026-10-01  8:46 ` Greg Kroah-Hartman
@ 2026-10-01 20:38   ` Rosen Penev
  2026-10-02  5:54     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Rosen Penev @ 2026-10-01 20:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rosen Penev
  Cc: linux-serial, Jiri Slaby, open list:TTY LAYER AND SERIAL DRIVERS

On Thu Oct 1, 2026 at 1:46 AM PDT, Greg Kroah-Hartman wrote:
> On Fri, Sep 25, 2026 at 11:15:30AM -0700, Rosen Penev wrote:
>> struct uart_port has its irq member as an unsigned int, which does not
>> work when platform_get_irq() returns an error.
>>
>> Use a local irq variable to handle this and write to struct uart_port's
>> irq member when platform_get_irq() succeeds. On success, it returns an
>> IRQ >= 0, which is representable by unsigned int.
>>
>> Fixes: 831603b3e8aa ("serial: cpm_uart: replace irq_of_parse_and_map with platform_get_irq")
>> Reported-by: kernel test robot <lkp@intel.com>
>> Closes: https://lore.kernel.org/oe-kbuild-all/202609251916.1XlVHLwd-lkp@intel.com/
>> Signed-off-by: Rosen Penev <rosenp@gmail.com>
>> ---
>>  drivers/tty/serial/cpm_uart.c | 10 ++++++----
>>  1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/tty/serial/cpm_uart.c b/drivers/tty/serial/cpm_uart.c
>> index 39f54bb7b485..ca0acccd3dd8 100644
>> --- a/drivers/tty/serial/cpm_uart.c
>> +++ b/drivers/tty/serial/cpm_uart.c
>> @@ -1517,6 +1517,7 @@ static int cpm_uart_probe(struct platform_device *ofdev)
>>  {
>>  	int index = probe_index++;
>>  	struct uart_cpm_port *pinfo = &cpm_uart_ports[index];
>> +	int irq;
>>  	int ret;
>>
>>  	pinfo->port.line = index;
>> @@ -1524,14 +1525,15 @@ static int cpm_uart_probe(struct platform_device *ofdev)
>>  	if (index >= UART_NR)
>>  		return -ENODEV;
>>
>> +	irq = platform_get_irq(ofdev, 0);
>> +	if (irq < 0)
>> +		return irq;
>> +
>>  	platform_set_drvdata(ofdev, pinfo);
>>
>>  	/* initialize the device pointer for the port */
>>  	pinfo->port.dev = &ofdev->dev;
>> -
>> -	pinfo->port.irq = platform_get_irq(ofdev, 0);
>> -	if (pinfo->port.irq < 0)
>> -		return pinfo->port.irq;
>> +	pinfo->port.irq = irq;
>
> Why did you move where platform_get_irq() is called?

So that platform_set_drvdata does not get called on failure.

>
> thanks,
>
> greg k-h



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

* Re: [PATCH] serial: cpm_uart: use irq variable for platform_get_irq()
  2026-10-01 20:38   ` Rosen Penev
@ 2026-10-02  5:54     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-10-02  5:54 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-serial, Jiri Slaby, open list:TTY LAYER AND SERIAL DRIVERS

On Thu, Oct 01, 2026 at 01:38:15PM -0700, Rosen Penev wrote:
> On Thu Oct 1, 2026 at 1:46 AM PDT, Greg Kroah-Hartman wrote:
> > On Fri, Sep 25, 2026 at 11:15:30AM -0700, Rosen Penev wrote:
> >> struct uart_port has its irq member as an unsigned int, which does not
> >> work when platform_get_irq() returns an error.
> >>
> >> Use a local irq variable to handle this and write to struct uart_port's
> >> irq member when platform_get_irq() succeeds. On success, it returns an
> >> IRQ >= 0, which is representable by unsigned int.
> >>
> >> Fixes: 831603b3e8aa ("serial: cpm_uart: replace irq_of_parse_and_map with platform_get_irq")
> >> Reported-by: kernel test robot <lkp@intel.com>
> >> Closes: https://lore.kernel.org/oe-kbuild-all/202609251916.1XlVHLwd-lkp@intel.com/
> >> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> >> ---
> >>  drivers/tty/serial/cpm_uart.c | 10 ++++++----
> >>  1 file changed, 6 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/tty/serial/cpm_uart.c b/drivers/tty/serial/cpm_uart.c
> >> index 39f54bb7b485..ca0acccd3dd8 100644
> >> --- a/drivers/tty/serial/cpm_uart.c
> >> +++ b/drivers/tty/serial/cpm_uart.c
> >> @@ -1517,6 +1517,7 @@ static int cpm_uart_probe(struct platform_device *ofdev)
> >>  {
> >>  	int index = probe_index++;
> >>  	struct uart_cpm_port *pinfo = &cpm_uart_ports[index];
> >> +	int irq;
> >>  	int ret;
> >>
> >>  	pinfo->port.line = index;
> >> @@ -1524,14 +1525,15 @@ static int cpm_uart_probe(struct platform_device *ofdev)
> >>  	if (index >= UART_NR)
> >>  		return -ENODEV;
> >>
> >> +	irq = platform_get_irq(ofdev, 0);
> >> +	if (irq < 0)
> >> +		return irq;
> >> +
> >>  	platform_set_drvdata(ofdev, pinfo);
> >>
> >>  	/* initialize the device pointer for the port */
> >>  	pinfo->port.dev = &ofdev->dev;
> >> -
> >> -	pinfo->port.irq = platform_get_irq(ofdev, 0);
> >> -	if (pinfo->port.irq < 0)
> >> -		return pinfo->port.irq;
> >> +	pinfo->port.irq = irq;
> >
> > Why did you move where platform_get_irq() is called?
> 
> So that platform_set_drvdata does not get called on failure.

Why does that matter?

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

end of thread, other threads:[~2026-10-02  5:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 18:15 [PATCH] serial: cpm_uart: use irq variable for platform_get_irq() Rosen Penev
2026-10-01  8:46 ` Greg Kroah-Hartman
2026-10-01 20:38   ` Rosen Penev
2026-10-02  5:54     ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®