Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6875855ybc; Thu, 28 Nov 2019 07:01:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzQdQxvMaaaj17sNHfnnqUjSsGIr88Jj5V00L5uTdvEzLepA2spKS2e7Xs/ora6zenbaF1d X-Received: by 2002:a05:6402:714:: with SMTP id w20mr34753923edx.93.1574953274350; Thu, 28 Nov 2019 07:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574953274; cv=none; d=google.com; s=arc-20160816; b=buAzCM3GP9mEy6UZILbk3rSGCV4w4G7RR3P7fogGBRrdMfmhsBb4uS5kyX/uK6FZ+y 5RQTen0afNtFfizm4P6huiVpCdWqwnwuGy174VjAin4KJ8Tagm3zubQFD/wM534JPKCq vHZW9aQWuLfJhYycsryMg27KG0Lf0m3DUS86g8azYgDC2RURwFxr4iFxiKJoFv137ZjL rdrji1MUWg6MGjM6PtL5W+VyNGTIsSA0IpA0Ip6OhVbFcizWXDmZY89WpLcJLg7CjFTL rObp1qQxyvf9CUKwkfMANNw/SauMxj7rGSEBevY1+2tjIyJaEg1jnB+ahm7li9j8Rz2l TZ/w== 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=72sEWcRrZShV6+ZtrbY8IpuEizwarRLNFp/8lkLUzfY=; b=fdhEt6zTClWU5sNxZZIjCKmNtfURXRoNezH+eZ4JrRb8C/IZPa/EWXmku8DXcMhWWB bI+Cq3cWQcapJdsH9HQnFYzvcUMgrIOfojnDLdfKE9C3K21Rkhxj7munA+rwM0iSDmhQ 74HWUORVhR4AHnZj/LQBMyq4++HvwiWZrVjL7+BnqaMLrC6m3Ve1ok1NcxNmXYJYNw/G G7HAQgwA8IU5kDRmTL2FyI5ZTjgIyXvTjKUuCMGVxk5CtW1Skuv1TuXnbkgmvD0cTdxT PhBnlzStqDcE2arhw8bvPGRYkjSAJL4+8sMBkfPIvtT2D49jKEb0MgackFAemYDr2nhy bOPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=GU+FHdBJ; 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 pw17si12478555ejb.45.2019.11.28.07.00.47; Thu, 28 Nov 2019 07:01:14 -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=GU+FHdBJ; 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 S1727702AbfK1O6x (ORCPT + 99 others); Thu, 28 Nov 2019 09:58:53 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:38732 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727534AbfK1O6A (ORCPT ); Thu, 28 Nov 2019 09:58:00 -0500 Received: by mail-lf1-f67.google.com with SMTP id r14so4005778lfm.5 for ; Thu, 28 Nov 2019 06:57:58 -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=72sEWcRrZShV6+ZtrbY8IpuEizwarRLNFp/8lkLUzfY=; b=GU+FHdBJRYkw5UkPWN7s3g70/83WQOEmISQwX9qSdRVD3WHOUaGAFdBUx3Sme7fjHL /Z+7qlogtJH6EcMtuHnCJMLrZd5CaVdwbfAxgYfHduzeaVVIkMdpB925f242Mn00PfSy RuXGBWmdfSaOhpduQ3XxsbwxqdAElKPZlwwik= 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=72sEWcRrZShV6+ZtrbY8IpuEizwarRLNFp/8lkLUzfY=; b=ABwR8d+KKNt+NDRYEO0fI3VWhz7qovt0Pn8qSR+U/EK+LBT3coVQXIsmKG2k/rIuQw V+w2hktxZ2U2erpaEVqa3x3tKxyfbySVAVFk/AO11E0ooZAxzW5wCPd2eww0PLsSGyrN akAJJ4xyZDFY7aRRqDcbMZfF++cM9LAiCQmuHwlaAtt3V4Pk+69wiyON5j9Ncsg++MCJ Z/6yg5YjCUAxOvfFXV/IHHliFOeteST/OJ+yfQo7Ish58Zi+XmBLyot9xUEKSKysmnQX a+SvLsXpA8GvvnvfEVhN8+CmQ3wO8mzRKuhJty1T0+Z3Clx2WXOukv4fqfZr7p4ELEMN xicw== X-Gm-Message-State: APjAAAXU1vtjG5I8Y6UEIMNZczbHTZzz1ue4g138ret+KZrRkYylBjJx p5my1hwjoQ2u1buidRvc3ILr5IDhf3kggiS5 X-Received: by 2002:a19:6b04:: with SMTP id d4mr33009525lfa.10.1574953077507; Thu, 28 Nov 2019 06:57:57 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id u2sm2456803lfl.18.2019.11.28.06.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 06:57:57 -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 , Timur Tabi , Rasmus Villemoes Subject: [PATCH v6 40/49] soc: fsl: qe: avoid IS_ERR_VALUE in ucc_slow.c Date: Thu, 28 Nov 2019 15:55:45 +0100 Message-Id: <20191128145554.1297-41-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191128145554.1297-1-linux@rasmusvillemoes.dk> References: <20191128145554.1297-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 trying to build this for a 64-bit platform, one gets warnings from using IS_ERR_VALUE on something which is not sizeof(long). Instead, change the various *_offset fields to store a signed integer, and simply check for a negative return from qe_muram_alloc(). Since qe_muram_free() now accepts and ignores a negative argument, we only need to make sure these fields are initialized with -1, and we can just unconditionally call qe_muram_free() in ucc_slow_free(). Note that the error case for us_pram_offset failed to set that field to 0 (which, as noted earlier, is anyway a bogus sentinel value). Reviewed-by: Timur Tabi Signed-off-by: Rasmus Villemoes --- drivers/soc/fsl/qe/ucc_slow.c | 22 +++++++++------------- include/soc/fsl/qe/ucc_slow.h | 6 +++--- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/soc/fsl/qe/ucc_slow.c b/drivers/soc/fsl/qe/ucc_slow.c index 9b55fd0f50c6..274d34449846 100644 --- a/drivers/soc/fsl/qe/ucc_slow.c +++ b/drivers/soc/fsl/qe/ucc_slow.c @@ -154,6 +154,9 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc __func__); return -ENOMEM; } + uccs->rx_base_offset = -1; + uccs->tx_base_offset = -1; + uccs->us_pram_offset = -1; /* Fill slow UCC structure */ uccs->us_info = us_info; @@ -179,7 +182,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc /* Get PRAM base */ uccs->us_pram_offset = qe_muram_alloc(UCC_SLOW_PRAM_SIZE, ALIGNMENT_OF_UCC_SLOW_PRAM); - if (IS_ERR_VALUE(uccs->us_pram_offset)) { + if (uccs->us_pram_offset < 0) { printk(KERN_ERR "%s: cannot allocate MURAM for PRAM", __func__); ucc_slow_free(uccs); return -ENOMEM; @@ -206,10 +209,9 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc uccs->rx_base_offset = qe_muram_alloc(us_info->rx_bd_ring_len * sizeof(struct qe_bd), QE_ALIGNMENT_OF_BD); - if (IS_ERR_VALUE(uccs->rx_base_offset)) { + if (uccs->rx_base_offset < 0) { printk(KERN_ERR "%s: cannot allocate %u RX BDs\n", __func__, us_info->rx_bd_ring_len); - uccs->rx_base_offset = 0; ucc_slow_free(uccs); return -ENOMEM; } @@ -217,9 +219,8 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc uccs->tx_base_offset = qe_muram_alloc(us_info->tx_bd_ring_len * sizeof(struct qe_bd), QE_ALIGNMENT_OF_BD); - if (IS_ERR_VALUE(uccs->tx_base_offset)) { + if (uccs->tx_base_offset < 0) { printk(KERN_ERR "%s: cannot allocate TX BDs", __func__); - uccs->tx_base_offset = 0; ucc_slow_free(uccs); return -ENOMEM; } @@ -352,14 +353,9 @@ void ucc_slow_free(struct ucc_slow_private * uccs) if (!uccs) return; - if (uccs->rx_base_offset) - qe_muram_free(uccs->rx_base_offset); - - if (uccs->tx_base_offset) - qe_muram_free(uccs->tx_base_offset); - - if (uccs->us_pram) - qe_muram_free(uccs->us_pram_offset); + qe_muram_free(uccs->rx_base_offset); + qe_muram_free(uccs->tx_base_offset); + qe_muram_free(uccs->us_pram_offset); if (uccs->us_regs) iounmap(uccs->us_regs); diff --git a/include/soc/fsl/qe/ucc_slow.h b/include/soc/fsl/qe/ucc_slow.h index 8696fdea2ae9..d187a6be83bc 100644 --- a/include/soc/fsl/qe/ucc_slow.h +++ b/include/soc/fsl/qe/ucc_slow.h @@ -185,7 +185,7 @@ struct ucc_slow_private { struct ucc_slow_info *us_info; struct ucc_slow __iomem *us_regs; /* Ptr to memory map of UCC regs */ struct ucc_slow_pram *us_pram; /* a pointer to the parameter RAM */ - u32 us_pram_offset; + s32 us_pram_offset; int enabled_tx; /* Whether channel is enabled for Tx (ENT) */ int enabled_rx; /* Whether channel is enabled for Rx (ENR) */ int stopped_tx; /* Whether channel has been stopped for Tx @@ -194,8 +194,8 @@ struct ucc_slow_private { struct list_head confQ; /* frames passed to chip waiting for tx */ u32 first_tx_bd_mask; /* mask is used in Tx routine to save status and length for first BD in a frame */ - u32 tx_base_offset; /* first BD in Tx BD table offset (In MURAM) */ - u32 rx_base_offset; /* first BD in Rx BD table offset (In MURAM) */ + s32 tx_base_offset; /* first BD in Tx BD table offset (In MURAM) */ + s32 rx_base_offset; /* first BD in Rx BD table offset (In MURAM) */ struct qe_bd *confBd; /* next BD for confirm after Tx */ struct qe_bd *tx_bd; /* next BD for new Tx request */ struct qe_bd *rx_bd; /* next BD to collect after Rx */ -- 2.23.0