staging: comedi: mite: use pci_ioremap_bar()
Use pci_ioremap_bar() to ioremap the PCI resources. That function just takes the pci device and a bar number. It also has some additional sanity checks to make sure the bar is actually a memory resource. This also makes sure that the entire PCI bar is ioremap'ed instead of assuming the size of a bar. For aesthetic reasons, don't set the private data phys_addr vars until after the ioremap is successful. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
b153c68dce
commit
cc3750883c
1 changed files with 5 additions and 16 deletions
|
@ -58,10 +58,6 @@
|
||||||
#include "comedi_fc.h"
|
#include "comedi_fc.h"
|
||||||
#include "mite.h"
|
#include "mite.h"
|
||||||
|
|
||||||
#define PCI_MITE_SIZE 4096
|
|
||||||
#define PCI_DAQ_SIZE 4096
|
|
||||||
#define PCI_DAQ_SIZE_660X 8192
|
|
||||||
|
|
||||||
#define TOP_OF_PAGE(x) ((x)|(~(PAGE_MASK)))
|
#define TOP_OF_PAGE(x) ((x)|(~(PAGE_MASK)))
|
||||||
|
|
||||||
struct mite_struct *mite_alloc(struct pci_dev *pcidev)
|
struct mite_struct *mite_alloc(struct pci_dev *pcidev)
|
||||||
|
@ -104,35 +100,28 @@ static unsigned mite_fifo_size(struct mite_struct *mite, unsigned channel)
|
||||||
int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
|
int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
|
||||||
{
|
{
|
||||||
unsigned long length;
|
unsigned long length;
|
||||||
resource_size_t addr;
|
|
||||||
int i;
|
int i;
|
||||||
u32 csigr_bits;
|
u32 csigr_bits;
|
||||||
unsigned unknown_dma_burst_bits;
|
unsigned unknown_dma_burst_bits;
|
||||||
|
|
||||||
pci_set_master(mite->pcidev);
|
pci_set_master(mite->pcidev);
|
||||||
|
|
||||||
addr = pci_resource_start(mite->pcidev, 0);
|
mite->mite_io_addr = pci_ioremap_bar(mite->pcidev, 0);
|
||||||
mite->mite_phys_addr = addr;
|
|
||||||
mite->mite_io_addr = ioremap(addr, PCI_MITE_SIZE);
|
|
||||||
if (!mite->mite_io_addr) {
|
if (!mite->mite_io_addr) {
|
||||||
dev_err(&mite->pcidev->dev,
|
dev_err(&mite->pcidev->dev,
|
||||||
"Failed to remap mite io memory address\n");
|
"Failed to remap mite io memory address\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
mite->mite_phys_addr = pci_resource_start(mite->pcidev, 0);
|
||||||
|
|
||||||
addr = pci_resource_start(mite->pcidev, 1);
|
mite->daq_io_addr = pci_ioremap_bar(mite->pcidev, 1);
|
||||||
mite->daq_phys_addr = addr;
|
|
||||||
length = pci_resource_len(mite->pcidev, 1);
|
|
||||||
/*
|
|
||||||
* In case of a 660x board, DAQ size is 8k instead of 4k
|
|
||||||
* (see as shown by lspci output)
|
|
||||||
*/
|
|
||||||
mite->daq_io_addr = ioremap(mite->daq_phys_addr, length);
|
|
||||||
if (!mite->daq_io_addr) {
|
if (!mite->daq_io_addr) {
|
||||||
dev_err(&mite->pcidev->dev,
|
dev_err(&mite->pcidev->dev,
|
||||||
"Failed to remap daq io memory address\n");
|
"Failed to remap daq io memory address\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
mite->daq_phys_addr = pci_resource_start(mite->pcidev, 1);
|
||||||
|
length = pci_resource_len(mite->pcidev, 1);
|
||||||
|
|
||||||
if (use_iodwbsr_1) {
|
if (use_iodwbsr_1) {
|
||||||
writel(0, mite->mite_io_addr + MITE_IODWBSR);
|
writel(0, mite->mite_io_addr + MITE_IODWBSR);
|
||||||
|
|
Loading…
Add table
Reference in a new issue