From: Gerd Knorr <kraxel@bytesex.org>
To: Kernel List <linux-kernel@vger.kernel.org>,
Greg KH <greg@kroah.com>, Frank Davis <fdavis@si.rr.com>
Subject: [patch] add i2c_clients_command()
Date: Wed, 2 Apr 2003 19:06:52 +0200 [thread overview]
Message-ID: <20030402170652.GA24954@bytesex.org> (raw)
Hi,
This patch adds a function which loops over all i2c clients attached
to some i2c adapter and calls the ->command function of the driver.
Currently the bttv and saa7134 drivers have simliar functions, but
(currently) without sane locking and module handling. Newer versions
will switch to this function. Updates for the two drivers which are
actually using this new function are available from
http://bytesex.org/patches/wip/
Gerd
diff -u linux-2.5.66/drivers/i2c/i2c-core.c linux/drivers/i2c/i2c-core.c
--- linux-2.5.66/drivers/i2c/i2c-core.c 2003-04-02 11:42:18.357220889 +0200
+++ linux/drivers/i2c/i2c-core.c 2003-04-02 16:17:47.127702160 +0200
@@ -494,6 +494,27 @@
return 0;
}
+void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg)
+{
+ int i;
+
+ down(&adap->list);
+ for (i = 0; i < I2C_CLIENT_MAX; i++) {
+ if (NULL == adap->clients[i])
+ continue;
+ if (!try_module_get(adap->clients[i]->driver->owner))
+ continue;
+ if (NULL == adap->clients[i]->driver->command)
+ continue;
+
+ up(&adap->list);
+ adap->clients[i]->driver->command(adap->clients[i],cmd,arg);
+ module_put(adap->clients[i]->driver->owner);
+ down(&adap->list);
+ }
+ up(&adap->list);
+}
+
#ifdef CONFIG_PROC_FS
/* This function generates the output for /proc/bus/i2c-? */
static ssize_t i2cproc_bus_read(struct file *file, char *buf,
@@ -1417,6 +1438,7 @@
EXPORT_SYMBOL(i2c_use_client);
EXPORT_SYMBOL(i2c_release_client);
EXPORT_SYMBOL(i2c_check_addr);
+EXPORT_SYMBOL(i2c_clients_command);
EXPORT_SYMBOL(i2c_master_send);
EXPORT_SYMBOL(i2c_master_recv);
diff -u linux-2.5.66/include/linux/i2c.h linux/include/linux/i2c.h
--- linux-2.5.66/include/linux/i2c.h 2003-04-02 11:49:36.479533709 +0200
+++ linux/include/linux/i2c.h 2003-04-02 11:49:36.727492916 +0200
@@ -329,6 +329,11 @@
extern int i2c_use_client(struct i2c_client *);
extern int i2c_release_client(struct i2c_client *);
+/* call the i2c_client->command() of all attached clients with
+ * the given arguments */
+extern void i2c_clients_command(struct i2c_adapter *adap,
+ unsigned int cmd, void *arg);
+
/* returns -EBUSY if address has been taken, 0 if not. Note that the only
other place at which this is called is within i2c_attach_client; so
you can cheat by simply not registering. Not recommended, of course! */
--
Michael Moore for president!
next reply other threads:[~2003-04-02 16:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-02 17:06 Gerd Knorr [this message]
2003-04-02 18:08 ` [patch] add i2c_clients_command() Christoph Hellwig
2003-04-03 8:49 ` Gerd Knorr
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=20030402170652.GA24954@bytesex.org \
--to=kraxel@bytesex.org \
--cc=fdavis@si.rr.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.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