Skip to content

Commit 611780a

Browse files
VillemoesLi Yang
authored andcommitted
soc: fsl: qe: avoid IS_ERR_VALUE in ucc_slow.c
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 <timur@kernel.org> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Li Yang <leoyang.li@nxp.com>
1 parent ec2058a commit 611780a

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

‎drivers/soc/fsl/qe/ucc_slow.c‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
154154
__func__);
155155
return -ENOMEM;
156156
}
157+
uccs->rx_base_offset = -1;
158+
uccs->tx_base_offset = -1;
159+
uccs->us_pram_offset = -1;
157160

158161
/* Fill slow UCC structure */
159162
uccs->us_info = us_info;
@@ -179,7 +182,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
179182
/* Get PRAM base */
180183
uccs->us_pram_offset =
181184
qe_muram_alloc(UCC_SLOW_PRAM_SIZE, ALIGNMENT_OF_UCC_SLOW_PRAM);
182-
if (IS_ERR_VALUE(uccs->us_pram_offset)) {
185+
if (uccs->us_pram_offset < 0) {
183186
printk(KERN_ERR "%s: cannot allocate MURAM for PRAM", __func__);
184187
ucc_slow_free(uccs);
185188
return -ENOMEM;
@@ -206,20 +209,18 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
206209
uccs->rx_base_offset =
207210
qe_muram_alloc(us_info->rx_bd_ring_len * sizeof(struct qe_bd),
208211
QE_ALIGNMENT_OF_BD);
209-
if (IS_ERR_VALUE(uccs->rx_base_offset)) {
212+
if (uccs->rx_base_offset < 0) {
210213
printk(KERN_ERR "%s: cannot allocate %u RX BDs\n", __func__,
211214
us_info->rx_bd_ring_len);
212-
uccs->rx_base_offset = 0;
213215
ucc_slow_free(uccs);
214216
return -ENOMEM;
215217
}
216218

217219
uccs->tx_base_offset =
218220
qe_muram_alloc(us_info->tx_bd_ring_len * sizeof(struct qe_bd),
219221
QE_ALIGNMENT_OF_BD);
220-
if (IS_ERR_VALUE(uccs->tx_base_offset)) {
222+
if (uccs->tx_base_offset < 0) {
221223
printk(KERN_ERR "%s: cannot allocate TX BDs", __func__);
222-
uccs->tx_base_offset = 0;
223224
ucc_slow_free(uccs);
224225
return -ENOMEM;
225226
}
@@ -352,14 +353,9 @@ void ucc_slow_free(struct ucc_slow_private * uccs)
352353
if (!uccs)
353354
return;
354355

355-
if (uccs->rx_base_offset)
356-
qe_muram_free(uccs->rx_base_offset);
357-
358-
if (uccs->tx_base_offset)
359-
qe_muram_free(uccs->tx_base_offset);
360-
361-
if (uccs->us_pram)
362-
qe_muram_free(uccs->us_pram_offset);
356+
qe_muram_free(uccs->rx_base_offset);
357+
qe_muram_free(uccs->tx_base_offset);
358+
qe_muram_free(uccs->us_pram_offset);
363359

364360
if (uccs->us_regs)
365361
iounmap(uccs->us_regs);

‎include/soc/fsl/qe/ucc_slow.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ struct ucc_slow_private {
185185
struct ucc_slow_info *us_info;
186186
struct ucc_slow __iomem *us_regs; /* Ptr to memory map of UCC regs */
187187
struct ucc_slow_pram *us_pram; /* a pointer to the parameter RAM */
188-
u32 us_pram_offset;
188+
s32 us_pram_offset;
189189
int enabled_tx; /* Whether channel is enabled for Tx (ENT) */
190190
int enabled_rx; /* Whether channel is enabled for Rx (ENR) */
191191
int stopped_tx; /* Whether channel has been stopped for Tx
@@ -194,8 +194,8 @@ struct ucc_slow_private {
194194
struct list_head confQ; /* frames passed to chip waiting for tx */
195195
u32 first_tx_bd_mask; /* mask is used in Tx routine to save status
196196
and length for first BD in a frame */
197-
u32 tx_base_offset; /* first BD in Tx BD table offset (In MURAM) */
198-
u32 rx_base_offset; /* first BD in Rx BD table offset (In MURAM) */
197+
s32 tx_base_offset; /* first BD in Tx BD table offset (In MURAM) */
198+
s32 rx_base_offset; /* first BD in Rx BD table offset (In MURAM) */
199199
struct qe_bd *confBd; /* next BD for confirm after Tx */
200200
struct qe_bd *tx_bd; /* next BD for new Tx request */
201201
struct qe_bd *rx_bd; /* next BD to collect after Rx */

0 commit comments

Comments
 (0)