Message ID | 20200226101842.29426-2-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [v1,1/4] dmaengine: Refactor dmaengine_check_align() to be bit operations only | expand |
Hi Andy, On 2/26/20 12:18 PM, Andy Shevchenko wrote: > When negative condition is in use we may decrease indentation level > and make the main part of logic better visible. It makes the code a bit nicer, I agree. Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > include/linux/dmaengine.h | 35 ++++++++++++++++++----------------- > 1 file changed, 18 insertions(+), 17 deletions(-) > > diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h > index 9f3f5582816a..ae56a91c2a05 100644 > --- a/include/linux/dmaengine.h > +++ b/include/linux/dmaengine.h > @@ -618,10 +618,11 @@ static inline void dmaengine_unmap_put(struct dmaengine_unmap_data *unmap) > > static inline void dma_descriptor_unmap(struct dma_async_tx_descriptor *tx) > { > - if (tx->unmap) { > - dmaengine_unmap_put(tx->unmap); > - tx->unmap = NULL; > - } > + if (!tx->unmap) > + return; > + > + dmaengine_unmap_put(tx->unmap); > + tx->unmap = NULL; > } > > #ifndef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH > @@ -1408,11 +1409,12 @@ static inline enum dma_status dma_async_is_complete(dma_cookie_t cookie, > static inline void > dma_set_tx_state(struct dma_tx_state *st, dma_cookie_t last, dma_cookie_t used, u32 residue) > { > - if (st) { > - st->last = last; > - st->used = used; > - st->residue = residue; > - } > + if (!st) > + return; > + > + st->last = last; > + st->used = used; > + st->residue = residue; > } > > #ifdef CONFIG_DMA_ENGINE > @@ -1489,12 +1491,11 @@ static inline int dmaengine_desc_set_reuse(struct dma_async_tx_descriptor *tx) > if (ret) > return ret; > > - if (caps.descriptor_reuse) { > - tx->flags |= DMA_CTRL_REUSE; > - return 0; > - } else { > + if (!caps.descriptor_reuse) > return -EPERM; > - } > + > + tx->flags |= DMA_CTRL_REUSE; > + return 0; > } > > static inline void dmaengine_desc_clear_reuse(struct dma_async_tx_descriptor *tx) > @@ -1510,10 +1511,10 @@ static inline bool dmaengine_desc_test_reuse(struct dma_async_tx_descriptor *tx) > static inline int dmaengine_desc_free(struct dma_async_tx_descriptor *desc) > { > /* this is supported for reusable desc, so check that */ > - if (dmaengine_desc_test_reuse(desc)) > - return desc->desc_free(desc); > - else > + if (!dmaengine_desc_test_reuse(desc)) > return -EPERM; > + > + return desc->desc_free(desc); > } > > /* --- DMA device --- */ > - Péter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 9f3f5582816a..ae56a91c2a05 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -618,10 +618,11 @@ static inline void dmaengine_unmap_put(struct dmaengine_unmap_data *unmap) static inline void dma_descriptor_unmap(struct dma_async_tx_descriptor *tx) { - if (tx->unmap) { - dmaengine_unmap_put(tx->unmap); - tx->unmap = NULL; - } + if (!tx->unmap) + return; + + dmaengine_unmap_put(tx->unmap); + tx->unmap = NULL; } #ifndef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH @@ -1408,11 +1409,12 @@ static inline enum dma_status dma_async_is_complete(dma_cookie_t cookie, static inline void dma_set_tx_state(struct dma_tx_state *st, dma_cookie_t last, dma_cookie_t used, u32 residue) { - if (st) { - st->last = last; - st->used = used; - st->residue = residue; - } + if (!st) + return; + + st->last = last; + st->used = used; + st->residue = residue; } #ifdef CONFIG_DMA_ENGINE @@ -1489,12 +1491,11 @@ static inline int dmaengine_desc_set_reuse(struct dma_async_tx_descriptor *tx) if (ret) return ret; - if (caps.descriptor_reuse) { - tx->flags |= DMA_CTRL_REUSE; - return 0; - } else { + if (!caps.descriptor_reuse) return -EPERM; - } + + tx->flags |= DMA_CTRL_REUSE; + return 0; } static inline void dmaengine_desc_clear_reuse(struct dma_async_tx_descriptor *tx) @@ -1510,10 +1511,10 @@ static inline bool dmaengine_desc_test_reuse(struct dma_async_tx_descriptor *tx) static inline int dmaengine_desc_free(struct dma_async_tx_descriptor *desc) { /* this is supported for reusable desc, so check that */ - if (dmaengine_desc_test_reuse(desc)) - return desc->desc_free(desc); - else + if (!dmaengine_desc_test_reuse(desc)) return -EPERM; + + return desc->desc_free(desc); } /* --- DMA device --- */
When negative condition is in use we may decrease indentation level and make the main part of logic better visible. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- include/linux/dmaengine.h | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)