[PATCH] uio_pdrv_genirq: convert to use device_property APIs

Chris Packham posted 1 patch 1 year, 10 months ago
drivers/uio/uio_pdrv_genirq.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
[PATCH] uio_pdrv_genirq: convert to use device_property APIs
Posted by Chris Packham 1 year, 10 months ago
Convert the uio_pdrv_genirq driver to use the device_property_* APIs
instead of the of_property_* ones. This allows UIO interrupts to be
defined via an ACPI overlay using the Device Tree namespace linkage.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
 drivers/uio/uio_pdrv_genirq.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index 63258b6accc4..772ab42a3ba1 100644
--- a/drivers/uio/uio_pdrv_genirq.c
+++ b/drivers/uio/uio_pdrv_genirq.c
@@ -23,8 +23,8 @@
 #include <linux/irq.h>
 
 #include <linux/of.h>
-#include <linux/of_platform.h>
-#include <linux/of_address.h>
+#include <linux/mod_devicetable.h>
+#include <linux/property.h>
 
 #define DRIVER_NAME "uio_pdrv_genirq"
 
@@ -110,7 +110,7 @@ static void uio_pdrv_genirq_cleanup(void *data)
 static int uio_pdrv_genirq_probe(struct platform_device *pdev)
 {
 	struct uio_info *uioinfo = dev_get_platdata(&pdev->dev);
-	struct device_node *node = pdev->dev.of_node;
+	struct fwnode_handle *node = dev_fwnode(&pdev->dev);
 	struct uio_pdrv_genirq_platdata *priv;
 	struct uio_mem *uiomem;
 	int ret = -EINVAL;
@@ -127,11 +127,12 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
 			return -ENOMEM;
 		}
 
-		if (!of_property_read_string(node, "linux,uio-name", &name))
+
+		if (!device_property_read_string(&pdev->dev, "linux,uio-name", &name))
 			uioinfo->name = devm_kstrdup(&pdev->dev, name, GFP_KERNEL);
 		else
 			uioinfo->name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
-						       "%pOFn", node);
+						       "%pfwP", node);
 
 		uioinfo->version = "devicetree";
 		/* Multiple IRQs are not supported */
-- 
2.43.2
Re: [PATCH] uio_pdrv_genirq: convert to use device_property APIs
Posted by Chris Packham 1 year, 10 months ago
On 25/03/24 14:50, Chris Packham wrote:
> Convert the uio_pdrv_genirq driver to use the device_property_* APIs
> instead of the of_property_* ones. This allows UIO interrupts to be
> defined via an ACPI overlay using the Device Tree namespace linkage.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
>   drivers/uio/uio_pdrv_genirq.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
> index 63258b6accc4..772ab42a3ba1 100644
> --- a/drivers/uio/uio_pdrv_genirq.c
> +++ b/drivers/uio/uio_pdrv_genirq.c
> @@ -23,8 +23,8 @@
>   #include <linux/irq.h>
>   
>   #include <linux/of.h>
> -#include <linux/of_platform.h>
> -#include <linux/of_address.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/property.h>
>   
>   #define DRIVER_NAME "uio_pdrv_genirq"
>   
> @@ -110,7 +110,7 @@ static void uio_pdrv_genirq_cleanup(void *data)
>   static int uio_pdrv_genirq_probe(struct platform_device *pdev)
>   {
>   	struct uio_info *uioinfo = dev_get_platdata(&pdev->dev);
> -	struct device_node *node = pdev->dev.of_node;
> +	struct fwnode_handle *node = dev_fwnode(&pdev->dev);
>   	struct uio_pdrv_genirq_platdata *priv;
>   	struct uio_mem *uiomem;
>   	int ret = -EINVAL;
> @@ -127,11 +127,12 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
>   			return -ENOMEM;
>   		}
>   
> -		if (!of_property_read_string(node, "linux,uio-name", &name))
> +
Someone off-list pointed out the extra newline here. I'll fix that up in 
v2 (I'll wait a bit for any other comments before sending that out).
> +		if (!device_property_read_string(&pdev->dev, "linux,uio-name", &name))
>   			uioinfo->name = devm_kstrdup(&pdev->dev, name, GFP_KERNEL);
>   		else
>   			uioinfo->name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
> -						       "%pOFn", node);
> +						       "%pfwP", node);
>   
>   		uioinfo->version = "devicetree";
>   		/* Multiple IRQs are not supported */