lkml.org 
[lkml]   [2022]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] mmc: atmel-mci: simplify if-if to if-else
On Tue, Apr 26, 2022 at 03:53:09PM +0200, Ulf Hansson wrote:
> On Sun, 24 Apr 2022 at 11:04, Wan Jiabing <wanjiabing@vivo.com> wrote:
> >
> > Use if and else instead of if(A) and if (!A).
> >
> > Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> > ---
> > drivers/mmc/host/atmel-mci.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> > index 807177c953f3..98893ccad4bd 100644
> > --- a/drivers/mmc/host/atmel-mci.c
> > +++ b/drivers/mmc/host/atmel-mci.c
> > @@ -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

OK

How about this new patch?

Thanks,
Wan Jiabing

From ce6f779033c9a8aa2489f59c860bb2a49a67c278 Mon Sep 17 00:00:00 2001
From: Wan Jiabing <wanjiabing@vivo.com>
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.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
drivers/mmc/host/atmel-mci.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 807177c953f3..91d52ba7a39f 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -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,
--
2.35.3
\
 
 \ /
  Last update: 2022-04-26 17:07    [W:0.070 / U:0.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site