Skip to contentSkip to conversation

ata: pata_macio: Use of_property_present() helper

PATCH In review Yang Li 3 participants 3 messages Feb 21, 2023 libata

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 ata: pata_macio: Use of_property_present() helper

Use of_property_present() instead of of_get_property/of_find_property() in places where we just need to test presence of a property.

---
 drivers/ata/pata_macio.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/ata/pata_macio.c +3 -4
index 9ccaac9e2bc3..f698d77e87e1 100644
@@ -479,10 +479,9 @@ static int pata_macio_cable_detect(struct ata_port *ap)
 	    priv->kind == controller_un_ata6 ||
 	    priv->kind == controller_k2_ata6 ||
 	    priv->kind == controller_sh_ata6) {
-		const char* cable = of_get_property(priv->node, "cable-type",
-						    NULL);
+		const char *cable = of_property_present(priv->node, "cable-type");
 		struct device_node *root = of_find_node_by_path("/");
-		const char *model = of_get_property(root, "model", NULL);
+		const char *model = of_property_present(root, "model");
 
 		of_node_put(root);
 
@@ -973,7 +972,7 @@ static void pata_macio_invariants(struct pata_macio_priv *priv)
 	/* XXX FIXME --- setup priv->mediabay here */
 
 	/* Get Apple bus ID (for clock and ASIC control) */
-	bidp = of_get_property(priv->node, "AAPL,bus-id", NULL);
+	bidp = of_property_present(priv->node, "AAPL,bus-id");
 	priv->aapl_bus_id =  bidp ? *bidp : 0;
 
 	/* Fixup missing Apple bus ID in case of media-bay */
Signature · 1 line
2.20.1.7.g153144c
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi Yang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20230220]

url:    https://github.com/intel-lab-lkp/linux/commits/Yang-Li/ata-pata_macio-Use-of_property_present-helper/20230221-103834
patch link:    https://lore.kernel.org/r/20230221023634.87925-1-yang.lee%40linux.alibaba.com
patch subject: [PATCH -next] ata: pata_macio: Use of_property_present() helper
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20230221/[email protected]/config)
compiler: powerpc-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/257ef88e819f378a5925cd9a44857f4591d860e9
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Yang-Li/ata-pata_macio-Use-of_property_present-helper/20230221-103834 git checkout 257ef88e819f378a5925cd9a44857f4591d860e9
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/ata/pata_macio.c: In function 'pata_macio_cable_detect':

>> drivers/ata/pata_macio.c:482:37: error: incompatible types when initializing type 'const char *' using type 'bool' {aka '_Bool'}
     482 |                 const char *cable = of_property_present(priv->node, "cable-type");
         |                                     ^~~~~~~~~~~~~~~~~~~
   drivers/ata/pata_macio.c:484:37: error: incompatible types when initializing type 'const char *' using type 'bool' {aka '_Bool'}
     484 |                 const char *model = of_property_present(root, "model");
         |                                     ^~~~~~~~~~~~~~~~~~~
   drivers/ata/pata_macio.c: In function 'pata_macio_invariants':
>> drivers/ata/pata_macio.c:975:16: error: incompatible types when assigning to type 'const int *' from type 'bool' {aka '_Bool'}
     975 |         bidp = of_property_present(priv->node, "AAPL,bus-id");
         |                ^~~~~~~~~~~~~~~~~~~

vim +482 drivers/ata/pata_macio.c

472
473 static int pata_macio_cable_detect(struct ata_port *ap)
474 {
475 struct pata_macio_priv *priv = ap->private_data;
476
477 /* Get cable type from device-tree */

   478		if (priv->kind == controller_kl_ata4 ||
   479		    priv->kind == controller_un_ata6 ||
   480		    priv->kind == controller_k2_ata6 ||
   481		    priv->kind == controller_sh_ata6) {
 > 482			const char *cable = of_property_present(priv->node, "cable-type");

483 struct device_node *root = of_find_node_by_path("/");
484 const char *model = of_property_present(root, "model");
485
486 of_node_put(root);
487
488 if (cable && !strncmp(cable, "80-", 3)) {
489 /* Some drives fail to detect 80c cable in PowerBook
490 * These machine use proprietary short IDE cable
491 * anyway
492 */
493 if (!strncmp(model, "PowerBook", 9))
494 return ATA_CBL_PATA40_SHORT;
495 else
496 return ATA_CBL_PATA80;
497 }
498 }
499
500 /* G5's seem to have incorrect cable type in device-tree.
501 * Let's assume they always have a 80 conductor cable, this seem to
502 * be always the case unless the user mucked around
503 */
504 if (of_device_is_compatible(priv->node, "K2-UATA") ||
505 of_device_is_compatible(priv->node, "shasta-ata"))
506 return ATA_CBL_PATA80;
507
508 /* Anything else is 40 connectors */
509 return ATA_CBL_PATA40;
510 }
511

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#2 lore raw
In reply to Yang Li

Hello!

Quoted 1 line · Yang Li

Use of_property_present() instead of of_get_property/of_find_property()

I'm not seeing of_property_present() anywhere (we have of_prperty_read_bool()
though)... what repo was this patch done against?

Quoted 12 lines

in places where we just need to test presence of a property.

---
 drivers/ata/pata_macio.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/ata/pata_macio.c +0 -0
index 9ccaac9e2bc3..f698d77e87e1 100644

drivers/ata/pata_macio.c static int pata_macio_cable_detect(struct ata_port *ap) · line 484

Quoted 9 lines
drivers/ata/pata_macio.c +2 -3
@@ -479,10 +479,9 @@ static int pata_macio_cable_detect(struct ata_port *ap)
 	    priv->kind == controller_un_ata6 ||
 	    priv->kind == controller_k2_ata6 ||
 	    priv->kind == controller_sh_ata6) {
-		const char* cable = of_get_property(priv->node, "cable-type",
-						    NULL);
+		const char *cable = of_property_present(priv->node, "cable-type");
 		struct device_node *root = of_find_node_by_path("/");
-		const char *model = of_get_property(root, "model", NULL);
+		const char *model = of_property_present(root, "model");

We use the values of these properties...

[...]

drivers/ata/pata_macio.c static void pata_macio_invariants(struct pata_macio_priv *priv) · line 975

Quoted 6 lines
drivers/ata/pata_macio.c +1 -1
@@ -973,7 +972,7 @@ static void pata_macio_invariants(struct pata_macio_priv *priv)
 	/* XXX FIXME --- setup priv->mediabay here */
 
 	/* Get Apple bus ID (for clock and ASIC control) */
-	bidp = of_get_property(priv->node, "AAPL,bus-id", NULL);
+	bidp = of_property_present(priv->node, "AAPL,bus-id");

And this one too...

[...]

MBR, Sergey