Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b876e985 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

staging: comedi: mite: cleanup mite_unsetup()



This function is only called by comedi drivers during the (*detach) of the
driver. After it is called mite_free() is always called to kfree the allocated
mite_struct pointer.

Rename this function to mite_detach() and merge the kfree() from mite_free()
into it.

Remove the unnecessary clearing of the mite variables since the mite pointer
is going to be kfree()'d anyway.

The mite_detach() function checks if the pointer is valid so remove the
unnecessary checks in the callers.

The check can also be removed in ni_660x since the ni_660x_free_mite_rings()
function does not actually need the 'mite' pointer.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 90866896
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -173,25 +173,19 @@ int mite_setup(struct mite_struct *mite)
}
EXPORT_SYMBOL_GPL(mite_setup);

void mite_unsetup(struct mite_struct *mite)
void mite_detach(struct mite_struct *mite)
{
	/* unsigned long offset, start, length; */

	if (!mite)
		return;

	if (mite->mite_io_addr) {
	if (mite->mite_io_addr)
		iounmap(mite->mite_io_addr);
		mite->mite_io_addr = NULL;
	}
	if (mite->daq_io_addr) {
	if (mite->daq_io_addr)
		iounmap(mite->daq_io_addr);
		mite->daq_io_addr = NULL;
	}
	if (mite->mite_phys_addr)
		mite->mite_phys_addr = 0;

	kfree(mite);
}
EXPORT_SYMBOL_GPL(mite_unsetup);
EXPORT_SYMBOL_GPL(mite_detach);

struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite_struct *mite)
{
+1 −6
Original line number Diff line number Diff line
@@ -65,14 +65,9 @@ struct mite_struct {

struct mite_struct *mite_alloc(struct pci_dev *pcidev);

static inline void mite_free(struct mite_struct *mite)
{
	kfree(mite);
}

int mite_setup(struct mite_struct *mite);
int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1);
void mite_unsetup(struct mite_struct *mite);
void mite_detach(struct mite_struct *mite);
struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite_struct *mite);
void mite_free_ring(struct mite_dma_descriptor_ring *ring);
struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
+2 −6
Original line number Diff line number Diff line
@@ -716,12 +716,8 @@ static void ni_65xx_detach(struct comedi_device *dev)
	}
	if (dev->irq)
		free_irq(dev->irq, dev);
	if (devpriv) {
		if (devpriv->mite) {
			mite_unsetup(devpriv->mite);
			mite_free(devpriv->mite);
		}
	}
	if (devpriv)
		mite_detach(devpriv->mite);
	comedi_pci_disable(dev);
}

+2 −5
Original line number Diff line number Diff line
@@ -1195,11 +1195,8 @@ static void ni_660x_detach(struct comedi_device *dev)
	if (devpriv) {
		if (devpriv->counter_dev)
			ni_gpct_device_destroy(devpriv->counter_dev);
		if (devpriv->mite) {
		ni_660x_free_mite_rings(dev);
			mite_unsetup(devpriv->mite);
			mite_free(devpriv->mite);
		}
		mite_detach(devpriv->mite);
	}
	comedi_pci_disable(dev);
}
+2 −4
Original line number Diff line number Diff line
@@ -259,10 +259,8 @@ static void ni_670x_detach(struct comedi_device *dev)
		if (s)
			kfree(s->range_table_list);
	}
	if (devpriv && devpriv->mite) {
		mite_unsetup(devpriv->mite);
		mite_free(devpriv->mite);
	}
	if (devpriv)
		mite_detach(devpriv->mite);
	comedi_pci_disable(dev);
}

Loading