From patchwork Wed Mar 20 18:49:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 160727 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp627452jan; Wed, 20 Mar 2019 11:52:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFGnMli94PvkpIOATYE3njOavLDLnZPLN3NxrTqo33EcGdiEcLlEVldleY6l/4E5gu2iTV X-Received: by 2002:a17:902:e68e:: with SMTP id cn14mr9529109plb.67.1553107951953; Wed, 20 Mar 2019 11:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553107951; cv=none; d=google.com; s=arc-20160816; b=hhU1h6vAy05n0jRSq8xQRgN9tDWQfo+DSt7ppqPdLQt6GMBBhnm4EN0VPtL0+uumnA fiIJEunXr2o9D9UG54ufzEsAIl51CLfs1WKYkElrDyULfRlFMPGZQUC0AodKFU2vfcd3 Kz8LwaYHrmQP3lVwvWRfHb904YXAOFcw8EasVwUyk7d0zqM8QMqYpEyhFEJXFv23nwAq nt9Jlkpei9Ibz/p8tbE3ZBgpFBOL0DbAuSlIld1hMKVIRzEURi75ibaVuVIch3zYviUJ ZS07kp2Jf1xSdbvAtU0g6Vw747rN8dgUKt3e7M+D6/9Pvp+sEM2+ZQ3ZUD18tnzu7FIS Lz2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=BTP7rtpDLwTWW1seMzs0ICR2JzFa4zfvh3vevJfFYP0=; b=p23Ql72m6L9yDxVtpgeJ0qHbDiG3e+uL7VSL5x2kI59bfKkI7GBlLFmBOUSl/m8y9x 7QBfllYy1e3rxPcf44LjrxaZShd1io5th7Q/AWMIc5rPrWajqQHSKc6NvFS8ihayCNyy YcTORBE6buC25Nn1W8yOFonwdEuq+YSHMZInvQqOYpq7PjZfpOO4ClLWmK2peyO6Otlk QP64LwviNFSJJtE607+kUfN33+pYj9Jg6XD0RwTDFhryjhA2+JIOJ+rXC/YvD2QHCl5n VlvmtQiVnXnOvrgTXZgALBReNMZLJ4u3ckHAUWM21d+NX86j1iy1/yFw1AHRtw+ZamS5 2U0w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t37si2229289pgl.137.2019.03.20.11.52.31; Wed, 20 Mar 2019 11:52:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727834AbfCTSwa (ORCPT + 31 others); Wed, 20 Mar 2019 14:52:30 -0400 Received: from foss.arm.com ([217.140.101.70]:44808 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727492AbfCTSuP (ORCPT ); Wed, 20 Mar 2019 14:50:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 58691174E; Wed, 20 Mar 2019 11:50:14 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D2D183F59C; Wed, 20 Mar 2019 11:50:12 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, coresight@lists.linaro.org, mike.leach@linaro.org, robert.walker@arm.com, Suzuki K Poulose , Mathieu Poirier Subject: [PATCH 03/25] coresight: replicator: Prepare for merging with dynamic-replicator Date: Wed, 20 Mar 2019 18:49:20 +0000 Message-Id: <1553107783-3340-4-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553107783-3340-1-git-send-email-suzuki.poulose@arm.com> References: <1553107783-3340-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As a preparatory step to merge the separate drivers for static and dynamic replicators, annotate the static replicator specific details. Also refactor the probe routine to make it generic in order to merge the drivers easily. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-replicator.c | 62 +++++++++++++--------- 1 file changed, 36 insertions(+), 26 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index feac983..43cbcf1 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -56,58 +56,68 @@ static const struct coresight_ops replicator_cs_ops = { .link_ops = &replicator_link_ops, }; -static int replicator_probe(struct platform_device *pdev) +static int replicator_probe(struct device *dev) { - int ret; - struct device *dev = &pdev->dev; + int ret = 0; struct coresight_platform_data *pdata = NULL; struct replicator_drvdata *drvdata; struct coresight_desc desc = { 0 }; - struct device_node *np = pdev->dev.of_node; + struct device_node *np = dev->of_node; if (np) { pdata = of_get_coresight_platform_data(dev, np); if (IS_ERR(pdata)) return PTR_ERR(pdata); - pdev->dev.platform_data = pdata; + dev->platform_data = pdata; } drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; - drvdata->dev = &pdev->dev; - drvdata->atclk = devm_clk_get(&pdev->dev, "atclk"); /* optional */ + drvdata->dev = dev; + drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */ if (!IS_ERR(drvdata->atclk)) { ret = clk_prepare_enable(drvdata->atclk); if (ret) return ret; } - pm_runtime_get_noresume(&pdev->dev); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - platform_set_drvdata(pdev, drvdata); + + dev_set_drvdata(dev, drvdata); desc.type = CORESIGHT_DEV_TYPE_LINK; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT; desc.ops = &replicator_cs_ops; - desc.pdata = pdev->dev.platform_data; - desc.dev = &pdev->dev; + desc.pdata = dev->platform_data; + desc.dev = dev; drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { ret = PTR_ERR(drvdata->csdev); - goto out_disable_pm; + goto out_disable_clk; } - pm_runtime_put(&pdev->dev); + pm_runtime_put(dev); - return 0; - -out_disable_pm: - if (!IS_ERR(drvdata->atclk)) +out_disable_clk: + if (ret && !IS_ERR_OR_NULL(drvdata->atclk)) clk_disable_unprepare(drvdata->atclk); - pm_runtime_put_noidle(&pdev->dev); - pm_runtime_disable(&pdev->dev); + return ret; +} + +static int static_replicator_probe(struct platform_device *pdev) +{ + int ret; + + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + ret = replicator_probe(&pdev->dev); + + if (ret) { + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + } return ret; } @@ -139,18 +149,18 @@ static const struct dev_pm_ops replicator_dev_pm_ops = { replicator_runtime_resume, NULL) }; -static const struct of_device_id replicator_match[] = { +static const struct of_device_id static_replicator_match[] = { {.compatible = "arm,coresight-replicator"}, {} }; -static struct platform_driver replicator_driver = { - .probe = replicator_probe, +static struct platform_driver static_replicator_driver = { + .probe = static_replicator_probe, .driver = { .name = "coresight-replicator", - .of_match_table = replicator_match, + .of_match_table = static_replicator_match, .pm = &replicator_dev_pm_ops, .suppress_bind_attrs = true, }, }; -builtin_platform_driver(replicator_driver); +builtin_platform_driver(static_replicator_driver);