Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2482707ybx; Fri, 8 Nov 2019 05:04:20 -0800 (PST) X-Google-Smtp-Source: APXvYqyDfxHeyL0nz8OrBM2ZGzvMfqom19CQu6Asme01AnVD+Mxq3howAfxtYfkqZIrDEX6ZZoRr X-Received: by 2002:a5d:62cd:: with SMTP id o13mr8670924wrv.367.1573218259846; Fri, 08 Nov 2019 05:04:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573218259; cv=none; d=google.com; s=arc-20160816; b=0knzaV2nnfkDmtr4MQ7zV9ezU/H6YCkQQ5EECSN31CaN/7uz088BQ6ymILqXZBURZ3 YgF0RaVBCMxJ4dlYYKFSOTxJtMTqN2N5acKeaRG5fkyRWvGs9j3nIw0RyeeO7/5XPqBV 8NeH8S5qxcuLj69yNYWo2KjX4PwLRUvT7BeYYDrviqaZIKK8c6c30KH3rq9NxB9MQXKB RXuIT++WDYza0KjykOML5nS+LQnMR9NxeKS02ku0HZaqkPYE4Klw07pCTgIuxKPgkWM7 1fW8ahYMbBvEaPVvs2EuobaQopt0CzdnN29XUx6nyhz/Plzl2PDDd3TF/f7rwILGZqON du2g== 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=uKxtxAnStDtPqjNJxBgJ+/b3/LBB3oZn+H7vofIc/Cg=; b=FnD5kWjVxLeC/q2r+hHpP2UcB//Otiyu3T3g6U0jTsAQMx9hg7KPygt8WdNu5nFsdm KFewH5+YLqSZciw+UVcoc46Uk+GBq9rd8m6iYGKe3JM11+6bz/e03eYC7ss3pAZk3JUT 5w8vaOn8oMpd3TGTyvpqIrmFvxNB3BooqFxrIzpOU4kDGtiG1RZoMGB1iKKP2XxR9rF9 d3L0dMnye4/BCNtAYcWtwNhFuWhbJQ923COxnSAYe+Nv1UE73BRh3md1XkNJ49do8Xbd I98iUqv90GrulMwzyF7c1M0bXorfOWQXGruiFC0vjuoIG5T47UanjCOKJTi1rvEBS/56 BHzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=OMJjEfRd; 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 q40si3853286eda.218.2019.11.08.05.03.55; Fri, 08 Nov 2019 05:04:19 -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=OMJjEfRd; 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 S1731140AbfKHNCc (ORCPT + 99 others); Fri, 8 Nov 2019 08:02:32 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44500 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730662AbfKHNCW (ORCPT ); Fri, 8 Nov 2019 08:02:22 -0500 Received: by mail-lf1-f65.google.com with SMTP id v4so4391768lfd.11 for ; Fri, 08 Nov 2019 05:02:21 -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=uKxtxAnStDtPqjNJxBgJ+/b3/LBB3oZn+H7vofIc/Cg=; b=OMJjEfRd48l9yUpyE2357XcIsRJLdOdGu6cqnnbciUlwZHeZovkZpyp0t0N/AXUB0G mmPymXL+MPaOrKkaQbKIZvzq8vi1p6BeMnR73GkDYliRrt73eSaJgjoKJvIjcrt4ppVh teAlmhXN/Smyo6qtACnfhoCrC+ohYMOVNT7Ag= 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=uKxtxAnStDtPqjNJxBgJ+/b3/LBB3oZn+H7vofIc/Cg=; b=oq4So6VfrtYI61b2bm9+2XzQf/WUHi3ZNGaKS0ziEm1ZA4MigOQd2YZ6xcjTZsxewR 5eSHlTRzNDaBlt78q5hsVZwEnoifWTC61YT+IGeHg/rynBY2hg2rltc1ld0iB9aZKN+A 9YsSvY6EsfN9Me2XmmS8oHvbMXVYZfBiR1N/GhmNYxMnNhgpMAzaeCrgwJUKvfehwP+y bKoqqC3mBtWHGyErT6VxbElQbASrBzkpftoelqPbAxZbjIEhOTgcMyyTk3kKSQcspo3p ya6H7nZ493C1zEC61uek1epCeYkXIxwdf0dNnY1SJuHATCk7LMN+zEKe0HWKJV2GS1+Z JIfg== X-Gm-Message-State: APjAAAU7c5Hmm4cP0s9IpZKDCzOWZbQO2R2/uRW4TUOQLPvgeCDn7Xpy R8a/DGN/p1qSY+AQcJkiPwqu1g== X-Received: by 2002:a19:706:: with SMTP id 6mr1175198lfh.93.1573218140577; Fri, 08 Nov 2019 05:02:20 -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.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2019 05:02:20 -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 42/47] soc: fsl: qe: avoid IS_ERR_VALUE in ucc_fast.c Date: Fri, 8 Nov 2019 14:01:18 +0100 Message-Id: <20191108130123.6839-43-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 When building this on a 64-bit platform gcc rightly warns that the error checking is broken (-ENOMEM stored in an u32 does not compare greater than (unsigned long)-MAX_ERRNO). Instead, change the ucc_fast_[tr]x_virtual_fifo_base_offset members to s32 and use an ordinary check-for-negative. Also, this avoids treating 0 as "this cannot have been returned from qe_muram_alloc() so don't free it". Signed-off-by: Rasmus Villemoes --- drivers/soc/fsl/qe/ucc_fast.c | 15 ++++++--------- include/soc/fsl/qe/ucc_fast.h | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/soc/fsl/qe/ucc_fast.c b/drivers/soc/fsl/qe/ucc_fast.c index ca0452497a20..ad6193ea4597 100644 --- a/drivers/soc/fsl/qe/ucc_fast.c +++ b/drivers/soc/fsl/qe/ucc_fast.c @@ -197,6 +197,8 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc __func__); return -ENOMEM; } + uccf->ucc_fast_tx_virtual_fifo_base_offset = -1; + uccf->ucc_fast_rx_virtual_fifo_base_offset = -1; /* Fill fast UCC structure */ uccf->uf_info = uf_info; @@ -265,10 +267,9 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc /* Allocate memory for Tx Virtual Fifo */ uccf->ucc_fast_tx_virtual_fifo_base_offset = qe_muram_alloc(uf_info->utfs, UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT); - if (IS_ERR_VALUE(uccf->ucc_fast_tx_virtual_fifo_base_offset)) { + if (uccf->ucc_fast_tx_virtual_fifo_base_offset < 0) { printk(KERN_ERR "%s: cannot allocate MURAM for TX FIFO\n", __func__); - uccf->ucc_fast_tx_virtual_fifo_base_offset = 0; ucc_fast_free(uccf); return -ENOMEM; } @@ -278,10 +279,9 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc qe_muram_alloc(uf_info->urfs + UCC_FAST_RECEIVE_VIRTUAL_FIFO_SIZE_FUDGE_FACTOR, UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT); - if (IS_ERR_VALUE(uccf->ucc_fast_rx_virtual_fifo_base_offset)) { + if (uccf->ucc_fast_rx_virtual_fifo_base_offset < 0) { printk(KERN_ERR "%s: cannot allocate MURAM for RX FIFO\n", __func__); - uccf->ucc_fast_rx_virtual_fifo_base_offset = 0; ucc_fast_free(uccf); return -ENOMEM; } @@ -384,11 +384,8 @@ void ucc_fast_free(struct ucc_fast_private * uccf) if (!uccf) return; - if (uccf->ucc_fast_tx_virtual_fifo_base_offset) - qe_muram_free(uccf->ucc_fast_tx_virtual_fifo_base_offset); - - if (uccf->ucc_fast_rx_virtual_fifo_base_offset) - qe_muram_free(uccf->ucc_fast_rx_virtual_fifo_base_offset); + qe_muram_free(uccf->ucc_fast_tx_virtual_fifo_base_offset); + qe_muram_free(uccf->ucc_fast_rx_virtual_fifo_base_offset); if (uccf->uf_regs) iounmap(uccf->uf_regs); diff --git a/include/soc/fsl/qe/ucc_fast.h b/include/soc/fsl/qe/ucc_fast.h index e9cc46042a83..ba0e838f962a 100644 --- a/include/soc/fsl/qe/ucc_fast.h +++ b/include/soc/fsl/qe/ucc_fast.h @@ -188,9 +188,9 @@ struct ucc_fast_private { int stopped_tx; /* Whether channel has been stopped for Tx (STOP_TX, etc.) */ int stopped_rx; /* Whether channel has been stopped for Rx */ - u32 ucc_fast_tx_virtual_fifo_base_offset;/* pointer to base of Tx + s32 ucc_fast_tx_virtual_fifo_base_offset;/* pointer to base of Tx virtual fifo */ - u32 ucc_fast_rx_virtual_fifo_base_offset;/* pointer to base of Rx + s32 ucc_fast_rx_virtual_fifo_base_offset;/* pointer to base of Rx virtual fifo */ #ifdef STATISTICS u32 tx_frames; /* Transmitted frames counter. */ -- 2.23.0