From: Michael Lawnick <nospam_lawnick-Mmb7MZpHnFY@public.gmane.org>
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: public-khali-PUYAD+kWke1g9hUCZPvPmw-8ByrlEUxsivZ+VzJOa5vwg@public.gmane.org
Subject: [PATCH]i2c: Make test for force on client probe possible
Date: Fri, 13 Mar 2009 11:15:57 +0100 [thread overview]
Message-ID: <49BA325D.7030308@gmx.de> (raw)
Hi,
in new driver model 'kind' is no more provided for client's probe
function. The driver frame work creates the path
sys/bus/i2c/devices/[bus]-[dev]/ and populates it with the entries
modalias, name, subsystem@ and uevent. If probe fails (because the
device is not on bus at the moment) the client's sysFs-entries are not
created, but the entries above remain.
This patch provides means to get modules force parameter in probe
function. Clients should test and create entries despite test fail. Of
course entry callbacks should return -EIO as long as device stays
unreachable.
Signed-off-by: <nospam_lawnick-Mmb7MZpHnFY@public.gmane.org>
Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
---
drivers/i2c/i2c-core.c | 29 ++
include/linux/i2c.h | 2 +
2 files changed, 31 insertions(+), 0 deletion(-)
--- linux-2.6.28.7_org/drivers/i2c/i2c-core.c 2009-02-20
23:41:27.000000000 +0100
+++ linux-2.6.28.7/drivers/i2c/i2c-core.c 2009-03-12
13:08:35.000000000 +0100
@@ -323,6 +323,34 @@
}
EXPORT_SYMBOL_GPL(i2c_unregister_device);
+int i2c_client_is_forced (struct i2c_client *client)
+{
+ int forced = 0;
+
+ if (client->driver->address_data->forces) {
+ int adap_id = i2c_adapter_id(client->adapter);
+ const unsigned short * const *forces =
client->driver->address_data->forces;
+ int kind, i;
+
+ for (kind = 0; forces[kind]; kind++) {
+ for (i = 0; forces[kind][i] != I2C_CLIENT_END;
+ i += 2) {
+ if ((forces[kind][i] == adap_id
+ || forces[kind][i] == ANY_I2C_BUS)
+ && forces[kind][i+1] == client->addr) {
+ dev_dbg(&client->dev, "forced "
+ "probe for adapter %d, "
+ "addr 0x%02x, kind %d\n",
+ adap_id, forces[kind][i
+ 1],
+ kind);
+ forced = 1;
+ }
+ }
+ }
+ }
+ return forced;
+}
+EXPORT_SYMBOL_GPL(i2c_client_is_forced);
static const struct i2c_device_id dummy_id[] = {
{ "dummy", 0 },
--- linux-2.6.28.7_org/include/linux/i2c.h 2009-02-20
23:41:27.000000000 +0100
+++ linux-2.6.28.7/include/linux/i2c.h 2009-03-13 11:07:43.000000000 +0100
@@ -301,6 +301,8 @@
extern void i2c_unregister_device(struct i2c_client *);
+extern int i2c_client_is_forced(struct i2c_client *client);
+
/* Mainboard arch_initcall() code should register all its I2C devices.
* This is done at arch_initcall time, before declaring any i2c adapters.
* Modules for add-on boards must use other calls.
next reply other threads:[~2009-03-13 10:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-13 10:15 Michael Lawnick [this message]
[not found] ` <49BA325D.7030308-Mmb7MZpHnFY@public.gmane.org>
2009-03-13 12:09 ` [PATCH]i2c: Make test for force on client probe possible Jean Delvare
[not found] ` <20090313130942.5addd79e-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-03-20 8:02 ` Michael Lawnick
[not found] ` <49C34D97.1010603-Mmb7MZpHnFY@public.gmane.org>
2009-03-20 8:44 ` Jean Delvare
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=49BA325D.7030308@gmx.de \
--to=nospam_lawnick-mmb7mzphnfy@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=public-khali-PUYAD+kWke1g9hUCZPvPmw-8ByrlEUxsivZ+VzJOa5vwg@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