mmc: atmel-mci: simplify if-if to if-else
PATCH 1/1 mmc: atmel-mci: simplify if-if to if-else
Use if and else instead of if(A) and if (!A).
--- drivers/mmc/host/atmel-mci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/host/atmel-mci.c +1 -2
@@ -1125,8 +1125,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) chan = host->dma.chan;if (chan) host->data_chan = chan; - -if (!chan) +else return -ENODEV ;if (data->flags &MMC_DATA_READ ) {
Signature · 1 line
2.35.1
Quoted 13 lines · Wan Jiabing
Use if and else instead of if(A) and if (!A).
Signed-off-by Wan Jiabing <[email protected]>--- drivers/mmc/host/atmel-mci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/mmc/host/atmel-mci.c +0
-0
drivers/mmc/host/atmel-mci.c atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) · line 1129
Quoted 7 lines
drivers/mmc/host/atmel-mci.c +1
-2@@ -1125,8 +1125,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) chan = host->dma.chan;if (chan) host->data_chan = chan; - -if (!chan) +else return -ENODEV ;
To make a slightly better improvement of the code, I suggest we add an early bail out point in the atmci_prepare_data_dma() function. Like below:
if (!host->dma.chan)
return -ENODEV;
[...]
Kind regards
Uffe
Quoted 26 lines · Ulf Hansson
Quoted 13 lines · Wan Jiabing
Use if and else instead of if(A) and if (!A).
Signed-off-by Wan Jiabing <[email protected]>--- drivers/mmc/host/atmel-mci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/mmc/host/atmel-mci.c +0
-0drivers/mmc/host/atmel-mci.c atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) · line 1129
Quoted 7 lines
drivers/mmc/host/atmel-mci.c +1
-2@@ -1125,8 +1125,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) chan = host->dma.chan;if (chan) host->data_chan = chan; - -if (!chan) +else return -ENODEV ;To make a slightly better improvement of the code, I suggest we add an early bail out point in the
atmci_prepare_data_dma()function. Like below:
Quoted 7 lines
if (!host->dma.chan)
return -ENODEV;[...]
Kind regards
Uffe
OK
How about this new patch?
Thanks,
Wan Jiabing
From ce6f779033c9a8aa2489f59c860bb2a49a67c278 Mon Sep 17 00:00:00 2001
From: Wan Jiabing <[email protected]>
Date: Tue, 26 Apr 2022 23:01:18 +0800
Subject: [PATCH] mmc: atmel-mci: Simplify if(chan) and if(!chan)
Use if(!host->dma.chan) instead of if(chan) and if(!chan) to make code better.
--- drivers/mmc/host/atmel-mci.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/mmc/host/atmel-mci.c +4 -5
@@ -1122,13 +1122,12 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) }/* If we don't have a channel, we can't do DMA */ - chan = host->dma.chan; -if (chan) - host->data_chan = chan; - -if (!chan) +if (!host->dma.chan)return -ENODEV ; + chan = host->dma.chan; + host->data_chan = chan; +if (data->flags &MMC_DATA_READ ) { host->dma_conf.direction = slave_dirn =DMA_DEV_TO_MEM ; maxburst = atmci_convert_chksize(host,
Signature · 1 line
2.35.3
Quoted 31 lines · Wan Jiabing
Quoted 29 lines · Ulf Hansson
Quoted 13 lines · Wan Jiabing
Use if and else instead of if(A) and if (!A).
Signed-off-by Wan Jiabing <[email protected]>--- drivers/mmc/host/atmel-mci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/mmc/host/atmel-mci.c +0
-0drivers/mmc/host/atmel-mci.c atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) · line 1129
Quoted 7 lines
drivers/mmc/host/atmel-mci.c +1
-2@@ -1125,8 +1125,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) chan = host->dma.chan;if (chan) host->data_chan = chan; - -if (!chan) +else return -ENODEV ;To make a slightly better improvement of the code, I suggest we add an early bail out point in the
atmci_prepare_data_dma()function. Like below:if (!host->dma.chan)
return -ENODEV;
Quoted 8 lines
Quoted 4 lines
[...]
Kind regards
UffeOK
How about this new patch?
Please post a new version in plain text, not as an attachment.
Kind regards
Uffe