Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5775139imu; Tue, 13 Nov 2018 11:31:50 -0800 (PST) X-Google-Smtp-Source: AJdET5c4ieKPqmogKS+fSeEo81aJOwuHAbETeOau81E97NSUw09ByxSdUWw5Tp9uvoyBP84nE7g0 X-Received: by 2002:a63:30c8:: with SMTP id w191mr4654931pgw.120.1542137510758; Tue, 13 Nov 2018 11:31:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542137510; cv=none; d=google.com; s=arc-20160816; b=ylUAjzakRvorannqADLumJj+vYFW16eTMkCi79X83ocxS4TtiZ2/hSZKJWfMfe40zx uq93R9ACZV0FyODZMdyHeZOzqhGbzjbYNUuN5agICtbUN84d4xmhfhhRx53Xh3UhWD30 PlLzQ48FMrzC2dg5t7Pdva4u6opeVJAwfruRFYlYgs5Ao1cHUoXarDKSQ0yJhvZM7643 yAgTsEG/ZPDW0/rKC4eFACxUk2v0IA34TSr4aUJ5HoY1+Hh1Bv/vz1Lj3IFVOra3pi3m nHj0Y7AtknLhJFiO1sIiasqq4MquTx7v4U1qXyE9Wg4sf35KPqT7Gs7IMfyXCAh15b3A dqww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Eaibw42TEZJ4RgYZwRWqg4J0BgO+zEcG3Q2MRl7w58s=; b=rRNQqCrt6OqYUWrdfrSa6aEm3joGYo4nmxjgHN4bLzQpB9r2iUHB/xSaeWpnP1Rxig gFKaLl8pLERR1STIL1HRS2+lzQL2X5lQg+ZI7thle02GkXSZhW73698NKhriCk7oHAG/ InbI/JiCZ5i/5JeDO3qqGVof4eMpvVS2DwpbU/IbbqVi2dlr4D/IdtjAae+5CdPzifEz jnBs73MLuk3FzKS60C+39lSLAEWYEhsXUj7/YVb4prztzuqvahQ2M1sOcLszOojDiHlq kNzWNrjRBbBK/+OAnxyZxwFqo2lZIaE5oU/FKaYKSUDZHz+H3qWp5DzqPBjKDZWlXtis 24ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=d5aqCfmQ; 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 k135si2038654pgc.574.2018.11.13.11.31.32; Tue, 13 Nov 2018 11:31:50 -0800 (PST) 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=d5aqCfmQ; 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 S1727974AbeKNFai (ORCPT + 99 others); Wed, 14 Nov 2018 00:30:38 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:54876 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725748AbeKNFai (ORCPT ); Wed, 14 Nov 2018 00:30:38 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id wADJUgQW051228; Tue, 13 Nov 2018 13:30:42 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1542137442; bh=Eaibw42TEZJ4RgYZwRWqg4J0BgO+zEcG3Q2MRl7w58s=; h=From:To:CC:Subject:Date; b=d5aqCfmQX1uiXf4rcmDzU2V9BoOByJ4HbU0YYdTjNc8QXEe8q2xO8W3OLseTyuiNE euGNKjluFEn6BgDWSMUYl2PVt6E/yXHzz7w0Ww60iha5cThgyyyutYyS+tMGHwwHlh VXY0LNWCCgTQ2tMxCi4KbnvYydKH+vnOE7CvgzPI= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wADJUgVc021908 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 Nov 2018 13:30:42 -0600 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE102.ent.ti.com (157.170.170.32) 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 13:30:41 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE112.ent.ti.com (157.170.170.23) 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 13:30:41 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id wADJUfAe021871; Tue, 13 Nov 2018 13:30:41 -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 wADJUfx18701; Tue, 13 Nov 2018 13:30:41 -0600 (CST) From: Dave Gerlach To: Viresh Kumar , "Rafael J . Wysocki" CC: , , , , Keerthy J , Tero Kristo , Tony Lindgren , Nishanth Menon , Dave Gerlach , Stephen Boyd , Johan Hovold Subject: [PATCH v4] cpufreq: ti-cpufreq: Only register platform_device when supported Date: Tue, 13 Nov 2018 13:30:40 -0600 Message-ID: <20181113193040.15181-1-d-gerlach@ti.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- v3->v4: Use platform_device_register_data rather than platform_device_register_resndata as we are only passing data. v3: https://patchwork.kernel.org/patch/10681161/ drivers/cpufreq/ti-cpufreq.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c index 3f0e2a14895a..22b53bf26817 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,14 @@ 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_data(NULL, "ti-cpufreq", -1, match, + sizeof(*match)); + return 0; } module_init(ti_cpufreq_init); -- 2.19.0