spi: pxa2xx: Reuse int_stop_and_reset() in couple of places
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
Quoted 6 lines · Dan Carpenter
Hello Andy Shevchenko,
The patch
3bbdc083262d: "spi: pxa2xx: Reuseint_stop_and_reset()in couple of places" from Jul 19, 2021, leads to the following static checker warning:
Quoted 7 lines
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!
Signature · 2 lines
With Best Regards, Andy Shevchenko