[PATCH] mtd: gpmi: add gpmi_devdata{} to simplify the code

Ezequiel Garcia ezequiel.garcia at free-electrons.com
Fri Mar 21 10:51:15 EDT 2014


On Mar 21, Gupta, Pekon wrote:
> >From: Huang Shijie [mailto:b32955 at freescale.com]
[..[
> >> Can you use "compatible" string in DT for this ?
> >>
> >>
> >sorry, could you please give me an example?
> >
> >I do not know what's your meaning. :(
> >
> 
> Can you use something like this, instead of populating static for each chip.
> 
> if (of_device_is_compatible(of_node, "imx23") || of_device_is_compatible(child, "imx28")) {
> 	bch_max_ecc_strength = 20;
> 	max_chain_delay = 16;
> } elseif (of_device_is_compatible(of_node, "imx6q") {
> 	bch_max_ecc_strength = 40;
> 	max_chain_delay = 12;
> } elseif (of_device_is_compatible(of_node, "imx6sx") {
> 	bch_max_ecc_strength = 40;
> 	max_chain_delay = 0; /* whatever is here */
> } else {
> 	bch_max_ecc_strength = 1; /* whatever is default */
> 	max_chain_delay = 0; /* whatever is default */
> }
> 

IMHO, this is much more expensive, harder to maintain and less readable.

Using the compatible string to match a compatible data, and putting IP-specific
data in there (just like this patch is doing), seems like a much nicer approach.
FWIW, we are using the same trick on a few mvebu drivers.
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com



More information about the linux-mtd mailing list