From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: johnpol@2ka.mipt.ru
Subject: [PATCH] w1: Added w1_reset_select_slave() - Resets the bus and then selects the slave by
Date: Thu, 8 Sep 2005 15:22:41 -0700 [thread overview]
Message-ID: <11262181611117@kroah.com> (raw)
In-Reply-To: <11262181613474@kroah.com>
[PATCH] w1: Added w1_reset_select_slave() - Resets the bus and then selects the slave by
sending either a skip rom or a rom match.
Patch from Ben Gardner <bgardner@wabtec.com>
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
commit ea7d8f65c865ebfa1d7cd67c360a87333ff013c1
tree 1e687c32d53a92c10a61fb23ab14763459ff5779
parent db2d0008de519c5db6baec45f7831e08790301cf
author Evgeniy Polyakov <johnpol@2ka.mipt.ru> Thu, 11 Aug 2005 17:27:49 +0400
committer Greg Kroah-Hartman <gregkh@suse.de> Thu, 08 Sep 2005 14:41:26 -0700
drivers/w1/w1_io.c | 24 ++++++++++++++++++++++++
drivers/w1/w1_io.h | 1 +
drivers/w1/w1_therm.c | 11 ++---------
3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -277,6 +277,29 @@ void w1_search_devices(struct w1_master
w1_search(dev, cb);
}
+/**
+ * Resets the bus and then selects the slave by sending either a skip rom
+ * or a rom match.
+ * The w1 master lock must be held.
+ *
+ * @param sl the slave to select
+ * @return 0=success, anything else=error
+ */
+int w1_reset_select_slave(struct w1_slave *sl)
+{
+ if (w1_reset_bus(sl->master))
+ return -1;
+
+ if (sl->master->slave_count == 1)
+ w1_write_8(sl->master, W1_SKIP_ROM);
+ else {
+ u8 match[9] = {W1_MATCH_ROM, };
+ memcpy(&match[1], (u8 *)&sl->reg_num, 8);
+ w1_write_block(sl->master, match, 9);
+ }
+ return 0;
+}
+
EXPORT_SYMBOL(w1_touch_bit);
EXPORT_SYMBOL(w1_write_8);
EXPORT_SYMBOL(w1_read_8);
@@ -286,3 +309,4 @@ EXPORT_SYMBOL(w1_delay);
EXPORT_SYMBOL(w1_read_block);
EXPORT_SYMBOL(w1_write_block);
EXPORT_SYMBOL(w1_search_devices);
+EXPORT_SYMBOL(w1_reset_select_slave);
diff --git a/drivers/w1/w1_io.h b/drivers/w1/w1_io.h
--- a/drivers/w1/w1_io.h
+++ b/drivers/w1/w1_io.h
@@ -34,5 +34,6 @@ u8 w1_calc_crc8(u8 *, int);
void w1_write_block(struct w1_master *, const u8 *, int);
u8 w1_read_block(struct w1_master *, u8 *, int);
void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb);
+int w1_reset_select_slave(struct w1_slave *sl);
#endif /* __W1_IO_H */
diff --git a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c
--- a/drivers/w1/w1_therm.c
+++ b/drivers/w1/w1_therm.c
@@ -176,15 +176,10 @@ static ssize_t w1_therm_read_bin(struct
crc = 0;
while (max_trying--) {
- if (!w1_reset_bus (dev)) {
+ if (!w1_reset_select_slave(sl)) {
int count = 0;
- u8 match[9] = {W1_MATCH_ROM, };
unsigned int tm = 750;
- memcpy(&match[1], (u64 *) & sl->reg_num, 8);
-
- w1_write_block(dev, match, 9);
-
w1_write_8(dev, W1_CONVERT_TEMP);
while (tm) {
@@ -193,8 +188,7 @@ static ssize_t w1_therm_read_bin(struct
flush_signals(current);
}
- if (!w1_reset_bus (dev)) {
- w1_write_block(dev, match, 9);
+ if (!w1_reset_select_slave(sl)) {
w1_write_8(dev, W1_READ_SCRATCHPAD);
if ((count = w1_read_block(dev, rom, 9)) != 9) {
@@ -205,7 +199,6 @@ static ssize_t w1_therm_read_bin(struct
if (rom[8] == crc && rom[0])
verdict = 1;
-
}
}
next prev parent reply other threads:[~2005-09-08 22:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-05 21:44 [GIT PATCH] I2C patches for 2.6.13 Greg KH
2005-09-06 19:09 ` [lm-sensors] " Jean Delvare
2005-09-08 22:22 ` [PATCH] W1: w1_netlink: New init/fini netlink callbacks Greg KH
2005-09-08 22:22 ` [PATCH] w1: Detouching bug fixed Greg KH
2005-09-08 22:22 ` [PATCH] w1: Fixed 64bit compilation warning Greg KH
2005-09-08 22:22 ` [PATCH] w1: hotplug support Greg KH
2005-09-08 22:22 ` [PATCH] W1: Sync with w1/ds9490 tree Greg KH
2005-09-08 22:22 ` [PATCH] w1: Added add/remove slave callbacks Greg KH
2005-09-08 22:22 ` [PATCH] w1: Added inline functions on top of container_of() Greg KH
2005-09-08 22:22 ` Greg KH [this message]
2005-09-08 22:22 ` [PATCH] w1_ds2433: Added crc16 protection and read caching Greg KH
2005-09-08 22:22 ` [PATCH] lib/crc16: added crc16 algorithm Greg KH
2005-09-08 22:22 ` [PATCH] w1: Decreased debug level Greg KH
2005-09-08 22:22 ` [PATCH] w1: Added DS2433 driver Greg KH
2005-09-08 22:22 ` [PATCH] w1: Added DS2433 driver - family id update Greg KH
2005-09-08 22:22 ` [PATCH] w1: added private family data into w1_slave strucutre Greg KH
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=11262181611117@kroah.com \
--to=gregkh@suse.de \
--cc=greg@kroah.com \
--cc=johnpol@2ka.mipt.ru \
--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