public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: david <david@avoncliff.com>
To: Evgeniy Polyakov <zbr@ioremap.net>,
	greg@kroah.com, linux-kernel@vger.kernel.org
Subject: [PATCH] w1_therm:Retries:remove old code add CRC
Date: Mon, 17 Dec 2012 21:13:39 +0000	[thread overview]
Message-ID: <50CF8B03.1070102@avoncliff.com> (raw)

w1_therm includes some obsolete code to detect bad_roms, this is no
longer relevant.
The retry code is only used for this bad_rom test, however there is a
CRC check that detects a bad read, but does not trigger a retry. This
patch removes all the bad_rom code and uses the CRC check to trigger
retries.

Patch is against Raspberry 3.2.27 ( my test hardware) but has also been
tested against 3.7.

David Stevenson   david at avoncliff.com

diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 016dd7d..8166075 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -45,10 +45,6 @@ MODULE_DESCRIPTION("Driver for 1-wire Dallas network
protocol, temperature famil
 static int w1_strong_pullup = 1;
 module_param_named(strong_pullup, w1_strong_pullup, int, 0);

-static u8 bad_roms[][9] = {
-				{0xaa, 0x00, 0x4b, 0x46, 0xff, 0xff, 0x0c, 0x10, 0x87},
-				{}
-			};

 static ssize_t w1_therm_read(struct device *device,
 	struct device_attribute *attr, char *buf);
@@ -159,16 +155,6 @@ static inline int w1_convert_temp(u8 rom[9], u8 fid)
 	return 0;
 }

-static int w1_therm_check_rom(u8 rom[9])
-{
-	int i;
-
-	for (i=0; i<sizeof(bad_roms)/9; ++i)
-		if (!memcmp(bad_roms[i], rom, 9))
-			return 1;
-
-	return 0;
-}

 static ssize_t w1_therm_read(struct device *device,
 	struct device_attribute *attr, char *buf)
@@ -183,10 +169,11 @@ static ssize_t w1_therm_read(struct device *device,

 	memset(rom, 0, sizeof(rom));

-	verdict = 0;
-	crc = 0;
-
 	while (max_trying--) {
+
+		verdict = 0;
+		crc = 0;
+		
 		if (!w1_reset_select_slave(sl)) {
 			int count = 0;
 			unsigned int tm = 750;
@@ -214,7 +201,7 @@ static ssize_t w1_therm_read(struct device *device,
 			}
 		}

-		if (!w1_therm_check_rom(rom))
+		if (verdict)
 			break;
 	}


                 reply	other threads:[~2012-12-17 21:39 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=50CF8B03.1070102@avoncliff.com \
    --to=david@avoncliff.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zbr@ioremap.net \
    /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