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]
Message-ID: <20130813091539.20d4b6a3@skate>
Date:	Tue, 13 Aug 2013 09:15:39 +0200
From:	Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>
To:	Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>
Cc:	Russell King <linux@....linux.org.uk>,
	Jason Cooper <jason@...edaemon.net>,
	Andrew Lunn <andrew@...n.ch>,
	Bjorn Helgaas <bhelgaas@...gle.com>,
	linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
	linux-pci@...r.kernel.org
Subject: Re: [PATCH 2/9] PCI: mvebu: increment nports only for registered
 ports

Dear Sebastian Hesselbarth,

On Mon, 12 Aug 2013 20:46:48 +0200, Sebastian Hesselbarth wrote:

> diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> index d5fe674..0a359d7 100644
> --- a/drivers/pci/host/pci-mvebu.c
> +++ b/drivers/pci/host/pci-mvebu.c
> @@ -842,21 +842,21 @@ static int __init mvebu_pcie_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> +	i = 0;
>  	for_each_child_of_node(pdev->dev.of_node, child) {
>  		if (!of_device_is_available(child))
>  			continue;
> -		pcie->nports++;
> +		i++;
>  	}
>  
> -	pcie->ports = devm_kzalloc(&pdev->dev, pcie->nports *
> +	pcie->ports = devm_kzalloc(&pdev->dev, i *
>  				   sizeof(struct mvebu_pcie_port),
>  				   GFP_KERNEL);
>  	if (!pcie->ports)
>  		return -ENOMEM;
>  
> -	i = 0;
>  	for_each_child_of_node(pdev->dev.of_node, child) {
> -		struct mvebu_pcie_port *port = &pcie->ports[i];
> +		struct mvebu_pcie_port *port = &pcie->ports[pcie->nports];
>  
>  		if (!of_device_is_available(child))
>  			continue;
> @@ -929,7 +929,7 @@ static int __init mvebu_pcie_probe(struct platform_device *pdev)
>  		port->dn = child;
>  		spin_lock_init(&port->conf_lock);
>  		mvebu_sw_pci_bridge_init(port);
> -		i++;
> +		pcie->nports++;
>  	}

I think I'd prefer using 'i' in this loop, and then after the loop have
a:

	pcie->nports = i;

assignment. That's nitpicking, but I don't like the fact that within
the loop 'pcie->nports' doesn't mean "Number of enabled PCIe ports",
but means "Last enabled PCIe port".

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ