- 09 4月, 2013 12 次提交
-
-
由 H Hartley Sweeten 提交于
A return value of >=0 indicates a successful attach to the comedi core. Return 0 since that is more common in the kernel. Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 H Hartley Sweeten 提交于
This is just added noise. Remove it. Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 H Hartley Sweeten 提交于
To improve the readability, add some whitespace to the subdevice init. Also, for aesthetic reasons and the help with greps, rename the (*insn_{read,write}) functions. Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 H Hartley Sweeten 提交于
Use the number of subdevices allocated (dev->n_subdevices) in the (*detach) instead of assuming a given number. Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 H Hartley Sweeten 提交于
Define and document the bit shifts of the serial.data read from the device that is used to configure the subdevice channels. Use the new defines to tidy up the configuration process. Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 H Hartley Sweeten 提交于
Split out the code that sets up the comedi subdevices that are attached to the serial port. There are actually two steps: 1) Read the configuration of the attached subdevices. 2) Use the configuration data to setup the comedi subdevices. Step 1 is split out as serial2002_setup_subdevs(). Step 2 is split out as serial2002_setup_subdevice(). Cleanup the split out code to remove all the extra '{ }' and indents. Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 H Hartley Sweeten 提交于
Remove the unnecessary '{ }' around the code and the extra indents in the switch(). Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 H Hartley Sweeten 提交于
Rename the two local variables used to set the serial port speed and latency so thy are unique. Remove the unnecessary '{ }' around the code and the extra indents. Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 H Hartley Sweeten 提交于
Factor the (*poll) busy wait code out of tty_read() so the indent level can be reduced and tty_read() is a bit cleaner. Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 H Hartley Sweeten 提交于
The struct file_operations (*read) and (*write) operations expect the buffer to be a __user space pointer. Currently the (*write) operations in this driver cause this warning: warning: incorrect type in argument 2 (different address spaces) expected char const [noderef] <asn:1>*<noident> got unsigned char [usertype] *buf And the (*read) operations cause this warning: warning: incorrect type in argument 2 (different address spaces) expected char [noderef] <asn:1>*<noident> got unsigned char *<noident> Use __force to cast the buffer to a __user pointer to suppress the warnings. Consolidate the (*read) calls into a helper function, __tty_readb(). Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Masanari Iida 提交于
Correct spelling typo in comment within staging/csr Signed-off-by: NMasanari Iida <standby24x7@gmail.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Lars-Peter Clausen 提交于
Use dev_pm_ops instead of the deprecated legacy suspend/resume callbacks. Signed-off-by: NLars-Peter Clausen <lars@metafoo.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
- 06 4月, 2013 28 次提交
-
-
由 Valentin Ilie 提交于
Replace disallocated with deallocated Signed-off-by: NValentin Ilie <valentin.ilie@gmail.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
Add local function `comedi_clear_board_dev()` as a safer alternative to `comedi_clear_board_minor()` when we already have a pointer to a `struct comedi_device`. It uses the board minor device number stored in the `struct comedi_device` (which must have already been initialized) and only clears the entry in `comedi_board_minor_table[]` if it points to the specified `struct comedi_device`. Rather than returning the old table entry, it returns `true` if the entry matched (and so has just been cleared) and returns `false` otherwise. Call `comedi_clear_board_dev()` instead of `comedi_clear_board_minor()` in `comedi_unlocked_ioctl()` (in the code that frees a dynamically allocated comedi device detached by the `COMEDI_DEVCONFIG` ioctl). That ought to return `true` but check it just in case before freeing the device. There is still a race condition here which needs to be dealt with once we've implemented reference counting for `struct comedi_device`s. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
`struct comedi_file_info` is no longer used so remove it. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
`comedi_alloc_board_minor()` allocates and initializes a `struct comedi_file_info` and a `struct comedi_device`, and assigns a board minor device number (if there are any available), storing a pointer to the allocated `struct comedi_file_info` in `comedi_board_minor_table[minor]` where `minor` is the board minor device number. There is no longer anything useful in the `struct comedi_file_info` apart from the pointer to the `struct comedi_device` that was allocated, so the `struct comedi_file_info` is superfluous. Change `comedi_board_minor_table[]` to hold pointers to the actual `struct comedi_device`'s. `comedi_alloc_board_minor()` no longer needs to allocate a `struct comedi_file_info`. Replace `comedi_free_board_file_info()` with `comedi_free_board_dev()` with its parameter pointing to the `struct comedi_device` to be freed (there is no longer a `struct comedi_file_info` to be freed). There are consequential changes to `comedi_dev_from_board_minor()`, `comedi_clear_board_minor()` (which now returns a `struct comedi_device *`), `comedi_free_board_minor()`, `comedi_release_hardware_device()` and `comedi_unlocked_ioctl()` (when dealing with detachment of a dynamically allocated comedi device by the `COMEDI_DEVCONFIG` ioctl). `comedi_dev_from_file_info()` is no longer used as a result of the above changes so remove it. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
`comedi_alloc_subdevice_minor()` allocates and initializes a `struct comedi_file_info` and assigns a subdevice minor device number (if there are any available), storing a pointer to the allocated `struct comedi_file_info` in `comedi_subdevice_minor_table[i]` where `i` is the array index corresponding to the subdevice minor device number (indexed by subdevice minor device number minus `COMEDI_NUM_BOARD_MINORS`). The information stored in the `struct comedi_file_info` can be derived from the subdevice structure (`struct comedi_subdevice`) itself, so the `struct comedi_file_info` is superfluous. Change `comedi_subdevice_minor_table[]` to hold pointers to the actual `struct comedi_subdevice`'s. `comedi_alloc_subdevice_minor()` no longer needs to allocate a `struct comedi_file_info` and `comedi_free_subdevice_info()` no longer has a `struct comedi_file_info` to free. Replace `comedi_file_info_from_minor()` with `comedi_subdevice_from_minor()`, returning a (possibly NULL) pointer to a `struct comedi_subdevice` from the table. This has knock-on effects for `comedi_dev_from_subdevice_minor()`, `comedi_read_subdevice()` and `comedi_write_subdevice()`. In particular, `comedi_read_subdevice()` and `comedi_write_subdevice()` now need to check the subdevice flags to see if the determine whether to override the comedi device's default read/write subdevice. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
Merge the code from `comedi_file_info_from_board_minor()` into `comedi_dev_from_board_minor()` and remove it since nothing else calls it. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
Merge the code from `comedi_clear_subdevice_minor()` into `comedi_free_subdevice_minor()` and remove it since nothing else calls it. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
Refactor `comedi_dev_from_minor()` to call one of two new functions `comedi_dev_from_board_minor()` (for minor device numbers less than `COMEDI_NUM_BOARD_MINORS`) or `comedi_dev_from_subdevice_minor()` (for minor device numbers greater than or equal to `COMEDI_NUM_BOARD_MINORS`, which are subdevice minor device numbers). Remove `comedi_file_info_from_minor()` as it is no longer used. This is a step towards removing `struct comedi_file_info`. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
Since the parameters of `comedi_read_subdevice()` and `comedi_write_subdevice()` have changed, there is no longer a need to keep a local variable `struct comedi_file_info *info` hanging around in the file operation functions and device attribute access functions. Remove the variable from those function and replace the call sequence `info = comedi_file_info_from_minor(minor)`, `dev = comedi_dev_from_file_info(info)` with the simpler `dev = comedi_dev_from_minor(minor)`. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
`comedi_read_subdevice()` and `comedi_write_subdevice()` currently take a single parameter pointing to a `struct comedi_file_info`. I'm trying to get rid of `struct comedi_file_info` so as part of that plan, `comedi_read_subdevice()` and `comedi_write_subdevice()` need to change. Change them to take two parameters: a pointer to a `struct comedi_device` and a minor device number. If the minor device number is a "board" minor device number (`minor < COMEDI_NUM_BOARD_MINORS`) we'll always return the default read or write subdevice. If the minor device number if a "subdevice" minor device number a different read or write subdevice may be returned. In that case, use the subdevice minor device number to look up the information about whether the default read or write subdevice needs to be overridden. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
The comedi device attribute functions such as `show_max_read_buffer_kb()` call `dev_get_drvdata()` to get a pointer to a `struct comedi_file_info` from the private driver data field of class device. Change them to use the minor device number to look up this pointer value so they behave more like the file operation functions. Check the pointer is non-NULL as the entry in the minor device table could have been set to NULL. Note that there is still a race condition in the use of this pointer value after acquiring the mutex which needs to be dealt with once reference counting has been implemented for comedi devices. The calls to `dev_set_drvdata()` from `comedi_alloc_board_minor()` and `comedi_alloc_subdevice_minor()` are no longer needed so remove them. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
The comedi device attribute functions such as `show_read_buffer_kb()` or `show_write_buffer_kb()` call `comedi_read_subdevice()` or `comedi_write_subdevice()` without acquiring the comedi device's mutex first, although the functions do acquire the mutex afterwards. Change them to acquire the mutex first. This is consistent with most of the comedi device file operation functions (apart from `comedi_read()` and `comedi_write()` which probably need looking at). Despite the use of the mutex, there are still race conditions as the `struct comedi_file_info *info` variable value set before acquiring the mutex could be stale after acquiring the mutex. This problem will be dealt with once reference counting has been implemented for the comedi devices. This patch also adds local variable `struct comedi_device *dev` to the functions to reduce the use of the `info` variable a little bit. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
Most of the comedi core uses the identifier `dev` to point to a `struct comedi_device`. The device sysfs attribute functions such as `show_max_read_buffer_kb()` use the parameter id `dev` to point to a `struct device`. Rename the parameter to `csdev` for "class device" for consistency with the functions that call `device_create()` to create these class devices (`comedi_alloc_board_minor()` and `comedi_alloc_subdevice_minor()`). Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
The `hardware_device` member of `struct comedi_device_info` is only set to point to a hardware device by the auto-configuration code (specifically `comedi_alloc_board_minor() with a non-NULL `hardware_device` parameter) so that it can be found again by the auto-unconfiguration code (specifically `comedi_release_hardware_device()`). However, as `info->device->hw_dev` (where `info` is a pointer to the `struct comedi_device_info`) is set to the same value as `info->hardware_device` (by calling `comedi_set_hw_dev()` with the same hardware device pointer) we can look for that instead, so there is no need for the `hardware_device` member any more. Get rid of it. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
`comedi_clear_minor()` calls either `comedi_clear_board_minor()` or `comedi_clear_subdevice_minor()` depending on its minor device number parameter. The one it calls only depends on where it is called from, so bypass the calls to `comedi_clear_minor()` and remove it. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
The comedi core reserves minor device numbers from 0 to `COMEDI_NUM_BOARD_MINORS - 1` (0 to 0x30 - 1) for the main comedi "board" devices and reserves minor device numbers from `COMEDI_NUM_BOARD_MINORS` to `COMEDI_NUM_MINORS - 1` (0x30 to 0x100 - 1) for comedi subdevices (or at least those that claim to support asynchronous comedi commands). There is an array `comedi_file_info_table[COMEDI_NUM_MINORS]` used to hold pointers to information for each board minor device number and subdevice minor device number that has been allocated (with NULL pointers for those not allocated), along with a protective lock `comedi_file_info_table_lock`. Since the ranges of board minor device numbers and subdevice minor device numbers do not overlap, we can use separate tables and separate locks for the different types of minor device numbers. This will allow us to use different pointer types for the elements of each table in the future without just using a generic `void *`. (At the moment, the table elements point to a `struct comedi_file_info` allocated dynamically for each allocated board minor device or subdevice minor device, but I plan to get rid of that data structure.) Replace `comedi_file_info_table[COMEDI_NUM_MINORS]` with two new arrays of the same type, `comedi_board_minor_table[COMEDI_NUM_BOARD_MINORS]` for board minors, and `comedi_subdevice_minor_table[COMEDI_NUM_SUBDEVICE_MINORS]` for subdevice minors (where `COMEDI_NUM_SUBDEVICE_MINORS` is `COMEDI_NUM_MINORS - COMEDI_NUM_BOARD_MINORS`). `comedi_subdevice_minor_table[]` is indexed by the subdevice minor number minus `COMEDI_NUM_BOARD_MINORS` since `COMEDI_NUM_BOARD_MINORS` is the first valid subdevice minor number. Replace `comedi_file_info_table_lock` with `comedi_board_minor_table_lock` for board minors and `comedi_subdevice_minor_table_lock` for subdevice minors. Refactor `comedi_clear_minor()` to call one of two new functions `comedi_clear_board_minor()` and `comedi_clear_subdevice_minor()` depending on the minor device number passed as a parameter. Similarly, refactor `comedi_file_info_from_minor()` to call one of two new functions `comedi_file_info_from_board_minor()` and `comedi_file_info_from_subdevice_minor()` depending on the minor device number parameter. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
The macro `COMEDI_FIRST_SUBDEVICE_MINOR` just expands to another macro `COMEDI_NUM_BOARD_MINORS`. Replace uses of `COMEDI_FIRST_SUBDEVICE_MINOR` with `COMEDI_NUM_BOARD_MINORS` and get rid of the former. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
The macro definitions `COMEDI_NUM_MINORS` and `COMEDI_FIRST_SUBDEVICE_MINOR` are only used in "comedi_fops.c" so move them to there from "comedidev.h". Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
The spin-lock `comedi_file_info_table_lock` is used to protect against simultaneous modification and access of `comedi_file_info_table[]`. Change it from a spin-lock to a mutex as it is only used in contexts where sleeping is allowed. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
Call `comedi_set_hw_dev()` to set the `hw_dev` member of `struct comedi_device` in `comedi_alloc_board_minor()` instead of in `comedi_auto_config()`. Don't bother to check for an error returned by `comedi_set_hw_dev()` here; it only fails when changing a non-NULL pointer to a different non-NULL pointer and since the `struct comedi_device` has just been allocated and initialized, its `hw_dev` will be NULL already. Calling `comedi_set_hw_dev()` with a non-NULL hardware device pointer increments the kref counter for the hardware device. If `comedi_alloc_board_minor()` fails further down the function, we rely on its call to `comedi_device_cleanup()` to call `comedi_clear_hw_dev()` (via `comedi_device_detach()` and `cleanup_device()`) to clear `hw_dev` and decrement its kref counter. (That's the "beneficial side-effect" mentioned in the patch that replaced `__comedi_device_detach()`.) Remove the call to `comedi_set_hw_dev()` from `comedi_auto_config()` as the call to `comedi_alloc_board_minor()` does it for us. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
`comedi_device_postconfig()` calls `comedi_device_detach()` on failure. Remove that call and make the callers of `comedi_device_postconfig()` call `comedi_device_detach()` themselves if it returns an error. This seems more logical as the callers of `comedi_device_postconfig()` called `comedi_device_detach()` anyway if they didn't call `comedi_device_postconfig()`. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
`comedi_device_detach()` does nothing if the `struct comedi_device`'s `attached` member is false, otherwise it calls `__comedi_device_detach()` to do the real work. `__comedi_device_detach()` is called from various other functions in "drivers.c" (`comedi_device_postconfig()`, `comedi_device_attach()`, and `comedi_auto_config()`) to bypass the check for the `attached` member being false. If we make `__comedi_device_detach()` safe to call when the `attached` member is already false, we can remove the check in `comedi_device_detach()`, subsume `__comedi_device_detach()` within `comedi_device_detach()`, and replace all the calls to `__comedi_device_detach()` with calls to `comedi_device_detach()`. In fact, it is already safe to call `__comedi_device_detach()` when the `attached` member is false. We just need to remove the warning message it outputs when the `driver` member is NULL. Then the function becomes idempotent without outputting spurious warnings. (It is idempotent because `dev->driver->detach()` will only be called once at most and the call to `cleanup_device()` is idempotent itself.) Combine `comedi_device_detach()` with `__comedi_device_detach()`, removing the check for the `attached` member being false and removing the warning about the `driver` member being NULL, and replace all calls to `__comedi_device_detach()` with calls to the combined `comedi_device_detach()`. A beneficial side-effect of the above change is that a call to `comedi_device_detach()` will always result in a call to `cleanup_device()` and so always result in a call to `comedi_clear_hw_dev()`. We will make use of this beneficial side-effect in a later patch. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
On failure of the call to the low-level comedi device driver's `->attach()` handler from `__comedi_device_attach()`, reverse the current ordering of the calls to `module_put()` and `comedi_device_detach()` because `__comedi_device_detach()` will call code in the module being put. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
For a legacy device attachment with the `COMEDI_DEVCONFIG` ioctl, `do_devconfig_ioctl()` calls `comedi_device_attach()` to find a matching device driver and attach the device. It then tries to increment the device driver's module count and if that fails it detaches the device. So on successful attachment of a device by the `COMEDI_DEVCONFIG` ioctl, the device driver's module count will have been incremented. `comedi_device_attach()` is called from nowhere else. It already increments the device driver's module count temporarily and decrements it again; if it gets as far as calling `comedi_device_postconfig()` the module count is decremented within that function. Simplify the above by removing the decrement of the device driver module count from `comedi_device_postconfig()`. If the call to `comedi_device_postconfig()` succeeds, `comedi_device_attach()` will return with the module count still incremented, otherwise decrement the module count before returning the error. Don't try and increment the module count in `do_devconfig_ioctl()` after a successful return from `comedi_device_attach()` as the module count has now already been incremented. `comedi_device_postconfig()` is also called by `comedi_auto_config()` which currently has to increment the device driver's module count temporarily so that `comedi_device_postconfig()` can decrement it, but always returns with no overall change to the module count. Remove all the module count manipulations from `comedi_device_postconfig()`. There is no other reason for `comedi_auto_config()` to increment the device driver's module count temporarily, since it is only called (indirectly) from the device driver itself (usually via one of the wrappers `comedi_pci_auto_config()` or `comedi_usb_auto_config()`). Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
Move a few functions and variables to avoid a couple of forward declarations. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
If a dynamically allocated (non-legacy, and automatically configured) comedi device has been successfully unconfigured by use of the `COMEDI_DEVCONFIG` ioctl, then remove the device afterwards. (Dynamically identified comedi devices are identified by their minor device number being `comedi_num_legacy_minors` or greater.) This is done in `comedi_unlocked_ioctl()` on return from `do_devconfig_ioctl()`. Note that there is an unlikely race condition with some other thread that has just called `comedi_file_info_from_minor()` or `comedi_dev_from_minor()` and is about to use the device, but that race condition also exists for automatically removed devices and will be dealt with properly once reference counting of comedi devices has been implemented. We do avoid a race condition between automatic removal and removal by the `COMEDI_DEVCONFIG` ioctl though. Also add an extra precaution in `do_devconfig_ioctl()` to avoid configuring a dynamically allocated device since there is a tight window avoiding the race condition where this could happen and the device is about to be removed anyway. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
When `comedi_unlocked_ioctl()` handled the `COMEDI_DEVCONFIG` ioctl via a call to `do_devconfig()`, this used to be allowed to attach a legacy hardware device to any board minor device, and the auto-unconfiguration code for non-legacy used to search all board minor devices to find the hardware device being removed. After calling `do_devconfig()` successfully, `comedi_unlocked_ioctl()` sets the `hardware_device` member of the `struct comedi_file_info` to NULL to stop the auto-unconfiguration code finding it by accident and unconfiguring the wrong comedi device as a result. The above is no longer necessary because `do_devconfig()` now only allows legacy hardware devices to be attached to comedi board minor device numbers below `comedi_num_legacy_minors` and the auto-unconfiguration code (particularly `comedi_release_hardware_device()`) only searches comedi board minor device numbers greater than or equal to `comedi_num_legacy_minors`, so there is no overlap. Remove the now unnecessary setting of `info->hardware_device = NULL` in `comedi_unlocked_ioctl()`. Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Ian Abbott 提交于
`comedi_alloc_board_minor()` is called for both reserved "legacy" devices created during module initialization, and for dynamically created devices (via `comedi_auto_config()`). All the minor device numbers from 0 to `comedi_num_legacy_minors - 1` are for legacy devices and all those from `comedi_num_legacy_minors` to `COMEDI_NUM_BOARD_MINORS - 1` are for dynamically created devices. `comedi_release_hardware_device()` is called (via `comedi_auto_unconfig()`) when a dynamically created device is being removed. It needs to search the table of minor device numbers to see which one is associated with the hardware device. It currently starts the search at minor device number 0. Change it to start from `comedi_num_legacy_minors` to skip over those belonging to legacy devices. Also change `comedi_alloc_board_minor()` to skip the legacy devices when searching for a free minor device number for the dynamically created device. (The validity of the `hardware_device` parameter is used to distinguish the legacy devices from the dynamically created ones.) Signed-off-by: NIan Abbott <abbotti@mev.co.uk> Reviewed-by: NH Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-