Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4465669pxb; Tue, 5 Oct 2021 03:47:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2XRR8TA19LQweKmDZf47PwjVxcW6XZfsZqlSKCj3qdiu0knUGNhfDMjAojfeI3zuuwoo0 X-Received: by 2002:a17:906:a18b:: with SMTP id s11mr24409943ejy.8.1633430861936; Tue, 05 Oct 2021 03:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633430861; cv=none; d=google.com; s=arc-20160816; b=JfQDh+ZS/2Etgnmggpbcrr/INJNcV035zfsV/IQkltDVDt0s1Uj83ybszmpF2Cd+fK +jHYFedQVpKfxc1yCr7Op9xj0LQNnkafMFo5kimGVKLiAIwDEZRyRMs45jPYKr2yeiXO RtIby7+XXoo0X1VoF5T1MsaflucidEEU1gbRVzVUaQpvod/+qY14hVNE1x92+4Dd/UvD Xh/WOhaLv1XdjrRDgwQC1fBagG6r+TcCqUzbyOCmc9w8MRzU7EjltqHy1vIjO0i7jJcc WAnms82ZnaGTKemMDww0FD6XbnsG5YJ04ftirRAIhCqpuuf45I8mDMXucggnb10Q559g yAuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=CgfAA5tuaR0skShOha2ZwCdxx+sB32VR21cf+MP43iA=; b=rzp2PAsMjS9qI20jiJOd7n89oWlE71Q80qlRVDLbieoPpVtuK+kuxw7QHkaHVQjt6C 1xnNpsRA5GiJTnzuaFJEW444+Rd0mRvUP6yV+jDjDNVXoBWyUbcs2I//hBJcABYDUWul iXWxOaWTPA+IwvQhCSayyIcUHGvnr9zX9eImZoXVXNcsRPCrNmlGGcy8J0A00Um0XfuH 4Fw0hELg8s2bwW45DgcahOOTMed1lBRAgX5rzHt+lJrsLzzBXvpi0LpzSnq4hB6M3DXM uhSGGwWLj75/AxbGQ5PA0n4GwY/V4OO2r7tzcVBde0PVNH8iaMAYD8RlxaAP1Z+XrGHU +hcg== ARC-Authentication-Results: i=1; mx.google.com; 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 b13si29886183ede.314.2021.10.05.03.47.18; Tue, 05 Oct 2021 03:47:41 -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; 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 S234158AbhJEKpM (ORCPT + 99 others); Tue, 5 Oct 2021 06:45:12 -0400 Received: from mail-vk1-f180.google.com ([209.85.221.180]:42905 "EHLO mail-vk1-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233576AbhJEKpK (ORCPT ); Tue, 5 Oct 2021 06:45:10 -0400 Received: by mail-vk1-f180.google.com with SMTP id r25so266242vkl.9; Tue, 05 Oct 2021 03:43:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CgfAA5tuaR0skShOha2ZwCdxx+sB32VR21cf+MP43iA=; b=b5O2/bal3QQH1oliV7cKeq4hxlFYmJkqjDIYawaQXQr0pLN0snP23X/t3a5nMSN6wF GLTc6CArRydwBawrfcAgt0XHYZFXpT/a/Zk1augaWH4A6w7cI8Kpjd2mvoEiiHoWyy7G wTI4rFJP4k+v7oKTVN4x0cveD+x6KtPP9pMqcjnA+hLJAyZyYG7TmWRxeGIy1BpVdbnZ UhPZubVU3B6cJEwJy+vTG44JFD94qokO7JvI1fkHd4cNwPJxaMmRy46vt9Xv5VTFV4Fh eTp9F/hiQ+4RR2V+wYZ+cMm4nZe8kvn4gwHRz32g3MaCKvQ1GqDIjOzHpfUMSwd30Pla W/3g== X-Gm-Message-State: AOAM532CgU8FrgxOnHQz5rPz/psM6Sa0fg+s4vUSyXP+IuXydlTQB6st UApemvrOlHumzv1zQ6xIO0ReTD4+wUATWoUUyVA= X-Received: by 2002:a1f:230c:: with SMTP id j12mr19610053vkj.11.1633430599705; Tue, 05 Oct 2021 03:43:19 -0700 (PDT) MIME-Version: 1.0 References: <20210914141939.26410-1-semen.protsenko@linaro.org> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 5 Oct 2021 12:43:08 +0200 Message-ID: Subject: Re: [PATCH] clk: Add clk_set_parent debugfs node To: Sam Protsenko Cc: Michael Turquette , Stephen Boyd , Chanwoo Choi , Sylwester Nawrocki , Krzysztof Kozlowski , Mike Tipton , linux-clk , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sam, On Tue, Oct 5, 2021 at 12:11 PM Sam Protsenko wrote: > On Tue, 14 Sept 2021 at 17:19, Sam Protsenko wrote: > > Useful for testing mux clocks. One can write the index of the parent to > > set into clk_set_parent node, starting from 0. Example > > > > # cat clk_possible_parrents > > dout_shared0_div4 dout_shared1_div4 > > # cat clk_parent > > dout_shared0_div4 > > # echo 1 > clk_set_parent > > # cat clk_parent > > dout_shared1_div4 > > > > Define CLOCK_ALLOW_WRITE_DEBUGFS in drivers/clk/clk.c in order to use > > this feature. > > > > Signed-off-by: Sam Protsenko > > --- > > + Adding more folks for review > > Guys, can you please review this one? Thanks for your patch! > > --- a/drivers/clk/clk.c > > +++ b/drivers/clk/clk.c > > @@ -3214,6 +3214,30 @@ static int current_parent_show(struct seq_file *s, void *data) > > } > > DEFINE_SHOW_ATTRIBUTE(current_parent); > > > > +#ifdef CLOCK_ALLOW_WRITE_DEBUGFS > > +static int clk_set_parent_set(void *data, u64 val) u64 is overkill, num_parents is u8. > > +{ > > + struct clk_core *core = data, *parent; > > + int ret; > > + > > + if (val >= core->num_parents) > > + return -EINVAL; clk_core_get_parent_by_index() called below already checks this. > > + > > + parent = clk_core_get_parent_by_index(core, val); > > + if (IS_ERR_OR_NULL(parent)) > > + return PTR_ERR(parent); > > + > > + clk_prepare_lock(); > > + ret = clk_core_set_parent_nolock(core, parent); > > + clk_prepare_unlock(); > > + > > + return ret; > > +} > > + > > +DEFINE_DEBUGFS_ATTRIBUTE(clk_set_parent_fops, NULL, clk_set_parent_set, > > + "%llu\n"); > > +#endif > > + > > static int clk_duty_cycle_show(struct seq_file *s, void *data) > > { > > struct clk_core *core = s->private; > > @@ -3285,9 +3309,14 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry) > > debugfs_create_file("clk_parent", 0444, root, core, > > ¤t_parent_fops); > > > > - if (core->num_parents > 1) > > + if (core->num_parents > 1) { > > debugfs_create_file("clk_possible_parents", 0444, root, core, > > &possible_parents_fops); > > +#ifdef CLOCK_ALLOW_WRITE_DEBUGFS > > + debugfs_create_file("clk_set_parent", 0200, root, core, > > + &clk_set_parent_fops); > > +#endif Why add a new file, instead of making the existing "clk_parent" file writable, like is done for "clk_rate"? Yes, "clk_parent" prints a name, while you use a parent number, but I guess that can be fixed? Or even both can be accepted? > > + } > > > > if (core->ops->debug_init) > > core->ops->debug_init(core->hw, core->dentry); Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds