Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1558616

[PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx()
Date 2017-01-13 18:30 +0100
Message-ID <sZdPP-3DF-11@gated-at.bofh.it> (permalink)
References <sZdwt-3x7-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 17:30:46 +0100

Delete a duplicate check after a bit of exception handling was moved into
a previous if branch of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/spi/spi-topcliff-pch.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 97fd1ea9826b..33043a830032 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -584,22 +584,25 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
 	data->pkt_tx_buff = kzalloc(size, GFP_KERNEL);
 	if (data->pkt_tx_buff) {
 		data->pkt_rx_buff = kzalloc(size, GFP_KERNEL);
-		if (!data->pkt_rx_buff)
+		if (!data->pkt_rx_buff) {
 			kfree(data->pkt_tx_buff);
-	}
 
-	if (!data->pkt_rx_buff) {
-		/* flush queue and set status of all transfers to -ENOMEM */
-		list_for_each_entry_safe(pmsg, tmp, data->queue.next, queue) {
-			pmsg->status = -ENOMEM;
+			/*
+			 * Flush queue and set status of all transfers
+			 * to -ENOMEM.
+			 */
+			list_for_each_entry_safe(pmsg, tmp, data->queue.next,
+						 queue) {
+				pmsg->status = -ENOMEM;
 
-			if (pmsg->complete)
-				pmsg->complete(pmsg->context);
+				if (pmsg->complete)
+					pmsg->complete(pmsg->context);
 
-			/* delete from queue */
-			list_del_init(&pmsg->queue);
+				/* delete from queue */
+				list_del_init(&pmsg->queue);
+			}
+			return;
 		}
-		return;
 	}
 
 	/* copy Tx Data */
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/17] SPI: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:10 +0100
  [PATCH 01/17] spi: Use kcalloc() in spi_register_board_info() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:10 +0100
  [PATCH 04/17] spi: fsl: Use kmalloc_array() in  of_fsl_spi_get_chipselects() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
  [PATCH 07/17] spi/mpc52xx: Combine substrings for two messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
  [PATCH 06/17] spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
  [PATCH 02/17] spi: Adjust checks for null pointers in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
  [PATCH 03/17] spi: fsl: Use kcalloc() in of_fsl_spi_get_chipselects() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
  [PATCH 10/17] spi/ppc4xx: Adjust checks for null pointers in two  functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
  [PATCH 08/17] spi/ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
  [PATCH 09/17] spi/ppc4xx: Combine substrings for a message in  spi_ppc4xx_of_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
  [PATCH 05/17] spi: fsl: Combine substrings for two messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
  [PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
    Re: [PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx() Geert Uytterhoeven <geert@linux-m68k.org> - 2017-01-13 19:20 +0100
  [PATCH 12/17] spi/topcliff-pch: Improve size determinations in  pch_spi_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
  [PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
    Re: [PATCH 14/17] spi/topcliff-pch: Adjust six checks for null  pointers Dan Carpenter <dan.carpenter@oracle.com> - 2017-01-14 07:40 +0100
  [PATCH 16/17] spi/topcliff-pch: Delete an error message for a failed  memory allocation in pch_spi_set_tx() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
  [PATCH 13/17] spi/topcliff-pch: Delete an unnecessary return  statement in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
  [PATCH 15/17] spi/topcliff-pch: Combine substrings for four messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
  [PATCH 11/17] spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100

csiph-web