From patchwork Thu Apr 25 19:52:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 162889 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2364566jan; Thu, 25 Apr 2019 12:56:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqw30Rq1rT70H2M3kkD7oVdMR+INDGzpKqH8NGPxcKLic6wSu4HPN3P2HqBa/pk4Xu2lNx3v X-Received: by 2002:a62:e411:: with SMTP id r17mr42332853pfh.127.1556222162508; Thu, 25 Apr 2019 12:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556222162; cv=none; d=google.com; s=arc-20160816; b=cNfSX8+sFvVXr867ATGRq7WUKODG/bZYKRyw+aizM8/Uo+rIfA77InCbppPqPQgllt sGVQainR8u2m67dO1N3Pa98UAQmibPJg6GnrlPvf5PivUJ/e+/8itkKm71/o9j5OL4zx 6Oj4YlCn+rVrCUycncyNAsQIQoftktx9sDYjk4NvG59IidtO076Nizyh8d41M8Vs0cIk 6FFtQBw7FLL3s5b8vtk724q6Ng2XMKT+h7nWnKlvec8dPShCgEsN7DLGIvwdYFxM8fE+ gQmGN8i5wJKE6CY6wJxMaAemDeBKYcZL/vffTqWy8lbYTfhXX5lVaOOxUEO/0hxRPt3S NxFg== 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:dkim-signature; bh=bgGGBhw0+vDHwgRg8Lg3/ie77JvSZeI8JjKHAU8cgFw=; b=huLMxpi2ocK7KZfFwHrV/PFWYHSDc/gU5Pxueq/AwtMPo7BiP/Hbq0iEQSrH9cdvfm n2xpOWHjJf4UEaB0942JyBALdjTNyaC18jp25hvo0bgN3tYlN/Mu8/rnhA831GR2cEav NnnaWu3xQsS6vHBpbTMmOXES1XzLCpDm31KeSxOt4IaKquMLMIlciXz+craNMaEj5unY u2OXTgjkC2gRfmxN0TsTjA7t+fK3UE7cB1A2Zp1/jXwtVSxbKuZUtVwc96kjZVQJbKOr y6JmmqaoH1LpCiLdacDUORydXa7V0l7GtdGwW3la6k96ZA1TWNk5zdLIxXIPtfLZvYFN WeDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CPnCXH5w; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si21224974pgv.195.2019.04.25.12.56.02; Thu, 25 Apr 2019 12:56:02 -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=@linaro.org header.s=google header.b=CPnCXH5w; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388006AbfDYT4B (ORCPT + 30 others); Thu, 25 Apr 2019 15:56:01 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38454 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387648AbfDYTxU (ORCPT ); Thu, 25 Apr 2019 15:53:20 -0400 Received: by mail-pf1-f195.google.com with SMTP id 10so438549pfo.5 for ; Thu, 25 Apr 2019 12:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bgGGBhw0+vDHwgRg8Lg3/ie77JvSZeI8JjKHAU8cgFw=; b=CPnCXH5wv5s81Bmkz/8nI8XhRVwekiRbWHgD9nnyYlY2/Jec/MMGJZzKpHhvCa00rI eyW8G9UkqbFo7R81IWY66MsHBgyZRS06wgiuLqMmRpE5kKgnKbgmP5PDL2VTWwdNxjwo 2Q1STDGyQQAohFPmQWIC8+Q7YvgX/WGjV1NI69pMCwL5jChkrtwnDtaTpOikhBGgnOHC BuVyvJ10bWA4DX3f1+pA2zySpnmjbnRDpIXqECoLBBOLLPR2lEyl9R+Bt9lKcYjTimxH rfzhVbXOGMaixnTIu+caylqN183Uw9n36xNK2OlMt0psyOSe3vfLFGsLBSD6FTNtairq 0rhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bgGGBhw0+vDHwgRg8Lg3/ie77JvSZeI8JjKHAU8cgFw=; b=Wl/FezMeOtUk5R2+P8DFdXYeNA91nsH8mcPjkcU4qVRNdZc8EJh44EUcq5IHXLUcHo mP63WugzFLMNXUDLtM0hZsochi7LPBw6WcKm7tG6orIEe613a1jLDPcGsdVTEAF7pku8 d6AOZq2MOQH9xoGr4dxFDhjYE8H/5dO8iDMojon02cZmTfllVlg9FdtHAIkquVvMEVIT CLPREkuHo9iMVUHmDZzbElt0epOOdp3vK+F1VMVtj19yDlfXYSiEPqqMCeYCxHgJ3QD5 duXtUX4Rg8My21idiEGXt2ojC4m93GsctEXNLHcAy91ztq756ncOAFml+IdZevyq1ONN C6Mw== X-Gm-Message-State: APjAAAXkZWcegiXQTyfmUbAP7BwFqUNvp1uNlViQyNnfmsw818IarNKg MqRw7R2MrweHy6/MxyRVfYzbUg== X-Received: by 2002:a63:cd50:: with SMTP id a16mr20239491pgj.394.1556221998950; Thu, 25 Apr 2019 12:53:18 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id t64sm47261961pfa.86.2019.04.25.12.53.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 12:53:18 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/32] coresight: replicator: Prepare for merging with dynamic-replicator Date: Thu, 25 Apr 2019 13:52:43 -0600 Message-Id: <20190425195310.31562-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190425195310.31562-1-mathieu.poirier@linaro.org> References: <20190425195310.31562-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suzuki K Poulose 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 Signed-off-by: Mathieu Poirier --- .../coresight/coresight-replicator.c | 62 +++++++++++-------- 1 file changed, 36 insertions(+), 26 deletions(-) -- 2.17.1 diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index feac98315471..43cbcf1e7be8 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);