[v2] misc: cxl: Use device_type helpers to access the node type

Message ID 20181205191655.14612-1-robh@kernel.org
State New
Headers show
Series
  • [v2] misc: cxl: Use device_type helpers to access the node type
Related show

Commit Message

Rob Herring Dec. 5, 2018, 7:16 p.m.
Remove directly accessing device_type property and use the
of_node_is_type accessor instead. While not using it here, this is
part of eventually removing the struct device_node.type pointer.

Cc: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxppc-dev@lists.ozlabs.org
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

Signed-off-by: Rob Herring <robh@kernel.org>

---
v2:
- Reword commit message as this change was using the .type ptr.

 drivers/misc/cxl/pci.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

-- 
2.19.1

Comments

Frederic Barrat Dec. 6, 2018, 3:36 p.m. | #1
Le 05/12/2018 à 20:16, Rob Herring a écrit :
> Remove directly accessing device_type property and use the

> of_node_is_type accessor instead. While not using it here, this is

> part of eventually removing the struct device_node.type pointer.

> 

> Cc: Frederic Barrat <fbarrat@linux.vnet.ibm.com>

> Cc: Arnd Bergmann <arnd@arndb.de>

> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

> Cc: linuxppc-dev@lists.ozlabs.org

> Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

> Signed-off-by: Rob Herring <robh@kernel.org>

> ---

> v2:

> - Reword commit message as this change was using the .type ptr.


Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>



> 

>   drivers/misc/cxl/pci.c | 4 +---

>   1 file changed, 1 insertion(+), 3 deletions(-)

> 

> diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c

> index b66d832d3233..c79ba1c699ad 100644

> --- a/drivers/misc/cxl/pci.c

> +++ b/drivers/misc/cxl/pci.c

> @@ -1718,7 +1718,6 @@ int cxl_slot_is_switched(struct pci_dev *dev)

>   {

>   	struct device_node *np;

>   	int depth = 0;

> -	const __be32 *prop;

> 

>   	if (!(np = pci_device_to_OF_node(dev))) {

>   		pr_err("cxl: np = NULL\n");

> @@ -1727,8 +1726,7 @@ int cxl_slot_is_switched(struct pci_dev *dev)

>   	of_node_get(np);

>   	while (np) {

>   		np = of_get_next_parent(np);

> -		prop = of_get_property(np, "device_type", NULL);

> -		if (!prop || strcmp((char *)prop, "pciex"))

> +		if (!of_node_is_type(np, "pciex"))

>   			break;

>   		depth++;

>   	}

>
Michael Ellerman Dec. 10, 2018, 5:38 a.m. | #2
Rob Herring <robh@kernel.org> writes:

> Remove directly accessing device_type property and use the

> of_node_is_type accessor instead. While not using it here, this is

> part of eventually removing the struct device_node.type pointer.

>

> Cc: Frederic Barrat <fbarrat@linux.vnet.ibm.com>

> Cc: Arnd Bergmann <arnd@arndb.de>

> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

> Cc: linuxppc-dev@lists.ozlabs.org

> Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

> Signed-off-by: Rob Herring <robh@kernel.org>

> ---

> v2:

> - Reword commit message as this change was using the .type ptr.


I already have v1 in my next.

cheers

> diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c

> index b66d832d3233..c79ba1c699ad 100644

> --- a/drivers/misc/cxl/pci.c

> +++ b/drivers/misc/cxl/pci.c

> @@ -1718,7 +1718,6 @@ int cxl_slot_is_switched(struct pci_dev *dev)

>  {

>  	struct device_node *np;

>  	int depth = 0;

> -	const __be32 *prop;

>  

>  	if (!(np = pci_device_to_OF_node(dev))) {

>  		pr_err("cxl: np = NULL\n");

> @@ -1727,8 +1726,7 @@ int cxl_slot_is_switched(struct pci_dev *dev)

>  	of_node_get(np);

>  	while (np) {

>  		np = of_get_next_parent(np);

> -		prop = of_get_property(np, "device_type", NULL);

> -		if (!prop || strcmp((char *)prop, "pciex"))

> +		if (!of_node_is_type(np, "pciex"))

>  			break;

>  		depth++;

>  	}

> -- 

> 2.19.1

Patch

diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index b66d832d3233..c79ba1c699ad 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -1718,7 +1718,6 @@  int cxl_slot_is_switched(struct pci_dev *dev)
 {
 	struct device_node *np;
 	int depth = 0;
-	const __be32 *prop;
 
 	if (!(np = pci_device_to_OF_node(dev))) {
 		pr_err("cxl: np = NULL\n");
@@ -1727,8 +1726,7 @@  int cxl_slot_is_switched(struct pci_dev *dev)
 	of_node_get(np);
 	while (np) {
 		np = of_get_next_parent(np);
-		prop = of_get_property(np, "device_type", NULL);
-		if (!prop || strcmp((char *)prop, "pciex"))
+		if (!of_node_is_type(np, "pciex"))
 			break;
 		depth++;
 	}