[2/4] dma-pool: Get rid of dma_in_atomic_pool()
diff mbox series

Message ID 20200709161903.26229-3-nsaenzjulienne@suse.de
State New, archived
Headers show
Series
  • dma-pool: Fix atomic pool selection
Related show

Commit Message

Nicolas Saenz Julienne July 9, 2020, 4:19 p.m. UTC
The function is only used once and can be simplified to a one-liner.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 kernel/dma/pool.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

Comments

David Rientjes July 9, 2020, 9:51 p.m. UTC | #1
On Thu, 9 Jul 2020, Nicolas Saenz Julienne wrote:

> The function is only used once and can be simplified to a one-liner.
> 
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

I'll leave this one to Christoph to decide on.  One thing I really liked 
about hacking around in kernel/dma is the coding style, it really follows 
"one function does one thing and does it well" even if there is only one 
caller.  dma_in_atomic_pool() was an attempt to follow in those footsteps.
Christoph Hellwig July 10, 2020, 6:50 a.m. UTC | #2
On Thu, Jul 09, 2020 at 02:51:13PM -0700, David Rientjes wrote:
> On Thu, 9 Jul 2020, Nicolas Saenz Julienne wrote:
> 
> > The function is only used once and can be simplified to a one-liner.
> > 
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> 
> I'll leave this one to Christoph to decide on.  One thing I really liked 
> about hacking around in kernel/dma is the coding style, it really follows 
> "one function does one thing and does it well" even if there is only one 
> caller.  dma_in_atomic_pool() was an attempt to follow in those footsteps.

While I like the helper aswell, I don't see how it could work nicely
with the changes in patch 4.

Patch
diff mbox series

diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
index 8cfa01243ed2..7363640fc91c 100644
--- a/kernel/dma/pool.c
+++ b/kernel/dma/pool.c
@@ -217,15 +217,6 @@  static inline struct gen_pool *dev_to_pool(struct device *dev)
 	return atomic_pool_kernel;
 }
 
-static bool dma_in_atomic_pool(struct device *dev, void *start, size_t size)
-{
-	struct gen_pool *pool = dev_to_pool(dev);
-
-	if (unlikely(!pool))
-		return false;
-	return gen_pool_has_addr(pool, (unsigned long)start, size);
-}
-
 void *dma_alloc_from_pool(struct device *dev, size_t size,
 			  struct page **ret_page, gfp_t flags)
 {
@@ -256,7 +247,7 @@  bool dma_free_from_pool(struct device *dev, void *start, size_t size)
 {
 	struct gen_pool *pool = dev_to_pool(dev);
 
-	if (!dma_in_atomic_pool(dev, start, size))
+	if (!pool || !gen_pool_has_addr(pool, (unsigned long)start, size))
 		return false;
 	gen_pool_free(pool, (unsigned long)start, size);
 	return true;