Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5657617imu; Tue, 13 Nov 2018 09:43:43 -0800 (PST) X-Google-Smtp-Source: AJdET5dspnTzJhGVgxZTS/zVk4ckv2wXFEuDBVOR/cMLDBtDdlMpgNPLQZcTCrd0JCumDnfQZ2zT X-Received: by 2002:a62:3891:: with SMTP id f139-v6mr6166741pfa.196.1542131023531; Tue, 13 Nov 2018 09:43:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542131023; cv=none; d=google.com; s=arc-20160816; b=tPfd0QeJODASVwDpZ3jwlZ2dH1HHsLuAEDLgvsk7mPhdR92EtMrwXsuyjKZiQQndhC v3dIRKuMClZb/iX6p7fR6EjWsmRn3pDqV9Vq5nXP2+JPEA3PryoxQgK4ey+poWGrimLM NAzUre0fPTdVtnwqY3nZYm9WbhaIq/Bi9EOyD+qwfU/I90Cb6+8lk3O+WA9/H3itWlH4 MdX2Gs7YxzugrbA2XDFLaWdexMc7TLHY8ojf20K64Y40Kw2PdnBvti4maNPhkOAVZ1De eSPsZo0QfDdAVS3y664e894kBLfO2yD5v9z/icKmn7Fk26LHsey0B5xut/bcJzD90PFH v0oQ== 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=6h3yBy6yxBC5/wHBXcPz5P4Ib+Z0R91C8J511DqKqUY=; b=cIsa+uruAwCOhEqlMBT1zSUNLPtj9Dg48UB54EcdAF7Zu2VlRdgZiCsQvKP0o/Qo0H yflHcjgmeyoVp+mLBpcrNJYVnsQg0hfUFaSyRWsXOv5FIZiaI4yBFZ+YBIpL2r0fTEDl tmwk4DlaY2QLsUTvI0LNnHed3A/H9zDYxg0rtgmxDZsKAMrr3qjwbGgjU1jYC/44e3Uy oivOy/Gx0F8OldmHPZKOnYz6i33Yn+vKQb6Bwf4YnCy5PTnB1R+w33Sb1ehGWb59uU1n KzyR9BP4UFHl0yZTdJn/bDe1yGDkj82vFivLgcOUfDHCgkvq4JAO6KI8Jj7PYvyb/Yuw okFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=nO2QU0jF; 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 t20-v6si370497plo.293.2018.11.13.09.43.28; Tue, 13 Nov 2018 09:43:43 -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=nO2QU0jF; 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 S1731971AbeKNDlv (ORCPT + 99 others); Tue, 13 Nov 2018 22:41:51 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:49326 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731822AbeKNDlu (ORCPT ); Tue, 13 Nov 2018 22:41:50 -0500 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" CC: , , , , Keerthy J , Tero Kristo , Tony Lindgren , Nishanth Menon , Dave Gerlach , Stephen Boyd , Johan Hovold 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 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 --- 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); -- 2.19.0