On Thu, Jul 16, 2015 at 9:35 AM, Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx> wrote: > 2015-07-16 16:07 GMT+09:00 Linus Walleij <linus.walleij@xxxxxxxxxx>: >>> ngpio == 248 for some SoCs, >>> and ngpio == 136 for some, etc. >> >> That is the wrong way to handle different SoC. That should be handled >> by different compatible strings, and then you select the number of GPIOs >> for the version corresponding to that compatibe string. >> >>>>> +static const struct of_device_id uniphier_gpio_match[] = { >>>>> + { .compatible = "socionext,uniphier-gpio" }, >>>>> + { /* sentinel */ } >>>>> +}; >> >> i.e. you should use the .data field of of_device_id to carry variant-specific >> information. > > > Currently, I want to use this driver on 7 SoCs > > PH1-sLD3: ngpio == 136 > PH1-LD4 : ngpio == 136 > PH1-Pro4: ngpio == 248 > PH1-sLD8: ngpio == 136 > PH1-Pro5: ngpio == 248 > ProXstream2: ngpio == 232 > PH1-LD6b: ngpio == 232 > > So, should I describe the OF match table like this? > > static const struct of_device_id uniphier_gpio_match[] = { > { .compatible = "socionext,ph1-sld3-gpio" .data = (void *)136 }, > { .compatible = "socionext,ph1-ld4-gpio" .data = (void *)136 }, > { .compatible = "socionext,ph1-pro4-gpio" .data = (void *)248 }, > { .compatible = "socionext,ph1-sld8-gpio" .data = (void *)136 }, > { .compatible = "socionext,ph1-pro5-gpio" .data = (void *)248 }, > { .compatible = "socionext,proxstream2-gpio", .data = (void *)232 }, > { .compatible = "socionext,ph1-ld6b-gpio", .data = (void *)232 }, > { /* sentinel */ } > }; Yes. > One disadvantage for this way is that > I need to touch the driver file every time I add a new SoC support. That is appropriate since it is a new hardware. This is the same as the fact that we touch the kernel to add new USB IDs and PCI IDs every time a new hardware comes out for x86, we should know what hardware we are toying with. Since you seem to have a pin controller in parallel anyways I see it as natural to do this at the same time as you do that anyways. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html