linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ARM: kirkwood: Convert orion-nand to fdt
Date: Sun, 11 Mar 2012 17:52:32 +0000	[thread overview]
Message-ID: <201203111752.32497.arnd@arndb.de> (raw)
In-Reply-To: <1331476406-9844-3-git-send-email-jm@lentin.co.uk>

On Sunday 11 March 2012, Jamie Lentin wrote:
> The DNS-320 and 325 have a NAND partitioned to store uboot, uimage and root
> filesystem. Store this information in devicetree.

All the important parts  look good to me, just two small details:

> -	board = pdev->dev.platform_data;
> +	if (pdev->dev.of_node) {
> +		board = kzalloc(sizeof(struct orion_nand_data), GFP_KERNEL);
> +		if (!board) {
> +			printk(KERN_ERR "orion_nand: failed to allocate board structure.\n");
> +			ret = -ENOMEM;
> +			goto no_res;
> +		}
> +		if (!of_property_read_u32(pdev->dev.of_node, "cle", &val))
> +			board->cle = (u8)val;
> +		if (!of_property_read_u32(pdev->dev.of_node, "ale", &val))
> +			board->ale = (u8)val;
> +		if (!of_property_read_u32(pdev->dev.of_node, "width", &val))
> +			board->width = (u8)val;
> +		if (!of_property_read_u32(pdev->dev.of_node,
> +						"chip-delay", &val))
> +			board->chip_delay = (u8)val;
> +	} else
> +		board = pdev->dev.platform_data;

If you use devm_kzalloc, the memory will get freed automatically during cleanup.
  
> +#ifdef CONFIG_OF
> +static struct of_device_id orion_nand_of_match_table[] = {
> +	{ .compatible = "mrvl,orion-nand", },
> +	{},
> +};
> +#else
> +#define orion_nand_of_match_table NULL
> +#endif
> +
>  static struct platform_driver orion_nand_driver = {
>  	.remove		= __devexit_p(orion_nand_remove),
>  	.driver		= {
>  		.name	= "orion_nand",
>  		.owner	= THIS_MODULE,
> +		.of_match_table = of_match_ptr(orion_nand_of_match_table),
>  	},
>  };

When you use of_match_ptr(), you can leave out the "#else\n#define orion_nand_of_match_table NULL".

	Arnd

  reply	other threads:[~2012-03-11 17:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-11 14:33 [PATCH 0/2] Add support for DNS-320 and DNS-325 using devicetree Jamie Lentin
2012-03-11 14:33 ` [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325 Jamie Lentin
2012-03-11 17:46   ` Arnd Bergmann
2012-03-12  3:17     ` Jason Cooper
2012-03-12  8:11       ` Arnd Bergmann
2012-03-12 16:10         ` Jason Cooper
2012-03-12  3:02   ` Jason Cooper
2012-03-12  8:17     ` Arnd Bergmann
2012-03-12 14:22       ` Jamie Lentin
2012-03-12 14:27         ` Jason Cooper
2012-03-12 14:58           ` Arnd Bergmann
2012-03-12 17:59     ` Jamie Lentin
2012-03-12 18:56       ` Jason Cooper
2012-03-11 14:33 ` [PATCH 2/2] ARM: kirkwood: Convert orion-nand to fdt Jamie Lentin
2012-03-11 17:52   ` Arnd Bergmann [this message]
2012-03-12  3:23   ` Jason Cooper
2012-03-12  2:36 ` [PATCH 0/2] Add support for DNS-320 and DNS-325 using devicetree Jason Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201203111752.32497.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).