Lines Matching +full:0 +full:- +full:9 +full:a +full:- +full:f
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * You should have received a copy of the GNU General Public License
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family.");
41 * If it was disabled a parasite powered device might not get the require
42 * current to do a temperature conversion. If it is enabled parasite powered
43 * devices have a better chance of getting the current required.
46 module_param_named(strong_pullup, w1_strong_pullup, int, 0);
48 static u8 bad_roms[][9] = {
49 {0xaa, 0x00, 0x4b, 0x46, 0xff, 0xff, 0x0c, 0x10, 0x87},
61 return device_create_file(&sl->dev, &w1_therm_attr); in w1_therm_add_slave()
66 device_remove_file(&sl->dev, &w1_therm_attr); in w1_therm_remove_slave()
98 struct w1_family *f; member
99 int (*convert)(u8 rom[9]);
103 static inline int w1_DS18B20_convert_temp(u8 rom[9]);
104 static inline int w1_DS18S20_convert_temp(u8 rom[9]);
108 .f = &w1_therm_family_DS18S20,
112 .f = &w1_therm_family_DS1822,
116 .f = &w1_therm_family_DS18B20,
120 .f = &w1_therm_family_DS28EA00,
125 static inline int w1_DS18B20_convert_temp(u8 rom[9]) in w1_DS18B20_convert_temp() argument
131 static inline int w1_DS18S20_convert_temp(u8 rom[9]) in w1_DS18S20_convert_temp() argument
136 return 0; in w1_DS18S20_convert_temp()
138 if (rom[1] == 0) in w1_DS18S20_convert_temp()
139 t = ((s32)rom[0] >> 1)*1000; in w1_DS18S20_convert_temp()
141 t = 1000*(-1*(s32)(0x100-rom[0]) >> 1); in w1_DS18S20_convert_temp()
143 t -= 250; in w1_DS18S20_convert_temp()
144 h = 1000*((s32)rom[7] - (s32)rom[6]); in w1_DS18S20_convert_temp()
151 static inline int w1_convert_temp(u8 rom[9], u8 fid) in w1_convert_temp() argument
155 for (i = 0; i < ARRAY_SIZE(w1_therm_families); ++i) in w1_convert_temp()
156 if (w1_therm_families[i].f->fid == fid) in w1_convert_temp()
159 return 0; in w1_convert_temp()
162 static int w1_therm_check_rom(u8 rom[9]) in w1_therm_check_rom() argument
166 for (i=0; i<sizeof(bad_roms)/9; ++i) in w1_therm_check_rom()
167 if (!memcmp(bad_roms[i], rom, 9)) in w1_therm_check_rom()
170 return 0; in w1_therm_check_rom()
177 struct w1_master *dev = sl->master; in w1_therm_read()
178 u8 rom[9], crc, verdict, external_power; in w1_therm_read()
182 i = mutex_lock_interruptible(&dev->mutex); in w1_therm_read()
183 if (i != 0) in w1_therm_read()
186 memset(rom, 0, sizeof(rom)); in w1_therm_read()
188 verdict = 0; in w1_therm_read()
189 crc = 0; in w1_therm_read()
191 while (max_trying--) { in w1_therm_read()
193 int count = 0; in w1_therm_read()
210 mutex_unlock(&dev->mutex); in w1_therm_read()
213 if (sleep_rem != 0) in w1_therm_read()
214 return -EINTR; in w1_therm_read()
216 i = mutex_lock_interruptible(&dev->mutex); in w1_therm_read()
217 if (i != 0) in w1_therm_read()
221 if (sleep_rem != 0) { in w1_therm_read()
222 mutex_unlock(&dev->mutex); in w1_therm_read()
223 return -EINTR; in w1_therm_read()
230 if ((count = w1_read_block(dev, rom, 9)) != 9) { in w1_therm_read()
232 "returned %u instead of 9.\n", in w1_therm_read()
247 for (i = 0; i < 9; ++i) in w1_therm_read()
248 c -= snprintf(buf + PAGE_SIZE - c, c, "%02x ", rom[i]); in w1_therm_read()
249 c -= snprintf(buf + PAGE_SIZE - c, c, ": crc=%02x %s\n", in w1_therm_read()
252 memcpy(sl->rom, rom, sizeof(sl->rom)); in w1_therm_read()
256 for (i = 0; i < 9; ++i) in w1_therm_read()
257 c -= snprintf(buf + PAGE_SIZE - c, c, "%02x ", sl->rom[i]); in w1_therm_read()
259 c -= snprintf(buf + PAGE_SIZE - c, c, "t=%d\n", in w1_therm_read()
260 w1_convert_temp(rom, sl->family->fid)); in w1_therm_read()
261 mutex_unlock(&dev->mutex); in w1_therm_read()
263 return PAGE_SIZE - c; in w1_therm_read()
270 for (i = 0; i < ARRAY_SIZE(w1_therm_families); ++i) { in w1_therm_init()
271 err = w1_register_family(w1_therm_families[i].f); in w1_therm_init()
276 return 0; in w1_therm_init()
283 for (i = 0; i < ARRAY_SIZE(w1_therm_families); ++i) in w1_therm_fini()
285 w1_unregister_family(w1_therm_families[i].f); in w1_therm_fini()