linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC: proposal for new i2c.h macro to initialize i2c address lists on the fly
@ 2009-06-06 13:00 Hans Verkuil
  2009-06-06 17:32 ` Trent Piepho
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Hans Verkuil @ 2009-06-06 13:00 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-media-u79uwXL29TY76Z2rM5mHXA

Hi all,

For video4linux we sometimes need to probe for a single i2c address. 
Normally you would do it like this:

static const unsigned short addrs[] = {
	addr, I2C_CLIENT_END
};

client = i2c_new_probed_device(adapter, &info, addrs);

This is a bit awkward and I came up with this macro:

#define V4L2_I2C_ADDRS(addr, addrs...) \
        ((const unsigned short []){ addr, ## addrs, I2C_CLIENT_END })

This can construct a list of one or more i2c addresses on the fly. But this 
is something that really belongs in i2c.h, renamed to I2C_ADDRS.

With this macro we can just do:

client = i2c_new_probed_device(adapter, &info, I2C_ADDRS(addr));

Comments?

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG Telecom

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-06-09 14:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-06 13:00 RFC: proposal for new i2c.h macro to initialize i2c address lists on the fly Hans Verkuil
2009-06-06 17:32 ` Trent Piepho
2009-06-06 22:20 ` Jon Smirl
     [not found]   ` <9e4733910906061520o7b0b2858wf4530cf672b1adc9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-06-06 23:23     ` hermann pitton
2009-06-07  6:35   ` Hans Verkuil
     [not found]     ` <200906070835.46989.hverkuil-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org>
2009-06-07 13:25       ` Jon Smirl
     [not found]         ` <9e4733910906070625i74477c9ma422b061eb61449d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-06-07 13:30           ` Jon Smirl
     [not found]             ` <9e4733910906070630i1ffcb821xb912f5ea662c7bef-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-06-07 13:38               ` Hans Verkuil
2009-06-07 20:00         ` Andy Walls
     [not found]           ` <1244404831.3141.33.camel-xioobY1GIEhKttHedORAlB2eb7JE58TQ@public.gmane.org>
2009-06-07 21:01             ` hermann pitton
     [not found] ` <200906061500.49338.hverkuil-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org>
2009-06-06 21:38   ` Mauro Carvalho Chehab
2009-06-08 12:39   ` Jean Delvare
2009-06-09 13:04     ` Hans Verkuil
     [not found]       ` <200906091504.37330.hverkuil-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org>
2009-06-09 14:54         ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).