Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2483257ybx; Fri, 8 Nov 2019 05:04:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyfZbTY9Mv7gAneTtTFC6P3rQ5YdkE7jB/RWU5sJ1KeXNEVY2pS9nkAyGrH/MA8NLd2pZ9U X-Received: by 2002:a05:6402:138c:: with SMTP id b12mr10134939edv.28.1573218282940; Fri, 08 Nov 2019 05:04:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573218282; cv=none; d=google.com; s=arc-20160816; b=myGup3p47rT9jgAqKwqpD8ySgy2SQ+LUAZwucURkw5lVv2HQEYObZklGx74jArPbb1 3XrskQuhhxOvfVYAwqozP4GZ0pbezdMD1W5rqfUxxArowK8uvzZqRkH/OqtOWRmUXbkf tNsqyQVe6PYsNKLafby9SrK2KRiWOrS1GY4+I0ag774125+Vd160gXJtYEuvmDZ5gkkv FsGUArDo9SMTBEpddktE5OxknWSYiHWc1VHlbwRuPNQXkRqqElWVkusZnnIEqrKwWu/k iXr9UtvzWgYjV/9rpRvqM3hq5Qmn/mcyVvAhv8eRB2xpnZ4ZAFguRgkdGxyiveny7uQ7 62xw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DamhDMgU5LUEj6+/3a9o1XbDY44tIM+8wHrJxcRu+uM=; b=E/mvFS7czpI18QiTwx8kDmDIrrjqPeqM7Z6hfHYdt5AtTR8TlRIIyVm5v9bjuJK6mv G/wdHyOVUZp88ibBHfboDdr17uOlgjGqR/q7Rmq18fgpnjSnR9vsLtCGb8XtE9BeOebk e32UM5lVFGTgg9DQYuyxVM6zkRr6x1yf5IhtMIbdVQBPfvgekshKeNZn6crKxFLPHO56 mpFNFJcJgnidsZJ99fq+XHCanGZz2y5GIj3+NFaHxJ4x1YLN6suhEStUax+U1UgUmUHN FrP1XH5cs5u9rI42sjcloR8uRmr/0LcqxLeOnkbGtT79xgnSINUUo7F9x3o6VJPw73kj F8Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=CzwCiuj6; 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 o27si1061473ejg.238.2019.11.08.05.04.18; Fri, 08 Nov 2019 05:04:42 -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=@rasmusvillemoes.dk header.s=google header.b=CzwCiuj6; 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 S1729373AbfKHNCB (ORCPT + 99 others); Fri, 8 Nov 2019 08:02:01 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42979 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729086AbfKHNCA (ORCPT ); Fri, 8 Nov 2019 08:02:00 -0500 Received: by mail-lf1-f65.google.com with SMTP id z12so4390047lfj.9 for ; Fri, 08 Nov 2019 05:01:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DamhDMgU5LUEj6+/3a9o1XbDY44tIM+8wHrJxcRu+uM=; b=CzwCiuj6exVzCOFgPuTt4r411VFLxU0lG62JmrAC0Tq/FkGLV3hcmjLjTOyorGZ6BF f5vdfP5f8/tUJl6K09ZcsdwAkooUD8r/2Uhwc8HsNoAH1bikyuyJ6cAkf0huPMxyLgC/ q3hQieIudS4xARAsuE4JftrjXtWacrgN01Omo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DamhDMgU5LUEj6+/3a9o1XbDY44tIM+8wHrJxcRu+uM=; b=QL9qyvlatI/d4kNTHTEDZb7prZCUz3BilNVOeRiQAHBve8YYC1Q9sW/RDW2Rv3vJSw 7u5t4FPmiCUPKuI8RRNvGf5QSwJrCaXrKP2Hn9iQXcrdx+dgYCOwDzGJhEEEniPuYtvQ TNyfnCIgcDu69ax6ev5REcGHTZr4JFThMsuys7Gyap3nlPjYquZ0JdN71c+/bDqznEfT 9S28U9XKdz9/jgG7rXGp/1jGk9LsxkgV4hgwBkOfbEv/phS5dcrosWj+4YLSG5IVHVUO GFT+YquAB5J4oou6XcfOb46rDVQU+d9Do6nE+F8nciQ6sFPDol8HAN4SZ0oDHGLfxgty mbTA== X-Gm-Message-State: APjAAAWX5VGfAnv/wGBgaLqFW50tVQuEXGh8dDd/Ra9ClpwMS+GGEH5O AVUH7WxpNlJ+KhTbSF7PlvKuAg== X-Received: by 2002:a19:fc1c:: with SMTP id a28mr6554479lfi.170.1573218116086; Fri, 08 Nov 2019 05:01:56 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id d28sm2454725lfn.33.2019.11.08.05.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2019 05:01:55 -0800 (PST) From: Rasmus Villemoes To: Qiang Zhao , Li Yang , Christophe Leroy Cc: linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Scott Wood , Rasmus Villemoes Subject: [PATCH v4 22/47] soc: fsl: qe: qe.c: use of_property_read_* helpers Date: Fri, 8 Nov 2019 14:00:58 +0100 Message-Id: <20191108130123.6839-23-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191108130123.6839-1-linux@rasmusvillemoes.dk> References: <20191108130123.6839-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of manually doing of_get_property/of_find_property and reading the value by assigning to a u32* or u64* and dereferencing, use the of_property_read_* functions. This make the code more readable, and more importantly, is required for this to work correctly on little-endian platforms. Signed-off-by: Rasmus Villemoes --- drivers/soc/fsl/qe/qe.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c index a4763282ea68..ec511840db3c 100644 --- a/drivers/soc/fsl/qe/qe.c +++ b/drivers/soc/fsl/qe/qe.c @@ -159,8 +159,7 @@ static unsigned int brg_clk = 0; unsigned int qe_get_brg_clk(void) { struct device_node *qe; - int size; - const u32 *prop; + u32 brg; unsigned int mod; if (brg_clk) @@ -170,9 +169,8 @@ unsigned int qe_get_brg_clk(void) if (!qe) return brg_clk; - prop = of_get_property(qe, "brg-frequency", &size); - if (prop && size == sizeof(*prop)) - brg_clk = *prop; + if (!of_property_read_u32(qe, "brg-frequency", &brg)) + brg_clk = brg; of_node_put(qe); @@ -571,11 +569,9 @@ EXPORT_SYMBOL(qe_upload_firmware); struct qe_firmware_info *qe_get_firmware_info(void) { static int initialized; - struct property *prop; struct device_node *qe; struct device_node *fw = NULL; const char *sprop; - unsigned int i; /* * If we haven't checked yet, and a driver hasn't uploaded a firmware @@ -609,20 +605,11 @@ struct qe_firmware_info *qe_get_firmware_info(void) strlcpy(qe_firmware_info.id, sprop, sizeof(qe_firmware_info.id)); - prop = of_find_property(fw, "extended-modes", NULL); - if (prop && (prop->length == sizeof(u64))) { - const u64 *iprop = prop->value; - - qe_firmware_info.extended_modes = *iprop; - } + of_property_read_u64(fw, "extended-modes", + &qe_firmware_info.extended_modes); - prop = of_find_property(fw, "virtual-traps", NULL); - if (prop && (prop->length == 32)) { - const u32 *iprop = prop->value; - - for (i = 0; i < ARRAY_SIZE(qe_firmware_info.vtraps); i++) - qe_firmware_info.vtraps[i] = iprop[i]; - } + of_property_read_u32_array(fw, "virtual-traps", qe_firmware_info.vtraps, + ARRAY_SIZE(qe_firmware_info.vtraps)); of_node_put(fw); @@ -633,17 +620,13 @@ EXPORT_SYMBOL(qe_get_firmware_info); unsigned int qe_get_num_of_risc(void) { struct device_node *qe; - int size; unsigned int num_of_risc = 0; - const u32 *prop; qe = qe_get_device_node(); if (!qe) return num_of_risc; - prop = of_get_property(qe, "fsl,qe-num-riscs", &size); - if (prop && size == sizeof(*prop)) - num_of_risc = *prop; + of_property_read_u32(qe, "fsl,qe-num-riscs", &num_of_risc); of_node_put(qe); -- 2.23.0