* [PATCH v2] irqchip/ls-scfg-msi: Use device_get_match_data()
@ 2023-10-20 13:02 Rob Herring
2023-10-24 9:19 ` Vladimir Oltean
2023-10-27 7:23 ` [tip: irq/core] " tip-bot2 for Rob Herring
0 siblings, 2 replies; 3+ messages in thread
From: Rob Herring @ 2023-10-20 13:02 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel, Vladimir Oltean
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data in a single step without the unnecessary
intermediate match pointer. With this, adjust the includes to
explicitly include the correct headers. That also serves as
preparation to remove implicit includes within the DT headers.
of_platform.h currently includes platform_device.h among others.
Signed-off-by: Rob Herring <robh@kernel.org>
---
v2:
- Expand commit message
---
drivers/irqchip/irq-ls-scfg-msi.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c
index f31a262fe438..15cf80b46322 100644
--- a/drivers/irqchip/irq-ls-scfg-msi.c
+++ b/drivers/irqchip/irq-ls-scfg-msi.c
@@ -17,7 +17,8 @@
#include <linux/irqdomain.h>
#include <linux/of_irq.h>
#include <linux/of_pci.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/spinlock.h>
#define MSI_IRQS_PER_MSIR 32
@@ -334,20 +335,17 @@ MODULE_DEVICE_TABLE(of, ls_scfg_msi_id);
static int ls_scfg_msi_probe(struct platform_device *pdev)
{
- const struct of_device_id *match;
struct ls_scfg_msi *msi_data;
struct resource *res;
int i, ret;
- match = of_match_device(ls_scfg_msi_id, &pdev->dev);
- if (!match)
- return -ENODEV;
-
msi_data = devm_kzalloc(&pdev->dev, sizeof(*msi_data), GFP_KERNEL);
if (!msi_data)
return -ENOMEM;
- msi_data->cfg = (struct ls_scfg_msi_cfg *) match->data;
+ msi_data->cfg = (struct ls_scfg_msi_cfg *)device_get_match_data(&pdev->dev);
+ if (!msi_data->cfg)
+ return -ENODEV;
msi_data->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(msi_data->regs)) {
--
2.42.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] irqchip/ls-scfg-msi: Use device_get_match_data()
2023-10-20 13:02 [PATCH v2] irqchip/ls-scfg-msi: Use device_get_match_data() Rob Herring
@ 2023-10-24 9:19 ` Vladimir Oltean
2023-10-27 7:23 ` [tip: irq/core] " tip-bot2 for Rob Herring
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2023-10-24 9:19 UTC (permalink / raw)
To: Rob Herring; +Cc: Thomas Gleixner, linux-kernel
On Fri, Oct 20, 2023 at 08:02:56AM -0500, Rob Herring wrote:
> Use preferred device_get_match_data() instead of of_match_device() to
> get the driver match data in a single step without the unnecessary
> intermediate match pointer. With this, adjust the includes to
> explicitly include the correct headers. That also serves as
> preparation to remove implicit includes within the DT headers.
> of_platform.h currently includes platform_device.h among others.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> v2:
> - Expand commit message
> ---
> drivers/irqchip/irq-ls-scfg-msi.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c
> index f31a262fe438..15cf80b46322 100644
> --- a/drivers/irqchip/irq-ls-scfg-msi.c
> +++ b/drivers/irqchip/irq-ls-scfg-msi.c
> @@ -17,7 +17,8 @@
> #include <linux/irqdomain.h>
> #include <linux/of_irq.h>
> #include <linux/of_pci.h>
> -#include <linux/of_platform.h>
> +#include <linux/platform_device.h>
> +#include <linux/property.h>
> #include <linux/spinlock.h>
>
> #define MSI_IRQS_PER_MSIR 32
> @@ -334,20 +335,17 @@ MODULE_DEVICE_TABLE(of, ls_scfg_msi_id);
>
> static int ls_scfg_msi_probe(struct platform_device *pdev)
> {
> - const struct of_device_id *match;
> struct ls_scfg_msi *msi_data;
> struct resource *res;
> int i, ret;
>
> - match = of_match_device(ls_scfg_msi_id, &pdev->dev);
> - if (!match)
> - return -ENODEV;
> -
> msi_data = devm_kzalloc(&pdev->dev, sizeof(*msi_data), GFP_KERNEL);
> if (!msi_data)
> return -ENOMEM;
>
> - msi_data->cfg = (struct ls_scfg_msi_cfg *) match->data;
> + msi_data->cfg = (struct ls_scfg_msi_cfg *)device_get_match_data(&pdev->dev);
I wanted to suggest to drop the unnecessary cast of the void pointer.
But the driver keeps msi_data->cfg as a non-const pointer, and that
causes a warning that is otherwise suppressed by this cast. So eliminating
the type cast and keeping "cfg" as const is definitely a separate change.
> + if (!msi_data->cfg)
> + return -ENODEV;
>
> msi_data->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> if (IS_ERR(msi_data->regs)) {
> --
> 2.42.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread* [tip: irq/core] irqchip/ls-scfg-msi: Use device_get_match_data()
2023-10-20 13:02 [PATCH v2] irqchip/ls-scfg-msi: Use device_get_match_data() Rob Herring
2023-10-24 9:19 ` Vladimir Oltean
@ 2023-10-27 7:23 ` tip-bot2 for Rob Herring
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Rob Herring @ 2023-10-27 7:23 UTC (permalink / raw)
To: linux-tip-commits
Cc: Rob Herring, Thomas Gleixner, Vladimir Oltean, x86, linux-kernel, maz
The following commit has been merged into the irq/core branch of tip:
Commit-ID: 08d4c174828d868d314d2475fbcaa1393f0bbba9
Gitweb: https://git.kernel.org/tip/08d4c174828d868d314d2475fbcaa1393f0bbba9
Author: Rob Herring <robh@kernel.org>
AuthorDate: Fri, 20 Oct 2023 08:02:56 -05:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 27 Oct 2023 09:15:44 +02:00
irqchip/ls-scfg-msi: Use device_get_match_data()
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data in a single step without the unnecessary
intermediate match pointer.
With this, adjust the includes to explicitly include the correct
headers. That also serves as preparation to remove implicit includes within
the DT headers. of_platform.h currently includes platform_device.h among
others.
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20231020130255.2954415-3-robh@kernel.org
---
drivers/irqchip/irq-ls-scfg-msi.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c
index f31a262..15cf80b 100644
--- a/drivers/irqchip/irq-ls-scfg-msi.c
+++ b/drivers/irqchip/irq-ls-scfg-msi.c
@@ -17,7 +17,8 @@
#include <linux/irqdomain.h>
#include <linux/of_irq.h>
#include <linux/of_pci.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/spinlock.h>
#define MSI_IRQS_PER_MSIR 32
@@ -334,20 +335,17 @@ MODULE_DEVICE_TABLE(of, ls_scfg_msi_id);
static int ls_scfg_msi_probe(struct platform_device *pdev)
{
- const struct of_device_id *match;
struct ls_scfg_msi *msi_data;
struct resource *res;
int i, ret;
- match = of_match_device(ls_scfg_msi_id, &pdev->dev);
- if (!match)
- return -ENODEV;
-
msi_data = devm_kzalloc(&pdev->dev, sizeof(*msi_data), GFP_KERNEL);
if (!msi_data)
return -ENOMEM;
- msi_data->cfg = (struct ls_scfg_msi_cfg *) match->data;
+ msi_data->cfg = (struct ls_scfg_msi_cfg *)device_get_match_data(&pdev->dev);
+ if (!msi_data->cfg)
+ return -ENODEV;
msi_data->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(msi_data->regs)) {
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-27 7:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-20 13:02 [PATCH v2] irqchip/ls-scfg-msi: Use device_get_match_data() Rob Herring
2023-10-24 9:19 ` Vladimir Oltean
2023-10-27 7:23 ` [tip: irq/core] " tip-bot2 for Rob Herring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome