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:	Wed, 13 May 2015 13:24:15 -0700
From:	Brian Norris <computersforpeace@...il.com>
To:	Arnd Bergmann <arnd@...db.de>
Cc:	linux-mtd@...ts.infradead.org, Dmitry Torokhov <dtor@...gle.com>,
	Anatol Pomazao <anatol@...gle.com>,
	Ray Jui <rjui@...adcom.com>,
	Corneliu Doban <cdoban@...adcom.com>,
	Jonathan Richardson <jonathar@...adcom.com>,
	Scott Branden <sbranden@...adcom.com>,
	Florian Fainelli <f.fainelli@...il.com>,
	Rafał Miłecki <zajec5@...il.com>,
	bcm-kernel-feedback-list@...adcom.com,
	Dan Ehrenberg <dehrenberg@...omium.org>,
	Gregory Fong <gregory.0xf0@...il.com>,
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
	Kevin Cernekee <cernekee@...il.com>
Subject: Re: [PATCH v4 08/11] mtd: brcmnand: add BCM63138 support

On Wed, May 13, 2015 at 10:02:49PM +0200, Arnd Bergmann wrote:
> On Wednesday 13 May 2015 12:45:21 Brian Norris wrote:
> > I could still avoid one pointer chase and one extra memory allocation by
> > embedding 'struct brcmnand_soc' in a 'struct bcm63138_nand_soc'. e.g.:
> > 
> > struct bcm63138_nand_soc {
> > 	void __iomem *base;
> > 	struct brcmnand_soc soc;
> > };
> > 
> > static bool bcm63138_nand_intc_ack(struct brcmnand_soc *soc)
> > {
> > 	struct bcm63138_nand_soc *priv;
> > 	priv = container_of(soc, struct bcm63138_nand_soc, soc);
> > 
> > 	...
> > }
> > 
> > static int bcm63138_nand_probe(...)
> > {
> > 	struct bcm63138_nand_soc *priv;
> > 
> > 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> > 	...
> > 	return brcmnand_probe(pdev, &priv->soc);
> > }
> 
> That would make struct brcmnand_soc an empty structure, right?

No, it still contains the function pointers for our callbacks, which is
the entire point. I guess it's more of a 'nand_soc_ops' structure than a
'nand_soc' pointer now though.

> I think that's fine though, at least it avoids passing void pointers
> and it avoids one of the two allocations you do.
> 
> There is another variation of this model, which some drivers use:
> 
> static int bcm63138_nand_probe(...)
> {
> 	struct bcm63138_nand_soc *priv;
> 	struct brcmnand_controller *controller;
> 
> 	controller = brcmnand_controller_alloc(dev, sizeof (*priv));
> 
> 	priv = brcmnand_controller_priv(controller);
> 
> 	...
> 
> 	return brcmnand_register(controller);
> }
> 
> struct brcmnand_controller *brcmnand_controller_alloc(struct device *pdev, size_t extra)
> {
> 	struct brcmnand_controller *p = dev_kzalloc(dev, sizeof(*p) + extra);
> 
> 	...
> 
> 	return p;
> }
> 
> void *brcmnand_controller_priv(brcmnand_controller *p)
> {
> 	/* extra data follows at the next byte after the controller structure */
> 	return p + 1;
> }

Ah, so this allows the driver to still be agnostic about the contents of
brcmnand_controller.

> Some subsystem maintainers prefer this model over the other one, up to you.

I'll probably stick with mine. But thanks for the suggestion. I'll keep
it in mind. I was actually thinking of imitating this model for other
larger portions of drivers/mtd/nand/, to aid in bounding what drivers
are expected to do vs. allowing the core subsystem to handle things.

Brian
--
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