Skip to contentSkip to conversation

mmc: mmc_spi: Convert 'multiple' to be boolean in mmc_spi_data_do()

PATCH In review Andy Shevchenko 2 participants 4 messages Dec 6, 2021 – Dec 9, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mmc: mmc_spi: Convert 'multiple' to be boolean in mmc_spi_data_do()

Convert 'multiple' to be boolean in mmc_spi_data_do() since it's initially being used as boolean.

---
 drivers/mmc/host/mmc_spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/mmc_spi.c +2 -2
index b431cdd27353..4b0f9035ad29 100644
@@ -547,7 +547,7 @@ mmc_spi_command_send(struct mmc_spi_host *host,
 static void
 mmc_spi_setup_data_message(
 	struct mmc_spi_host	*host,
-	int			multiple,
+	bool			multiple,
 	enum dma_data_direction	direction)
 {
 	struct spi_transfer	*t;
@@ -862,7 +862,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
 	enum dma_data_direction	direction;
 	struct scatterlist	*sg;
 	unsigned		n_sg;
-	int			multiple = (data->blocks > 1);
+	bool			multiple = (data->blocks > 1);
 	u32			clock_rate;
 	unsigned long		timeout;
 
Signature · 1 line
2.33.0
#1 lore raw

PATCH 2/2 mmc: mmc_spi: Use write_or_read temporary variable in mmc_spi_data_do()

Use write_or_read temporary variable in mmc_spi_data_do() to deduplicate the conditional code.

---
 drivers/mmc/host/mmc_spi.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/mmc/host/mmc_spi.c +4 -8
index 4b0f9035ad29..a576181e9db0 100644
@@ -859,14 +859,14 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
 	struct spi_device	*spi = host->spi;
 	struct device		*dma_dev = host->dma_dev;
 	struct spi_transfer	*t;
-	enum dma_data_direction	direction;
+	enum dma_data_direction	direction = mmc_get_dma_dir(data);
 	struct scatterlist	*sg;
 	unsigned		n_sg;
 	bool			multiple = (data->blocks > 1);
+	const char		*write_or_read = (direction == DMA_TO_DEVICE) ? "write" : "read";
 	u32			clock_rate;
 	unsigned long		timeout;
 
-	direction = mmc_get_dma_dir(data);
 	mmc_spi_setup_data_message(host, multiple, direction);
 	t = &host->t;
 
@@ -921,9 +921,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
 		while (length) {
 			t->len = min(length, blk_size);
 
-			dev_dbg(&host->spi->dev, "    %s block, %d bytes\n",
-				(direction == DMA_TO_DEVICE) ? "write" : "read",
-				t->len);
+			dev_dbg(&spi->dev, "    %s block, %d bytes\n", write_or_read, t->len);
 
 			if (direction == DMA_TO_DEVICE)
 				status = mmc_spi_writeblock(host, t, timeout);
@@ -948,9 +946,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
 
 		if (status < 0) {
 			data->error = status;
-			dev_dbg(&spi->dev, "%s status %d\n",
-				(direction == DMA_TO_DEVICE) ? "write" : "read",
-				status);
+			dev_dbg(&spi->dev, "%s status %d\n", write_or_read, status);
 			break;
 		}
 	}
Signature · 1 line
2.33.0
#2 lore raw

Re: [PATCH v1 2/2] mmc: mmc_spi: Use write_or_read temporary variable in mmc_spi_data_do()

Quoted 5 lines · Andy Shevchenko

Use write_or_read temporary variable in mmc_spi_data_do() to deduplicate the conditional code.

Applied for next, thanks!

Kind regards
Uffe

Quoted 50 lines
---
 drivers/mmc/host/mmc_spi.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/mmc/host/mmc_spi.c +4 -9
index 4b0f9035ad29..a576181e9db0 100644
@@ -859,14 +859,14 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
        struct spi_device       *spi = host->spi;
        struct device           *dma_dev = host->dma_dev;
        struct spi_transfer     *t;
-       enum dma_data_direction direction;
+       enum dma_data_direction direction = mmc_get_dma_dir(data);
        struct scatterlist      *sg;
        unsigned                n_sg;
        bool                    multiple = (data->blocks > 1);
+       const char              *write_or_read = (direction == DMA_TO_DEVICE) ? "write" : "read";
        u32                     clock_rate;
        unsigned long           timeout;
 
-       direction = mmc_get_dma_dir(data);
        mmc_spi_setup_data_message(host, multiple, direction);
        t = &host->t;
 
@@ -921,9 +921,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
                while (length) {
                        t->len = min(length, blk_size);
 
-                       dev_dbg(&host->spi->dev, "    %s block, %d bytes\n",
-                               (direction == DMA_TO_DEVICE) ? "write" : "read",
-                               t->len);
+                       dev_dbg(&spi->dev, "    %s block, %d bytes\n", write_or_read, t->len);
 
                        if (direction == DMA_TO_DEVICE)
                                status = mmc_spi_writeblock(host, t, timeout);
@@ -948,9 +946,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
 
                if (status < 0) {
                        data->error = status;
-                       dev_dbg(&spi->dev, "%s status %d\n",
-                               (direction == DMA_TO_DEVICE) ? "write" : "read",
-                               status);
+                       dev_dbg(&spi->dev, "%s status %d\n", write_or_read, status);
                        break;
                }
        }
--

2.33.0

#3 lore raw
In reply to Andy Shevchenko
Quoted 5 lines · Andy Shevchenko

Convert 'multiple' to be boolean in mmc_spi_data_do() since it's initially being used as boolean.

Applied for next, thanks!

Kind regards
Uffe

Quoted 29 lines
---
 drivers/mmc/host/mmc_spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/mmc_spi.c +2 -3
index b431cdd27353..4b0f9035ad29 100644
@@ -547,7 +547,7 @@ mmc_spi_command_send(struct mmc_spi_host *host,
 static void
 mmc_spi_setup_data_message(
        struct mmc_spi_host     *host,
-       int                     multiple,
+       bool                    multiple,
        enum dma_data_direction direction)
 {
        struct spi_transfer     *t;
@@ -862,7 +862,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
        enum dma_data_direction direction;
        struct scatterlist      *sg;
        unsigned                n_sg;
-       int                     multiple = (data->blocks > 1);
+       bool                    multiple = (data->blocks > 1);
        u32                     clock_rate;
        unsigned long           timeout;
 
--

2.33.0