Wolfram Sang wrote:
> On Tue, May 13, 2008 at 01:20:24PM +0300, Darius wrote:
>> I set up i2c_board_info in board init function. Should I somewhere
>> call i2c_new_device()?
> Have you called i2c_register_board_info? (If not, check
> arch/arm/mach-iop32x/em7210.c for an example)
> 
> All the best,
> 
>    Wolfram

yes, I have.
I attach simplified i2c code part from my driver above:

---------------------------------------------------------------------------------------------------------

struct ov7670 {
        struct i2c_client *client;
};

static int ov7670_probe(struct i2c_client *client, const struct 
i2c_device_id *did)
{
        struct ov7670 *ov7670;
        struct i2c_adapter *adapter =to_i2c_adapter(client->dev.parent);
        int ret;

        printk ("OV7670: error1\n");

        if (!i2c_check_functionality(adapter,I2C_FUNC_SMBUS_WORD_DATA)){
                return -EIO;
        }
        
        ov7670 = kzalloc(sizeof(struct ov7670), GFP_KERNEL);
        if (!ov7670)
                return -ENOMEM;
        ov7670->client = client;
        i2c_set_clientdata(client, ov7670);
        return 0;
}

static int ov7670_remove(struct i2c_client *client)
{
        struct ov7670 *ov7670 = i2c_get_clientdata(client);
        struct i2c_adapter *adapter =to_i2c_adapter(client->dev.parent);
        kfree(ov7670);
        return 0;
}

static const struct i2c_device_id ov7670_id[] = {
        { "ov7670", 0 },
        { }
};
MODULE_DEVICE_TABLE(i2c, ov7670_id);

static struct i2c_driver ov7670_i2c_driver = {
        .driver =       
                        {
                                .name = "ov7670",
                        },
        .probe          = ov7670_probe,
        .remove         = ov7670_remove,
        .id_table       = ov7670_id,
};

static int __init ov7670_init(void)
{
        printk ("OV7670: driver init\n");
        return i2c_add_driver(&ov7670_i2c_driver);
}

static void __exit ov7670_exit(void)
{
        printk ("OV7670: driver exit\n");       
        i2c_del_driver(&ov7670_i2c_driver);
}

module_init(ov7670_init);
module_exit(ov7670_exit);


-------------------------------------------------------------------------------------------

And piece from board init:

------------------------------------------------------------------------------------------

static struct i2c_board_info __initdata mx1ads_i2c_devices[] = {
        {
                I2C_BOARD_INFO("ov7670", 0x42),
        }
};

<...>
i2c_register_board_info(0,mx1ads_i2c_devices,ARRAY_SIZE(mx1ads_i2c_devices));
<...>


_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

Reply via email to