From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752366AbbIXInc (ORCPT ); Thu, 24 Sep 2015 04:43:32 -0400 Received: from mga03.intel.com ([134.134.136.65]:48329 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751043AbbIXIn2 (ORCPT ); Thu, 24 Sep 2015 04:43:28 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,580,1437462000"; d="scan'208";a="811885046" Date: Thu, 24 Sep 2015 11:43:24 +0300 From: Mika Westerberg To: Olliver Schinagl Cc: Linus Walleij , Grant Likely , "Rafael J. Wysocki" , Alexandre Courbot , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: gpios search behaviour for gpio from _DSD Message-ID: <20150924084324.GK1536@lahna.fi.intel.com> References: <5603A552.9020005@schinagl.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5603A552.9020005@schinagl.nl> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 24, 2015 at 09:25:06AM +0200, Olliver Schinagl wrote: > Hey list, Mika, > > With commit 0d9a693cc86 the following snippet of code was added: > > + /* Try first from _DSD */ > + for (i = 0; i < ARRAY_SIZE(suffixes); i++) { > + if (con_id && strcmp(con_id, "gpios")) { > + snprintf(propname, sizeof(propname), "%s-%s", > + con_id, suffixes[i]); > > and I was wondering why the gpios suffix is singled out. Are we not allowed > to check for all the strings in the suffixes array? Is gpios special or is > gpio simply not allowed. If that strcmp check would be removed, would bad > things happen? We default to "gpios". So if you pass "reset" we actually look for proprerty "reset-gpios". This is the recommend syntax AFAIK. > Also, just to educate myself, isn't relying on left to right parsing > complier specifc? E.g. if con_id is null, we end up passing NULL to strcmp > and atleast for libc can cause segfaults iirc. '&&' is so called short circuit operator so if we already know that con_id is NULL we never evaluate the remaining conditions.