From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, sensors@Stimpy.netroedge.com
Cc: khali@linux-fr.org
Subject: [PATCH] I2C: Remove redundancy from i2c-core.c
Date: Tue, 21 Jun 2005 22:17:44 -0700 [thread overview]
Message-ID: <11194174641478@kroah.com> (raw)
In-Reply-To: <11194174641612@kroah.com>
[PATCH] I2C: Remove redundancy from i2c-core.c
Call i2c_transfer() from i2c_master_send() and i2c_master_recv() to
avoid the redundant code that was in all three functions. It also
removes unnecessary debug statements as suggested by Jean Delvare.
This is important for the non-blocking interfaces because they will
have to handle a non-blocking interface in this area. Having it in
one place greatly simplifies the changes.
Signed-off-by: Corey Minyard <minyard@acm.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
commit 815f55f280fb2781ba1c2a350516b73e55119c60
tree 48c06bd1650d44aa274989ce2696eb5091d3805c
parent 30aedcb33970367e50b5edf373e9cd1a5cebcbe1
author Jean Delvare <khali@linux-fr.org> Sat, 07 May 2005 22:58:46 +0200
committer Greg Kroah-Hartman <gregkh@suse.de> Tue, 21 Jun 2005 21:51:55 -0700
drivers/i2c/i2c-core.c | 64 +++++++++++++++---------------------------------
1 files changed, 20 insertions(+), 44 deletions(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -611,27 +611,16 @@ int i2c_master_send(struct i2c_client *c
struct i2c_adapter *adap=client->adapter;
struct i2c_msg msg;
- if (client->adapter->algo->master_xfer) {
- msg.addr = client->addr;
- msg.flags = client->flags & I2C_M_TEN;
- msg.len = count;
- msg.buf = (char *)buf;
+ msg.addr = client->addr;
+ msg.flags = client->flags & I2C_M_TEN;
+ msg.len = count;
+ msg.buf = (char *)buf;
- dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n",
- count);
-
- down(&adap->bus_lock);
- ret = adap->algo->master_xfer(adap,&msg,1);
- up(&adap->bus_lock);
-
- /* if everything went ok (i.e. 1 msg transmitted), return #bytes
- * transmitted, else error code.
- */
- return (ret == 1 )? count : ret;
- } else {
- dev_err(&client->adapter->dev, "I2C level transfers not supported\n");
- return -ENOSYS;
- }
+ ret = i2c_transfer(adap, &msg, 1);
+
+ /* If everything went ok (i.e. 1 msg transmitted), return #bytes
+ transmitted, else error code. */
+ return (ret == 1) ? count : ret;
}
int i2c_master_recv(struct i2c_client *client, char *buf ,int count)
@@ -639,31 +628,18 @@ int i2c_master_recv(struct i2c_client *c
struct i2c_adapter *adap=client->adapter;
struct i2c_msg msg;
int ret;
- if (client->adapter->algo->master_xfer) {
- msg.addr = client->addr;
- msg.flags = client->flags & I2C_M_TEN;
- msg.flags |= I2C_M_RD;
- msg.len = count;
- msg.buf = buf;
- dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n",
- count);
-
- down(&adap->bus_lock);
- ret = adap->algo->master_xfer(adap,&msg,1);
- up(&adap->bus_lock);
-
- dev_dbg(&client->adapter->dev, "master_recv: return:%d (count:%d, addr:0x%02x)\n",
- ret, count, client->addr);
-
- /* if everything went ok (i.e. 1 msg transmitted), return #bytes
- * transmitted, else error code.
- */
- return (ret == 1 )? count : ret;
- } else {
- dev_err(&client->adapter->dev, "I2C level transfers not supported\n");
- return -ENOSYS;
- }
+ msg.addr = client->addr;
+ msg.flags = client->flags & I2C_M_TEN;
+ msg.flags |= I2C_M_RD;
+ msg.len = count;
+ msg.buf = buf;
+
+ ret = i2c_transfer(adap, &msg, 1);
+
+ /* If everything went ok (i.e. 1 msg transmitted), return #bytes
+ transmitted, else error code. */
+ return (ret == 1) ? count : ret;
}
next prev parent reply other threads:[~2005-06-22 6:32 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-22 5:16 [GIT PATCH] I2C patches for 2.6.12 Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Kill address ranges in non-sensors i2c chip drivers Greg KH
2005-06-22 5:17 ` [PATCH] I2C: i2c-vid.h: Support for VID to reg conversion Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Merge unused address lists in some video drivers Greg KH
2005-06-22 5:17 ` [PATCH] I2C: rtc8564.c remove duplicate include Greg KH
2005-06-22 5:17 ` [PATCH] I2C: ds1337 1/4 Greg KH
2005-06-22 5:17 ` [PATCH] I2C: mark all functions static in atxp1 driver Greg KH
2005-06-22 5:17 ` [PATCH] I2C: add new " Greg KH
2005-06-22 5:17 ` [PATCH] I2C: ds1337: i2c_transfer() checking Greg KH
2005-06-22 5:17 ` [PATCH] I2C: ds1337: Make time format consistent with other RTC drivers Greg KH
2005-06-22 5:17 ` [PATCH] I2C: ds1337 2/4 Greg KH
2005-06-22 5:17 ` [PATCH] I2C: ds1337 3/4 Greg KH
2005-06-22 5:17 ` [PATCH] I2C: ds1337: search by bus number Greg KH
2005-06-22 5:17 ` [PATCH] ds1337 driver works also with ds1339 chip Greg KH
2005-06-22 5:17 ` [PATCH] ds1337: export ds1337_do_command Greg KH
2005-06-22 5:17 ` [PATCH] I2C: add new hardware monitor driver: adm9240 Greg KH
2005-06-22 5:17 ` [PATCH] I2C: #include <linux/config.h> cleanup Greg KH
2005-06-22 5:17 ` [PATCH] I2C: drivers/i2c/*: " Greg KH
2005-06-22 5:17 ` [PATCH] I2C: New hardware monitoring driver: w83627ehf Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Fix bugs in the new w83627ehf driver Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Add support for the LPC47M15x and LPC47M192 chips to smsc47m1 Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Allow for sharing of the interrupt line for i2c-mpc.c Greg KH
2005-06-22 5:17 ` [PATCH] Spelling fixes for drivers/i2c Greg KH
2005-06-22 5:17 ` Greg KH [this message]
2005-06-22 5:17 ` [PATCH] I2C: sysfs names: rename to cpu0_vid, take 3 Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Setting w83627hf fan divisor 128 fails Greg KH
2005-06-22 5:17 ` [PATCH] I2C: remove <linux/delay.h> from via686a Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Kill common macro abuse in chip drivers Greg KH
2005-06-22 5:17 ` [PATCH] I2C: adm9240 driver cleanup Greg KH
2005-06-22 5:17 ` [PATCH] I2C: include of jiffies.h for some i2c drivers Greg KH
2005-06-22 5:17 ` [PATCH] I2C: chips/Kconfig corrections Greg KH
2005-06-22 5:17 ` [PATCH] I2C: driver adm1021: remove die_code Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Coding style cleanups to via686a Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Spelling fixes for drivers/i2c/algos/i2c-algo-pca.c Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Kill another macro abuse in via686a Greg KH
2005-06-22 5:17 ` [PATCH] I2C: fix up some sysfs device attribute file parameters Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Spelling fixes for drivers/i2c/busses/i2c-parport.c Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Spelling fixes for drivers/i2c/i2c-core.c Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Spelling fixes for drivers/i2c/i2c-dev.c Greg KH
2005-06-22 5:17 ` [PATCH] I2C: add i2c driver for TPS6501x Greg KH
2005-06-22 5:17 ` [PATCH] i2c: Race fix for i2c-mpc.c Greg KH
2005-06-22 5:17 ` [PATCH] I2C: Sensors mailing list has moved Greg KH
2005-06-22 5:17 ` [PATCH] I2C: documentation update 1/3 Greg KH
2005-06-22 5:17 ` [PATCH] I2C: KConfig update - some EXPERIMENTAL removal Greg KH
2005-06-23 21:12 ` [PATCH] I2C: add i2c driver for TPS6501x Jean Delvare
2005-06-22 7:37 ` [PATCH] I2C: Remove redundancy from i2c-core.c Thomas Schneller
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=11194174641478@kroah.com \
--to=gregkh@suse.de \
--cc=greg@kroah.com \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sensors@Stimpy.netroedge.com \
/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