Loading drivers/w1/w1_io.c +24 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,29 @@ void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb) 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); Loading @@ -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); drivers/w1/w1_io.h +1 −0 Original line number Diff line number Diff line Loading @@ -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 */ drivers/w1/w1_therm.c +2 −9 Original line number Diff line number Diff line Loading @@ -176,15 +176,10 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si 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) { Loading @@ -193,8 +188,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si 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) { Loading @@ -205,7 +199,6 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si if (rom[8] == crc && rom[0]) verdict = 1; } } Loading Loading
drivers/w1/w1_io.c +24 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,29 @@ void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb) 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); Loading @@ -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);
drivers/w1/w1_io.h +1 −0 Original line number Diff line number Diff line Loading @@ -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 */
drivers/w1/w1_therm.c +2 −9 Original line number Diff line number Diff line Loading @@ -176,15 +176,10 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si 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) { Loading @@ -193,8 +188,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si 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) { Loading @@ -205,7 +199,6 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si if (rom[8] == crc && rom[0]) verdict = 1; } } Loading