View | Details | Raw Unified | Return to bug 239695 | Differences between
and this patch

Collapse All | Expand All

(-)sys/dev/iicbus/ds1672.c (-15 / +3 lines)
Lines 71-98 Link Here
71
static int
71
static int
72
ds1672_read(device_t dev, uint8_t addr, uint8_t *data, uint8_t size)
72
ds1672_read(device_t dev, uint8_t addr, uint8_t *data, uint8_t size)
73
{
73
{
74
	struct iic_msg msgs[2] = {
74
	return (iicdev_readfrom(dev, addr, data, size, IIC_INTRWAIT));
75
	     { DS1672_ADDR, IIC_M_WR, 1, &addr },
76
	     { DS1672_ADDR, IIC_M_RD, size, data }
77
	};
78
79
	return (iicbus_transfer(dev, msgs, 2));
80
}
75
}
81
76
82
static int
77
static int
83
ds1672_write(device_t dev, uint8_t addr, uint8_t *data, uint8_t size)
78
ds1672_write(device_t dev, uint8_t addr, uint8_t *data, uint8_t size)
84
{
79
{
85
	uint8_t buffer[MAX_IIC_DATA_SIZE + 1];
86
	struct iic_msg msgs[1] = {
87
	     { DS1672_ADDR, IIC_M_WR, size + 1, buffer },
88
	};
89
	
90
	if (size > MAX_IIC_DATA_SIZE)
80
	if (size > MAX_IIC_DATA_SIZE)
91
		return (ENOMEM);
81
		return (ENOMEM);
92
	/* NB: register pointer precedes actual data */
82
	
93
	buffer[0] = addr;
83
	return (iicdev_writeto(dev, addr, data, size, IIC_INTRWAIT));
94
	memcpy(buffer + 1, data, size);
95
	return (iicbus_transfer(dev, msgs, 1));
96
}
84
}
97
85
98
static int
86
static int
(-)sys/dev/iicbus/sy8106a.c (-31 / +2 lines)
Lines 83-124 Link Here
83
static int
83
static int
84
sy8106a_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size)
84
sy8106a_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size)
85
{
85
{
86
	struct sy8106a_softc *sc;
86
	return (iicdev_readfrom(dev, reg, data, size, IIC_INTRWAIT));
87
	struct iic_msg msg[2];
88
89
	sc = device_get_softc(dev);
90
91
	msg[0].slave = sc->addr;
92
	msg[0].flags = IIC_M_WR;
93
	msg[0].len = 1;
94
	msg[0].buf = ®
95
96
	msg[1].slave = sc->addr;
97
	msg[1].flags = IIC_M_RD;
98
	msg[1].len = size;
99
	msg[1].buf = data;
100
101
	return (iicbus_transfer(dev, msg, 2));
102
}
87
}
103
88
104
static int
89
static int
105
sy8106a_write(device_t dev, uint8_t reg, uint8_t val)
90
sy8106a_write(device_t dev, uint8_t reg, uint8_t val)
106
{
91
{
107
	struct sy8106a_softc *sc;
92
	return (iicdev_writeto(dev, reg, &val, sizeof(val), IIC_INTRWAIT));
108
	struct iic_msg msg;
109
	uint8_t buffer[2];
110
111
	sc = device_get_softc(dev);
112
113
	buffer[0] = reg;
114
	buffer[1] = val;
115
116
	msg.slave = sc->addr;
117
	msg.flags = IIC_M_WR;
118
	msg.len = 2;
119
	msg.buf = buffer;
120
121
	return (iicbus_transfer(dev, &msg, 1));
122
}
93
}
123
94
124
static int
95
static int
(-)sys/dev/iicbus/syr827.c (-31 / +2 lines)
Lines 90-131 Link Here
90
static int
90
static int
91
syr827_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size)
91
syr827_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size)
92
{
92
{
93
	struct syr827_softc *sc;
93
	return (iicdev_readfrom(dev, reg, data, size, IIC_INTRWAIT));
94
	struct iic_msg msg[2];
95
96
	sc = device_get_softc(dev);
97
98
	msg[0].slave = sc->addr;
99
	msg[0].flags = IIC_M_WR;
100
	msg[0].len = 1;
101
	msg[0].buf = ®
102
103
	msg[1].slave = sc->addr;
104
	msg[1].flags = IIC_M_RD;
105
	msg[1].len = size;
106
	msg[1].buf = data;
107
108
	return (iicbus_transfer(dev, msg, 2));
109
}
94
}
110
95
111
static int
96
static int
112
syr827_write(device_t dev, uint8_t reg, uint8_t val)
97
syr827_write(device_t dev, uint8_t reg, uint8_t val)
113
{
98
{
114
	struct syr827_softc *sc;
99
	return (iicdev_writeto(dev, reg, &val, sizeof(val), IIC_INTRWAIT));
115
	struct iic_msg msg;
116
	uint8_t buffer[2];
117
118
	sc = device_get_softc(dev);
119
120
	buffer[0] = reg;
121
	buffer[1] = val;
122
123
	msg.slave = sc->addr;
124
	msg.flags = IIC_M_WR;
125
	msg.len = 2;
126
	msg.buf = buffer;
127
128
	return (iicbus_transfer(dev, &msg, 1));
129
}
100
}
130
101
131
static int
102
static int

Return to bug 239695