예제 #1
0
/*
	this two functions are used by i2c slave core to get data by the specific i2c slave device
	or send data to it to feed i2c master's need.

	@mod: async(1) or sync(0) mode.
*/
int i2c_slave_device_read(i2c_slave_device_t *device, int num, u8 *data)
{
	int read_num, read_total = 0;
	int step = 1000;
	u8 *read_buf = data;
	printk(KERN_INFO "%s: device id=%d, num=%d\n", __func__, device->id,
	       num);
	read_num = i2c_slave_rb_consume(device->receive_buffer, num, read_buf);
	read_total += read_num;
	read_buf += read_num;
	step--;
	while ((read_total < num) && step) {
		set_current_state(TASK_INTERRUPTIBLE);
		schedule_timeout(HZ / 10);
		if (!signal_pending(current)) {
		} else {
			 /*TODO*/ break;
		}
		read_num =
		    i2c_slave_rb_consume(device->receive_buffer,
					 num - read_total, read_buf);
		num -= read_num;
		read_buf += read_num;
		step--;
	}
	return read_total;
}
예제 #2
0
int i2c_slave_device_consume(i2c_slave_device_t *device, int num, u8 *data)
{
	return i2c_slave_rb_consume(device->send_buffer, num, data);
}