question about drivers/gpu/drm/i915/dvo_ch7xxx.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux