From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Wen Wang" Subject: Re: Question about i2c new style modle Date: Sun, 12 Oct 2008 19:52:08 +0800 Message-ID: <56458e0810120452n2def8400n883ad46d0440e779@mail.gmail.com> References: <56458e0810112335r529622dei4c6891465c6fdf88@mail.gmail.com> <20081012075715.GA26683@pengutronix.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4927435166591902306==" Return-path: In-Reply-To: <20081012075715.GA26683-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: i2c-bounces-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org Errors-To: i2c-bounces-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org To: Wolfram Sang Cc: i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org List-Id: linux-i2c@vger.kernel.org --===============4927435166591902306== Content-Type: multipart/alternative; boundary="----=_Part_26059_23495841.1223812328080" ------=_Part_26059_23495841.1223812328080 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Wolfram, Thank you for your quick response, really appreciate. You're saying "You supply i2c_board_info in your board init code and when the i2c adapter is initialized", but I'm quite sure there won't be a such static i2c_board_info in the board init code. And I'm just wonder if there is a dynamic detect method to go? Here is my proposed code, can you please help to correct it if I'm wrong? static const unsigned short normal_i2c[] = { DEVICE_ADDRESS, I2C_CLIENT_END }; I2C_CLIENT_INSMOD(foo); static int foo_detect(struct i2c_client *client, int kind, struct i2c_board_info *info) { /* Things here */ return 0; } static int foo_probe(struct i2c_client *client, const struct i2c_device_id *id) { /* Things here */ return 0; } static int foo_remove(struct i2c_client *client) { /* Things here */ return 0; } static const struct i2c_device_id foo_id[] = { { "foo", 0 }, { } }; static struct i2c_driver foo_driver = { .driver = { .name = "foo", }, .probe = foo_probe, .remove = foo_remove, .id_table = foo_id, .class = I2C_CLASS_CAM_DIGITAL, .detect = foo_detect, .address_data = &addr_data, }; Best Regards Wen ------=_Part_26059_23495841.1223812328080 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Hi Wolfram,
 
Thank you for your quick response, really appreciate.
 
You're saying "You supply i2c_board_info in your board init code and when the
i2c adapter is initialized", but I'm quite sure there won't be a such static i2c_board_info in the board init code.
 
And I'm just wonder if there is a dynamic detect method to go?
 
Here is my proposed code, can you please help to correct it if I'm wrong?
 
static const unsigned short normal_i2c[] = { DEVICE_ADDRESS, I2C_CLIENT_END };
I2C_CLIENT_INSMOD(foo);
 
static int foo_detect(struct i2c_client *client, int kind,
                             struct i2c_board_info *info)
{
         /* Things here */
         return 0;
}
 
static int foo_probe(struct i2c_client *client,
                            const struct i2c_device_id *id)
         /* Things here */
         return 0;
}
 
static int foo_remove(struct i2c_client *client)
{
         /* Things here */
         return 0;
}
 
static const struct i2c_device_id foo_id[] = {
         { "foo", 0 },
         { }
};
 
static struct i2c_driver foo_driver = {
         .driver = {
                 .name = "foo",
         },
         .probe  = foo_probe,
         .remove  = foo_remove,
         .id_table = foo_id,
         .class  = I2C_CLASS_CAM_DIGITAL,
         .detect  = foo_detect,
         .address_data = &addr_data,
};
 
Best Regards
Wen
------=_Part_26059_23495841.1223812328080-- --===============4927435166591902306== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ i2c mailing list i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org http://lists.lm-sensors.org/mailman/listinfo/i2c --===============4927435166591902306==--