- 论坛徽章:
- 0
|
这是我的ioctl里面的一段代码 标注为红色的那个debug可以打印出数值,但传到应用程序,那个结构体打印出的都是默认的值,我发现copy_to_user里的第一个参数已经被转化为64位。
case VDRIVER_SCAN_CARDS:
{
vdriver_debug("\n");
vdriver_debug("VDRIVER_SCAN_CARDS............\n");
vd_scan_cards = kmalloc(sizeof(VD_PCI_SCAN_CARDS), GFP_KERNEL);
if(copy_from_user(vd_scan_cards, (VD_PCI_SCAN_CARDS *)arg, sizeof(VD_PCI_SCAN_CARDS)))
{
vdriver_error("VDRIVER_SCAN_CARDS comand error !\n");
return -EFAULT;
}
vendorid = vd_scan_cards->searchId.dwVendorId;
deviceid = vd_scan_cards->searchId.dwDeviceId;
if(deviceid == 0)
{
deviceid = PCI_ANY_ID;
}
if(vendorid == 0)
{
vendorid = PCI_ANY_ID;
}
vdriver_debug("The usr params vendorid is %x,deviceid is %x\n",vendorid, deviceid);
do
{
pci_dev = pci_get_device(vendorid, deviceid, pci_dev);
vdriver_debug("vdriver scan cards the pci_dev is %x\n",(unsigned int)pci_dev);
if(pci_dev != NULL)
{
vd_scan_cards->cardId[card_count].dwVendorId = pci_dev->vendor;
vd_scan_cards->cardId[card_count].dwDeviceId = pci_dev->device;
vdriver_debug("vdriver scan cards VendorId is %x,DeviceId is %x\n",pci_dev->vendor,pci_dev->device);
busnum = (pci_dev->bus->number);
devnum = ((pci_dev->devfn)>>3) & 0x1f;
funnum = (pci_dev->devfn) & 0x7;
vd_scan_cards->cardSlot[card_count].dwBus = busnum;
vd_scan_cards->cardSlot[card_count].dwSlot = devnum;
vd_scan_cards->cardSlot[card_count].dwFunction = funnum;
vdriver_debug("vdriver scan cards dwBus is %d,dwSlot is %d,dwFunction is %d\n",(unsigned int)vd_scan_cards->cardSlot[card_count].dwBus,
(unsigned int)vd_scan_cards->cardSlot[card_count].dwSlot,(unsigned int)vd_scan_cards->cardSlot[card_count].dwFunction);
card_ir = pci_dev->irq;
vdriver_debug("vdriver scan cards interrupt num is %x\n",card_ir);
card_count ++;
}
}
while(pci_dev != 0);
vd_scan_cards->dwCards = card_count;
vdriver_debug("Total scan the card number is %d...........\n",(unsigned int)vd_scan_cards->dwCards);
if (copy_to_user((VD_PCI_SCAN_CARDS *)arg, vd_scan_cards, sizeof(VD_PCI_SCAN_CARDS)))
return -EFAULT;
kfree(vd_scan_cards);
break;
}回复 3# Tinnal
|
|