diff mbox

[v2,01/29] radix-tree: Introduce radix_tree_empty

Message ID 1460643410-30196-2-git-send-email-willy@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Matthew Wilcox April 14, 2016, 2:16 p.m. UTC
The irqdomain code was checking for 0 or 1 entries, not 0 entries like
the comment said they were.  Introduce a new helper that will actually
check for an empty tree.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
---
 include/linux/radix-tree.h | 5 +++++
 kernel/irq/irqdomain.c     | 7 +------
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Jan Kara May 3, 2016, 2:24 p.m. UTC | #1
On Thu 14-04-16 10:16:22, Matthew Wilcox wrote:
> The irqdomain code was checking for 0 or 1 entries, not 0 entries like
> the comment said they were.  Introduce a new helper that will actually
> check for an empty tree.
> 
> Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>

The patch looks good. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  include/linux/radix-tree.h | 5 +++++
>  kernel/irq/irqdomain.c     | 7 +------
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
> index 51a97ac..83f708e 100644
> --- a/include/linux/radix-tree.h
> +++ b/include/linux/radix-tree.h
> @@ -136,6 +136,11 @@ do {									\
>  	(root)->rnode = NULL;						\
>  } while (0)
>  
> +static inline bool radix_tree_empty(struct radix_tree_root *root)
> +{
> +	return root->rnode == NULL;
> +}
> +
>  /**
>   * Radix-tree synchronization
>   *
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 3a519a0..ba3f60d 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -139,12 +139,7 @@ void irq_domain_remove(struct irq_domain *domain)
>  {
>  	mutex_lock(&irq_domain_mutex);
>  
> -	/*
> -	 * radix_tree_delete() takes care of destroying the root
> -	 * node when all entries are removed. Shout if there are
> -	 * any mappings left.
> -	 */
> -	WARN_ON(domain->revmap_tree.height);
> +	WARN_ON(!radix_tree_empty(&domain->revmap_tree));
>  
>  	list_del(&domain->link);
>  
> -- 
> 2.8.0.rc3
> 
>
diff mbox

Patch

diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 51a97ac..83f708e 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -136,6 +136,11 @@  do {									\
 	(root)->rnode = NULL;						\
 } while (0)
 
+static inline bool radix_tree_empty(struct radix_tree_root *root)
+{
+	return root->rnode == NULL;
+}
+
 /**
  * Radix-tree synchronization
  *
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 3a519a0..ba3f60d 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -139,12 +139,7 @@  void irq_domain_remove(struct irq_domain *domain)
 {
 	mutex_lock(&irq_domain_mutex);
 
-	/*
-	 * radix_tree_delete() takes care of destroying the root
-	 * node when all entries are removed. Shout if there are
-	 * any mappings left.
-	 */
-	WARN_ON(domain->revmap_tree.height);
+	WARN_ON(!radix_tree_empty(&domain->revmap_tree));
 
 	list_del(&domain->link);