/* 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. */
int w1_reset_select_slave(struct w1_slave *sl)
/* 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. */
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, };
		u64 rn = le64_to_cpu(*((u64*)&sl->reg_num));
		memcpy(&match[1], &rn, 8);
		w1_write_block(sl->master, match, 9);
	}
	return 0;
}