Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753889Ab2KMNNs (ORCPT ); Tue, 13 Nov 2012 08:13:48 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:45029 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751643Ab2KMNNr (ORCPT ); Tue, 13 Nov 2012 08:13:47 -0500 MIME-Version: 1.0 In-Reply-To: <1503934.I4tc7K6I6s@percival> References: <38620644.IyR5R8rjKP@percival> <1801189.6J3flQFRCq@percival> <1503934.I4tc7K6I6s@percival> Date: Tue, 13 Nov 2012 14:13:45 +0100 Message-ID: Subject: Re: How about a gpio_get(device *, char *) function? From: Linus Walleij To: Alex Courbot Cc: Stephen Warren , Grant Likely , "devicetree-discuss@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" , Thomas Gleixner Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2198 Lines: 64 On Thu, Nov 8, 2012 at 7:23 AM, Alex Courbot wrote: > On Thursday 08 November 2012 05:24:19 Linus Walleij wrote: >> On Tue, Nov 6, 2012 at 2:33 AM, Alex Courbot wrote: >> > How about, in a first time (and because I'd also like to get the power >> > seqs >> > moving on), a typedef from int to gpio_handle_t and a first implementation >> > of the gpio_handle_*() API that would just call the existing >> > integer-based API (apart from gpio_handle_get())? That way things will >> > not break when we switch to a real handle. >> >> I'm afraid of typedef:ing gpio_handle_t to int because it sort of >> encourages non-handlers to be used mixed with the old integers. >> >> I would prefer to create, e.g. in >> something like: >> >> struct gpio; >> >> struct gpio *gpio_get(struct device *dev, const char *name); >> >> int gpio_get_value(struct gpio *g); >> >> Nothing more! I.e. struct gpio is an opaque cookie, nothing to be known >> about it. > > However these is already a struct gpio declared in linux/gpio.h. Shall the > opaque handler be renamed something like "struct gpioh", or is your idea to > make both APIs mutually exclusive? Basically I'd like the API's to be mutually execlusive. But maybe there is a namespace clash anyway, since the handler code will have to #linclude This is one of the rare cases where I'd maybe like to even #undef gpio in the core code just to be able to mask that defintion of "gpio" with the "gpio" from the new API. I really like the fact that it will bite your hand if you try to use both APIs at once, you could even introduce some #define DO_NOT_INCLUDE_LINUX_GPIO_H in And #define DO_NOT_INCLUDE_GPIO_CONSUMER_H in and then put things like: #ifdef DO_NOT_INCLUDE_LINUX_GPIO_H #error "Trying to use mutually exclusive interfaces" #endif into ... Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/