linux-sg2042/drivers/staging/comedi
H Hartley Sweeten 484ecc95d9 staging: comedi: cleanup all the comedi_driver 'detach' functions
1. Change the return type from int to void

All the detach functions, except for the comedi usb drivers, simply
return success (0). Plus, the return code is never checked in the
comedi core.

The comedi usb drivers do return error codes but the conditions can
never happen.

The first check is:

	if (!dev)
		return -EFAULT;

This checks that the passed comedi_device pointer is valid. The detach
function itself is called using this pointer so it MUST always be valid
or there is a bug in the core:

	if (dev->driver)
		dev->driver->detach(dev);

And the second check:

	usb = dev->private;
	if (!usb)
		return -EFAULT;

The dev->private pointer is setup in the attach function to point to the
probed usb device. This value could be NULL if the attach fails. But,
since the comedi core is going to unload the driver anyway and does not
check for errors there is no gain by returning one.

After removing these checks from the comedi usb drivers the detach
functions required a bit of cleanup.

2. Remove all the printk noise in the detach functions

All of the printk output is really just noise. The user did a rmmod to
unload the driver, we really don't need to tell them about it.

Also, some of the messages are output using:

	dev_dbg(dev->hw_dev, ...
or
	dev_info(dev->hw_dev, ...

Unfortunately the hw_dev value is only used by drivers that are doing
DMA. For most drivers this variable is going to be NULL so the output
is not going to work as expected.

3. Refactor a couple static 'free_resource' functions into the detach
   functions.

The 'free_resource' function is only being called by the detach and it
makes more sense to just absorb the code.

4. Remove a couple unnecessary braces for single statements.

5. Remove unnecessary comments.

Most of the comedi drivers appear to be based on the comedi skel driver
and have the comments from that driver included. These comments make
sense in the skel driver for reference but they don't need to be in any
of the actual drivers.

6. Remove all the extra whitespace.

It's not needed to make the functions any more readable.

7. Remove the now unused 'attached_successfully' variable in the
   cb_pcimdda driver.

This variable was only used to conditionally output some driver noise
during the detach. Since all the printk's have been removed this
variable is no longer necessary.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-18 17:29:55 -07:00
..
drivers staging: comedi: cleanup all the comedi_driver 'detach' functions 2012-05-18 17:29:55 -07:00
kcomedilib Staging: comedi: kcomedilib: fix coding style issues in kcomedilib_main.c 2010-07-08 13:15:16 -07:00
Kconfig staging: comedi: remove all 'default N' in Kconfig 2012-05-18 17:15:47 -07:00
Makefile Staging: comedi: Makefile: replace the use of <module>-objs with <module>-y 2010-10-08 07:23:52 -07:00
TODO Staging: comedi: Remove typedefs 2010-06-17 13:49:07 -07:00
comedi.h staging: comedi: COMEDI_CB_EOA is also used to report end-of-output. 2012-04-18 16:37:06 -07:00
comedi_compat32.c Staging: comedi: range.c: properly mark up __user pointers 2010-05-11 11:36:03 -07:00
comedi_compat32.h Staging: comedi: remove check for HAVE_COMPAT_IOCTL 2009-12-11 12:23:01 -08:00
comedi_fops.c staging: comedi: register sysfs device attributes with driver core 2012-05-14 13:00:55 -07:00
comedi_fops.h module_param: make bool parameters really bool (drivers & misc) 2012-01-13 09:32:20 +10:30
comedidev.h staging: comedi: cleanup all the comedi_driver 'detach' functions 2012-05-18 17:29:55 -07:00
comedilib.h Staging: comedi: kcomedilib: make it typesafe 2010-05-11 11:36:02 -07:00
drivers.c staging: comedi: Add helper macro for comedi usb driver boilerplate 2012-05-16 19:19:06 -07:00
internal.h staging: comedi: Add module parameters for default buffer size 2012-04-13 11:18:23 -07:00
proc.c Staging: comedi: clean up sparse issues in proc.c 2010-05-11 11:36:03 -07:00
range.c Staging: comedi: range.c: properly mark up __user pointers 2010-05-11 11:36:03 -07:00