lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 24 Oct 2023 12:19:49 +0300
From:   Vladimir Oltean <vladimir.oltean@....com>
To:     Rob Herring <robh@...nel.org>
Cc:     Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] irqchip/ls-scfg-msi: Use device_get_match_data()

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@...nel.org>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@....com>
Tested-by: Vladimir Oltean <vladimir.oltean@....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
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ