[PATCH] Staging: comedi: fix block comments coding style issue in comedi.h
Fix up block comments to make a trailing */ on a separate line Signed-off-by: maomao xu --- drivers/staging/comedi/comedi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index 66edda1..ec5e59c 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -895,7 +895,8 @@ enum amplc_dio_ts_clock_src { }; /* Values for setting a gate source with INSN_CONFIG_SET_GATE_SRC for - * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver). */ + * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver). + */ enum amplc_dio_gate_source { AMPLC_DIO_GAT_VCC, /* internal high logic level */ AMPLC_DIO_GAT_GND, /* internal low logic level */ -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
re: staging: wilc1000: call linux_sdio_init instead of io_init
Hello Glen Lee, The patch de11ee8b214e: "staging: wilc1000: call linux_sdio_init instead of io_init" from Nov 6, 2015, leads to the following static checker warning: drivers/staging/wilc1000/wilc_sdio.c:574 sdio_init() info: ignoring unreachable code. drivers/staging/wilc1000/wilc_sdio.c 553 554 static int sdio_init(struct wilc *wilc, wilc_debug_func func) 555 { 556 sdio_cmd52_t cmd; 557 int loop; 558 u32 chipid; 559 560 memset(&g_sdio, 0, sizeof(wilc_sdio_t)); 561 562 g_sdio.dPrint = func; 563 564 if (!linux_sdio_init()) { 565 g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed io init bus...\n"); 566 return 0; 567 } else { 568 return 0; 569 } 570 571 /** 572 * function 0 csa enable 573 **/ 574 cmd.read_write = 1; This line is not reachable now. Really, you should consider runing Smatch over this driver. Anyway, I have pasted most of the warnings here. Based on yesterday's linux-next. Some of the warnings are not in the released versions of Smatch... drivers/staging/wilc1000/wilc_wlan.c:1330 wilc_wlan_start() warn: bool is not less than zero. drivers/staging/wilc1000/host_interface.c:368 handle_set_wfi_drv_handler() warn: 'sem:&hif_sema_driver' is sometimes locked here and sometimes unlocked. drivers/staging/wilc1000/host_interface.c:1028 Handle_Connect() error: potential null dereference 'hif_drv->usr_conn_req.pu8ssid'. (kmalloc returns null) drivers/staging/wilc1000/host_interface.c:1428 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'hif_drv->usr_scan_req.net_info[i]->au8bssid' drivers/staging/wilc1000/host_interface.c:1429 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'pstrNetworkInfo->au8bssid' drivers/staging/wilc1000/host_interface.c:1450 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt]->au8bssid' drivers/staging/wilc1000/host_interface.c:1451 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'pstrNetworkInfo->au8bssid' drivers/staging/wilc1000/host_interface.c:1771 Handle_Key() warn: passing freed memory 'pstrHostIFkeyAttr->attr.wep.key' drivers/staging/wilc1000/host_interface.c:1872 Handle_Key() error: double unlock 'sem:&hif_drv->sem_test_key_block' drivers/staging/wilc1000/host_interface.c:1933 Handle_Key() error: double unlock 'sem:&hif_drv->sem_test_key_block' drivers/staging/wilc1000/host_interface.c:2619 Handle_ListenStateExpired() error: potential null dereference 'wid.val'. (kmalloc returns null) drivers/staging/wilc1000/host_interface.c:2619 Handle_ListenStateExpired() error: we previously assumed 'wid.val' could be null (see line 2616) drivers/staging/wilc1000/host_interface.c:2703 Handle_SetMulticastFilter() warn: 0xff is larger than 1 bits drivers/staging/wilc1000/host_interface.c:2704 Handle_SetMulticastFilter() warn: right shifting more than type allows drivers/staging/wilc1000/host_interface.c:4062 hif_get_cfg() warn: inconsistent returns 'sem:&hif_drv->sem_cfg_values'. Locked on: line 3980 Unlocked on: line 4062 drivers/staging/wilc1000/host_interface.c:4198 host_int_init() warn: inconsistent returns 'sem:&hif_drv->sem_cfg_values'. Locked on: line 4198 Unlocked on: line 4188 drivers/staging/wilc1000/host_interface.c:4984 host_int_setup_ipaddress() info: ignoring unreachable code. drivers/staging/wilc1000/wilc_wfi_cfgoperations.c:731 scan() warn: this array is probably non-NULL. 'request->ssids + i->ssid' drivers/staging/wilc1000/wilc_wfi_cfgoperations.c:732 scan() error: potential null dereference 'strHiddenNetwork.pstrHiddenNetworkInfo'. (kmalloc returns null) drivers/staging/wilc1000/wilc_wfi_cfgoperations.c:1280 add_key() error: potential null dereference 'g_key_gtk_params.key'. (kmalloc returns null) drivers/staging/wilc1000/wilc_wfi_cfgoperations.c:2995 add_station() error: buffer overflow 'priv->assoc_stainfo.au8Sta_AssociatedBss' 9 <= 2007 drivers/staging/wilc1000/linux_wlan.c:423 linux_wlan_txq_task() error: double unlock 'sem:&wl->txq_thread_started' drivers/staging/wilc1000/linux_wlan.c:493 linux_wlan_get_firmware() warn: missing error code here? 'netdev_priv()' failed. 'ret' = '0' drivers/staging/wilc1000/linux_wlan.c:1014 wilc1000_wlan_init() warn: putting NUL at 'size' might be off-by-one drivers/staging/wilc1000/linux_wlan.c:1014 wilc1000_wlan_init() error: off-by-one overflow 'Firmware_ver' size 20. rl = '0-20' drivers/staging/wilc1000/linux_wlan.c:1363 mac_ioctl() warn: passing uninitialized 'rssi' drivers/staging/wilc1000/coreconfigurator.c:532 ParseAssocRespInfo() warn: possible memory leak of 'pstrConnectRespInfo' regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://dr
Re: [PATCH 05/23] staging: comedi: adv_pci1710: define the mux control register bits
On 13/11/15 18:11, H Hartley Sweeten wrote: For aesthetics, define some macros to set the bits in the mux control register. Also, rename the 'mux_ext' member of the private data. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) Presumably this is PATCH v2 05/23. -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 00/23] staging: comedi: adv_pci1710: tidy up driver
On 13/11/15 18:11, H Hartley Sweeten wrote: Now that the PCI-1720 support has been moved to a separate driver, remove some unnecessary boardinfo in this driver and tidy it up a bit. v2: address some issues pointed out by Ian Abbott with the patches that support external analog output reference tidy up analog output subdev_flags fix counter 0 internal clock source also add a new patch to tidy up analog input subdev_flags H Hartley Sweeten (23): staging: comedi: adv_pci1710: remove 'has_irq' boardinfo staging: comedi: adv_pci1710: remove 'has_counter' boardinfo staging: comedi: adv_pci1710: don't "reset" board when detaching staging: comedi: adv_pci1710: refactor ai range programming staging: comedi: adv_pci1710: define the mux control register bits staging: comedi: adv_pci1710: remove 'n_aichan' boardinfo staging: comedi: adv_pci1710: remove 'has_di_do' boardinfo staging: comedi: adv_pci1710: remove 'has_large_fifo' and 'has_diff_ai' boardinfo staging: comedi: adv_pci1710: tidy up boardinfo definition staging: comedi: adv_pci1710: rename interrupt_service_pci1710() staging: comedi: adv_pci1710: rename pci171x_insn_counter_config() staging: comedi: adv_pci1710: rename pci171x_d[io]_insn_bits staging: comedi: adv_pci1710: rename pci171x_ao_insn_write() staging: comedi: adv_pci1710: support external analog output reference staging: comedi: adv_pci1710: tidy up analog output subdev_flags staging: comedi: adv_pci1710: tidy up analog input subdev_flags staging: comedi: adv_pci1710: post increment 'subdev' in (*auto_attach) staging: comedi: adv_pci1710: ai (*cancel) should not enable software trigger staging: comedi: adv_pci1710: tidy up pci1710_reset() staging: comedi: adv_pci1710: fix counter 0 internal clock source staging: comedi: adv_pci1710: fix ai (*insn_read) staging: comedi: adv_pci1710: rename pci171x_ai_{cmd,cmdtest}() staging: comedi: adv_pci1710: rename pci171x_ai_*() drivers/staging/comedi/drivers/adv_pci1710.c | 437 +-- 1 file changed, 207 insertions(+), 230 deletions(-) Thanks! Reviewed-by: Ian Abbott -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: comedi: ni_mio_common: add "no_channel" versions of some functions
On 14/11/15 18:19, Andrzej Pietrasiewicz wrote: ni_release_ai_mite_channel(), ni_release_ao_mite_channel(), ni_release_gpct_mite_channel() and ni_release_cdo_mite_channel() call functions which interpret -1 as a special value meaning "no channel". This patch adds explicit "no_channel" versions instead. On the other hand, after "no_channel" versions are used, ni_set_ai_dma_channel(), ni_set_ao_dma_channel(), ni_set_gpct_dma_channel(), ni_set_cdo_dma_channel() are called with actual "channel" parameter being always unsigned, so their signatures are changed accordingly. A side benefit of the changes is suppressesing 4 sparse warnings: "warning: shift too big (4294967295) for type int". Signed-off-by: Andrzej Pietrasiewicz --- drivers/staging/comedi/drivers/ni_mio_common.c | 82 +++--- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 6cc304a..3caadd1 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -579,48 +579,54 @@ static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel) return 0; } -/* negative channel means no channel */ -static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel) +static inline void ni_set_ai_dma_channel(struct comedi_device *dev, +unsigned channel) { - unsigned bits = 0; - - if (channel >= 0) - bits = ni_stc_dma_channel_select_bitfield(channel); + unsigned bits = ni_stc_dma_channel_select_bitfield(channel); ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG, NI_E_DMA_AI_SEL_MASK, NI_E_DMA_AI_SEL(bits)); } -/* negative channel means no channel */ -static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel) +static inline void ni_set_ai_dma_no_channel(struct comedi_device *dev) { - unsigned bits = 0; + ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG, NI_E_DMA_AI_SEL_MASK, 0); +} - if (channel >= 0) - bits = ni_stc_dma_channel_select_bitfield(channel); +static inline void ni_set_ao_dma_channel(struct comedi_device *dev, +unsigned channel) +{ + unsigned bits = ni_stc_dma_channel_select_bitfield(channel); ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG, NI_E_DMA_AO_SEL_MASK, NI_E_DMA_AO_SEL(bits)); } -/* negative channel means no channel */ +static inline void ni_set_ao_dma_no_channel(struct comedi_device *dev) +{ + ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG, NI_E_DMA_AO_SEL_MASK, 0); +} + static inline void ni_set_gpct_dma_channel(struct comedi_device *dev, unsigned gpct_index, - int channel) + unsigned channel) { - unsigned bits = 0; - - if (channel >= 0) - bits = ni_stc_dma_channel_select_bitfield(channel); + unsigned bits = ni_stc_dma_channel_select_bitfield(channel); ni_set_bitfield(dev, NI_E_DMA_G0_G1_SEL_REG, NI_E_DMA_G0_G1_SEL_MASK(gpct_index), NI_E_DMA_G0_G1_SEL(gpct_index, bits)); } -/* negative mite_channel means no channel */ +static inline void ni_set_gpct_dma_no_channel(struct comedi_device *dev, + unsigned gpct_index) +{ + ni_set_bitfield(dev, NI_E_DMA_G0_G1_SEL_REG, + NI_E_DMA_G0_G1_SEL_MASK(gpct_index), 0); +} + static inline void ni_set_cdo_dma_channel(struct comedi_device *dev, - int mite_channel) + unsigned mite_channel) { struct ni_private *devpriv = dev->private; unsigned long flags; @@ -628,16 +634,26 @@ static inline void ni_set_cdo_dma_channel(struct comedi_device *dev, spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags); devpriv->cdio_dma_select_reg &= ~NI_M_CDIO_DMA_SEL_CDO_MASK; - if (mite_channel >= 0) { - /* -* XXX just guessing ni_stc_dma_channel_select_bitfield() -* returns the right bits, under the assumption the cdio dma -* selection works just like ai/ao/gpct. -* Definitely works for dma channels 0 and 1. -*/ - bits = ni_stc_dma_channel_select_bitfield(mite_channel); - devpriv->cdio_dma_select_reg |= NI_M_CDIO_DMA_SEL_CDO(bits); - } + /* +* XXX just guessing ni_stc_dma_channel_select_bitfield() +* returns the right bits, under the assumption the cdio dma +* selection works just like ai/ao/gpct. +* Definitely works for dma channels 0 and 1. +*/ + bits = ni_stc_dma_channel_
[PATCH 00/28] staging: most: bug-fixes and clean-up
This patchset is needed to have open issues of the MOST driver fixed and the code cleaned up. Christian Gromm (28): staging: most: remove unnecessary keep_mbo variable staging: most: rename variables staging: most: simplify expression staging: most: unify types staging: most: use min_t staging: most: fix mbo leak staging: most: fix tracking of MBO offset staging: most: use readl and writel functions staging: most: remove function destroy_most_c_obj staging: most: add missing call to ida_simple_remove staging: most: move call to disconnect_channel callback staging: most: move initialization of pointer staging: most: move mutex staging: most: move channel disconnect to function most_deregister_interface staging: most: remove tainted flag staging: most: remove reference counter staging: most: remove code to destroy channel staging: most: remove redundant mutexes staging: most: remove redundant call to wake_up_interruptible staging: most: encapsulate shared code staging: most: fix retrieval of buffer availability staging: most: rename variable channel staging: most: fix race conditions staging: most: change type of access_ref staging: most: remove stacked_mbo staging: most: rearrange function aim_write staging: most: add statistics for dropped packets staging: most: remove 2nd forward declaration of struct most_aim drivers/staging/most/aim-cdev/cdev.c | 362 - drivers/staging/most/aim-network/networking.c | 11 +- drivers/staging/most/hdm-dim2/dim2_hdm.c |4 +- drivers/staging/most/mostcore/core.c | 125 ++--- drivers/staging/most/mostcore/mostcore.h |3 +- 5 files changed, 218 insertions(+), 287 deletions(-) -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 04/28] staging: most: unify types
This patch unifies variable types to get less castings. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c |8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index b293078..4bf0322 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -39,7 +39,7 @@ struct aim_channel { struct most_channel_config *cfg; unsigned int channel_id; dev_t devno; - unsigned int mbo_offs; + size_t mbo_offs; struct mbo *stacked_mbo; DECLARE_KFIFO_PTR(fifo, typeof(struct mbo *)); atomic_t access_ref; @@ -221,8 +221,7 @@ error: static ssize_t aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) { - ssize_t copied; - size_t to_copy, not_copied; + size_t to_copy, not_copied, copied; struct mbo *mbo; struct aim_channel *channel = filp->private_data; @@ -247,8 +246,7 @@ start_copy: return -EIO; } - to_copy = min((int)count, - (int)(mbo->processed_length - channel->mbo_offs)); + to_copy = min(count, (size_t)mbo->processed_length - channel->mbo_offs); not_copied = copy_to_user(buf, mbo->virt_address + channel->mbo_offs, -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 02/28] staging: most: rename variables
This patch renames some variables for better readability. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index 6f70ed7..bff891f 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -221,8 +221,8 @@ error: static ssize_t aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) { - ssize_t retval; - size_t not_copied, proc_len; + ssize_t copied; + size_t to_copy, not_copied; struct mbo *mbo; struct aim_channel *channel = filp->private_data; @@ -247,17 +247,17 @@ start_copy: return -EIO; } - proc_len = min((int)count, - (int)(mbo->processed_length - channel->mbo_offs)); + to_copy = min((int)count, + (int)(mbo->processed_length - channel->mbo_offs)); not_copied = copy_to_user(buf, mbo->virt_address + channel->mbo_offs, - proc_len); + to_copy); - retval = not_copied ? proc_len - not_copied : proc_len; + copied = not_copied ? to_copy - not_copied : to_copy; if (count < mbo->processed_length) { - channel->mbo_offs = retval; + channel->mbo_offs = copied; channel->stacked_mbo = mbo; } else { most_put_mbo(mbo); @@ -265,7 +265,7 @@ start_copy: channel->stacked_mbo = NULL; } mutex_unlock(&channel->io_mutex); - return retval; + return copied; } static inline bool __must_check IS_ERR_OR_FALSE(int x) -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 01/28] staging: most: remove unnecessary keep_mbo variable
The MBO pointer stacked_mbo and the boolean variable keep_mbo are always changed together and therefore provide the same information. This patch removes keep_mbo and uses stacked_mbo instead. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index dc3fb25..6f70ed7 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -39,7 +39,6 @@ struct aim_channel { struct most_channel_config *cfg; unsigned int channel_id; dev_t devno; - bool keep_mbo; unsigned int mbo_offs; struct mbo *stacked_mbo; DECLARE_KFIFO_PTR(fifo, typeof(struct mbo *)); @@ -136,7 +135,7 @@ static int aim_close(struct inode *inode, struct file *filp) while (kfifo_out((struct kfifo *)&channel->fifo, &mbo, 1)) most_put_mbo(mbo); - if (channel->keep_mbo) + if (channel->stacked_mbo) most_put_mbo(channel->stacked_mbo); ret = most_stop_channel(channel->iface, channel->channel_id, &cdev_aim); atomic_dec(&channel->access_ref); @@ -227,9 +226,8 @@ aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) struct mbo *mbo; struct aim_channel *channel = filp->private_data; - if (channel->keep_mbo) { + if (channel->stacked_mbo) { mbo = channel->stacked_mbo; - channel->keep_mbo = false; goto start_copy; } while ((!kfifo_out(&channel->fifo, &mbo, 1)) && (channel->dev)) { @@ -249,9 +247,6 @@ start_copy: return -EIO; } - if (count < mbo->processed_length) - channel->keep_mbo = true; - proc_len = min((int)count, (int)(mbo->processed_length - channel->mbo_offs)); @@ -261,12 +256,13 @@ start_copy: retval = not_copied ? proc_len - not_copied : proc_len; - if (channel->keep_mbo) { + if (count < mbo->processed_length) { channel->mbo_offs = retval; channel->stacked_mbo = mbo; } else { most_put_mbo(mbo); channel->mbo_offs = 0; + channel->stacked_mbo = NULL; } mutex_unlock(&channel->io_mutex); return retval; -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 05/28] staging: most: use min_t
This patch replaces min with min_t. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index 4bf0322..6ee4eb2 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -246,7 +246,9 @@ start_copy: return -EIO; } - to_copy = min(count, (size_t)mbo->processed_length - channel->mbo_offs); + to_copy = min_t(size_t, + count, + mbo->processed_length - channel->mbo_offs); not_copied = copy_to_user(buf, mbo->virt_address + channel->mbo_offs, -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 07/28] staging: most: fix tracking of MBO offset
This patch increments mbo_offs by the number of bytes that have been copied and resets it in case a complete mbo has been transferred to user buffer. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c |5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index 86194ce..0141293 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -257,9 +257,8 @@ start_copy: copied = to_copy - not_copied; - if (count < mbo->processed_length) { - channel->mbo_offs = copied; - } else { + channel->mbo_offs += copied; + if (channel->mbo_offs >= mbo->processed_length) { most_put_mbo(mbo); channel->mbo_offs = 0; channel->stacked_mbo = NULL; -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 03/28] staging: most: simplify expression
This patch replaces the ternary ?-operator with a way simpler subtraction. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index bff891f..b293078 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -254,7 +254,7 @@ start_copy: mbo->virt_address + channel->mbo_offs, to_copy); - copied = not_copied ? to_copy - not_copied : to_copy; + copied = to_copy - not_copied; if (count < mbo->processed_length) { channel->mbo_offs = copied; -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 08/28] staging: most: use readl and writel functions
This patch makes use of functions readl and writel instead of the __raw_* variants. Signed-off-by: Christian Gromm --- drivers/staging/most/hdm-dim2/dim2_hdm.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/most/hdm-dim2/dim2_hdm.c b/drivers/staging/most/hdm-dim2/dim2_hdm.c index 327d738..48ce7ab 100644 --- a/drivers/staging/most/hdm-dim2/dim2_hdm.c +++ b/drivers/staging/most/hdm-dim2/dim2_hdm.c @@ -140,7 +140,7 @@ bool dim2_sysfs_get_state_cb(void) */ u32 dimcb_io_read(u32 *ptr32) { - return __raw_readl(ptr32); + return readl(ptr32); } /** @@ -150,7 +150,7 @@ u32 dimcb_io_read(u32 *ptr32) */ void dimcb_io_write(u32 *ptr32, u32 value) { - __raw_writel(value, ptr32); + writel(value, ptr32); } /** -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 06/28] staging: most: fix mbo leak
This patch fixes a potential MBO leak in case function aim_read() exits right after the MBO has been fetched from kfifo and before it has been saved to the variable stacked_mbo. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index 6ee4eb2..86194ce 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -237,6 +237,7 @@ aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) (!channel->dev return -ERESTARTSYS; } + channel->stacked_mbo = mbo; start_copy: /* make sure we don't submit to gone devices */ @@ -258,7 +259,6 @@ start_copy: if (count < mbo->processed_length) { channel->mbo_offs = copied; - channel->stacked_mbo = mbo; } else { most_put_mbo(mbo); channel->mbo_offs = 0; -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 09/28] staging: most: remove function destroy_most_c_obj
This patch removes the function destroy_most_c_obj and executes its code within function destroy_most_inst_obj. Signed-off-by: Christian Gromm --- drivers/staging/most/mostcore/core.c | 38 +- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index ed1ed25..8be6cdcf 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -551,29 +551,6 @@ create_most_c_obj(const char *name, struct kobject *parent) return c; } -/** - * destroy_most_c_obj - channel release function - * @c: pointer to channel object - * - * This decrements the reference counter of the channel object. - * If the reference count turns zero, its release function is called. - */ -static void destroy_most_c_obj(struct most_c_obj *c) -{ - if (c->aim0.ptr) - c->aim0.ptr->disconnect_channel(c->iface, c->channel_id); - if (c->aim1.ptr) - c->aim1.ptr->disconnect_channel(c->iface, c->channel_id); - c->aim0.ptr = NULL; - c->aim1.ptr = NULL; - - mutex_lock(&deregister_mutex); - flush_trash_fifo(c); - flush_channel_fifos(c); - mutex_unlock(&deregister_mutex); - kobject_put(&c->kobj); -} - /* ___ ___ * ___I N S T A N C E___ */ @@ -766,7 +743,20 @@ static void destroy_most_inst_obj(struct most_inst_obj *inst) * reference count of the inst->kobj */ list_for_each_entry_safe(c, tmp, &inst->channel_list, list) { - destroy_most_c_obj(c); + if (c->aim0.ptr) + c->aim0.ptr->disconnect_channel(c->iface, + c->channel_id); + if (c->aim1.ptr) + c->aim1.ptr->disconnect_channel(c->iface, + c->channel_id); + c->aim0.ptr = NULL; + c->aim1.ptr = NULL; + + mutex_lock(&deregister_mutex); + flush_trash_fifo(c); + flush_channel_fifos(c); + mutex_unlock(&deregister_mutex); + kobject_put(&c->kobj); } kobject_put(&inst->kobj); } -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 16/28] staging: most: remove reference counter
This patch removes the unnecessary reference conter mod_ref. Signed-off-by: Christian Gromm --- drivers/staging/most/mostcore/core.c | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index 58e288b..daae42d 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -35,7 +35,6 @@ static struct class *most_class; static struct device *class_glue_dir; static struct ida mdev_id; -static int modref; static int dummy_num_buffers; struct most_c_aim_obj { @@ -1508,7 +1507,6 @@ int most_start_channel(struct most_interface *iface, int id, mutex_unlock(&c->start_mutex); return -ENOLCK; } - modref++; c->cfg.extra_len = 0; if (c->iface->configure(c->iface, c->channel_id, &c->cfg)) { @@ -1550,7 +1548,6 @@ out: error: module_put(iface->mod); - modref--; mutex_unlock(&c->start_mutex); return ret; } @@ -1584,10 +1581,8 @@ int most_stop_channel(struct most_interface *iface, int id, c->hdm_enqueue_task = NULL; mutex_unlock(&c->stop_task_mutex); - if (iface->mod && modref) { + if (iface->mod) module_put(iface->mod); - modref--; - } c->is_poisoned = true; if (c->iface->poison_channel(c->iface, c->channel_id)) { @@ -1808,12 +1803,6 @@ void most_deregister_interface(struct most_interface *iface) c->aim1.ptr = NULL; } - while (modref) { - if (iface->mod && modref) - module_put(iface->mod); - modref--; - } - list_for_each_entry(c, &i->channel_list, list) { if (c->aim0.refs + c->aim1.refs <= 0) continue; -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 23/28] staging: most: fix race conditions
This patch fixes race conditions that might emerge from functions aim_open, aim_close, aim_read, aim_write and aim_disconnect_channel within module cdev. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c | 89 +- 1 file changed, 54 insertions(+), 35 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index 5065139..ade7808 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -32,6 +32,7 @@ static struct most_aim cdev_aim; struct aim_channel { wait_queue_head_t wq; + spinlock_t unlink; /* synchronization lock to unlink channels */ struct cdev cdev; struct device *dev; struct mutex io_mutex; @@ -55,6 +56,12 @@ static inline bool ch_has_mbo(struct aim_channel *c) return channel_has_mbo(c->iface, c->channel_id, &cdev_aim) > 0; } +static inline bool ch_get_mbo(struct aim_channel *c, struct mbo **mbo) +{ + *mbo = most_get_mbo(c->iface, c->channel_id, &cdev_aim); + return *mbo; +} + static struct aim_channel *get_channel(struct most_interface *iface, int id) { struct aim_channel *c, *tmp; @@ -82,6 +89,7 @@ static void stop_channel(struct aim_channel *c) most_put_mbo(mbo); if (c->stacked_mbo) most_put_mbo(c->stacked_mbo); + c->stacked_mbo = NULL; most_stop_channel(c->iface, c->channel_id, &cdev_aim); } @@ -121,16 +129,25 @@ static int aim_open(struct inode *inode, struct file *filp) pr_info("WARN: Access flags mismatch\n"); return -EACCES; } + + mutex_lock(&c->io_mutex); + if (!c->dev) { + pr_info("WARN: Device is destroyed\n"); + mutex_unlock(&c->io_mutex); + return -EBUSY; + } + if (!atomic_inc_and_test(&c->access_ref)) { pr_info("WARN: Device is busy\n"); atomic_dec(&c->access_ref); + mutex_unlock(&c->io_mutex); return -EBUSY; } - ret = most_start_channel(c->iface, c->channel_id, -&cdev_aim); + ret = most_start_channel(c->iface, c->channel_id, &cdev_aim); if (ret) atomic_dec(&c->access_ref); + mutex_unlock(&c->io_mutex); return ret; } @@ -146,17 +163,17 @@ static int aim_close(struct inode *inode, struct file *filp) struct aim_channel *c = to_channel(inode->i_cdev); mutex_lock(&c->io_mutex); - if (!c->dev) { + spin_lock(&c->unlink); + atomic_dec(&c->access_ref); + spin_unlock(&c->unlink); + if (c->dev) { + stop_channel(c); mutex_unlock(&c->io_mutex); - atomic_dec(&c->access_ref); + } else { destroy_cdev(c); + mutex_unlock(&c->io_mutex); kfree(c); - return 0; } - mutex_unlock(&c->io_mutex); - - stop_channel(c); - atomic_dec(&c->access_ref); return 0; } @@ -171,40 +188,27 @@ static ssize_t aim_write(struct file *filp, const char __user *buf, size_t count, loff_t *offset) { int ret, err; - size_t actual_len = 0; - size_t max_len = 0; + size_t actual_len; + size_t max_len; ssize_t retval; - struct mbo *mbo; + struct mbo *mbo = NULL; struct aim_channel *c = filp->private_data; mutex_lock(&c->io_mutex); - if (unlikely(!c->dev)) { + while (c->dev && !ch_get_mbo(c, &mbo)) { mutex_unlock(&c->io_mutex); - return -EPIPE; - } - mutex_unlock(&c->io_mutex); - - mbo = most_get_mbo(c->iface, c->channel_id, &cdev_aim); - if (!mbo) { if ((filp->f_flags & O_NONBLOCK)) return -EAGAIN; - if (wait_event_interruptible( - c->wq, - (mbo = most_get_mbo(c->iface, - c->channel_id, - &cdev_aim)) || - (!c->dev))) + if (wait_event_interruptible(c->wq, ch_has_mbo(c) || !c->dev)) return -ERESTARTSYS; + mutex_lock(&c->io_mutex); } - mutex_lock(&c->io_mutex); if (unlikely(!c->dev)) { - mutex_unlock(&c->io_mutex); err = -EPIPE; goto error; } - mutex_unlock(&c->io_mutex); max_len = c->cfg->buffer_size; actual_len = min(count, max_len); @@ -222,9 +226,12 @@ static ssize_t aim_write(struct file *filp, const char __user *buf, err = ret; goto error; } + mutex_unlock(&c->io_mutex); return actual_len - retval; error: - mos
[PATCH 21/28] staging: most: fix retrieval of buffer availability
This patch fixes the function channel_has_mbo that delivers the false information in case two AIMs are using the same tx channel. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c | 12 ++-- drivers/staging/most/mostcore/core.c |7 ++- drivers/staging/most/mostcore/mostcore.h |3 ++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index 533e290..c4bbf7d 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -50,6 +50,11 @@ struct aim_channel { static struct list_head channel_list; static spinlock_t ch_list_lock; +static inline bool ch_has_mbo(struct aim_channel *c) +{ + return channel_has_mbo(c->iface, c->channel_id, &cdev_aim) > 0; +} + static struct aim_channel *get_channel(struct most_interface *iface, int id) { struct aim_channel *channel, *tmp; @@ -279,11 +284,6 @@ start_copy: return copied; } -static inline bool __must_check IS_ERR_OR_FALSE(int x) -{ - return x <= 0; -} - static unsigned int aim_poll(struct file *filp, poll_table *wait) { struct aim_channel *c = filp->private_data; @@ -295,7 +295,7 @@ static unsigned int aim_poll(struct file *filp, poll_table *wait) if (!kfifo_is_empty(&c->fifo)) mask |= POLLIN | POLLRDNORM; } else { - if (!IS_ERR_OR_FALSE(channel_has_mbo(c->iface, c->channel_id))) + if (ch_has_mbo(c)) mask |= POLLOUT | POLLWRNORM; } return mask; diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index b085f0a..ff0e0dc 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -1352,7 +1352,7 @@ most_c_obj *get_channel_by_iface(struct most_interface *iface, int id) return i->channel[id]; } -int channel_has_mbo(struct most_interface *iface, int id) +int channel_has_mbo(struct most_interface *iface, int id, struct most_aim *aim) { struct most_c_obj *c = get_channel_by_iface(iface, id); unsigned long flags; @@ -1361,6 +1361,11 @@ int channel_has_mbo(struct most_interface *iface, int id) if (unlikely(!c)) return -EINVAL; + if (c->aim0.refs && c->aim1.refs && + ((aim == c->aim0.ptr && c->aim0.num_buffers <= 0) || +(aim == c->aim1.ptr && c->aim1.num_buffers <= 0))) + return false; + spin_lock_irqsave(&c->fifo_lock, flags); empty = list_empty(&c->fifo); spin_unlock_irqrestore(&c->fifo_lock, flags); diff --git a/drivers/staging/most/mostcore/mostcore.h b/drivers/staging/most/mostcore/mostcore.h index bda3850..60e018e 100644 --- a/drivers/staging/most/mostcore/mostcore.h +++ b/drivers/staging/most/mostcore/mostcore.h @@ -310,7 +310,8 @@ int most_deregister_aim(struct most_aim *aim); struct mbo *most_get_mbo(struct most_interface *iface, int channel_idx, struct most_aim *); void most_put_mbo(struct mbo *mbo); -int channel_has_mbo(struct most_interface *iface, int channel_idx); +int channel_has_mbo(struct most_interface *iface, int channel_idx, + struct most_aim *aim); int most_start_channel(struct most_interface *iface, int channel_idx, struct most_aim *); int most_stop_channel(struct most_interface *iface, int channel_idx, -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 13/28] staging: most: move mutex
This patch removes mutex from code that doesn't need any locking. Signed-off-by: Christian Gromm --- drivers/staging/most/mostcore/core.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index 21c550c..ae1b577 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -1830,15 +1830,14 @@ void most_deregister_interface(struct most_interface *iface) struct most_inst_obj *i = iface->priv; struct most_c_obj *c; - mutex_lock(&deregister_mutex); if (unlikely(!i)) { pr_info("Bad Interface\n"); - mutex_unlock(&deregister_mutex); return; } pr_info("deregistering MOST device %s (%s)\n", i->kobj.name, iface->description); + mutex_lock(&deregister_mutex); atomic_set(&i->tainted, 1); mutex_unlock(&deregister_mutex); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 15/28] staging: most: remove tainted flag
This patch removes the atomic tainted flag. It is needed to get rid of logical overhead. Signed-off-by: Christian Gromm --- drivers/staging/most/mostcore/core.c | 33 + 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index 782747a..58e288b 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -74,7 +74,6 @@ struct most_c_obj { struct most_inst_obj { int dev_id; - atomic_t tainted; struct most_interface *iface; struct list_head channel_list; struct most_c_obj *channel[MAX_CHANNELS]; @@ -1299,18 +1298,10 @@ _exit: */ int most_submit_mbo(struct mbo *mbo) { - struct most_c_obj *c; - struct most_inst_obj *i; - if (unlikely((!mbo) || (!mbo->context))) { pr_err("Bad MBO or missing channel reference\n"); return -EINVAL; } - c = mbo->context; - i = c->inst; - - if (unlikely(atomic_read(&i->tainted))) - return -ENODEV; nq_hdm_mbo(mbo); return 0; @@ -1436,17 +1427,8 @@ EXPORT_SYMBOL_GPL(most_get_mbo); */ void most_put_mbo(struct mbo *mbo) { - struct most_c_obj *c; - struct most_inst_obj *i; - - c = mbo->context; - i = c->inst; + struct most_c_obj *c = mbo->context; - if (unlikely(atomic_read(&i->tainted))) { - mbo->status = MBO_E_CLOSE; - trash_mbo(mbo); - return; - } if (c->cfg.direction == MOST_CH_TX) { arm_mbo(mbo); return; @@ -1602,14 +1584,6 @@ int most_stop_channel(struct most_interface *iface, int id, c->hdm_enqueue_task = NULL; mutex_unlock(&c->stop_task_mutex); - mutex_lock(&deregister_mutex); - if (atomic_read(&c->inst->tainted)) { - mutex_unlock(&deregister_mutex); - mutex_unlock(&c->start_mutex); - return -ENODEV; - } - mutex_unlock(&deregister_mutex); - if (iface->mod && modref) { module_put(iface->mod); modref--; @@ -1750,7 +1724,6 @@ struct kobject *most_register_interface(struct most_interface *iface) INIT_LIST_HEAD(&inst->channel_list); inst->iface = iface; inst->dev_id = id; - atomic_set(&inst->tainted, 0); list_add_tail(&inst->list, &instance_list); for (i = 0; i < iface->num_channels; i++) { @@ -1835,10 +1808,6 @@ void most_deregister_interface(struct most_interface *iface) c->aim1.ptr = NULL; } - mutex_lock(&deregister_mutex); - atomic_set(&i->tainted, 1); - mutex_unlock(&deregister_mutex); - while (modref) { if (iface->mod && modref) module_put(iface->mod); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 19/28] staging: most: remove redundant call to wake_up_interruptible
This patch prevents the cdev module from rousing the channel wait queue in case the channel is about to be closed. It is safe to do so, because the application can not be waiting within read or write and at the same time be calling close. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c |2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index 0141293..fd2ac89 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -127,7 +127,6 @@ static int aim_close(struct inode *inode, struct file *filp) kfifo_free(&channel->fifo); list_del(&channel->list); ida_simple_remove(&minor_id, MINOR(channel->devno)); - wake_up_interruptible(&channel->wq); kfree(channel); return 0; } @@ -139,7 +138,6 @@ static int aim_close(struct inode *inode, struct file *filp) most_put_mbo(channel->stacked_mbo); ret = most_stop_channel(channel->iface, channel->channel_id, &cdev_aim); atomic_dec(&channel->access_ref); - wake_up_interruptible(&channel->wq); return ret; } -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 10/28] staging: most: add missing call to ida_simple_remove
This patch adds two missing calls to function ida_simpel_remove. Signed-off-by: Christian Gromm --- drivers/staging/most/mostcore/core.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index 8be6cdcf..995987d 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -1752,6 +1752,7 @@ struct kobject *most_register_interface(struct most_interface *iface) inst = create_most_inst_obj(name); if (!inst) { pr_info("Failed to allocate interface instance\n"); + ida_simple_remove(&mdev_id, id); return ERR_PTR(-ENOMEM); } @@ -1808,6 +1809,7 @@ struct kobject *most_register_interface(struct most_interface *iface) free_instance: pr_info("Failed allocate channel(s)\n"); list_del(&inst->list); + ida_simple_remove(&mdev_id, id); destroy_most_inst_obj(inst); return ERR_PTR(-ENOMEM); } -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 17/28] staging: most: remove code to destroy channel
This patch removes unnecessary code to destroy channel objects. It is needed, because function most_stop_channel, which is indirectly triggered by function most_deregister_interface, already destroys the channels. Signed-off-by: Christian Gromm --- drivers/staging/most/mostcore/core.c | 13 - 1 file changed, 13 deletions(-) diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index daae42d..31ea3a5 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -1803,19 +1803,6 @@ void most_deregister_interface(struct most_interface *iface) c->aim1.ptr = NULL; } - list_for_each_entry(c, &i->channel_list, list) { - if (c->aim0.refs + c->aim1.refs <= 0) - continue; - - mutex_lock(&c->stop_task_mutex); - if (c->hdm_enqueue_task) - kthread_stop(c->hdm_enqueue_task); - c->hdm_enqueue_task = NULL; - mutex_unlock(&c->stop_task_mutex); - - if (iface->poison_channel(iface, c->channel_id)) - pr_err("Can't poison channel %d\n", c->channel_id); - } ida_simple_remove(&mdev_id, i->dev_id); list_del(&i->list); destroy_most_inst_obj(i); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 12/28] staging: most: move initialization of pointer
This patch makes function store_add_link initialize the pointer to an AIM right before the channel is probed. Signed-off-by: Christian Gromm --- drivers/staging/most/mostcore/core.c |7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index d5ef61d..21c550c 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -996,11 +996,14 @@ static ssize_t store_add_link(struct most_aim_obj *aim_obj, else return -ENOSPC; + *aim_ptr = aim_obj->driver; ret = aim_obj->driver->probe_channel(c->iface, c->channel_id, &c->cfg, &c->kobj, mdev_devnod); - if (ret) + if (ret) { + *aim_ptr = NULL; return ret; - *aim_ptr = aim_obj->driver; + } + return len; } -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 25/28] staging: most: remove stacked_mbo
This patch makes use of kfifo_peek and kfifo_skip, which renders the variable stacked_mbo useless. It is therefore removed. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c | 16 +++- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index d9c3f56..0ee2f08 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -41,7 +41,6 @@ struct aim_channel { unsigned int channel_id; dev_t devno; size_t mbo_offs; - struct mbo *stacked_mbo; DECLARE_KFIFO_PTR(fifo, typeof(struct mbo *)); int access_ref; struct list_head list; @@ -87,9 +86,6 @@ static void stop_channel(struct aim_channel *c) while (kfifo_out((struct kfifo *)&c->fifo, &mbo, 1)) most_put_mbo(mbo); - if (c->stacked_mbo) - most_put_mbo(c->stacked_mbo); - c->stacked_mbo = NULL; most_stop_channel(c->iface, c->channel_id, &cdev_aim); } @@ -143,6 +139,7 @@ static int aim_open(struct inode *inode, struct file *filp) return -EBUSY; } + c->mbo_offs = 0; ret = most_start_channel(c->iface, c->channel_id, &cdev_aim); if (!ret) c->access_ref = 1; @@ -249,11 +246,7 @@ aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) struct aim_channel *c = filp->private_data; mutex_lock(&c->io_mutex); - if (c->stacked_mbo) { - mbo = c->stacked_mbo; - goto start_copy; - } - while ((!kfifo_out(&c->fifo, &mbo, 1)) && (c->dev)) { + while (c->dev && !kfifo_peek(&c->fifo, &mbo)) { mutex_unlock(&c->io_mutex); if (filp->f_flags & O_NONBLOCK) return -EAGAIN; @@ -263,9 +256,7 @@ aim_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) return -ERESTARTSYS; mutex_lock(&c->io_mutex); } - c->stacked_mbo = mbo; -start_copy: /* make sure we don't submit to gone devices */ if (unlikely(!c->dev)) { mutex_unlock(&c->io_mutex); @@ -284,9 +275,9 @@ start_copy: c->mbo_offs += copied; if (c->mbo_offs >= mbo->processed_length) { + kfifo_skip(&c->fifo); most_put_mbo(mbo); c->mbo_offs = 0; - c->stacked_mbo = NULL; } mutex_unlock(&c->io_mutex); return copied; @@ -466,7 +457,6 @@ static int aim_probe(struct most_interface *iface, int channel_id, c->iface = iface; c->cfg = cfg; c->channel_id = channel_id; - c->mbo_offs = 0; c->access_ref = 0; spin_lock_init(&c->unlink); INIT_KFIFO(c->fifo); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 14/28] staging: most: move channel disconnect to function most_deregister_interface
This patch moves the code that disconnects linked channels. It is needed to have cleaning things up done right. Signed-off-by: Christian Gromm --- drivers/staging/most/mostcore/core.c | 24 +++- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index ae1b577..782747a 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -738,20 +738,7 @@ static void destroy_most_inst_obj(struct most_inst_obj *inst) { struct most_c_obj *c, *tmp; - /* need to destroy channels first, since -* each channel incremented the -* reference count of the inst->kobj -*/ list_for_each_entry_safe(c, tmp, &inst->channel_list, list) { - if (c->aim0.ptr) - c->aim0.ptr->disconnect_channel(c->iface, - c->channel_id); - if (c->aim1.ptr) - c->aim1.ptr->disconnect_channel(c->iface, - c->channel_id); - c->aim0.ptr = NULL; - c->aim1.ptr = NULL; - mutex_lock(&deregister_mutex); flush_trash_fifo(c); flush_channel_fifos(c); @@ -1837,6 +1824,17 @@ void most_deregister_interface(struct most_interface *iface) pr_info("deregistering MOST device %s (%s)\n", i->kobj.name, iface->description); + list_for_each_entry(c, &i->channel_list, list) { + if (c->aim0.ptr) + c->aim0.ptr->disconnect_channel(c->iface, + c->channel_id); + if (c->aim1.ptr) + c->aim1.ptr->disconnect_channel(c->iface, + c->channel_id); + c->aim0.ptr = NULL; + c->aim1.ptr = NULL; + } + mutex_lock(&deregister_mutex); atomic_set(&i->tainted, 1); mutex_unlock(&deregister_mutex); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 22/28] staging: most: rename variable channel
This patch renames the variable 'channel' to 'c'. This is needed to have the code look more homogeneous and to prevent format violations. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c | 216 +- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index c4bbf7d..5065139 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -57,13 +57,13 @@ static inline bool ch_has_mbo(struct aim_channel *c) static struct aim_channel *get_channel(struct most_interface *iface, int id) { - struct aim_channel *channel, *tmp; + struct aim_channel *c, *tmp; unsigned long flags; int found_channel = 0; spin_lock_irqsave(&ch_list_lock, flags); - list_for_each_entry_safe(channel, tmp, &channel_list, list) { - if ((channel->iface == iface) && (channel->channel_id == id)) { + list_for_each_entry_safe(c, tmp, &channel_list, list) { + if ((c->iface == iface) && (c->channel_id == id)) { found_channel = 1; break; } @@ -71,7 +71,7 @@ static struct aim_channel *get_channel(struct most_interface *iface, int id) spin_unlock_irqrestore(&ch_list_lock, flags); if (!found_channel) return NULL; - return channel; + return c; } static void stop_channel(struct aim_channel *c) @@ -108,29 +108,29 @@ static void destroy_cdev(struct aim_channel *c) */ static int aim_open(struct inode *inode, struct file *filp) { - struct aim_channel *channel; + struct aim_channel *c; int ret; - channel = to_channel(inode->i_cdev); - filp->private_data = channel; + c = to_channel(inode->i_cdev); + filp->private_data = c; - if (((channel->cfg->direction == MOST_CH_RX) && + if (((c->cfg->direction == MOST_CH_RX) && ((filp->f_flags & O_ACCMODE) != O_RDONLY)) || -((channel->cfg->direction == MOST_CH_TX) && +((c->cfg->direction == MOST_CH_TX) && ((filp->f_flags & O_ACCMODE) != O_WRONLY))) { pr_info("WARN: Access flags mismatch\n"); return -EACCES; } - if (!atomic_inc_and_test(&channel->access_ref)) { + if (!atomic_inc_and_test(&c->access_ref)) { pr_info("WARN: Device is busy\n"); - atomic_dec(&channel->access_ref); + atomic_dec(&c->access_ref); return -EBUSY; } - ret = most_start_channel(channel->iface, channel->channel_id, + ret = most_start_channel(c->iface, c->channel_id, &cdev_aim); if (ret) - atomic_dec(&channel->access_ref); + atomic_dec(&c->access_ref); return ret; } @@ -143,20 +143,20 @@ static int aim_open(struct inode *inode, struct file *filp) */ static int aim_close(struct inode *inode, struct file *filp) { - struct aim_channel *channel = to_channel(inode->i_cdev); - - mutex_lock(&channel->io_mutex); - if (!channel->dev) { - mutex_unlock(&channel->io_mutex); - atomic_dec(&channel->access_ref); - destroy_cdev(channel); - kfree(channel); + struct aim_channel *c = to_channel(inode->i_cdev); + + mutex_lock(&c->io_mutex); + if (!c->dev) { + mutex_unlock(&c->io_mutex); + atomic_dec(&c->access_ref); + destroy_cdev(c); + kfree(c); return 0; } - mutex_unlock(&channel->io_mutex); + mutex_unlock(&c->io_mutex); - stop_channel(channel); - atomic_dec(&channel->access_ref); + stop_channel(c); + atomic_dec(&c->access_ref); return 0; } @@ -175,38 +175,38 @@ static ssize_t aim_write(struct file *filp, const char __user *buf, size_t max_len = 0; ssize_t retval; struct mbo *mbo; - struct aim_channel *channel = filp->private_data; + struct aim_channel *c = filp->private_data; - mutex_lock(&channel->io_mutex); - if (unlikely(!channel->dev)) { - mutex_unlock(&channel->io_mutex); + mutex_lock(&c->io_mutex); + if (unlikely(!c->dev)) { + mutex_unlock(&c->io_mutex); return -EPIPE; } - mutex_unlock(&channel->io_mutex); + mutex_unlock(&c->io_mutex); - mbo = most_get_mbo(channel->iface, channel->channel_id, &cdev_aim); + mbo = most_get_mbo(c->iface, c->channel_id, &cdev_aim); if (!mbo) { if ((filp->f_flags & O_NONBLOCK)) return -EAGAIN; if (wait_event_interruptible( - channel->wq, - (mbo = most_get_mbo(channel->i
[PATCH 11/28] staging: most: move call to disconnect_channel callback
This patch invokes AIM's disconnect_channel callback before the corresponding pointers are re-initialized to NULL. Signed-off-by: Christian Gromm --- drivers/staging/most/mostcore/core.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index 995987d..d5ef61d 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -1046,12 +1046,12 @@ static ssize_t store_remove_link(struct most_aim_obj *aim_obj, if (IS_ERR(c)) return -ENODEV; + if (aim_obj->driver->disconnect_channel(c->iface, c->channel_id)) + return -EIO; if (c->aim0.ptr == aim_obj->driver) c->aim0.ptr = NULL; if (c->aim1.ptr == aim_obj->driver) c->aim1.ptr = NULL; - if (aim_obj->driver->disconnect_channel(c->iface, c->channel_id)) - return -EIO; return len; } -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 24/28] staging: most: change type of access_ref
This patch changes the type of the access reference from atomit_t to int. It is needed, because the reference variable is secured by synchronization locks and does not need to be atomic anymore. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index ade7808..d9c3f56 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -43,7 +43,7 @@ struct aim_channel { size_t mbo_offs; struct mbo *stacked_mbo; DECLARE_KFIFO_PTR(fifo, typeof(struct mbo *)); - atomic_t access_ref; + int access_ref; struct list_head list; }; @@ -137,16 +137,15 @@ static int aim_open(struct inode *inode, struct file *filp) return -EBUSY; } - if (!atomic_inc_and_test(&c->access_ref)) { + if (c->access_ref) { pr_info("WARN: Device is busy\n"); - atomic_dec(&c->access_ref); mutex_unlock(&c->io_mutex); return -EBUSY; } ret = most_start_channel(c->iface, c->channel_id, &cdev_aim); - if (ret) - atomic_dec(&c->access_ref); + if (!ret) + c->access_ref = 1; mutex_unlock(&c->io_mutex); return ret; } @@ -164,7 +163,7 @@ static int aim_close(struct inode *inode, struct file *filp) mutex_lock(&c->io_mutex); spin_lock(&c->unlink); - atomic_dec(&c->access_ref); + c->access_ref = 0; spin_unlock(&c->unlink); if (c->dev) { stop_channel(c); @@ -347,7 +346,7 @@ static int aim_disconnect_channel(struct most_interface *iface, int channel_id) spin_lock(&c->unlink); c->dev = NULL; spin_unlock(&c->unlink); - if (!atomic_read(&c->access_ref)) { + if (c->access_ref) { stop_channel(c); wake_up_interruptible(&c->wq); mutex_unlock(&c->io_mutex); @@ -378,7 +377,7 @@ static int aim_rx_completion(struct mbo *mbo) return -ENXIO; spin_lock(&c->unlink); - if (atomic_read(&c->access_ref) || !c->dev) { + if (!c->access_ref || !c->dev) { spin_unlock(&c->unlink); return -EFAULT; } @@ -468,7 +467,7 @@ static int aim_probe(struct most_interface *iface, int channel_id, c->cfg = cfg; c->channel_id = channel_id; c->mbo_offs = 0; - atomic_set(&c->access_ref, -1); + c->access_ref = 0; spin_lock_init(&c->unlink); INIT_KFIFO(c->fifo); retval = kfifo_alloc(&c->fifo, cfg->num_buffers, GFP_KERNEL); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 27/28] staging: most: add statistics for dropped packets
This patch adds a counter for dropped packets. It needed for statistical analysis. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-network/networking.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/most/aim-network/networking.c b/drivers/staging/most/aim-network/networking.c index 3c7beb0..a1fc8b3 100644 --- a/drivers/staging/most/aim-network/networking.c +++ b/drivers/staging/most/aim-network/networking.c @@ -431,6 +431,7 @@ static int aim_rx_data(struct mbo *mbo) u32 len = mbo->processed_length; struct sk_buff *skb; struct net_device *dev; + typeof(skb->len) skb_len; nd = get_net_dev_context(mbo->ifp); if (!nd || !nd->channels_opened || nd->rx.ch_id != mbo->hdm_channel_id) @@ -482,9 +483,13 @@ static int aim_rx_data(struct mbo *mbo) memcpy(skb_put(skb, len), buf, len); skb->protocol = eth_type_trans(skb, dev); - dev->stats.rx_packets++; - dev->stats.rx_bytes += skb->len; - netif_rx(skb); + skb_len = skb->len; + if (netif_rx(skb) == NET_RX_SUCCESS) { + dev->stats.rx_packets++; + dev->stats.rx_bytes += skb_len; + } else { + dev->stats.rx_dropped++; + } out: most_put_mbo(mbo); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 28/28] staging: most: remove 2nd forward declaration of struct most_aim
This patch removes the second forwared declaration of struct most_aim. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c |2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index e5ceb82..e9943c3 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -399,8 +399,6 @@ static int aim_tx_completion(struct most_interface *iface, int channel_id) return 0; } -static struct most_aim cdev_aim; - /** * aim_probe - probe function of the driver module * @iface: pointer to interface instance -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 26/28] staging: most: rearrange function aim_write
This patch rearranges the code of function aim_write() of module aim-cdev. It is needed to remove the error lable and make the code straighter. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c | 22 ++ 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index 0ee2f08..e5ceb82 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -183,7 +183,6 @@ static int aim_close(struct inode *inode, struct file *filp) static ssize_t aim_write(struct file *filp, const char __user *buf, size_t count, loff_t *offset) { - int ret, err; size_t actual_len; size_t max_len; ssize_t retval; @@ -202,8 +201,8 @@ static ssize_t aim_write(struct file *filp, const char __user *buf, } if (unlikely(!c->dev)) { - err = -EPIPE; - goto error; + mutex_unlock(&c->io_mutex); + return -EPIPE; } max_len = c->cfg->buffer_size; @@ -212,23 +211,14 @@ static ssize_t aim_write(struct file *filp, const char __user *buf, retval = copy_from_user(mbo->virt_address, buf, mbo->buffer_length); if (retval) { - err = -EIO; - goto error; + most_put_mbo(mbo); + mutex_unlock(&c->io_mutex); + return -EIO; } - ret = most_submit_mbo(mbo); - if (ret) { - pr_info("submitting MBO to core failed\n"); - err = ret; - goto error; - } + most_submit_mbo(mbo); mutex_unlock(&c->io_mutex); return actual_len - retval; -error: - if (mbo) - most_put_mbo(mbo); - mutex_unlock(&c->io_mutex); - return err; } /** -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 20/28] staging: most: encapsulate shared code
This patch encapsulates shared code. It therefore creates the new functions stop_channel and destroy_cdev. Signed-off-by: Christian Gromm --- drivers/staging/most/aim-cdev/cdev.c | 55 ++ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c index fd2ac89..533e290 100644 --- a/drivers/staging/most/aim-cdev/cdev.c +++ b/drivers/staging/most/aim-cdev/cdev.c @@ -69,6 +69,30 @@ static struct aim_channel *get_channel(struct most_interface *iface, int id) return channel; } +static void stop_channel(struct aim_channel *c) +{ + struct mbo *mbo; + + while (kfifo_out((struct kfifo *)&c->fifo, &mbo, 1)) + most_put_mbo(mbo); + if (c->stacked_mbo) + most_put_mbo(c->stacked_mbo); + most_stop_channel(c->iface, c->channel_id, &cdev_aim); +} + +static void destroy_cdev(struct aim_channel *c) +{ + unsigned long flags; + + device_destroy(aim_class, c->devno); + cdev_del(&c->cdev); + kfifo_free(&c->fifo); + spin_lock_irqsave(&ch_list_lock, flags); + list_del(&c->list); + spin_unlock_irqrestore(&ch_list_lock, flags); + ida_simple_remove(&minor_id, MINOR(c->devno)); +} + /** * aim_open - implements the syscall to open the device * @inode: inode pointer @@ -114,31 +138,21 @@ static int aim_open(struct inode *inode, struct file *filp) */ static int aim_close(struct inode *inode, struct file *filp) { - int ret; - struct mbo *mbo; struct aim_channel *channel = to_channel(inode->i_cdev); mutex_lock(&channel->io_mutex); if (!channel->dev) { mutex_unlock(&channel->io_mutex); atomic_dec(&channel->access_ref); - device_destroy(aim_class, channel->devno); - cdev_del(&channel->cdev); - kfifo_free(&channel->fifo); - list_del(&channel->list); - ida_simple_remove(&minor_id, MINOR(channel->devno)); + destroy_cdev(channel); kfree(channel); return 0; } mutex_unlock(&channel->io_mutex); - while (kfifo_out((struct kfifo *)&channel->fifo, &mbo, 1)) - most_put_mbo(mbo); - if (channel->stacked_mbo) - most_put_mbo(channel->stacked_mbo); - ret = most_stop_channel(channel->iface, channel->channel_id, &cdev_aim); + stop_channel(channel); atomic_dec(&channel->access_ref); - return ret; + return 0; } /** @@ -310,7 +324,6 @@ static const struct file_operations channel_fops = { static int aim_disconnect_channel(struct most_interface *iface, int channel_id) { struct aim_channel *channel; - unsigned long flags; if (!iface) { pr_info("Bad interface pointer\n"); @@ -326,13 +339,7 @@ static int aim_disconnect_channel(struct most_interface *iface, int channel_id) mutex_unlock(&channel->io_mutex); if (atomic_read(&channel->access_ref)) { - device_destroy(aim_class, channel->devno); - cdev_del(&channel->cdev); - kfifo_free(&channel->fifo); - ida_simple_remove(&minor_id, MINOR(channel->devno)); - spin_lock_irqsave(&ch_list_lock, flags); - list_del(&channel->list); - spin_unlock_irqrestore(&ch_list_lock, flags); + destroy_cdev(channel); kfree(channel); } else { wake_up_interruptible(&channel->wq); @@ -526,11 +533,7 @@ static void __exit mod_exit(void) most_deregister_aim(&cdev_aim); list_for_each_entry_safe(channel, tmp, &channel_list, list) { - device_destroy(aim_class, channel->devno); - cdev_del(&channel->cdev); - kfifo_free(&channel->fifo); - list_del(&channel->list); - ida_simple_remove(&minor_id, MINOR(channel->devno)); + destroy_cdev(channel); kfree(channel); } class_destroy(aim_class); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 18/28] staging: most: remove redundant mutexes
This patch removes the mutexes stop_task_mutex and deregister mutex, since they can safely be left out. Signed-off-by: Christian Gromm --- drivers/staging/most/mostcore/core.c |9 - 1 file changed, 9 deletions(-) diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c index 31ea3a5..b085f0a 100644 --- a/drivers/staging/most/mostcore/core.c +++ b/drivers/staging/most/mostcore/core.c @@ -65,7 +65,6 @@ struct most_c_obj { struct most_c_aim_obj aim1; struct list_head trash_fifo; struct task_struct *hdm_enqueue_task; - struct mutex stop_task_mutex; wait_queue_head_t hdm_fifo_wq; }; @@ -93,8 +92,6 @@ struct most_inst_obj { _mbo; \ }) -static struct mutex deregister_mutex; - /* ___ ___ * ___C H A N N E L___ */ @@ -737,10 +734,8 @@ static void destroy_most_inst_obj(struct most_inst_obj *inst) struct most_c_obj *c, *tmp; list_for_each_entry_safe(c, tmp, &inst->channel_list, list) { - mutex_lock(&deregister_mutex); flush_trash_fifo(c); flush_channel_fifos(c); - mutex_unlock(&deregister_mutex); kobject_put(&c->kobj); } kobject_put(&inst->kobj); @@ -1575,11 +1570,9 @@ int most_stop_channel(struct most_interface *iface, int id, if (c->aim0.refs + c->aim1.refs >= 2) goto out; - mutex_lock(&c->stop_task_mutex); if (c->hdm_enqueue_task) kthread_stop(c->hdm_enqueue_task); c->hdm_enqueue_task = NULL; - mutex_unlock(&c->stop_task_mutex); if (iface->mod) module_put(iface->mod); @@ -1757,7 +1750,6 @@ struct kobject *most_register_interface(struct most_interface *iface) init_completion(&c->cleanup); atomic_set(&c->mbo_ref, 0); mutex_init(&c->start_mutex); - mutex_init(&c->stop_task_mutex); list_add_tail(&c->list, &inst->channel_list); } pr_info("registered new MOST device mdev%d (%s)\n", @@ -1853,7 +1845,6 @@ static int __init most_init(void) pr_info("init()\n"); INIT_LIST_HEAD(&instance_list); INIT_LIST_HEAD(&aim_list); - mutex_init(&deregister_mutex); ida_init(&mdev_id); if (bus_register(&most_bus)) { -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 12/28] staging: most: move initialization of pointer
On Wed, Nov 18, 2015 at 01:43:36PM +0100, Christian Gromm wrote: > This patch makes function store_add_link initialize the pointer to an AIM > right before the channel is probed. > The patch description implies that this is a cleanup but looking at the patch it looks like a behavior change. Actually for quite a few of these it definitely is a bugfix but it's not clear what the bug would look like to the user. Please always be explicit. For example, calculating the offset badly seems like it might have security implications. Don't be ambiguous if that's the case. regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 27/28] staging: most: add statistics for dropped packets
On Wed, Nov 18, 2015 at 01:43:51PM +0100, Christian Gromm wrote: > This patch adds a counter for dropped packets. It needed for statistical > analysis. > > Signed-off-by: Christian Gromm > --- > drivers/staging/most/aim-network/networking.c | 11 --- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/most/aim-network/networking.c > b/drivers/staging/most/aim-network/networking.c > index 3c7beb0..a1fc8b3 100644 > --- a/drivers/staging/most/aim-network/networking.c > +++ b/drivers/staging/most/aim-network/networking.c > @@ -431,6 +431,7 @@ static int aim_rx_data(struct mbo *mbo) > u32 len = mbo->processed_length; > struct sk_buff *skb; > struct net_device *dev; > + typeof(skb->len) skb_len; Heh. Use unsigned int. regards, dan carpenter ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/4] Drivers: hv: utils: fix memory leak on on_msg() failure
inmsg should be freed in case of on_msg() failure to avoid memory leak. Preserve the error code from on_msg(). Signed-off-by: Vitaly Kuznetsov --- Changes since v1: - Preserve the error code from on_msg(). [Dan Carpenter] --- drivers/hv/hv_utils_transport.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c index 24b2766..40abe44 100644 --- a/drivers/hv/hv_utils_transport.c +++ b/drivers/hv/hv_utils_transport.c @@ -77,6 +77,7 @@ static ssize_t hvt_op_write(struct file *file, const char __user *buf, { struct hvutil_transport *hvt; u8 *inmsg; + int ret; hvt = container_of(file->f_op, struct hvutil_transport, fops); @@ -84,11 +85,11 @@ static ssize_t hvt_op_write(struct file *file, const char __user *buf, if (IS_ERR(inmsg)) return PTR_ERR(inmsg); - if (hvt->on_msg(inmsg, count)) - return -EFAULT; + ret = hvt->on_msg(inmsg, count); + kfree(inmsg); - return count; + return ret ? ret : count; } static unsigned int hvt_op_poll(struct file *file, poll_table *wait) -- 2.4.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/4] Drivers: hv: utils: rename outmsg_lock
As a preparation to reusing outmsg_lock to protect test-and-set openrations on 'mode' rename it the more general 'lock'. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_utils_transport.c | 14 +++--- drivers/hv/hv_utils_transport.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c index 40abe44..59c6f3d 100644 --- a/drivers/hv/hv_utils_transport.c +++ b/drivers/hv/hv_utils_transport.c @@ -27,11 +27,11 @@ static struct list_head hvt_list = LIST_HEAD_INIT(hvt_list); static void hvt_reset(struct hvutil_transport *hvt) { - mutex_lock(&hvt->outmsg_lock); + mutex_lock(&hvt->lock); kfree(hvt->outmsg); hvt->outmsg = NULL; hvt->outmsg_len = 0; - mutex_unlock(&hvt->outmsg_lock); + mutex_unlock(&hvt->lock); if (hvt->on_reset) hvt->on_reset(); } @@ -47,7 +47,7 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf, if (wait_event_interruptible(hvt->outmsg_q, hvt->outmsg_len > 0)) return -EINTR; - mutex_lock(&hvt->outmsg_lock); + mutex_lock(&hvt->lock); if (!hvt->outmsg) { ret = -EAGAIN; goto out_unlock; @@ -68,7 +68,7 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf, hvt->outmsg_len = 0; out_unlock: - mutex_unlock(&hvt->outmsg_lock); + mutex_unlock(&hvt->lock); return ret; } @@ -197,7 +197,7 @@ int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len) return ret; } /* HVUTIL_TRANSPORT_CHARDEV */ - mutex_lock(&hvt->outmsg_lock); + mutex_lock(&hvt->lock); if (hvt->outmsg) { /* Previous message wasn't received */ ret = -EFAULT; @@ -211,7 +211,7 @@ int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len) } else ret = -ENOMEM; out_unlock: - mutex_unlock(&hvt->outmsg_lock); + mutex_unlock(&hvt->lock); return ret; } @@ -242,7 +242,7 @@ struct hvutil_transport *hvutil_transport_init(const char *name, hvt->mdev.fops = &hvt->fops; init_waitqueue_head(&hvt->outmsg_q); - mutex_init(&hvt->outmsg_lock); + mutex_init(&hvt->lock); spin_lock(&hvt_list_lock); list_add(&hvt->list, &hvt_list); diff --git a/drivers/hv/hv_utils_transport.h b/drivers/hv/hv_utils_transport.h index 314c76c..bff4c92 100644 --- a/drivers/hv/hv_utils_transport.h +++ b/drivers/hv/hv_utils_transport.h @@ -38,7 +38,7 @@ struct hvutil_transport { u8 *outmsg; /* message to the userspace */ int outmsg_len; /* its length */ wait_queue_head_t outmsg_q; /* poll/read wait queue */ - struct mutex outmsg_lock; /* protects outmsg */ + struct mutex lock; /* protects struct members */ }; struct hvutil_transport *hvutil_transport_init(const char *name, -- 2.4.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 4/4] Drivers: hv: utils: fix crash when device is removed from host side
The crash is observed when a service is being disabled host side while userspace daemon is connected to the device: [ 90.244859] general protection fault: [#1] SMP ... [ 90.800082] Call Trace: [ 90.800082] [] __fput+0xc8/0x1f0 [ 90.800082] [] fput+0xe/0x10 ... [ 90.800082] [] do_signal+0x28/0x580 [ 90.800082] [] ? finish_task_switch+0xa6/0x180 [ 90.800082] [] ? __schedule+0x28f/0x870 [ 90.800082] [] ? hvt_op_read+0x12a/0x140 [hv_utils] ... The problem is that hvutil_transport_destroy() which does misc_deregister() freeing the appropriate device is reachable by two paths: module unload and from util_remove(). While module unload path is protected by .owner in struct file_operations util_remove() path is not. Freeing the device while someone holds an open fd for it is a show stopper. In general, it is not possible to revoke an fd from all users so the only way to solve the issue is to defer freeing the hvutil_transport structure. Signed-off-by: Vitaly Kuznetsov --- drivers/hv/hv_utils_transport.c | 26 +++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c index 31c2f86..ee20b50 100644 --- a/drivers/hv/hv_utils_transport.c +++ b/drivers/hv/hv_utils_transport.c @@ -155,13 +155,22 @@ static int hvt_op_open(struct inode *inode, struct file *file) return ret; } +static void hvt_transport_free(struct hvutil_transport *hvt) +{ + misc_deregister(&hvt->mdev); + kfree(hvt->outmsg); + kfree(hvt); +} + static int hvt_op_release(struct inode *inode, struct file *file) { struct hvutil_transport *hvt; + int mode_old; hvt = container_of(file->f_op, struct hvutil_transport, fops); mutex_lock(&hvt->lock); + mode_old = hvt->mode; if (hvt->mode != HVUTIL_TRANSPORT_DESTROY) hvt->mode = HVUTIL_TRANSPORT_INIT; /* @@ -171,6 +180,9 @@ static int hvt_op_release(struct inode *inode, struct file *file) hvt_reset(hvt); mutex_unlock(&hvt->lock); + if (mode_old == HVUTIL_TRANSPORT_DESTROY) + hvt_transport_free(hvt); + return 0; } @@ -304,17 +316,25 @@ err_free_hvt: void hvutil_transport_destroy(struct hvutil_transport *hvt) { + int mode_old; + mutex_lock(&hvt->lock); + mode_old = hvt->mode; hvt->mode = HVUTIL_TRANSPORT_DESTROY; wake_up_interruptible(&hvt->outmsg_q); mutex_unlock(&hvt->lock); + /* +* In case we were in 'chardev' mode we still have an open fd so we +* have to defer freeing the device. Netlink interface can be freed +* now. +*/ spin_lock(&hvt_list_lock); list_del(&hvt->list); spin_unlock(&hvt_list_lock); if (hvt->cn_id.idx > 0 && hvt->cn_id.val > 0) cn_del_callback(&hvt->cn_id); - misc_deregister(&hvt->mdev); - kfree(hvt->outmsg); - kfree(hvt); + + if (mode_old != HVUTIL_TRANSPORT_CHARDEV) + hvt_transport_free(hvt); } -- 2.4.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 3/4] Drivers: hv: utils: introduce HVUTIL_TRANSPORT_DESTROY mode
When Hyper-V host asks us to remove some util driver by closing the appropriate channel there is no easy way to force the current file descriptor holder to hang up but we can start to respond -EBADF to all operations asking it to exit gracefully. As we're setting hvt->mode from two separate contexts now we need to use a proper locking. Signed-off-by: Vitaly Kuznetsov --- Changes since v1: - Don't re-introduce memory leak in hvt_op_write() [Dan Carpenter] --- drivers/hv/hv_utils_transport.c | 71 - drivers/hv/hv_utils_transport.h | 1 + 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c index 59c6f3d..31c2f86 100644 --- a/drivers/hv/hv_utils_transport.c +++ b/drivers/hv/hv_utils_transport.c @@ -27,11 +27,9 @@ static struct list_head hvt_list = LIST_HEAD_INIT(hvt_list); static void hvt_reset(struct hvutil_transport *hvt) { - mutex_lock(&hvt->lock); kfree(hvt->outmsg); hvt->outmsg = NULL; hvt->outmsg_len = 0; - mutex_unlock(&hvt->lock); if (hvt->on_reset) hvt->on_reset(); } @@ -44,10 +42,17 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf, hvt = container_of(file->f_op, struct hvutil_transport, fops); - if (wait_event_interruptible(hvt->outmsg_q, hvt->outmsg_len > 0)) + if (wait_event_interruptible(hvt->outmsg_q, hvt->outmsg_len > 0 || +hvt->mode != HVUTIL_TRANSPORT_CHARDEV)) return -EINTR; mutex_lock(&hvt->lock); + + if (hvt->mode == HVUTIL_TRANSPORT_DESTROY) { + ret = -EBADF; + goto out_unlock; + } + if (!hvt->outmsg) { ret = -EAGAIN; goto out_unlock; @@ -85,7 +90,10 @@ static ssize_t hvt_op_write(struct file *file, const char __user *buf, if (IS_ERR(inmsg)) return PTR_ERR(inmsg); - ret = hvt->on_msg(inmsg, count); + if (hvt->mode == HVUTIL_TRANSPORT_DESTROY) + ret = -EBADF; + else + ret = hvt->on_msg(inmsg, count); kfree(inmsg); @@ -99,6 +107,10 @@ static unsigned int hvt_op_poll(struct file *file, poll_table *wait) hvt = container_of(file->f_op, struct hvutil_transport, fops); poll_wait(file, &hvt->outmsg_q, wait); + + if (hvt->mode == HVUTIL_TRANSPORT_DESTROY) + return -EBADF; + if (hvt->outmsg_len > 0) return POLLIN | POLLRDNORM; @@ -108,26 +120,39 @@ static unsigned int hvt_op_poll(struct file *file, poll_table *wait) static int hvt_op_open(struct inode *inode, struct file *file) { struct hvutil_transport *hvt; + int ret = 0; + bool issue_reset = false; hvt = container_of(file->f_op, struct hvutil_transport, fops); - /* -* Switching to CHARDEV mode. We switch bach to INIT when device -* gets released. -*/ - if (hvt->mode == HVUTIL_TRANSPORT_INIT) + mutex_lock(&hvt->lock); + + if (hvt->mode == HVUTIL_TRANSPORT_DESTROY) { + ret = -EBADF; + } else if (hvt->mode == HVUTIL_TRANSPORT_INIT) { + /* +* Switching to CHARDEV mode. We switch bach to INIT when +* device gets released. +*/ hvt->mode = HVUTIL_TRANSPORT_CHARDEV; + } else if (hvt->mode == HVUTIL_TRANSPORT_NETLINK) { /* * We're switching from netlink communication to using char * device. Issue the reset first. */ - hvt_reset(hvt); + issue_reset = true; hvt->mode = HVUTIL_TRANSPORT_CHARDEV; - } else - return -EBUSY; + } else { + ret = -EBUSY; + } - return 0; + if (issue_reset) + hvt_reset(hvt); + + mutex_unlock(&hvt->lock); + + return ret; } static int hvt_op_release(struct inode *inode, struct file *file) @@ -136,12 +161,15 @@ static int hvt_op_release(struct inode *inode, struct file *file) hvt = container_of(file->f_op, struct hvutil_transport, fops); - hvt->mode = HVUTIL_TRANSPORT_INIT; + mutex_lock(&hvt->lock); + if (hvt->mode != HVUTIL_TRANSPORT_DESTROY) + hvt->mode = HVUTIL_TRANSPORT_INIT; /* * Cleanup message buffers to avoid spurious messages when the daemon * connects back. */ hvt_reset(hvt); + mutex_unlock(&hvt->lock); return 0; } @@ -168,6 +196,7 @@ static void hvt_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) * Switching to NETLINK mode. Switching to CHARDEV happens when someone * opens the device. */ + mutex_lock(&hvt->lock); if (hvt->mode == HVUTIL_TRANSPORT_INIT)
[PATCH v2 0/4] Drivers: hv: utils: prevent crash when a utility driver is disabled host side
Changes since v1: - Don't re-introduce memory leak in hvt_op_write(), preserve the error code from on_msg() [Dan Carpenter] Original description: I'm observing a crash when a utility driver is disabled host side (e.g. 'Guest services' is disabled live) when we have userspace daemon connected: [ 90.244859] general protection fault: [#1] SMP ... [ 90.800082] CPU: 3 PID: 473 Comm: hypervfcopyd Not tainted 4.3.0-rc7_netvsc_noalloc+ #1053 ... [ 90.800082] Call Trace: [ 90.800082] [] __fput+0xc8/0x1f0 [ 90.800082] [] fput+0xe/0x10 [ 90.800082] [] task_work_run+0x73/0x90 [ 90.800082] [] do_exit+0x335/0xa90 [ 90.800082] [] do_group_exit+0x3f/0xc0 [ 90.800082] [] get_signal+0x25e/0x5e0 [ 90.800082] [] do_signal+0x28/0x580 [ 90.800082] [] ? finish_task_switch+0xa6/0x180 [ 90.800082] [] ? __schedule+0x28f/0x870 [ 90.800082] [] ? hvt_op_read+0x12a/0x140 [hv_utils] [ 90.800082] [] ? wake_atomic_t_function+0x70/0x70 ... [ 90.800082] RIP [] module_put+0x16/0x90 [ 90.800082] RSP [ 95.734261] ---[ end trace 0e09af6a6294a668 ]--- The problem is that hvutil_transport_destroy() which does misc_deregister() freeing the appropriate device is reachable by two paths: module unload and from util_remove(). While module unload path is protected by .owner in struct file_operations util_remove() path is not. Freeing the device while someone holds an open fd for it is a show stopper. In general, it is not possible to revoke an fd from all users so the only way to solve the issue is to defer freeing the hvutil_transport structure asking the daemon to exit gracefully by responding -EBADF to all operations on unload. Patch 1 fixes an unrelated issue I spotted, patch 2 renames outmsg_lock to 'lock' as we're gonna use it to protect test-and-set operations on 'mode', patch 3 introduces HVUTIL_TRANSPORT_DESTROY mode of operation, patch 4 fixes the issue itself. Patches are rebased on previously sent Olaf's fixes. Vitaly Kuznetsov (4): Drivers: hv: utils: fix memory leak on on_msg() failure Drivers: hv: utils: rename outmsg_lock Drivers: hv: utils: introduce HVUTIL_TRANSPORT_DESTROY mode Drivers: hv: utils: fix crash when device is removed from host side drivers/hv/hv_utils_transport.c | 112 +++- drivers/hv/hv_utils_transport.h | 3 +- 2 files changed, 89 insertions(+), 26 deletions(-) -- 2.4.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] comedi: pcmmio: Fix coding style - use BIT macro
On 14/11/15 13:24, Ranjith Thangavel wrote: BIT macro is used for defining BIT location instead of shifting operator - coding style issue Signed-off-by: Ranjith Thangavel --- drivers/staging/comedi/drivers/pcmmio.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index f7ec224..f2aedc21 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -84,20 +84,20 @@ #define PCMMIO_AI_LSB_REG 0x00 #define PCMMIO_AI_MSB_REG 0x01 #define PCMMIO_AI_CMD_REG 0x02 -#define PCMMIO_AI_CMD_SE BIT(7) +#define PCMMIO_AI_CMD_SE BIT(7) #define PCMMIO_AI_CMD_ODD_CHANBIT(6) #define PCMMIO_AI_CMD_CHAN_SEL(x) (((x) & 0x3) << 4) #define PCMMIO_AI_CMD_RANGE(x)(((x) & 0x3) << 2) -#define PCMMIO_RESOURCE_REG0x02 +#define PCMMIO_RESOURCE_REG0x02 #define PCMMIO_RESOURCE_IRQ(x)(((x) & 0xf) << 0) #define PCMMIO_AI_STATUS_REG 0x03 #define PCMMIO_AI_STATUS_DATA_READY BIT(7) -#define PCMMIO_AI_STATUS_DATA_DMA_PEND BIT(6) -#define PCMMIO_AI_STATUS_CMD_DMA_PEND BIT(5) +#define PCMMIO_AI_STATUS_DATA_DMA_PEND BIT(6) +#define PCMMIO_AI_STATUS_CMD_DMA_PEND BIT(5) #define PCMMIO_AI_STATUS_IRQ_PEND BIT(4) -#define PCMMIO_AI_STATUS_DATA_DRQ_ENA BIT(2) +#define PCMMIO_AI_STATUS_DATA_DRQ_ENA BIT(2) #define PCMMIO_AI_STATUS_REG_SEL BIT(3) -#define PCMMIO_AI_STATUS_CMD_DRQ_ENA BIT(1) +#define PCMMIO_AI_STATUS_CMD_DRQ_ENA BIT(1) #define PCMMIO_AI_STATUS_IRQ_ENA BIT(0) #define PCMMIO_AI_RES_ENA_REG 0x03 #define PCMMIO_AI_RES_ENA_CMD_REG_ACCESS 0 @@ -126,12 +126,12 @@ #define PCMMIO_AO_CMD_CHAN_SEL_ALL(0x0f << 0) #define PCMMIO_AO_STATUS_REG 0x0b #define PCMMIO_AO_STATUS_DATA_READY BIT(7) -#define PCMMIO_AO_STATUS_DATA_DMA_PEND BIT(6) -#define PCMMIO_AO_STATUS_CMD_DMA_PEND BIT(5) +#define PCMMIO_AO_STATUS_DATA_DMA_PEND BIT(6) +#define PCMMIO_AO_STATUS_CMD_DMA_PEND BIT(5) #define PCMMIO_AO_STATUS_IRQ_PEND BIT(4) -#define PCMMIO_AO_STATUS_DATA_DRQ_ENA BIT(2) +#define PCMMIO_AO_STATUS_DATA_DRQ_ENA BIT(2) #define PCMMIO_AO_STATUS_REG_SEL BIT(3) -#define PCMMIO_AO_STATUS_CMD_DRQ_ENA BIT(1) +#define PCMMIO_AO_STATUS_CMD_DRQ_ENA BIT(1) #define PCMMIO_AO_STATUS_IRQ_ENA BIT(0) #define PCMMIO_AO_RESOURCE_ENA_REG0x0b #define PCMMIO_AO_2ND_DAC_OFFSET 0x04 This patch appears to be fixing the whitespace issues introduced by your previous patch of the same name, but your previous patch hasn't been applied because of the whitespace issues. What you need to do in this case is merge this patch with your previous of the same name, for example by using an interactive git rebase with this patch marked as a 'fixup' patch. Then submit the combined single patch using the '[PATCH v2]' tag in the email. If that's a bit daunting, it might be easier for you to recreate the patch from scratch! -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] comedi: gsc_hpdi: Fix coding style - use kernel type definitions for variables
On 14/11/15 17:21, Ranjith Thangavel wrote: kernel type definitions are preferred for variables over standard type definitions Signed-off-by: Ranjith Thangavel --- drivers/staging/comedi/drivers/gsc_hpdi.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index e929618..cc67a07 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -125,7 +125,7 @@ struct hpdi_private { void __iomem *plx9080_mmio; - uint32_t *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */ + u32 *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */ /* physical addresses of dma buffers */ dma_addr_t dio_buffer_phys_addr[NUM_DMA_BUFFERS]; /* @@ -137,7 +137,7 @@ struct hpdi_private { dma_addr_t dma_desc_phys_addr; unsigned int num_dma_descriptors; /* pointer to start of buffers indexed by descriptor */ - uint32_t *desc_dio_buffer[NUM_DMA_DESCRIPTORS]; + u32 *desc_dio_buffer[NUM_DMA_DESCRIPTORS]; /* index of the dma descriptor that is currently being used */ unsigned int dma_desc_index; unsigned int tx_fifo_size; @@ -192,10 +192,10 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) struct hpdi_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; - uint32_t hpdi_intr_status, hpdi_board_status; - uint32_t plx_status; - uint32_t plx_bits; - uint8_t dma0_status, dma1_status; + u32 hpdi_intr_status, hpdi_board_status; + u32 plx_status; + u32 plx_bits; + u8 dma0_status, dma1_status; unsigned long flags; if (!dev->attached) @@ -290,7 +290,7 @@ static int gsc_hpdi_cmd(struct comedi_device *dev, struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; unsigned long flags; - uint32_t bits; + u32 bits; if (s->io_bits) return -EINVAL; @@ -424,7 +424,7 @@ static int gsc_hpdi_setup_dma_descriptors(struct comedi_device *dev, { struct hpdi_private *devpriv = dev->private; dma_addr_t phys_addr = devpriv->dma_desc_phys_addr; - uint32_t next_bits = PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT | + u32 next_bits = PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT | PLX_XFER_LOCAL_TO_PCI; unsigned int offset = 0; unsigned int idx = 0; @@ -516,7 +516,7 @@ static void gsc_hpdi_free_dma(struct comedi_device *dev) static int gsc_hpdi_init(struct comedi_device *dev) { struct hpdi_private *devpriv = dev->private; - uint32_t plx_intcsr_bits; + u32 plx_intcsr_bits; /* wait 10usec after reset before accessing fifos */ writel(BOARD_RESET_BIT, dev->mmio + BOARD_CONTROL_REG); @@ -546,7 +546,7 @@ static int gsc_hpdi_init(struct comedi_device *dev) static void gsc_hpdi_init_plx9080(struct comedi_device *dev) { struct hpdi_private *devpriv = dev->private; - uint32_t bits; + u32 bits; void __iomem *plx_iobase = devpriv->plx9080_mmio; #ifdef __BIG_ENDIAN Thanks! Reviewed-by: Ian Abbott -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: media: bcm2048: fix brace coding style issue in radio-bcm2048.c
This is a patch to the radio-bcm2048.c file that fixes up a brace warning found by the checkpatch.pl tool. Signed-off-by: Jitendra Kumar Khasdev --- drivers/staging/media/bcm2048/radio-bcm2048.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index b10d601..6226e02 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -2021,8 +2021,8 @@ static ssize_t bcm2048_##prop##_read(struct device *dev, \ } #define DEFINE_SYSFS_PROPERTY(prop, signal, size, mask, check) \ -property_write(prop, signal size, mask, check) \ -property_read(prop, size, mask) +(property_write(prop, signal size, mask, check) \ +property_read(prop, size, mask)) #define property_str_read(prop, size) \ static ssize_t bcm2048_##prop##_read(struct device *dev, \ -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] comedi: ni_6527: Fix coding style - use BIT macro
On 14/11/15 13:13, Ranjith Thangavel wrote: BIT macro is used for defining BIT location instead of shifting operator - coding style issue Signed-off-by: Ranjith Thangavel --- drivers/staging/comedi/drivers/ni_6527.c | 27 ++- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index b340b98..1903d64 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -32,6 +32,8 @@ #include "../comedi_pci.h" +#include "comedi_fc.h" + That part seems to have been added in by mistake. /* * PCI BAR1 - Register memory map * @@ -52,13 +54,13 @@ #define NI6527_FILT_ENA_REG(x)(0x0c + (x)) #define NI6527_STATUS_REG 0x14 #define NI6527_STATUS_IRQ BIT(2) -#define NI6527_STATUS_OVERFLOW BIT(1) +#define NI6527_STATUS_OVERFLOW BIT(1) #define NI6527_STATUS_EDGEBIT(0) #define NI6527_CTRL_REG 0x15 #define NI6527_CTRL_FALLING BIT(4) #define NI6527_CTRL_RISINGBIT(3) #define NI6527_CTRL_IRQ BIT(2) -#define NI6527_CTRL_OVERFLOW BIT(1) +#define NI6527_CTRL_OVERFLOW BIT(1) #define NI6527_CTRL_EDGE BIT(0) #define NI6527_CTRL_DISABLE_IRQS 0 #define NI6527_CTRL_ENABLE_IRQS (NI6527_CTRL_FALLING | \ That part seems to be based on top of your previous patch that had whitespace issues. @@ -221,11 +223,11 @@ static int ni6527_intr_cmdtest(struct comedi_device *dev, /* Step 1 : check if triggers are trivially valid */ - err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW); - err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_OTHER); - err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW); - err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); - err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT); + err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW); + err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_OTHER); + err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW); + err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); + err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT); if (err) return 1; @@ -235,12 +237,11 @@ static int ni6527_intr_cmdtest(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ - err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0); - err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0); - err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg, - cmd->chanlist_len); - err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); + err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); if (err) return 3; As Dan Carpenter pointed out, this part has been added by mistake. The parts added by mistake seem to be a throwback to an earlier kernel version. -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: media: bcm2048: fix brace coding style issue in radio-bcm2048.c
Hi Jitendra, [auto build test ERROR on: linuxtv-media/master] [also build test ERROR on: v4.4-rc1 next-20151118] url: https://github.com/0day-ci/linux/commits/Jitendra-Kumar-Khasdev/staging-media-bcm2048-fix-brace-coding-style-issue-in-radio-bcm2048-c/20151118-235820 base: git://linuxtv.org/media_tree.git master config: tile-allyesconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=tile All errors (new ones prefixed by >>): drivers/staging/media/bcm2048/radio-bcm2048.c:2051:1: error: expected identifier or '(' before 'static' drivers/staging/media/bcm2048/radio-bcm2048.c:2052:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2053:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2054:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2056:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2057:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2058:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2059:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2060:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2061:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2062:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2063:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2064:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2066:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2067:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2068:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2069:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2070:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2071:1: error: expected identifier or '(' before ')' token drivers/staging/media/bcm2048/radio-bcm2048.c:2083:1: error: expected identifier or '(' before 'static' drivers/staging/media/bcm2048/radio-bcm2048.c: In function 'bcm2048_sysfs_unregister_properties': drivers/staging/media/bcm2048/radio-bcm2048.c:2155:43: error: 'attrs' undeclared (first use in this function) drivers/staging/media/bcm2048/radio-bcm2048.c:2155:43: note: each undeclared identifier is reported only once for each function it appears in drivers/staging/media/bcm2048/radio-bcm2048.c: In function 'bcm2048_sysfs_register_properties': drivers/staging/media/bcm2048/radio-bcm2048.c:2165:18: error: 'attrs' undeclared (first use in this function) >> drivers/staging/media/bcm2048/radio-bcm2048.c:2165:18: error: negative width >> in bit-field '' drivers/staging/media/bcm2048/radio-bcm2048.c: In function 'bcm2048_i2c_driver_probe': drivers/staging/media/bcm2048/radio-bcm2048.c:2650:44: error: 'attrs' undeclared (first use in this function) drivers/staging/media/bcm2048/radio-bcm2048.c:2650:44: error: negative width in bit-field '' drivers/staging/media/bcm2048/radio-bcm2048.c: In function 'bcm2048_i2c_driver_remove': drivers/staging/media/bcm2048/radio-bcm2048.c:2671:45: error: 'attrs' undeclared (first use in this function) drivers/staging/media/bcm2048/radio-bcm2048.c:2671:45: error: negative width in bit-field '' drivers/staging/media/bcm2048/radio-bcm2048.c: At top level: drivers/staging/media/bcm2048/radio-bcm2048.c:449:12: warning: 'bcm2048_get_power_state' defined but not used [-Wunused-function] drivers/staging/media/bcm2048/radio-bcm2048.c:506:12: warning: 'bcm2048_set_rds' defined but not used [-Wunused-function]
RE: [PATCH 05/23] staging: comedi: adv_pci1710: define the mux control register bits
On Wednesday, November 18, 2015 3:33 AM, Ian Abbott wrote: > On 13/11/15 18:11, H Hartley Sweeten wrote: >> For aesthetics, define some macros to set the bits in the mux control >> register. Also, rename the 'mux_ext' member of the private data. >> >> Signed-off-by: H Hartley Sweeten >> Cc: Ian Abbott >> Cc: Greg Kroah-Hartman >> --- >> drivers/staging/comedi/drivers/adv_pci1710.c | 14 +- >> 1 file changed, 9 insertions(+), 5 deletions(-) > > Presumably this is PATCH v2 05/23. Ian, Yes it is. Sorry about that. Greg, Can you handle this or would you prefer that I resubmit the series? Regards, Hartley ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: media: bcm2048: fix brace coding style issue in radio-bcm2048.c
Hi Jitendra, [auto build test ERROR on linuxtv-media/master] [also build test ERROR on v4.4-rc1 next-20151118] url: https://github.com/0day-ci/linux/commits/Jitendra-Kumar-Khasdev/staging-media-bcm2048-fix-brace-coding-style-issue-in-radio-bcm2048-c/20151118-235820 base: git://linuxtv.org/media_tree.git master config: xtensa-allyesconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=xtensa All error/warnings (new ones prefixed by >>): >> drivers/staging/media/bcm2048/radio-bcm2048.c:1963:1: error: expected >> identifier or '(' before 'static' static ssize_t bcm2048_##prop##_write(struct device *dev, \ ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2024:2: note: in expansion of >> macro 'property_write' (property_write(prop, signal size, mask, check)\ ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2051:1: note: in expansion of >> macro 'DEFINE_SYSFS_PROPERTY' DEFINE_SYSFS_PROPERTY(power_state, unsigned, int, "%u", 0) ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2025:32: error: expected >> identifier or '(' before ')' token property_read(prop, size, mask)) ^ drivers/staging/media/bcm2048/radio-bcm2048.c:2052:1: note: in expansion of macro 'DEFINE_SYSFS_PROPERTY' DEFINE_SYSFS_PROPERTY(mute, unsigned, int, "%u", 0) ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2025:32: error: expected >> identifier or '(' before ')' token property_read(prop, size, mask)) ^ drivers/staging/media/bcm2048/radio-bcm2048.c:2053:1: note: in expansion of macro 'DEFINE_SYSFS_PROPERTY' DEFINE_SYSFS_PROPERTY(audio_route, unsigned, int, "%u", 0) ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2025:32: error: expected >> identifier or '(' before ')' token property_read(prop, size, mask)) ^ drivers/staging/media/bcm2048/radio-bcm2048.c:2054:1: note: in expansion of macro 'DEFINE_SYSFS_PROPERTY' DEFINE_SYSFS_PROPERTY(dac_output, unsigned, int, "%u", 0) ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2025:32: error: expected >> identifier or '(' before ')' token property_read(prop, size, mask)) ^ drivers/staging/media/bcm2048/radio-bcm2048.c:2056:1: note: in expansion of macro 'DEFINE_SYSFS_PROPERTY' DEFINE_SYSFS_PROPERTY(fm_hi_lo_injection, unsigned, int, "%u", 0) ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2025:32: error: expected >> identifier or '(' before ')' token property_read(prop, size, mask)) ^ drivers/staging/media/bcm2048/radio-bcm2048.c:2057:1: note: in expansion of macro 'DEFINE_SYSFS_PROPERTY' DEFINE_SYSFS_PROPERTY(fm_frequency, unsigned, int, "%u", 0) ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2025:32: error: expected >> identifier or '(' before ')' token property_read(prop, size, mask)) ^ drivers/staging/media/bcm2048/radio-bcm2048.c:2058:1: note: in expansion of macro 'DEFINE_SYSFS_PROPERTY' DEFINE_SYSFS_PROPERTY(fm_af_frequency, unsigned, int, "%u", 0) ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2025:32: error: expected >> identifier or '(' before ')' token property_read(prop, size, mask)) ^ drivers/staging/media/bcm2048/radio-bcm2048.c:2059:1: note: in expansion of macro 'DEFINE_SYSFS_PROPERTY' DEFINE_SYSFS_PROPERTY(fm_deemphasis, unsigned, int, "%u", 0) ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2025:32: error: expected >> identifier or '(' before ')' token property_read(prop, size, mask)) ^ drivers/staging/media/bcm2048/radio-bcm2048.c:2060:1: note: in expansion of macro 'DEFINE_SYSFS_PROPERTY' DEFINE_SYSFS_PROPERTY(fm_rds_mask, unsigned, int, "%u", 0) ^ >> drivers/staging/media/bcm2048/radio-bcm2048.c:2025:32: error: expected >> identifier or '(' before ')' token property_read(prop, size, mask)) ^ drivers/staging/media/bcm2048/radio-bcm2048.c:2061:1: note: in expansion of macro 'DEFINE_SYSFS_PROPERTY' DE
Re: [PATCH] comedi: dmm32at: Fix coding style - use BIT macro
On 14/11/15 17:10, Ranjith Thangavel wrote: BIT macro is used for defining BIT location instead of shifting operator, usleep_range is preferred over udelay - coding style issue Those two things should be done in separate patches. Signed-off-by: Ranjith Thangavel --- drivers/staging/comedi/drivers/dmm32at.c | 104 +++--- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 958c0d4..0836d39 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -46,74 +46,74 @@ #define DMM32AT_AI_START_CONV_REG 0x00 #define DMM32AT_AI_LSB_REG0x00 #define DMM32AT_AUX_DOUT_REG 0x01 -#define DMM32AT_AUX_DOUT2 (1 << 2) /* J3.42 - OUT2 (OUT2EN) */ -#define DMM32AT_AUX_DOUT1 (1 << 1) /* J3.43 */ -#define DMM32AT_AUX_DOUT0 (1 << 0) /* J3.44 - OUT0 (OUT0EN) */ +#define DMM32AT_AUX_DOUT2 BIT(2) /* J3.42 - OUT2 (OUT2EN) */ +#define DMM32AT_AUX_DOUT1 BIT(1) /* J3.43 */ +#define DMM32AT_AUX_DOUT0 BIT(0) /* J3.44 - OUT0 (OUT0EN) */ #define DMM32AT_AI_MSB_REG0x01 #define DMM32AT_AI_LO_CHAN_REG0x02 #define DMM32AT_AI_HI_CHAN_REG0x03 #define DMM32AT_AUX_DI_REG0x04 -#define DMM32AT_AUX_DI_DACBUSY (1 << 7) -#define DMM32AT_AUX_DI_CALBUSY (1 << 6) -#define DMM32AT_AUX_DI3(1 << 3) /* J3.45 - ADCLK (CLKSEL) */ -#define DMM32AT_AUX_DI2(1 << 2) /* J3.46 - GATE12 (GT12EN) */ -#define DMM32AT_AUX_DI1(1 << 1) /* J3.47 - GATE0 (GT0EN) */ -#define DMM32AT_AUX_DI0(1 << 0) /* J3.48 - CLK0 (SRC0) */ +#define DMM32AT_AUX_DI_DACBUSY BIT(7) +#define DMM32AT_AUX_DI_CALBUSY BIT(6) +#define DMM32AT_AUX_DI3BIT(3) /* J3.45 - ADCLK (CLKSEL) */ +#define DMM32AT_AUX_DI2BIT(2) /* J3.46 - GATE12 (GT12EN) */ +#define DMM32AT_AUX_DI1BIT(1) /* J3.47 - GATE0 (GT0EN) */ +#define DMM32AT_AUX_DI0BIT(0) /* J3.48 - CLK0 (SRC0) */ #define DMM32AT_AO_LSB_REG0x04 #define DMM32AT_AO_MSB_REG0x05 #define DMM32AT_AO_MSB_DACH(x)((x) << 6) #define DMM32AT_FIFO_DEPTH_REG0x06 #define DMM32AT_FIFO_CTRL_REG 0x07 -#define DMM32AT_FIFO_CTRL_FIFOEN (1 << 3) -#define DMM32AT_FIFO_CTRL_SCANEN (1 << 2) -#define DMM32AT_FIFO_CTRL_FIFORST (1 << 1) +#define DMM32AT_FIFO_CTRL_FIFOEN BIT(3) +#define DMM32AT_FIFO_CTRL_SCANEN BIT(2) +#define DMM32AT_FIFO_CTRL_FIFORST BIT(1) #define DMM32AT_FIFO_STATUS_REG 0x07 -#define DMM32AT_FIFO_STATUS_EF (1 << 7) -#define DMM32AT_FIFO_STATUS_HF (1 << 6) -#define DMM32AT_FIFO_STATUS_FF (1 << 5) -#define DMM32AT_FIFO_STATUS_OVF(1 << 4) -#define DMM32AT_FIFO_STATUS_FIFOEN (1 << 3) -#define DMM32AT_FIFO_STATUS_SCANEN (1 << 2) -#define DMM32AT_FIFO_STATUS_PAGE_MASK (3 << 0) +#define DMM32AT_FIFO_STATUS_EF BIT(7) +#define DMM32AT_FIFO_STATUS_HF BIT(6) +#define DMM32AT_FIFO_STATUS_FF BIT(5) +#define DMM32AT_FIFO_STATUS_OVFBIT(4) +#define DMM32AT_FIFO_STATUS_FIFOEN BIT(3) +#define DMM32AT_FIFO_STATUS_SCANEN BIT(2) +#define DMM32AT_FIFO_STATUS_PAGE_MASK 0 As Dan Carpenter pointer out the new value of DMM32AT_FIFO_STATUS_PAGE_MASK is wrong (the old value was 3). #define DMM32AT_CTRL_REG 0x08 -#define DMM32AT_CTRL_RESETA(1 << 5) -#define DMM32AT_CTRL_RESETD(1 << 4) -#define DMM32AT_CTRL_INTRST(1 << 3) -#define DMM32AT_CTRL_PAGE_8254 (0 << 0) -#define DMM32AT_CTRL_PAGE_8255 (1 << 0) -#define DMM32AT_CTRL_PAGE_CALIB(3 << 0) +#define DMM32AT_CTRL_RESETABIT(5) +#define DMM32AT_CTRL_RESETDBIT(4) +#define DMM32AT_CTRL_INTRSTBIT(3) +#define DMM32AT_CTRL_PAGE_8254 0 +#define DMM32AT_CTRL_PAGE_8255 BIT(0) +#define DMM32AT_CTRL_PAGE_CALIB0 The new value of DMM32AT_CTRL_PAGE_CALIB is wrong - the old value is 3. DMM32AT_CTRL_PAGE_8254, DMM32AT_CTRL_PAGE_8255 and DMM32AT_CTRL_PAGE_CALIB are 2-bit values, so the BIT() macro isn't really the best representation. (To be honest, I don't really know what the preferred representation of shifted multi-bit values is.) #define DMM32AT_AI_STATUS_REG 0x08 -#define DMM32AT_AI_STATUS_STS (1 << 7) -#define DMM32AT_AI_STATUS_SD1 (1 << 6) -#define DMM32AT_AI_STATUS_SD0 (1 << 5) +#define DMM32AT_AI_STATUS_STS BIT(7) +#define DMM32AT_AI_STATUS_SD1 BIT(6) +#define DMM32AT_AI_STATUS_SD0 BIT(5) #define DMM32AT_AI_STAT
Re: [PATCH] comedi: dmm32at: Fix coding style - use BIT macro
On 18/11/15 16:26, Ian Abbott wrote: On 14/11/15 17:10, Ranjith Thangavel wrote: BIT macro is used for defining BIT location instead of shifting operator, usleep_range is preferred over udelay - coding style issue Those two things should be done in separate patches. Sorry, I didn't see you've reposted this as two separate patches, so ignore my previous reply. -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] comedi: ni_6527: Fix coding style - use BIT macro
On 16/11/15 16:56, Ranjith Thangavel wrote: BIT macro is used for defining BIT location instead of shifting operator - coding style issue Signed-off-by: Ranjith Thangavel --- drivers/staging/comedi/drivers/ni_6527.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 62a817e..84c62e2 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -42,24 +42,24 @@ #define NI6527_DO_REG(x) (0x03 + (x)) #define NI6527_ID_REG 0x06 #define NI6527_CLR_REG0x07 -#define NI6527_CLR_EDGE(1 << 3) -#define NI6527_CLR_OVERFLOW(1 << 2) -#define NI6527_CLR_FILT(1 << 1) -#define NI6527_CLR_INTERVAL(1 << 0) +#define NI6527_CLR_EDGEBIT(3) +#define NI6527_CLR_OVERFLOWBIT(2) +#define NI6527_CLR_FILTBIT(1) +#define NI6527_CLR_INTERVALBIT(0) #define NI6527_CLR_IRQS (NI6527_CLR_EDGE | NI6527_CLR_OVERFLOW) #define NI6527_CLR_RESET_FILT (NI6527_CLR_FILT | NI6527_CLR_INTERVAL) #define NI6527_FILT_INTERVAL_REG(x) (0x08 + (x)) #define NI6527_FILT_ENA_REG(x)(0x0c + (x)) #define NI6527_STATUS_REG 0x14 -#define NI6527_STATUS_IRQ (1 << 2) -#define NI6527_STATUS_OVERFLOW (1 << 1) -#define NI6527_STATUS_EDGE (1 << 0) +#define NI6527_STATUS_IRQ BIT(2) +#define NI6527_STATUS_OVERFLOW BIT(1) +#define NI6527_STATUS_EDGE BIT(0) #define NI6527_CTRL_REG 0x15 -#define NI6527_CTRL_FALLING(1 << 4) -#define NI6527_CTRL_RISING (1 << 3) -#define NI6527_CTRL_IRQ(1 << 2) -#define NI6527_CTRL_OVERFLOW (1 << 1) -#define NI6527_CTRL_EDGE (1 << 0) +#define NI6527_CTRL_FALLINGBIT(4) +#define NI6527_CTRL_RISING BIT(3) +#define NI6527_CTRL_IRQBIT(2) +#define NI6527_CTRL_OVERFLOW BIT(1) +#define NI6527_CTRL_EDGE BIT(0) #define NI6527_CTRL_DISABLE_IRQS 0 #define NI6527_CTRL_ENABLE_IRQS (NI6527_CTRL_FALLING | \ NI6527_CTRL_RISING | \ Thanks! Reviewed-by: Ian Abbott -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro
On 16/11/15 17:18, Ranjith Thangavel wrote: BIT macro is used for defining BIT location instead of shifting operator, usleep_range is preferred over udelay - coding style issue This patch doesn't use usleep_range(), so the description is inaccurate. Signed-off-by: Ranjith Thangavel --- drivers/staging/comedi/drivers/dmm32at.c | 100 +++--- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 958c0d4..d312fda 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c [snip] -#define DMM32AT_AI_CFG_SCINT_20US (0 << 4) -#define DMM32AT_AI_CFG_SCINT_15US (1 << 4) -#define DMM32AT_AI_CFG_SCINT_10US (2 << 4) -#define DMM32AT_AI_CFG_SCINT_5US (3 << 4) -#define DMM32AT_AI_CFG_RANGE (1 << 3) /* 0=5V 1=10V */ -#define DMM32AT_AI_CFG_ADBU(1 << 2) /* 0=bipolar 1=unipolar */ +#define DMM32AT_AI_CFG_SCINT_20US 0 +#define DMM32AT_AI_CFG_SCINT_15US BIT(4) +#define DMM32AT_AI_CFG_SCINT_10US (BIT(5) & ~BIT(4)) The `(BIT(5) & ~BIT(4))` is a bit ugly. You can just use `BIT(5)` to fit in with the style of your other changes. (Personally though, I don't think BIT() is appropriate for shifted, multi-bit values.) +#define DMM32AT_AI_CFG_SCINT_5US (BIT(5) | BIT(4)) +#define DMM32AT_AI_CFG_RANGE BIT(3) /* 0=5V 1=10V */ +#define DMM32AT_AI_CFG_ADBUBIT(2) /* 0=bipolar 1=unipolar */ [snip] -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro
On Wednesday, November 18, 2015 9:42 AM, Ian Abbott wrote: > On 16/11/15 17:18, Ranjith Thangavel wrote: [snip] >> -#define DMM32AT_AI_CFG_SCINT_20US (0 << 4) >> -#define DMM32AT_AI_CFG_SCINT_15US (1 << 4) >> -#define DMM32AT_AI_CFG_SCINT_10US (2 << 4) >> -#define DMM32AT_AI_CFG_SCINT_5US(3 << 4) >> -#define DMM32AT_AI_CFG_RANGE(1 << 3) /* 0=5V 1=10V */ >> -#define DMM32AT_AI_CFG_ADBU (1 << 2) /* 0=bipolar 1=unipolar */ >> +#define DMM32AT_AI_CFG_SCINT_20US 0 >> +#define DMM32AT_AI_CFG_SCINT_15US BIT(4) >> +#define DMM32AT_AI_CFG_SCINT_10US (BIT(5) & ~BIT(4)) > > The `(BIT(5) & ~BIT(4))` is a bit ugly. You can just use `BIT(5)` to > fit in with the style of your other changes. > > (Personally though, I don't think BIT() is appropriate for shifted, > multi-bit values.) It would be more appropriate as a macro: #define DMM32AT_AI_CFG_SCINT(x) (((x) & 0x3) << 4) #define DMM32AT_AI_CFG_SCINT_20US DMM32AT_AI_CFG_SCINT (0) #define DMM32AT_AI_CFG_SCINT_15US DMM32AT_AI_CFG_SCINT (1) #define DMM32AT_AI_CFG_SCINT_10US DMM32AT_AI_CFG_SCINT (2) #define DMM32AT_AI_CFG_SCINT_5USDMM32AT_AI_CFG_SCINT (3) Regards, Hartley ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro
On 18/11/15 16:45, Hartley Sweeten wrote: On Wednesday, November 18, 2015 9:42 AM, Ian Abbott wrote: On 16/11/15 17:18, Ranjith Thangavel wrote: [snip] -#define DMM32AT_AI_CFG_SCINT_20US (0 << 4) -#define DMM32AT_AI_CFG_SCINT_15US (1 << 4) -#define DMM32AT_AI_CFG_SCINT_10US (2 << 4) -#define DMM32AT_AI_CFG_SCINT_5US (3 << 4) -#define DMM32AT_AI_CFG_RANGE (1 << 3) /* 0=5V 1=10V */ -#define DMM32AT_AI_CFG_ADBU(1 << 2) /* 0=bipolar 1=unipolar */ +#define DMM32AT_AI_CFG_SCINT_20US 0 +#define DMM32AT_AI_CFG_SCINT_15US BIT(4) +#define DMM32AT_AI_CFG_SCINT_10US (BIT(5) & ~BIT(4)) The `(BIT(5) & ~BIT(4))` is a bit ugly. You can just use `BIT(5)` to fit in with the style of your other changes. (Personally though, I don't think BIT() is appropriate for shifted, multi-bit values.) It would be more appropriate as a macro: #define DMM32AT_AI_CFG_SCINT(x) (((x) & 0x3) << 4) #define DMM32AT_AI_CFG_SCINT_20US DMM32AT_AI_CFG_SCINT (0) #define DMM32AT_AI_CFG_SCINT_15US DMM32AT_AI_CFG_SCINT (1) #define DMM32AT_AI_CFG_SCINT_10US DMM32AT_AI_CFG_SCINT (2) #define DMM32AT_AI_CFG_SCINT_5USDMM32AT_AI_CFG_SCINT (3) Yes, but without the spaces in the macro calls! It's slightly surprising no one has pushed a generic macro for this sort of thing, maybe something like: #define MBIT(v, s) ((v) * BIT(s)) although the name sucks - maybe the problem is thinking up a decent name! -- -=( Ian Abbott @ MEV Ltd.E-mail: )=- -=( Web: http://www.mev.co.uk/ )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 17/33] staging: comedi: adv_pci_dio: remove defines used for the do registers
These defines are only used to initialize the diosubd_data 'addr' members in the boardinfo. For aesthetics, just open-code the values and remove the defines. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 32 +--- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 578c646..a72b04e 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -50,19 +50,12 @@ enum hw_cards_id { /* Register offset definitions */ /* Advantech PCI-1730/3/4 */ -#define PCI1730_IDO 0/* W: Isolated digital output 0-15 */ -#define PCI1730_DO2/* W: Digital output 0-15 */ #definePCI1730_3_INT_EN0x08/* R/W: enable/disable interrupts */ #definePCI1730_3_INT_RF0x0c/* R/W: set falling/raising edge for * interrupts */ #definePCI1730_3_INT_CLR 0x10/* R/W: clear interrupts */ -#define PCI1734_IDO 0/* W: Isolated digital output 0-31 */ - -/* Advantech PCI-1735U */ -#define PCI1735_DO0/* W: Digital output 0-31 */ /* Advantech PCI-1736UP */ -#define PCI1736_IDO0 /* W: Isolated digital output 0-15 */ #define PCI1736_3_INT_EN0x08 /* R/W: enable/disable interrupts */ #define PCI1736_3_INT_RF0x0c /* R/W: set falling/raising edge for * interrupts */ @@ -74,7 +67,6 @@ enum hw_cards_id { #define PCI1739_ISR 32/* R: Interrupt status register */ /* Advantech PCI-1750 */ -#define PCI1750_IDO 0/* W: Isolated digital output 0-15 */ #define PCI1750_ICR 32/* W: Interrupt control register */ #define PCI1750_ISR 32/* R: Interrupt status register */ @@ -94,9 +86,6 @@ enum hw_cards_id { #define PCI1753E_ICR351/* R/W: Interrupt control register group 3 */ /* Advantech PCI-1752/4/6 */ -#define PCI1752_IDO 0/* R/W: Digital output 0-31 */ -#define PCI1752_IDO2 4/* R/W: Digital output 32-63 */ -#define PCI1756_IDO 4/* R/W: Digital output 0-31 */ #define PCI1754_6_ICR0 0x08/* R/W: Interrupt control register group 0 */ #define PCI1754_6_ICR1 0x0a/* R/W: Interrupt control register group 1 */ #define PCI1754_ICR2 0x0c/* R/W: Interrupt control register group 2 */ @@ -104,7 +93,6 @@ enum hw_cards_id { #define PCI1752_6_CFC 0x12/* R/W: set/read channel freeze function */ /* Advantech PCI-1762 registers */ -#define PCI1762_RO0/* R/W: Relays status/output */ #define PCI1762_ICR 6/* W: Interrupt control register */ #define PCI1762_ISR 6/* R: Interrupt status register */ @@ -132,8 +120,8 @@ static const struct dio_boardtype boardtypes[] = { .nsubdevs = 5, .sdi[0] = { 16, 0x02, },/* DI 0-15 */ .sdi[1] = { 16, 0x00, },/* ISO DI 0-15 */ - .sdo[0] = { 16, PCI1730_DO, }, - .sdo[1] = { 16, PCI1730_IDO, }, + .sdo[0] = { 16, 0x02, },/* DO 0-15 */ + .sdo[1] = { 16, 0x00, },/* ISO DO 0-15 */ .id_reg = 0x04, }, [TYPE_PCI1733] = { @@ -147,7 +135,7 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1734", .cardtype = TYPE_PCI1734, .nsubdevs = 2, - .sdo[1] = { 32, PCI1734_IDO, }, + .sdo[1] = { 32, 0x00, },/* ISO DO 0-31 */ .id_reg = 0x04, }, [TYPE_PCI1735] = { @@ -155,7 +143,7 @@ static const struct dio_boardtype boardtypes[] = { .cardtype = TYPE_PCI1735, .nsubdevs = 4, .sdi[0] = { 32, 0x00, },/* DI 0-31 */ - .sdo[0] = { 32, PCI1735_DO, }, + .sdo[0] = { 32, 0x00, },/* DO 0-31 */ .id_reg = 0x08, .timer_regbase = 0x04, }, @@ -164,7 +152,7 @@ static const struct dio_boardtype boardtypes[] = { .cardtype = TYPE_PCI1736, .nsubdevs = 3, .sdi[1] = { 16, 0x00, },/* ISO DI 0-15 */ - .sdo[1] = { 16, PCI1736_IDO, }, + .sdo[1] = { 16, 0x00, },/* ISO DO 0-15 */ .id_reg = 0x04, }, [TYPE_PCI1739] = { @@ -179,7 +167,7 @@ static const struct dio_boardtype boardtypes[] = { .cardtype = TYPE_PCI1750, .nsubdevs = 2, .sdi[1] = { 16, 0x00, },/
[PATCH 13/33] staging: comedi: adv_pci_dio: remove defines used for the di registers
These defines are only used to initialize the diosubd_data 'addr' members in the boardinfo. For aesthetics, just open-code the values and remove the defines. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 30 ++-- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index fdb6063..3c4335e 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -50,11 +50,8 @@ enum hw_cards_id { /* Register offset definitions */ /* Advantech PCI-1730/3/4 */ -#define PCI1730_IDI 0/* R: Isolated digital input 0-15 */ #define PCI1730_IDO 0/* W: Isolated digital output 0-15 */ -#define PCI1730_DI2/* R: Digital input 0-15 */ #define PCI1730_DO2/* W: Digital output 0-15 */ -#define PCI1733_IDI 0/* R: Isolated digital input 0-31 */ #definePCI1730_3_INT_EN0x08/* R/W: enable/disable interrupts */ #definePCI1730_3_INT_RF0x0c/* R/W: set falling/raising edge for * interrupts */ @@ -62,11 +59,9 @@ enum hw_cards_id { #define PCI1734_IDO 0/* W: Isolated digital output 0-31 */ /* Advantech PCI-1735U */ -#define PCI1735_DI0/* R: Digital input 0-31 */ #define PCI1735_DO0/* W: Digital output 0-31 */ /* Advantech PCI-1736UP */ -#define PCI1736_IDI0 /* R: Isolated digital input 0-15 */ #define PCI1736_IDO0 /* W: Isolated digital output 0-15 */ #define PCI1736_3_INT_EN0x08 /* R/W: enable/disable interrupts */ #define PCI1736_3_INT_RF0x0c /* R/W: set falling/raising edge for @@ -79,7 +74,6 @@ enum hw_cards_id { #define PCI1739_ISR 32/* R: Interrupt status register */ /* Advantech PCI-1750 */ -#define PCI1750_IDI 0/* R: Isolated digital input 0-15 */ #define PCI1750_IDO 0/* W: Isolated digital output 0-15 */ #define PCI1750_ICR 32/* W: Interrupt control register */ #define PCI1750_ISR 32/* R: Interrupt status register */ @@ -102,9 +96,6 @@ enum hw_cards_id { /* Advantech PCI-1752/4/6 */ #define PCI1752_IDO 0/* R/W: Digital output 0-31 */ #define PCI1752_IDO2 4/* R/W: Digital output 32-63 */ -#define PCI1754_IDI 0/* R: Digital input 0-31 */ -#define PCI1754_IDI2 4/* R: Digital input 32-64 */ -#define PCI1756_IDI 0/* R: Digital input 0-31 */ #define PCI1756_IDO 4/* R/W: Digital output 0-31 */ #define PCI1754_6_ICR0 0x08/* R/W: Interrupt control register group 0 */ #define PCI1754_6_ICR1 0x0a/* R/W: Interrupt control register group 1 */ @@ -114,7 +105,6 @@ enum hw_cards_id { /* Advantech PCI-1762 registers */ #define PCI1762_RO0/* R/W: Relays status/output */ -#define PCI1762_IDI 2/* R: Isolated input status */ #define PCI1762_ICR 6/* W: Interrupt control register */ #define PCI1762_ISR 6/* R: Interrupt status register */ @@ -140,8 +130,8 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1730", .cardtype = TYPE_PCI1730, .nsubdevs = 5, - .sdi[0] = { 16, PCI1730_DI, }, - .sdi[1] = { 16, PCI1730_IDI, }, + .sdi[0] = { 16, 0x02, },/* DI 0-15 */ + .sdi[1] = { 16, 0x00, },/* ISO DI 0-15 */ .sdo[0] = { 16, PCI1730_DO, }, .sdo[1] = { 16, PCI1730_IDO, }, .id_reg = 0x04, @@ -150,7 +140,7 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1733", .cardtype = TYPE_PCI1733, .nsubdevs = 2, - .sdi[1] = { 32, PCI1733_IDI, }, + .sdi[1] = { 32, 0x00, },/* ISO DI 0-31 */ .id_reg = 0x04, }, [TYPE_PCI1734] = { @@ -164,7 +154,7 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1735", .cardtype = TYPE_PCI1735, .nsubdevs = 4, - .sdi[0] = { 32, PCI1735_DI, }, + .sdi[0] = { 32, 0x00, },/* DI 0-31 */ .sdo[0] = { 32, PCI1735_DO, }, .id_reg = 0x08, .timer_regbase = 0x04, @@ -173,7 +163,7 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1736", .cardtype = TYPE_PCI1736, .nsubdevs = 3, - .sdi[1] = { 16, PCI1736_IDI, }, +
[PATCH 04/33] staging: comedi: adv_pci_dio: post increment 'subdev' in (*auto_attach)
For aesthetics, post-increment the 'subdev' index when used to get a comedi_subdevice pointer instead of incrementing it after the subdevice is initialized. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 16 +--- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index b1f966e..4d4b38c 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -557,38 +557,34 @@ static int pci_dio_auto_attach(struct comedi_device *dev, subdev = 0; for (i = 0; i < MAX_DI_SUBDEVS; i++) if (board->sdi[i].chans) { - s = &dev->subdevices[subdev]; + s = &dev->subdevices[subdev++]; pci_dio_add_di(dev, s, &board->sdi[i]); - subdev++; } for (i = 0; i < MAX_DO_SUBDEVS; i++) if (board->sdo[i].chans) { - s = &dev->subdevices[subdev]; + s = &dev->subdevices[subdev++]; pci_dio_add_do(dev, s, &board->sdo[i]); - subdev++; } for (i = 0; i < MAX_DIO_SUBDEVG; i++) for (j = 0; j < board->sdio[i].regs; j++) { - s = &dev->subdevices[subdev]; + s = &dev->subdevices[subdev++]; ret = subdev_8255_init(dev, s, NULL, board->sdio[i].addr + j * I8255_SIZE); if (ret) return ret; - subdev++; } if (board->boardid.chans) { - s = &dev->subdevices[subdev]; + s = &dev->subdevices[subdev++]; s->type = COMEDI_SUBD_DI; pci_dio_add_di(dev, s, &board->boardid); - subdev++; } if (board->timer_regbase) { - s = &dev->subdevices[subdev]; + s = &dev->subdevices[subdev++]; dev->pacer = comedi_8254_init(dev->iobase + board->timer_regbase, @@ -597,8 +593,6 @@ static int pci_dio_auto_attach(struct comedi_device *dev, return -ENOMEM; comedi_8254_subdevice_init(s, dev->pacer); - - subdev++; } pci_dio_reset(dev); -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 25/33] staging: comedi: adv_pci_dio: cleanup PCI-175[46] interrupt registers
For aesthetics, replace these defines with a macro. Refactor the switch in pci_dio_reset() to use common code. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 21 + 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index df60503..f7466f4 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -64,11 +64,9 @@ enum hw_cards_id { #define PCI1753_INT_REG(x) (0x10 + (x)) /* R/W: control group 0 to 3 */ #define PCI1753E_INT_REG(x)(0x30 + (x)) /* R/W: control group 0 to 3 */ -/* Advantech PCI-1752/4/6 */ -#define PCI1754_6_ICR0 0x08/* R/W: Interrupt control register group 0 */ -#define PCI1754_6_ICR1 0x0a/* R/W: Interrupt control register group 1 */ -#define PCI1754_ICR2 0x0c/* R/W: Interrupt control register group 2 */ -#define PCI1754_ICR3 0x0e/* R/W: Interrupt control register group 3 */ +/* PCI-1754, PCI-1756 interrupt control registers */ +#define PCI1754_INT_REG(x) (0x08 + (x) * 2) /* R/W: control group 0 to 3 */ + #define PCI1752_6_CFC 0x12/* R/W: set/read channel freeze function */ /* Advantech PCI-1762 registers */ @@ -318,14 +316,13 @@ static int pci_dio_reset(struct comedi_device *dev) } break; case TYPE_PCI1754: - outw(0x08, dev->iobase + PCI1754_6_ICR0); - outw(0x08, dev->iobase + PCI1754_6_ICR1); - outw(0x08, dev->iobase + PCI1754_ICR2); - outw(0x08, dev->iobase + PCI1754_ICR3); - break; case TYPE_PCI1756: - outw(0x08, dev->iobase + PCI1754_6_ICR0); - outw(0x08, dev->iobase + PCI1754_6_ICR1); + outw(0x08, dev->iobase + PCI1754_INT_REG(0)); + outw(0x08, dev->iobase + PCI1754_INT_REG(1)); + if (board->cardtype == TYPE_PCI1754) { + outw(0x08, dev->iobase + PCI1754_INT_REG(2)); + outw(0x08, dev->iobase + PCI1754_INT_REG(3)); + } break; case TYPE_PCI1762: outw(0x0101, dev->iobase + PCI1762_ICR); -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 08/33] staging: comedi: adv_pci_dio: refactor 'io_access' boardinfo
The boards supported by this driver either use 8-bit or 16-bit I/O. The 'io_access' member of the boardinfo is used by the (*auto_attach) to determine which (*insn_bits) function to use. Simplify the boardinfo a bit by refactoring the 'io_access' member into a bit-field flag 'is_16bit'. Use the new flag and remove the switch () code in the (*auto_attach). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 57 +++- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index b0bbc73..ba3cb3b 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -43,11 +43,6 @@ enum hw_cards_id { TYPE_PCI1762 }; -/* which I/O instructions to use */ -enum hw_io_access { - IO_8b, IO_16b -}; - #define MAX_DI_SUBDEVS 2 /* max number of DI subdevices per card */ #define MAX_DO_SUBDEVS 2 /* max number of DO subdevices per card */ #define MAX_DIO_SUBDEVG2 /* max number of DIO subdevices group per @@ -147,7 +142,7 @@ struct dio_boardtype { struct diosubd_data sdio[MAX_DIO_SUBDEVG]; /* DIO 8255 chans */ struct diosubd_data boardid;/* card supports board ID switch */ unsigned long timer_regbase; - enum hw_io_access io_access; + unsigned int is_16bit:1; }; static const struct dio_boardtype boardtypes[] = { @@ -160,7 +155,6 @@ static const struct dio_boardtype boardtypes[] = { .sdo[0] = { 16, PCI1730_DO, 2, }, .sdo[1] = { 16, PCI1730_IDO, 2, }, .boardid= { 4, PCI173x_BOARDID, 1, }, - .io_access = IO_8b, }, [TYPE_PCI1733] = { .name = "pci1733", @@ -168,7 +162,6 @@ static const struct dio_boardtype boardtypes[] = { .nsubdevs = 2, .sdi[1] = { 32, PCI1733_IDI, 4, }, .boardid= { 4, PCI173x_BOARDID, 1, }, - .io_access = IO_8b, }, [TYPE_PCI1734] = { .name = "pci1734", @@ -176,7 +169,6 @@ static const struct dio_boardtype boardtypes[] = { .nsubdevs = 2, .sdo[1] = { 32, PCI1734_IDO, 4, }, .boardid= { 4, PCI173x_BOARDID, 1, }, - .io_access = IO_8b, }, [TYPE_PCI1735] = { .name = "pci1735", @@ -186,7 +178,6 @@ static const struct dio_boardtype boardtypes[] = { .sdo[0] = { 32, PCI1735_DO, 4, }, .boardid= { 4, PCI1735_BOARDID, 1, }, .timer_regbase = PCI1735_C8254, - .io_access = IO_8b, }, [TYPE_PCI1736] = { .name = "pci1736", @@ -195,14 +186,12 @@ static const struct dio_boardtype boardtypes[] = { .sdi[1] = { 16, PCI1736_IDI, 2, }, .sdo[1] = { 16, PCI1736_IDO, 2, }, .boardid= { 4, PCI1736_BOARDID, 1, }, - .io_access = IO_8b, }, [TYPE_PCI1739] = { .name = "pci1739", .cardtype = TYPE_PCI1739, .nsubdevs = 2, .sdio[0]= { 48, PCI1739_DIO, 2, }, - .io_access = IO_8b, }, [TYPE_PCI1750] = { .name = "pci1750", @@ -210,7 +199,6 @@ static const struct dio_boardtype boardtypes[] = { .nsubdevs = 2, .sdi[1] = { 16, PCI1750_IDI, 2, }, .sdo[1] = { 16, PCI1750_IDO, 2, }, - .io_access = IO_8b, }, [TYPE_PCI1751] = { .name = "pci1751", @@ -218,7 +206,6 @@ static const struct dio_boardtype boardtypes[] = { .nsubdevs = 3, .sdio[0]= { 48, PCI1751_DIO, 2, }, .timer_regbase = PCI1751_CNT, - .io_access = IO_8b, }, [TYPE_PCI1752] = { .name = "pci1752", @@ -227,14 +214,13 @@ static const struct dio_boardtype boardtypes[] = { .sdo[0] = { 32, PCI1752_IDO, 2, }, .sdo[1] = { 32, PCI1752_IDO2, 2, }, .boardid= { 4, PCI175x_BOARDID, 1, }, - .io_access = IO_16b, + .is_16bit = 1, }, [TYPE_PCI1753] = { .name = "pci1753", .cardtype = TYPE_PCI1753, .nsubdevs = 4, .sdio[0]= { 96, PCI1753_DIO, 4, }, - .io_access = IO_8b, }, [TYPE_PCI1753E] = { .name
[PATCH 14/33] staging: comedi: adv_pci_dio: remove board reset during (*detach)
The board reset function disables and clears all interrupts. It also resets all the digital output channels to 0. Interrupts are not used by this driver so the disable/clear during the (*detach) is not necessary. Reseting all the digital outputs to 0 might not be desired depending on what the outputs are connected to. Remove the board reset and just use comedi_pci_detach() directly for the driver (*detach). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 3c4335e..83591a6 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -548,18 +548,11 @@ static int pci_dio_auto_attach(struct comedi_device *dev, return 0; } -static void pci_dio_detach(struct comedi_device *dev) -{ - if (dev->iobase) - pci_dio_reset(dev); - comedi_pci_detach(dev); -} - static struct comedi_driver adv_pci_dio_driver = { .driver_name= "adv_pci_dio", .module = THIS_MODULE, .auto_attach= pci_dio_auto_attach, - .detach = pci_dio_detach, + .detach = comedi_pci_detach, }; static int adv_pci_dio_pci_probe(struct pci_dev *dev, -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 02/33] staging: comedi: adv_pci_dio: tidy up comedi driver block comment
Reformat the bolck comment in the kernel CodingStyle. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 40 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 28ed1cd..9794502 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -4,30 +4,24 @@ * Author: Michal Dobes * * Hardware driver for Advantech PCI DIO cards. -*/ + */ + /* -Driver: adv_pci_dio -Description: Advantech PCI-1730, PCI-1733, PCI-1734, PCI-1735U, - PCI-1736UP, PCI-1739U, PCI-1750, PCI-1751, PCI-1752, - PCI-1753/E, PCI-1754, PCI-1756, PCI-1762 -Author: Michal Dobes -Devices: [Advantech] PCI-1730 (adv_pci_dio), PCI-1733, - PCI-1734, PCI-1735U, PCI-1736UP, PCI-1739U, PCI-1750, - PCI-1751, PCI-1752, PCI-1753, - PCI-1753+PCI-1753E, PCI-1754, PCI-1756, - PCI-1762 -Status: untested -Updated: Mon, 09 Jan 2012 12:40:46 + - -This driver supports now only insn interface for DI/DO/DIO. - -Configuration options: - [0] - PCI bus of device (optional) - [1] - PCI slot of device (optional) - If bus/slot is not specified, the first available PCI - device will be used. - -*/ + * Driver: adv_pci_dio + * Description: Advantech PCI-1730, PCI-1733, PCI-1734, PCI-1735U, + * PCI-1736UP, PCI-1739U, PCI-1750, PCI-1751, PCI-1752, + * PCI-1753/E, PCI-1754, PCI-1756, PCI-1762 + * Devices: [Advantech] PCI-1730 (adv_pci_dio), PCI-1733, + * PCI-1734, PCI-1735U, PCI-1736UP, PCI-1739U, PCI-1750, + * PCI-1751, PCI-1752, PCI-1753, + * PCI-1753+PCI-1753E, PCI-1754, PCI-1756, + * PCI-1762 + * Author: Michal Dobes + * Updated: Mon, 09 Jan 2012 12:40:46 + + * Status: untested + * + * Configuration Options: not applicable, uses PCI auto config + */ #include #include -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 26/33] staging: comedi: adv_pci_dio: rename PCI1752_6_CFC define
For aesthetics, rename this define and fix the alignment. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index f7466f4..5aba40e 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -67,7 +67,8 @@ enum hw_cards_id { /* PCI-1754, PCI-1756 interrupt control registers */ #define PCI1754_INT_REG(x) (0x08 + (x) * 2) /* R/W: control group 0 to 3 */ -#define PCI1752_6_CFC 0x12/* R/W: set/read channel freeze function */ +/* PCI-1752, PCI-1756 special registers */ +#define PCI1752_CFC_REG0x12/* R/W: channel freeze function */ /* Advantech PCI-1762 registers */ #define PCI1762_ICR 6/* W: Interrupt control register */ @@ -286,7 +287,7 @@ static int pci_dio_reset(struct comedi_device *dev) /* disable channel freeze function on the PCI-1752/1756 boards */ if (board->cardtype == TYPE_PCI1752 || board->cardtype == TYPE_PCI1756) - outw(0, dev->iobase + PCI1752_6_CFC); + outw(0, dev->iobase + PCI1752_CFC_REG); /* disable and clear interrupts */ switch (board->cardtype) { -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 06/33] staging: comedi: adv_pci_dio: absorb pci_dio_add_do()
This function initializes a digitial output subdevice. For aesthetics, absorb it into the (*auto_attach). Remove the improper initialization of the SDF_LSAMPL subdev_flag and len_chanlist. These are only used by subdevices that support async commands. Also remove the unnecessary initilaization of the subdevice 'state'. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 43 +--- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 5da1e62..deac3a8 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -467,34 +467,6 @@ static int pci_dio_add_di(struct comedi_device *dev, return 0; } -static int pci_dio_add_do(struct comedi_device *dev, - struct comedi_subdevice *s, - const struct diosubd_data *d) -{ - const struct dio_boardtype *board = dev->board_ptr; - - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - if (d->chans > 16) - s->subdev_flags |= SDF_LSAMPL; - s->n_chan = d->chans; - s->maxdata = 1; - s->len_chanlist = d->chans; - s->range_table = &range_digital; - s->state = 0; - switch (board->io_access) { - case IO_8b: - s->insn_bits = pci_dio_insn_bits_do_b; - break; - case IO_16b: - s->insn_bits = pci_dio_insn_bits_do_w; - break; - } - s->private = (void *)d; - - return 0; -} - static unsigned long pci_dio_override_cardtype(struct pci_dev *pcidev, unsigned long cardtype) { @@ -568,7 +540,20 @@ static int pci_dio_auto_attach(struct comedi_device *dev, d = &board->sdo[i]; if (d->chans) { s = &dev->subdevices[subdev++]; - pci_dio_add_do(dev, s, d); + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = d->chans; + s->maxdata = 1; + s->range_table = &range_digital; + switch (board->io_access) { + case IO_8b: + s->insn_bits= pci_dio_insn_bits_do_b; + break; + case IO_16b: + s->insn_bits= pci_dio_insn_bits_do_w; + break; + } + s->private = (void *)d; } } -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 00/33] staging: comedi: adv_pci_dio: cleanup driver
With the PCI-1760 support moved to a separate driver this one can now be simplified and cleaned up pretty nicely. Tidy up this driver and fix all the checkpatch.pl issues. This series applies after: "staging: comedi: adv_pci_dio: separate out PCI-1760 support" H Hartley Sweeten (33): staging: comedi: adv_pci_dio: remove unnecessary function separation comments staging: comedi: adv_pci_dio: tidy up comedi driver block comment staging: comedi: adv_pci_dio: remove 'main_pci_region' boardinfo staging: comedi: adv_pci_dio: post increment 'subdev' in (*auto_attach) staging: comedi: adv_pci_dio: use a const pointer to the diosubd_data staging: comedi: adv_pci_dio: absorb pci_dio_add_do() staging: comedi: adv_pci_dio: absorb pci_dio_add_di() staging: comedi: adv_pci_dio: refactor 'io_access' boardinfo staging: comedi: adv_pci_dio: remove need for diosubd_data 'regs' member staging: comedi: adv_pci_dio: use the diosubd_data 'addr' for di/do s->private staging: comedi: adv_pci_dio: simplify the 'boardid' boardinfo staging: comedi: adv_pci_dio: remove defines used for the 'timer_regbase' staging: comedi: adv_pci_dio: remove defines used for the di registers staging: comedi: adv_pci_dio: remove board reset during (*detach) staging: comedi: adv_pci_dio: do board reset early in (*auto_attach) staging: comedi: adv_pci_dio: reset digital outputs in subdevice init staging: comedi: adv_pci_dio: remove defines used for the do registers staging: comedi: adv_pci_dio: remove defines used for the dio (8255) registers staging: comedi: adv_pci_dio: use a default case in pci_dio_reset() staging: comedi: adv_pci_dio: disable channel freeze outside of switch staging: comedi: adv_pci_dio: cleanup "disable and clear interrupts" comments staging: comedi: adv_pci_dio: use common defines for PCI-173[036] registers staging: comedi: adv_pci_dio: use common defines for PCI-1739/175[01] registers staging: comedi: adv_pci_dio: cleanup PCI-1753 interrupt register defines staging: comedi: adv_pci_dio: cleanup PCI-175[46] interrupt registers staging: comedi: adv_pci_dio: rename PCI1752_6_CFC define staging: comedi: adv_pci_dio: cleanup PCI-1762 interrupt registers staging: comedi: adv_pci_dio: remove boardinfo 'cardtype' staging: comedi: adv_pci_dio: move and rename enum hw_cards_id staging: comedi: adv_pci_dio: move and rename the MAX_*_SUBDEV[SG] defines staging: comedi: adv_pci_dio: move pci_dio_override_cardtype() staging: comedi: adv_pci_dio: tidy up the comedi comment block staging: comedi: adv_pci_dio: update the MODULE_DESCRIPTION drivers/staging/comedi/drivers/adv_pci_dio.c | 707 ++- 1 file changed, 265 insertions(+), 442 deletions(-) -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 09/33] staging: comedi: adv_pci_dio: remove need for diosubd_data 'regs' member
Currently the (*insn_bits) functions used the 'regs' member to determine how many registers need to be read or written to update the subdevice. We can use the subdevice 'n_chan' to determine this and make the code a bit clearer. The (*auto_attach) also uses this member to determine how many 8255 devices need to be initialized. These subdevices do not use the 'chans' member of diosubd_data. Move the 'regs' value to the 'chans' to allow removing the 'regs' member completely. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 120 ++- 1 file changed, 64 insertions(+), 56 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index ba3cb3b..e620e34 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -127,10 +127,8 @@ enum hw_cards_id { #define PCI1762_ISR 6/* R: Interrupt status register */ struct diosubd_data { - int chans; /* num of chans */ + int chans; /* num of chans or 8255 devices */ int addr; /* PCI address ofset */ - int regs; /* number of registers to read or 8255 - subdevices */ }; struct dio_boardtype { @@ -150,138 +148,144 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1730", .cardtype = TYPE_PCI1730, .nsubdevs = 5, - .sdi[0] = { 16, PCI1730_DI, 2, }, - .sdi[1] = { 16, PCI1730_IDI, 2, }, - .sdo[0] = { 16, PCI1730_DO, 2, }, - .sdo[1] = { 16, PCI1730_IDO, 2, }, - .boardid= { 4, PCI173x_BOARDID, 1, }, + .sdi[0] = { 16, PCI1730_DI, }, + .sdi[1] = { 16, PCI1730_IDI, }, + .sdo[0] = { 16, PCI1730_DO, }, + .sdo[1] = { 16, PCI1730_IDO, }, + .boardid= { 4, PCI173x_BOARDID, }, }, [TYPE_PCI1733] = { .name = "pci1733", .cardtype = TYPE_PCI1733, .nsubdevs = 2, - .sdi[1] = { 32, PCI1733_IDI, 4, }, - .boardid= { 4, PCI173x_BOARDID, 1, }, + .sdi[1] = { 32, PCI1733_IDI, }, + .boardid= { 4, PCI173x_BOARDID, }, }, [TYPE_PCI1734] = { .name = "pci1734", .cardtype = TYPE_PCI1734, .nsubdevs = 2, - .sdo[1] = { 32, PCI1734_IDO, 4, }, - .boardid= { 4, PCI173x_BOARDID, 1, }, + .sdo[1] = { 32, PCI1734_IDO, }, + .boardid= { 4, PCI173x_BOARDID, }, }, [TYPE_PCI1735] = { .name = "pci1735", .cardtype = TYPE_PCI1735, .nsubdevs = 4, - .sdi[0] = { 32, PCI1735_DI, 4, }, - .sdo[0] = { 32, PCI1735_DO, 4, }, - .boardid= { 4, PCI1735_BOARDID, 1, }, + .sdi[0] = { 32, PCI1735_DI, }, + .sdo[0] = { 32, PCI1735_DO, }, + .boardid= { 4, PCI1735_BOARDID, }, .timer_regbase = PCI1735_C8254, }, [TYPE_PCI1736] = { .name = "pci1736", .cardtype = TYPE_PCI1736, .nsubdevs = 3, - .sdi[1] = { 16, PCI1736_IDI, 2, }, - .sdo[1] = { 16, PCI1736_IDO, 2, }, - .boardid= { 4, PCI1736_BOARDID, 1, }, + .sdi[1] = { 16, PCI1736_IDI, }, + .sdo[1] = { 16, PCI1736_IDO, }, + .boardid= { 4, PCI1736_BOARDID, }, }, [TYPE_PCI1739] = { .name = "pci1739", .cardtype = TYPE_PCI1739, .nsubdevs = 2, - .sdio[0]= { 48, PCI1739_DIO, 2, }, + .sdio[0]= { 2, PCI1739_DIO, }, }, [TYPE_PCI1750] = { .name = "pci1750", .cardtype = TYPE_PCI1750, .nsubdevs = 2, - .sdi[1] = { 16, PCI1750_IDI, 2, }, - .sdo[1] = { 16, PCI1750_IDO, 2, }, + .sdi[1] = { 16, PCI1750_IDI, }, + .sdo[1] = { 16, PCI1750_IDO, }, }, [TYPE_PCI1751] = { .name = "pci1751", .cardtype = TYPE_PCI1751, .nsubdevs = 3, - .sdio[0]= { 48, PCI1751_DIO, 2, }, + .sdio[0]
[PATCH 11/33] staging: comedi: adv_pci_dio: simplify the 'boardid' boardinfo
The "board id" register is always 4-bits (4 di channels) and the register used to read the bits is always > 0. Simplify the 'boardid' boardinfo by replacing it with a 'id_reg' member and open-coding the subdevice n_chan. For aesthetics, remove all the *_BOARDID defines and just open-code the register values in the boardinfo. Add the missing boardinfo for the pci1739 board id register and increase the nsubdevs to handle it. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 36 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 51611c7..d24134f 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -60,13 +60,11 @@ enum hw_cards_id { * interrupts */ #definePCI1730_3_INT_CLR 0x10/* R/W: clear interrupts */ #define PCI1734_IDO 0/* W: Isolated digital output 0-31 */ -#define PCI173x_BOARDID 4/* R: Board I/D switch for 1730/3/4 */ /* Advantech PCI-1735U */ #define PCI1735_DI0/* R: Digital input 0-31 */ #define PCI1735_DO0/* W: Digital output 0-31 */ #define PCI1735_C8254 4/* R/W: 8254 counter */ -#define PCI1735_BOARDID 8/* R: Board I/D switch for 1735U */ /* Advantech PCI-1736UP */ #define PCI1736_IDI0 /* R: Isolated digital input 0-15 */ @@ -75,13 +73,11 @@ enum hw_cards_id { #define PCI1736_3_INT_RF0x0c /* R/W: set falling/raising edge for * interrupts */ #define PCI1736_3_INT_CLR 0x10 /* R/W: clear interrupts */ -#define PCI1736_BOARDID4 /* R: Board I/D switch for 1736UP */ /* Advantech PCI-1739U */ #define PCI1739_DIO 0/* R/W: begin of 8255 registers block */ #define PCI1739_ICR 32/* W: Interrupt control register */ #define PCI1739_ISR 32/* R: Interrupt status register */ -#define PCI1739_BOARDID 8/* R: Board I/D switch for 1739U */ /* Advantech PCI-1750 */ #define PCI1750_IDI 0/* R: Isolated digital input 0-15 */ @@ -117,12 +113,10 @@ enum hw_cards_id { #define PCI1754_ICR2 0x0c/* R/W: Interrupt control register group 2 */ #define PCI1754_ICR3 0x0e/* R/W: Interrupt control register group 3 */ #define PCI1752_6_CFC 0x12/* R/W: set/read channel freeze function */ -#define PCI175x_BOARDID0x10/* R: Board I/D switch for 1752/4/6 */ /* Advantech PCI-1762 registers */ #define PCI1762_RO0/* R/W: Relays status/output */ #define PCI1762_IDI 2/* R: Isolated input status */ -#define PCI1762_BOARDID 4/* R: Board I/D switch */ #define PCI1762_ICR 6/* W: Interrupt control register */ #define PCI1762_ISR 6/* R: Interrupt status register */ @@ -138,7 +132,7 @@ struct dio_boardtype { struct diosubd_data sdi[MAX_DI_SUBDEVS];/* DI chans */ struct diosubd_data sdo[MAX_DO_SUBDEVS];/* DO chans */ struct diosubd_data sdio[MAX_DIO_SUBDEVG]; /* DIO 8255 chans */ - struct diosubd_data boardid;/* card supports board ID switch */ + unsigned long id_reg; unsigned long timer_regbase; unsigned int is_16bit:1; }; @@ -152,21 +146,21 @@ static const struct dio_boardtype boardtypes[] = { .sdi[1] = { 16, PCI1730_IDI, }, .sdo[0] = { 16, PCI1730_DO, }, .sdo[1] = { 16, PCI1730_IDO, }, - .boardid= { 4, PCI173x_BOARDID, }, + .id_reg = 0x04, }, [TYPE_PCI1733] = { .name = "pci1733", .cardtype = TYPE_PCI1733, .nsubdevs = 2, .sdi[1] = { 32, PCI1733_IDI, }, - .boardid= { 4, PCI173x_BOARDID, }, + .id_reg = 0x04, }, [TYPE_PCI1734] = { .name = "pci1734", .cardtype = TYPE_PCI1734, .nsubdevs = 2, .sdo[1] = { 32, PCI1734_IDO, }, - .boardid= { 4, PCI173x_BOARDID, }, + .id_reg = 0x04, }, [TYPE_PCI1735] = { .name = "pci1735", @@ -174,7 +168,7 @@ static const struct dio_boardtype boardtypes[] = { .nsubdevs = 4, .sdi[0] = { 32, PCI1735_DI, }, .sdo[0] = { 32, PCI1735_DO, }, - .boardid= { 4, PCI1735_BOARDID, }, + .id_reg = 0x08, .timer_regbase = PCI1735_C8254, }, [TYPE_PCI1736] = { @@ -183,13 +177,14 @@
[PATCH 05/33] staging: comedi: adv_pci_dio: use a const pointer to the diosubd_data
For aesthetics, use a const pointer to access the diosubd_data in the boardinfo when doing the (*auto_attach).. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 31 +--- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 4d4b38c..5da1e62 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -532,6 +532,7 @@ static int pci_dio_auto_attach(struct comedi_device *dev, { struct pci_dev *pcidev = comedi_to_pci_dev(dev); const struct dio_boardtype *board = NULL; + const struct diosubd_data *d; struct comedi_subdevice *s; int ret, subdev, i, j; @@ -555,32 +556,38 @@ static int pci_dio_auto_attach(struct comedi_device *dev, return ret; subdev = 0; - for (i = 0; i < MAX_DI_SUBDEVS; i++) - if (board->sdi[i].chans) { + for (i = 0; i < MAX_DI_SUBDEVS; i++) { + d = &board->sdi[i]; + if (d->chans) { s = &dev->subdevices[subdev++]; - pci_dio_add_di(dev, s, &board->sdi[i]); + pci_dio_add_di(dev, s, d); } + } - for (i = 0; i < MAX_DO_SUBDEVS; i++) - if (board->sdo[i].chans) { + for (i = 0; i < MAX_DO_SUBDEVS; i++) { + d = &board->sdo[i]; + if (d->chans) { s = &dev->subdevices[subdev++]; - pci_dio_add_do(dev, s, &board->sdo[i]); + pci_dio_add_do(dev, s, d); } + } - for (i = 0; i < MAX_DIO_SUBDEVG; i++) - for (j = 0; j < board->sdio[i].regs; j++) { + for (i = 0; i < MAX_DIO_SUBDEVG; i++) { + d = &board->sdio[i]; + for (j = 0; j < d->regs; j++) { s = &dev->subdevices[subdev++]; ret = subdev_8255_init(dev, s, NULL, - board->sdio[i].addr + - j * I8255_SIZE); + d->addr + j * I8255_SIZE); if (ret) return ret; } + } - if (board->boardid.chans) { + d = &board->boardid; + if (d->chans) { s = &dev->subdevices[subdev++]; s->type = COMEDI_SUBD_DI; - pci_dio_add_di(dev, s, &board->boardid); + pci_dio_add_di(dev, s, d); } if (board->timer_regbase) { -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 15/33] staging: comedi: adv_pci_dio: do board reset early in (*auto_attach)
The board reset function disables and clears all interrupts. It also resets all the digital output channels to 0. Interrupts are not currently used by this driver. For asthetics, do the board reset early in the (*auto_attach) to make sure the interrupts are disabled in case this feature is added. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 83591a6..55ca8f9 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -471,6 +471,8 @@ static int pci_dio_auto_attach(struct comedi_device *dev, else dev->iobase = pci_resource_start(pcidev, 2); + pci_dio_reset(dev); + ret = comedi_alloc_subdevices(dev, board->nsubdevs); if (ret) return ret; @@ -543,8 +545,6 @@ static int pci_dio_auto_attach(struct comedi_device *dev, comedi_8254_subdevice_init(s, dev->pacer); } - pci_dio_reset(dev); - return 0; } -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 32/33] staging: comedi: adv_pci_dio: tidy up the comedi comment block
The Description is a bit long winded and the same information is in the Devices. Shorten the Description and tidy up the Devices. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index b7f13bc..f8e9bf9 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -8,14 +8,11 @@ /* * Driver: adv_pci_dio - * Description: Advantech PCI-1730, PCI-1733, PCI-1734, PCI-1735U, - * PCI-1736UP, PCI-1739U, PCI-1750, PCI-1751, PCI-1752, - * PCI-1753/E, PCI-1754, PCI-1756, PCI-1762 + * Description: Advantech Digital I/O Cards * Devices: [Advantech] PCI-1730 (adv_pci_dio), PCI-1733, * PCI-1734, PCI-1735U, PCI-1736UP, PCI-1739U, PCI-1750, - * PCI-1751, PCI-1752, PCI-1753, - * PCI-1753+PCI-1753E, PCI-1754, PCI-1756, - * PCI-1762 + * PCI-1751, PCI-1752, PCI-1753, PCI-1753+PCI-1753E, + * PCI-1754, PCI-1756, PCI-1762 * Author: Michal Dobes * Updated: Mon, 09 Jan 2012 12:40:46 + * Status: untested -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 20/33] staging: comedi: adv_pci_dio: disable channel freeze outside of switch
For aesthetics, move the disable of the channel freeze for the PCI-1752 and PCI-1756 boards out of the switch used to disable and clear interrupts. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 231fa73..80c34aa 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -303,6 +303,10 @@ static int pci_dio_reset(struct comedi_device *dev) { const struct dio_boardtype *board = dev->board_ptr; + /* disable channel freeze function on the PCI-1752/1756 boards */ + if (board->cardtype == TYPE_PCI1752 || board->cardtype == TYPE_PCI1756) + outw(0, dev->iobase + PCI1752_6_CFC); + switch (board->cardtype) { case TYPE_PCI1730: case TYPE_PCI1733: @@ -330,10 +334,6 @@ static int pci_dio_reset(struct comedi_device *dev) /* disable & clear interrupts */ outb(0x88, dev->iobase + PCI1750_ICR); break; - case TYPE_PCI1752: - outw(0, dev->iobase + PCI1752_6_CFC); /* disable channel freeze - * function */ - break; case TYPE_PCI1753E: outb(0x88, dev->iobase + PCI1753E_ICR0); /* disable & clear * interrupts */ @@ -356,8 +356,6 @@ static int pci_dio_reset(struct comedi_device *dev) outw(0x08, dev->iobase + PCI1754_ICR3); break; case TYPE_PCI1756: - outw(0, dev->iobase + PCI1752_6_CFC); /* disable channel freeze - * function */ outw(0x08, dev->iobase + PCI1754_6_ICR0); /* disable and clear * interrupts */ outw(0x08, dev->iobase + PCI1754_6_ICR1); -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 07/33] staging: comedi: adv_pci_dio: absorb pci_dio_add_di()
This function initializes a digitial input subdevices. For aesthetics, absorb it into the (*auto_attach). Remove the improper initialization of the SDF_LSAMPL subdev_flag and len_chanlist. These are only used by subdevices that support async commands. Also, remove the unnecessary 'specflags' from the diosubd_data. Only the boardid subdevice uses it. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 127 +-- 1 file changed, 62 insertions(+), 65 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index deac3a8..b0bbc73 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -136,7 +136,6 @@ struct diosubd_data { int addr; /* PCI address ofset */ int regs; /* number of registers to read or 8255 subdevices */ - unsigned int specflags; /* addon subdevice flags */ }; struct dio_boardtype { @@ -156,36 +155,36 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1730", .cardtype = TYPE_PCI1730, .nsubdevs = 5, - .sdi[0] = { 16, PCI1730_DI, 2, 0, }, - .sdi[1] = { 16, PCI1730_IDI, 2, 0, }, - .sdo[0] = { 16, PCI1730_DO, 2, 0, }, - .sdo[1] = { 16, PCI1730_IDO, 2, 0, }, - .boardid= { 4, PCI173x_BOARDID, 1, SDF_INTERNAL, }, + .sdi[0] = { 16, PCI1730_DI, 2, }, + .sdi[1] = { 16, PCI1730_IDI, 2, }, + .sdo[0] = { 16, PCI1730_DO, 2, }, + .sdo[1] = { 16, PCI1730_IDO, 2, }, + .boardid= { 4, PCI173x_BOARDID, 1, }, .io_access = IO_8b, }, [TYPE_PCI1733] = { .name = "pci1733", .cardtype = TYPE_PCI1733, .nsubdevs = 2, - .sdi[1] = { 32, PCI1733_IDI, 4, 0, }, - .boardid= { 4, PCI173x_BOARDID, 1, SDF_INTERNAL, }, + .sdi[1] = { 32, PCI1733_IDI, 4, }, + .boardid= { 4, PCI173x_BOARDID, 1, }, .io_access = IO_8b, }, [TYPE_PCI1734] = { .name = "pci1734", .cardtype = TYPE_PCI1734, .nsubdevs = 2, - .sdo[1] = { 32, PCI1734_IDO, 4, 0, }, - .boardid= { 4, PCI173x_BOARDID, 1, SDF_INTERNAL, }, + .sdo[1] = { 32, PCI1734_IDO, 4, }, + .boardid= { 4, PCI173x_BOARDID, 1, }, .io_access = IO_8b, }, [TYPE_PCI1735] = { .name = "pci1735", .cardtype = TYPE_PCI1735, .nsubdevs = 4, - .sdi[0] = { 32, PCI1735_DI, 4, 0, }, - .sdo[0] = { 32, PCI1735_DO, 4, 0, }, - .boardid= { 4, PCI1735_BOARDID, 1, SDF_INTERNAL, }, + .sdi[0] = { 32, PCI1735_DI, 4, }, + .sdo[0] = { 32, PCI1735_DO, 4, }, + .boardid= { 4, PCI1735_BOARDID, 1, }, .timer_regbase = PCI1735_C8254, .io_access = IO_8b, }, @@ -193,31 +192,31 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1736", .cardtype = TYPE_PCI1736, .nsubdevs = 3, - .sdi[1] = { 16, PCI1736_IDI, 2, 0, }, - .sdo[1] = { 16, PCI1736_IDO, 2, 0, }, - .boardid= { 4, PCI1736_BOARDID, 1, SDF_INTERNAL, }, + .sdi[1] = { 16, PCI1736_IDI, 2, }, + .sdo[1] = { 16, PCI1736_IDO, 2, }, + .boardid= { 4, PCI1736_BOARDID, 1, }, .io_access = IO_8b, }, [TYPE_PCI1739] = { .name = "pci1739", .cardtype = TYPE_PCI1739, .nsubdevs = 2, - .sdio[0]= { 48, PCI1739_DIO, 2, 0, }, + .sdio[0]= { 48, PCI1739_DIO, 2, }, .io_access = IO_8b, }, [TYPE_PCI1750] = { .name = "pci1750", .cardtype = TYPE_PCI1750, .nsubdevs = 2, - .sdi[1] = { 16, PCI1750_IDI, 2, 0, }, - .sdo[1] = { 16, PCI1750_IDO, 2, 0, }, + .sdi[1] = { 16, PCI1750_IDI, 2, }, + .sdo[1] = { 16, PCI1750_IDO, 2, }, .io_access = IO_8b, }, [TYPE_PCI1751] =
[PATCH 33/33] staging: comedi: adv_pci_dio: update the MODULE_DESCRIPTION
Change the MODULE_DESCRIPTION to something more useful than the generic "Comedi low-level driver". Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index f8e9bf9..620cec1 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -510,5 +510,5 @@ static struct pci_driver adv_pci_dio_pci_driver = { module_comedi_pci_driver(adv_pci_dio_driver, adv_pci_dio_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org";); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi driver for Advantech Digital I/O Cards"); MODULE_LICENSE("GPL"); -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 28/33] staging: comedi: adv_pci_dio: remove boardinfo 'cardtype'
This member of the boardinfo is identical to the offset of the boardinfo in the boardtypes array. It's also passed as the 'context' to the driver (*auto_attach). The 'cardtype' is only needed by the (*auto_attach) to determine which PCI BAR to use and in pci_dio_reset() to handle the board specific code. Remove the 'cardtype' member and use the 'context' value instead. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 31 +++- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 6fafc24..21df123 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -80,7 +80,6 @@ struct diosubd_data { struct dio_boardtype { const char *name; /* board name */ - enum hw_cards_id cardtype; int nsubdevs; struct diosubd_data sdi[MAX_DI_SUBDEVS];/* DI chans */ struct diosubd_data sdo[MAX_DO_SUBDEVS];/* DO chans */ @@ -93,7 +92,6 @@ struct dio_boardtype { static const struct dio_boardtype boardtypes[] = { [TYPE_PCI1730] = { .name = "pci1730", - .cardtype = TYPE_PCI1730, .nsubdevs = 5, .sdi[0] = { 16, 0x02, },/* DI 0-15 */ .sdi[1] = { 16, 0x00, },/* ISO DI 0-15 */ @@ -103,21 +101,18 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1733] = { .name = "pci1733", - .cardtype = TYPE_PCI1733, .nsubdevs = 2, .sdi[1] = { 32, 0x00, },/* ISO DI 0-31 */ .id_reg = 0x04, }, [TYPE_PCI1734] = { .name = "pci1734", - .cardtype = TYPE_PCI1734, .nsubdevs = 2, .sdo[1] = { 32, 0x00, },/* ISO DO 0-31 */ .id_reg = 0x04, }, [TYPE_PCI1735] = { .name = "pci1735", - .cardtype = TYPE_PCI1735, .nsubdevs = 4, .sdi[0] = { 32, 0x00, },/* DI 0-31 */ .sdo[0] = { 32, 0x00, },/* DO 0-31 */ @@ -126,7 +121,6 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1736] = { .name = "pci1736", - .cardtype = TYPE_PCI1736, .nsubdevs = 3, .sdi[1] = { 16, 0x00, },/* ISO DI 0-15 */ .sdo[1] = { 16, 0x00, },/* ISO DO 0-15 */ @@ -134,28 +128,24 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1739] = { .name = "pci1739", - .cardtype = TYPE_PCI1739, .nsubdevs = 3, .sdio[0]= { 2, 0x00, }, /* 8255 DIO */ .id_reg = 0x08, }, [TYPE_PCI1750] = { .name = "pci1750", - .cardtype = TYPE_PCI1750, .nsubdevs = 2, .sdi[1] = { 16, 0x00, },/* ISO DI 0-15 */ .sdo[1] = { 16, 0x00, },/* ISO DO 0-15 */ }, [TYPE_PCI1751] = { .name = "pci1751", - .cardtype = TYPE_PCI1751, .nsubdevs = 3, .sdio[0]= { 2, 0x00, }, /* 8255 DIO */ .timer_regbase = 0x18, }, [TYPE_PCI1752] = { .name = "pci1752", - .cardtype = TYPE_PCI1752, .nsubdevs = 3, .sdo[0] = { 32, 0x00, },/* DO 0-31 */ .sdo[1] = { 32, 0x04, },/* DO 32-63 */ @@ -164,20 +154,17 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1753] = { .name = "pci1753", - .cardtype = TYPE_PCI1753, .nsubdevs = 4, .sdio[0]= { 4, 0x00, }, /* 8255 DIO */ }, [TYPE_PCI1753E] = { .name = "pci1753e", - .cardtype = TYPE_PCI1753E, .nsubdevs = 8, .sdio[0]= { 4, 0x00, }, /* 8255 DIO */ .sdio[1]= { 4, 0x20, }, /* 8255 DIO */ }, [TYPE_PCI1754] = { .name = "pci1754", - .cardtype = TYPE_PCI1754, .nsubdevs = 3, .sdi[0] = { 32, 0x00, },/* DI 0-31 */
[PATCH 24/33] staging: comedi: adv_pci_dio: cleanup PCI-1753 interrupt register defines
For aesthetics, replace these defines with some macros. Refactor the switch in pci_dio_reset() to not require the fallthrough comment. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 33 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index c216f39..df60503 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -60,15 +60,9 @@ enum hw_cards_id { /* PCI-1739U, PCI-1750, PCI1751 interrupt control registers */ #define PCI1750_INT_REG0x20/* R/W: status/control */ -/* Advantech PCI-1751/3/3E */ -#define PCI1753_ICR0 16/* R/W: Interrupt control register group 0 */ -#define PCI1753_ICR1 17/* R/W: Interrupt control register group 1 */ -#define PCI1753_ICR2 18/* R/W: Interrupt control register group 2 */ -#define PCI1753_ICR3 19/* R/W: Interrupt control register group 3 */ -#define PCI1753E_ICR048/* R/W: Interrupt control register group 0 */ -#define PCI1753E_ICR149/* R/W: Interrupt control register group 1 */ -#define PCI1753E_ICR250/* R/W: Interrupt control register group 2 */ -#define PCI1753E_ICR351/* R/W: Interrupt control register group 3 */ +/* PCI-1753, PCI-1753E interrupt control registers */ +#define PCI1753_INT_REG(x) (0x10 + (x)) /* R/W: control group 0 to 3 */ +#define PCI1753E_INT_REG(x)(0x30 + (x)) /* R/W: control group 0 to 3 */ /* Advantech PCI-1752/4/6 */ #define PCI1754_6_ICR0 0x08/* R/W: Interrupt control register group 0 */ @@ -310,17 +304,18 @@ static int pci_dio_reset(struct comedi_device *dev) case TYPE_PCI1751: outb(0x88, dev->iobase + PCI1750_INT_REG); break; - case TYPE_PCI1753E: - outb(0x88, dev->iobase + PCI1753E_ICR0); - outb(0x80, dev->iobase + PCI1753E_ICR1); - outb(0x80, dev->iobase + PCI1753E_ICR2); - outb(0x80, dev->iobase + PCI1753E_ICR3); - /* fallthrough */ case TYPE_PCI1753: - outb(0x88, dev->iobase + PCI1753_ICR0); - outb(0x80, dev->iobase + PCI1753_ICR1); - outb(0x80, dev->iobase + PCI1753_ICR2); - outb(0x80, dev->iobase + PCI1753_ICR3); + case TYPE_PCI1753E: + outb(0x88, dev->iobase + PCI1753_INT_REG(0)); + outb(0x80, dev->iobase + PCI1753_INT_REG(1)); + outb(0x80, dev->iobase + PCI1753_INT_REG(2)); + outb(0x80, dev->iobase + PCI1753_INT_REG(3)); + if (board->cardtype == TYPE_PCI1753E) { + outb(0x88, dev->iobase + PCI1753E_INT_REG(0)); + outb(0x80, dev->iobase + PCI1753E_INT_REG(1)); + outb(0x80, dev->iobase + PCI1753E_INT_REG(2)); + outb(0x80, dev->iobase + PCI1753E_INT_REG(3)); + } break; case TYPE_PCI1754: outw(0x08, dev->iobase + PCI1754_6_ICR0); -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 21/33] staging: comedi: adv_pci_dio: cleanup "disable and clear interrupts" comments
For aesthetics, use a common comment for the switch() that disables and clears interrupts. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 24 ++-- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 80c34aa..8fb03e2 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -307,62 +307,50 @@ static int pci_dio_reset(struct comedi_device *dev) if (board->cardtype == TYPE_PCI1752 || board->cardtype == TYPE_PCI1756) outw(0, dev->iobase + PCI1752_6_CFC); + /* disable and clear interrupts */ switch (board->cardtype) { case TYPE_PCI1730: case TYPE_PCI1733: - /* disable interrupts */ outb(0, dev->iobase + PCI1730_3_INT_EN); - /* clear interrupts */ outb(0x0f, dev->iobase + PCI1730_3_INT_CLR); - /* set rising edge trigger */ outb(0, dev->iobase + PCI1730_3_INT_RF); break; case TYPE_PCI1736: - /* disable interrupts */ outb(0, dev->iobase + PCI1736_3_INT_EN); - /* clear interrupts */ outb(0x0f, dev->iobase + PCI1736_3_INT_CLR); - /* set rising edge trigger */ outb(0, dev->iobase + PCI1736_3_INT_RF); break; case TYPE_PCI1739: - /* disable & clear interrupts */ outb(0x88, dev->iobase + PCI1739_ICR); break; case TYPE_PCI1750: case TYPE_PCI1751: - /* disable & clear interrupts */ outb(0x88, dev->iobase + PCI1750_ICR); break; case TYPE_PCI1753E: - outb(0x88, dev->iobase + PCI1753E_ICR0); /* disable & clear - * interrupts */ + outb(0x88, dev->iobase + PCI1753E_ICR0); outb(0x80, dev->iobase + PCI1753E_ICR1); outb(0x80, dev->iobase + PCI1753E_ICR2); outb(0x80, dev->iobase + PCI1753E_ICR3); /* fallthrough */ case TYPE_PCI1753: - outb(0x88, dev->iobase + PCI1753_ICR0); /* disable & clear -* interrupts */ + outb(0x88, dev->iobase + PCI1753_ICR0); outb(0x80, dev->iobase + PCI1753_ICR1); outb(0x80, dev->iobase + PCI1753_ICR2); outb(0x80, dev->iobase + PCI1753_ICR3); break; case TYPE_PCI1754: - outw(0x08, dev->iobase + PCI1754_6_ICR0); /* disable and clear - * interrupts */ + outw(0x08, dev->iobase + PCI1754_6_ICR0); outw(0x08, dev->iobase + PCI1754_6_ICR1); outw(0x08, dev->iobase + PCI1754_ICR2); outw(0x08, dev->iobase + PCI1754_ICR3); break; case TYPE_PCI1756: - outw(0x08, dev->iobase + PCI1754_6_ICR0); /* disable and clear - * interrupts */ + outw(0x08, dev->iobase + PCI1754_6_ICR0); outw(0x08, dev->iobase + PCI1754_6_ICR1); break; case TYPE_PCI1762: - outw(0x0101, dev->iobase + PCI1762_ICR); /* disable & clear - * interrupts */ + outw(0x0101, dev->iobase + PCI1762_ICR); break; default: break; -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 22/33] staging: comedi: adv_pci_dio: use common defines for PCI-173[036] registers
These boards use the same offsets for the interrupt control registers. For aesthetics, remove the current defines and use common ones. Fix the switch() in pci_dio_reset() to use common code. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 30 ++-- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 8fb03e2..fae0a0b 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -48,18 +48,14 @@ enum hw_cards_id { #define MAX_DIO_SUBDEVG2 /* max number of DIO subdevices group per * card */ -/* Register offset definitions */ -/* Advantech PCI-1730/3/4 */ -#definePCI1730_3_INT_EN0x08/* R/W: enable/disable interrupts */ -#definePCI1730_3_INT_RF0x0c/* R/W: set falling/raising edge for -* interrupts */ -#definePCI1730_3_INT_CLR 0x10/* R/W: clear interrupts */ - -/* Advantech PCI-1736UP */ -#define PCI1736_3_INT_EN0x08 /* R/W: enable/disable interrupts */ -#define PCI1736_3_INT_RF0x0c /* R/W: set falling/raising edge for -* interrupts */ -#define PCI1736_3_INT_CLR 0x10 /* R/W: clear interrupts */ +/* + * Register offset definitions + */ + +/* PCI-1730, PCI-1733, PCI-1736 interrupt control registers */ +#define PCI173X_INT_EN_REG 0x08/* R/W: enable/disable */ +#define PCI173X_INT_RF_REG 0x0c/* R/W: falling/rising edge */ +#define PCI173X_INT_CLR_REG0x10/* R/W: clear */ /* Advantech PCI-1739U */ #define PCI1739_ICR 32/* W: Interrupt control register */ @@ -311,14 +307,10 @@ static int pci_dio_reset(struct comedi_device *dev) switch (board->cardtype) { case TYPE_PCI1730: case TYPE_PCI1733: - outb(0, dev->iobase + PCI1730_3_INT_EN); - outb(0x0f, dev->iobase + PCI1730_3_INT_CLR); - outb(0, dev->iobase + PCI1730_3_INT_RF); - break; case TYPE_PCI1736: - outb(0, dev->iobase + PCI1736_3_INT_EN); - outb(0x0f, dev->iobase + PCI1736_3_INT_CLR); - outb(0, dev->iobase + PCI1736_3_INT_RF); + outb(0, dev->iobase + PCI173X_INT_EN_REG); + outb(0x0f, dev->iobase + PCI173X_INT_CLR_REG); + outb(0, dev->iobase + PCI173X_INT_RF_REG); break; case TYPE_PCI1739: outb(0x88, dev->iobase + PCI1739_ICR); -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 27/33] staging: comedi: adv_pci_dio: cleanup PCI-1762 interrupt registers
For aesthetics, use a common define for the interrupt control and status registers. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 5aba40e..6fafc24 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -70,9 +70,8 @@ enum hw_cards_id { /* PCI-1752, PCI-1756 special registers */ #define PCI1752_CFC_REG0x12/* R/W: channel freeze function */ -/* Advantech PCI-1762 registers */ -#define PCI1762_ICR 6/* W: Interrupt control register */ -#define PCI1762_ISR 6/* R: Interrupt status register */ +/* PCI-1762 interrupt control registers */ +#define PCI1762_INT_REG0x06/* R/W: status/control */ struct diosubd_data { int chans; /* num of chans or 8255 devices */ @@ -326,7 +325,7 @@ static int pci_dio_reset(struct comedi_device *dev) } break; case TYPE_PCI1762: - outw(0x0101, dev->iobase + PCI1762_ICR); + outw(0x0101, dev->iobase + PCI1762_INT_REG); break; default: break; -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 23/33] staging: comedi: adv_pci_dio: use common defines for PCI-1739/175[01] registers
These boards use the same offsets for the interrupt control registers. For aesthetics, remove the current defines and use common ones. Fix the switch() in pci_dio_reset() to use common code. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 15 +++ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index fae0a0b..c216f39 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -57,17 +57,10 @@ enum hw_cards_id { #define PCI173X_INT_RF_REG 0x0c/* R/W: falling/rising edge */ #define PCI173X_INT_CLR_REG0x10/* R/W: clear */ -/* Advantech PCI-1739U */ -#define PCI1739_ICR 32/* W: Interrupt control register */ -#define PCI1739_ISR 32/* R: Interrupt status register */ - -/* Advantech PCI-1750 */ -#define PCI1750_ICR 32/* W: Interrupt control register */ -#define PCI1750_ISR 32/* R: Interrupt status register */ +/* PCI-1739U, PCI-1750, PCI1751 interrupt control registers */ +#define PCI1750_INT_REG0x20/* R/W: status/control */ /* Advantech PCI-1751/3/3E */ -#define PCI1751_ICR 32/* W: Interrupt control register */ -#define PCI1751_ISR 32/* R: Interrupt status register */ #define PCI1753_ICR0 16/* R/W: Interrupt control register group 0 */ #define PCI1753_ICR1 17/* R/W: Interrupt control register group 1 */ #define PCI1753_ICR2 18/* R/W: Interrupt control register group 2 */ @@ -313,11 +306,9 @@ static int pci_dio_reset(struct comedi_device *dev) outb(0, dev->iobase + PCI173X_INT_RF_REG); break; case TYPE_PCI1739: - outb(0x88, dev->iobase + PCI1739_ICR); - break; case TYPE_PCI1750: case TYPE_PCI1751: - outb(0x88, dev->iobase + PCI1750_ICR); + outb(0x88, dev->iobase + PCI1750_INT_REG); break; case TYPE_PCI1753E: outb(0x88, dev->iobase + PCI1753E_ICR0); -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 29/33] staging: comedi: adv_pci_dio: move and rename enum hw_cards_id
For aesthetics, move this enum after the register defines and rename it to have namespace associated with the driver. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 29 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 21df123..2f89cbe 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -31,18 +31,6 @@ #include "8255.h" #include "comedi_8254.h" -/* hardware types of the cards */ -enum hw_cards_id { - TYPE_PCI1730, TYPE_PCI1733, TYPE_PCI1734, TYPE_PCI1735, TYPE_PCI1736, - TYPE_PCI1739, - TYPE_PCI1750, - TYPE_PCI1751, - TYPE_PCI1752, - TYPE_PCI1753, TYPE_PCI1753E, - TYPE_PCI1754, TYPE_PCI1756, - TYPE_PCI1762 -}; - #define MAX_DI_SUBDEVS 2 /* max number of DI subdevices per card */ #define MAX_DO_SUBDEVS 2 /* max number of DO subdevices per card */ #define MAX_DIO_SUBDEVG2 /* max number of DIO subdevices group per @@ -73,6 +61,23 @@ enum hw_cards_id { /* PCI-1762 interrupt control registers */ #define PCI1762_INT_REG0x06/* R/W: status/control */ +enum pci_dio_boardid { + TYPE_PCI1730, + TYPE_PCI1733, + TYPE_PCI1734, + TYPE_PCI1735, + TYPE_PCI1736, + TYPE_PCI1739, + TYPE_PCI1750, + TYPE_PCI1751, + TYPE_PCI1752, + TYPE_PCI1753, + TYPE_PCI1753E, + TYPE_PCI1754, + TYPE_PCI1756, + TYPE_PCI1762 +}; + struct diosubd_data { int chans; /* num of chans or 8255 devices */ unsigned long addr; /* PCI address ofset */ -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 10/33] staging: comedi: adv_pci_dio: use the diosubd_data 'addr' for di/do s->private
Currently the di/do subdevices store a pointer to the diosubd_data in s->private. The (*insn_bits) functions then use that to get to the 'addr' needed to access the registers. The only member of diosubd_data that is needed by the (*insn_bits) functions is the 'addr'. For aesthetics, just store the 'addr' in s->private. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index e620e34..51611c7 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -128,7 +128,7 @@ enum hw_cards_id { struct diosubd_data { int chans; /* num of chans or 8255 devices */ - int addr; /* PCI address ofset */ + unsigned long addr; /* PCI address ofset */ }; struct dio_boardtype { @@ -261,8 +261,8 @@ static int pci_dio_insn_bits_di_b(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - const struct diosubd_data *d = (const struct diosubd_data *)s->private; - unsigned long iobase = dev->iobase + d->addr; + unsigned long reg = (unsigned long)s->private; + unsigned long iobase = dev->iobase + reg; data[1] = inb(iobase); if (s->n_chan > 8) @@ -280,8 +280,8 @@ static int pci_dio_insn_bits_di_w(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - const struct diosubd_data *d = (const struct diosubd_data *)s->private; - unsigned long iobase = dev->iobase + d->addr; + unsigned long reg = (unsigned long)s->private; + unsigned long iobase = dev->iobase + reg; data[1] = inw(iobase); if (s->n_chan > 16) @@ -295,8 +295,8 @@ static int pci_dio_insn_bits_do_b(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - const struct diosubd_data *d = (const struct diosubd_data *)s->private; - unsigned long iobase = dev->iobase + d->addr; + unsigned long reg = (unsigned long)s->private; + unsigned long iobase = dev->iobase + reg; if (comedi_dio_update_state(s, data)) { outb(s->state & 0xff, iobase); @@ -318,8 +318,8 @@ static int pci_dio_insn_bits_do_w(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - const struct diosubd_data *d = (const struct diosubd_data *)s->private; - unsigned long iobase = dev->iobase + d->addr; + unsigned long reg = (unsigned long)s->private; + unsigned long iobase = dev->iobase + reg; if (comedi_dio_update_state(s, data)) { outw(s->state & 0x, iobase); @@ -505,7 +505,7 @@ static int pci_dio_auto_attach(struct comedi_device *dev, s->insn_bits= board->is_16bit ? pci_dio_insn_bits_di_w : pci_dio_insn_bits_di_b; - s->private = (void *)d; + s->private = (void *)d->addr; } } @@ -521,7 +521,7 @@ static int pci_dio_auto_attach(struct comedi_device *dev, s->insn_bits= board->is_16bit ? pci_dio_insn_bits_do_w : pci_dio_insn_bits_do_b; - s->private = (void *)d; + s->private = (void *)d->addr; } } @@ -546,7 +546,7 @@ static int pci_dio_auto_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_bits= board->is_16bit ? pci_dio_insn_bits_di_w : pci_dio_insn_bits_di_b; - s->private = (void *)d; + s->private = (void *)d->addr; } if (board->timer_regbase) { -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 16/33] staging: comedi: adv_pci_dio: reset digital outputs in subdevice init
Currently the board reset function also resets the digital output channels to 0. This works but it makes the reset function a bit messy and each board type has to be handled special. Move the digital output reset into the subdevice init where it can be handle based on the subdevice setup. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 36 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 55ca8f9..578c646 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -321,11 +321,6 @@ static int pci_dio_reset(struct comedi_device *dev) switch (board->cardtype) { case TYPE_PCI1730: - outb(0, dev->iobase + PCI1730_DO); /* clear outputs */ - outb(0, dev->iobase + PCI1730_DO + 1); - outb(0, dev->iobase + PCI1730_IDO); - outb(0, dev->iobase + PCI1730_IDO + 1); - /* fallthrough */ case TYPE_PCI1733: /* disable interrupts */ outb(0, dev->iobase + PCI1730_3_INT_EN); @@ -335,21 +330,11 @@ static int pci_dio_reset(struct comedi_device *dev) outb(0, dev->iobase + PCI1730_3_INT_RF); break; case TYPE_PCI1734: - outb(0, dev->iobase + PCI1734_IDO); /* clear outputs */ - outb(0, dev->iobase + PCI1734_IDO + 1); - outb(0, dev->iobase + PCI1734_IDO + 2); - outb(0, dev->iobase + PCI1734_IDO + 3); break; case TYPE_PCI1735: - outb(0, dev->iobase + PCI1735_DO); /* clear outputs */ - outb(0, dev->iobase + PCI1735_DO + 1); - outb(0, dev->iobase + PCI1735_DO + 2); - outb(0, dev->iobase + PCI1735_DO + 3); break; case TYPE_PCI1736: - outb(0, dev->iobase + PCI1736_IDO); - outb(0, dev->iobase + PCI1736_IDO + 1); /* disable interrupts */ outb(0, dev->iobase + PCI1736_3_INT_EN); /* clear interrupts */ @@ -371,10 +356,6 @@ static int pci_dio_reset(struct comedi_device *dev) case TYPE_PCI1752: outw(0, dev->iobase + PCI1752_6_CFC); /* disable channel freeze * function */ - outw(0, dev->iobase + PCI1752_IDO); /* clear outputs */ - outw(0, dev->iobase + PCI1752_IDO + 2); - outw(0, dev->iobase + PCI1752_IDO2); - outw(0, dev->iobase + PCI1752_IDO2 + 2); break; case TYPE_PCI1753E: outb(0x88, dev->iobase + PCI1753E_ICR0); /* disable & clear @@ -403,8 +384,6 @@ static int pci_dio_reset(struct comedi_device *dev) outw(0x08, dev->iobase + PCI1754_6_ICR0); /* disable and clear * interrupts */ outw(0x08, dev->iobase + PCI1754_6_ICR1); - outw(0, dev->iobase + PCI1756_IDO); /* clear outputs */ - outw(0, dev->iobase + PCI1756_IDO + 2); break; case TYPE_PCI1762: outw(0x0101, dev->iobase + PCI1762_ICR); /* disable & clear @@ -507,6 +486,21 @@ static int pci_dio_auto_attach(struct comedi_device *dev, ? pci_dio_insn_bits_do_w : pci_dio_insn_bits_do_b; s->private = (void *)d->addr; + + /* reset all outputs to 0 */ + if (board->is_16bit) { + outw(0, dev->iobase + d->addr); + if (s->n_chan > 16) + outw(0, dev->iobase + d->addr + 2); + } else { + outb(0, dev->iobase + d->addr); + if (s->n_chan > 8) + outb(0, dev->iobase + d->addr + 1); + if (s->n_chan > 16) + outb(0, dev->iobase + d->addr + 2); + if (s->n_chan > 24) + outb(0, dev->iobase + d->addr + 3); + } } } -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 01/33] staging: comedi: adv_pci_dio: remove unnecessary function separation comments
These are not necessary and just add cruft. Remove them. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 9 - 1 file changed, 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 81b2cf2..28ed1cd 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -298,9 +298,6 @@ static const struct dio_boardtype boardtypes[] = { }, }; -/* -== -*/ static int pci_dio_insn_bits_di_b(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -315,9 +312,6 @@ static int pci_dio_insn_bits_di_b(struct comedi_device *dev, return insn->n; } -/* -== -*/ static int pci_dio_insn_bits_di_w(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -497,9 +491,6 @@ static int pci_dio_add_di(struct comedi_device *dev, return 0; } -/* -== -*/ static int pci_dio_add_do(struct comedi_device *dev, struct comedi_subdevice *s, const struct diosubd_data *d) -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 31/33] staging: comedi: adv_pci_dio: move pci_dio_override_cardtype()
This function is called as part of the pci_driver (*probe) before doing the (*auto_attach) of the comedi driver. For aesthetics, move the function to a more logical place in the driver. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 64 ++-- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index f3c9628..b7f13bc 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -322,38 +322,6 @@ static int pci_dio_reset(struct comedi_device *dev, unsigned long cardtype) return 0; } -static unsigned long pci_dio_override_cardtype(struct pci_dev *pcidev, - unsigned long cardtype) -{ - /* -* Change cardtype from TYPE_PCI1753 to TYPE_PCI1753E if expansion -* board available. Need to enable PCI device and request the main -* registers PCI BAR temporarily to perform the test. -*/ - if (cardtype != TYPE_PCI1753) - return cardtype; - if (pci_enable_device(pcidev) < 0) - return cardtype; - if (pci_request_region(pcidev, 2, "adv_pci_dio") == 0) { - /* -* This test is based on Advantech's "advdaq" driver source -* (which declares its module licence as "GPL" although the -* driver source does not include a "COPYING" file). -*/ - unsigned long reg = pci_resource_start(pcidev, 2) + 53; - - outb(0x05, reg); - if ((inb(reg) & 0x07) == 0x02) { - outb(0x02, reg); - if ((inb(reg) & 0x07) == 0x05) - cardtype = TYPE_PCI1753E; - } - pci_release_region(pcidev, 2); - } - pci_disable_device(pcidev); - return cardtype; -} - static int pci_dio_auto_attach(struct comedi_device *dev, unsigned long context) { @@ -477,6 +445,38 @@ static struct comedi_driver adv_pci_dio_driver = { .detach = comedi_pci_detach, }; +static unsigned long pci_dio_override_cardtype(struct pci_dev *pcidev, + unsigned long cardtype) +{ + /* +* Change cardtype from TYPE_PCI1753 to TYPE_PCI1753E if expansion +* board available. Need to enable PCI device and request the main +* registers PCI BAR temporarily to perform the test. +*/ + if (cardtype != TYPE_PCI1753) + return cardtype; + if (pci_enable_device(pcidev) < 0) + return cardtype; + if (pci_request_region(pcidev, 2, "adv_pci_dio") == 0) { + /* +* This test is based on Advantech's "advdaq" driver source +* (which declares its module licence as "GPL" although the +* driver source does not include a "COPYING" file). +*/ + unsigned long reg = pci_resource_start(pcidev, 2) + 53; + + outb(0x05, reg); + if ((inb(reg) & 0x07) == 0x02) { + outb(0x02, reg); + if ((inb(reg) & 0x07) == 0x05) + cardtype = TYPE_PCI1753E; + } + pci_release_region(pcidev, 2); + } + pci_disable_device(pcidev); + return cardtype; +} + static int adv_pci_dio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) { -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 12/33] staging: comedi: adv_pci_dio: remove defines used for the 'timer_regbase'
These defines are only used to initialize the 'timer_regbase' boardinfo. For aesthetics, just open-code the values and remove the defines. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index d24134f..fdb6063 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -64,7 +64,6 @@ enum hw_cards_id { /* Advantech PCI-1735U */ #define PCI1735_DI0/* R: Digital input 0-31 */ #define PCI1735_DO0/* W: Digital output 0-31 */ -#define PCI1735_C8254 4/* R/W: 8254 counter */ /* Advantech PCI-1736UP */ #define PCI1736_IDI0 /* R: Isolated digital input 0-15 */ @@ -87,7 +86,6 @@ enum hw_cards_id { /* Advantech PCI-1751/3/3E */ #define PCI1751_DIO 0/* R/W: begin of 8255 registers block */ -#define PCI1751_CNT 24/* R/W: begin of 8254 registers block */ #define PCI1751_ICR 32/* W: Interrupt control register */ #define PCI1751_ISR 32/* R: Interrupt status register */ #define PCI1753_DIO 0/* R/W: begin of 8255 registers block */ @@ -169,7 +167,7 @@ static const struct dio_boardtype boardtypes[] = { .sdi[0] = { 32, PCI1735_DI, }, .sdo[0] = { 32, PCI1735_DO, }, .id_reg = 0x08, - .timer_regbase = PCI1735_C8254, + .timer_regbase = 0x04, }, [TYPE_PCI1736] = { .name = "pci1736", @@ -198,7 +196,7 @@ static const struct dio_boardtype boardtypes[] = { .cardtype = TYPE_PCI1751, .nsubdevs = 3, .sdio[0]= { 2, PCI1751_DIO, }, - .timer_regbase = PCI1751_CNT, + .timer_regbase = 0x18, }, [TYPE_PCI1752] = { .name = "pci1752", -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 03/33] staging: comedi: adv_pci_dio: remove 'main_pci_region' boardinfo
All the boards use PCI BAR2 for the dev->iobase except for the pci1736 which uses PCI BAR0. Just use the board->cardtype to determine which PCI BAR to use. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 30 +++- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 9794502..b1f966e 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -53,8 +53,6 @@ enum hw_io_access { #define MAX_DIO_SUBDEVG2 /* max number of DIO subdevices group per * card */ -#define PCIDIO_MAINREG2/* main I/O region for all Advantech cards? */ - /* Register offset definitions */ /* Advantech PCI-1730/3/4 */ #define PCI1730_IDI 0/* R: Isolated digital input 0-15 */ @@ -83,7 +81,6 @@ enum hw_io_access { * interrupts */ #define PCI1736_3_INT_CLR 0x10 /* R/W: clear interrupts */ #define PCI1736_BOARDID4 /* R: Board I/D switch for 1736UP */ -#define PCI1736_MAINREG0 /* Normal register (2) doesn't work */ /* Advantech PCI-1739U */ #define PCI1739_DIO 0/* R/W: begin of 8255 registers block */ @@ -144,7 +141,6 @@ struct diosubd_data { struct dio_boardtype { const char *name; /* board name */ - int main_pci_region;/* main I/O PCI region */ enum hw_cards_id cardtype; int nsubdevs; struct diosubd_data sdi[MAX_DI_SUBDEVS];/* DI chans */ @@ -158,7 +154,6 @@ struct dio_boardtype { static const struct dio_boardtype boardtypes[] = { [TYPE_PCI1730] = { .name = "pci1730", - .main_pci_region = PCIDIO_MAINREG, .cardtype = TYPE_PCI1730, .nsubdevs = 5, .sdi[0] = { 16, PCI1730_DI, 2, 0, }, @@ -170,7 +165,6 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1733] = { .name = "pci1733", - .main_pci_region = PCIDIO_MAINREG, .cardtype = TYPE_PCI1733, .nsubdevs = 2, .sdi[1] = { 32, PCI1733_IDI, 4, 0, }, @@ -179,7 +173,6 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1734] = { .name = "pci1734", - .main_pci_region = PCIDIO_MAINREG, .cardtype = TYPE_PCI1734, .nsubdevs = 2, .sdo[1] = { 32, PCI1734_IDO, 4, 0, }, @@ -188,7 +181,6 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1735] = { .name = "pci1735", - .main_pci_region = PCIDIO_MAINREG, .cardtype = TYPE_PCI1735, .nsubdevs = 4, .sdi[0] = { 32, PCI1735_DI, 4, 0, }, @@ -199,7 +191,6 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1736] = { .name = "pci1736", - .main_pci_region = PCI1736_MAINREG, .cardtype = TYPE_PCI1736, .nsubdevs = 3, .sdi[1] = { 16, PCI1736_IDI, 2, 0, }, @@ -209,7 +200,6 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1739] = { .name = "pci1739", - .main_pci_region = PCIDIO_MAINREG, .cardtype = TYPE_PCI1739, .nsubdevs = 2, .sdio[0]= { 48, PCI1739_DIO, 2, 0, }, @@ -217,7 +207,6 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1750] = { .name = "pci1750", - .main_pci_region = PCIDIO_MAINREG, .cardtype = TYPE_PCI1750, .nsubdevs = 2, .sdi[1] = { 16, PCI1750_IDI, 2, 0, }, @@ -226,7 +215,6 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1751] = { .name = "pci1751", - .main_pci_region = PCIDIO_MAINREG, .cardtype = TYPE_PCI1751, .nsubdevs = 3, .sdio[0]= { 48, PCI1751_DIO, 2, 0, }, @@ -235,7 +223,6 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1752] = { .name = "pci1752", - .main_pci_region = PCIDIO_MAINREG, .cardtype = TYPE_PCI1752, .nsubdevs = 3, .sdo[0] = { 32, PCI1752_IDO, 2, 0, }, @@ -245,7 +232,6 @@ static const struct dio_boardtype boardtypes[] = { }, [TYPE_PCI1753] = {
[PATCH 18/33] staging: comedi: adv_pci_dio: remove defines used for the dio (8255) registers
These defines are only used to initialize the diosubd_data 'addr' members in the boardinfo. For aesthetics, just open-code the values and remove the defines. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index a72b04e..c564b69 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -62,7 +62,6 @@ enum hw_cards_id { #define PCI1736_3_INT_CLR 0x10 /* R/W: clear interrupts */ /* Advantech PCI-1739U */ -#define PCI1739_DIO 0/* R/W: begin of 8255 registers block */ #define PCI1739_ICR 32/* W: Interrupt control register */ #define PCI1739_ISR 32/* R: Interrupt status register */ @@ -71,15 +70,12 @@ enum hw_cards_id { #define PCI1750_ISR 32/* R: Interrupt status register */ /* Advantech PCI-1751/3/3E */ -#define PCI1751_DIO 0/* R/W: begin of 8255 registers block */ #define PCI1751_ICR 32/* W: Interrupt control register */ #define PCI1751_ISR 32/* R: Interrupt status register */ -#define PCI1753_DIO 0/* R/W: begin of 8255 registers block */ #define PCI1753_ICR0 16/* R/W: Interrupt control register group 0 */ #define PCI1753_ICR1 17/* R/W: Interrupt control register group 1 */ #define PCI1753_ICR2 18/* R/W: Interrupt control register group 2 */ #define PCI1753_ICR3 19/* R/W: Interrupt control register group 3 */ -#define PCI1753E_DIO 32/* R/W: begin of 8255 registers block */ #define PCI1753E_ICR048/* R/W: Interrupt control register group 0 */ #define PCI1753E_ICR149/* R/W: Interrupt control register group 1 */ #define PCI1753E_ICR250/* R/W: Interrupt control register group 2 */ @@ -159,7 +155,7 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1739", .cardtype = TYPE_PCI1739, .nsubdevs = 3, - .sdio[0]= { 2, PCI1739_DIO, }, + .sdio[0]= { 2, 0x00, }, /* 8255 DIO */ .id_reg = 0x08, }, [TYPE_PCI1750] = { @@ -173,7 +169,7 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1751", .cardtype = TYPE_PCI1751, .nsubdevs = 3, - .sdio[0]= { 2, PCI1751_DIO, }, + .sdio[0]= { 2, 0x00, }, /* 8255 DIO */ .timer_regbase = 0x18, }, [TYPE_PCI1752] = { @@ -189,14 +185,14 @@ static const struct dio_boardtype boardtypes[] = { .name = "pci1753", .cardtype = TYPE_PCI1753, .nsubdevs = 4, - .sdio[0]= { 4, PCI1753_DIO, }, + .sdio[0]= { 4, 0x00, }, /* 8255 DIO */ }, [TYPE_PCI1753E] = { .name = "pci1753e", .cardtype = TYPE_PCI1753E, .nsubdevs = 8, - .sdio[0]= { 4, PCI1753_DIO, }, - .sdio[1]= { 4, PCI1753E_DIO, }, + .sdio[0]= { 4, 0x00, }, /* 8255 DIO */ + .sdio[1]= { 4, 0x20, }, /* 8255 DIO */ }, [TYPE_PCI1754] = { .name = "pci1754", -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 19/33] staging: comedi: adv_pci_dio: use a default case in pci_dio_reset()
For aesthetics, use a default case in the switch (board->cardtype) used to reset the various boards. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index c564b69..231fa73 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -313,11 +313,6 @@ static int pci_dio_reset(struct comedi_device *dev) /* set rising edge trigger */ outb(0, dev->iobase + PCI1730_3_INT_RF); break; - case TYPE_PCI1734: - break; - case TYPE_PCI1735: - break; - case TYPE_PCI1736: /* disable interrupts */ outb(0, dev->iobase + PCI1736_3_INT_EN); @@ -326,12 +321,10 @@ static int pci_dio_reset(struct comedi_device *dev) /* set rising edge trigger */ outb(0, dev->iobase + PCI1736_3_INT_RF); break; - case TYPE_PCI1739: /* disable & clear interrupts */ outb(0x88, dev->iobase + PCI1739_ICR); break; - case TYPE_PCI1750: case TYPE_PCI1751: /* disable & clear interrupts */ @@ -373,6 +366,8 @@ static int pci_dio_reset(struct comedi_device *dev) outw(0x0101, dev->iobase + PCI1762_ICR); /* disable & clear * interrupts */ break; + default: + break; } return 0; -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 30/33] staging: comedi: adv_pci_dio: move and rename the MAX_*_SUBDEV[SG] defines
For aesthetics, move these defines after the register defines and rename them to have namespace associated with the driver. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci_dio.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 2f89cbe..f3c9628 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -31,11 +31,6 @@ #include "8255.h" #include "comedi_8254.h" -#define MAX_DI_SUBDEVS 2 /* max number of DI subdevices per card */ -#define MAX_DO_SUBDEVS 2 /* max number of DO subdevices per card */ -#define MAX_DIO_SUBDEVG2 /* max number of DIO subdevices group per -* card */ - /* * Register offset definitions */ @@ -61,6 +56,11 @@ /* PCI-1762 interrupt control registers */ #define PCI1762_INT_REG0x06/* R/W: status/control */ +/* maximum number of subdevice descriptions in the boardinfo */ +#define PCI_DIO_MAX_DI_SUBDEVS 2 /* 2 x 8/16/32 input channels max */ +#define PCI_DIO_MAX_DO_SUBDEVS 2 /* 2 x 8/16/32 output channels max */ +#define PCI_DIO_MAX_DIO_SUBDEVG2 /* 2 x any number of 8255 devices max */ + enum pci_dio_boardid { TYPE_PCI1730, TYPE_PCI1733, @@ -86,9 +86,9 @@ struct diosubd_data { struct dio_boardtype { const char *name; /* board name */ int nsubdevs; - struct diosubd_data sdi[MAX_DI_SUBDEVS];/* DI chans */ - struct diosubd_data sdo[MAX_DO_SUBDEVS];/* DO chans */ - struct diosubd_data sdio[MAX_DIO_SUBDEVG]; /* DIO 8255 chans */ + struct diosubd_data sdi[PCI_DIO_MAX_DI_SUBDEVS]; + struct diosubd_data sdo[PCI_DIO_MAX_DO_SUBDEVS]; + struct diosubd_data sdio[PCI_DIO_MAX_DIO_SUBDEVG]; unsigned long id_reg; unsigned long timer_regbase; unsigned int is_16bit:1; @@ -385,7 +385,7 @@ static int pci_dio_auto_attach(struct comedi_device *dev, return ret; subdev = 0; - for (i = 0; i < MAX_DI_SUBDEVS; i++) { + for (i = 0; i < PCI_DIO_MAX_DI_SUBDEVS; i++) { d = &board->sdi[i]; if (d->chans) { s = &dev->subdevices[subdev++]; @@ -401,7 +401,7 @@ static int pci_dio_auto_attach(struct comedi_device *dev, } } - for (i = 0; i < MAX_DO_SUBDEVS; i++) { + for (i = 0; i < PCI_DIO_MAX_DO_SUBDEVS; i++) { d = &board->sdo[i]; if (d->chans) { s = &dev->subdevices[subdev++]; @@ -432,7 +432,7 @@ static int pci_dio_auto_attach(struct comedi_device *dev, } } - for (i = 0; i < MAX_DIO_SUBDEVG; i++) { + for (i = 0; i < PCI_DIO_MAX_DIO_SUBDEVG; i++) { d = &board->sdio[i]; for (j = 0; j < d->chans; j++) { s = &dev->subdevices[subdev++]; -- 2.5.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: media: bcm2048: fix brace coding style issue in radio-bcm2048.c
On Wed, Nov 18, 2015 at 09:25:22PM +0530, Jitendra Kumar Khasdev wrote: > This is a patch to the radio-bcm2048.c file that fixes up a brace warning > found by the checkpatch.pl tool. > > Signed-off-by: Jitendra Kumar Khasdev > --- > drivers/staging/media/bcm2048/radio-bcm2048.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c > b/drivers/staging/media/bcm2048/radio-bcm2048.c > index b10d601..6226e02 100644 > --- a/drivers/staging/media/bcm2048/radio-bcm2048.c > +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c > @@ -2021,8 +2021,8 @@ static ssize_t bcm2048_##prop##_read(struct device > *dev,\ > } > > #define DEFINE_SYSFS_PROPERTY(prop, signal, size, mask, check) > \ > -property_write(prop, signal size, mask, check) > \ > -property_read(prop, size, mask) > +(property_write(prop, signal size, mask, check) > \ > +property_read(prop, size, mask)) You didn't even test-build this patch, why not? ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: linux-4.4-rc1/drivers/staging/rts5208/sd.c:4170: bad if test ?
On Wed, Nov 18, 2015 at 08:53:51AM +, David Binderman wrote: > hello there, > > [linux-4.4-rc1/drivers/staging/rts5208/sd.c:4170]: (style) Expression '(X & > 0x1e) != 0x3' is always true. > > Source code is > > if ((ptr[3] & 0x1E) != 0x03) { > > Suggest code rework. Great, please send a patch fixing this! thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: linux-4.4-rc1/drivers/staging/rts5208/sd.c:4170: bad if test ?
On Wed, Nov 18, 2015 at 05:25:38PM +, David Binderman wrote: > Hello there Greg, > > > > Date: Wed, 18 Nov 2015 09:14:41 -0800 > > From: gre...@linuxfoundation.org > > To: dcb...@hotmail.com > > CC: de...@driverdev.osuosl.org > > Subject: Re: linux-4.4-rc1/drivers/staging/rts5208/sd.c:4170: bad if test ? > > > > On Wed, Nov 18, 2015 at 08:53:51AM +, David Binderman wrote: > >> hello there, > >> > >> [linux-4.4-rc1/drivers/staging/rts5208/sd.c:4170]: (style) Expression '(X > >> & 0x1e) != 0x3' is always true. > >> > >> Source code is > >> > >> if ((ptr[3] & 0x1E) != 0x03) { > >> > >> Suggest code rework. > > > > Great, please send a patch fixing this! > > Sorry, not possible. I can't meet the strict requirements of kernel patches, > due to my hotmail account messing up white space. Use hotmail as an imap server for 'git send-email' or use one of many other free email providers that will not damage whitespace. greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: media: bcm2048: fix brace coding style issue in radio-bcm2048.c
On Wednesday 18 November 2015 10:42 PM, Greg KH wrote: > On Wed, Nov 18, 2015 at 09:25:22PM +0530, Jitendra Kumar Khasdev wrote: >> This is a patch to the radio-bcm2048.c file that fixes up a brace warning >> found by the checkpatch.pl tool. >> >> Signed-off-by: Jitendra Kumar Khasdev >> --- >> drivers/staging/media/bcm2048/radio-bcm2048.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c >> b/drivers/staging/media/bcm2048/radio-bcm2048.c >> index b10d601..6226e02 100644 >> --- a/drivers/staging/media/bcm2048/radio-bcm2048.c >> +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c >> @@ -2021,8 +2021,8 @@ static ssize_t bcm2048_##prop##_read(struct device >> *dev, \ >> } >> >> #define DEFINE_SYSFS_PROPERTY(prop, signal, size, mask, check) >> \ >> -property_write(prop, signal size, mask, check) >> \ >> -property_read(prop, size, mask) >> +(property_write(prop, signal size, mask, check) >> \ >> +property_read(prop, size, mask)) > You didn't even test-build this patch, why not? > Greg KH, I have compiled the kernel by following these step: 1. copied the .config files 2. make defconfig 3. make -j6 It doesn't show me any warning. so I have tested on my side. -- Thanks and Regards, Jitendra Kumar Khasdev ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/8] staging: comedi: make some variables unsigned in comedi_write()
In `comedi_write()`, the `n` and `m` variables are of type `int`. Change them to `unsigned int` as they are used to measure a positive number of bytes. The `count` variable is also of type `int` and holds the returned number of bytes written. Change it to type `ssize_t` to match the function's return type. Signed-off-by: Ian Abbott --- drivers/staging/comedi/comedi_fops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 94c2348..188a12a 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2303,7 +2303,9 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, { struct comedi_subdevice *s; struct comedi_async *async; - int n, m, count = 0, retval = 0; + unsigned int n, m; + ssize_t count = 0; + int retval = 0; DECLARE_WAITQUEUE(wait, current); struct comedi_file *cfp = file->private_data; struct comedi_device *dev = cfp->dev; -- 2.6.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/8] staging: comedi: return error on "write" if no command set up
The "write" file operation handler, `comedi_write()` returns an error for pretty much any condition that prevents a "write" going ahead. One of the conditions that prevents a "write" going ahead is that no asynchronous command has been set up, but that currently results in a return value of 0 (unless COMEDI instructions are being processed or an asynchronous command has been set up by a different file object). Change it to return `-EINVAL` in this case. Signed-off-by: Ian Abbott --- drivers/staging/comedi/comedi_fops.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 4dd4289..2a2b5a0 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2331,9 +2331,12 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, } async = s->async; - - if (!s->busy || !nbytes) + if (!nbytes) + goto out; + if (!s->busy) { + retval = -EINVAL; goto out; + } if (s->busy != file) { retval = -EACCES; goto out; @@ -2373,8 +2376,10 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, retval = -ERESTARTSYS; break; } - if (!s->busy) + if (!s->busy) { + retval = -EINVAL; break; + } if (s->busy != file) { retval = -EACCES; break; -- 2.6.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/8] staging: comedi: do extra checks for becoming non-busy for "write"
`comedi_write()` is the handler for the "write" file operation for COMEDI devices. It mostly runs without using the main mutex of the COMEDI device, but uses the `attach_lock` rw_semaphore to protect against the COMEDI device becoming "detached". A file object can write data for a COMEDI asynchonous command if it initiated the command. The COMEDI subdevice is marked as busy when the command is started. At some point, the "write" handler detects that the command has terminated and so marks the subdevice as non-busy. In order to mark the subdevice as non-busy, the "write" handler needs to release the `attach_lock` rw_semaphore and `acquire the main `mutex`. There is a vulnerable point between the two, so it checks that the device is still attached after acquiring the mutex. However, it does not currently check that the conditions for becoming non-busy still hold. Add some more checks that the subdevice is still busy with a command initiated by the same file object, and that the command is in the correct direction (in case the subdevice supports both "read" and "write"). Signed-off-by: Ian Abbott --- drivers/staging/comedi/comedi_fops.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index c9da6f3..94c2348 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2420,10 +2420,15 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, * sufficient (unless there have been 2**32 detaches in the * meantime!), but check the subdevice pointer as well just in * case. +* +* Also check the subdevice is still in a suitable state to +* become non-busy in case it changed behind our back. */ new_s = comedi_file_write_subdevice(file); if (dev->attached && old_detach_count == dev->detach_count && - s == new_s && new_s->async == async) + s == new_s && new_s->async == async && s->busy == file && + (async->cmd.flags & CMDF_WRITE) && + !comedi_is_subdevice_running(s)) do_become_nonbusy(dev, s); mutex_unlock(&dev->mutex); } -- 2.6.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/8] staging: comedi: avoid bad truncation of a size_t in comedi_write()
At one point in `comedi_write()`, the variable `n` gets assigned to the minimum of the parameter `nbytes` and the amount of writeable buffer space. The way that is done currently is unsafe in the unlikely case that `nbytes` exceeds `UINT_MAX`, so fix it. Signed-off-by: Ian Abbott --- drivers/staging/comedi/comedi_fops.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 188a12a..8c784c4 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2357,16 +2357,13 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, break; } - n = nbytes; - - m = n; + /* Allocate all free buffer space. */ + comedi_buf_write_alloc(s, async->prealloc_bufsz); + m = comedi_buf_write_n_allocated(s); + /* Avoid buffer wraparound. */ if (async->buf_write_ptr + m > async->prealloc_bufsz) m = async->prealloc_bufsz - async->buf_write_ptr; - comedi_buf_write_alloc(s, async->prealloc_bufsz); - if (m > comedi_buf_write_n_allocated(s)) - m = comedi_buf_write_n_allocated(s); - if (m < n) - n = m; + n = min_t(size_t, m, nbytes); if (n == 0) { if (file->f_flags & O_NONBLOCK) { -- 2.6.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/8] staging: comedi: simplify returned errors for comedi_write()
In order to perform a "write" file operation, an asynchronous COMEDI command in the "write" direction needs to have been set up by the current file object on the COMEDI "write" subdevice associated with the file object. If there is a "write" subdevice, but a command has not been set up by the file object (or is has been set-up in the wrong direction), `comedi_write()` currently returns one of two error values `-EINVAL` or `-EACCES`. `-EACCES` is returned if the command was set up by a different subdevice, or somewhat randomly, if a COMEDI "instruction" is currently being processed. `-EINVAL` is returned in other cases. Simplify it by returning `-EINVAL` for all these cases. Signed-off-by: Ian Abbott --- drivers/staging/comedi/comedi_fops.c | 21 +++-- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 2a2b5a0..5a9c9d9 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2333,15 +2333,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, async = s->async; if (!nbytes) goto out; - if (!s->busy) { - retval = -EINVAL; - goto out; - } - if (s->busy != file) { - retval = -EACCES; - goto out; - } - if (!(async->cmd.flags & CMDF_WRITE)) { + if (s->busy != file || !(async->cmd.flags & CMDF_WRITE)) { retval = -EINVAL; goto out; } @@ -2376,15 +2368,8 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, retval = -ERESTARTSYS; break; } - if (!s->busy) { - retval = -EINVAL; - break; - } - if (s->busy != file) { - retval = -EACCES; - break; - } - if (!(async->cmd.flags & CMDF_WRITE)) { + if (s->busy != file || + !(async->cmd.flags & CMDF_WRITE)) { retval = -EINVAL; break; } -- 2.6.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/8] staging: comedi: rearrange comedi_write() code
Rearrange the code in `comedi_write()` to reduce the amount of indentation. The code never reiterates the `while` loop once `count` has become non-zero, so we can check that in the `while` condition to save an indentation level. (Note that `nbytes` has been checked to be non-zero before entering the loop, so we can remove that check.) Move the code that makes the subdevice "become non-busy" outside the `while` loop, using a new flag variable `become_nonbusy` to decide whether it needs to be done. This simplifies the wait queue handling so there is a single place where the task is removed from the wait queue, and we can remove the `on_wait_queue` flag variable. Signed-off-by: Ian Abbott --- drivers/staging/comedi/comedi_fops.c | 71 +++- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 7b4af51..c9da6f3 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2307,7 +2307,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, DECLARE_WAITQUEUE(wait, current); struct comedi_file *cfp = file->private_data; struct comedi_device *dev = cfp->dev; - bool on_wait_queue = false; + bool become_nonbusy = false; bool attach_locked; unsigned int old_detach_count; @@ -2342,48 +2342,16 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, } add_wait_queue(&async->wait_head, &wait); - on_wait_queue = true; - while (nbytes > 0 && !retval) { + while (count == 0 && !retval) { unsigned runflags; set_current_state(TASK_INTERRUPTIBLE); runflags = comedi_get_subdevice_runflags(s); if (!comedi_is_runflags_running(runflags)) { - if (count == 0) { - struct comedi_subdevice *new_s; - - if (comedi_is_runflags_in_error(runflags)) - retval = -EPIPE; - else - retval = 0; - /* -* To avoid deadlock, cannot acquire dev->mutex -* while dev->attach_lock is held. Need to -* remove task from the async wait queue before -* releasing dev->attach_lock, as it might not -* be valid afterwards. -*/ - remove_wait_queue(&async->wait_head, &wait); - on_wait_queue = false; - up_read(&dev->attach_lock); - attach_locked = false; - mutex_lock(&dev->mutex); - /* -* Become non-busy unless things have changed -* behind our back. Checking dev->detach_count -* is unchanged ought to be sufficient (unless -* there have been 2**32 detaches in the -* meantime!), but check the subdevice pointer -* as well just in case. -*/ - new_s = comedi_file_write_subdevice(file); - if (dev->attached && - old_detach_count == dev->detach_count && - s == new_s && new_s->async == async) - do_become_nonbusy(dev, s); - mutex_unlock(&dev->mutex); - } + if (comedi_is_runflags_in_error(runflags)) + retval = -EPIPE; + become_nonbusy = true; break; } @@ -2433,12 +2401,33 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, nbytes -= n; buf += n; - break; /* makes device work like a pipe */ } -out: - if (on_wait_queue) - remove_wait_queue(&async->wait_head, &wait); + remove_wait_queue(&async->wait_head, &wait); set_current_state(TASK_RUNNING); + if (become_nonbusy && count == 0) { + struct comedi_subdevice *new_s; + + /* +* To avoid deadlock, cannot acquire dev->mutex +* while dev->attach_lock is held. +*/ + up_read(&dev->attach_lock); + attach_locked = false; + mutex_lock(&dev->mutex); + /* +* Check device hasn't become de
[PATCH 0/8] staging: comedi: some comedi_write() changes
Tidy up the "write" file operation handler, `comedi_write()` a bit and improve the error handling. 1) staging: comedi: rearrange comedi_write() code 2) staging: comedi: do extra checks for becoming non-busy for "write" 3) staging: comedi: make some variables unsigned in comedi_write() 4) staging: comedi: avoid bad truncation of a size_t in comedi_write() 5) staging: comedi: allow buffer wraparound in comedi_write() 6) staging: comedi: return error on "write" if no command set up 7) staging: comedi: simplify returned errors for comedi_write() 8) staging: comedi: check for more errors for zero-length write drivers/staging/comedi/comedi_fops.c | 124 --- 1 file changed, 56 insertions(+), 68 deletions(-) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/8] staging: comedi: allow buffer wraparound in comedi_write()
`comedi_write()` copies data from the user buffer to the acquisition data buffer, which is cyclic, using a single call to `copy_from_user()`. It currently avoids having to deal with wraparound of the cyclic buffer by limiting the amount it copies (and the amount returned to the user). Change it to deal with the wraparound using two calls to `copy_from_user()` if necessary. Signed-off-by: Ian Abbott --- drivers/staging/comedi/comedi_fops.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 8c784c4..4dd4289 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2346,6 +2346,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, add_wait_queue(&async->wait_head, &wait); while (count == 0 && !retval) { unsigned runflags; + unsigned int wp, n1, n2; set_current_state(TASK_INTERRUPTIBLE); @@ -2360,9 +2361,6 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, /* Allocate all free buffer space. */ comedi_buf_write_alloc(s, async->prealloc_bufsz); m = comedi_buf_write_n_allocated(s); - /* Avoid buffer wraparound. */ - if (async->buf_write_ptr + m > async->prealloc_bufsz) - m = async->prealloc_bufsz - async->buf_write_ptr; n = min_t(size_t, m, nbytes); if (n == 0) { @@ -2388,8 +2386,14 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, continue; } - m = copy_from_user(async->prealloc_buf + async->buf_write_ptr, - buf, n); + wp = async->buf_write_ptr; + n1 = min(n, async->prealloc_bufsz - wp); + n2 = n - n1; + m = copy_from_user(async->prealloc_buf + wp, buf, n1); + if (m) + m += n2; + else if (n2) + m = copy_from_user(async->prealloc_buf, buf + n1, n2); if (m) { n -= m; retval = -EFAULT; -- 2.6.2 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel