Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2000118imm; Thu, 23 Aug 2018 12:22:30 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyvc/LU6hnNQFbCNmyGv88UJfJVxUPaYAAWT1hyle6fDlZjO9NjOLsIPz1maTD13N3O/YQh X-Received: by 2002:a63:6343:: with SMTP id x64-v6mr27022354pgb.173.1535052150704; Thu, 23 Aug 2018 12:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535052150; cv=none; d=google.com; s=arc-20160816; b=N3R+1bAhpK33E2jr/UbZiFiO5Ykv2x3htgERdd+y/MXxoOUaTrrD/r8qHDSfHCxntT PDbFSbuQWsnvdoUziE+G/jNYl8efZ7G0Lon1id13ETbEVPc6a7h1DsZG6prkLgRKBWE0 Sk8LO+c2bQtVX2uMQ6VFOA2c8wyGvKRA+34Vhs8CgbRb64gkv1GgqQlynJ2gvCTngvuY 4sCfI6JOfvA1K8wPp/pd28XUQ6W5LFP+jIPUSpyuQohkTX4EM6g6cApio60Y0v4wHa6U iMtBSoRhmnSEWOfIARZLtJGW7or00A64RJ4bpY5oNSLp9FoikvwpqY1o+nK0Jb+q1IZP W8iA== 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=G855R1hIFQQxOte1LcXkyZCHvaLlOLhLvNcT4DSa2CA=; b=facKFbcCrcZRfQjmwDz6pJCKo9EQGDAZJtB5H0CVTnbTg+ymRXhC2sSrzKFd9qzSvr Qbm6NWuExSLSUaaNgS8xZZQB4/6aJfoC6LdL5DmNBhYCKzmpL7fGby4xGIxWOrS/6Obc 4HTTf+8GV7+0GAVPoT7jWRzH/PEETwV+KkdHySeB6+m2Ypqwy7+uQjB5pLnMQrCoCmex 9zGFQO9M35j5Vbpw0nSWqm/ehCtDIh7Y4SvSriQtIiMERuWP1E8/SFbaV0Rm44efEwfk 3oUXamXCkD2eYpipV8/iDDubOHEg3cJMgRuJlhYbqwyK/J/G1Mfi9lxQS+/uaoRX4o84 GzEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xdBLudeI; 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 e125-v6si5006034pgc.424.2018.08.23.12.22.15; Thu, 23 Aug 2018 12:22:30 -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=xdBLudeI; 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 S1727292AbeHWWwH (ORCPT + 99 others); Thu, 23 Aug 2018 18:52:07 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:45650 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbeHWWwF (ORCPT ); Thu, 23 Aug 2018 18:52:05 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id w7NJKcu0065506; Thu, 23 Aug 2018 14:20:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1535052038; bh=G855R1hIFQQxOte1LcXkyZCHvaLlOLhLvNcT4DSa2CA=; h=From:To:CC:Subject:Date; b=xdBLudeIUGtvW2IlzFvhHXUoAvS1OJoIOAG+/EkQaVkcQDMoQjBsG+kyPiV7vtJPW FKqT0gPXX1xpwPSgJw9JR7ZknYmImrzoJTw86mTZwV7S3TsrBBC0H5/KeuT3xA9QpY A75+MS9dfR4/2ykdGyhaQhFCQ9AVtvlkvsVUswAs= Received: from DFLE101.ent.ti.com (dfle101.ent.ti.com [10.64.6.22]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7NJKcsA011311; Thu, 23 Aug 2018 14:20:38 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 23 Aug 2018 14:20:37 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Thu, 23 Aug 2018 14:20:37 -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 w7NJKbvB008289; Thu, 23 Aug 2018 14:20:37 -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 w7NJKbx04183; Thu, 23 Aug 2018 14:20:37 -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 v2] cpufreq: ti-cpufreq: Only register platform_device when supported Date: Thu, 23 Aug 2018 14:20:35 -0500 Message-ID: <20180823192035.22940-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 platform device. Reviewed-by: Johan Hovold Signed-off-by: Dave Gerlach --- v1->v2: * Return 'match' directly in ti_cpufreq_match_node. * Add Johan's Reviewed-by. drivers/cpufreq/ti-cpufreq.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c index 3f0e2a14895a..6b025953ddee 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 = ti_cpufreq_match_node(); if (!match) return -ENODEV; @@ -290,7 +299,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