2021-11-06 22:51:29

by Puranjay Mohan

[permalink] [raw]
Subject: [PATCH 0/1] device property: Adding fwnode_irq_get_by_name()

While working on an IIO driver I was told to use of_irq_get_byname() as
the generic version is not available in property.c.
I wish to work on this and have written a function that may work.
I am not sure about its correctness so I am posting this patch early for
review.

Puranjay Mohan (1):
device property: Add fwnode_irq_get_by_name

drivers/base/property.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

--
2.30.1


2021-11-06 23:21:51

by Puranjay Mohan

[permalink] [raw]
Subject: [PATCH 1/1] device property: Add fwnode_irq_get_by_name

The fwnode framework did not have means to obtain the IRQ number from
the name of a node.
Add that now, in form of the fwnode_irq_get_by_name() function.

Signed-off-by: Puranjay Mohan <[email protected]>
---
drivers/base/property.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index f1f35b48ab8b..627e4e6d3ebd 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -958,6 +958,30 @@ int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)
}
EXPORT_SYMBOL(fwnode_irq_get);

+/**
+ * fwnode_irq_get_by_name - Get IRQ directly from its name.
+ * @fwnode: Pointer to the firmware node
+ * @name: IRQ Name
+ *
+ * Returns Linux IRQ number on success. Other values are determined
+ * accordingly to acpi_/of_ irq_get() operation.
+ */
+int fwnode_irq_get_by_name(const struct fwnode_handle *fwnode, const char *name)
+{
+ int index;
+
+ if (unlikely(!name))
+ return -EINVAL;
+
+ index = of_property_match_string(to_of_node(fwnode), "interrupt-names",
+ name);
+ if (index < 0)
+ return index;
+
+ return fwnode_irq_get(fwnode, index);
+}
+EXPORT_SYMBOL(fwnode_irq_get_by_name);
+
/**
* fwnode_graph_get_next_endpoint - Get next endpoint firmware node
* @fwnode: Pointer to the parent firmware node
--
2.30.1

2021-11-07 13:54:16

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/1] device property: Add fwnode_irq_get_by_name

Hi Puranjay,

I love your patch! Perhaps something to improve:

[auto build test WARNING on driver-core/driver-core-testing]
[also build test WARNING on v5.15 next-20211106]
[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]

url: https://github.com/0day-ci/linux/commits/Puranjay-Mohan/device-property-Adding-fwnode_irq_get_by_name/20211107-014150
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git 27e0bcd02990f7291adb0f111e300f06c495d509
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 11.2.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/0day-ci/linux/commit/b3dc64f4a6e40482f1d4313e5cb664a60cf5eb13
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Puranjay-Mohan/device-property-Adding-fwnode_irq_get_by_name/20211107-014150
git checkout b3dc64f4a6e40482f1d4313e5cb664a60cf5eb13
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=ia64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> drivers/base/property.c:1032:5: warning: no previous prototype for 'fwnode_irq_get_by_name' [-Wmissing-prototypes]
1032 | int fwnode_irq_get_by_name(const struct fwnode_handle *fwnode, const char *name)
| ^~~~~~~~~~~~~~~~~~~~~~


vim +/fwnode_irq_get_by_name +1032 drivers/base/property.c

1023
1024 /**
1025 * fwnode_irq_get_by_name - Get IRQ directly from its name.
1026 * @fwnode: Pointer to the firmware node
1027 * @name: IRQ Name
1028 *
1029 * Returns Linux IRQ number on success. Other values are determined
1030 * accordingly to acpi_/of_ irq_get() operation.
1031 */
> 1032 int fwnode_irq_get_by_name(const struct fwnode_handle *fwnode, const char *name)
1033 {
1034 int index;
1035
1036 if (unlikely(!name))
1037 return -EINVAL;
1038
1039 index = of_property_match_string(to_of_node(fwnode), "interrupt-names",
1040 name);
1041 if (index < 0)
1042 return index;
1043
1044 return fwnode_irq_get(fwnode, index);
1045 }
1046 EXPORT_SYMBOL(fwnode_irq_get_by_name);
1047

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (2.69 kB)
.config.gz (19.49 kB)
Download all attachments

2021-11-07 16:31:09

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 0/1] device property: Adding fwnode_irq_get_by_name()

On Sat, Nov 06, 2021 at 11:09:08PM +0530, Puranjay Mohan wrote:
> While working on an IIO driver I was told to use of_irq_get_byname() as
> the generic version is not available in property.c.
> I wish to work on this and have written a function that may work.
> I am not sure about its correctness so I am posting this patch early for
> review.

Please test your code, and also provide a user for it. We can not take
new functions that no one uses as that usually means they do not work.

thanks,

greg k-h

2021-11-07 17:16:55

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/1] device property: Add fwnode_irq_get_by_name

Hi Puranjay,

I love your patch! Yet something to improve:

[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on v5.15 next-20211106]
[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]

url: https://github.com/0day-ci/linux/commits/Puranjay-Mohan/device-property-Adding-fwnode_irq_get_by_name/20211107-014150
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git 27e0bcd02990f7291adb0f111e300f06c495d509
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 11.2.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/0day-ci/linux/commit/b3dc64f4a6e40482f1d4313e5cb664a60cf5eb13
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Puranjay-Mohan/device-property-Adding-fwnode_irq_get_by_name/20211107-014150
git checkout b3dc64f4a6e40482f1d4313e5cb664a60cf5eb13
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arc

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/base/property.c:1032:5: error: no previous prototype for 'fwnode_irq_get_by_name' [-Werror=missing-prototypes]
1032 | int fwnode_irq_get_by_name(const struct fwnode_handle *fwnode, const char *name)
| ^~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors


vim +/fwnode_irq_get_by_name +1032 drivers/base/property.c

1023
1024 /**
1025 * fwnode_irq_get_by_name - Get IRQ directly from its name.
1026 * @fwnode: Pointer to the firmware node
1027 * @name: IRQ Name
1028 *
1029 * Returns Linux IRQ number on success. Other values are determined
1030 * accordingly to acpi_/of_ irq_get() operation.
1031 */
> 1032 int fwnode_irq_get_by_name(const struct fwnode_handle *fwnode, const char *name)
1033 {
1034 int index;
1035
1036 if (unlikely(!name))
1037 return -EINVAL;
1038
1039 index = of_property_match_string(to_of_node(fwnode), "interrupt-names",
1040 name);
1041 if (index < 0)
1042 return index;
1043
1044 return fwnode_irq_get(fwnode, index);
1045 }
1046 EXPORT_SYMBOL(fwnode_irq_get_by_name);
1047

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (2.73 kB)
.config.gz (67.86 kB)
Download all attachments

2021-11-09 22:53:31

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 0/1] device property: Adding fwnode_irq_get_by_name()

On Wed, Nov 10, 2021 at 01:00:26AM +0530, Puranjay Mohan wrote:
> On Sun, Nov 7, 2021 at 1:59 PM Greg KH <[email protected]> wrote:
> >
> > On Sat, Nov 06, 2021 at 11:09:08PM +0530, Puranjay Mohan wrote:
> > > While working on an IIO driver I was told to use of_irq_get_byname() as
> > > the generic version is not available in property.c.
> > > I wish to work on this and have written a function that may work.
> > > I am not sure about its correctness so I am posting this patch early for
> > > review.
> >
>
> Hi Greg,
>
> > Please test your code, and also provide a user for it. We can not take
> > new functions that no one uses as that usually means they do not work.
>
> Actually, I just wanted to get a review of this code before I test it.

No, please test your code first, before asking others to review it.

Do you want to spend your time reviewing code that the creator has not
even tested themselves?

thanks,

greg k-h

2021-11-09 23:09:34

by Puranjay Mohan

[permalink] [raw]
Subject: Re: [PATCH 0/1] device property: Adding fwnode_irq_get_by_name()

On Wed, Nov 10, 2021 at 1:15 AM Greg KH <[email protected]> wrote:
>
> On Wed, Nov 10, 2021 at 01:00:26AM +0530, Puranjay Mohan wrote:
> > On Sun, Nov 7, 2021 at 1:59 PM Greg KH <[email protected]> wrote:
> > >
> > > On Sat, Nov 06, 2021 at 11:09:08PM +0530, Puranjay Mohan wrote:
> > > > While working on an IIO driver I was told to use of_irq_get_byname() as
> > > > the generic version is not available in property.c.
> > > > I wish to work on this and have written a function that may work.
> > > > I am not sure about its correctness so I am posting this patch early for
> > > > review.
> > >
> >
> > Hi Greg,
> >
> > > Please test your code, and also provide a user for it. We can not take
> > > new functions that no one uses as that usually means they do not work.
> >
> > Actually, I just wanted to get a review of this code before I test it.
>
> No, please test your code first, before asking others to review it.
>

Sorry for this inconvenience.
Actually, I have never worked on this part of the kernel before so I
was not sure if I was doing the right thing.
Now, I have tested it and sent a new version.

P.S - I won't send untested code again.

> Do you want to spend your time reviewing code that the creator has not
> even tested themselves?
>
> thanks,
>
> greg k-h

Thanks,
Puranjay Mohan

2021-11-10 00:14:47

by Puranjay Mohan

[permalink] [raw]
Subject: Re: [PATCH 0/1] device property: Adding fwnode_irq_get_by_name()

On Sun, Nov 7, 2021 at 1:59 PM Greg KH <[email protected]> wrote:
>
> On Sat, Nov 06, 2021 at 11:09:08PM +0530, Puranjay Mohan wrote:
> > While working on an IIO driver I was told to use of_irq_get_byname() as
> > the generic version is not available in property.c.
> > I wish to work on this and have written a function that may work.
> > I am not sure about its correctness so I am posting this patch early for
> > review.
>

Hi Greg,

> Please test your code, and also provide a user for it. We can not take
> new functions that no one uses as that usually means they do not work.

Actually, I just wanted to get a review of this code before I test it.
Now, I have made a few changes and tested it using an IIO driver on a
raspberry pi and the sensor.
I will be posting a v2 that also includes a user of this function.

>
> thanks,
>
> greg k-h




Thanks,
Puranjay Mohan