Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

w1_therm: Retries: remove old code add CRC

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.

Signed-off-by: David Stevenson <david@avoncliff.com>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

David Stevenson and committed by
Greg Kroah-Hartman
867ff988 e5279ff6

+6 -19
+6 -19
drivers/w1/slaves/w1_therm.c
··· 45 45 static int w1_strong_pullup = 1; 46 46 module_param_named(strong_pullup, w1_strong_pullup, int, 0); 47 47 48 - static u8 bad_roms[][9] = { 49 - {0xaa, 0x00, 0x4b, 0x46, 0xff, 0xff, 0x0c, 0x10, 0x87}, 50 - {} 51 - }; 52 48 53 49 static ssize_t w1_therm_read(struct device *device, 54 50 struct device_attribute *attr, char *buf); ··· 164 168 return 0; 165 169 } 166 170 167 - static int w1_therm_check_rom(u8 rom[9]) 168 - { 169 - int i; 170 - 171 - for (i=0; i<sizeof(bad_roms)/9; ++i) 172 - if (!memcmp(bad_roms[i], rom, 9)) 173 - return 1; 174 - 175 - return 0; 176 - } 177 171 178 172 static ssize_t w1_therm_read(struct device *device, 179 173 struct device_attribute *attr, char *buf) ··· 180 194 181 195 memset(rom, 0, sizeof(rom)); 182 196 183 - verdict = 0; 184 - crc = 0; 185 - 186 197 while (max_trying--) { 198 + 199 + verdict = 0; 200 + crc = 0; 201 + 187 202 if (!w1_reset_select_slave(sl)) { 188 203 int count = 0; 189 204 unsigned int tm = 750; ··· 236 249 } 237 250 } 238 251 239 - if (!w1_therm_check_rom(rom)) 252 + if (verdict) 240 253 break; 241 254 } 242 255 ··· 247 260 if (verdict) 248 261 memcpy(sl->rom, rom, sizeof(sl->rom)); 249 262 else 250 - dev_warn(device, "18S20 doesn't respond to CONVERT_TEMP.\n"); 263 + dev_warn(device, "Read failed CRC check\n"); 251 264 252 265 for (i = 0; i < 9; ++i) 253 266 c -= snprintf(buf + PAGE_SIZE - c, c, "%02x ", sl->rom[i]);