Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6523413ybi; Wed, 5 Jun 2019 02:14:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5NLGcF6KpVyND3jbK6uoprNeGRaEtpGixmp/MWhB1eaj+TsJ0wcjwh7KVa7wgyiEKgBBn X-Received: by 2002:a63:fa4a:: with SMTP id g10mr2978718pgk.147.1559726082453; Wed, 05 Jun 2019 02:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559726082; cv=none; d=google.com; s=arc-20160816; b=DOIXIZXK7MF6ZQBNcbWp9EzqSRj8ocyaB+XsK2p0J2cHBp6Y5Qlkxke6D6GQxW4qSP o33AfSFqr3aTGJ/jpP2yRkShafSwvi56T6uktfy6yKACAfckTV/2bVEl4Y5NuHdDie6N 3vifVdgpFFM2A3lkXf6twnkIvn1xhtCDN9ABmD9TnGPRKjfoRk/Ge0IoAxsEKBWE11k4 EmTGyHMO/ZxcgEi6AoeA4DPqncpraap53bteCZE/p1ByV6K+0qk8Wjxw2a+EfWcRr1fu 0DvLZLlZn3Mdjc4hzQDSJJ5EZHAZ30zOOHeu9oFw98COdWpJZpaqSUHEMnk5Jbu6uPv0 WACw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=dCaDpb3auqRXbSrH4RTG3g9kxZ/wRrhXBCwcOUxOBbw=; b=fbWyFNanN8YQzFVMH6GHLSeCBdLoDa5uK+geiidRpbsrbBPjVBcVX8OsNkVnfhYnaP h6yj2iAjWouG/KfQKAW0EcerEwsjX+0vshK/eB8ZeM50zsLW/LEY1rk5VFGWh0a0thKF An9EgjOkd16c4gVIXQiTgC0JROhDKMPuDh0j/geB9x13IvxV0GwURnlitPgorH8fejG1 nxHTqD7iJPgEliDvB5rMmIJ+RFFzjtajNDcTHXH17brrbdwNlkEzmaRZsm+8/i4XuEfx H5ISeoqdlsO97WccRSmgxBXWsMXe/UlK+X3NMagnj7DeMa8jAj0bJWzg7SHgw6LRuj35 YVSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=uLZDtOX6; 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=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4si1768057pfz.30.2019.06.05.02.14.26; Wed, 05 Jun 2019 02:14:42 -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=@samsung.com header.s=mail20170921 header.b=uLZDtOX6; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727072AbfFEJNI (ORCPT + 99 others); Wed, 5 Jun 2019 05:13:08 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:41761 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726964AbfFEJNF (ORCPT ); Wed, 5 Jun 2019 05:13:05 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190605091304euoutp01242fd0b36355948263cc5bfe4cd047fb~lQoTaPZG62439724397euoutp01P for ; Wed, 5 Jun 2019 09:13:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190605091304euoutp01242fd0b36355948263cc5bfe4cd047fb~lQoTaPZG62439724397euoutp01P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1559725984; bh=dCaDpb3auqRXbSrH4RTG3g9kxZ/wRrhXBCwcOUxOBbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uLZDtOX6VzHhs0ngxlvXpoH+QARcGpwNrwUNIwmwY3wfd5wGToasLiGNyxAo40cRF cVI+3iEsQSaYlvBfLR0Dgif5C5seINtLoqLnmypCrD4MwBKhWEihnxz8Qy/67jVihY eoEzL4qEGSGa+I2tvXJmr0XWTFcIjHG1zCnwDO5Y= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190605091303eucas1p21879409895da6e6a59b072a64f617dfe~lQoSylXgG2735527355eucas1p2f; Wed, 5 Jun 2019 09:13:03 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 9E.64.04325.F9787FC5; Wed, 5 Jun 2019 10:13:03 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20190605091302eucas1p2b2a959c0889666e95bd727381bceab24~lQoR95t8y2502725027eucas1p2W; Wed, 5 Jun 2019 09:13:02 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190605091302eusmtrp27a4f331736299163b9914d514e88d067~lQoRuQx1G2473824738eusmtrp2T; Wed, 5 Jun 2019 09:13:02 +0000 (GMT) X-AuditID: cbfec7f5-b75ff700000010e5-38-5cf7879f2b1c Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 15.30.04146.E9787FC5; Wed, 5 Jun 2019 10:13:02 +0100 (BST) Received: from AMDC3778.DIGITAL.local (unknown [106.120.51.20]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190605091301eusmtip1141ea85bf51ce59463aa07a5397a0b9c~lQoRALZQM2955629556eusmtip1h; Wed, 5 Jun 2019 09:13:01 +0000 (GMT) From: Lukasz Luba To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: b.zolnierkie@samsung.com, krzk@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, cw00.choi@samsung.com, kyungmin.park@samsung.com, m.szyprowski@samsung.com, s.nawrocki@samsung.com, myungjoo.ham@samsung.com, kgene@kernel.org, l.luba@partner.samsung.com, willy.mh.wolff.ml@gmail.com Subject: [PATCH v4 2/5] drivers: devfreq: events: change matching code during probe Date: Wed, 5 Jun 2019 11:12:33 +0200 Message-Id: <20190605091236.24263-3-l.luba@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190605091236.24263-1-l.luba@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEKsWRmVeSWpSXmKPExsWy7djPc7rz27/HGDzbIWKxccZ6VovrX56z Wsw/co7Vov/xa2aL8+c3sFucbXrDbnGrQcZi0+NrrBaXd81hs/jce4TRYsb5fUwWa4/cZbdY ev0ik8XtxhVsFq17j7BbHH7Tzmrx7cQjRgdBjzXz1jB67Jx1l91j06pONo/NS+o9Dr7bw+TR t2UVo8fnTXIB7FFcNimpOZllqUX6dglcGRN37WcrmCpd0bxoK3sD4yKxLkYODgkBE4kL87m7 GLk4hARWMEqcOveOCcL5wijR/G8ZM4TzmVHiwpx1TDAd066IQsSXM0psP/mNEa7j47PDYEVs AnoSO1YVdjFycogILGaU+HY4CqSGWWAZk8S+5k9MIAlhgVCJnldtjCA2i4CqxINLN5lBbF4B e4n1pw6D1UgIyEus3nCAGWQmp4CDxOYZ9iBzJATOsUtcOnqQGaLGRWLSly3sELawxKvjMLaM xP+d86HmFEs09C5khLBrJB73z4WqsZ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KK3MPMUpwMCuJ8Cbe/hIjxJuSWFmVWpQfX1Sak1p8iNEU6KaJzFKiyfnA CM4riTc0NTS3sDQ0NzY3NrNQEuftEDgYIySQnliSmp2aWpBaBNPHxMEp1cDotffjhqitmpaL b9989n9yacG+mK5zryfe95+5lfNLw7Ozobfza5gzja1kfgYrf46aP7fu35EbDBktM2yDfnxd dHSH3Ro+1y87pi/IfJi22dj6a+29sGlKCy6Y/2DXLtqkvPF9sK7KS66Zns2Gl6vPvZDafdy6 o7lTUmd73T0t502F3s2VAhFMSizFGYmGWsxFxYkAtUOFLagCAAA= X-CMS-MailID: 20190605091302eucas1p2b2a959c0889666e95bd727381bceab24 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190605091302eucas1p2b2a959c0889666e95bd727381bceab24 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190605091302eucas1p2b2a959c0889666e95bd727381bceab24 References: <20190605091236.24263-1-l.luba@partner.samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch changes the way how the 'ops' gets populated for different device versions. The matching function now uses 'of_device_id' in order to identify the device type. Signed-off-by: Lukasz Luba Signed-off-by: Chanwoo Choi --- drivers/devfreq/event/exynos-ppmu.c | 38 +++++++++++++++++++---------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/devfreq/event/exynos-ppmu.c b/drivers/devfreq/event/exynos-ppmu.c index c2ea94957501..17f3c86a6f00 100644 --- a/drivers/devfreq/event/exynos-ppmu.c +++ b/drivers/devfreq/event/exynos-ppmu.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,11 @@ #include "exynos-ppmu.h" +enum exynos_ppmu_type { + EXYNOS_TYPE_PPMU, + EXYNOS_TYPE_PPMU_V2, +}; + struct exynos_ppmu_data { struct clk *clk; }; @@ -36,6 +42,7 @@ struct exynos_ppmu { struct regmap *regmap; struct exynos_ppmu_data ppmu; + enum exynos_ppmu_type ppmu_type; }; #define PPMU_EVENT(name) \ @@ -483,31 +490,23 @@ static const struct devfreq_event_ops exynos_ppmu_v2_ops = { static const struct of_device_id exynos_ppmu_id_match[] = { { .compatible = "samsung,exynos-ppmu", - .data = (void *)&exynos_ppmu_ops, + .data = (void *)EXYNOS_TYPE_PPMU, }, { .compatible = "samsung,exynos-ppmu-v2", - .data = (void *)&exynos_ppmu_v2_ops, + .data = (void *)EXYNOS_TYPE_PPMU_V2, }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, exynos_ppmu_id_match); -static struct devfreq_event_ops *exynos_bus_get_ops(struct device_node *np) -{ - const struct of_device_id *match; - - match = of_match_node(exynos_ppmu_id_match, np); - return (struct devfreq_event_ops *)match->data; -} - static int of_get_devfreq_events(struct device_node *np, struct exynos_ppmu *info) { struct devfreq_event_desc *desc; - struct devfreq_event_ops *event_ops; struct device *dev = info->dev; struct device_node *events_np, *node; int i, j, count; + const struct of_device_id *of_id; events_np = of_get_child_by_name(np, "events"); if (!events_np) { @@ -515,7 +514,6 @@ static int of_get_devfreq_events(struct device_node *np, "failed to get child node of devfreq-event devices\n"); return -EINVAL; } - event_ops = exynos_bus_get_ops(np); count = of_get_child_count(events_np); desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL); @@ -523,6 +521,12 @@ static int of_get_devfreq_events(struct device_node *np, return -ENOMEM; info->num_events = count; + of_id = of_match_device(exynos_ppmu_id_match, dev); + if (of_id) + info->ppmu_type = (enum exynos_ppmu_type)of_id->data; + else + return -EINVAL; + j = 0; for_each_child_of_node(events_np, node) { for (i = 0; i < ARRAY_SIZE(ppmu_events); i++) { @@ -540,7 +544,15 @@ static int of_get_devfreq_events(struct device_node *np, continue; } - desc[j].ops = event_ops; + switch (info->ppmu_type) { + case EXYNOS_TYPE_PPMU: + desc[j].ops = &exynos_ppmu_ops; + break; + case EXYNOS_TYPE_PPMU_V2: + desc[j].ops = &exynos_ppmu_v2_ops; + break; + } + desc[j].driver_data = info; of_property_read_string(node, "event-name", &desc[j].name); -- 2.17.1