* [PATCH 1/1] device property: Add fwnode_name_eq()
@ 2023-10-31 13:53 Sakari Ailus
2023-10-31 16:32 ` Andy Shevchenko
2023-10-31 21:49 ` kernel test robot
0 siblings, 2 replies; 4+ messages in thread
From: Sakari Ailus @ 2023-10-31 13:53 UTC (permalink / raw)
To: Laurent Pinchart, linux-acpi
Cc: Andy Shevchenko, linux-media, Paul Elder, Hans Verkuil,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Julien Stephan, devicetree,
linux-mediatek
Add fwnode_name_eq() to implement the functionality of of_node_name_eq()
on fwnode property API. The same convention of ending the comparison at
'@' (besides '\0') is applied on also both ACPI and swnode. The function
is intended for comparing unit address-less node names on DT and firmware
or swnodes compliant with DT bindings.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
Hi Laurent,
Would you be able to use this to replace of_node_name_eq()?
It's fully untested.
I didn't add an op for it as it rather looks like all the implentations
would be the same (but with different container struct).
drivers/base/property.c | 28 ++++++++++++++++++++++++++++
include/linux/property.h | 1 +
2 files changed, 29 insertions(+)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 8c40abed7852..766ac3fc8cc5 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -594,6 +594,34 @@ const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode)
return fwnode_call_ptr_op(fwnode, get_name_prefix);
}
+/**
+ * fwnode_name_eq - Return true if node name is equal
+ * @fwnode The firmware node
+ * @name: The name to which to compare the node name
+ *
+ * Compare the name provided as an argument to the name of the node, stopping
+ * the comparison to either '\0' or '@' character, whichever comes first. This
+ * function is generally used for comparing node names while ignoring the
+ * possible unit address of the node.
+ *
+ * Return: true if the node name matches with the name provided in the @name
+ * argument, false otherwise.
+ */
+bool fwnode_name_eq(const struct fwnode_handle *fwnode, const char *name)
+{
+ const char *node_name;
+ unsigned int len;
+
+ node_name = fwnode_get_name(fwnode);
+ if (!node_name)
+ return false;
+
+ len = strchrnul(node_name, '@') - node_name;
+
+ return strlen(name) == len && !strncmp(node_name, name, len);
+}
+EXPORT_SYMBOL_GPL(fwnode_name_eq);
+
/**
* fwnode_get_parent - Return parent firwmare node
* @fwnode: Firmware whose parent is retrieved
diff --git a/include/linux/property.h b/include/linux/property.h
index 083a1f41364b..096ade186601 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -108,6 +108,7 @@ struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
const char *fwnode_get_name(const struct fwnode_handle *fwnode);
const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode);
+bool fwnode_name_eq(const struct fwnode_handle *fwnode, const char *name);
struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode);
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] device property: Add fwnode_name_eq()
2023-10-31 13:53 [PATCH 1/1] device property: Add fwnode_name_eq() Sakari Ailus
@ 2023-10-31 16:32 ` Andy Shevchenko
2023-10-31 17:19 ` Sakari Ailus
2023-10-31 21:49 ` kernel test robot
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2023-10-31 16:32 UTC (permalink / raw)
To: Sakari Ailus
Cc: Laurent Pinchart, linux-acpi, linux-media, Paul Elder,
Hans Verkuil, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Matthias Brugger, AngeloGioacchino Del Regno, Julien Stephan,
devicetree, linux-mediatek
On Tue, Oct 31, 2023 at 03:53:06PM +0200, Sakari Ailus wrote:
> Add fwnode_name_eq() to implement the functionality of of_node_name_eq()
> on fwnode property API. The same convention of ending the comparison at
> '@' (besides '\0') is applied on also both ACPI and swnode. The function
> is intended for comparing unit address-less node names on DT and firmware
> or swnodes compliant with DT bindings.
Some comments below.
...
> Would you be able to use this to replace of_node_name_eq()?
Can you point out to the use case? Maybe it can be rewritten using existing
APIs?
...
> + len = strchrnul(node_name, '@') - node_name;
> + return strlen(name) == len && !strncmp(node_name, name, len);
Seems like this is reimplementation of str_has_prefix().
len = strchrnul(node_name, '@') - node_name;
return str_has_prefix(node_name, name) == len;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] device property: Add fwnode_name_eq()
2023-10-31 16:32 ` Andy Shevchenko
@ 2023-10-31 17:19 ` Sakari Ailus
0 siblings, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2023-10-31 17:19 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Laurent Pinchart, linux-acpi, linux-media, Paul Elder,
Hans Verkuil, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Matthias Brugger, AngeloGioacchino Del Regno, Julien Stephan,
devicetree, linux-mediatek
Hi Andy,
On Tue, Oct 31, 2023 at 06:32:17PM +0200, Andy Shevchenko wrote:
> On Tue, Oct 31, 2023 at 03:53:06PM +0200, Sakari Ailus wrote:
> > Add fwnode_name_eq() to implement the functionality of of_node_name_eq()
> > on fwnode property API. The same convention of ending the comparison at
> > '@' (besides '\0') is applied on also both ACPI and swnode. The function
> > is intended for comparing unit address-less node names on DT and firmware
> > or swnodes compliant with DT bindings.
>
> Some comments below.
>
> ...
>
> > Would you be able to use this to replace of_node_name_eq()?
>
> Can you point out to the use case? Maybe it can be rewritten using existing
> APIs?
Parsing DT for THine THP7321 ISP:
<URL:https://lore.kernel.org/linux-media/20231030133247.11243-1-laurent.pinchart@ideasonboard.com/T/#t>.
The driver shouldn't be bothered with separating the node name from the
unit address (separated by '@').
>
> ...
>
> > + len = strchrnul(node_name, '@') - node_name;
>
> > + return strlen(name) == len && !strncmp(node_name, name, len);
>
> Seems like this is reimplementation of str_has_prefix().
>
> len = strchrnul(node_name, '@') - node_name;
> return str_has_prefix(node_name, name) == len;
I'll use this in v2.
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] device property: Add fwnode_name_eq()
2023-10-31 13:53 [PATCH 1/1] device property: Add fwnode_name_eq() Sakari Ailus
2023-10-31 16:32 ` Andy Shevchenko
@ 2023-10-31 21:49 ` kernel test robot
1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-10-31 21:49 UTC (permalink / raw)
To: Sakari Ailus, Laurent Pinchart, linux-acpi
Cc: oe-kbuild-all, Andy Shevchenko, linux-media, Paul Elder,
Hans Verkuil, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Matthias Brugger, AngeloGioacchino Del Regno, Julien Stephan,
devicetree, linux-mediatek
Hi Sakari,
kernel test robot noticed the following build warnings:
[auto build test WARNING on driver-core/driver-core-testing]
[also build test WARNING on driver-core/driver-core-next driver-core/driver-core-linus linus/master v6.6 next-20231031]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sakari-Ailus/device-property-Add-fwnode_name_eq/20231031-224454
base: driver-core/driver-core-testing
patch link: https://lore.kernel.org/r/20231031135306.1106640-1-sakari.ailus%40linux.intel.com
patch subject: [PATCH 1/1] device property: Add fwnode_name_eq()
config: sh-allnoconfig (https://download.01.org/0day-ci/archive/20231101/202311010542.1tRHV0in-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231101/202311010542.1tRHV0in-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311010542.1tRHV0in-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/base/property.c:611: warning: Function parameter or member 'fwnode' not described in 'fwnode_name_eq'
vim +611 drivers/base/property.c
596
597 /**
598 * fwnode_name_eq - Return true if node name is equal
599 * @fwnode The firmware node
600 * @name: The name to which to compare the node name
601 *
602 * Compare the name provided as an argument to the name of the node, stopping
603 * the comparison to either '\0' or '@' character, whichever comes first. This
604 * function is generally used for comparing node names while ignoring the
605 * possible unit address of the node.
606 *
607 * Return: true if the node name matches with the name provided in the @name
608 * argument, false otherwise.
609 */
610 bool fwnode_name_eq(const struct fwnode_handle *fwnode, const char *name)
> 611 {
612 const char *node_name;
613 unsigned int len;
614
615 node_name = fwnode_get_name(fwnode);
616 if (!node_name)
617 return false;
618
619 len = strchrnul(node_name, '@') - node_name;
620
621 return strlen(name) == len && !strncmp(node_name, name, len);
622 }
623 EXPORT_SYMBOL_GPL(fwnode_name_eq);
624
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-31 21:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-31 13:53 [PATCH 1/1] device property: Add fwnode_name_eq() Sakari Ailus
2023-10-31 16:32 ` Andy Shevchenko
2023-10-31 17:19 ` Sakari Ailus
2023-10-31 21:49 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox