Commit graph

177 commits

Author SHA1 Message Date
Ian Abbott a588da1d5a staging: comedi: simplify comedi_auto_attach()
`comedi_auto_config()` just calls internal function
`comedi_auto_config_helper()`, passing it a wrapper function
`comedi_auto_config_wrapper()` to handle the specifics of checking and
calling the low-level comedi driver's `auto_attach()` handler.

Since there are no other callers of `comedi_auto_config_helper()` or
`comedi_auto_config_wrapper()`, combine everything into the single
exported function `comedi_auto_config()`.

Change the ordering of the check for existence of the low-level comedi
driver's `auto_attach()` handler and the allocation of the comedi minor
device number.  This means the log message warning of the absence of the
handler now has to be refer to the hardware device instead of the
not-yet-allocated comedi device.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:48 -08:00
Ian Abbott af448aca8f staging: comedi: don't check driver->auto_attach
There is no need for `comedi_pci_auto_config()` and
`comedi_usb_auto_config()` to check that `driver->auto_attach` is
non-null before calling `comedi_auto_attach()` as this check is done by
`comedi_auto_config()` itself (actually by
`comedi_auto_config_wrapper()`).  Remove the unnecessary checks.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:47 -08:00
Ian Abbott 45d6f1965e staging: comedi: don't call attach_usb handler
All the Comedi drivers that call `comedi_usb_auto_config()` have
replaced the `attach_usb()` handler in their `struct comedi_driver` with
a `auto_attach()` handler, so there is no need to check for the
existence of the `attach_usb()` handler any more.  Remove this check and
the code that calls it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:47 -08:00
Ian Abbott a692e9743a staging: comedi: don't call attach_pci handler
All the Comedi drivers that call `comedi_pci_auto_config()` have
replaced the `attach_pci()` handler in their `struct comedi_driver` with
a `auto_attach()` handler, so there is no need to check for the
existence of the `attach_pci()` handler any more.  Remove this check and
the code that calls it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:47 -08:00
Ian Abbott 847d74a260 staging: comedi: remove old auto-config
All the Comedi drivers that call `comedi_pci_auto_config()` or
`comedi_usb_auto_config()` define a `auto_attach()` handler in their
`struct comedi_driver`.  There is no need to fall back to abusing the
`attach()` handler any more, so remove the code that supports that.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-14 16:25:47 -08:00
Ian Abbott d5121914a2 staging: comedi: support auto_attach() for PCI and USB
Allow `comedi_pci_auto_config()` and `comedi_usb_auto_config()` to use
the new `auto_attach()` hook in the low-level driver's `struct
comedi_driver` if it is set and the `attach_pci()` or `attach_usb()`
hook (for PCI or USB respectively) is `NULL`.

Eventually, the `auto_attach()` hook will be the only way of
auto-configuring hardware devices as comedi devices and the bus-type
specific `attach_pci()` and `attach_usb()` hooks will be removed.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-29 15:02:08 -07:00
Ian Abbott 8ed705aff0 staging: comedi: add generic auto-config functions
Add (and export) generic auto-config function `comedi_auto_config()` to
allow hardware devices on arbitrary bus types (e.g. platform devices,
spi devices, etc.) to be auto-configured as comedi devices.  This uses a
new `auto_attach()` hook in the `struct comedi_driver`.  This new hook
will eventually replace the bus-specific `attach_pci()` and
`attach_usb()` hooks in the low-level comedi drivers.

When the `auto_attach()` hook is called in the low-level driver, the
`hw_dev` member of the `struct comedi_device` will have already been set
to the hardware device passed to `comedi_auto_config()`.  The low-level
driver can convert this to some bus-device wrapper structure pointer,
possibly with the help of the `context` parameter that is passed
unchanged from the `comedi_auto_config()` call.

Also export the existing `comedi_auto_unconfig()` function as the
matching call to `comedi_auto_config()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-29 15:02:08 -07:00
Ian Abbott 156096a039 staging: comedi: rename old auto-config functions
Rename `comedi_auto_config()` to `comedi_old_auto_config()`, and
`comedi_auto_config_wrapper()` to `comedi_old_auto_config_wrapper()`.
These functions are deprecated and will be removed once the few
remaining low-level comedi drivers that use them have been updated.
(The low-level drivers in question support auto-configuration of
detected comedi devices, but still use the `attach()` hook in their
`struct comedi_driver` to do so.)

This internal change frees up the name `comedi_auto_config` for future
use.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-29 15:02:08 -07:00
Ian Abbott f9c3e4e7a7 staging: comedi: change type of auto-config context
Change the type of the context parameter passed to
`comedi_auto_config_helper()` from `void *` to `unsigned long`.  It's
currently just an internal change and all current internal usages pass
pointers in the context, but future uses of this function may pass
integer values or pointer values at the whim of a lower-level comedi
driver and the `unsigned long` type expresses this better as it is
commonly used in the Linux kernel to hold such values.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-29 15:02:07 -07:00
Ian Abbott 26cbd46529 staging: comedi: always set hw_dev during auto-config
Auto-configuration (auto-attachment) of USB and PCI comedi devices all
goes through `comedi_auto_config_helper()`.  That is a good place to set
the comedi device's `hw_dev` pointer to the hardware `struct device` via
a call to `comedi_set_hw_dev(comedi_device, hardware_device)` as it may
obviate the need for the low-level comedi driver to make this call.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-22 12:43:37 -07:00
Ian Abbott 9f82e95773 staging: comedi: sparse warning in insn_rw_emulate_bits()
`insn_rw_emulate_bits()` is used to emulate the `INSN_READ` and
`INSN_WRITE` comedi instructions for subdevices that don't have an
`insn_read()` or `insn_write()` handler but do have an `insn_bits()`
handler.

The function fills in a temporary `struct comedi_insn` called `new_insn`
to pass to the subdevice's `insn_bits()` handler.  In doing so, it sets
the `new_insn.data` pointer to point to a temporary data array.  This
results in a warning from "sparse" because the `data` pointer in `struct
comedi_insn` has the `__user` tag.  The subdevice's `insn_bits()`
handler ignores it anyway as it gets passed a pointer to the temporary
data array in a separate parameter.  Don't bother setting
`new_insn.data`; just leave it set to `NULL` (done by an earlier
`memset()`).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-19 11:26:12 +01:00
Güngör Erseymen 559e9a6899 staging: comedi: fix brace coding style issues
Fix coding style issues by removing unnecessary braces.

Signed-off-by: Güngör Erseymen <gelurine@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-11 12:12:07 -07:00
H Hartley Sweeten 5e4c58ce65 staging: comedi: drivers: remove subdevice pointer math
Convert the comedi_subdevice access from pointer math to array
access.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-05 20:01:35 -07:00
Greg Kroah-Hartman 8f8b77bfdc Merge 3.6-rc3 into staging-next
This picks up fixes we want in this branch to allow us to properly test.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-27 07:10:40 -07:00
Ian Abbott 4f870fe626 staging: comedi: replace printk calls in comedi core
Replace the printk() calls in the comedi core module with something more
suitable, such as dev_...() or pr_...().  Remove the ones that report a
failure to increment a module count (try_module_get() failure).  Change
the printk() call in the DPRINTK() macro to pr_debug().

TODO: Most of the DPRINTK() calls need to be replaced with something
else.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-16 11:35:45 -07:00
Ian Abbott 8c3714d60c staging: comedi: make attach handler optional
Some low-level Comedi drivers no longer support manual configuration of
devices with the COMEDI_DEVCONFIG ioctl (used by the comedi_config
program).  For those drivers, the 'attach_pci' or 'attach_usb' handler
will be set in the struct comedi_driver to configure devices
automatically (via comedi_pci_auto_config() or
comedi_usb_auto_config()).  Their 'attach' handlers are redundant but
the the comedi core module currently requires it to be set.

Make the 'attach' handler optional and issue a warning if something
wants to call it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-15 15:30:56 -07:00
Ian Abbott 80eb7a506f staging: comedi: Fix reversed test in comedi_device_attach()
Commit 3902a37028 (staging: comedi:
refactor comedi_device_attach() a bit) by yours truly introduced an
inverted logic bug in comedi_device_attach() for the case where the
driver expects the device to be configured by driver name rather than
board name.  The result of a strcmp() is being tested incorrectly.  Fix
it.

Thanks to Stephen N Chivers for discovering the bug and suggesting the
fix.

Cc: <stable@vger.kernel.org> # 3.5.x
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-14 16:52:17 -07:00
Ian Abbott f286766e4b staging: comedi: remove comedi_fops.h
Move the contents of "comedi_fops.h" into "comedi_internal.h" and delete
"comedi_fops.h". It only contains a couple of external variable
declarations (and #include <linux/types.h>) and one of those isn't even
declared in "comedi_fops.c".  The other one is an external declaration
of a variable used to store a module parameter and some of those are
already externally declared in "comedi_internal.h", so they can keep it
company!

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-20 12:56:55 -07:00
Ian Abbott 3a5fa27516 staging: comedi: rename internal.h to comedi_internal.h
Use a less generic name for this internal header file included by
various parts of the comedi core.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-20 12:56:54 -07:00
Greg Kroah-Hartman 89a86a2da3 Merge branch 'staging-linus' into staging-next
We need this for the pstore fixes that went into the staging-linus branch, so
that things apply properly for the pstore/android code merge.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-13 16:57:09 -07:00
H Hartley Sweeten 03afcf4727 staging: comedi: cleanup comedi_alloc_subdevices
Access the individual comedi_subdevices using a pointer instead
of directly accessing as an array. This is how the rest of the
comedi core accesses them.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbott@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:44:04 -07:00
H Hartley Sweeten fba1d0faf7 staging: comedi: only set dev->n_subdevices when kcalloc succeedes
It's possible for the kcalloc in comedi_alloc_subdevices to fail.
Only set the dev->n_subdevices variable if the allocation is
successful.

Since the core sets dev->n_subdevices, remove all the places in the
drivers where this variable was getting set.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbott@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:44:03 -07:00
H Hartley Sweeten 7f801c4171 staging: comedi: sanity check num_subdevices parameter in comedi_alloc_subdevices
It's possible for a couple of the comedi drivers to incorrectly call
comedi_alloc_subdevices with num_subdevices = 0. Add a sanity check
before doing the kcalloc.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbot@mev.co.uk>
Cc: Frank Mori Hess <kmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:44:03 -07:00
H Hartley Sweeten 8b9ba6e5ef staging: comedi: change type of num_subdevices parameter to comedi_alloc_subdevices
The n_subdevices variable of struct comedi_device is an int type.
Change the type of the comedi_alloc_subdevices 'num_subdevices' from
an unsigned int to an int to match it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbott@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:40:51 -07:00
H Hartley Sweeten 2f0b9d082e staging: comedi: export alloc_subdevices as comedi_alloc_subdevices
Move the inline alloc_subdevices() function from comedidev.h
to drivers.c and rename it to comedi_alloc_subdevices(). The
function is large enough to warrant being an exported symbol
rather than being an inline in every driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 11:14:33 -07:00
Ian Abbott 4e2f002f7a staging: comedi: describe comedi_recognize()
Add a comment to comedi_recognize() to describe what it does as it's a
bit confusing.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-11 16:54:28 -07:00
Randy Dunlap 78b10615ad staging/comedi: fix build for USB not enabled
Calls to optional subsystems cannot be made indiscriminately.
Enclose all of the usb helper functions inside
#if IS_ENABLED(CONFIG_USB)
to fix these build errors.

(The pci helper functions are OK since there are stubs in
linux/pci.h for the called functions when PCI is not enabled.
Possibly the same could be done for the called USB functions.)

ERROR: "usb_deregister" [drivers/staging/comedi/comedi.ko] undefined!
ERROR: "usb_register_driver" [drivers/staging/comedi/comedi.ko] undefined!

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-11 16:49:35 -07:00
H Hartley Sweeten 1364b02fbf staging: comedi: drivers.c: remove unused inline functions
Remove the inline functions uvirt_to_kva and kvirt_to_kva, they
are not referenced by any of the drivers.c code.

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-06-04 20:46:07 -07:00
Dan Carpenter 1c9de58acc staging: comedi: cleanup comedi_recognize()
This function is more complicated than it needs to be because of the
consts.  It's not worth saving them when we drop the consts anyway
when we return (void *)name_ptr.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc:
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-04 20:33:39 -07:00
H Hartley Sweeten 55c03cff7f staging: comedi: remove private header comedi_pci.h
Remove the private header, comedi_pci.h, by moving the two
helper functions into divers.c and providing the prototypes
in comedidev.h.

This allows the comedi_pci_enable/disable helper functions
to be shared instead of having an inline version in every
comedi pci driver.

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-06-04 20:24:43 -07:00
H Hartley Sweeten 64255031bd staging: comedi: Add helper macro for comedi usb driver boilerplate
Introduce the module_comedi_usb_driver macro, and the
associated register/unregister functions, which is a
convenience macro for comedi usb driver modules similar
to module_platform_driver. It is intended to be used by
drivers where the init/exit section does nothing but
register/unregister the comedi driver and associated usb
driver. By using this macro it is possible to eliminate
a few lines of boilerplate code per comedi usb driver.

Also, when registering the usb driver check for failure
and unregister the comedi driver.

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-16 19:19:06 -07:00
H Hartley Sweeten d4899c6ff8 staging: comedi: Add helper macro for comedi pci driver boilerplate
Introduce the module_comedi_pci_driver macro, and the
associated register/unregister functions, which is a
convenience macro for comedi pci driver modules similar
to module_platform_driver. It is intended to be used by
drivers where the init/exit section does nothing but
register/unregister the comedi driver and associated pci
driver. By using this macro it is possible to eliminate
a few lines of boilerplate code per comedi pci driver.

Add a check to make sure that the pci_driver->name is
set. Once all the comedi pci drivers have been fixed this
will be removed.

Also, when registering the pci driver check for failure
and unregister the comedi driver.

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-14 13:48:47 -07:00
Ian Abbott 4d7df82127 staging: comedi: Add module parameters for default buffer size
For comedi subdevices that support asynchronous transfer commands, the
initial buffer size and maximum buffer size for the transfer are both
set to 64 KiB when the comedi device is "attached" to the hardware
device.  For many applications with reasonable fast sample rates and
slow user-space (e.g. Python) these sizes are a bit too small.

A task with CAP_SYS_ADMIN privileges can change the maximum buffer size
for a comedi subdevice with an ioctl call or by writing to a device
attribute file in sysfs, but that's not very convenient.  For comedi
devices attached during system startup, this could be done by a start-up
script, but for hot-plugged devices it would require scripts run by udev
rules, etc.

Rather than use hardwired values, this patch introduces a couple of
module parameters to set the defaults for the initial buffer size
(comedi_default_buf_size_kb) and maximum buffer size
(comedi_default_buf_maxsize_kb).  These values are applied in place of
the previous hard-wired values when the comedi device is "attached".
The module parameter values are in units of KiB for consistency with the
existing device attribute files.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-13 11:18:23 -07:00
Ian Abbott cf938c2473 staging: comedi: restrict comedi_auto_config() to single driver
comedi_auto_config() only needs to consider a single struct
comedi_driver object, but it currently calls comedi_device_attach()
which looks at all struct comedi_driver objects registered with the
Comedi core.

Instead, call the recently added comedi_auto_config_helper() with a new
wrapper comedi_auto_config_wrapper() to mimic the effect of
comedi_device_attach() for a single struct comedi_driver.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-10 11:22:01 -07:00
Ian Abbott 63bf3d11df staging: comedi: pass struct comedi_driver * to comedi_auto_config()
Pass a pointer to the struct comedi_driver to comedi_auto_config()
instead of the driver name.  comedi_auto_config() will be changed to
make use of this.  It currently calls comedi_device_attach() which
examines the whole list of struct comedi_driver objects.  It will be
changed to restrict itself to just the supplied struct comedi_driver
object.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-10 11:22:01 -07:00
Ian Abbott f401167002 staging: comedi: add bus-type-specific attach hooks for PCI and USB
The Comedi auto-configuration mechanism used to bind hardware devices to
comedi devices automatically is pretty kludgy.  It fakes a "manual"
configuration of the comedi device as though the COMEDI_DEVCONFIG ioctl
(or the 'comedi_config' utility) were used.  In particular, the
low-level comedi driver's '->attach()' routine is called with a pointer
to the struct comedi_device being attached and a pointer to a 'struct
devconfig' containing a device name string and a few integer options to
help the attach routine locate the device being attached.  In the case
of PCI devices, these integer options are the PCI bus and slot numbers.
In the case of USB devices, there are no integer options and it relies
more on pot luck to attach the correct device.

This patch adds a couple of bus-type-specific attach routine hooks to
the struct comedi_driver, which a low-level driver can optionally fill
in if it supports auto-configuration.

A low-level driver that supports auto-configuration of {PCI,USB} devices
calls the existing comedi_{pci,usb}_auto_config() when it wishes to
auto-configure a freshly probed device (maybe after loading firmware).
This will call the new '->attach_{pci,usb}()' hook if the driver has
defined it, otherwise it will fall back to calling the '->attach()' hook
as before.  The '->attach_{pci,usb}()' hook gets a pointer to the struct
comedi_device and a pointer to the struct {pci_dev,usb_interface} and
can figure out the {PCI,USB} device details for itself.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-10 11:22:01 -07:00
Ian Abbott 3902a37028 staging: comedi: refactor comedi_device_attach() a bit
Split the post-config part of comedi_device_attach() into new function
comedi_device_postconfig() and rearrange the rest of the function a bit.

The new comedi_device_postconfig() function will be called by some new
bus-type-specific auto-attach functions.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-10 11:21:11 -07:00
Ian Abbott d8b6ca0850 staging: comedi: pass usb interface to comedi_usb_auto_config
The comedi_usb_auto_config() and comedi_usb_auto_unconfig() functions
currently take a 'struct usb_device *'.  It makes more sense to pass a
'struct usb_interface *' to allow for composite USB devices.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-10 11:21:10 -07:00
Ian Abbott c43435d772 staging: comedi: don't hijack hardware device private data
comedi_auto_config() associates a Comedi minor device number with an
auto-configured hardware device and comedi_auto_unconfig() disassociates
it.  Currently, these use the hardware device's private data pointer to
point to some allocated storage holding the minor device number.  This
is a bit of a waste of the hardware device's private data pointer,
preventing it from being used for something more useful by the low-level
comedi device drivers.  For example, it would make more sense if
comedi_usb_auto_config() was passed a pointer to the struct
usb_interface instead of the struct usb_device, but this cannot be done
currently because the low-level comedi drivers already use the private
data pointer in the struct usb_interface for something more useful.

This patch stops the comedi core hijacking the hardware device's private
data pointer.  Instead, comedi_auto_config() stores a pointer to the
hardware device's struct device in the struct comedi_device_file_info
associated with the minor device number, and comedi_auto_unconfig()
calls new function comedi_find_board_minor() to recover the minor device
number associated with the hardware device.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-10 11:21:10 -07:00
Ian Abbott 4c093a6dc2 staging: comedi: pass 'struct comedi_driver *' to comedi_..._auto_config
The comedi_pci_auto_config() and comedi_usb_auto_config() functions
currently take a board name parameter which is actually a driver name
parameter.  Replace it with a pointer to the struct comedi_driver.  This
will allow comedi_pci_auto_config() and comedi_usb_auto_config() to call
bus-type-specific auto-configuration hooks in the struct comedi_driver
if they exist (they don't yet).  The idea is that these
bus-type-specific auto-configuration hooks won't have to search the bus
for the device being auto-configured like 'attach()' hook has to.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-10 11:17:27 -07:00
David Howells 9ffc93f203 Remove all #inclusions of asm/system.h
Remove all #inclusions of asm/system.h preparatory to splitting and killing
it.  Performed with the following command:

perl -p -i -e 's!^#\s*include\s*<asm/system[.]h>.*\n!!' `grep -Irl '^#\s*include\s*<asm/system[.]h>' *`

Signed-off-by: David Howells <dhowells@redhat.com>
2012-03-28 18:30:03 +01:00
Greg Kroah-Hartman 408093d2a1 Staging: comedi: drivers.c: fix PAGE_KERNEL_NOCACHE issue
Not all arches have PAGE_KERNEL_NOCACHE, so use the "normal" PAGE_KERNEL
on those that do not have it.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-06-09 12:13:53 -07:00
Micha Hergarden 3ad4e21960 staging: comedi: fix coding style issue in drivers.c
This is a patch to the drivers.c file that fixes up a
braces around single statement warning found by the
checkpatch.pl tool

Signed-off-by: Micha Hergarden <micha.hergarden@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-02-04 13:04:24 -08:00
Xenofon Foukas 88ab8a8445 Staging: comedi: Fix coding style issues in drivers.c
This patch fixes line over 80 characters warning issues found
in file drivers.c

Signed-off-by: Xenofon Foukas <foukas.xenofon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-12-09 16:39:06 -08:00
Joe Perches 5b84cc7810 staging: Use vzalloc
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-09 16:34:01 -08:00
Mark Rankilor 67b0e64a7b Staging: comedi: Fixed printk call lengths and log levels
This is a patch to include log levels and fix some over length lines in
printk calls in drivers.c

Signed-off-by: Mark Rankilor <reodge@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-11 11:36:18 -07:00
Greg Kroah-Hartman 7029a87455 Staging: comedi: drivers.c sparse cleanup
Fix up some sparse issues in drivers.c

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-11 11:36:03 -07:00
Greg Kroah-Hartman 09372df0df Staging: comedi: make comedi_reset_async_buf local to comedi core
No one outside of the comedi core calls this function, so don't export
it to the world.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-11 11:36:03 -07:00
Greg Kroah-Hartman 242e7ad91a Staging: comedi: make comedi_alloc_board_minor local to comedi core
No one outside of the comedi core calls this function, so create
an internal.h file to put the prototype in, and don't export
it to the world.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-11 11:36:03 -07:00
Mark Rankilor aad4029a49 Staging: comedi: Adjusted some long line lengths in drivers.c
This patch fixes some long line lengths in drivers.c that checkpatch.pl was
complaining about

Signed-off-by: Mark Rankilor <reodge@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-11 11:36:02 -07:00
Greg Kroah-Hartman 4bf935596b Staging: comedi: remove comedi_ksyms.c
Move the 4 remaining exports to their function location
and then remove the comedi_ksyms.c file, as it's no longer
needed.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-11 11:36:00 -07:00
Greg Kroah-Hartman d58214b0b8 Staging: comedi: move a bunch of EXPORT_SYMBOL lines
Move the ones that are needed to be in drivers.c into the
file.  This is with the goal of deleting the comedi_ksyms.c
file.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-11 11:35:59 -07:00
Greg Kroah-Hartman be29eac8ed Staging: comedi: remove wrapper.h
Just make the bit call when it is needed, no need to wrap
things up like this for no reason.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-11 11:35:58 -07:00
Zachary Richey ac4898a0f8 Staging: comedi: fixed coding style issues in drivers.c
This patch fixes coding style issues found by checkpatch.pl, and doesnt
line break string literals.

Signed-off-by: Zachary Richey <zr.public@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-11 11:35:39 -07:00
Andrea Gelmini 5617f9da46 Staging: comedi: drivers.c: Checkpatch cleanup
WARNING: Use #include <linux/io.h> instead of <asm/io.h>
+#include <asm/io.h>

WARNING: braces {} are not necessary for any arm of this statement
+	if (dev->driver) {
[...]
+	} else {
[...]

WARNING: braces {} are not necessary for single statement blocks
+	if (insn->insn == INSN_READ) {
+		data[0] = (new_data[1] >> (chan - base_bitfield_channel)) & 1;
+	}

WARNING: braces {} are not necessary for single statement blocks
+	if (async->prealloc_buf && async->prealloc_bufsz == new_size) {
+		return 0;
+	}

WARNING: braces {} are not necessary for single statement blocks
+				if (async->buf_page_list[i].virt_addr == NULL) {
+					break;
+				}

WARNING: braces {} are not necessary for single statement blocks
+	if ((int)(async->buf_write_alloc_count + nbytes - free_end) > 0) {
+		nbytes = free_end - async->buf_write_alloc_count;
+	}

WARNING: braces {} are not necessary for single statement blocks
+	if ((int)(async->buf_write_alloc_count + nbytes - free_end) > 0) {
+		nbytes = 0;
+	}

WARNING: braces {} are not necessary for single statement blocks
+	if (async->buf_write_ptr >= async->prealloc_bufsz) {
+		async->buf_write_ptr %= async->prealloc_bufsz;
+	}

Signed-off-by: Andrea Gelmini <andrea.gelmini@gelma.net
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-03 16:43:07 -08:00
Mithlesh Thukral d43d27abf7 Staging: comedi: drivers.c: checkpatch fix
Fix a checkpatch.pl error. Fix struct * foo to struct *foo

Signed-off-by: Mithlesh Thukral <mithlesh@linsyssoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11 12:21:48 -08:00
Figo.zhang b455073c88 Staging: comedi: no need for checking vfree call
vfree() does it's own NULL checking,so no need for check before
calling it.

'pages' is local variable argment,so in v2, it is no need assignment
 to NULL.

Signed-off-by: Figo.zhang <figo1802@gmail.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-09-15 12:01:33 -07:00
Mithlesh Thukral 0a85b6f0ab Staging: Comedi: Lindent changes to comdi driver in staging tree
Lindent changes to comdi driver in staging tree.
This patch is followed by the checkpatch.pl error fixes.
Did not make them part of this patch as the patch size is already huge.

Signed-off-by: Mithlesh Thukral <mithlesh@linsyssoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-09-15 12:01:33 -07:00
Greg Kroah-Hartman 5f74ea14c0 Staging: comedi: remove comedi-specific wrappers
There are a number of comedi "wrappers" for some RT functions that are
about to go away.  This patch removes all of the wrapper calls within
the comedi drivers and core in order to prepare for removing the RT
comedi code.

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-06-19 11:00:33 -07:00
Bill Pemberton 8629efa4cb Staging: comedi: make use of ARRAY_SIZE macro
Replace instances of computing number of elements in an array with
sizeof(foo)/sizeof(struct footype) with the ARRAY_SIZE macro.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-06-19 11:00:33 -07:00
Bill Pemberton 53106ae68a Staging Comedi: fix spacing around parens
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-06-19 11:00:31 -07:00
Stoyan Gaydarov 2961f24f78 Staging: BUG to BUG_ON changes
Signed-off-by: Stoyan Gaydarov <stoyboyker@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:54:26 -07:00
Bill Pemberton 0707bb04be Staging: comedi: Remove comedi_devconfig typedef
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:58 -07:00
Bill Pemberton 90035c0886 Staging: comedi: Remove comedi_insn typedef
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:57 -07:00
Bill Pemberton 139dfbdfac Staging: comedi: Remove comedi_driver typedef
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:56 -07:00
Bill Pemberton d163679cee Staging: comedi: Remove comedi_async typedef
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:56 -07:00
Bill Pemberton 34c43922e6 Staging: comedi: Remove comedi_subdevice typedef
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:56 -07:00
Bill Pemberton 71b5f4f119 Staging: comedi: Remove comedi_device typedef
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:56 -07:00
Bill Pemberton 790c55415a Staging: comedi: Remove lsampl_t and sampl_t typedefs
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:55 -07:00
Bill Pemberton dedd1325f1 Staging: comedi: Remove checks for NULL before calling kfree()
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:54 -07:00
Bill Pemberton e473e9120b Staging: comedi: Change "foo * bar" to "foo *bar"
Removes checkpatch.pl errors

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:53 -07:00
Bill Pemberton b6c777571b Staging: comedi: Convert C99 style comments to traditional style comments
Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:53 -07:00
Ian Abbott 719548ef66 Staging: comedi: Make comedi_auto_config() succeed when auto-configuration disabled.
Otherwise it would not work properly.

From: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: David Schleef <ds@schleef.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:52 -07:00
Bernd Porr c28264dac4 Staging: comedi: add comedi_usb_auto_[un]config functions
This will be used by the usbdux and usbduxfast drivers.

From: Bernd Porr <BerndPorr@f2s.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: David Schleef <ds@schleef.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:52 -07:00
Ian Abbott 6a9d7a21d7 Staging: comedi: Add a module parameter 'comedi_autoconfig'.
Set it to 0 or 'N' to disable autoconfiguration.
It is enabled by default.

From: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: David Schleef <ds@schleef.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-04-03 14:53:51 -07:00
Harvey Harrison d599edcaea staging: __FUNCTION__ is gcc-specific, use __func__
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-01-07 15:48:54 -08:00
David Schleef ed9eccbe89 Staging: add comedi core
This adds the Comedi core to the staging tree.
This is a data acquision infrastructure for Linux, providing a common
interface for these types of drivers.

Taken directly from the comedi git tree, with only minor tweaks
by Greg to get it to build properly within the kernel tree.

From: David Schleef <ds@schleef.org>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Shawn Bohrer <shawn.bohrer@gmail.com>
Signed-off-by: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-01-06 13:52:16 -08:00