Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp425677ybx; Fri, 1 Nov 2019 05:46:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDJELRGUXwEVsh2752/laHDyVfUIlYUbYUH/qCCqSSuaQ/2TBbb+2FU7hx9gCgyzDrIPSJ X-Received: by 2002:a17:906:2599:: with SMTP id m25mr9079799ejb.227.1572612387250; Fri, 01 Nov 2019 05:46:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572612387; cv=none; d=google.com; s=arc-20160816; b=mg2KVs0RItGzX560fV7W1Yv8r6CNqsdHWicbLUGbn5jRLnat0qPDPaQf+uqllcbfvO RjBqn61CPfd9+QziE0ZZaZczIGAXYQOjk/2dgXh12t0s7m8h4MZBHpCNOgokkdI6UiT1 Ncm843NHqccMjJ7n6MfbCfiuQvV0fizdCHpLAvgR+XbxV90X+V5L8pg3H71BAdTvihNh WokD3ECVQvGOFs2qjN/ktVsw6ilkdh2Q8ROzY1zIzsNDPNxJYz56rVMD+BqLwnYROHOT Djd5b204+G98bL3csMnkhXrVsNUDKtT4NAigvOxkMXu5e3Al3Uu3fEbzmC00WBiExMl2 I6kg== 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=y9+9brdUsBMDsBate+OcYeL/vnJHS5qQv5Htp+H+ANZ8Ck2bq0FwqoLHGt1coaw3f+ 9r1jWil6w5NlcEyz6ToMsLs9aD2tfOXIR4JDeFodfJ50HmF94Ox+b9jZ93gWYiHotp28 zHUqR+6AXMNHhU7HiLR2rNciDbqJOEwJhWbsTW6Q7ee9FroSdp8DjudRAUPFi4RyYXOs fkLWIIRfIkgCqZVkznk6vJhVlezMtD1vsTgqpdklAZMhXqbVUNRlPGFFYmVqFbkUstKz mbnmr7NbRzvTcjBtex88Mf+HacYnZJsFrwA5Y1oMn4mjia5FKPmlkg5F/bOp1hk2bTuT AqSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=RVI8Jc7Q; 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 18si5635294ejv.363.2019.11.01.05.46.04; Fri, 01 Nov 2019 05:46:27 -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=@rasmusvillemoes.dk header.s=google header.b=RVI8Jc7Q; 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 S1730777AbfKAMmt (ORCPT + 99 others); Fri, 1 Nov 2019 08:42:49 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40218 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730716AbfKAMmo (ORCPT ); Fri, 1 Nov 2019 08:42:44 -0400 Received: by mail-lj1-f195.google.com with SMTP id q2so3561819ljg.7 for ; Fri, 01 Nov 2019 05:42:43 -0700 (PDT) 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=RVI8Jc7QJXtUyehVy/2ZLH5KOcNtBY4ej4JTLrLF37ovYlpHfFGePEvhr0cru5jX5R DDSEMoiHcuFOPLrcqX/6yDYoWxYIK8sIyHPteoFu3x6hDugimd/A0m2Ca+fO2CBA9yPb r9nwKykJSVb5eDXL5KejAxr2j65tQDEYh8TcE= 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=nxC8vE5qC8sJJo8k/YQsDJuHEVEGV7KDlGWuD7YJwglX/04I4qfsmzQsAu/+KK3LaI k0gVJqO3VZSubkUJFokvPvxU/BYlW5N/kzQBc17dv8ypuqGcmyNb5ladIF53kEs+9rVW v4Ny1fPp8tMBQ2Rf4/QvHGbGMHFdROq1AUss7VgsIyU18eNjsn2sRLjV4vj1ldstnA9D eIdnd7M2eEiwnqEKBEH6eaXdxLO+kUjN58Y6e57qTqnfOg9geAw+2/30+lgBGTCwWc/o BqpjvsR+5fGz1Y2Um81wquZH2R0L5+y3yePO9UkRxiTvVtWLmT2ICCbP/05zdTHazojz 565g== X-Gm-Message-State: APjAAAXFvWIHGm8oE/yRhFLIdYyptO+haB+ilds0eU0A1k9wR1gDqB2q 21fa/CNmoPqtKsQ90hWYzMaDsA== X-Received: by 2002:a2e:8204:: with SMTP id w4mr8267295ljg.212.1572612162716; Fri, 01 Nov 2019 05:42:42 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id o26sm2458540lfi.57.2019.11.01.05.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 05:42:42 -0700 (PDT) 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 v3 22/36] soc: fsl: qe: qe.c: use of_property_read_* helpers Date: Fri, 1 Nov 2019 13:41:56 +0100 Message-Id: <20191101124210.14510-23-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191101124210.14510-1-linux@rasmusvillemoes.dk> References: <20191018125234.21825-1-linux@rasmusvillemoes.dk> <20191101124210.14510-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