Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3901781ybl; Mon, 9 Dec 2019 02:00:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyi5LhB2pzIszXHUEpszuf3F9QTcmGysBmm+M265RcCS64GPRIa7T98dAo4yM+eZf8PtpMg X-Received: by 2002:aca:5785:: with SMTP id l127mr22655792oib.168.1575885611769; Mon, 09 Dec 2019 02:00:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575885611; cv=none; d=google.com; s=arc-20160816; b=hr3R1lmqqj04WD5VzJamnrXSSNQaEpX5U67QJ9NW6Gb9Yg1ZOSGqNbgGlOtPMSl8DI XE6FlJVkCr2dVEEXq5u0vzowcFULcpGFFscHepOOSqChUg8EOb6jscVYzsqmUDWbQ5CS RC8NTvUQCmoGdYQ0ML90ieZ03Qu2xUugvLAW8KF3MpGoLfCxKHgo7fvjtPzohXiTd7W8 f8Howh4wSHYPix5oIZQljBeR0vaCWBbnuipavkDcTNdQtHNiMp2+hFYVukYreXivjUhi i1qoDnbIy9Y9TaOmxovODnyqGdmP5P1I0pUb2Nu5bd1jiu474RC52M5IY4rylNJDLwX3 qI5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=lzTDv+dO/+PM01LtSLVu+2d7e5hNtzv5BMs+YE1AfZM=; b=hIXZlAtkf3jFjKEfM4I4IH8ESYvwcZ1Rand/oEGoiJ8Zof7lZwxxfkAilkDEaqWqMo QPt1I92Lx/+JlI76o6X9Az1MZO/6wl3+JZwMlwRa7xQGz/rqodNxWRwNRBRWEyo9EQ0M h+Cu5EY5Rm2EA4XudgLPxshnATWGShZY5zjOrEZ3wt5u7X0eCRTyuI2dI7g4lJVMwMdM b/mL70JZx17Hin9o0b20e2gG+fYc6CMQcqoMQlLLbfZaoJiwoYWQw0At3GI4V2rvbc9G bHdsbJYRtE0YsqGgmI5vcubDY3sjOi4/XpChJ/oaA3kl4rRy2DI98h5ckgaT1nZ4r1gB 1HIA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 19si11399534oiq.128.2019.12.09.01.59.58; Mon, 09 Dec 2019 02:00:11 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727329AbfLIJ6l (ORCPT + 99 others); Mon, 9 Dec 2019 04:58:41 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:40646 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbfLIJ6k (ORCPT ); Mon, 9 Dec 2019 04:58:40 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 16FCF28BB97 Subject: Re: [resend PATCH v6 06/12] clk: mediatek: mt2701: switch mmsys to platform device probing To: matthias.bgg@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, ck.hu@mediatek.com, p.zabel@pengutronix.de, airlied@linux.ie, mturquette@baylibre.com, sboyd@kernel.org, ulrich.hecht+renesas@gmail.com, laurent.pinchart@ideasonboard.com Cc: sean.wang@mediatek.com, sean.wang@kernel.org, rdunlap@infradead.org, wens@csie.org, hsinyi@chromium.org, frank-w@public-files.de, drinkcat@chromium.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, mbrugger@suse.com References: <20191207224740.24536-1-matthias.bgg@kernel.org> <20191207224740.24536-7-matthias.bgg@kernel.org> From: Enric Balletbo i Serra Message-ID: Date: Mon, 9 Dec 2019 10:58:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20191207224740.24536-7-matthias.bgg@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Matthias, On 7/12/19 23:47, matthias.bgg@kernel.org wrote: > From: Matthias Brugger > > Switch probing for the MMSYS to support invocation to a plain > paltform device. The driver will be probed by the DRM subsystem. > > Signed-off-by: Matthias Brugger > --- > drivers/clk/mediatek/clk-mt2701-mm.c | 41 ++++++++++++++++++++-------- > 1 file changed, 29 insertions(+), 12 deletions(-) > > diff --git a/drivers/clk/mediatek/clk-mt2701-mm.c b/drivers/clk/mediatek/clk-mt2701-mm.c > index 054b597d4a73..4a9433c2b2b8 100644 > --- a/drivers/clk/mediatek/clk-mt2701-mm.c > +++ b/drivers/clk/mediatek/clk-mt2701-mm.c > @@ -4,14 +4,20 @@ > * Author: Shunli Wang > */ > > +#include > #include > #include > +#include > > #include "clk-mtk.h" > #include "clk-gate.h" > > #include > > +struct clk_mt2701_mm_priv { > + struct clk_onecell_data *clk_data; > +}; > + > static const struct mtk_gate_regs disp0_cg_regs = { > .set_ofs = 0x0104, > .clr_ofs = 0x0108, > @@ -79,23 +85,25 @@ static const struct mtk_gate mm_clks[] = { > GATE_DISP1(CLK_MM_TVE_FMM, "mm_tve_fmm", "mm_sel", 14), > }; > > -static const struct of_device_id of_match_clk_mt2701_mm[] = { > - { .compatible = "mediatek,mt2701-mmsys", }, > - {} > -}; > - > static int clk_mt2701_mm_probe(struct platform_device *pdev) > { > - struct clk_onecell_data *clk_data; > int r; > - struct device_node *node = pdev->dev.of_node; > + struct device_node *node = pdev->dev.parent->of_node; > + struct clk_mt2701_mm_priv *private; > + > + private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL); > + if (!private) > + return -ENOMEM; > > - clk_data = mtk_alloc_clk_data(CLK_MM_NR); > + private->clk_data = mtk_alloc_clk_data(CLK_MM_NR); > + > + platform_set_drvdata(pdev, private); > > mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks), > - clk_data); > + private->clk_data); > > - r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); > + r = of_clk_add_provider(node, of_clk_src_onecell_get, > + private->clk_data); > if (r) > dev_err(&pdev->dev, > "could not register clock provider: %s: %d\n", > @@ -104,12 +112,21 @@ static int clk_mt2701_mm_probe(struct platform_device *pdev) > return r; > } > > +static int clk_mt2701_mm_remove(struct platform_device *pdev) > +{ > + struct clk_mt2701_mm_priv *private = platform_get_drvdata(pdev); > + I think that private->clk_data->clks is also kallocated and need to be freed? But I think that the best approach now is to switch to use devm allocations in clk-mt2701-mm.c and this remove function will not be needed. > + kfree(private->clk_data); > + > + return 0; > +} > + > static struct platform_driver clk_mt2701_mm_drv = { > .probe = clk_mt2701_mm_probe, > + .remove = clk_mt2701_mm_remove, > .driver = { > .name = "clk-mt2701-mm", > - .of_match_table = of_match_clk_mt2701_mm, > }, > }; > > -builtin_platform_driver(clk_mt2701_mm_drv); > +module_platform_driver(clk_mt2701_mm_drv); >