Re: [PATCH 3/7] staging: comedi: amplc_pci230: Add attach_pci() hook

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

 



On 04/06/12 23:39, H Hartley Sweeten wrote:
On Friday, June 01, 2012 9:32 AM, Ian Abbott wrote:
Implement the attach_pci() hook as function pci230_attach_pci().  This
is called by comedi_pci_auto_config() in preference to the old attach()
hook (implemented by pci230_attach() and still required for "manual"
configuration of comedi devices).  The advantage of the attach_pci()
hook is that it avoids searching for the PCI device.

Refactor pci230_attach() and factor out code common to pci230_attach()
and pci230_attach_pci() into new functions pci230_match_pci_board(),
pci230_find_pci_board(), pci230_find_pci(), pci230_alloc_private() and
pci230_attach_common().

Finally, move pci230_attach() and pci230_detach() along with all the new
functions towards the bottom of the file as it makes the patch much
cleaner (though longer) and I plan to move things around soon to get
rid of the remaining forward references.

Signed-off-by: Ian Abbott<abbotti@xxxxxxxxx>
---
  drivers/staging/comedi/drivers/amplc_pci230.c |  578 +++++++++++++------------
  1 files changed, 301 insertions(+), 277 deletions(-)

<snip>

+static int __devinit pci230_attach_pci(struct comedi_device *dev,
+				       struct pci_dev *pci_dev)

This function should not be tagged '__devinit'.

I disagree.

<snip>

static struct comedi_driver amplc_pci230_driver = {
  	.driver_name	= "amplc_pci230",
  	.module		= THIS_MODULE,
  	.attach		= pci230_attach,
+	.attach_pci	= pci230_attach_pci,
  	.detach		= pci230_detach,
  	.board_name	=&pci230_boards[0].name,
  	.offset		= sizeof(pci230_boards[0]),

This comedi_driver structure is going to exist until comedi_driver_unregister
is called to remove it from the global comedi_drivers pool. All the data in this
structure needs to remain valid while it exists.

And so it does. Compare the 'probe' member of a statically initialized variable of type 'struct pci_driver', for example. That points to a function tagged '__devinit'.

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
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