[PATCH 06/18] staging: comedi: addi-data: absorb pci_card_alloc() into i_ADDI_Attach()

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

 



The function pci_card_alloc() enables the pci device by calling
comedi_pci_enable() and then optionally calls pci_set_master() to
enable bus mastering for DMA.

Absorb this code directly into i_ADDI_Attach() as is more typical
for comedi PCI drivers. Also, remove the now unused i_Master
parameter from ptr_select_and_alloc_pci_card().

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 .../comedi/drivers/addi-data/addi_amcc_s5933.h     | 31 ++--------------------
 .../staging/comedi/drivers/addi-data/addi_common.c |  8 +++++-
 2 files changed, 9 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
index 27c3fba..b3035b5 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
+++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
@@ -224,10 +224,8 @@ int i_find_free_pci_card_by_position(unsigned short vendor_id,
 struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
 						    unsigned short device_id,
 						    unsigned short pci_bus,
-						    unsigned short pci_slot,
-						    int i_Master);
+						    unsigned short pci_slot);
 
-int pci_card_alloc(struct pcilst_struct *amcc, int master);
 int i_pci_card_free(struct pcilst_struct *amcc);
 
 /****************************************************************************/
@@ -332,24 +330,6 @@ int i_find_free_pci_card_by_position(unsigned short vendor_id,
 }
 
 /****************************************************************************/
-/* mark card as used */
-int pci_card_alloc(struct pcilst_struct *amcc, int master)
-{
-	if (!amcc)
-		return -1;
-
-	if (amcc->used)
-		return 1;
-	if (comedi_pci_enable(amcc->pcidev, "addi_amcc_s5933"))
-		return -1;
-	if (master)
-		pci_set_master(amcc->pcidev);
-	amcc->used = 1;
-
-	return 0;
-}
-
-/****************************************************************************/
 /* mark card as free */
 int i_pci_card_free(struct pcilst_struct *amcc)
 {
@@ -368,8 +348,7 @@ int i_pci_card_free(struct pcilst_struct *amcc)
 struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
 						    unsigned short device_id,
 						    unsigned short pci_bus,
-						    unsigned short pci_slot,
-						    int i_Master)
+						    unsigned short pci_slot)
 {
 	struct pcilst_struct *card;
 
@@ -395,12 +374,6 @@ struct pcilst_struct *ptr_select_and_alloc_pci_card(unsigned short vendor_id,
 		}
 	}
 
-	if (pci_card_alloc(card, i_Master) != 0) {
-		printk(" - Can't allocate card!\n");
-		return NULL;
-
-	}
-
 	return card;
 }
 #endif
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c
index b6130f8..6ed851f 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_common.c
+++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c
@@ -112,11 +112,17 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	card = ptr_select_and_alloc_pci_card(this_board->i_VendorId,
 					     this_board->i_DeviceId,
 					     it->options[0],
-					     it->options[1], i_Dma);
+					     it->options[1]);
 
 	if (card == NULL)
 		return -EIO;
 
+	ret = comedi_pci_enable(card->pcidev, "addi_amcc_s5933");
+	if (ret)
+		return ret;
+	if (i_Dma)
+		pci_set_master(card->pcidev);
+	card->used = 1;
 	devpriv->allocated = 1;
 
 	iobase_a = pci_resource_start(card->pcidev, 0);
-- 
1.7.11

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/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