[staging:staging-next 143/420] drivers/staging/android/vsoc.c:804:4: warning: cast to pointer from integer of different size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git staging-next
head:   fec2dbfeba0967fbb4cdf69114db29d5333d8a8f
commit: 3d2ec9dcd5539d421a6814ded10a1a3008e70548 [143/420] staging: Android: Add 'vsoc' driver for cuttlefish.
config: i386-randconfig-n0-201817 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        git checkout 3d2ec9dcd5539d421a6814ded10a1a3008e70548
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/linux/dma-mapping.h:7:0,
                    from drivers/staging/android/vsoc.c:28:
   drivers/staging/android/vsoc.c: In function 'vsoc_probe_device':
>> drivers/staging/android/vsoc.c:804:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       (void *)vsoc_dev.shm_phys_start, vsoc_dev.shm_size);
       ^
   include/linux/device.h:1382:58: note: in definition of macro 'dev_info'
    #define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
                                                             ^~~

vim +804 drivers/staging/android/vsoc.c

   758	
   759	static int vsoc_probe_device(struct pci_dev *pdev,
   760				     const struct pci_device_id *ent)
   761	{
   762		int result;
   763		int i;
   764		resource_size_t reg_size;
   765		dev_t devt;
   766	
   767		vsoc_dev.dev = pdev;
   768		result = pci_enable_device(pdev);
   769		if (result) {
   770			dev_err(&pdev->dev,
   771				"pci_enable_device failed %s: error %d\n",
   772				pci_name(pdev), result);
   773			return result;
   774		}
   775		vsoc_dev.enabled_device = 1;
   776		result = pci_request_regions(pdev, "vsoc");
   777		if (result < 0) {
   778			dev_err(&pdev->dev, "pci_request_regions failed\n");
   779			vsoc_remove_device(pdev);
   780			return -EBUSY;
   781		}
   782		vsoc_dev.requested_regions = 1;
   783		/* Set up the control registers in BAR 0 */
   784		reg_size = pci_resource_len(pdev, REGISTER_BAR);
   785		if (reg_size > MAX_REGISTER_BAR_LEN)
   786			vsoc_dev.regs =
   787			    pci_iomap(pdev, REGISTER_BAR, MAX_REGISTER_BAR_LEN);
   788		else
   789			vsoc_dev.regs = pci_iomap(pdev, REGISTER_BAR, reg_size);
   790	
   791		if (!vsoc_dev.regs) {
   792			dev_err(&pdev->dev,
   793				"cannot ioremap registers of size %zu\n",
   794			       (size_t)reg_size);
   795			vsoc_remove_device(pdev);
   796			return -EBUSY;
   797		}
   798	
   799		/* Map the shared memory in BAR 2 */
   800		vsoc_dev.shm_phys_start = pci_resource_start(pdev, SHARED_MEMORY_BAR);
   801		vsoc_dev.shm_size = pci_resource_len(pdev, SHARED_MEMORY_BAR);
   802	
   803		dev_info(&pdev->dev, "shared memory @ DMA %p size=0x%zx\n",
 > 804			 (void *)vsoc_dev.shm_phys_start, vsoc_dev.shm_size);
   805		/* TODO(ghartman): ioremap_wc should work here */
   806		vsoc_dev.kernel_mapped_shm = ioremap_nocache(
   807				vsoc_dev.shm_phys_start, vsoc_dev.shm_size);
   808		if (!vsoc_dev.kernel_mapped_shm) {
   809			dev_err(&vsoc_dev.dev->dev, "cannot iomap region\n");
   810			vsoc_remove_device(pdev);
   811			return -EBUSY;
   812		}
   813	
   814		vsoc_dev.layout =
   815		    (struct vsoc_shm_layout_descriptor *)vsoc_dev.kernel_mapped_shm;
   816		dev_info(&pdev->dev, "major_version: %d\n",
   817			 vsoc_dev.layout->major_version);
   818		dev_info(&pdev->dev, "minor_version: %d\n",
   819			 vsoc_dev.layout->minor_version);
   820		dev_info(&pdev->dev, "size: 0x%x\n", vsoc_dev.layout->size);
   821		dev_info(&pdev->dev, "regions: %d\n", vsoc_dev.layout->region_count);
   822		if (vsoc_dev.layout->major_version !=
   823		    CURRENT_VSOC_LAYOUT_MAJOR_VERSION) {
   824			dev_err(&vsoc_dev.dev->dev,
   825				"driver supports only major_version %d\n",
   826				CURRENT_VSOC_LAYOUT_MAJOR_VERSION);
   827			vsoc_remove_device(pdev);
   828			return -EBUSY;
   829		}
   830		result = alloc_chrdev_region(&devt, 0, vsoc_dev.layout->region_count,
   831					     VSOC_DEV_NAME);
   832		if (result) {
   833			dev_err(&vsoc_dev.dev->dev, "alloc_chrdev_region failed\n");
   834			vsoc_remove_device(pdev);
   835			return -EBUSY;
   836		}
   837		vsoc_dev.major = MAJOR(devt);
   838		cdev_init(&vsoc_dev.cdev, &vsoc_ops);
   839		vsoc_dev.cdev.owner = THIS_MODULE;
   840		result = cdev_add(&vsoc_dev.cdev, devt, vsoc_dev.layout->region_count);
   841		if (result) {
   842			dev_err(&vsoc_dev.dev->dev, "cdev_add error\n");
   843			vsoc_remove_device(pdev);
   844			return -EBUSY;
   845		}
   846		vsoc_dev.cdev_added = 1;
   847		vsoc_dev.class = class_create(THIS_MODULE, VSOC_DEV_NAME);
   848		if (IS_ERR(vsoc_dev.class)) {
   849			dev_err(&vsoc_dev.dev->dev, "class_create failed\n");
   850			vsoc_remove_device(pdev);
   851			return PTR_ERR(vsoc_dev.class);
   852		}
   853		vsoc_dev.class_added = 1;
   854		vsoc_dev.regions = (struct vsoc_device_region *)
   855			(vsoc_dev.kernel_mapped_shm +
   856			 vsoc_dev.layout->vsoc_region_desc_offset);
   857		vsoc_dev.msix_entries = kcalloc(
   858				vsoc_dev.layout->region_count,
   859				sizeof(vsoc_dev.msix_entries[0]), GFP_KERNEL);
   860		if (!vsoc_dev.msix_entries) {
   861			dev_err(&vsoc_dev.dev->dev,
   862				"unable to allocate msix_entries\n");
   863			vsoc_remove_device(pdev);
   864			return -ENOSPC;
   865		}
   866		vsoc_dev.regions_data = kcalloc(
   867				vsoc_dev.layout->region_count,
   868				sizeof(vsoc_dev.regions_data[0]), GFP_KERNEL);
   869		if (!vsoc_dev.regions_data) {
   870			dev_err(&vsoc_dev.dev->dev,
   871				"unable to allocate regions' data\n");
   872			vsoc_remove_device(pdev);
   873			return -ENOSPC;
   874		}
   875		for (i = 0; i < vsoc_dev.layout->region_count; ++i)
   876			vsoc_dev.msix_entries[i].entry = i;
   877	
   878		result = pci_enable_msix_exact(vsoc_dev.dev, vsoc_dev.msix_entries,
   879					       vsoc_dev.layout->region_count);
   880		if (result) {
   881			dev_info(&pdev->dev, "pci_enable_msix failed: %d\n", result);
   882			vsoc_remove_device(pdev);
   883			return -ENOSPC;
   884		}
   885		/* Check that all regions are well formed */
   886		for (i = 0; i < vsoc_dev.layout->region_count; ++i) {
   887			const struct vsoc_device_region *region = vsoc_dev.regions + i;
   888	
   889			if (!PAGE_ALIGNED(region->region_begin_offset) ||
   890			    !PAGE_ALIGNED(region->region_end_offset)) {
   891				dev_err(&vsoc_dev.dev->dev,
   892					"region %d not aligned (%x:%x)", i,
   893					region->region_begin_offset,
   894					region->region_end_offset);
   895				vsoc_remove_device(pdev);
   896				return -EFAULT;
   897			}
   898			if (region->region_begin_offset >= region->region_end_offset ||
   899			    region->region_end_offset > vsoc_dev.shm_size) {
   900				dev_err(&vsoc_dev.dev->dev,
   901					"region %d offsets are wrong: %x %x %zx",
   902					i, region->region_begin_offset,
   903					region->region_end_offset, vsoc_dev.shm_size);
   904				vsoc_remove_device(pdev);
   905				return -EFAULT;
   906			}
   907			if (region->managed_by >= vsoc_dev.layout->region_count) {
   908				dev_err(&vsoc_dev.dev->dev,
   909					"region %d has invalid owner: %u",
   910					i, region->managed_by);
   911				vsoc_remove_device(pdev);
   912				return -EFAULT;
   913			}
   914		}
   915		vsoc_dev.msix_enabled = 1;
   916		for (i = 0; i < vsoc_dev.layout->region_count; ++i) {
   917			const struct vsoc_device_region *region = vsoc_dev.regions + i;
   918			size_t name_sz = sizeof(vsoc_dev.regions_data[i].name) - 1;
   919			const struct vsoc_signal_table_layout *h_to_g_signal_table =
   920				&region->host_to_guest_signal_table;
   921			const struct vsoc_signal_table_layout *g_to_h_signal_table =
   922				&region->guest_to_host_signal_table;
   923	
   924			vsoc_dev.regions_data[i].name[name_sz] = '\0';
   925			memcpy(vsoc_dev.regions_data[i].name, region->device_name,
   926			       name_sz);
   927			dev_info(&pdev->dev, "region %d name=%s\n",
   928				 i, vsoc_dev.regions_data[i].name);
   929			init_waitqueue_head(
   930					&vsoc_dev.regions_data[i].interrupt_wait_queue);
   931			init_waitqueue_head(&vsoc_dev.regions_data[i].futex_wait_queue);
   932			vsoc_dev.regions_data[i].incoming_signalled =
   933				vsoc_dev.kernel_mapped_shm +
   934				region->region_begin_offset +
   935				h_to_g_signal_table->interrupt_signalled_offset;
   936			vsoc_dev.regions_data[i].outgoing_signalled =
   937				vsoc_dev.kernel_mapped_shm +
   938				region->region_begin_offset +
   939				g_to_h_signal_table->interrupt_signalled_offset;
   940	
   941			result = request_irq(
   942					vsoc_dev.msix_entries[i].vector,
   943					vsoc_interrupt, 0,
   944					vsoc_dev.regions_data[i].name,
   945					vsoc_dev.regions_data + i);
   946			if (result) {
   947				dev_info(&pdev->dev,
   948					 "request_irq failed irq=%d vector=%d\n",
   949					i, vsoc_dev.msix_entries[i].vector);
   950				vsoc_remove_device(pdev);
   951				return -ENOSPC;
   952			}
   953			vsoc_dev.regions_data[i].irq_requested = 1;
   954			if (!device_create(vsoc_dev.class, NULL,
   955					   MKDEV(vsoc_dev.major, i),
   956					   NULL, vsoc_dev.regions_data[i].name)) {
   957				dev_err(&vsoc_dev.dev->dev, "device_create failed\n");
   958				vsoc_remove_device(pdev);
   959				return -EBUSY;
   960			}
   961			vsoc_dev.regions_data[i].device_created = 1;
   962		}
   963		return 0;
   964	}
   965	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux