From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: question about drivers/gpu/drm/i915/dvo_ch7xxx.c Date: Sun, 7 Oct 2012 22:45:18 +0200 Message-ID: <20121007204518.GC7352@phenom.ffwll.local> References: <1348990388-7413-1-git-send-email-Julia.Lawall@lip6.fr> <1348990388-7413-4-git-send-email-Julia.Lawall@lip6.fr> <506A1AFE.7050202@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by gabe.freedesktop.org (Postfix) with ESMTP id 35BA69E81E for ; Sun, 7 Oct 2012 13:44:21 -0700 (PDT) Received: by mail-wi0-f169.google.com with SMTP id hq4so2403805wib.0 for ; Sun, 07 Oct 2012 13:44:20 -0700 (PDT) Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Julia Lawall Cc: daniel.vetter@ffwll.ch, Ryan Mallon , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Sat, Oct 06, 2012 at 03:20:19PM +0200, Julia Lawall wrote: > 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? Looks like the 2 byte buffer size is just copy&pasta from writeb. And didn't find any other reson for it not being just 1 byte. > Unrelatedly, is it correct that ch has type uint8_t and out_buf and > in_buf have type u8? drm/i915 is totally confused about the (u)int*_t vs (s|t)* types unfortunately. I think nowadays we mostly stick to _t typedefs, but not consistenly. Yours, Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch