Return-path: Received: from relais.videotron.ca ([24.201.245.36]:57738 "EHLO relais.videotron.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761562Ab0HFQxt (ORCPT ); Fri, 6 Aug 2010 12:53:49 -0400 MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Date: Fri, 06 Aug 2010 12:53:47 -0400 (EDT) From: Nicolas Pitre To: Russell King - ARM Linux Cc: Ohad Ben-Cohen , Linus Walleij , Vitaly Wool , Kalle Valo , Pandita Vikram , Tony Lindgren , linux-wireless@vger.kernel.org, Roger Quadros , linux-mmc@vger.kernel.org, San Mehat , Chikkature Rajashekar Madhusudhan , Luciano Coelho , linux-omap@vger.kernel.org, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, Ido Yariv Subject: Re: [PATCH v2 03/20] mmc: support embedded data field in mmc_host In-reply-to: <20100806144605.GA21015@n2100.arm.linux.org.uk> Message-id: References: <20100804114147.GB6852@n2100.arm.linux.org.uk> <20100806144605.GA21015@n2100.arm.linux.org.uk> Sender: linux-wireless-owner@vger.kernel.org List-ID: On Fri, 6 Aug 2010, Russell King - ARM Linux wrote: > On Fri, Aug 06, 2010 at 01:02:24PM +0300, Ohad Ben-Cohen wrote: > > We have Russell's suggestion which is nice and simple, but it has the > > 1 device limitation. > > You could make it generic by doing something like this: > > #define set_device_data(name, type, index, data) \ > ({ \ > extern void __set_device_data(const char *, int, void *, size_t); \ > BUILD_BUG_ON(!__same_type(type, *data)); \ > __set_device_data(name ":" #type, index, data, sizeof(type)); \ > }) > > #define get_device_data(name, type, index) ({ \ > extern void *__get_device_data(const char *, int); \ > type *__ptr = __get_device_data(name ":" #type, index); \ > __ptr; }) > > And now we have something that takes a string and index to use as a lookup > key in some kind of list - and it's typesafe (because the lookup key is > dependent on the stringified type.) > > But... at this point I feel that we're getting too complicated, and will > get shouted at to use something like DT which already solves this problem. DT is not generally available yet. A simple interim solution would still be worth it. Nicolas