From: Asier Llano Palacios <a.llano@usyscom.com>
To: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Subject: [PATCH] 1-Wire Dallas in bigendian machines
Date: Mon, 21 Feb 2005 16:04:39 +0100 [thread overview]
Message-ID: <1108998279.4563.10.camel@localhost.localdomain> (raw)
I've been testing the 1-Wire Dallas in a bigendian machine (through a
GPIO) and I've found some problems that can easily addressed with the
provided patch. (inline at the end of the message).
I have a question about the implementation of w1_smem.
In the line 90 of drivers/w1/w1_smem.c.
for (i = 0; i < 9; ++i)
count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]);
I don't see why this loop is execute 9 times when the provided reg_num
is 8 bytes long. I don't understand the purpose of the last byte.
Thank you very much.
--
Asier Llano Palacios <a.llano@usyscom.com>
diff -urP linux-2.6.10/drivers/w1/w1.c
linux-2.6.10-w1-bigendian/drivers/w1/w1.c
--- linux-2.6.10/drivers/w1/w1.c 2004-12-24 22:34:30.000000000 +0100
+++ linux-2.6.10-w1-bigendian/drivers/w1/w1.c 2005-01-28
12:54:39.000000000 +0100
@@ -579,9 +579,10 @@
slave_count++;
}
- if (slave_count == dev->slave_count &&
- rn && ((rn >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn, 7)) {
- w1_attach_slave_device(dev, (struct w1_reg_num *) &rn);
+ if (slave_count == dev->slave_count && rn ) {
+ tmp = cpu_to_le64(rn);
+ if(((rn >> 56) & 0xff) == w1_calc_crc8((u8 *)&tmp, 7))
+ w1_attach_slave_device(dev, (struct w1_reg_num *) &rn);
}
}
}
diff -urP linux-2.6.10/drivers/w1/w1.h
linux-2.6.10-w1-bigendian/drivers/w1/w1.h
--- linux-2.6.10/drivers/w1/w1.h 2004-12-24 22:35:50.000000000 +0100
+++ linux-2.6.10-w1-bigendian/drivers/w1/w1.h 2005-01-28
13:05:47.000000000 +0100
@@ -24,9 +24,17 @@
struct w1_reg_num
{
+#if defined(__LITTLE_ENDIAN_BITFIELD)
__u64 family:8,
id:48,
crc:8;
+#elif defined(__BIG_ENDIAN_BITFIELD)
+ __u64 crc:8,
+ id:48,
+ family:8;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
};
#ifdef __KERNEL__
reply other threads:[~2005-02-21 15:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1108998279.4563.10.camel@localhost.localdomain \
--to=a.llano@usyscom.com \
--cc=johnpol@2ka.mipt.ru \
/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
all inboxes | Powered by JetHome®