question about drivers/gpu/drm/i915/dvo_ch7xxx.c
Julia Lawall
julia.lawall at lip6.fr
Sat Oct 6 06:20:19 PDT 2012
Hello,
I am looking at introducing some macros for i2c_msg initialization, and
Ryan Mallon suggested that sometimes it could be useful to at the same
time replace explicit lengths with the size of the associated buffer. But
in some cases the sizes are not the same. An example is as follows, in
drivers/gpu/drm/i915/dvo_ch7xxx.c:
static bool ch7xxx_readb(struct intel_dvo_device *dvo, int addr, uint8_t
*ch)
{
struct ch7xxx_priv *ch7xxx = dvo->dev_priv;
struct i2c_adapter *adapter = dvo->i2c_bus;
u8 out_buf[2];
u8 in_buf[2];
struct i2c_msg msgs[] = {
{
.addr = dvo->slave_addr,
.flags = 0,
.len = 1,
.buf = out_buf,
},
{
.addr = dvo->slave_addr,
.flags = I2C_M_RD,
.len = 1,
.buf = in_buf,
}
};
out_buf[0] = addr;
out_buf[1] = 0;
if (i2c_transfer(adapter, msgs, 2) == 2) {
*ch = in_buf[0];
return true;
};
if (!ch7xxx->quiet) {
DRM_DEBUG_KMS("Unable to read register 0x%02x from %s:%02x.\n",
addr, adapter->name, dvo->slave_addr);
}
return false;
}
The buffers both have size 2, but only one byte is asked to be read or
written. Is there any need for the buffers to have size 2 in this case?
Unrelatedly, is it correct that ch has type uint8_t and out_buf and in_buf
have type u8?
julia
More information about the dri-devel
mailing list