From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752171AbdATNgm (ORCPT ); Fri, 20 Jan 2017 08:36:42 -0500 Received: from mga14.intel.com ([192.55.52.115]:59549 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752111AbdATNgh (ORCPT ); Fri, 20 Jan 2017 08:36:37 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,258,1477983600"; d="scan'208";a="1085291215" Date: Fri, 20 Jan 2017 15:36:27 +0200 From: Mika Westerberg To: Linus Walleij Cc: Neil Armstrong , Alexandre Courbot , Andy Shevchenko , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 3/3] pinctrl / gpio: Introduce .set_config() callback for GPIO chips Message-ID: <20170120133627.GK17297@lahna.fi.intel.com> References: <20170119094820.83595-1-mika.westerberg@linux.intel.com> <20170119094820.83595-4-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 20, 2017 at 10:13:05AM +0100, Linus Walleij wrote: > > +static int gpio_set_drive_mode(struct gpio_chip *gc, unsigned offset, > > + enum pin_config_param mode) > > +{ > > + unsigned long config = { PIN_CONF_PACKED(mode, 0) }; > > + > > + return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP; > > +} > > I would name it gpio_set_drive_single_ended() as the open source/open > drain is all we support here. OK. > > if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) { > > /* First see if we can enable open drain in hardware */ > > - if (gc->set_single_ended) { > > - ret = gc->set_single_ended(gc, gpio_chip_hwgpio(desc), > > - LINE_MODE_OPEN_DRAIN); > > - if (!ret) > > - goto set_output_value; > > - } > > + ret = gpio_set_drive_mode(gc, gpio_chip_hwgpio(desc), > > + PIN_CONFIG_DRIVE_OPEN_DRAIN); > > + if (!ret) > > + goto set_output_value; > > Aha I see, so if we fail to set single ended we get to the next step. > Nice. > > > /* Emulate open drain by not actively driving the line high */ > > if (val) > > return gpiod_direction_input(desc); > > } > > (...) > > > - if (gc->set_single_ended) { > > - ret = gc->set_single_ended(gc, gpio_chip_hwgpio(desc), > > - LINE_MODE_OPEN_SOURCE); > > - if (!ret) > > - goto set_output_value; > > - } > > + ret = gpio_set_drive_mode(gc, gpio_chip_hwgpio(desc), > > + PIN_CONFIG_DRIVE_OPEN_SOURCE); > > /* Emulate open source by not actively driving the line low */ > > if (!val) > > return gpiod_direction_input(desc); > > But here the handling seems to be wrong? You still need > the if (!ret) goto set_output_value? Good point. I'll fix that in the next version.