public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: kalhan trisal <kalhantrisal-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
Cc: i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
Subject: Re: need soem help realter to I2C client
Date: Fri, 19 Sep 2008 14:42:31 +0200	[thread overview]
Message-ID: <20080919144231.780fb37a@hyperion.delvare> (raw)
In-Reply-To: <697640.78220.qm-4UY5Ii0Ri9vS1Wi2ZBor9F5cfvJIxWXgQQ4Iyu8u01E@public.gmane.org>

Hi Kalhan,

On Fri, 19 Sep 2008 12:03:56 +0530 (IST), kalhan trisal wrote:
> Hello, 
>    I have platform which has 5 hw devices and I want single driver
> to control all the devices.

Bad idea. This will make your code non-reusable, meaning that nobody
will be interested in it.

> I donot need probe as I know the devices are present and I know all
> the slave address. The interface for read write is using sysfs and
> I am planning to put it under hwmon. These all devices are separate
> chips.
> 
>    Can I do this please let me know.
> 
> 
>  struct foo_data { 
>     struct i2c_client client_data[5]; 
>    }; 
> 
> int foo_detect_client(struct i2c_adapter *adapter, int address,  
>                          unsigned short flags, int kind) 

This interface is deprecated, so no new driver will be allowed to use
it. Please use the (new) standard .probe() method instead.

> { 
>      int err = 0; 
>      int i; 
>      int addrtemp[]= {0x42,0x45,0x46,0x47,0x48};
>      struct i2c_client *new_client; 
>      struct foo_data *data; 
>      const char *client_name = "";
>      
>       For(i=0;i<5;i++)
>       {

You will have to fix your coding style as well.

>            new_client = &data->client_data[i];
>            new_client->addr = addrtemp[i]; 
>            new_client->data = data; //lets consider it is same 
>            new_client->adapter = adapter; 
>            new_client->driver = &foo_driver; 
>            new_client->flags = 0; 
>      
>            strcpy(new_client->name,client_name); 
>           /* Tell the i2c layer a new client has arrived */ 
>           if ((err = i2c_attach_client(new_client))) 
>       }
> }

-- 
Jean Delvare

_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c

  parent reply	other threads:[~2008-09-19 12:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-19  6:33 need soem help realter to I2C client kalhan trisal
     [not found] ` <697640.78220.qm-4UY5Ii0Ri9vS1Wi2ZBor9F5cfvJIxWXgQQ4Iyu8u01E@public.gmane.org>
2008-09-19 12:42   ` Jean Delvare [this message]
     [not found]     ` <20080919144231.780fb37a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-09-19 13:04       ` tvp5150 new style i2c driver Luca Santini
     [not found]         ` <48D3A36D.1090001-wNesuFfO2Ajz1n+OaKNE4w@public.gmane.org>
2008-09-19 13:23           ` Jean Delvare
2008-09-19 15:04       ` Luca Santini
     [not found]         ` <48D3BF65.1020201-wNesuFfO2Ajz1n+OaKNE4w@public.gmane.org>
2008-09-19 15:25           ` Jean Delvare
2008-09-19 15:27       ` Luca Santini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080919144231.780fb37a@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
    --cc=kalhantrisal-/E1597aS9LQAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox