public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Ayman KHAMOUMA <ayman.khamouma-qxv4g6HH51o@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Need help on selecting one (and only one) i2c bus
Date: Wed, 11 Mar 2009 12:22:57 +0100	[thread overview]
Message-ID: <20090311122257.7c7805f0@hyperion.delvare> (raw)
In-Reply-To: <000301c9a237$e6d3c8f0$b23e81a4-J7BnVcvkGbbQT0dZR+AlfA@public.gmane.org>

Hi Ayman,

On Wed, 11 Mar 2009 11:55:22 +0100, Ayman KHAMOUMA wrote:
> After some researches I guess I have to use the normal_i2c and ignore
> arrays:
> 
> static unsigned short normal_i2c[] = { 0x71, I2C_CLIENT_END};
> static unsigned short ignore[] = { 0x01, 0x71, 0x02, 0x71, I2C_CLIENT_END};
> 
> static struct i2c_client_address_data addr_data = {
>     .normal_i2c = normal_i2c,
>     .ignore     = ignore,
> };
> 
> Int the init function I have to allocate a major to the driver, and than add
> the I2c driver:
> i2c_add_driver(&i2c_my_drv);
> 
> After doing that, i2c_my_drv.attach_adapter is called.
> 
> Which will call (among others) my probe function, in which I call
> i2c_attach_client.
> 
> 
> Am I in the right way ?

No. You're using the old, deprecated way to instantiate devices, and
you are abusing it (the ignore array wasn't meant to be used the way
you do.)

You said you're using kernel 2.6.23.17, it's not brand new, but it's
not too old either. At any rate, it already includes the new-style
device binding. So, instead of using the old binding model and then
fight to get your driver to _not_ attach to improper devices/addresses,
you should use the new model and explicitly instantiate your device, so
that your driver won't even try to bind to the wrong devices.

I have posted an explanation about how to do this recently:
http://marc.info/?l=linux-i2c&m=123659553713018&w=2

You should convert your driver to a new-style one and use either method
1 or method 2, whichever is easier for you. See the following document
for a guide on how to update your code:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=Documentation/i2c/upgrading-clients;hb=HEAD

It's for kernel 2.6.26 and later but it should mostly apply to 2.6.23
too. The only big difference I can think of is that 2.6.23 doesn't have
struct i2c_device_id, instead the device driver binding is based on the
i2c driver name. I can help you with this if you can't figure it out.

As a side note, the fact that you needed to add buses 1 and 2 to the
ignore list suggests that something is wrong with your I2C bus driver.
It is rather unlikely that all 3 I2C buses on your system have a device
at address 0x71, so your old-style driver shouldn't have instantiated 3
devices. If it did, it strongly suggests that the quick write i2c-core
is using to check for the presence of a device at a given address
improperly reported success in all cases. You really should check your
I2C bus driver and in particular the implementation of 0-byte messages
before going further with the device driver.

-- 
Jean Delvare
http://khali.linux-fr.org/wishlist.html

  parent reply	other threads:[~2009-03-11 11:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-09 14:52 Need help on selecting one (and only one) i2c bus Ayman KHAMOUMA
     [not found] ` <000001c9a0c6$bf92af80$b23e81a4-J7BnVcvkGbbQT0dZR+AlfA@public.gmane.org>
2009-03-10 15:30   ` Jean Delvare
     [not found]     ` <20090310163044.571e4aff-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-03-10 15:58       ` Ayman KHAMOUMA
2009-03-10 16:03       ` Ayman KHAMOUMA
2009-03-11 10:55       ` Ayman KHAMOUMA
     [not found]         ` <000301c9a237$e6d3c8f0$b23e81a4-J7BnVcvkGbbQT0dZR+AlfA@public.gmane.org>
2009-03-11 11:22           ` Jean Delvare [this message]
     [not found]             ` <20090311122257.7c7805f0-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-03-11 11:44               ` Ayman KHAMOUMA
2009-03-11 16:51               ` Ayman KHAMOUMA
     [not found]                 ` <001301c9a269$ab95d940$b23e81a4-J7BnVcvkGbbQT0dZR+AlfA@public.gmane.org>
2009-03-11 19:09                   ` Jean Delvare
2009-03-24 10:27               ` I2c message at init time Ayman KHAMOUMA
     [not found]                 ` <000201c9ac6b$34a95300$2d3f81a4-J7BnVcvkGbbQT0dZR+AlfA@public.gmane.org>
2009-03-24 15:52                   ` Jean Delvare
     [not found]                     ` <20090324165227.0d97454c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-03-24 15:58                       ` Ayman KHAMOUMA
     [not found]     ` <fd6b62c10903102327u426a4262meeabe2c581d7107b@mail.gmail.com>
     [not found]       ` <fd6b62c10903102327u426a4262meeabe2c581d7107b-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-03-11  9:15         ` Need help on selecting one (and only one) i2c bus Jean Delvare
     [not found]           ` <20090311101513.271f5464-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-03-11  9:47             ` Daniel Mack
     [not found]               ` <fd6b62c10903110319w1eebd2ebs4b83e7d1247f1678@mail.gmail.com>
     [not found]                 ` <fd6b62c10903110319w1eebd2ebs4b83e7d1247f1678-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-03-11 10:40                   ` Daniel Mack
  -- strict thread matches above, loose matches on Subject: below --
2009-03-09 10:58 Ayman KHAMOUMA

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=20090311122257.7c7805f0@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=ayman.khamouma-qxv4g6HH51o@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@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