diff mbox series

[v2,07/14] spi: pxa2xx: Introduce int_stop_and_reset() helper

Message ID 20210423182441.50272-8-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series spi: pxa2xx: Set of cleanups | expand

Commit Message

Andy Shevchenko April 23, 2021, 6:24 p.m. UTC
Currently we have three times the same few lines repeated in the code.
Deduplicate them by newly introduced int_stop_and_reset() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

Comments

Mark Brown May 10, 2021, 12:09 p.m. UTC | #1
On Fri, Apr 23, 2021 at 09:24:34PM +0300, Andy Shevchenko wrote:
> Currently we have three times the same few lines repeated in the code.
> Deduplicate them by newly introduced int_stop_and_reset() helper.

This doesn't apply against current code, please check and resend.
Andy Shevchenko May 10, 2021, 12:38 p.m. UTC | #2
On Mon, May 10, 2021 at 01:09:53PM +0100, Mark Brown wrote:
> On Fri, Apr 23, 2021 at 09:24:34PM +0300, Andy Shevchenko wrote:
> > Currently we have three times the same few lines repeated in the code.
> > Deduplicate them by newly introduced int_stop_and_reset() helper.
> 
> This doesn't apply against current code, please check and resend.

Hmm...

Can you, please, point out, what branch should I use?
It seems good against v5.13-rc1 and spi/for-5.14.

Okay, I will resend against spi/for-5.14, but I don't see the issue here.
Mark Brown May 10, 2021, 1:57 p.m. UTC | #3
On Mon, May 10, 2021 at 03:38:56PM +0300, Andy Shevchenko wrote:

> Okay, I will resend against spi/for-5.14, but I don't see the issue here.

It'll have been against 5.14.
diff mbox series

Patch

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index 0296cbdee848..4dab47e18d10 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -620,13 +620,20 @@  static void reset_sccr1(struct driver_data *drv_data)
 	pxa2xx_spi_write(drv_data, SSCR1, sccr1_reg);
 }
 
-static void int_error_stop(struct driver_data *drv_data, const char* msg)
+static void int_stop_and_reset(struct driver_data *drv_data)
 {
-	/* Stop and reset SSP */
+	/* Clear and disable interrupts */
 	write_SSSR_CS(drv_data, drv_data->clear_sr);
 	reset_sccr1(drv_data);
-	if (!pxa25x_ssp_comp(drv_data))
-		pxa2xx_spi_write(drv_data, SSTO, 0);
+	if (pxa25x_ssp_comp(drv_data))
+		return;
+
+	pxa2xx_spi_write(drv_data, SSTO, 0);
+}
+
+static void int_error_stop(struct driver_data *drv_data, const char *msg)
+{
+	int_stop_and_reset(drv_data);
 	pxa2xx_spi_flush(drv_data);
 	pxa2xx_spi_off(drv_data);
 
@@ -638,11 +645,7 @@  static void int_error_stop(struct driver_data *drv_data, const char* msg)
 
 static void int_transfer_complete(struct driver_data *drv_data)
 {
-	/* Clear and disable interrupts */
-	write_SSSR_CS(drv_data, drv_data->clear_sr);
-	reset_sccr1(drv_data);
-	if (!pxa25x_ssp_comp(drv_data))
-		pxa2xx_spi_write(drv_data, SSTO, 0);
+	int_stop_and_reset(drv_data);
 
 	spi_finalize_current_transfer(drv_data->controller);
 }
@@ -1151,11 +1154,7 @@  static int pxa2xx_spi_slave_abort(struct spi_controller *controller)
 {
 	struct driver_data *drv_data = spi_controller_get_devdata(controller);
 
-	/* Stop and reset SSP */
-	write_SSSR_CS(drv_data, drv_data->clear_sr);
-	reset_sccr1(drv_data);
-	if (!pxa25x_ssp_comp(drv_data))
-		pxa2xx_spi_write(drv_data, SSTO, 0);
+	int_stop_and_reset(drv_data);
 	pxa2xx_spi_flush(drv_data);
 	pxa2xx_spi_off(drv_data);