linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] spi: pxa2xx: Reuse int_stop_and_reset() in couple of places
@ 2021-07-21 11:32 Dan Carpenter
  2021-07-21 12:15 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-07-21 11:32 UTC (permalink / raw)
  To: andriy.shevchenko; +Cc: linux-spi

Hello Andy Shevchenko,

The patch 3bbdc083262d: "spi: pxa2xx: Reuse int_stop_and_reset() in
couple of places" from Jul 19, 2021, leads to the following static
checker warning:

	drivers/spi/spi-pxa2xx.c:774 ssp_int()
	error: we previously assumed 'drv_data->controller->cur_msg' could be null (see line 773)

drivers/spi/spi-pxa2xx.c
    731 static irqreturn_t ssp_int(int irq, void *dev_id)
    732 {
    733 	struct driver_data *drv_data = dev_id;
    734 	u32 sccr1_reg;
    735 	u32 mask = drv_data->mask_sr;
    736 	u32 status;
    737 
    738 	/*
    739 	 * The IRQ might be shared with other peripherals so we must first
    740 	 * check that are we RPM suspended or not. If we are we assume that
    741 	 * the IRQ was not for us (we shouldn't be RPM suspended when the
    742 	 * interrupt is enabled).
    743 	 */
    744 	if (pm_runtime_suspended(drv_data->ssp->dev))
    745 		return IRQ_NONE;
    746 
    747 	/*
    748 	 * If the device is not yet in RPM suspended state and we get an
    749 	 * interrupt that is meant for another device, check if status bits
    750 	 * are all set to one. That means that the device is already
    751 	 * powered off.
    752 	 */
    753 	status = pxa2xx_spi_read(drv_data, SSSR);
    754 	if (status == ~0)
    755 		return IRQ_NONE;
    756 
    757 	sccr1_reg = pxa2xx_spi_read(drv_data, SSCR1);
    758 
    759 	/* Ignore possible writes if we don't need to write */
    760 	if (!(sccr1_reg & SSCR1_TIE))
    761 		mask &= ~SSSR_TFS;
    762 
    763 	/* Ignore RX timeout interrupt if it is disabled */
    764 	if (!(sccr1_reg & SSCR1_TINTE))
    765 		mask &= ~SSSR_TINT;
    766 
    767 	if (!(status & mask))
    768 		return IRQ_NONE;
    769 
    770 	pxa2xx_spi_write(drv_data, SSCR1, sccr1_reg & ~drv_data->int_cr1);
    771 	pxa2xx_spi_write(drv_data, SSCR1, sccr1_reg);
    772 
    773 	if (!drv_data->controller->cur_msg) {
--> 774 		handle_bad_msg(drv_data);
                        ^^^^^^^^^^^^^^^^^^^^^^^^
We can't reset with a NULL drv_data->controller->cur_msg.

    775 		/* Never fail */
    776 		return IRQ_HANDLED;
    777 	}
    778 
    779 	return drv_data->transfer_handler(drv_data);
    780 }

regards,
dan carpenter

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

* Re: [bug report] spi: pxa2xx: Reuse int_stop_and_reset() in couple of places
  2021-07-21 11:32 [bug report] spi: pxa2xx: Reuse int_stop_and_reset() in couple of places Dan Carpenter
@ 2021-07-21 12:15 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2021-07-21 12:15 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-spi

On Wed, Jul 21, 2021 at 04:32:46AM -0700, Dan Carpenter wrote:
> Hello Andy Shevchenko,
> 
> The patch 3bbdc083262d: "spi: pxa2xx: Reuse int_stop_and_reset() in
> couple of places" from Jul 19, 2021, leads to the following static
> checker warning:
> 
> 	drivers/spi/spi-pxa2xx.c:774 ssp_int()
> 	error: we previously assumed 'drv_data->controller->cur_msg' could be null (see line 773)

>     773 	if (!drv_data->controller->cur_msg) {
> --> 774 		handle_bad_msg(drv_data);
>                         ^^^^^^^^^^^^^^^^^^^^^^^^
> We can't reset with a NULL drv_data->controller->cur_msg.

We can if we handle this inside reset_sccr1() properly.
Thanks for the report and patch on its way!

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2021-07-21 12:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-21 11:32 [bug report] spi: pxa2xx: Reuse int_stop_and_reset() in couple of places Dan Carpenter
2021-07-21 12:15 ` Andy Shevchenko

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