Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1676754pxj; Wed, 19 May 2021 11:13:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzk47mfwNYREFgoH3Gj0K2Sc2f/X6n9d5TjmvShfo4h1ZlCvUzTD1ZxWxscx+eTxIxogdKO X-Received: by 2002:a05:6602:2416:: with SMTP id s22mr767071ioa.15.1621448027732; Wed, 19 May 2021 11:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621448027; cv=none; d=google.com; s=arc-20160816; b=LKEWyula/diOl9iRceiEpQ8GpbiTOrTnMqKRDC3NanbXlIDmLb//qYrWQWgIlH8UWL CAyii/pWxHYRva3l13L1MoIxZTBmpyi8hGAoD3Xsl0Irvhcm35kzuw7wucY8IsHpOlhn 14D9mONdfEKkaVLSv6TXSNbXeXo0LySYIV6dmbNLyEe+bLncMJJg1+gkjqOpyv8J8rlh fY/+UTjgILHNb+AGlfBa6D2AJ0CFfTyzi3ldDv9mlr6bR+JgY5u4rvqqrOtcV/033ivP 5CudCEFRsijo1jDQTBlokMQKESyQ8ZegWz7DmpEl39Vpmo3HunHXZx7FGizXQY1Ws2RL pyNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:importance:content-transfer-encoding :mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:dkim-signature; bh=FOfLt10TiVeFqvn1BJZhsE1iqcFUNQB5NLaFkxVKwVA=; b=JYnbuQ5lTNOXLxUNyvSNdP0qvuPCRf3TPBl6aXs6oR4dU0dUYjwISo+JFH+g4qBLcs DZPKbIG01L6OVOfPLyKjb1UnnXP6DKTJHO4lujxO821y3bvpjWY4n2nUf3J3sJNEHF/u dxKcibfDmjLt0iO8SP79yyW7SiQhQdGi8cR+50sjILw2kkAhtD02qkVCHcAmoTmLryu7 MTjhr6cWd6PHDmktMrdz4D08sN4JhCZsnIZQOSC/adNzxYqQoPFNbTjbruAHP8/f0qjP 6QBNLq/1H8T8cqRzdeh4c3+ZZB2ktWfXJcSc3p9ZSw9nUIMc05YxnREkgvtzxuhAp1bs c8dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@libero.it header.s=s2021 header.b=lv2X90aU; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=libero.it Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si431275ilg.93.2021.05.19.11.13.35; Wed, 19 May 2021 11:13:47 -0700 (PDT) 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=@libero.it header.s=s2021 header.b=lv2X90aU; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=libero.it Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349692AbhERN7N (ORCPT + 99 others); Tue, 18 May 2021 09:59:13 -0400 Received: from smtp-34-i2.italiaonline.it ([213.209.12.34]:55639 "EHLO libero.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S243387AbhERN7C (ORCPT ); Tue, 18 May 2021 09:59:02 -0400 Received: from oxapps-15-086.iol.local ([10.101.8.96]) by smtp-34.iol.local with ESMTPA id j0EAlzpEt5WrZj0EAlFIwH; Tue, 18 May 2021 15:57:42 +0200 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=libero.it; s=s2021; t=1621346262; bh=FOfLt10TiVeFqvn1BJZhsE1iqcFUNQB5NLaFkxVKwVA=; h=From; b=lv2X90aUi2sKd8HFgWQFQkl3E9rShMmXYo1Ghvv5h3yrUcggkbcIF0OGqJUSG7sLa EeZzeI/jYFAfwR6yg333GRYGeUZFRYxTWZlYVi9Q+ZjCH6GKZrLdsHmnxViCV/7NkR +mOjzN5g8SbC1nxzknr8MZ9T/N/Y9lOyTcGsCKtSTHnY2VbJBwu8/qyCuB/xZiGVSY 7IaYmE/LVckCc8KhvuOf7G1eIcfZu9uTEYeq+p48x5oYBYdn9Ig4Dqftww6bnmaCBx yTPhmJycCzywr0ZaIH1gjPylClOppNaE1f3EIsTgrG6mxRefJYxTuisPAsby0AXYZr RnkKBPQsGVIPw== X-CNFS-Analysis: v=2.4 cv=W4/96Tak c=1 sm=1 tr=0 ts=60a3c7d6 cx=a_exe a=v+7NFWUWLAxl90LcUtT8lA==:117 a=C-c6dMTymFoA:10 a=IkcTkHD0fZMA:10 a=vesc6bHxzc4A:10 a=pGLkceISAAAA:8 a=L547Ubht33J7g4M119MA:9 a=QEXdDO2ut3YA:10 Date: Tue, 18 May 2021 15:57:42 +0200 (CEST) From: Dario Binacchi To: Andy Shevchenko , Drew Fustini Cc: Linux Kernel Mailing List , Linus Walleij , "open list:GPIO SUBSYSTEM" Message-ID: <1735504854.166374.1621346262270@mail1.libero.it> In-Reply-To: References: <20210516135531.2203-1-dariobin@libero.it> <20210516135531.2203-2-dariobin@libero.it> Subject: Re: [PATCH 1/2] pinctrl: core: configure pinmux from pins debug file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.3-Rev34 X-Originating-IP: 185.33.57.41 X-Originating-Client: open-xchange-appsuite x-libjamsun: vSw5ATWRP9oT0Qm6yB5B4Ld4Nh24bik/ x-libjamv: WOw4sxia8EU= X-CMAE-Envelope: MS4xfIGqIQFtXe9VbPscHiVEg1wVgwd9KALqR6oww1JdTJpem7gLAUeeXckAiFXJ9+RUz0TXIF6fXViM9EgLgxgSczwan9tqRLcmRgHuxwqvDsKbHG0QZR+4 4OKnrihaxNp9nNCNzKngEA5JTVXEDzQP0faTfrDnCDlA3Cmvz6zBnD+ppGdvlveWlGaxUNUiLB42tKo1gaBl+gsLr/zfsrexUol+xJryHO5JdF6iAYGSzhJ0 +QS2F6+Mcw3lJSHQCHJ/wVym8nsuGRL20f2ATJ1N40xNUC2X+1BqUIv+1cglh1Dels+SzaiBQk7Ec6Qocq8wE0yEeVA/1sYTMZBpU9cJiUIGTWBWm5rp2r+D RBMScHxO Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > Il 17/05/2021 22:02 Andy Shevchenko ha scritto: > > > On Sun, May 16, 2021 at 7:43 PM Dario Binacchi wrote: > > > > The MPUs of some architectures (e.g AM335x) must be in privileged > > operating mode to write on the pinmux > > pinmux is not pin configuration. You need to rethink the approach. > > > registers. In such cases, where > > writes will not work from user space, now it can be done from the pins > > debug file if the platform driver exports the pin_dbg_set() helper among > > the registered operations. > > Drew, is it similar to what you are trying to achieve? > > ... > > > +static ssize_t pinctrl_pins_write(struct file *file, > > + const char __user *user_buf, size_t count, > > + loff_t *ppos) > > +{ > > + struct seq_file *s = file->private_data; > > + struct pinctrl_dev *pctldev = s->private; > > + const struct pinctrl_ops *ops = pctldev->desc->pctlops; > > + char buf[32]; > > + char *c = &buf[0]; > > + char *token; > > + int ret, buf_size; > > + unsigned int i, pin; > > + > > + if (!ops->pin_dbg_set) > > + return -EFAULT; > > + > > + /* Get userspace string and assure termination */ > > + buf_size = min(count, sizeof(buf) - 1); > > + if (copy_from_user(buf, user_buf, buf_size)) > > + return -EFAULT; > > + > > + buf[buf_size] = 0; > > Can't you use strncpy_from_user() ? Ok, I'll use strncpy_from_user() in the next version of the patch > > > > + token = strsep(&c, " "); > > > + if (kstrtouint(token, 0, &pin)) > > + return -EINVAL; > > Don't shadow an error code. You are right > > > + for (i = 0; i < pctldev->desc->npins; i++) { > > + if (pin != pctldev->desc->pins[i].number) > > + continue; > > Hmm... I don't get this. Why is it needed? I want to make sure the pin is managed Thanks and regards, Dario > > > + ret = ops->pin_dbg_set(pctldev, pin, c); > > + if (ret) > > + return ret; > > + > > + return count; > > + } > > + > > + return -EINVAL; > > +} > > ... > > > - debugfs_create_file("pins", 0444, > > + debugfs_create_file("pins", 0644, > > device_root, pctldev, &pinctrl_pins_fops); > > Why is it in this file? > > > > -- > With Best Regards, > Andy Shevchenko