From patchwork Tue Nov 13 17:39:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 10681163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FD8D1759 for ; Tue, 13 Nov 2018 17:42:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02D312AF46 for ; Tue, 13 Nov 2018 17:42:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB3292AFF2; Tue, 13 Nov 2018 17:42:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7887E2AF46 for ; Tue, 13 Nov 2018 17:42:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=x8QMhzQOsAnSv4QYLHZ4KYHQ4HtpBwl2bVumGC0qGYc=; b=D72tB0uiO3Xvd+ VuVp9Dp4R/Ab+QUjMqAmsoiJm+J5UfasJPXlwXmQKyX+ROztkzDqcxOGUlX+DV64pI1Y+5ISGpK4Z DegoRVGqFON/P65ZQ67CQCmXZW//s0SABnuzTMLaWTQOujuZl9Pyn4KmdAevhYOggY4zSiXCVmJ5m g8NgCXxITkenDexp8upn9UySidPkAfnhTSEOEOcpp+Thrcv6jXLe4VB8tNhkq741fIbDG0zaPt7/z lDxbMv6Rrc7D0YqUXvZQz4SqJKM37weMwwg9v4oPpOYVF6E7t3Bx1PFeOyG8VLGcgrQv5O/pRTeha S+Kj6EZrzziwjA6KgZLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMci4-0001Jp-0G; Tue, 13 Nov 2018 17:42:44 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMci1-0001Jf-QO for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 17:42:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6h3yBy6yxBC5/wHBXcPz5P4Ib+Z0R91C8J511DqKqUY=; b=oRIm6ubZ7DJuz3cfeNBUeWHslc gBXRC/Aj+rD7EHorwLaRn8TjA4Q1mRMxaINLTRHDJeZAOYY3aMOXsgUAuGcGIHb+U2qESAkiG1X7n plXmJLj03Hz9MsVpu0tCv3wqAfXukwAl528HjA0mkJ8sdqJ5IzABDJmxBQxQ7/XaR/5btKpEOXNTf ntpR3oQ5TR6xSLOAyCj4YR/GsZ0V+Nl2b1pDPD3x2QtNozHwZIrpYH4FzklHUuQ7BaJ6zzEwXmfGQ aZKzRHx0UveLD0/VIEDwBacH234LPL7TWcVXQ6KX0euJ1YgoSlPi1imH6LTT2E4rEO8Thfisn12Tz 9ffORSlA==; Received: from fllv0015.ext.ti.com ([198.47.19.141]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMchy-0007nW-Jo for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 17:42:39 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id wADHfuFV044751; Tue, 13 Nov 2018 11:41:56 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1542130916; bh=6h3yBy6yxBC5/wHBXcPz5P4Ib+Z0R91C8J511DqKqUY=; h=From:To:CC:Subject:Date; b=nO2QU0jFET/xwvZAY9t7hSwMmcaLbhcC12/14Kd0Qu5q5Vc5efLZQbpxni5h7CKwG I1SVw43LyC1Nl0uDy69eMKMWDL/Mn7SAD3DeMn0+B7AVT6wnSmsJK57TCD5aTStvWC n0S5mS81sfcdbPFXQ85y/2THkkYh40BjpiUvspE4= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wADHfuWY052202 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 Nov 2018 11:41:56 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 13 Nov 2018 11:41:56 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Tue, 13 Nov 2018 11:41:55 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wADHftFW012563; Tue, 13 Nov 2018 11:41:55 -0600 Received: from localhost (uda0274052.dhcp.ti.com [128.247.59.203]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id wADHftx05569; Tue, 13 Nov 2018 11:41:55 -0600 (CST) From: Dave Gerlach To: Viresh Kumar , "Rafael J . Wysocki" Subject: [PATCH v3] cpufreq: ti-cpufreq: Only register platform_device when supported Date: Tue, 13 Nov 2018 11:39:12 -0600 Message-ID: <20181113173912.27643-1-d-gerlach@ti.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181113_124238_796453_38816F3B X-CRM114-Status: GOOD ( 15.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nishanth Menon , linux-pm@vger.kernel.org, Tony Lindgren , Keerthy J , Dave Gerlach , linux-kernel@vger.kernel.org, Johan Hovold , Tero Kristo , Stephen Boyd , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the ti-cpufreq driver blindly registers a 'ti-cpufreq' to force the driver to probe on any platforms where the driver is built in. However, this should only happen on platforms that actually can make use of the driver. There is already functionality in place to match the SoC compatible so let's factor this out into a separate call and make sure we find a match before creating the ti-cpufreq platform device. Reviewed-by: Johan Hovold Signed-off-by: Dave Gerlach --- v2->v3: Use platform_device_register_resndata to pass match data to probe to to avoid matching again in probe. v2: https://patchwork.kernel.org/patch/10574535/ drivers/cpufreq/ti-cpufreq.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c index 3f0e2a14895a..2f97a4b38bad 100644 --- a/drivers/cpufreq/ti-cpufreq.c +++ b/drivers/cpufreq/ti-cpufreq.c @@ -201,19 +201,28 @@ static const struct of_device_id ti_cpufreq_of_match[] = { {}, }; +static const struct of_device_id *ti_cpufreq_match_node(void) +{ + struct device_node *np; + const struct of_device_id *match; + + np = of_find_node_by_path("/"); + match = of_match_node(ti_cpufreq_of_match, np); + of_node_put(np); + + return match; +} + static int ti_cpufreq_probe(struct platform_device *pdev) { u32 version[VERSION_COUNT]; - struct device_node *np; const struct of_device_id *match; struct opp_table *ti_opp_table; struct ti_cpufreq_data *opp_data; const char * const reg_names[] = {"vdd", "vbb"}; int ret; - np = of_find_node_by_path("/"); - match = of_match_node(ti_cpufreq_of_match, np); - of_node_put(np); + match = dev_get_platdata(&pdev->dev); if (!match) return -ENODEV; @@ -290,7 +299,15 @@ static int ti_cpufreq_probe(struct platform_device *pdev) static int ti_cpufreq_init(void) { - platform_device_register_simple("ti-cpufreq", -1, NULL, 0); + const struct of_device_id *match; + + /* Check to ensure we are on a compatible platform */ + match = ti_cpufreq_match_node(); + if (match) + platform_device_register_resndata(NULL, "ti-cpufreq", -1, NULL, + 0, match, + sizeof(*match)); + return 0; } module_init(ti_cpufreq_init);