- 06 4月, 2013 40 次提交
-
-
由 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>
-
由 Ian Abbott 提交于
Return from `comedi_alloc_board_minor()` with the mutex of the created `struct comedi_device` pre-locked. This allows further initialization by the caller without the worry of something getting in there first. `comedi_auto_config()` no longer needs to check if the device is already "attached" since whatever was trying to attach the device would need to have locked the mutex first. 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 提交于
Change `comedi_alloc_board_minor()` to return a pointer to the allocated `struct comedi_device` instead of a minor device number. Return an `ERR_PTR()` value on error instead of a negative error number. This saves a call to `comedi_dev_from_minor()` in `comedi_auto_config()`. Also change it to use a local variable `dev` to hold the pointer to the `struct comedi_device` instead of using `info->device` all the time. 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_free_board_minor()` is now only called from the same .c file it is defined in, so give it static linkage. 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 `comedi_auto_config()` fails after allocating the minor device, call `comedi_release_hardware_device()` instead of `comedi_free_board_minor()` to free the minor device. That's the same call that `comedi_auto_unconfig()` uses, and is slightly safer as it checks the minor device number is still tied to the same hardware device. 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 提交于
Add `comedi_release_hardware_device()` as a replacement for the call sequence `comedi_find_board_minor()`, `comedi_free_board_minor()`. This is slightly safer as we can make sure nothing funny happens to the found `comedi_file_info_table[]` entry in the middle of the sequence. Change `comedi_auto_unconfig()` to call the new function instead of the old sequence. Remove `comedi_find_board_minor()` as it has no other callers. 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 提交于
Split out the part of `comedi_free_board_minor()` that clears the `comedi_file_info_table[]` element into new function `comedi_clear_minor()`. Split out the remainder of the original function into new function `comedi_free_board_file_info()`. Also re-use a call to `comedi_clear_minor()` in `comedi_free_subdevice_minor()` instead of doing the same thing inline. 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_cleanup()` is called just before freeing a comedi device. It is possible for the device to still be open in which case the module reference counts for the core comedi module and possibly the low-level driver module will remain out of whack because `comedi_close()` will not find the comedi device and so will not decrement the module counts. This really needs to be handled better, but for now decrement the module counts in `comedi_device_cleanup()` according to the number of outstanding opens. 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_init()` is only called from one place (`comedi_alloc_board_minor()`) and the `struct comedi_device` has already been zeroed out by `kzalloc()`. Don't bother zeroing it out again with `memset()`. 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 提交于
In the comedi core module, `comedi_file_info_table[]` is tentatively defined in the .bss section, so will already be zeroed out on initialization. Don't bother zeroing it out again in the module initialization function `comedi_init()`. 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 提交于
Do some minimal error checking of the parameters of `comedi_auto_config()`. Just make sure the `hardware_device` and `driver` parameters are non-NULL. 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>
-
由 Alexey Khoroshilov 提交于
There is no any error handling in dgrp_create_class_sysfs_files(). The patch adds code to check return values and propagate them to dgrp_init_module(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: NAlexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Kurt Kanzenbach 提交于
The `usbip list -l' command shows your local usb-devices. Example: $ usbip list -l $ Local USB devices $ ================= $ - busid 1-1 (13fe:1d00) $ 1-1:1.0 -> usb-storage $ $ - busid 1-2 (0409:55aa) $ 1-2:1.0 -> hub However this list command doesn't show which device is connected to this busid. Therefore you have to use another tool e.g. lsusb to determine that. This patches adds the possibility to see which device that is. Example: $ usbip list -l $ Local USB devices $ ================= $ - busid 1-1 (13fe:1d00) $ Kingston Technology Company Inc. : DataTraveler 2.0 1GB/4GB Flash Drive / Patriot Xporter 4GB Flash $ 1-1:1.0 -> usb-storage $ $ - busid 1-2 (0409:55aa) $ NEC Corp. : Hub (0409:55aa) $ 1-2:1.0 -> hub If parsable is specified the info will be not printed. Signed-off-by: NKurt Kanzenbach <ly80toro@cip.cs.fau.de> Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Kurt Kanzenbach 提交于
The command `usbip attach' uses --host for specifing the remote host, while `usbip list' uses --remote. This is confusing and this patch adapts this. In Addition changed the manpage and README accordingly. Before: $ usbip attach --host <host> -b <busid> $ usbip list --remote <host> Now: $ usbip attach --remote <host> -b <busid> $ usbip list --remote <host> Signed-off-by: NKurt Kanzenbach <ly80toro@cip.cs.fau.de> Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Kurt Kanzenbach 提交于
Since the names.c/names.h are taken from another project, some functions which names.c provides aren't used by usbipd. This patch fixes: - removed useless comments - unified debug/error messages by using the macros provided by usbip_common.h - removed unnused code The code cleanup includes: - remove unused data structures - remove code to create them - remove code to access them The file names.c is used to parse the `usb.ids' file. The parser stores a lot of information about usb devices that is never used. The `usb.ids' file has several sections. Some variables (like `lasthut') store the ID of the current section, and those variables are used to decide which section is currently being parsed (i.e. in which data structure the current line will be stored). We removed the code to read those IDs because they are never used anyway. We replaced them by the pseudo-ID `1' (instead of reading the ID from the file) to indicate that the parser is in a section that can be ignored. If the parser is in such a section, the current line (which contains sub-items for this section) is discarded. Signed-off-by: NKurt Kanzenbach <ly80toro@cip.cs.fau.de> Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Kurt Kanzenbach 提交于
Since no usbip_name function is used in usbipd, it's not necessary to parse "usb.ids" file at startup. Signed-off-by: NKurt Kanzenbach <ly80toro@cip.cs.fau.de> Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Stefan Reif 提交于
Call freeaddrinfo when connect/listen fails. Call usbip_host_driver_close on error. Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Kurt Kanzenbach 提交于
This patch simplified "stub_device_free" cleanup function: - changed return type to void, since the return value is not checked anywhere - kfree is NULL-safe, so removed if statement - deleted debug-message Signed-off-by: NKurt Kanzenbach <ly80toro@cip.cs.fau.de> Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Kurt Kanzenbach 提交于
This for loop is not needed, since STUB_BUSID_OTHER is defined as 0. In Addition added a comment if STUB_BUSID_OTHER changes sometime. Signed-off-by: NKurt Kanzenbach <ly80toro@cip.cs.fau.de> Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Kurt Kanzenbach 提交于
In each if-else case "return" is called. This is why these if-else-statements are useless. Removing them improves understanding and readability. Signed-off-by: NKurt Kanzenbach <ly80toro@cip.cs.fau.de> Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Kurt Kanzenbach 提交于
In each errorcase spin_unlock_irq is called and -EINVAL is returned. To simplify that I created a label called "err" doing that. On Success count will be returned. Signed-off-by: NKurt Kanzenbach <ly80toro@cip.cs.fau.de> Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Stefan Reif 提交于
Fix an indent. Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Stefan Reif 提交于
Remove broken preprocessor macro "hardware". It is unused and it references an element (pdev in vhci_hcd) that does not exist. Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Kurt Kanzenbach 提交于
Enumerations for one comment makes no sense. This is why this should be removed. Signed-off-by: NKurt Kanzenbach <ly80toro@cip.cs.fau.de> Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Stefan Reif 提交于
re-indent funtion "pickup_urb_and_free_priv" to improve readability. Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Kurt Kanzenbach 提交于
Reformat function stub_recv_cmd_unlink() to improve readability. Signed-off-by: NKurt Kanzenbach <ly80toro@cip.cs.fau.de> Signed-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Stefan Reif 提交于
replace numbers in code by ascii text constants as suggested by Dan Carpenter: http://driverdev.linuxdriverproject.org/pipermail/devel/2013-February/035907.htmlSigned-off-by: NStefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Dan Carpenter 提交于
There are some fields in "edata" which have not been cleared. One example is edata.cmd. It leaks uninitialized stack information to the user. Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 Dan Carpenter 提交于
"cfg_ap_config" has a number of fields which are not cleared before we copy them to the user. I've added a memset() at the beginning to set everything to zero. Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com> Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
-
由 H Hartley Sweeten 提交于
The simple mA ranges 0 to 20, 4 to 20, and 0 to 32 are fairly common. Introduce them in the comedi core and use them in the drivers. 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 private range, range_usbdux_ao_range, in this driver and use the comedi provided range_unipolar2_5 instead. 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 private range, range_ni_S_ai_6143, in this driver and use the comedi provided range_bipolar5 instead. 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 private range, range_ni_M_622x_ao, in this driver and use the comedi provided range_bipolar10 instead. 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 private ranges, dt9812_2pt5_a{in,out}_range, in this driver and use the comedi provided range_unipolar2_5 instead. 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 提交于
Introduce a simple unipolar 0 to 2.5 range, range_unipolar2_5, for use by the comedi drivers. 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 private ranges, dt9812_10_a{in,out}_range, in this driver and use the comedi provided range_bipolar10 instead. 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>
-