Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6161716yba; Thu, 11 Apr 2019 13:25:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTFkOmPvJ8Hw6moYjKZTu97qMjaFQR82vdsCA4wN26hT3nJL5aQC7x9gwUErtEgkW8D3V7 X-Received: by 2002:a63:fd49:: with SMTP id m9mr49452821pgj.16.1555014310709; Thu, 11 Apr 2019 13:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555014310; cv=none; d=google.com; s=arc-20160816; b=VN14vO9Ri7IMGHIvZn5kTiKvPkjZORPOkhP4LELiJPSnpWuNefpX4u2Xtf6VemxWF2 Fax8ygV+0HPz7QHGjFYmJ+EwQG4kEBMACbdwI4Cyc/NYoc4pIiasbw3fCU97wHL/KEfA dvm3cOGDbhZnOP5FQhwY+xai0WmuEQAapM84bmylI6u0Wqc2pRiuYU5cMWKLEYgFNibZ YdpDqeWPqIiL9xg/iJAZTBIByspFehpii2987KtU/RzY5kjvdTjY1g+UOKtun8E5kWSI EwWQRukfZWuU37y5nh7I2/n3NjU5efVdtC2gFyuwmf8mcIrZRzKNfxqzC2nFtW+DkKYe 1JKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:message-id:to:cc:subject :from:references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=wf0mygmqholMjyAPRmJ9oosHKNXD3rvzRtoAKnPCGnI=; b=lq0rPuiRVkyIB6noGjt8haihMmKxEEUxWt2JfQUaw36osRcFUq5zyQQ0BWlO184JF9 OJYQy0j3Ry0A/oYM5t0EvRZbKJZxdVd8w07Zndm03Zey4gQNsFkX64EXCkWJ9iNkn4fa 7VM71woRZa8U8pk1Ju9Q+YaDdvkV/JrS1d2OlC9faWP74wI6mKpEqgZWsKh/k+aRbRf7 QC4fSHnDx25hOBoO3FUz+R5AgUO6l4YE3A1KkSUUxKRdK76AvppxQEG8Vcm9COKpSVaV fraXngJN9s7G7wqGnzZc4lcFRvz0OQ2IXLuVIdhhKMoICSeFdyouB0hvBSveMbVAm7zM Fgsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jXpd0l71; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cl1si13401726plb.77.2019.04.11.13.24.55; Thu, 11 Apr 2019 13:25:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jXpd0l71; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726755AbfDKUYN (ORCPT + 99 others); Thu, 11 Apr 2019 16:24:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:48616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726630AbfDKUYN (ORCPT ); Thu, 11 Apr 2019 16:24:13 -0400 Received: from localhost (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1441C206B7; Thu, 11 Apr 2019 20:24:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555014252; bh=gpogGmmjDMsYMAnr0syGisErvEABGcnbj3Zuests78o=; h=In-Reply-To:References:From:Subject:Cc:To:Date:From; b=jXpd0l71cWiHhH/ePeTTKlHRfqVSxeBZGJM6K8dDgf6FCc+90ZQeA5zfD4mm6SQk0 V8g25CeQNqaMotjxQy0cXPNmCPLJ6BajjPGLiXPzSXJ1eGDhY14d9Ae8alx4GHvAO2 zAnQW1nxmLmywZ9vSE7sOpetDCJFtmZe9XWxj2UY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <20190305050546.23431-1-weiyi.lu@mediatek.com> <20190305050546.23431-10-weiyi.lu@mediatek.com> From: Stephen Boyd Subject: Re: [PATCH v5 8/9] clk: mediatek: Add MT8183 clock support Cc: Matthias Brugger , Stephen Boyd , Rob Herring , James Liao , Fan Chen , linux-arm Mailing List , lkml , "moderated list:ARM/Mediatek SoC support" , linux-clk@vger.kernel.org, srv_heupstream , stable@vger.kernel.org To: Nicolas Boichat , Weiyi Lu Message-ID: <155501425125.20095.3209997665406275606@swboyd.mtv.corp.google.com> User-Agent: alot/0.8 Date: Thu, 11 Apr 2019 13:24:11 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Nicolas Boichat (2019-03-08 06:46:01) >=20 > > > + > > > +#define GATE_AUDIO0(_id, _name, _parent, _shift) \ > > > + GATE_MTK(_id, _name, _parent, &audio0_cg_regs, _shift, \ > > > + &mtk_clk_gate_ops_no_setclr) >=20 > This macro (or variants that end up being equivalent) is repeated 103 > times in drivers/clk/mediatek/*. We can probably do better. My > suggestion is to do something like this: > #define GATE_MTK_CLK(reg, _id, _name, _parent, _shift) \ > GATE_MTK(_id, _name, _parent, ®##_cg_regs, _shift, \ > &mtk_clk_gate_ops_setclr_inv) >=20 > and use GATE_MTK_CLK(audio0, ...) in the gate clock arrays. Feel free to send patches. >=20 > > > +static int clk_mt8183_audio_probe(struct platform_device *pdev) > > > +{ > > > + struct clk_onecell_data *clk_data; > > > + int r; > > > + struct device_node *node =3D pdev->dev.of_node; > > > + > > > + clk_data =3D mtk_alloc_clk_data(CLK_AUDIO_NR_CLK); > > > + > > > + mtk_clk_register_gates(node, audio_clks, ARRAY_SIZE(audio_clk= s), > > > + clk_data); > > > + > > > + r =3D of_clk_add_provider(node, of_clk_src_onecell_get, clk_d= ata); > > > + if (r) > > > + return r; > > > + > > > + r =3D devm_of_platform_populate(&pdev->dev); > > > + if (r) > > > + of_clk_del_provider(node); > > > + > > > + return r; > > > +} >=20 > This (almost exact) function is now repeated 33 times in > drivers/clk/mediatek, I think it's really time for a cleanup... Maybe > there should be a common helper in clk-gate.c (or another file, not > sure), that fetches the clocks (and number of clocks from .data field > in the structure below). >=20 Yeah that would be great. I only tried to fix the problem where mtk has this duplicate code that probes platform drivers and finds things from it. See my branch on clk.git https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-mtk-of-p= lat-probe