Hi,

On Thu, Mar 27, 2014 at 11:46:10AM +0100, Alexander Aring wrote:
> Linux handle this #ifdef CONFIG_OF already in of.h
> 
> A static struct declaration is an already zeroed memory space, so we
> don't need a #ifdef CONFIG_OF here and we should have a small codebase.
> 
> if CONFIG_OF is not defined "of_match_ptr" will return NULL otherwise it
> returns the at86rf230_of_match pointer.
> 
> 
> static const struct of_device_id at86rf230_of_match[] = {
>         { .compatible = "atmel,at86rf230", },
>         { .compatible = "atmel,at86rf231", },
>         { .compatible = "atmel,at86rf233", },
>         { .compatible = "atmel,at86rf212", },
>         { },
> };
> MODULE_DEVICE_TABLE(of, at86rf230_of_match);
> 
> static const struct spi_device_id at86rf230_device_id[] = {
>         { .name = "at86rf230", },
>         { .name = "at86rf231", },
>         { .name = "at86rf233", },
>         { .name = "at86rf212", },
>         { },
> };
> MODULE_DEVICE_TABLE(spi, at86rf230_device_id);
> 
> static struct spi_driver at86rf230_driver = {
>         .id_table = at86rf230_device_id,
>         .driver = {
>                 .of_match_table = of_match_ptr(at86rf230_of_match),
>                 .name   = "at86rf230",
>                 .owner  = THIS_MODULE,
>         },
>         .probe      = at86rf230_probe,
>         .remove     = at86rf230_remove,
> };
> 
> Let me know if you are fine with that.
> 

With this solution "modinfo at86rf230" prints:

filename:
/lib/modules/3.14.0-rc8-01856-g8652599/kernel/drivers/net/ieee802154/at86rf230.ko
license:        GPL v2
description:    AT86RF230 Transceiver Driver
srcversion:     046691C0B2230A291E98B63
alias:          of:N*T*Catmel,at86rf212*
alias:          of:N*T*Catmel,at86rf233*
alias:          of:N*T*Catmel,at86rf231*
alias:          of:N*T*Catmel,at86rf230*
alias:          spi:at86rf212
alias:          spi:at86rf233
alias:          spi:at86rf231
alias:          spi:at86rf230
depends:        
intree:         Y
vermagic:       3.14.0-rc8-01856-g8652599 mod_unload modversions ARMv6p2v8 

and it should also work if we don't have CONFIG_OF enabled.

- Alex

------------------------------------------------------------------------------
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to