Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1117789imm; Wed, 22 Aug 2018 19:46:23 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyAWjzEnwtYNy82qxYBhOcCCKCiUs3L3KWuDOIUZO+yy5RojoHu4kPLsZp00JL8F6ooTi1+ X-Received: by 2002:a62:89d8:: with SMTP id n85-v6mr60224651pfk.83.1534992383741; Wed, 22 Aug 2018 19:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534992383; cv=none; d=google.com; s=arc-20160816; b=FJc4w56COd/bYQSKg6ZNBT1ymoPfTeSYmh7eUyXMw7LkkRX/tWo8KJyqaSaqR0ToGD uB/sh3qMmEFi+LalbRsHg1528i0MLngabN+NBfZsHcGubAB9OD4FKAJBqYPAPWuvighS +kjUgcIxsrLTq6WGWPV0Os0Qa/UCDhctoyctBKiU+91hn087bIXkRnp2NF7PsCMY/7/8 7QRt2k4FMj0ZA3wXk0coIRICzpMV6DRG0wMgLUKiCQqcCw9TyNTLIwzTFQs+lKV4gt2E Err9QJz7IUwgRn3am9DaHeF313bYpRCvg51S3ZVGSfhWtrreEXm2vB8czJp6GFqqPu2y dz8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=sOzNKhzPEYKnz5ebbYX8WGhMDtsj/JOWLzGnU9uAsCw=; b=NRZV5X/s5nzs+Hkrxp+NU+CwsSLbXNXOGzQ4zgxmkFV7AeoDrkUUnS3uAREbYn/bcU TXb4elhciMiMC5SBm7R7BFeZkEJffYXtmti/aeDJNbr0ybMDPhzhU9Hv5e0x2qqZp3w3 3A3ZGlGMIzAs/poK4RiXgSsg8wBHOWxwZ7rb2GgkljEprswsuathOdUIfdRxt6qpJr9h fK11/irFVx9LQF/dIi08TEwFKKnHlKdLZFWBrOFbNLdxxoNdP7DgvqExneDlYh4n8SLo ZidvmC1DkTmE5nzxVm2j9KW7PGdjg65zJ1Aphn/ynMHbG7QqdWOgkFWWSKO/M+XRQg4m lD/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=aotpEkTi; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 199-v6si3300496pgg.366.2018.08.22.19.46.08; Wed, 22 Aug 2018 19:46:23 -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=@ti.com header.s=ti-com-17Q1 header.b=aotpEkTi; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727624AbeHWGMa (ORCPT + 99 others); Thu, 23 Aug 2018 02:12:30 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:49018 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbeHWGM3 (ORCPT ); Thu, 23 Aug 2018 02:12:29 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id w7N2ijqY041409; Wed, 22 Aug 2018 21:44:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1534992285; bh=sOzNKhzPEYKnz5ebbYX8WGhMDtsj/JOWLzGnU9uAsCw=; h=From:To:CC:Subject:Date; b=aotpEkTiwPKY08EjoJA7HbhkRDoDz2RXosM9TXS+bzL5dpDSpvQOc7oGNM44ZZ2x+ W3Y+K1y44Hw7Vbki1U4jlvfjhzLUyuHH37UCxMdPcg0YvWscUNktTtanlEl7oHTQFZ ocnectyvH2Sk0ZK197EE7zURRaPf1Wn/ED1HcxWM= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7N2ij12006128; Wed, 22 Aug 2018 21:44:45 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 22 Aug 2018 21:44:45 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Wed, 22 Aug 2018 21:44:45 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7N2ij9e011750; Wed, 22 Aug 2018 21:44:45 -0500 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 w7N2iix06328; Wed, 22 Aug 2018 21:44:44 -0500 (CDT) From: Dave Gerlach To: Viresh Kumar , "Rafael J . Wysocki" CC: , , , , Tony Lindgren , Tero Kristo , Nishanth Menon , Stephen Boyd , Dave Gerlach , Keerthy J Subject: [PATCH] cpufreq: ti-cpufreq: Only register platform_device when supported Date: Wed, 22 Aug 2018 21:44:32 -0500 Message-ID: <20180823024432.7000-1-d-gerlach@ti.com> X-Mailer: git-send-email 2.16.1 MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 driver device. Signed-off-by: Dave Gerlach --- drivers/cpufreq/ti-cpufreq.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c index 3f0e2a14895a..541fdcf17b57 100644 --- a/drivers/cpufreq/ti-cpufreq.c +++ b/drivers/cpufreq/ti-cpufreq.c @@ -201,19 +201,31 @@ 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); + + if (!match) + return NULL; + else + 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 = ti_cpufreq_match_node(); if (!match) return -ENODEV; @@ -290,7 +302,10 @@ static int ti_cpufreq_probe(struct platform_device *pdev) static int ti_cpufreq_init(void) { - platform_device_register_simple("ti-cpufreq", -1, NULL, 0); + /* Check to ensure we are on a compatible platform */ + if (ti_cpufreq_match_node()) + platform_device_register_simple("ti-cpufreq", -1, NULL, 0); + return 0; } module_init(ti_cpufreq_init); -- 2.16.1