All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: daniel.vetter@ffwll.ch, Ryan Mallon <rmallon@gmail.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: question about drivers/gpu/drm/i915/dvo_ch7xxx.c
Date: Sun, 7 Oct 2012 22:45:18 +0200	[thread overview]
Message-ID: <20121007204518.GC7352@phenom.ffwll.local> (raw)
In-Reply-To: <alpine.DEB.2.02.1210061514090.2017@localhost6.localdomain6>

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

  reply	other threads:[~2012-10-07 20:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-30  7:33 [PATCH 0/3] introduce macros for i2c_msg initialization Julia Lawall
2012-09-30  7:33 ` [PATCH 3/3] drivers/media/tuners/fc0011.c: " Julia Lawall
2012-10-01 22:36   ` Ryan Mallon
2012-10-06 13:20     ` question about drivers/gpu/drm/i915/dvo_ch7xxx.c Julia Lawall
2012-10-07 20:45       ` Daniel Vetter [this message]
2012-10-02  5:31   ` [PATCH 3/3] drivers/media/tuners/fc0011.c: introduce macros for i2c_msg initialization Julia Lawall
2012-09-30  7:35 ` [PATCH 0/3] " Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121007204518.GC7352@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=julia.lawall@lip6.fr \
    --cc=rmallon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.