Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp623076img; Thu, 28 Feb 2019 05:20:16 -0800 (PST) X-Google-Smtp-Source: AHgI3IbQU0jnQJwmD0pVvVHBPi6gpvQf9+iI9H9fZa8PCpml0vel+NbuzEKTx5BprjoER3677URZ X-Received: by 2002:a63:6841:: with SMTP id d62mr8500113pgc.133.1551360016624; Thu, 28 Feb 2019 05:20:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551360016; cv=none; d=google.com; s=arc-20160816; b=MSLjduH+cOOUFz76G/2+NOXOquGqJZgMUopyhbNPtpAAStsHWfFjHLkWKW5iyKmUBp 33VoV9Z65WdSPBDu5r5kf8lQ5uMMEOIUe0b7qGGvfDnl7sYR07GB1GzXrfh19OcHBkvV rtNww7Zjl0sOWsh6oo6lNKTKnDNzETW8ufioXmc2gBfVoCkpgvjURPZdqiZ9zdQOpYuV 56PzZrYN+NCUKgPXryWlLcOa265qXNb8cVYUWkbX5N5QYI+Ox1tgC0QzSjWMzf+C0pxq 1+aSNLUp4/ROvz3t56BaflA/PwZSrUyRIE1otoQOsaXCmvbd+sK/sWbz7gCwzresKYhR c/LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=E6z81K0W96j894STLgudBmvoVYJfCsaxejDMwLE4FwQ=; b=KjNH/27mNMDtaw1W/YpX8f+cfwxk2PZnRm5KEcc/rrCLZjhkqn/g+ZwgSJOfIqzjeF WRR3m02Wz+dabbIMmaLZBnr3bb0jfhRxAYy6ROR7TmIXVYJQ5jLCZZd1Vjzh6DrDNyZ1 sWyQ8gR/crftXAw2jjfWpUvpB733O1h3o35krsAN+4sGPkcp1bjZV/Iu1Ak76ZtI50sk V/1YRHWOtwXNyjHDouV9mvVHxYrXEOTD0l9yvnDtaFMSz5tMEV94shXOdEX9JXSuATjX lMaE3N2wPUEwfBPtS/qUs/6ljcvcuSzhlTht+lxURT+bmZ3LWJq9pSVPXkFIkOYSU00d MXyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@prevas.se header.s=selector1 header.b=Dn+UFXxO; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67si3036155pgc.256.2019.02.28.05.19.53; Thu, 28 Feb 2019 05:20:16 -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=@prevas.se header.s=selector1 header.b=Dn+UFXxO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732437AbfB1KbI (ORCPT + 99 others); Thu, 28 Feb 2019 05:31:08 -0500 Received: from mail-eopbgr80119.outbound.protection.outlook.com ([40.107.8.119]:56544 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727666AbfB1KbG (ORCPT ); Thu, 28 Feb 2019 05:31:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E6z81K0W96j894STLgudBmvoVYJfCsaxejDMwLE4FwQ=; b=Dn+UFXxOliSd+BXsMHsN8DAx7Us7GCi2tt38+Aj/S4bJtQHPWeF5Wh7c7Aq3RSRz4YX9/vBN1s5u2sMoEzwemX48wbKvOgxpy+U2kqpDUsgJanHJkQMwNHkOnTrju4AuVc6kVihN2kU1DUfHAbkPAxhy6jIs7BCVAJT4N+PGtfU= Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM (20.178.126.212) by VI1PR10MB0509.EURPRD10.PROD.OUTLOOK.COM (10.167.201.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.16; Thu, 28 Feb 2019 10:30:42 +0000 Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::d49:d85b:58bf:cd5b]) by VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::d49:d85b:58bf:cd5b%6]) with mapi id 15.20.1643.022; Thu, 28 Feb 2019 10:30:42 +0000 From: Rasmus Villemoes To: Qiang Zhao , Leo Li CC: Scott Wood , "linux-kernel@vger.kernel.org" , Timur Tabi , Rasmus Villemoes Subject: [PATCH 3/4] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Thread-Topic: [PATCH 3/4] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Thread-Index: AQHUz1Co2oHyD1DDBUuzX0GX5in8aw== Date: Thu, 28 Feb 2019 10:30:42 +0000 Message-ID: <20190228103026.9566-4-rasmus.villemoes@prevas.dk> References: <338677b2-ef74-2afc-4542-c66f1acdb7e5@prevas.dk> <20190228103026.9566-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20190228103026.9566-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0127.eurprd05.prod.outlook.com (2603:10a6:7:28::14) To VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e3::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Rasmus.Villemoes@prevas.se; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [81.216.59.226] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 48be3bbf-95a1-475c-c52d-08d69d67ca54 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020);SRVR:VI1PR10MB0509; x-ms-traffictypediagnostic: VI1PR10MB0509: x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(136003)(39850400004)(376002)(366004)(346002)(396003)(189003)(199004)(476003)(446003)(11346002)(2616005)(8936002)(44832011)(8976002)(106356001)(42882007)(486006)(68736007)(186003)(50226002)(107886003)(105586002)(54906003)(74482002)(110136005)(316002)(5660300002)(97736004)(1076003)(72206003)(2906002)(52116002)(71190400001)(6486002)(305945005)(478600001)(256004)(71200400001)(53936002)(99286004)(6436002)(66066001)(6512007)(6116002)(81156014)(81166006)(102836004)(4326008)(25786009)(6506007)(386003)(26005)(76176011)(7736002)(36756003)(8676002)(14454004)(3846002);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR10MB0509;H:VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: prevas.se does not designate permitted sender hosts) x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1;VI1PR10MB0509;23:AVJKJ1jIfBMN8nqRtuLBFKpypqkQ2bxXs4QI8V2?= =?iso-8859-1?Q?bTBccqaRxZnhMcauAbzH3dIqwt/QK1ExKKTIYRhRJ6l4d59DivtnaExZbu?= =?iso-8859-1?Q?Qg4eo4YWUL5VkEbt83+uReSaaiGA7aXPAn8hGY8ah81JD5XECzFFKI+Wh3?= =?iso-8859-1?Q?9uvnYuITLCDrP9e4VQ4kEOWq9j0CDIkUqL/LIif0TXY4cZUJ8s4kf9ld4k?= =?iso-8859-1?Q?cCBCmUS873x8IvWyad3COkNR4vI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?= =?iso-8859-1?Q?tEuHwuaGu+kNqCL5mYkL+RrK70rJG3H49CXCXGjupgM6a1vHtvA5VXIrEg?= =?iso-8859-1?Q?LFXE6iiT8v/pUoLDfP5BVU5WIGtZ7DQqitytXYtkfZzTkm++Qmlt5M2IF7?= =?iso-8859-1?Q?akiNKhqrtuNr6zbGhWUTmw9Y4bKwI10hwe0sxxnOAQ5Vd/e3p2cuzBLcPV?= =?iso-8859-1?Q?IGd8BySa/vgoteWN8OMC4E92AK3KsDA8chIdY0o9RnUYGoB/sOeXAwJlsU?= =?iso-8859-1?Q?yysZbonQ=3D?= x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: olPirPRai45qVcbXyD2RlrcLKdWOaDkH2DJiLlVU1F5WZ8BYdn1mlM5R52+pffxQ4tpabDSFZMPGNttMo5qRWyYvsIAbzl3fS4/KuKvbNC+v7SxuTq8kXy8HerhAso48OCeB0SiFFq+l+Ati2TjET2kuwWD77twRQEj65cN8ShGppHLPdFiPBc5deXBkuiAmaScjz4LBFhpt6f6mGt7sxkmf6rhgK+t0K4uCiM3jICXkx+LmNXqW4xITFvG2Rvyjtb2JACy52WlAQw9yDKGleK8xgn1AIYsnLGVKt6gcWqxympR9FWg6f2GJmzWuiNm19jilCwJasspEQyVZ1B5nabmUcWIrso25tFc5YB/3q1VLYSp8K2+XdUlEoAmgLFBVLWjq/vaQNwVY09po9PSwCdMCmw0CDUwc3qRZk/iLlNQ= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 48be3bbf-95a1-475c-c52d-08d69d67ca54 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 10:30:41.5815 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB0509 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 'try of_find_compatible_node(NULL, NULL, "fsl,qe"), fall back to of_find_node_by_type(NULL, "qe")' pattern is repeated five times. Factor it into a common helper. Signed-off-by: Rasmus Villemoes --- drivers/soc/fsl/qe/qe.c | 71 +++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c index 9b9737a583ef..71beeb72eee4 100644 --- a/drivers/soc/fsl/qe/qe.c +++ b/drivers/soc/fsl/qe/qe.c @@ -56,6 +56,20 @@ static unsigned int qe_num_of_snum; =20 static phys_addr_t qebase =3D -1; =20 +static struct device_node *qe_get_device_node(void) +{ + struct device_node *qe; + + /* + * Newer device trees have an "fsl,qe" compatible property for the QE + * node, but we still need to support older device trees. + */ + qe =3D of_find_compatible_node(NULL, NULL, "fsl,qe"); + if (qe) + return qe; + return of_find_node_by_type(NULL, "qe"); +} + static phys_addr_t get_qe_base(void) { struct device_node *qe; @@ -65,12 +79,9 @@ static phys_addr_t get_qe_base(void) if (qebase !=3D -1) return qebase; =20 - qe =3D of_find_compatible_node(NULL, NULL, "fsl,qe"); - if (!qe) { - qe =3D of_find_node_by_type(NULL, "qe"); - if (!qe) - return qebase; - } + qe =3D qe_get_device_node(); + if (!qe) + return qebase; =20 ret =3D of_address_to_resource(qe, 0, &res); if (!ret) @@ -164,12 +175,9 @@ unsigned int qe_get_brg_clk(void) if (brg_clk) return brg_clk; =20 - qe =3D of_find_compatible_node(NULL, NULL, "fsl,qe"); - if (!qe) { - qe =3D of_find_node_by_type(NULL, "qe"); - if (!qe) - return brg_clk; - } + qe =3D qe_get_device_node(); + if (!qe) + return brg_clk; =20 prop =3D of_get_property(qe, "brg-frequency", &size); if (prop && size =3D=3D sizeof(*prop)) @@ -563,16 +571,9 @@ struct qe_firmware_info *qe_get_firmware_info(void) =20 initialized =3D 1; =20 - /* - * Newer device trees have an "fsl,qe" compatible property for the QE - * node, but we still need to support older device trees. - */ - qe =3D of_find_compatible_node(NULL, NULL, "fsl,qe"); - if (!qe) { - qe =3D of_find_node_by_type(NULL, "qe"); - if (!qe) - return NULL; - } + qe =3D qe_get_device_node(); + if (!qe) + return NULL; =20 /* Find the 'firmware' child node */ for_each_child_of_node(qe, fw) { @@ -622,16 +623,9 @@ unsigned int qe_get_num_of_risc(void) unsigned int num_of_risc =3D 0; const u32 *prop; =20 - qe =3D of_find_compatible_node(NULL, NULL, "fsl,qe"); - if (!qe) { - /* Older devices trees did not have an "fsl,qe" - * compatible property, so we need to look for - * the QE node by name. - */ - qe =3D of_find_node_by_type(NULL, "qe"); - if (!qe) - return num_of_risc; - } + qe =3D qe_get_device_node(); + if (!qe) + return num_of_risc; =20 prop =3D of_get_property(qe, "fsl,qe-num-riscs", &size); if (prop && size =3D=3D sizeof(*prop)) @@ -651,16 +645,9 @@ unsigned int qe_get_num_of_snums(void) const u32 *prop; =20 num_of_snums =3D 28; /* The default number of snum for threads is 28 */ - qe =3D of_find_compatible_node(NULL, NULL, "fsl,qe"); - if (!qe) { - /* Older devices trees did not have an "fsl,qe" - * compatible property, so we need to look for - * the QE node by name. - */ - qe =3D of_find_node_by_type(NULL, "qe"); - if (!qe) - return num_of_snums; - } + qe =3D qe_get_device_node(); + if (!qe) + return num_of_snums; =20 prop =3D of_get_property(qe, "fsl,qe-num-snums", &size); if (prop && size =3D=3D sizeof(*prop)) { --=20 2.20.1