Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5225139pxb; Mon, 15 Feb 2021 13:12:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAVl+0mvXmtkTLnxVgBoB0yUQzAvAlYcvT6reGBrgs6Je908QEAuxHiT+snGsdkwfk+hig X-Received: by 2002:a05:6402:190a:: with SMTP id e10mr17774796edz.110.1613423565680; Mon, 15 Feb 2021 13:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613423565; cv=none; d=google.com; s=arc-20160816; b=eBFnIVkC//PJHNnASb4qgeC6rGABfxm0NAZx2KmuLmRjky0NY8be2O52RfCxA9Gni9 Jnj1QlYyFJemk8R1qltFa/ntW1ONyK3pLlu4JzUuvqefZBje4rhdbBqwoRp7L4b2i4hZ BkkTv7e4BclvKvEXQGIvpXlRB1j8Hlt5OoXQLbSf0FKVtRBFd/c6rv3/g4HPrbPQR8uh +HRdPlJxlle58F53WvRb5O2ZyLQKQ4ddplt0cV3Ub692cxj00mi9tQK9LwVuqSyWC3S1 aoBxjpB/Wd8OgFzZ9Rh/5MaeDWugBAa7nV1aIWZ7hwodx2V7xK6rGFIUxBjA+MXEybz5 VzfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ou8P1Li7E2gyeKtwfnYhdaQdgF2O0F8yVAbqRLCEDE8=; b=sLxgNRYhWAbAiep0ileD13SbLxK2z0+zfTuu58Ar9QBR+vnoZzBWI0jOTMjwwosD1N 6GliZ4BUHAQzuQqUxFX93paCRJy25b6VmjXuRaycAl6YlEylgso3BHrbYYMMCn+EZDFQ 20mzuMfTyTQW/yCnJLT47HYgKbyrusNeoPU2sdrCG+EVU66JLZe+aKXQmakAEAVNwVHk eW2R4Vq84OIiYhcVc2Lj5+4yVx/dikrmoMH/Z78vRT7qA0PE69R0LaSyGatPbYtTtlZe r7d2wFZI0KyWXQFlFy3ny0ulSIJRNfJIzcCzoeCoHNuX/m5aQki+YdYq4/DrRscZrtqQ dE9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@beagleboard-org.20150623.gappssmtp.com header.s=20150623 header.b=E1IHFqJB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si12868300ejy.545.2021.02.15.13.12.20; Mon, 15 Feb 2021 13:12:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@beagleboard-org.20150623.gappssmtp.com header.s=20150623 header.b=E1IHFqJB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbhBOVKp (ORCPT + 99 others); Mon, 15 Feb 2021 16:10:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229717AbhBOVKm (ORCPT ); Mon, 15 Feb 2021 16:10:42 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65C36C06178A for ; Mon, 15 Feb 2021 13:09:52 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id ba1so4383015plb.1 for ; Mon, 15 Feb 2021 13:09:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ou8P1Li7E2gyeKtwfnYhdaQdgF2O0F8yVAbqRLCEDE8=; b=E1IHFqJBAhABl3o3qXIIXC/7j+N9OPZcNtf8P1Afsfz8RvG/bSRLhSEjRBA/9S5w7q jhCC+F3CB0G3LAGdmylE3Re7XOYvLpxv+1/u/Q7Hzg788gaxaEYCUgJl2yS4ttaMEBfs ll1VfIwhczN1r8mZRJ0nEdy2UJou7RY4Hg7XCOKkSAJak7CUv2s6F8LZqEKUH7vRv/8J tiTq8E28dH96z7IfrRSSbsL+7aAj/qXeVK3LiTDZr6K9zsQq2r0JWR5gDA+s4aF9+Ufx FctwvHyMrokBS8KEGb/HQrEUqGZAi6+ozPHHV7YObpTsxlvSa/iGFMesmuZBJLGgLL1H 2i8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ou8P1Li7E2gyeKtwfnYhdaQdgF2O0F8yVAbqRLCEDE8=; b=AOqVe3mZfz5H8iCR+w3UDXdHdDoC2xTX63o+V/3VL0z1ILdGskRtX+qcNCZscgyyYh MtM01IDcnN9MHTm8ABERS/gGPdmwQuyEaUT9Wg1FZm7zYBdfpYRPEmfxDVy9THhbnG+w t7q9le+XnE1D2zom/QUXp+pEZTyH46TtY0OiHG55ZuqdjERPGxW0XqX0EguAoncZFNHT 8ukCHh/HkyVapiwakun88RCWnYOiNIEb3K7BvLeAE6CmDQ5Ymui1158REj+P5f3usjs7 YYTxffXLZdrC5vVP0i9+TnbWcbC5dTVErt29uBPKeGvw43h4pCCeJ2IcABeujyyzBsnb pCvQ== X-Gm-Message-State: AOAM5330GIJCklX8NdIPB2dH3iPmJBwTxPdtU2CnMhzOLFZPzP72TqCv LosRGF/2smQmeAkcLFhwhwAW4A== X-Received: by 2002:a17:90a:de8d:: with SMTP id n13mr477375pjv.136.1613423391915; Mon, 15 Feb 2021 13:09:51 -0800 (PST) Received: from x1 ([2601:1c0:4701:ae70:7fd3:1922:5d5d:c85b]) by smtp.gmail.com with ESMTPSA id n1sm3308579pgi.78.2021.02.15.13.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 13:09:51 -0800 (PST) Date: Mon, 15 Feb 2021 13:09:49 -0800 From: Drew Fustini To: Andy Shevchenko Cc: Linus Walleij , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , Tony Lindgren , Alexandre Belloni , Geert Uytterhoeven , Pantelis Antoniou , Jason Kridner , Robert Nelson , Joe Perches , Dan Carpenter Subject: Re: [PATCH v5 2/2] pinctrl: pinmux: Add pinmux-select debugfs file Message-ID: <20210215210949.GA1012667@x1> References: <20210212223015.727608-1-drew@beagleboard.org> <20210212223015.727608-3-drew@beagleboard.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 15, 2021 at 09:04:20PM +0200, Andy Shevchenko wrote: > On Sat, Feb 13, 2021 at 12:30 AM Drew Fustini wrote: > > > > Add "pinmux-select" to debugfs which will activate a function and group > > when "" are written to the file. The write > > The non-standard way of showing parameters, I would write that as > " ". Sorry for your comments, but I don't understand what you mean by this one. I think we wrote "" " the same way, no? > > > operation pinmux_select() handles this by checking that the names map to > > valid selectors and then calling ops->set_mux(). > > > > The existing "pinmux-functions" debugfs file lists the pin functions > > registered for the pin controller. For example: > > > > function: pinmux-uart0, groups = [ pinmux-uart0-pins ] > > function: pinmux-mmc0, groups = [ pinmux-mmc0-pins ] > > function: pinmux-mmc1, groups = [ pinmux-mmc1-pins ] > > function: pinmux-i2c0, groups = [ pinmux-i2c0-pins ] > > function: pinmux-i2c1, groups = [ pinmux-i2c1-pins ] > > function: pinmux-spi1, groups = [ pinmux-spi1-pins ] > > Format this... > > > To activate function pinmux-i2c1 and group pinmux-i2c1-pins: > > > > echo "pinmux-i2c1 pinmux-i2c1-pins" > pinmux-select > > ...and this with two leading spaces (for example) to make sure that > people will understand that these lines are part of the example. Ok, thanks. > > ... > > > drivers/pinctrl/pinmux.c | 99 ++++++++++++++++++++++++++++++++++++++++ > > Still needs a documentation update. There is no documentation for any of the existing pinctrl debugfs files. I was planning to do this as part of a seperate patch, but I can make it part of this series instead. > > ... > > > + const char *usage = > > + "usage: echo ' ' > pinmux-select"; > > This is quite unusual to have in the kernel. Just return an error > code, everything else should be simply documented. > > ... > > > + if (len > PINMUX_SELECT_MAX) { > > > + dev_err(pctldev->dev, "write too big for buffer"); > > Noisy, the user will get an error code and interpret it properly. > So, please drop them all. Otherwise it would be quite easy to exhaust > kernel buffer with this noise and lost the important messages. > > > + return -EINVAL; > > To achieve the above, this rather should be -ENOMEM. > > > + } Thanks, I will remove the usage message and change the return value. > > ... > > > + gname = strchr(fname, ' '); > > + if (!gname) { > > + dev_err(pctldev->dev, usage); > > + ret = -EINVAL; > > + goto free_buf; > > + } > > + *gname++ = '\0'; > > I was thinking about this again and I guess we may allow any amount of > spaces in between and any kind of (like newline or TAB). > So, taking above into consideration the code may look like this: > > /* Take the input and remove leading and trailing spaces of entire buffer */ > fname = strstrip(buf); > /* Find a separator, i.e. a space character */ > for (gname = fname; !isspace(gname); gname++) > if (*gname == '\0') > return -EINVAL; > /* Replace separator with %NUL to terminate first word */ > *gname = '\0'; > /* Drop space characters between first and second words */ > gname = skip_spaces(gname + 1); > if (*gname == '\0') > return -EINVAL; > > But please double check the logic. > > ... Thanks for the example code. I'll test it out. > > > +free_buf: > > exit_free_buf: > Ok, thanks. > > + kfree(buf); > > + > > + return ret; > > +} > > -- > With Best Regards, > Andy Shevchenko