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, 14 Jun 2022 11:02:30 +0200
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     Sascha Hauer <sha@...gutronix.de>
Cc:     Rafał Miłecki <zajec5@...il.com>,
        Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
        Richard Weinberger <richard@....at>,
        Vignesh Raghavendra <vigneshr@...com>,
        Tom Rini <trini@...sulko.com>,
        Ahmad Fatoum <a.fatoum@...gutronix.de>,
        linux-arm-kernel@...ts.infradead.org, u-boot@...ts.denx.de,
        devicetree@...r.kernel.org, linux-mtd@...ts.infradead.org,
        linux-kernel@...r.kernel.org,
        Rafał Miłecki <rafal@...ecki.pl>
Subject: Re: [PATCH V3 2/2] nvmem: add driver handling U-Boot environment
 variables

Hello,

> > +static int u_boot_env_probe(struct platform_device *pdev)
> > +{
> > +	struct nvmem_config config = {
> > +		.name = "u-boot-env",
> > +		.reg_read = u_boot_env_read,
> > +	};
> > +	struct device *dev = &pdev->dev;
> > +	struct device_node *np = dev->of_node;
> > +	const struct of_device_id *of_id;
> > +	struct u_boot_env *priv;
> > +	int err;
> > +
> > +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> > +	if (!priv)
> > +		return -ENOMEM;
> > +	priv->dev = dev;
> > +
> > +	of_id = of_match_device(u_boot_env_of_match_table, dev);
> > +	if (!of_id)
> > +		return -EINVAL;
> > +	priv->format = (uintptr_t)of_id->data;
> > +
> > +	if (of_property_read_u32(np, "reg", (u32 *)&priv->offset) ||
> > +	    of_property_read_u32_index(np, "reg", 1, (u32 *)&priv->size)) {
> > +		dev_err(dev, "Failed to read \"reg\" property\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	priv->mtd = of_get_mtd_device_by_node(np->parent);
> > +	if (IS_ERR(priv->mtd)) {
> > +		dev_err(dev, "Failed to get %pOF MTD: %ld\n", np->parent, PTR_ERR(priv->mtd));
> > +		return PTR_ERR(priv->mtd);
> > +	}  
> 
> Partitions are mtd devices themselves and the mtd layer directly
> associates these devices to their OF node, so it should be possible
> to do a of_get_mtd_device_by_node(np) which gets you the partition.
> You can use the whole mtd device then and do not have to fiddle with
> reg properties, offsets and sizes in your driver yourself.

Just for the record, there will be one mtd device per partition, but
the "full" mtd device will only exist if the configuration contains
CONFIG_MTD_PARTITIONED_MASTER.

Thanks,
Miquèl

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ