From f6009ae536ec642e451d29327bf04532c4c7e0aa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 4 Sep 2014 10:39:38 -0700 Subject: [PATCH] staging: comedi: adl_pci9118: allocate private data in pci9118_common_attach() The (*auto_attach) and legacy (*attach) both allocate the private data but don't use it. For aesthetics, move the allocation into the common attach code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 81ba59feb68c..8b086c22b2e9 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -1767,12 +1767,16 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, int hw_err_mask) { const struct pci9118_boardinfo *board = comedi_board(dev); - struct pci9118_private *devpriv = dev->private; struct pci_dev *pcidev = comedi_to_pci_dev(dev); + struct pci9118_private *devpriv; struct comedi_subdevice *s; int ret, pages, i; u16 u16w; + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); + if (!devpriv) + return -ENOMEM; + ret = comedi_pci_enable(dev); if (ret) return ret; @@ -1923,7 +1927,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - struct pci9118_private *devpriv; struct pci_dev *pcidev; int ext_mux, disable_irq, master, softsshdelay, hw_err_mask; @@ -1933,10 +1936,6 @@ static int pci9118_attach(struct comedi_device *dev, softsshdelay = it->options[4]; hw_err_mask = it->options[5]; - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - pcidev = pci9118_find_pci(dev, it); if (!pcidev) return -EIO; @@ -1951,7 +1950,6 @@ static int pci9118_auto_attach(struct comedi_device *dev, { struct pci_dev *pcidev = comedi_to_pci_dev(dev); const struct pci9118_boardinfo *board = NULL; - struct pci9118_private *devpriv; if (context < ARRAY_SIZE(pci9118_boards)) board = &pci9118_boards[context]; @@ -1960,10 +1958,6 @@ static int pci9118_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - /* * Need to 'get' the PCI device to match the 'put' in pci9118_detach(). * (The 'put' also matches the implicit 'get' by pci9118_find_pci().) -- 2.30.2