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: <CAGhQ9VxzpPP0+YiVcwE2to_8Ajm1r4659HuWM8pfxUk0jdOzcw@mail.gmail.com>
Date:	Wed, 27 May 2015 19:47:00 +0200
From:	Joachim Eastwood <manabian@...il.com>
To:	Sanchayan Maity <maitysanchayan@...il.com>
Cc:	Arnd Bergmann <arnd@...db.de>, Shawn Guo <shawn.guo@...aro.org>,
	kernel@...gutronix.de, devicetree@...r.kernel.org,
	"linux-arm-kernel@...ts.infradead.org" 
	<linux-arm-kernel@...ts.infradead.org>,
	Stefan Agner <stefan@...er.ch>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 2/2] soc: Add driver for Freescale Vybrid Platform

On 26 May 2015 at 13:36, Sanchayan Maity <maitysanchayan@...il.com> wrote:
> This adds a SoC driver to be used by the Freescale Vybrid SoC's.
> We create the "fsl" directory for holding the different Freescale
> designs. Driver utilises syscon to get the various register values
> needed. After this sysfs exposes some SoC specific properties as
> below:
>
>> cd /sys/devices/soc0
>> ls
> family     machine    power      revision   soc_id     subsystem  uevent
>> cat family
> Freescale Vybrid VF610
>> cat machine
> Freescale Vybrid
>> cat revision
> 00000013
>> cat soc_id
> df6472a60c1c39d4
>
> Signed-off-by: Sanchayan Maity <maitysanchayan@...il.com>
> ---
[...]
> +static struct soc_device_attribute *soc_dev_attr;
> +static struct soc_device *soc_dev;

Now that this is a proper platform device consider putting these in a
struct and allocated it in probe to get rid of the global variables.

> +static int vf610_soc_probe(struct platform_device *pdev)
> +{
> +       struct regmap *ocotp_regmap, *mscm_regmap, *rom_regmap;
> +       struct device *dev = &pdev->dev;
> +       struct device_node *node = pdev->dev.of_node;
[...]
> +       soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
> +       if (!soc_dev_attr)
> +               return -ENOMEM;
> +
> +       soc_dev_attr->machine = kasprintf(GFP_KERNEL, "Freescale Vybrid");
> +       soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%016llx", soc_id);
> +       soc_dev_attr->family = kasprintf(GFP_KERNEL, "Freescale Vybrid VF%s",
> +                                                                soc_type);
> +       soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%08x", rom_rev);
> +
> +       soc_dev = soc_device_register(soc_dev_attr);
> +       if (IS_ERR(soc_dev)) {
> +               kfree(soc_dev_attr->revision);
> +               kfree(soc_dev_attr->family);
> +               kfree(soc_dev_attr->soc_id);
> +               kfree(soc_dev_attr->machine);
> +               kfree(soc_dev_attr);

Since you now have a device pointer you can now uses all the devm_*
functions to allocate your memory.
There is also a devm_kasprintf function.

> +               return -ENODEV;
> +       }
> +
> +       return 0;
> +}
> +
> +static int vf610_soc_remove(struct platform_device *pdev)
> +{
> +       if (soc_dev_attr) {
> +               kfree(soc_dev_attr->revision);
> +               kfree(soc_dev_attr->family);
> +               kfree(soc_dev_attr->soc_id);
> +               kfree(soc_dev_attr->machine);
> +               kfree(soc_dev_attr);

With devm_* you can remove this stuff.

> +       }
> +
> +       if (soc_dev)
> +               soc_device_unregister(soc_dev);
> +
> +       return 0;
> +}


regards,
Joachim Eastwood
--
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