Discussion:
[Acx100-devel] [PATCH] Remove remaining warnings on x86_64
Larry Finger
2012-05-11 16:56:35 UTC
Permalink
The previous patch left some warnings on 64-bit systems that are now
removed.

Signed-off-by: Larry Finger <***@lwfinger.net>
---
common.c | 3 ++-
merge.c | 22 +++++++++++-----------
2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/common.c b/common.c
index 2f1b338..25fbc27 100644
--- a/common.c
+++ b/common.c
@@ -1118,7 +1118,8 @@ static int acx100_create_dma_regions(acx_device_t * adev)
#ifdef CONFIG_ACX_MAC80211_MEM
else if (IS_MEM(adev)) {
/* sets the beginning of the rx descriptor queue, after the tx descrs */
- adev->acx_queue_indicator = (queueindicator_t *) le32_to_cpu (queueconf.QueueEnd);
+ adev->acx_queue_indicator = (queueindicator_t *)
+ (ulong)le32_to_cpu(queueconf.QueueEnd);

if (OK != acx_create_hostdesc_queues(adev))
goto fail;
diff --git a/merge.c b/merge.c
index d276ad5..2a35163 100644
--- a/merge.c
+++ b/merge.c
@@ -469,7 +469,7 @@ static void acx_create_rx_desc_queue(acx_device_t * adev, u32 rx_queue_start)
((u8 *) adev->iobase2 + rx_queue_start);
else
adev->rx.desc_start = (rxdesc_t *)
- ((u8 *) rx_queue_start);
+ ((u8 *) (ulong)rx_queue_start);

rxdesc = adev->rx.desc_start;

@@ -482,7 +482,7 @@ static void acx_create_rx_desc_queue(acx_device_t * adev, u32 rx_queue_start)
+ acx2cpu(rxdesc->pNextDesc));
else
adev->rx.desc_start = (rxdesc_t *)
- ((u8 *) acx2cpu(rxdesc->pNextDesc));
+ ((u8 *)(ulong)acx2cpu(rxdesc->pNextDesc));

rxdesc = adev->rx.desc_start;
}
@@ -523,7 +523,7 @@ static void acx_create_rx_desc_queue(acx_device_t * adev, u32 rx_queue_start)
{
write_slavemem32(adev,
(ulong) &(rxdesc->pNextDesc),
- (u32) cpu_to_le32 ((u8 *) rxdesc
+ (u32) cpu_to_le32 ((ulong)(u8 *) rxdesc
+ sizeof(*rxdesc)));
}

@@ -566,7 +566,7 @@ static void acx_create_tx_desc_queue(acx_device_t *adev, u32 tx_queue_start)
/* This refers to an ACX address, not one of ours */
adev->tx.desc_start = (IS_PCI(adev))
? (txdesc_t *) (adev->iobase2 + tx_queue_start)
- : (txdesc_t *) tx_queue_start;
+ : (txdesc_t *) (ulong)tx_queue_start;

log(L_DEBUG, "adev->iobase2=%p\n"
"tx_queue_start=%08X\n"
@@ -652,8 +652,8 @@ static void acx_create_tx_desc_queue(acx_device_t *adev, u32 tx_queue_start)

/* point to next txdesc */
write_slavemem32(adev, (ulong) &(txdesc->pNextDesc),
- (u32) cpu_to_le32 ((u8 *) txdesc
- + adev->tx.desc_size));
+ (u32)cpu_to_le32((ulong)(u8 *)txdesc
+ + adev->tx.desc_size));

/* go to the next one */
/* ++ is safe here (we are acx100) */
@@ -1551,7 +1551,7 @@ void acx_write_cmd_type_status(acx_device_t *adev, u16 type, u16 status)
// static inline
void acx_init_mboxes(acx_device_t *adev)
{
- u32 cmd_offs, info_offs;
+ ulong cmd_offs, info_offs;

FN_ENTER;

@@ -1567,10 +1567,10 @@ void acx_init_mboxes(acx_device_t *adev)
adev->info_area = (u8 *) adev->iobase2 + info_offs;
}
// OW iobase2 not used in mem.c, in pci.c it is
- log(L_DEBUG, "iobase2=%p cmd_mbox_offset=%X cmd_area=%p"
- "info_mbox_offset=%X info_area=%p\n",
- adev->iobase2, cmd_offs, adev->cmd_area,
- info_offs, adev->info_area);
+ log(L_DEBUG,
+ "iobase2=%p cmd_mbox_offset=%lX cmd_area=%pinfo_mbox_offset=%lX info_area=%p\n",
+ adev->iobase2, cmd_offs, adev->cmd_area,
+ info_offs, adev->info_area);

FN_EXIT0;
}
--
1.7.9.2
Larry Finger
2012-05-11 19:49:34 UTC
Permalink
Post by Larry Finger
The previous patch left some warnings on 64-bit systems that are now
removed.
---
common.c | 3 ++-
merge.c | 22 +++++++++++-----------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/common.c b/common.c
index 2f1b338..25fbc27 100644
--- a/common.c
+++ b/common.c
@@ -1118,7 +1118,8 @@ static int acx100_create_dma_regions(acx_device_t * adev)
#ifdef CONFIG_ACX_MAC80211_MEM
else if (IS_MEM(adev)) {
/* sets the beginning of the rx descriptor queue, after the tx descrs */
- adev->acx_queue_indicator = (queueindicator_t *) le32_to_cpu
(queueconf.QueueEnd);
+ adev->acx_queue_indicator = (queueindicator_t *)
+ (ulong)le32_to_cpu(queueconf.QueueEnd);
How can this and the other conversion (see rest of patch) of a 32 bit
numeric value to a 64 bit pointer work?
Maybe it works on a 64 bit host which only uses memory addresses in the
first 4 GiB, but I don't expect that this is really safe for any host.
For those cases where conversions from numeric values to pointers need
a type cast, (uintptr_t) or (intptr_t) would be better, because those
data types are specially designed to have the same size as a pointer.
Thanks for the comment. I was not aware of those particular type casts. My test
box has only 2 GB RAM, and I certainly cannot test for memory > 4 GB.

I will respin the patch and the one that did not go to the list. It will have
the same problems.

Larry

Loading...