Hi Varka,

On Thu, Mar 27, 2014 at 03:35:17PM +0530, Varka Bhadram wrote:
> 
> > no, of_match_ptr will return NULL if CONFIG_OF is not defined. We don't
> > need any IS_ENABLED(CONFIG_OF).
> >
> > see include/linux/of.h line 521
> >
> > - Alex
> 
> You are correct. I think the only way is
> 
> #ifdef CONFIG_OF
> static 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);
> #else
> static const struct spi_device_id at86rf230_ids [] = {         //For Non-DT
> supported boards
> { "at86rf230" , 0 },
> ..............
> { },
> };
> MODULE_DEVICE_TABLE ( spi , at86rf230_ids );
> #endif
> 
> static struct spi_driver at86rf230_driver = {
We also need a

.id_table = at86rf230_ids,

here.

>      . driver = {
>               #ifdef CONFIG_OF
>              . of_match_table = of_match_ptr ( at86rf230_of_match ),

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.

- 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