Skip to contentSkip to conversation

aic7xxx driver large integer warning

DISCUSSION Miguel Angel Flores 2 participants 4 messages Dec 6, 2004 – Dec 7, 2004

lore
Share & tools
lore
#0 lore raw

Hi list.

As I said yesterday, the 2.6.10rc3 kernel warns compiling the aic7xxxx SCSI driver:

---
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c: In function `ahc_linux_pci_dev_probe':
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c:229: warning: large integer implicitly truncated to unsigned type
---

[aic7xxx_osm_pci.c]
mask_39bit = 0x7FFFFFFFFFULL;

mask_39bit type is dma_addr_t. However the length of dma_addr_t is defined in types.h.

[types.h]
#ifdef CONFIG_HIGHMEM64G
typedef u64 dma_addr_t;
#else
typedef u32 dma_addr_t;
#endif
typedef u64 dma64_addr_t;

I think the correct solution is to make the assignement only if CONFIG_HIGHMEM64G is defined:

[aic7xxx_osm_pci.c]

       mask_39bit = 0x7FFFFFFFFFULL;  //assignement
       if (sizeof(dma_addr_t) > 4 //CONFIG_HIGHMEM64G is defined
        && ahc_linux_get_memsize() > 0x80000000
        && pci_set_dma_mask(pdev, mask_39bit) == 0) {

           /* the correct position of the assignement IMHO */

           ahc->flags |= AHC_39BIT_ADDRESSING;
           ahc->platform_data->hw_dma_mask = mask_39bit;
       } else {
           if (pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
               printk(KERN_WARNING "aic7xxx: No suitable DMA 
available.\n");
                       return (-ENODEV);
           }
           ahc->platform_data->hw_dma_mask = 0xFFFFFFFF;

Before I post a new patch, I wish to know your opinion.

Thanks,
MaF

#1 lore raw
Quoted 3 lines · Miguel Angel Flores

drivers/scsi/aic7xxx/aic7xxx_osm_pci.c:229: warning: large integer implicitly truncated to unsigned type
---

Add (dma_addr_t) casts and it will go away. The compiler just wants to know you mean it.

#2 lore raw
Quoted 4 lines · Alan Cox

Add (dma_addr_t) casts and it will go away. The compiler just wants to know you mean it.

Sure, but the 39 bit variable is only used when the type of dma_addr_t is u64. I think that is more clean to put this assignement inside the if block, like the rest of the CONFIG_HIGHMEM64G code. Anyway the (dma_addr_t) cast can be added too.

¿how you would solve this?

Cheers,
MaF

#3 lore raw
Quoted 6 lines · Miguel Angel Flores

Sure, but the 39 bit variable is only used when the type of dma_addr_t is u64. I think that is more clean to put this assignement inside the if block, like the rest of the CONFIG_HIGHMEM64G code. Anyway the (dma_addr_t) cast can be added too.

¿how you would solve this?

I'd just add the cast. The compiler will truncate it to FFFFFFFF if appropriate.