Re: [PATCH v3 5/7] PCI: irqdomain: Look up IRQ domain by fwnode_handle

2015-10-27 Thread Jiang Liu


On 2015/10/27 7:15, ja...@microsoft.com wrote:
> From: Jake Oshins 
> 
> The existing PCI code looks for an IRQ domain associated with a root PCI bus
> by looking in the Open Firmware tree.  This patch introduces a second way
> to identify the associated IRQ domain, if the lookup in the OF tree fails.
> The handle used for the IRQ domain lookup was introduced in the previous patch
> in the series.
> 
> Signed-off-by: Jake Oshins 
> ---
>  drivers/pci/probe.c | 13 +
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index c0f2e44..62c9ac7 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -664,6 +664,7 @@ static void pci_set_bus_speed(struct pci_bus *bus)
>  static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
>  {
>   struct irq_domain *d;
> + struct pci_host_bridge *host_bridge;
>  
>   /*
>* Any firmware interface that can resolve the msi_domain
> @@ -671,6 +672,18 @@ static struct irq_domain 
> *pci_host_bridge_msi_domain(struct pci_bus *bus)
>*/
>   d = pci_host_bridge_of_msi_domain(bus);
>  
> + /*
> +  * If no IRQ domain was found via the OF tree, try looking it up
> +  * directly through the fwnode_handle.
> +  */
> + if (!d) {
> + host_bridge = to_pci_host_bridge(bus->bridge);
> + if (host_bridge->fwnode) {
> + d = irq_find_matching_fwnode(host_bridge->fwnode,
> +  DOMAIN_BUS_ANY);
Should we use DOMAIN_BUS_PCI_MSI instead here?

> + }
> + }
> +
>   return d;
>  }
>  
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 4/7] PCI: Record an fwnode associated with root PCI buses, optionally

2015-10-27 Thread Jiang Liu
On 2015/10/27 7:15, ja...@microsoft.com wrote:
> From: Jake Oshins 
> 
> This patch allows a PCI front-end implementation to supply an fwnode_handle
> associated with a root PCI bus, optionally.  If supplied, the PCI driver
> records this.
> 
> This patch supports the next patch in the series, which looks up an IRQ domain
> through this handle.
Hi JaKeo,
Instead of changing the pci_create_root_bus() interface,
how about packing fwnode into sysdata, then we may
either 1) introduce a helper to retrieve fwnode from sysdata
or 2) set host_bridge->fwnode = sysdata in function
pcibios_root_bridge_prepare.

Thanks,
Gerry

> 
> Signed-off-by: Jake Oshins 
> ---
>  arch/sparc/kernel/pci.c   | 2 +-
>  drivers/acpi/pci_root.c   | 2 +-
>  drivers/parisc/lba_pci.c  | 2 +-
>  drivers/pci/host/pci-xgene.c  | 2 +-
>  drivers/pci/host/pcie-iproc.c | 3 ++-
>  drivers/pci/probe.c   | 8 +---
>  include/linux/pci.h   | 4 +++-
>  7 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
> index b91d7f1..3d4e9f9 100644
> --- a/arch/sparc/kernel/pci.c
> +++ b/arch/sparc/kernel/pci.c
> @@ -660,7 +660,7 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
>   pbm->busn.flags = IORESOURCE_BUS;
>   pci_add_resource(&resources, &pbm->busn);
>   bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
> -   pbm, &resources);
> +   pbm, &resources, NULL);
>   if (!bus) {
>   printk(KERN_ERR "Failed to create bus for %s\n",
>  node->full_name);
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 850d7bf..eab95bc 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -840,7 +840,7 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root 
> *root,
>   pci_acpi_root_add_resources(info);
>   pci_add_resource(&info->resources, &root->secondary);
>   bus = pci_create_root_bus(NULL, busnum, ops->pci_ops,
> -   sysdata, &info->resources);
> +   sysdata, &info->resources, NULL);
>   if (!bus)
>   goto out_release_info;
>  
> diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
> index a32c1f6..a7b9d5c 100644
> --- a/drivers/parisc/lba_pci.c
> +++ b/drivers/parisc/lba_pci.c
> @@ -1567,7 +1567,7 @@ lba_driver_probe(struct parisc_device *dev)
>   dev->dev.platform_data = lba_dev;
>   lba_bus = lba_dev->hba.hba_bus =
>   pci_create_root_bus(&dev->dev, lba_dev->hba.bus_num.start,
> - cfg_ops, NULL, &resources);
> + cfg_ops, NULL, &resources, NULL);
>   if (!lba_bus) {
>   pci_free_resource_list(&resources);
>   return 0;
> diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
> index ae00ce2..95c20c8 100644
> --- a/drivers/pci/host/pci-xgene.c
> +++ b/drivers/pci/host/pci-xgene.c
> @@ -545,7 +545,7 @@ static int xgene_pcie_probe_bridge(struct platform_device 
> *pdev)
>   return ret;
>  
>   bus = pci_create_root_bus(&pdev->dev, 0,
> - &xgene_pcie_ops, port, &res);
> + &xgene_pcie_ops, port, &res, NULL);
>   if (!bus)
>   return -ENOMEM;
>  
> diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
> index 9193951..bc999b7 100644
> --- a/drivers/pci/host/pcie-iproc.c
> +++ b/drivers/pci/host/pcie-iproc.c
> @@ -357,7 +357,8 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct 
> list_head *res)
>   sysdata = pcie;
>  #endif
>  
> - bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops, sysdata, res);
> + bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops, sysdata, res,
> +   NULL);
>   if (!bus) {
>   dev_err(pcie->dev, "unable to create PCI root bus\n");
>   ret = -ENOMEM;
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index f441d1b..c0f2e44 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2039,7 +2039,8 @@ void __weak pcibios_remove_bus(struct pci_bus *bus)
>  }
>  
>  struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> - struct pci_ops *ops, void *sysdata, struct list_head *resources)
> + struct pci_ops *ops, void *sysdata, struct list_head *resources,
> + struct fwnode_handle *fwnode)
>  {
>   int error;
>   struct pci_host_bridge *bridge;
> @@ -2069,6 +2070,7 @@ struct pci_bus *pci_create_root_bus(struct device 
> *parent, int bus,
>   if (!bridge)
>   goto err_out;
>  
> + bridge->fwnode = fwnode;
>   bridge->dev.parent = parent;
>   bridge->dev.release = pci_release_host_bridge_dev;
>   dev_set_name(&bridge->dev, "pci%04x:%02x", pci_do

Re: [PATCH v3 7/7] PCI: hv: New paravirtual PCI front-end for Hyper-V VMs

2015-10-27 Thread Jiang Liu
On 2015/10/27 7:15, ja...@microsoft.com wrote:
> From: Jake Oshins 
> 
> This patch introduces a new driver which exposes a root PCI bus whenever a PCI
> Express device is passed through to a guest VM under Hyper-V. The device can
> be single- or multi-function. The interrupts for the devices are managed by an
> IRQ domain, implemented within the driver.
> 
> Signed-off-by: Jake Oshins 
> ---

> +
> +/**
> + * hv_pcie_init_irq_domain() - Initialize IRQ domain
> + * @hbus:The root PCI bus
> + *
> + * Return: '0' on success and error value on failure
> + */
> +static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus)
> +{
> + hbus->msi_info.chip = &hv_msi_irq_chip;
> + hbus->msi_info.chip_data = hbus;
> + hbus->msi_info.ops = &hv_msi_ops;
> + hbus->msi_info.flags = (MSI_FLAG_USE_DEF_DOM_OPS |
> + MSI_FLAG_USE_DEF_CHIP_OPS | MSI_FLAG_MULTI_PCI_MSI |
> + MSI_FLAG_PCI_MSIX);
When interrupt remapping is not supported, x86 vector allocator
can't support multiple MSI because it can't allocate continuous
vectors yet. So please confirm whether we could enable
MSI_FLAG_MULTI_PCI_MSI for HV.

> + hbus->msi_info.handler = handle_edge_irq;
> + hbus->msi_info.handler_name = "edge";
> + hbus->msi_info.data = hbus;
How about using following pattern so we could avoid exporting
too many interfaces?

struct irq_domain *parent_domain = NULL;
hbus->msi_info.chip = &hv_msi_irq_chip;
hbus->msi_info.ops = &hv_msi_ops;
// Let arch code to fill in default ops for chip and domain
x86_setup_default_msi_irqdomian_info(&hbus->msi_info, &parent_domain);
// Override default ops if not applicable
hbus->irq_domain = pci_msi_create_irq_domain(hbus->fwnode,
 &hbus->msi_info,
 parent_domain);

> + hbus->irq_domain = pci_msi_create_irq_domain(hbus->fwnode,
> +  &hbus->msi_info,
> +  x86_vector_domain);
> + if (!hbus->irq_domain) {
> + pr_err("Failed to build an MSI IRQ domain\n");
> + return -ENODEV;
> + }
> +
> + return 0;
> +}
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/19] staging/wilc1000 cleanups

2015-10-27 Thread Tony Cho

Hi Arnd,
I expect your opinion but I would like to make the patch to revert
the commit bcc43a4b5ed75285aeacf2cf8d9b96d6379fb429 if you don't mind
because the WILC1000 in staging still has compile errors.
Then, we had better make patch for your concerns.

I always appreciate your review and contribution.

Thanks,
Tony.

On 2015년 10월 23일 16:51, Tony Cho wrote:

Hi Arnd,
First of all, I would like to say "thank you" for your efforts and 
contributions.
We are updating the driver because new revision came up and making new 
patches
to make it stable and elegant as Linux driver. In these days, we are 
sending big changes

while testing such patches and also doing updates at once.

As you did, we are scheduled to provide the patches making device tree 
and delete all of platform
dependencies as you removed WILC_SDIO_IRQ_GPIO as well as other 
things. So, I would like to

discuss with you for your series of patch.

In this time, I think it's important to make the driver to be compiled 
even if the link problem
happens as you reported. So, how about deleting all of SPI related 
files from source tree and
even from Kconfig for the time being because new bus driver will come 
or revert

the Kconfig and then can we expect the best patch in the near feature?

I respect your efforts and patches, so your opinion is very important 
to me.


Thanks,
Tony.

On 2015년 10월 23일 10:37, glen lee wrote:


On 2015년 10월 22일 21:23, Arnd Bergmann wrote:

On Wednesday 21 October 2015 19:06:52 glen lee wrote:

Hi arnd,

Thanks for the all the patches.
About the patch ( use proper naming for global symbols ),
We are planning to use this driver not only for wilc1000 but also for
other atmel wireless driver. I'd appreciate if you could use wl 
instead of wilc1000.


And the global variable g_linux_wlan will be placed in netdevice 
private data
and finally it will be removed. I already posted some of those 
patches.

I couldn't find the patches anywhere, but I've updated my series now
to rename the symbols to wilc_* and to remove most but not all 
references to
g_linux_wlan (or wilc_dev after my rename). Do you want me to post 
those
so you can integrate them, or should I have a look at what you sent 
first

(please send me a copy then).


Hi arnd,

I have tested with all the patches you have posted but it does not 
works. firmware start timed out

in the function wilc1000_start_firmware.
I also have tested with all the patched without last one, [RFC] one, 
but it shows

Segmentation fault when insmod driver.
For now, I can't rebase the patches. I'd appreciate if you could help 
us.


The title of my first patch is,
[PATCH 01/13] staging: wilc1000: add wilc to netdev private data 
structure

and also refer to [PATCH 00/12] WILC1000 V2 for the g_linux_wlan
( The patches posted by tony@atmel.com )

By the way, deleting feature COMPLEMENT_BOOT patch already posted but 
not yet accepted.


Thank you.
Glen.


Arnd






___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/10] staging: fsl-mc: Added generic MSI support for FSL-MC devices

2015-10-27 Thread Jiang Liu
On 2015/10/26 23:49, J. German Rivera wrote:
> Created an MSI domain for the fsl-mc bus-- including functions
> to create a domain, find a domain, alloc/free domain irqs, and
> bus specific overrides for domain and irq_chip ops.
> 
> Signed-off-by: J. German Rivera 
> ---
>  drivers/staging/fsl-mc/bus/Kconfig  |   1 +
>  drivers/staging/fsl-mc/bus/Makefile |   1 +
>  drivers/staging/fsl-mc/bus/mc-msi.c | 278 
> 
>  drivers/staging/fsl-mc/include/mc-private.h |  17 ++
>  drivers/staging/fsl-mc/include/mc.h |  17 ++
>  5 files changed, 314 insertions(+)
>  create mode 100644 drivers/staging/fsl-mc/bus/mc-msi.c
> 


> +
> +static void fsl_mc_msi_free_descs(struct device *dev)
> +{
> + struct msi_desc *desc, *tmp;
> +
> + list_for_each_entry_safe(desc, tmp, dev_to_msi_list(dev), list) {
> + list_del(&desc->list);
> + free_msi_entry(desc);
> + }
> +}
> +
> +static int fsl_mc_msi_alloc_descs(struct device *dev, unsigned int irq_count)
> +
> +{
> + unsigned int i;
> + int error;
> + struct msi_desc *msi_desc;
> +
> + for (i = 0; i < irq_count; i++) {
> + msi_desc = alloc_msi_entry(dev);
> + if (!msi_desc) {
> + dev_err(dev, "Failed to allocate msi entry\n");
> + error = -ENOMEM;
> + goto cleanup_msi_descs;
> + }
> +
> + msi_desc->msi_attrib.is_msix = 1;
> + msi_desc->msi_attrib.is_64 = 1;
> + msi_desc->msi_attrib.entry_nr = i;

Hi Rivera,
Field msi_desc->msi_attrib is for PCI MSI only, it would be better to
introduce a dedicated structure for FSL-MC, just like
struct platform_msi_desc.
Thanks,
Gerry

> + msi_desc->nvec_used = 1;
> + INIT_LIST_HEAD(&msi_desc->list);
> + list_add_tail(&msi_desc->list, dev_to_msi_list(dev));
> + }
> +
> + return 0;
> +
> +cleanup_msi_descs:
> + fsl_mc_msi_free_descs(dev);
> + return error;
> +}
> +
> +int fsl_mc_msi_domain_alloc_irqs(struct device *dev,
> +  unsigned int irq_count)
> +{
> + struct irq_domain *msi_domain;
> + int error;
> +
> + if (WARN_ON(!list_empty(dev_to_msi_list(dev
> + return -EINVAL;
> +
> + error = fsl_mc_msi_alloc_descs(dev, irq_count);
> + if (error < 0)
> + return error;
> +
> + msi_domain = dev_get_msi_domain(dev);
> + if (WARN_ON(!msi_domain)) {
> + error = -EINVAL;
> + goto cleanup_msi_descs;
> + }
> +
> + /*
> +  * NOTE: Calling this function will trigger the invocation of the
> +  * its_fsl_mc_msi_prepare() callback
> +  */
> + error = msi_domain_alloc_irqs(msi_domain, dev, irq_count);
> +
> + if (error) {
> + dev_err(dev, "Failed to allocate IRQs\n");
> + goto cleanup_msi_descs;
> + }
> +
> + return 0;
> +
> +cleanup_msi_descs:
> + fsl_mc_msi_free_descs(dev);
> + return error;
> +}
> +

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: rtl8188eu: clamp kernel macro used in proc_get_rx_signal

2015-10-27 Thread Greg Kroah-Hartman
On Mon, Oct 26, 2015 at 11:25:00PM +0700, Ivan Safonov wrote:
> To limit the range of integers there is clamp macro.
> 
> Signed-off-by: Ivan Safonov 
> ---
> Changes in v2:
>   - big patchset splitted into some small independent patches.

You didn't tell me that this was a v2 of a specific patch in your
series, so I am totally confused now.  I'm dropping all of the patches
you sent for this driver, please fix up the series and resend them all,
ordered, and ideally properly threaded, so I know how to apply them.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 12/23] staging/rdma/hfi1: Macro code clean up

2015-10-27 Thread Greg KH
On Mon, Oct 26, 2015 at 10:28:38AM -0400, ira.we...@intel.com wrote:
> From: Mitko Haralanov 
> 
> Clean up the context and sdma macros and move them to a more logical place in
> hfi.h
> 
> Signed-off-by: Mitko Haralanov 
> Signed-off-by: Ira Weiny 
> ---
>  drivers/staging/rdma/hfi1/hfi.h | 22 ++
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
> index a35213e9b500..41ad9a30149b 100644
> --- a/drivers/staging/rdma/hfi1/hfi.h
> +++ b/drivers/staging/rdma/hfi1/hfi.h
> @@ -1104,6 +1104,16 @@ struct hfi1_filedata {
>   int rec_cpu_num;
>  };
>  
> +/* for use in system calls, where we want to know device type, etc. */
> +#define fp_to_fd(fp) ((struct hfi1_filedata *)(fp)->private_data)
> +#define ctxt_fp(fp) (fp_to_fd((fp))->uctxt)
> +#define subctxt_fp(fp) (fp_to_fd((fp))->subctxt)
> +#define tidcursor_fp(fp) (fp_to_fd((fp))->tidcursor)
> +#define user_sdma_pkt_fp(fp) (fp_to_fd((fp))->pq)
> +#define user_sdma_comp_fp(fp) (fp_to_fd((fp))->cq)
> +#define notifier_fp(fp) (fp_to_fd((fp))->mn)
> +#define rb_fp(fp) (fp_to_fd((fp))->tid_rb_root)

Ick, no, don't do this, just spell it all out (odds are you will see tht
you can make the code simpler...)  If you don't know what "cq" or "pq"
are, then name them properly.

These need to be all removed.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 14/23] staging/rdma/hfi1: Implement Expected Receive TID caching

2015-10-27 Thread Greg KH
On Mon, Oct 26, 2015 at 10:28:40AM -0400, ira.we...@intel.com wrote:
> From: Mitko Haralanov 
> 
> Expected receives work by user-space libraries (PSM) calling into the
> driver with information about the user's receive buffer and have the driver
> DMA-map that buffer and program the HFI to receive data directly into it.
> 
> This is an expensive operation as it requires the driver to pin the pages
> which
> the user's buffer maps to, DMA-map them, and then program the HFI.
> 
> When the receive is complete, user-space libraries have to call into the 
> driver
> again so the buffer is removed from the HFI, un-mapped, and the pages 
> unpinned.
> 
> All of these operations are expensive, considering that a lot of applications
> (especially micro-benchmarks) use the same buffer over and over.
> 
> In order to get better performance for user-space applications, it is highly
> beneficial that they don't continuously call into the driver to register and
> unregister the same buffer. Rather, they can register the buffer and cache it
> for future work. The buffer can be unregistered when it is freed by the user.
> 
> This change implements such buffer caching by making use of the kernel's MMU
> notifier API. User-space libraries call into the driver only when the need to
> register a new buffer.
> 
> Once a buffer is registered, it stays programmed into the HFI until the kernel
> notifies the driver that the buffer has been freed by the user. At that time,
> the user-space library is notified and it can do the necessary work to remove
> the buffer from its cache.
> 
> Buffers which have been invalidated by the kernel are not automatically 
> removed
> from the HFI and do not have their pages unpinned. Buffers are only completely
> removed when the user-space libraries call into the driver to free them.  This
> is done to ensure that any ongoing transfers into that buffer are complete.
> This is important when a buffer is not completely freed but rather it is
> shrunk. The user-space library could still have uncompleted transfers into the
> remaining buffer.
> 
> With this feature, it is important that systems are setup with reasonable
> limits for the amount of lockable memory.  Keeping the limit at "unlimited" 
> (as
> we've done up to this point), may result in jobs being killed by the kernel's
> OOM due to them taking up excessive amounts of memory.
> 
> Reviewed-by: Arthur Kepner 
> Reviewed-by: Dennis Dalessandro 
> Signed-off-by: Mitko Haralanov 
> Signed-off-by: Ira Weiny 
> 
> ---
> Changes from V2:
>   Fix random Kconfig 0-day build error
>   Fix leak of random memory to user space caught by Dan Carpenter
>   Separate out pointer bug fix into a previous patch
>   Change error checks in case statement per Dan's comments
> 
>  drivers/staging/rdma/hfi1/Kconfig|1 +
>  drivers/staging/rdma/hfi1/Makefile   |2 +-
>  drivers/staging/rdma/hfi1/common.h   |   15 +-
>  drivers/staging/rdma/hfi1/file_ops.c |  490 ++---
>  drivers/staging/rdma/hfi1/hfi.h  |   43 +-
>  drivers/staging/rdma/hfi1/init.c |5 +-
>  drivers/staging/rdma/hfi1/trace.h|  132 ++--
>  drivers/staging/rdma/hfi1/user_exp_rcv.c | 1171 
> ++
>  drivers/staging/rdma/hfi1/user_exp_rcv.h |   82 +++
>  drivers/staging/rdma/hfi1/user_pages.c   |  110 +--
>  drivers/staging/rdma/hfi1/user_sdma.c|   13 +
>  drivers/staging/rdma/hfi1/user_sdma.h|   10 +-
>  include/uapi/rdma/hfi/hfi1_user.h|   42 +-
>  13 files changed, 1481 insertions(+), 635 deletions(-)
>  create mode 100644 drivers/staging/rdma/hfi1/user_exp_rcv.c
>  create mode 100644 drivers/staging/rdma/hfi1/user_exp_rcv.h

This is way too big to review properly, please break it up into
reviewable chunks.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V4] staging: wilc1000: wilc_msgqueue.c : remove goto statement

2015-10-27 Thread Glen Lee
From: Leo Kim 

This patch removes goto statement and moves the spin lock position.
If a memory allocation fails, directly returns an error.
The spin lock actually protects the pHandle. Therefore, call spin lock just
before pHandle is used.

Signee-eff-by: Lee Kim 
Signed-off-by: Tony Cho 
Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 25 -
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index b13809a..0eff121 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -56,37 +56,35 @@ int wilc_mq_destroy(WILC_MsgQueueHandle *pHandle)
 int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
 const void *pvSendBuffer, u32 u32SendBufferSize)
 {
-   int result = 0;
unsigned long flags;
Message *pstrMessage = NULL;
 
if ((!pHandle) || (u32SendBufferSize == 0) || (!pvSendBuffer)) {
PRINT_ER("pHandle or pvSendBuffer is null\n");
-   result = -EFAULT;
-   goto ERRORHANDLER;
+   return -EFAULT;
}
 
if (pHandle->bExiting) {
PRINT_ER("pHandle fail\n");
-   result = -EFAULT;
-   goto ERRORHANDLER;
+   return -EFAULT;
}
 
-   spin_lock_irqsave(&pHandle->strCriticalSection, flags);
-
/* construct a new message */
pstrMessage = kmalloc(sizeof(Message), GFP_ATOMIC);
if (!pstrMessage)
return -ENOMEM;
+
pstrMessage->u32Length = u32SendBufferSize;
pstrMessage->pstrNext = NULL;
pstrMessage->pvBuffer = kmemdup(pvSendBuffer, u32SendBufferSize,
GFP_ATOMIC);
if (!pstrMessage->pvBuffer) {
-   result = -ENOMEM;
-   goto ERRORHANDLER;
+   kfree(pstrMessage);
+   return -ENOMEM;
}
 
+   spin_lock_irqsave(&pHandle->strCriticalSection, flags);
+
/* add it to the message queue */
if (!pHandle->pstrMessageList) {
pHandle->pstrMessageList  = pstrMessage;
@@ -103,14 +101,7 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
 
up(&pHandle->hSem);
 
-ERRORHANDLER:
-   /* error occured, free any allocations */
-   if (pstrMessage) {
-   kfree(pstrMessage->pvBuffer);
-   kfree(pstrMessage);
-   }
-
-   return result;
+   return 0;
 }
 
 /*!
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 19/23] staging/rdma/hfi: modify workqueue for parallelism

2015-10-27 Thread Greg KH
On Mon, Oct 26, 2015 at 10:28:45AM -0400, ira.we...@intel.com wrote:
> From: Mike Marciniszyn 
> 
> The workqueue is currently single threaded per port which for a small number 
> of
> SDMA engines is ok.
> 
> For hfi1, the there are up to 16 SDMA engines that can be fed descriptors in
> parallel.
> 
> This patch:
> - Converts to use alloc_workqueue
> - Changes the workqueue limit from 1 to num_sdma
> - Makes the queue WQ_CPU_INTENSIVE and WQ_HIGHPRI
> - The sdma_engine now has a cpu that is initialized
>   as the MSI-X vectors are setup
> - Adjusts the post send logic to call a new scheduler
>   that doesn't get the s_lock
> - The new and old workqueue schedule now pass a
>   cpu
> - post send now uses the new scheduler
> - RC/UC QPs now pre-compute the sc, sde
> - The sde wq is eliminated since the new hfi1_wq is
>   multi-threaded

When you have to start enumerating all of the different things that your
patch does, that's a huge hint that you need to break it up into smaller
pieces.

Please break this up, it's not acceptable as-is.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 23/23] staging/rdma/hfi1: Update driver version string to 0.9-294

2015-10-27 Thread Greg KH
On Mon, Oct 26, 2015 at 10:28:49AM -0400, ira.we...@intel.com wrote:
> From: Jubin John 
> 
> Signed-off-by: Jubin John 
> Signed-off-by: Ira Weiny 
> ---
>  drivers/staging/rdma/hfi1/common.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rdma/hfi1/common.h 
> b/drivers/staging/rdma/hfi1/common.h
> index 7809093eb55e..5dd92720faae 100644
> --- a/drivers/staging/rdma/hfi1/common.h
> +++ b/drivers/staging/rdma/hfi1/common.h
> @@ -205,7 +205,7 @@
>   * to the driver itself, not the software interfaces it supports.
>   */
>  #ifndef HFI1_DRIVER_VERSION_BASE
> -#define HFI1_DRIVER_VERSION_BASE "0.9-248"
> +#define HFI1_DRIVER_VERSION_BASE "0.9-294"

Patches like this make no sense at all, please drop it and only use the
kernel version.  Trust me, it's going to get messy really fast (hint, it
already did...)

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wilc1000: fix build error on SPI

2015-10-27 Thread Glen Lee
wilc_netdev_init function has parameters to pass but no argument is passed
when bus type SPI is selected. Which causes build error.
This patch passes argument &wilc to the function wilc_netdev_init.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 9f899da..ded302a 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1736,6 +1736,10 @@ int wilc_netdev_init(struct wilc **wilc)
 /*The 1st function called after module inserted*/
 static int __init init_wilc_driver(void)
 {
+#ifdef WILC_SPI
+   struct wilc *wilc;
+#endif
+
 #if defined(WILC_DEBUGFS)
if (wilc_debugfs_init() < 0) {
PRINT_D(GENERIC_DBG, "fail to create debugfs for wilc 
driver\n");
@@ -1762,7 +1766,7 @@ static int __init init_wilc_driver(void)
}
 #else
PRINT_D(INIT_DBG, "Initializing netdev\n");
-   if (wilc_netdev_init())
+   if (wilc_netdev_init(&wilc))
PRINT_ER("Couldn't initialize netdev\n");
return 0;
 #endif
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/4 v2] staging: ipath: ipath_driver: Use setup_timer

2015-10-27 Thread Dan Carpenter
On Sun, Oct 25, 2015 at 01:21:11PM +0200, Leon Romanovsky wrote:
> On Sun, Oct 25, 2015 at 12:17 PM, Muhammad Falak R Wani
>  wrote:
> Please follow standard naming convention for the patches.
> It should be [PATCH v2 1/4] and not [PATCH 1/4 v2].

Does this matter?  It's in a thread so it sorts fine either way.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 02/27] staging: wilc1000: isr_bh_routine: use wilc instead of g_linux_wlan

2015-10-27 Thread Glen Lee
Use netdev private data member wilc instead of g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 324cc57..7d0d722 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -248,8 +248,14 @@ static irqreturn_t isr_uh_routine(int irq, void *user_data)
 
 irqreturn_t isr_bh_routine(int irq, void *userdata)
 {
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
+
+   nic = netdev_priv(userdata);
+   wilc = nic->wilc;
+
/*While mac is closing cacncel the handling of any interrupts received*/
-   if (g_linux_wlan->close) {
+   if (wilc->close) {
PRINT_ER("Driver is CLOSING: Can't handle BH interrupt\n");
return IRQ_HANDLED;
}
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 03/27] staging: wilc1000: deinit_irq: use wilc instead of g_linux_wlan

2015-10-27 Thread Glen Lee
This patch changes function parameter linux_wlan_t nic with net_dev dev and
use netdev private data member wilc instead of nic and g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 7d0d722..ac2bc06 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -310,12 +310,18 @@ static int init_irq(struct net_device *dev)
 }
 #endif
 
-static void deinit_irq(struct wilc *nic)
+static void deinit_irq(struct net_device *dev)
 {
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
+
+   nic = netdev_priv(dev);
+   wilc = nic->wilc;
+
 #if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
/* Deintialize IRQ */
-   if (&nic->dev_irq_num != 0) {
-   free_irq(nic->dev_irq_num, g_linux_wlan);
+   if (&wilc->dev_irq_num != 0) {
+   free_irq(wilc->dev_irq_num, wilc);
 
gpio_free(GPIO_NUM);
}
@@ -907,7 +913,7 @@ void wilc1000_wlan_deinit(struct net_device *dev)
wlan_deinitialize_threads(wl);
 
PRINT_D(INIT_DBG, "Deinitializing IRQ\n");
-   deinit_irq(wl);
+   deinit_irq(dev);
 
wilc_wlan_stop();
 
@@ -1144,7 +1150,7 @@ _fail_irq_enable_:
 _fail_irq_init_:
 #endif
 #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
-   deinit_irq(wl);
+   deinit_irq(dev);
 
 #endif
wlan_deinitialize_threads(wl);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 09/27] staging: wilc1000: wlan_initialize_threads: change argument with net_device

2015-10-27 Thread Glen Lee
This patch changes function argument with net_device and use netdev private
data member wilc instead of g_linux_wlan. And there are assignment code with
different value continuously. Take last code.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 8c81de9..4e88cbe 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1011,31 +1011,34 @@ void linux_to_wlan(wilc_wlan_inp_t *nwi, struct wilc 
*nic)
 #endif
 }
 
-int wlan_initialize_threads(perInterface_wlan_t *nic)
+int wlan_initialize_threads(struct net_device *dev)
 {
-
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
int ret = 0;
 
+   nic = netdev_priv(dev);
+   wilc = nic->wilc;
+
PRINT_D(INIT_DBG, "Initializing Threads ...\n");
 
/* create tx task */
PRINT_D(INIT_DBG, "Creating kthread for transmission\n");
-   g_linux_wlan->txq_thread = kthread_run(linux_wlan_txq_task, (void 
*)g_linux_wlan, "K_TXQ_TASK");
-   if (g_linux_wlan->txq_thread == NULL) {
+   wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)wilc,
+"K_TXQ_TASK");
+   if (!wilc->txq_thread) {
PRINT_ER("couldn't create TXQ thread\n");
ret = -ENOBUFS;
goto _fail_2;
}
/* wait for TXQ task to start. */
-   down(&g_linux_wlan->txq_thread_started);
+   down(&wilc->txq_thread_started);
 
return 0;
 
 _fail_2:
/*De-Initialize 2nd thread*/
-   g_linux_wlan->close = 1;
-
-   g_linux_wlan->close = 0;
+   wilc->close = 0;
return ret;
 }
 
@@ -1084,7 +1087,7 @@ int wilc1000_wlan_init(struct net_device *dev, 
perInterface_wlan_t *p_nic)
}
 #endif
 
-   ret = wlan_initialize_threads(nic);
+   ret = wlan_initialize_threads(dev);
if (ret < 0) {
PRINT_ER("Initializing Threads FAILED\n");
ret = -EIO;
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 01/27] staging: wicl1000: isr_uh_routine: use netdev private wilc

2015-10-27 Thread Glen Lee
Use netdev private member wilc instead of g_linux_wlan and change argument wilc
with dev in the function request_threaded_irq to pass back to handler
the function isr_uh_routine.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index ded302a..324cc57 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -229,10 +229,16 @@ static int dev_state_ev_handler(struct notifier_block 
*this, unsigned long event
 #if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
 static irqreturn_t isr_uh_routine(int irq, void *user_data)
 {
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
+   struct net_device *dev = (struct net_device *)user_data;
+
+   nic = netdev_priv(dev);
+   wilc = nic->wilc;
PRINT_D(INT_DBG, "Interrupt received UH\n");
 
/*While mac is closing cacncel the handling of any interrupts received*/
-   if (g_linux_wlan->close) {
+   if (wilc->close) {
PRINT_ER("Driver is CLOSING: Can't handle UH interrupt\n");
return IRQ_HANDLED;
}
@@ -284,7 +290,7 @@ static int init_irq(struct net_device *dev)
 
if ((ret != -1) && (request_threaded_irq(wl->dev_irq_num, 
isr_uh_routine, isr_bh_routine,
  IRQF_TRIGGER_LOW | 
IRQF_ONESHOT,   /*Without IRQF_ONESHOT the uh will remain kicked in 
and dont gave a chance to bh*/
- "WILC_IRQ", wl)) < 0) {
+ "WILC_IRQ", dev)) < 0) {
 
PRINT_ER("Failed to request IRQ for GPIO: %d\n", GPIO_NUM);
ret = -1;
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 06/27] staging: wilc1000: wilc_wlan_handle_rxq: add new argument and use wilc

2015-10-27 Thread Glen Lee
This patch adds new argument struct wilc and use it instead of g_linux_wlan.
Pass wilc to the function as well.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/wilc_wlan.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 5141fe0..4fc88ef 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1107,7 +1107,7 @@ _end_:
return ret;
 }
 
-static void wilc_wlan_handle_rxq(void)
+static void wilc_wlan_handle_rxq(struct wilc *wilc)
 {
wilc_wlan_dev_t *p = &g_wlan;
int offset = 0, size, has_packet = 0;
@@ -1122,7 +1122,7 @@ static void wilc_wlan_handle_rxq(void)
do {
if (p->quit) {
PRINT_D(RX_DBG, "exit 1st do-while due to Clean_UP 
function\n");
-   up(&g_linux_wlan->cfg_event);
+   up(&wilc->cfg_event);
break;
}
rqe = wilc_wlan_rxq_remove();
@@ -1194,7 +1194,7 @@ static void wilc_wlan_handle_rxq(void)
 **/
PRINT_D(RX_DBG, "p->cfg_seq_no 
= %d - rsp.seq_no = %d\n", p->cfg_seq_no, rsp.seq_no);
if (p->cfg_seq_no == rsp.seq_no)
-   
up(&g_linux_wlan->cfg_event);
+   up(&wilc->cfg_event);
} else if (rsp.type == 
WILC_CFG_RSP_STATUS) {
/**
 *  Call back to indicate 
status...
@@ -1350,7 +1350,7 @@ _end_:
 #endif
}
}
-   wilc_wlan_handle_rxq();
+   wilc_wlan_handle_rxq(wilc);
 }
 
 void wilc_handle_isr(void *wilc)
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 11/27] staging: wilc1000: wilc_wlan_handle_txq: add argument and use wilc

2015-10-27 Thread Glen Lee
This patch adds argument net_device dev and use netdev private data memeber
wilc instead of g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c |  4 ++--
 drivers/staging/wilc1000/wilc_wlan.c  | 11 ---
 drivers/staging/wilc1000/wilc_wlan.h  |  2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 5897f35..d9f1bf1 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -476,10 +476,10 @@ static int linux_wlan_txq_task(void *vp)
}
PRINT_D(TX_DBG, "txq_task handle the sending packet and let me 
go to sleep.\n");
 #if !defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
-   ret = wilc_wlan_handle_txq(&txq_count);
+   ret = wilc_wlan_handle_txq(dev, &txq_count);
 #else
do {
-   ret = wilc_wlan_handle_txq(&txq_count);
+   ret = wilc_wlan_handle_txq(dev, &txq_count);
if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD /* && 
netif_queue_stopped(pd->wilc_netdev)*/) {
PRINT_D(TX_DBG, "Waking up queue\n");
/* netif_wake_queue(pd->wilc_netdev); */
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 4fa956a..907da93 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -814,7 +814,7 @@ void chip_sleep_manually(u32 u32SleepTime)
  *  Tx, Rx queue handle functions
  *
  /
-int wilc_wlan_handle_txq(u32 *pu32TxqCount)
+int wilc_wlan_handle_txq(struct net_device *dev, u32 *pu32TxqCount)
 {
wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
int i, entries = 0;
@@ -828,13 +828,18 @@ int wilc_wlan_handle_txq(u32 *pu32TxqCount)
int counter;
int timeout;
u32 vmm_table[WILC_VMM_TBL_SIZE];
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
+
+   nic = netdev_priv(dev);
+   wilc = nic->wilc;
 
p->txq_exit = 0;
do {
if (p->quit)
break;
 
-   linux_wlan_lock_timeout(&g_linux_wlan->txq_add_to_head_cs,
+   linux_wlan_lock_timeout(&wilc->txq_add_to_head_cs,
CFG_PKTS_TIMEOUT);
 #ifdef TCP_ACK_FILTER
wilc_wlan_txq_filter_dup_tcp_ack();
@@ -1098,7 +1103,7 @@ _end_:
if (ret != 1)
break;
} while (0);
-   up(&g_linux_wlan->txq_add_to_head_cs);
+   up(&wilc->txq_add_to_head_cs);
 
p->txq_exit = 1;
PRINT_D(TX_DBG, "THREAD: Exiting txq\n");
diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
b/drivers/staging/wilc1000/wilc_wlan.h
index a07375b..79b35e6 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -300,7 +300,7 @@ int wilc_wlan_start(void);
 int wilc_wlan_stop(void);
 int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size,
  wilc_tx_complete_func_t func);
-int wilc_wlan_handle_txq(u32 *pu32TxqCount);
+int wilc_wlan_handle_txq(struct net_device *dev, u32 *pu32TxqCount);
 void wilc_handle_isr(void *wilc);
 void wilc_wlan_cleanup(void);
 int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 10/27] staging: wilc1000: linux_wlan_txq_task: use wilc instead of g_linux_wlan

2015-10-27 Thread Glen Lee
Pass argument dev instead of wilc from kthread_run and use netdev private data
member wilc instead of g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 4e88cbe..5897f35 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -440,7 +440,9 @@ int linux_wlan_get_num_conn_ifcs(void)
 static int linux_wlan_txq_task(void *vp)
 {
int ret, txq_count;
-
+   perInterface_wlan_t *nic;
+   struct wilc *wl;
+   struct net_device *dev = vp;
 #if defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
 #define TX_BACKOFF_WEIGHT_INCR_STEP (1)
 #define TX_BACKOFF_WEIGHT_DECR_STEP (1)
@@ -450,18 +452,21 @@ static int linux_wlan_txq_task(void *vp)
int backoff_weight = TX_BACKOFF_WEIGHT_MIN;
 #endif
 
+   nic = netdev_priv(dev);
+   wl = nic->wilc;
+
/* inform wilc1000_wlan_init that TXQ task is started. */
-   up(&g_linux_wlan->txq_thread_started);
+   up(&wl->txq_thread_started);
while (1) {
 
PRINT_D(TX_DBG, "txq_task Taking a nap :)\n");
-   down(&g_linux_wlan->txq_event);
+   down(&wl->txq_event);
/* wait_for_completion(&pd->txq_event); */
PRINT_D(TX_DBG, "txq_task Who waked me up :$\n");
 
-   if (g_linux_wlan->close) {
+   if (wl->close) {
/*Unlock the mutex in the mac_close function to 
indicate the exiting of the TX thread */
-   up(&g_linux_wlan->txq_thread_started);
+   up(&wl->txq_thread_started);
 
while (!kthread_should_stop())
schedule();
@@ -478,10 +483,10 @@ static int linux_wlan_txq_task(void *vp)
if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD /* && 
netif_queue_stopped(pd->wilc_netdev)*/) {
PRINT_D(TX_DBG, "Waking up queue\n");
/* netif_wake_queue(pd->wilc_netdev); */
-   if 
(netif_queue_stopped(g_linux_wlan->vif[0].ndev))
-   
netif_wake_queue(g_linux_wlan->vif[0].ndev);
-   if 
(netif_queue_stopped(g_linux_wlan->vif[1].ndev))
-   
netif_wake_queue(g_linux_wlan->vif[1].ndev);
+   if (netif_queue_stopped(wl->vif[0].ndev))
+   netif_wake_queue(wl->vif[0].ndev);
+   if (netif_queue_stopped(wl->vif[1].ndev))
+   netif_wake_queue(wl->vif[1].ndev);
}
 
if (ret == WILC_TX_ERR_NO_BUF) { /* failed to allocate 
buffers in chip. */
@@ -503,7 +508,7 @@ static int linux_wlan_txq_task(void *vp)
}
}
/*TODO: drop packets after a certain time/number of 
retry count. */
-   } while (ret == WILC_TX_ERR_NO_BUF && !g_linux_wlan->close); /* 
retry sending packets if no more buffers in chip. */
+   } while (ret == WILC_TX_ERR_NO_BUF && !wl->close); /* retry 
sending packets if no more buffers in chip. */
 #endif
}
return 0;
@@ -1024,7 +1029,7 @@ int wlan_initialize_threads(struct net_device *dev)
 
/* create tx task */
PRINT_D(INIT_DBG, "Creating kthread for transmission\n");
-   wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)wilc,
+   wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)dev,
 "K_TXQ_TASK");
if (!wilc->txq_thread) {
PRINT_ER("couldn't create TXQ thread\n");
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 08/27] staging: wilc1000: linux_wlan_set_bssid: use wilc instead of g_linux_wlan

2015-10-27 Thread Glen Lee
This patch uses netdev private data memeber wilc instead of g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 227dedb..8c81de9 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -405,10 +405,15 @@ int linux_wlan_set_bssid(struct net_device *wilc_netdev, 
u8 *pBSSID)
 {
int i = 0;
int ret = -1;
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
 
-   for (i = 0; i < g_linux_wlan->vif_num; i++)
-   if (g_linux_wlan->vif[i].ndev == wilc_netdev) {
-   memcpy(g_linux_wlan->vif[i].bssid, pBSSID, 6);
+   nic = netdev_priv(wilc_netdev);
+   wilc = nic->wilc;
+
+   for (i = 0; i < wilc->vif_num; i++)
+   if (wilc->vif[i].ndev == wilc_netdev) {
+   memcpy(wilc->vif[i].bssid, pBSSID, 6);
ret = 0;
break;
}
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 04/27] staging: wilc1000: wilc_handle_isr: add argument wilc to wilc_handle_isr

2015-10-27 Thread Glen Lee
This patch add new argument wilc to wilc_handle_isr and pass wilc to
the function.
It is void type for now because wilc_wlan.c was implemented platform
independently at the beginning (linux_wlan.c is implementation of LINUX part),
so the header file which defines struct wilc cannot be included at this moment,
but this driver is dedicated to LINUX so wilc_wlan.c and linux_wlan.c will be
merged. After that, this void type will be changed with struct wilc as well as
other functions which are using void type in wilc_wlan.h.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c  | 2 +-
 drivers/staging/wilc1000/linux_wlan_sdio.c | 7 +--
 drivers/staging/wilc1000/wilc_wlan.c   | 2 +-
 drivers/staging/wilc1000/wilc_wlan.h   | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index ac2bc06..54e077d 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -261,7 +261,7 @@ irqreturn_t isr_bh_routine(int irq, void *userdata)
}
 
PRINT_D(INT_DBG, "Interrupt received BH\n");
-   wilc_handle_isr();
+   wilc_handle_isr(wilc);
 
return IRQ_HANDLED;
 }
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.c 
b/drivers/staging/wilc1000/linux_wlan_sdio.c
index 1f8d874..4aff953 100644
--- a/drivers/staging/wilc1000/linux_wlan_sdio.c
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.c
@@ -27,7 +27,6 @@ struct wilc_sdio {
 };
 
 struct sdio_func *local_sdio_func;
-extern void wilc_handle_isr(void);
 
 static unsigned int sdio_default_speed;
 
@@ -42,9 +41,13 @@ static const struct sdio_device_id wilc_sdio_ids[] = {
 
 static void wilc_sdio_interrupt(struct sdio_func *func)
 {
+   struct wilc_sdio *wl_sdio;
+
+   wl_sdio = sdio_get_drvdata(func);
+
 #ifndef WILC_SDIO_IRQ_GPIO
sdio_release_host(func);
-   wilc_handle_isr();
+   wilc_handle_isr(wl_sdio->wilc);
sdio_claim_host(func);
 #endif
 }
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 67b0c52..be6f631 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1353,7 +1353,7 @@ _end_:
wilc_wlan_handle_rxq();
 }
 
-void wilc_handle_isr(void)
+void wilc_handle_isr(void *wilc)
 {
u32 int_status;
 
diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
b/drivers/staging/wilc1000/wilc_wlan.h
index bd89689..a07375b 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -301,7 +301,7 @@ int wilc_wlan_stop(void);
 int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size,
  wilc_tx_complete_func_t func);
 int wilc_wlan_handle_txq(u32 *pu32TxqCount);
-void wilc_handle_isr(void);
+void wilc_handle_isr(void *wilc);
 void wilc_wlan_cleanup(void);
 int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
  int commit, u32 drvHandler);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 05/27] staging: wilc1000: wilc_wlan_handle_isr_ext: add argument struct wilc

2015-10-27 Thread Glen Lee
This patch adds argument struct wilc and pass wilc to the function.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/wilc_wlan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index be6f631..5141fe0 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1260,7 +1260,7 @@ static void wilc_sleeptimer_isr_ext(u32 int_stats1)
 #endif
 }
 
-static void wilc_wlan_handle_isr_ext(u32 int_status)
+static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status)
 {
wilc_wlan_dev_t *p = &g_wlan;
 #ifdef MEMORY_STATIC
@@ -1364,7 +1364,7 @@ void wilc_handle_isr(void *wilc)
wilc_pllupdate_isr_ext(int_status);
 
if (int_status & DATA_INT_EXT) {
-   wilc_wlan_handle_isr_ext(int_status);
+   wilc_wlan_handle_isr_ext(wilc, int_status);
#ifndef WILC_OPTIMIZE_SLEEP_INT
/* Chip is up and talking*/
genuChipPSstate = CHIP_WAKEDUP;
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 07/27] staging: wilc1000: linux_wlan_mac_indicate: add argument and use wilc

2015-10-27 Thread Glen Lee
This patch adds argument wilc and pass the function wilc. Use wilc instead of
g_linux_wlan and pd.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 13 ++---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  2 +-
 drivers/staging/wilc1000/wilc_wlan.c  |  4 ++--
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 54e077d..227dedb 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -348,24 +348,23 @@ int linux_wlan_lock_timeout(void *vp, u32 timeout)
return error;
 }
 
-void linux_wlan_mac_indicate(int flag)
+void linux_wlan_mac_indicate(struct wilc *wilc, int flag)
 {
/*I have to do it that way becuase there is no mean to encapsulate 
device pointer
 * as a parameter
 */
-   struct wilc *pd = g_linux_wlan;
int status;
 
if (flag == WILC_MAC_INDICATE_STATUS) {
wilc_wlan_cfg_get_val(WID_STATUS, (unsigned char *)&status, 4);
-   if (pd->mac_status == WILC_MAC_STATUS_INIT) {
-   pd->mac_status = status;
-   up(&pd->sync_event);
+   if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
+   wilc->mac_status = status;
+   up(&wilc->sync_event);
} else {
-   pd->mac_status = status;
+   wilc->mac_status = status;
}
 
-   if (pd->mac_status == WILC_MAC_STATUS_CONNECT) {/* 
Connect */
+   if (wilc->mac_status == WILC_MAC_STATUS_CONNECT) {/* 
Connect */
}
 
} else if (flag == WILC_MAC_INDICATE_SCAN) {
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 8aa3355..a828fab 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -209,7 +209,7 @@ struct WILC_WFI_mon_priv {
 extern struct wilc *g_linux_wlan;
 extern struct net_device *WILC_WFI_devs[];
 void frmw_to_linux(u8 *buff, u32 size, u32 pkt_offset);
-void linux_wlan_mac_indicate(int flag);
+void linux_wlan_mac_indicate(struct wilc *wilc, int flag);
 void linux_wlan_rx_complete(void);
 void linux_wlan_dbg(u8 *buff);
 int linux_wlan_lock_timeout(void *vp, u32 timeout);
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 4fc88ef..4fa956a 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1199,10 +1199,10 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc)
/**
 *  Call back to indicate 
status...
 **/
-   
linux_wlan_mac_indicate(WILC_MAC_INDICATE_STATUS);
+   linux_wlan_mac_indicate(wilc, 
WILC_MAC_INDICATE_STATUS);
 
} else if (rsp.type == 
WILC_CFG_RSP_SCAN) {
-   
linux_wlan_mac_indicate(WILC_MAC_INDICATE_SCAN);
+   linux_wlan_mac_indicate(wilc, 
WILC_MAC_INDICATE_SCAN);
}
}
}
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 14/27] staging: wilc1000: wlan_deinit_locks: change argument wilc with net_device

2015-10-27 Thread Glen Lee
This patch changes argument wilc with net_device and use netdev private data
member wilc instead of g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index d9f1bf1..c0fac3cd 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -95,7 +95,7 @@ static struct notifier_block g_dev_notifier = {
  */
 static struct semaphore close_exit_sync;
 
-static int wlan_deinit_locks(struct wilc *nic);
+static int wlan_deinit_locks(struct net_device *dev);
 static void wlan_deinitialize_threads(struct wilc *nic);
 extern void WILC_WFI_monitor_rx(u8 *buff, u32 size);
 extern void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size);
@@ -940,7 +940,7 @@ void wilc1000_wlan_deinit(struct net_device *dev)
 
/*De-Initialize locks*/
PRINT_D(INIT_DBG, "Deinitializing Locks\n");
-   wlan_deinit_locks(wl);
+   wlan_deinit_locks(dev);
 
/* announce that wilc1000 is not initialized */
wl->initialized = false;
@@ -978,15 +978,21 @@ int wlan_init_locks(struct net_device *dev)
return 0;
 }
 
-static int wlan_deinit_locks(struct wilc *nic)
+static int wlan_deinit_locks(struct net_device *dev)
 {
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
+
+   nic = netdev_priv(dev);
+   wilc = nic->wilc;
+
PRINT_D(INIT_DBG, "De-Initializing Locks\n");
 
-   if (&g_linux_wlan->hif_cs != NULL)
-   mutex_destroy(&g_linux_wlan->hif_cs);
+   if (&wilc->hif_cs != NULL)
+   mutex_destroy(&wilc->hif_cs);
 
-   if (&g_linux_wlan->rxq_cs != NULL)
-   mutex_destroy(&g_linux_wlan->rxq_cs);
+   if (&wilc->rxq_cs != NULL)
+   mutex_destroy(&wilc->rxq_cs);
 
return 0;
 }
@@ -1169,7 +1175,7 @@ _fail_irq_init_:
 _fail_wilc_wlan_:
wilc_wlan_cleanup();
 _fail_locks_:
-   wlan_deinit_locks(wl);
+   wlan_deinit_locks(dev);
PRINT_ER("WLAN Iinitialization FAILED\n");
} else {
PRINT_D(INIT_DBG, "wilc1000 already initialized\n");
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 16/27] staging: wilc1000: wlan_deinitialize_threads: change argument and use wilc

2015-10-27 Thread Glen Lee
This patch changes function parameter type struct wilc with struct net_device
and use netdev private data member wilc instead of g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 412d5a0..b6244f93 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -96,7 +96,7 @@ static struct notifier_block g_dev_notifier = {
 static struct semaphore close_exit_sync;
 
 static int wlan_deinit_locks(struct net_device *dev);
-static void wlan_deinitialize_threads(struct wilc *nic);
+static void wlan_deinitialize_threads(struct net_device *dev);
 extern void WILC_WFI_monitor_rx(u8 *buff, u32 size);
 extern void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size);
 
@@ -919,7 +919,7 @@ void wilc1000_wlan_deinit(struct net_device *dev)
up(&wl->txq_event);
 
PRINT_D(INIT_DBG, "Deinitializing Threads\n");
-   wlan_deinitialize_threads(wl);
+   wlan_deinitialize_threads(dev);
 
PRINT_D(INIT_DBG, "Deinitializing IRQ\n");
deinit_irq(dev);
@@ -1053,18 +1053,23 @@ _fail_2:
return ret;
 }
 
-static void wlan_deinitialize_threads(struct wilc *nic)
+static void wlan_deinitialize_threads(struct net_device *dev)
 {
+   perInterface_wlan_t *nic;
+   struct wilc *wl;
+
+   nic = netdev_priv(dev);
+   wl = nic->wilc;
 
-   g_linux_wlan->close = 1;
+   wl->close = 1;
PRINT_D(INIT_DBG, "Deinitializing Threads\n");
 
-   if (&g_linux_wlan->txq_event != NULL)
-   up(&g_linux_wlan->txq_event);
+   if (&wl->txq_event != NULL)
+   up(&wl->txq_event);
 
-   if (g_linux_wlan->txq_thread != NULL) {
-   kthread_stop(g_linux_wlan->txq_thread);
-   g_linux_wlan->txq_thread = NULL;
+   if (wl->txq_thread != NULL) {
+   kthread_stop(wl->txq_thread);
+   wl->txq_thread = NULL;
}
 }
 
@@ -1171,7 +1176,7 @@ _fail_irq_init_:
deinit_irq(dev);
 
 #endif
-   wlan_deinitialize_threads(wl);
+   wlan_deinitialize_threads(dev);
 _fail_wilc_wlan_:
wilc_wlan_cleanup();
 _fail_locks_:
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 17/27] staging: wilc1000: mac_ioctl: use private data instead of g_linux_wlan

2015-10-27 Thread Glen Lee
Use netdev private data member wilc instead of g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index b6244f93..bd9f715 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1496,11 +1496,13 @@ int mac_ioctl(struct net_device *ndev, struct ifreq 
*req, int cmd)
perInterface_wlan_t *nic;
struct wilc_priv *priv;
s32 s32Error = 0;
+   struct wilc *wilc;
 
/* struct iwreq *wrq = (struct iwreq *) req;// tony moved to case 
SIOCSIWPRIV */
nic = netdev_priv(ndev);
+   wilc = nic->wilc;
 
-   if (!g_linux_wlan->initialized)
+   if (!wilc->initialized)
return 0;
 
switch (cmd) {
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 12/27] staging: wilc1000: wilc_wlan_txq_filter_dup_tcp_ack: add argument and use wilc

2015-10-27 Thread Glen Lee
This patch add argument net_device dev and use netdev private data member wilc
instead of g_linux_wlan. Pass argument dev to the function.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/wilc_wlan.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 907da93..63712a2 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -406,14 +406,18 @@ static inline int tcp_process(struct txq_entry_t *tqe)
 }
 
 
-static int wilc_wlan_txq_filter_dup_tcp_ack(void)
+static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev)
 {
-
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
u32 i = 0;
u32 Dropped = 0;
wilc_wlan_dev_t *p = &g_wlan;
 
-   spin_lock_irqsave(&g_linux_wlan->txq_spinlock, p->txq_spinlock_flags);
+   nic = netdev_priv(dev);
+   wilc = nic->wilc;
+
+   spin_lock_irqsave(&wilc->txq_spinlock, p->txq_spinlock_flags);
for (i = PendingAcks_arrBase; i < (PendingAcks_arrBase + Pending_Acks); 
i++) {
if (Pending_Acks_info[i].ack_num < 
Acks_keep_track_info[Pending_Acks_info[i].Session_index].Bigger_Ack_num) {
struct txq_entry_t *tqe;
@@ -440,12 +444,11 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(void)
PendingAcks_arrBase = 0;
 
 
-   spin_unlock_irqrestore(&g_linux_wlan->txq_spinlock,
-  p->txq_spinlock_flags);
+   spin_unlock_irqrestore(&wilc->txq_spinlock, p->txq_spinlock_flags);
 
while (Dropped > 0) {
/*consume the semaphore count of the removed packet*/
-   linux_wlan_lock_timeout(&g_linux_wlan->txq_event, 1);
+   linux_wlan_lock_timeout(&wilc->txq_event, 1);
Dropped--;
}
 
@@ -842,7 +845,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*pu32TxqCount)
linux_wlan_lock_timeout(&wilc->txq_add_to_head_cs,
CFG_PKTS_TIMEOUT);
 #ifdef TCP_ACK_FILTER
-   wilc_wlan_txq_filter_dup_tcp_ack();
+   wilc_wlan_txq_filter_dup_tcp_ack(dev);
 #endif
/**
 *  build the vmm list
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 13/27] staging: wilc1000: host_int_init: add argument net_device

2015-10-27 Thread Glen Lee
This patch add argument net_device and pass netdev private data member wilc
to kthread_run. Pass net_device to the function as well.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/host_interface.c | 11 +--
 drivers/staging/wilc1000/host_interface.h |  2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 930dcba..f658594 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -7,6 +7,7 @@
 #include "wilc_wlan_if.h"
 #include "wilc_msgqueue.h"
 #include 
+#include "wilc_wfi_netdevice.h"
 
 extern u8 connecting;
 
@@ -4131,11 +4132,16 @@ void host_int_send_network_info_to_host
 {
 }
 
-s32 host_int_init(struct host_if_drv **hif_drv_handler)
+s32 host_int_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
 {
s32 result = 0;
struct host_if_drv *hif_drv;
int err;
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
+
+   nic = netdev_priv(dev);
+   wilc = nic->wilc;
 
PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", 
clients_count + 1);
 
@@ -4181,7 +4187,8 @@ s32 host_int_init(struct host_if_drv **hif_drv_handler)
goto _fail_;
}
 
-   hif_thread_handler = kthread_run(hostIFthread, NULL, 
"WILC_kthread");
+   hif_thread_handler = kthread_run(hostIFthread, wilc,
+"WILC_kthread");
 
if (IS_ERR(hif_thread_handler)) {
PRINT_ER("Failed to creat Thread\n");
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index f3fb628..0fd2eda 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -911,7 +911,7 @@ void host_int_send_network_info_to_host
  *  @date  8 March 2012
  *  @version   1.0
  */
-s32 host_int_init(struct host_if_drv **phWFIDrv);
+s32 host_int_init(struct net_device *dev, struct host_if_drv **phWFIDrv);
 
 /**
  *  @brief  host interface initialization function
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index ac32d2b..21d053d 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -3464,7 +3464,7 @@ int wilc_init_host_int(struct net_device *net)
priv->bInP2PlistenState = false;
 
sema_init(&(priv->hSemScanReq), 1);
-   s32Error = host_int_init(&priv->hWILCWFIDrv);
+   s32Error = host_int_init(net, &priv->hWILCWFIDrv);
if (s32Error)
PRINT_ER("Error while initializing hostinterface\n");
 
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 15/27] staging: wilc1000: WILC_WFI_mgmt_rx: add argument wilc and use it

2015-10-27 Thread Glen Lee
This patch add new argument wilc and use it instead of g_wlan_linux.
Declare the function in wilc_wfi_netdevice.h.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 10 +-
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  1 +
 drivers/staging/wilc1000/wilc_wlan.c  |  3 +--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index c0fac3cd..412d5a0 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1611,25 +1611,25 @@ void frmw_to_linux(u8 *buff, u32 size, u32 pkt_offset)
}
 }
 
-void WILC_WFI_mgmt_rx(u8 *buff, u32 size)
+void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size)
 {
int i = 0;
perInterface_wlan_t *nic;
 
/*Pass the frame on the monitor interface, if any.*/
/*Otherwise, pass it on p2p0 netdev, if registered on it*/
-   for (i = 0; i < g_linux_wlan->vif_num; i++) {
-   nic = netdev_priv(g_linux_wlan->vif[i].ndev);
+   for (i = 0; i < wilc->vif_num; i++) {
+   nic = netdev_priv(wilc->vif[i].ndev);
if (nic->monitor_flag) {
WILC_WFI_monitor_rx(buff, size);
return;
}
}
 
-   nic = netdev_priv(g_linux_wlan->vif[1].ndev); /* p2p0 */
+   nic = netdev_priv(wilc->vif[1].ndev); /* p2p0 */
if ((buff[0] == nic->g_struct_frame_reg[0].frame_type && 
nic->g_struct_frame_reg[0].reg) ||
(buff[0] == nic->g_struct_frame_reg[1].frame_type && 
nic->g_struct_frame_reg[1].reg))
-   WILC_WFI_p2p_rx(g_linux_wlan->vif[1].ndev, buff, size);
+   WILC_WFI_p2p_rx(wilc->vif[1].ndev, buff, size);
 }
 
 void wl_wlan_cleanup(void)
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index a828fab..8ba69ee 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -216,4 +216,5 @@ int linux_wlan_lock_timeout(void *vp, u32 timeout);
 void wl_wlan_cleanup(void);
 int wilc_netdev_init(struct wilc **wilc);
 void wilc1000_wlan_deinit(struct net_device *dev);
+void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
 #endif
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 63712a2..babd941 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -18,7 +18,6 @@
  /
 extern wilc_hif_func_t hif_sdio;
 extern wilc_hif_func_t hif_spi;
-extern void WILC_WFI_mgmt_rx(u8 *buff, u32 size);
 u32 wilc_get_chipid(u8 update);
 u16 Set_machw_change_vir_if(bool bValue);
 
@@ -1178,7 +1177,7 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc)
/* reset mgmt indicator bit, to use pkt_offeset 
in furthur calculations */
pkt_offset &= ~(IS_MANAGMEMENT | 
IS_MANAGMEMENT_CALLBACK | IS_MGMT_STATUS_SUCCES);
 
-   WILC_WFI_mgmt_rx(&buffer[offset + 
HOST_HDR_OFFSET], pkt_len);
+   WILC_WFI_mgmt_rx(wilc, &buffer[offset + 
HOST_HDR_OFFSET], pkt_len);
}
else
{
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 19/27] staging: wilc1000: wilc_wlan_rxq_remove: add argument wilc and use it

2015-10-27 Thread Glen Lee
This patch adds new argument struct wilc and use it instead of g_linux_wlan.
Pass wilc to wilc_wlan_rxq_remove.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/wilc_wlan.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 7473742..1461b61 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -612,7 +612,7 @@ static int wilc_wlan_rxq_add(struct rxq_entry_t *rqe)
return p->rxq_entries;
 }
 
-static struct rxq_entry_t *wilc_wlan_rxq_remove(void)
+static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
 {
wilc_wlan_dev_t *p = &g_wlan;
 
@@ -620,12 +620,12 @@ static struct rxq_entry_t *wilc_wlan_rxq_remove(void)
if (p->rxq_head) {
struct rxq_entry_t *rqe;
 
-   mutex_lock(&g_linux_wlan->rxq_cs);
+   mutex_lock(&wilc->rxq_cs);
rqe = p->rxq_head;
p->rxq_head = p->rxq_head->next;
p->rxq_entries -= 1;
PRINT_D(RX_DBG, "RXQ entries decreased\n");
-   mutex_unlock(&g_linux_wlan->rxq_cs);
+   mutex_unlock(&wilc->rxq_cs);
return rqe;
}
PRINT_D(RX_DBG, "Nothing to get from Q\n");
@@ -1132,7 +1132,7 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc)
up(&wilc->cfg_event);
break;
}
-   rqe = wilc_wlan_rxq_remove();
+   rqe = wilc_wlan_rxq_remove(wilc);
if (rqe == NULL) {
PRINT_D(RX_DBG, "nothing in the queue - exit 1st 
do-while\n");
break;
@@ -1654,6 +1654,11 @@ void wilc_wlan_cleanup(struct net_device *dev)
struct rxq_entry_t *rqe;
u32 reg = 0;
int ret;
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
+
+   nic = netdev_priv(dev);
+   wilc = nic->wilc;
 
p->quit = 1;
do {
@@ -1666,7 +1671,7 @@ void wilc_wlan_cleanup(struct net_device *dev)
} while (1);
 
do {
-   rqe = wilc_wlan_rxq_remove();
+   rqe = wilc_wlan_rxq_remove(wilc);
if (rqe == NULL)
break;
 #ifndef MEMORY_STATIC
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 18/27] staging: wilc1000: wilc_wlan_cleanup: add new argument struct net_device

2015-10-27 Thread Glen Lee
This patch adds new function argument net_device and pass dev to the functions.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 4 ++--
 drivers/staging/wilc1000/wilc_wlan.c  | 2 +-
 drivers/staging/wilc1000/wilc_wlan.h  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index bd9f715..d193af8 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -927,7 +927,7 @@ void wilc1000_wlan_deinit(struct net_device *dev)
wilc_wlan_stop();
 
PRINT_D(INIT_DBG, "Deinitializing WILC Wlan\n");
-   wilc_wlan_cleanup();
+   wilc_wlan_cleanup(dev);
 #if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
   #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || 
defined(PLAT_ALLWINNER_A31)
PRINT_D(INIT_DBG, "Disabling IRQ 2\n");
@@ -1178,7 +1178,7 @@ _fail_irq_init_:
 #endif
wlan_deinitialize_threads(dev);
 _fail_wilc_wlan_:
-   wilc_wlan_cleanup();
+   wilc_wlan_cleanup(dev);
 _fail_locks_:
wlan_deinit_locks(dev);
PRINT_ER("WLAN Iinitialization FAILED\n");
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index babd941..7473742 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1647,7 +1647,7 @@ int wilc_wlan_stop(void)
return ret;
 }
 
-void wilc_wlan_cleanup(void)
+void wilc_wlan_cleanup(struct net_device *dev)
 {
wilc_wlan_dev_t *p = &g_wlan;
struct txq_entry_t *tqe;
diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
b/drivers/staging/wilc1000/wilc_wlan.h
index 79b35e6..d0b2448 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -302,7 +302,7 @@ int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 
buffer_size,
  wilc_tx_complete_func_t func);
 int wilc_wlan_handle_txq(struct net_device *dev, u32 *pu32TxqCount);
 void wilc_handle_isr(void *wilc);
-void wilc_wlan_cleanup(void);
+void wilc_wlan_cleanup(struct net_device *dev);
 int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
  int commit, u32 drvHandler);
 int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drvHandler);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 21/27] staging: wilc1000: GetIfHandler: add argument struct wilc and use it

2015-10-27 Thread Glen Lee
This patch adds new argument struct wilc and use it instead of
g_linux_wlan. And also pass wilc to the function.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 6293410..1f5c8f3 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -374,7 +374,7 @@ void linux_wlan_mac_indicate(struct wilc *wilc, int flag)
 
 }
 
-struct net_device *GetIfHandler(u8 *pMacHeader)
+struct net_device *GetIfHandler(struct wilc *wilc, u8 *pMacHeader)
 {
u8 *Bssid, *Bssid1;
int i = 0;
@@ -382,20 +382,20 @@ struct net_device *GetIfHandler(u8 *pMacHeader)
Bssid  = pMacHeader + 10;
Bssid1 = pMacHeader + 4;
 
-   for (i = 0; i < g_linux_wlan->vif_num; i++)
-   if (!memcmp(Bssid1, g_linux_wlan->vif[i].bssid, ETH_ALEN) ||
-   !memcmp(Bssid, g_linux_wlan->vif[i].bssid, ETH_ALEN))
-   return g_linux_wlan->vif[i].ndev;
+   for (i = 0; i < wilc->vif_num; i++)
+   if (!memcmp(Bssid1, wilc->vif[i].bssid, ETH_ALEN) ||
+   !memcmp(Bssid, wilc->vif[i].bssid, ETH_ALEN))
+   return wilc->vif[i].ndev;
 
PRINT_INFO(INIT_DBG, "Invalide handle\n");
for (i = 0; i < 25; i++)
PRINT_D(INIT_DBG, "%02x ", pMacHeader[i]);
Bssid  = pMacHeader + 18;
Bssid1 = pMacHeader + 12;
-   for (i = 0; i < g_linux_wlan->vif_num; i++)
-   if (!memcmp(Bssid1, g_linux_wlan->vif[i].bssid, ETH_ALEN) ||
-   !memcmp(Bssid, g_linux_wlan->vif[i].bssid, ETH_ALEN))
-   return g_linux_wlan->vif[i].ndev;
+   for (i = 0; i < wilc->vif_num; i++)
+   if (!memcmp(Bssid1, wilc->vif[i].bssid, ETH_ALEN) ||
+   !memcmp(Bssid, wilc->vif[i].bssid, ETH_ALEN))
+   return wilc->vif[i].ndev;
 
PRINT_INFO(INIT_DBG, "\n");
return NULL;
@@ -1567,7 +1567,7 @@ void frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, 
u32 pkt_offset)
struct net_device *wilc_netdev;
perInterface_wlan_t *nic;
 
-   wilc_netdev = GetIfHandler(buff);
+   wilc_netdev = GetIfHandler(wilc, buff);
if (wilc_netdev == NULL)
return;
 
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 26/27] staging: wilc1000: wilc_wlan_txq_add_net_pkt: add argument struct net_device

2015-10-27 Thread Glen Lee
This patch add new argument struct net_device *dev and pass net_device to
wilc_wlan_txq_add_net_pkt.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 4 ++--
 drivers/staging/wilc1000/wilc_wlan.c  | 4 ++--
 drivers/staging/wilc1000/wilc_wlan.h  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 9a105ceb..2a5b36f 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1413,8 +1413,8 @@ int mac_xmit(struct sk_buff *skb, struct net_device *ndev)
nic->netstats.tx_packets++;
nic->netstats.tx_bytes += tx_data->size;
tx_data->pBssid = wilc->vif[nic->u8IfIdx].bssid;
-   QueueCount = wilc_wlan_txq_add_net_pkt((void *)tx_data, tx_data->buff,
-  tx_data->size,
+   QueueCount = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data,
+  tx_data->buff, tx_data->size,
   linux_wlan_tx_complete);
 
if (QueueCount > FLOW_CONTROL_UPPER_THRESHOLD) {
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index b109289..14a56d6 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -502,8 +502,8 @@ static int wilc_wlan_txq_add_cfg_pkt(u8 *buffer, u32 
buffer_size)
return 1;
 }
 
-int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size,
- wilc_tx_complete_func_t func)
+int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
+ u32 buffer_size, wilc_tx_complete_func_t func)
 {
wilc_wlan_dev_t *p = &g_wlan;
struct txq_entry_t *tqe;
diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
b/drivers/staging/wilc1000/wilc_wlan.h
index d0b2448..57e1d51 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -298,8 +298,8 @@ typedef struct {
 int wilc_wlan_firmware_download(const u8 *buffer, u32 buffer_size);
 int wilc_wlan_start(void);
 int wilc_wlan_stop(void);
-int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size,
- wilc_tx_complete_func_t func);
+int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
+ u32 buffer_size, wilc_tx_complete_func_t func);
 int wilc_wlan_handle_txq(struct net_device *dev, u32 *pu32TxqCount);
 void wilc_handle_isr(void *wilc);
 void wilc_wlan_cleanup(struct net_device *dev);
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 23/27] staging: wilc1000: wilc_wlan_rxq_add: add argument wilc and use it

2015-10-27 Thread Glen Lee
This patch adds new argument struct wilc and use it instead of g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/wilc_wlan.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index aebc9a6..a6b966f 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -586,14 +586,14 @@ static struct txq_entry_t *wilc_wlan_txq_get_next(struct 
txq_entry_t *tqe)
return tqe;
 }
 
-static int wilc_wlan_rxq_add(struct rxq_entry_t *rqe)
+static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)
 {
wilc_wlan_dev_t *p = &g_wlan;
 
if (p->quit)
return 0;
 
-   mutex_lock(&g_linux_wlan->rxq_cs);
+   mutex_lock(&wilc->rxq_cs);
if (p->rxq_head == NULL) {
PRINT_D(RX_DBG, "Add to Queue head\n");
rqe->next = NULL;
@@ -607,7 +607,7 @@ static int wilc_wlan_rxq_add(struct rxq_entry_t *rqe)
}
p->rxq_entries += 1;
PRINT_D(RX_DBG, "Number of queue entries: %d\n", p->rxq_entries);
-   mutex_unlock(&g_linux_wlan->rxq_cs);
+   mutex_unlock(&wilc->rxq_cs);
return p->rxq_entries;
 }
 
@@ -1349,7 +1349,7 @@ _end_:
rqe->buffer = buffer;
rqe->buffer_size = size;
PRINT_D(RX_DBG, "rxq entery Size= %d - Address 
= %p\n", rqe->buffer_size, rqe->buffer);
-   wilc_wlan_rxq_add(rqe);
+   wilc_wlan_rxq_add(wilc, rqe);
}
} else {
 #ifndef MEMORY_STATIC
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 27/27] staging: wilc1000: tcp_process: add argument dev and use private data

2015-10-27 Thread Glen Lee
This patch adds new argument net_device and use netdev private data member
wilc instead of g_linux_wlan. Pass argument dev to the function as well.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/wilc_wlan.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 14a56d6..c026657 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -341,7 +341,7 @@ static inline int remove_TCP_related(void)
return 0;
 }
 
-static inline int tcp_process(struct txq_entry_t *tqe)
+static inline int tcp_process(struct net_device *dev, struct txq_entry_t *tqe)
 {
int ret;
u8 *eth_hdr_ptr;
@@ -350,8 +350,13 @@ static inline int tcp_process(struct txq_entry_t *tqe)
int i;
wilc_wlan_dev_t *p = &g_wlan;
unsigned long flags;
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
 
-   spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
+   nic = netdev_priv(dev);
+   wilc = nic->wilc;
+
+   spin_lock_irqsave(&wilc->txq_spinlock, flags);
 
eth_hdr_ptr = &buffer[0];
h_proto = ntohs(*((unsigned short *)ð_hdr_ptr[12]));
@@ -399,7 +404,7 @@ static inline int tcp_process(struct txq_entry_t *tqe)
} else {
ret = 0;
}
-   spin_unlock_irqrestore(&g_linux_wlan->txq_spinlock, flags);
+   spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
return ret;
 }
 
@@ -525,7 +530,7 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void 
*priv, u8 *buffer,
 #ifdef TCP_ACK_FILTER
tqe->tcp_PendingAck_index = NOT_TCP_ACK;
if (is_TCP_ACK_Filter_Enabled())
-   tcp_process(tqe);
+   tcp_process(dev, tqe);
 #endif
wilc_wlan_txq_add_to_tail(tqe);
/*return number of itemes in the queue*/
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 24/27] staging: wilc1000: wilc_wlan_txq_get_next: add argument wilc

2015-10-27 Thread Glen Lee
This patch adds new argument struct wilc and use wilc instead of g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/wilc_wlan.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index a6b966f..b109289 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -574,13 +574,14 @@ static struct txq_entry_t *wilc_wlan_txq_get_first(void)
return tqe;
 }
 
-static struct txq_entry_t *wilc_wlan_txq_get_next(struct txq_entry_t *tqe)
+static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc,
+ struct txq_entry_t *tqe)
 {
unsigned long flags;
-   spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
+   spin_lock_irqsave(&wilc->txq_spinlock, flags);
 
tqe = tqe->next;
-   spin_unlock_irqrestore(&g_linux_wlan->txq_spinlock, flags);
+   spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
 
 
return tqe;
@@ -887,7 +888,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*pu32TxqCount)
i++;
sum += vmm_sz;
PRINT_D(TX_DBG, "sum = %d\n", sum);
-   tqe = wilc_wlan_txq_get_next(tqe);
+   tqe = wilc_wlan_txq_get_next(wilc, tqe);
} else {
break;
}
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 22/27] staging: wilc1000: Set_machw_change_vir_if: add argument struct net_device

2015-10-27 Thread Glen Lee
Add new argument net_device and use netdev private data member wilc
instead of g_linux_wlan. Pass argument dev to the function as well.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c |  3 +--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  7 +++
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  1 +
 drivers/staging/wilc1000/wilc_wlan.c  | 12 
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 1f5c8f3..d839f3b 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -46,7 +46,6 @@
 #endif
 
 extern bool g_obtainingIP;
-extern u16 Set_machw_change_vir_if(bool bValue);
 extern void resolve_disconnect_aberration(void *drvHandler);
 extern u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
 extern struct timer_list hDuringIpTimer;
@@ -1244,7 +1243,7 @@ int mac_open(struct net_device *ndev)
return ret;
}
 
-   Set_machw_change_vir_if(false);
+   Set_machw_change_vir_if(ndev, false);
 
host_int_get_MacAddress(priv->hWILCWFIDrv, mac_add);
PRINT_D(INIT_DBG, "Mac address: %pM\n", mac_add);
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 21d053d..bf7a2a2 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -22,7 +22,6 @@
 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
 
 extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
-extern u16 Set_machw_change_vir_if(bool bValue);
 
 extern int mac_open(struct net_device *ndev);
 extern int mac_close(struct net_device *ndev);
@@ -1413,7 +1412,7 @@ static int del_key(struct wiphy *wiphy, struct net_device 
*netdev,
g_key_gtk_params.seq = NULL;
 
/*Reset WILC_CHANGING_VIR_IF register to allow adding futrue 
keys to CE H/W*/
-   Set_machw_change_vir_if(false);
+   Set_machw_change_vir_if(netdev, false);
}
 
if (key_index >= 0 && key_index <= 3) {
@@ -2562,7 +2561,7 @@ static int change_virtual_intf(struct wiphy *wiphy, 
struct net_device *dev,
PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
/*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to 
CE H/W*/
if (g_ptk_keys_saved && g_gtk_keys_saved) {
-   Set_machw_change_vir_if(true);
+   Set_machw_change_vir_if(dev, true);
}
 
switch (type) {
@@ -2724,7 +2723,7 @@ static int change_virtual_intf(struct wiphy *wiphy, 
struct net_device *dev,
 
/*Refresh scan, to refresh the scan results to the 
wpa_supplicant. Set MachHw to false to enable further key installments*/
refresh_scan(priv, 1, true);
-   Set_machw_change_vir_if(false);
+   Set_machw_change_vir_if(dev, false);
 
if (wl->initialized){
for (i = 0; i < num_reg_frame; i++) {
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index bca3e25..0bfe762 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -217,4 +217,5 @@ void wl_wlan_cleanup(void);
 int wilc_netdev_init(struct wilc **wilc);
 void wilc1000_wlan_deinit(struct net_device *dev);
 void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
+u16 Set_machw_change_vir_if(struct net_device *dev, bool bValue);
 #endif
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 35c4c32d..aebc9a6 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -19,7 +19,6 @@
 extern wilc_hif_func_t hif_sdio;
 extern wilc_hif_func_t hif_spi;
 u32 wilc_get_chipid(u8 update);
-u16 Set_machw_change_vir_if(bool bValue);
 
 
 
@@ -2033,13 +2032,18 @@ _fail_:
 
 }
 
-u16 Set_machw_change_vir_if(bool bValue)
+u16 Set_machw_change_vir_if(struct net_device *dev, bool bValue)
 {
u16 ret;
u32 reg;
+   perInterface_wlan_t *nic;
+   struct wilc *wilc;
+
+   nic = netdev_priv(dev);
+   wilc = nic->wilc;
 
/*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE 
H/W*/
-   mutex_lock(&g_linux_wlan->hif_cs);
+   mutex_lock(&wilc->hif_cs);
ret = (&g_wlan)->hif_func.hif_read_reg(WILC_CHANGING_VIR_IF, ®);
if (!ret)
PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n");
@@ -2054,7 +2058,7 @@ u16 Set_machw_change_vir_if(bool bValue)
if (!ret)
PRINT_ER("Error while writing reg WILC_CHANGING_VIR_IF\n");
 
-   mutex_unlock(&g_linux_wlan->hif_cs);
+   mutex_unlock(&wilc->hif_cs);
 
return ret;
 }

[PATCH V2 25/27] staging: wilc1000: mac_xmit: use netdev private wilc instead of g_linux_wlan

2015-10-27 Thread Glen Lee
This patch uses netdev private data member wilc instead of g_linux_wlan.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index d839f3b..9a105ceb 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1366,8 +1366,10 @@ int mac_xmit(struct sk_buff *skb, struct net_device 
*ndev)
char *pu8UdpBuffer;
struct iphdr *ih;
struct ethhdr *eth_h;
+   struct wilc *wilc;
 
nic = netdev_priv(ndev);
+   wilc = nic->wilc;
 
PRINT_D(TX_DBG, "Sending packet just received from TCP/IP\n");
 
@@ -1410,14 +1412,14 @@ int mac_xmit(struct sk_buff *skb, struct net_device 
*ndev)
PRINT_D(TX_DBG, "Adding tx packet to TX Queue\n");
nic->netstats.tx_packets++;
nic->netstats.tx_bytes += tx_data->size;
-   tx_data->pBssid = g_linux_wlan->vif[nic->u8IfIdx].bssid;
+   tx_data->pBssid = wilc->vif[nic->u8IfIdx].bssid;
QueueCount = wilc_wlan_txq_add_net_pkt((void *)tx_data, tx_data->buff,
   tx_data->size,
   linux_wlan_tx_complete);
 
if (QueueCount > FLOW_CONTROL_UPPER_THRESHOLD) {
-   netif_stop_queue(g_linux_wlan->vif[0].ndev);
-   netif_stop_queue(g_linux_wlan->vif[1].ndev);
+   netif_stop_queue(wilc->vif[0].ndev);
+   netif_stop_queue(wilc->vif[1].ndev);
}
 
return 0;
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V2 20/27] staging: wilc1000: frmw_to_linux: add argument struct wilc

2015-10-27 Thread Glen Lee
This patch adds new argument struct wilc and use it instead of
g_linux_wlan. Pass argument wilc to the function as well.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/linux_wlan.c | 6 +++---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +-
 drivers/staging/wilc1000/wilc_wlan.c  | 3 ++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index d193af8..6293410 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1557,7 +1557,7 @@ done:
return s32Error;
 }
 
-void frmw_to_linux(u8 *buff, u32 size, u32 pkt_offset)
+void frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset)
 {
 
unsigned int frame_len = 0;
@@ -1586,8 +1586,8 @@ void frmw_to_linux(u8 *buff, u32 size, u32 pkt_offset)
return;
}
 
-   if (g_linux_wlan == NULL || wilc_netdev == NULL)
-   PRINT_ER("wilc_netdev in g_linux_wlan is NULL");
+   if (wilc == NULL || wilc_netdev == NULL)
+   PRINT_ER("wilc_netdev in wilc is NULL");
skb->dev = wilc_netdev;
 
if (skb->dev == NULL)
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 8ba69ee..bca3e25 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -208,7 +208,7 @@ struct WILC_WFI_mon_priv {
 
 extern struct wilc *g_linux_wlan;
 extern struct net_device *WILC_WFI_devs[];
-void frmw_to_linux(u8 *buff, u32 size, u32 pkt_offset);
+void frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
 void linux_wlan_mac_indicate(struct wilc *wilc, int flag);
 void linux_wlan_rx_complete(void);
 void linux_wlan_dbg(u8 *buff);
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 1461b61..35c4c32d 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1184,7 +1184,8 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc)
 
if (!is_cfg_packet) {
if (pkt_len > 0) {
-   frmw_to_linux(&buffer[offset],
+   frmw_to_linux(wilc,
+ &buffer[offset],
  pkt_len,
  pkt_offset);
has_packet = 1;
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/4 v2] staging: ipath: ipath_driver: Use setup_timer

2015-10-27 Thread Leon Romanovsky
On Tue, Oct 27, 2015 at 11:19 AM, Dan Carpenter
 wrote:
> On Sun, Oct 25, 2015 at 01:21:11PM +0200, Leon Romanovsky wrote:
>> On Sun, Oct 25, 2015 at 12:17 PM, Muhammad Falak R Wani
>>  wrote:
>> Please follow standard naming convention for the patches.
>> It should be [PATCH v2 1/4] and not [PATCH 1/4 v2].
>
> Does this matter?  It's in a thread so it sorts fine either way.
It will be wise if people read guides and follow examples.

[1] https://www.kernel.org/doc/Documentation/SubmittingPatches


>
> regards,
> dan carpenter
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 08/10] staging: fsl-mc: Fixed bug in dprc_probe() error path

2015-10-27 Thread Dan Carpenter
On Mon, Oct 26, 2015 at 10:49:19AM -0500, J. German Rivera wrote:
> -error_cleanup_open:
> +dprc_scan_container_error:
>   (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);

The error label was better in the original code.  A "goto
error_cleanup_open", that tells you what the goto does.  "goto
dprc_scan_container_error" tells you nothing because you can see from
the line before that there was a container error.  No new information.
It's just like a function name tells you what a function does.  You
wouldn't name the function called_from_main().

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8188eu: fixed width data types replaced by int

2015-10-27 Thread Dan Carpenter
On Tue, Oct 27, 2015 at 12:04:12AM +0700, Ivan Safonov wrote:
> There is no need to use fixed width data types.
> 

True enough, this patch is fine.  But we use u32 for "unsigned int" in
many places just because it is shorter to type.  Don't do a wholesale
changing of these types. There should always be a reason for using s32
so feel free to do a re-typing of those.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/4 v2] staging: ipath: ipath_driver: Use setup_timer

2015-10-27 Thread Dan Carpenter
On Tue, Oct 27, 2015 at 11:45:18AM +0200, Leon Romanovsky wrote:
> On Tue, Oct 27, 2015 at 11:19 AM, Dan Carpenter
>  wrote:
> > On Sun, Oct 25, 2015 at 01:21:11PM +0200, Leon Romanovsky wrote:
> >> On Sun, Oct 25, 2015 at 12:17 PM, Muhammad Falak R Wani
> >>  wrote:
> >> Please follow standard naming convention for the patches.
> >> It should be [PATCH v2 1/4] and not [PATCH 1/4 v2].
> >
> > Does this matter?  It's in a thread so it sorts fine either way.
> It will be wise if people read guides and follow examples.
> 
> [1] https://www.kernel.org/doc/Documentation/SubmittingPatches

That document doesn't really specify one way or the other.  And even if
it did then why would you care?  Stop being so picky for no reason.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/8] staging: wilc1000: rename u8WepKeylen in host_int_add_wep_key_bss_sta

2015-10-27 Thread Chaehyun Lim
This patch changes u8WepKeylen to len that is third argument of
host_int_add_wep_key_bss_sta to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/host_interface.c | 8 
 drivers/staging/wilc1000/host_interface.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 1cb2095..b45bec4 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3159,7 +3159,7 @@ int host_int_set_wep_default_key(struct host_if_drv 
*hif_drv, u8 index)
 
 int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
 const u8 *key,
-u8 u8WepKeylen,
+u8 len,
 u8 u8Keyidx)
 {
int result = 0;
@@ -3177,9 +3177,9 @@ int host_int_add_wep_key_bss_sta(struct host_if_drv 
*hif_drv,
msg.body.key_info.type = WEP;
msg.body.key_info.action = ADDKEY;
msg.drv = hif_drv;
-   msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
-   memcpy(msg.body.key_info.attr.wep.key, key, u8WepKeylen);
-   msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
+   msg.body.key_info.attr.wep.key = kmalloc(len, GFP_KERNEL);
+   memcpy(msg.body.key_info.attr.wep.key, key, len);
+   msg.body.key_info.attr.wep.key_len = len;
msg.body.key_info.attr.wep.index = u8Keyidx;
 
result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 55a7274..0d8835d 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -405,7 +405,7 @@ int host_int_set_wep_default_key(struct host_if_drv 
*hif_drv, u8 index);
  *  @date  8 March 2012
  *  @version   1.0
  */
-int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv, const u8 *key, 
u8 u8WepKeylen, u8 u8Keyidx);
+int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv, const u8 *key, 
u8 len, u8 u8Keyidx);
 /**
  *  @brief  host_int_add_wep_key_bss_ap
  *  @detailsvalid only in AP mode if External Supplicant support is 
enabled.
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/8] staging: wilc1000: fix return type of host_int_add_wep_key_bss_sta

2015-10-27 Thread Chaehyun Lim
This patch changes return type of host_int_add_wep_key_bss_sta from s32
to int. The result variable gets return value from wilc_mq_send that has
return type of int. It should be changed return type of this function
as well as data type of result variable.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/host_interface.c | 4 ++--
 drivers/staging/wilc1000/host_interface.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 930dcba..702b7c8 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3157,12 +3157,12 @@ int host_int_set_wep_default_key(struct host_if_drv 
*hif_drv, u8 index)
return result;
 }
 
-s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
+int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
 const u8 *pu8WepKey,
 u8 u8WepKeylen,
 u8 u8Keyidx)
 {
-   s32 result = 0;
+   int result = 0;
struct host_if_msg msg;
 
if (!hif_drv) {
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index f3fb628..fd8257b 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -405,7 +405,7 @@ int host_int_set_wep_default_key(struct host_if_drv 
*hif_drv, u8 index);
  *  @date  8 March 2012
  *  @version   1.0
  */
-s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hWFIDrv, const u8 
*pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx);
+int host_int_add_wep_key_bss_sta(struct host_if_drv *hWFIDrv, const u8 
*pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx);
 /**
  *  @brief  host_int_add_wep_key_bss_ap
  *  @detailsvalid only in AP mode if External Supplicant support is 
enabled.
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/8] staging: wilc1000: rename pu8WepKey in host_int_add_wep_key_bss_sta

2015-10-27 Thread Chaehyun Lim
This patch changes pu8WepKey to key that is second argument of
host_int_add_wep_key_bss_sta to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/host_interface.c | 4 ++--
 drivers/staging/wilc1000/host_interface.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 702b7c8..1cb2095 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3158,7 +3158,7 @@ int host_int_set_wep_default_key(struct host_if_drv 
*hif_drv, u8 index)
 }
 
 int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
-const u8 *pu8WepKey,
+const u8 *key,
 u8 u8WepKeylen,
 u8 u8Keyidx)
 {
@@ -3178,7 +3178,7 @@ int host_int_add_wep_key_bss_sta(struct host_if_drv 
*hif_drv,
msg.body.key_info.action = ADDKEY;
msg.drv = hif_drv;
msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
-   memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, u8WepKeylen);
+   memcpy(msg.body.key_info.attr.wep.key, key, u8WepKeylen);
msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
msg.body.key_info.attr.wep.index = u8Keyidx;
 
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 3579aac..55a7274 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -405,7 +405,7 @@ int host_int_set_wep_default_key(struct host_if_drv 
*hif_drv, u8 index);
  *  @date  8 March 2012
  *  @version   1.0
  */
-int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv, const u8 
*pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx);
+int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv, const u8 *key, 
u8 u8WepKeylen, u8 u8Keyidx);
 /**
  *  @brief  host_int_add_wep_key_bss_ap
  *  @detailsvalid only in AP mode if External Supplicant support is 
enabled.
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/8] staging: wilc1000: fix parameter name of function declaration

2015-10-27 Thread Chaehyun Lim
This patch changes struct host_if_drv of host_int_add_wep_key_bss_sta
function declaration from hWFIDrv to hif_drv.
With this change, first parameter name of this function declaration and
definition has same name as hif_drv.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/host_interface.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index fd8257b..3579aac 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -405,7 +405,7 @@ int host_int_set_wep_default_key(struct host_if_drv 
*hif_drv, u8 index);
  *  @date  8 March 2012
  *  @version   1.0
  */
-int host_int_add_wep_key_bss_sta(struct host_if_drv *hWFIDrv, const u8 
*pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx);
+int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv, const u8 
*pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx);
 /**
  *  @brief  host_int_add_wep_key_bss_ap
  *  @detailsvalid only in AP mode if External Supplicant support is 
enabled.
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/8] staging: wilc1000: replace kmalloc/memcpy with kmemdup

2015-10-27 Thread Chaehyun Lim
This patch replaces kmalloc followed by memcpy with kmemdup.
It is also added error checking of kmemdup.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/host_interface.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index f7dc61b..50362c4 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3177,8 +3177,10 @@ int host_int_add_wep_key_bss_sta(struct host_if_drv 
*hif_drv,
msg.body.key_info.type = WEP;
msg.body.key_info.action = ADDKEY;
msg.drv = hif_drv;
-   msg.body.key_info.attr.wep.key = kmalloc(len, GFP_KERNEL);
-   memcpy(msg.body.key_info.attr.wep.key, key, len);
+   msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
+   if (!msg.body.key_info.attr.wep.key)
+   return -ENOMEM;
+
msg.body.key_info.attr.wep.key_len = len;
msg.body.key_info.attr.wep.index = index;
 
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/8] staging: wilc1000: rename u8Keyidx in host_int_add_wep_key_bss_sta

2015-10-27 Thread Chaehyun Lim
This patch changes u8Keyidx to index that is fourth argument of
host_int_add_wep_key_bss_sta to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/host_interface.c | 4 ++--
 drivers/staging/wilc1000/host_interface.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index b45bec4..f7dc61b 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3160,7 +3160,7 @@ int host_int_set_wep_default_key(struct host_if_drv 
*hif_drv, u8 index)
 int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
 const u8 *key,
 u8 len,
-u8 u8Keyidx)
+u8 index)
 {
int result = 0;
struct host_if_msg msg;
@@ -3180,7 +3180,7 @@ int host_int_add_wep_key_bss_sta(struct host_if_drv 
*hif_drv,
msg.body.key_info.attr.wep.key = kmalloc(len, GFP_KERNEL);
memcpy(msg.body.key_info.attr.wep.key, key, len);
msg.body.key_info.attr.wep.key_len = len;
-   msg.body.key_info.attr.wep.index = u8Keyidx;
+   msg.body.key_info.attr.wep.index = index;
 
result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
if (result)
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 0d8835d..1e134d4 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -405,7 +405,7 @@ int host_int_set_wep_default_key(struct host_if_drv 
*hif_drv, u8 index);
  *  @date  8 March 2012
  *  @version   1.0
  */
-int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv, const u8 *key, 
u8 len, u8 u8Keyidx);
+int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv, const u8 *key, 
u8 len, u8 index);
 /**
  *  @brief  host_int_add_wep_key_bss_ap
  *  @detailsvalid only in AP mode if External Supplicant support is 
enabled.
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 8/8] staging: wilc1000: remove multiple blank lines

2015-10-27 Thread Chaehyun Lim
This patch removes multiple blank lines found by checkpatch.

CHECK: Please don't use multiple blank lines
FILE: drivers/staging/wilc1000/host_interface.c:3175:

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/host_interface.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 50362c4..5a23738 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3172,7 +3172,6 @@ int host_int_add_wep_key_bss_sta(struct host_if_drv 
*hif_drv,
 
memset(&msg, 0, sizeof(struct host_if_msg));
 
-
msg.id = HOST_IF_MSG_KEY;
msg.body.key_info.type = WEP;
msg.body.key_info.action = ADDKEY;
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 7/8] staging: wilc1000: fix line over 80 characters

2015-10-27 Thread Chaehyun Lim
This patch fixes line over 80 characters found by checkpatch.

WARNING: line over 80 characters
FILE: drivers/staging/wilc1000/host_interface.h:408:

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/host_interface.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 1e134d4..a9f7d1d 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -405,7 +405,8 @@ int host_int_set_wep_default_key(struct host_if_drv 
*hif_drv, u8 index);
  *  @date  8 March 2012
  *  @version   1.0
  */
-int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv, const u8 *key, 
u8 len, u8 index);
+int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
+const u8 *key, u8 len, u8 index);
 /**
  *  @brief  host_int_add_wep_key_bss_ap
  *  @detailsvalid only in AP mode if External Supplicant support is 
enabled.
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH V2 11/27] staging: wilc1000: wilc_wlan_handle_txq: add argument and use wilc

2015-10-27 Thread kbuild test robot
Hi Glen,

[auto build test WARNING on staging/staging-next -- if it's inappropriate base, 
please suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Glen-Lee/staging-wicl1000-isr_uh_routine-use-netdev-private-wilc/20151027-173115
config: i386-allyesconfig (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from drivers/staging/wilc1000/coreconfigurator.c:13:0:
>> drivers/staging/wilc1000/wilc_wlan.h:303:33: warning: 'struct net_device' 
>> declared inside parameter list
int wilc_wlan_handle_txq(struct net_device *dev, u32 *pu32TxqCount);
^
>> drivers/staging/wilc1000/wilc_wlan.h:303:33: warning: its scope is only this 
>> definition or declaration, which is probably not what you want

vim +303 drivers/staging/wilc1000/wilc_wlan.h

   287  } wilc_cfg_frame_t;
   288  
   289  typedef struct {
   290  int (*wlan_tx)(u8 *, u32, wilc_tx_complete_func_t);
   291  } wilc_wlan_cfg_func_t;
   292  
   293  typedef struct {
   294  int type;
   295  u32 seq_no;
   296  } wilc_cfg_rsp_t;
   297  
   298  int wilc_wlan_firmware_download(const u8 *buffer, u32 buffer_size);
   299  int wilc_wlan_start(void);
   300  int wilc_wlan_stop(void);
   301  int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size,
   302wilc_tx_complete_func_t func);
 > 303  int wilc_wlan_handle_txq(struct net_device *dev, u32 *pu32TxqCount);
   304  void wilc_handle_isr(void *wilc);
   305  void wilc_wlan_cleanup(void);
   306  int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
   307int commit, u32 drvHandler);
   308  int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drvHandler);
   309  int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size);
   310  int wilc_wlan_txq_add_mgmt_pkt(void *priv, u8 *buffer, u32 buffer_size,
   311 wilc_tx_complete_func_t func);

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] Staging: android: uapi: fixed comment block coding style error in ion.h

2015-10-27 Thread Dzonatans Melgalvis
Fixed checkpatch.pl warning about comment block coding style.

Signed-off-by: Dzonatans Melgalvis http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH V2 13/27] staging: wilc1000: host_int_init: add argument net_device

2015-10-27 Thread kbuild test robot
Hi Glen,

[auto build test ERROR on staging/staging-next -- if it's inappropriate base, 
please suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Glen-Lee/staging-wicl1000-isr_uh_routine-use-netdev-private-wilc/20151027-173115
config: i386-allyesconfig (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from drivers/staging/wilc1000/host_interface.c:5:0:
>> drivers/staging/wilc1000/host_interface.h:914:50: warning: 'struct 
>> net_device' declared inside parameter list
s32 host_int_init(struct net_device *dev, struct host_if_drv **phWFIDrv);
 ^
>> drivers/staging/wilc1000/host_interface.h:914:50: warning: its scope is only 
>> this definition or declaration, which is probably not what you want
>> drivers/staging/wilc1000/host_interface.c:4135:5: error: conflicting types 
>> for 'host_int_init'
s32 host_int_init(struct net_device *dev, struct host_if_drv 
**hif_drv_handler)
^
   In file included from drivers/staging/wilc1000/host_interface.c:5:0:
   drivers/staging/wilc1000/host_interface.h:914:5: note: previous declaration 
of 'host_int_init' was here
s32 host_int_init(struct net_device *dev, struct host_if_drv **phWFIDrv);
^

vim +/host_int_init +4135 drivers/staging/wilc1000/host_interface.c

  4129  
  4130  void host_int_send_network_info_to_host
  4131  (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
  4132  {
  4133  }
  4134  
> 4135  s32 host_int_init(struct net_device *dev, struct host_if_drv 
> **hif_drv_handler)
  4136  {
  4137  s32 result = 0;
  4138  struct host_if_drv *hif_drv;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/4 v2] staging: ipath: ipath_driver: Use setup_timer

2015-10-27 Thread Muhammad Falak R Wani


On October 27, 2015 4:40:42 PM GMT+05:30, Dan Carpenter 
 wrote:
>On Tue, Oct 27, 2015 at 11:45:18AM +0200, Leon Romanovsky wrote:
>> On Tue, Oct 27, 2015 at 11:19 AM, Dan Carpenter
>>  wrote:
>> > On Sun, Oct 25, 2015 at 01:21:11PM +0200, Leon Romanovsky wrote:
>> >> On Sun, Oct 25, 2015 at 12:17 PM, Muhammad Falak R Wani
>> >>  wrote:
>> >> Please follow standard naming convention for the patches.
>> >> It should be [PATCH v2 1/4] and not [PATCH 1/4 v2].
>> >
>> > Does this matter?  It's in a thread so it sorts fine either way.
>> It will be wise if people read guides and follow examples.
>> 
>> [1] https://www.kernel.org/doc/Documentation/SubmittingPatches
>
>That document doesn't really specify one way or the other.  And even if
>it did then why would you care?  Stop being so picky for no reason.
>
>regards,
>dan carpenter

Sorry, my bad . Won't repeat such mistakes.
-- 
mfrw
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: board: Set PM domain before probe

2015-10-27 Thread Tomeu Vizoso
PM domains shouldn't be modified after a device is probed, so set it
before device registration to be sure of that.

In the future the PM domain pointer will be set through a setter that
will WARN if the device has been probed already.

Signed-off-by: Tomeu Vizoso 
Cc: Geert Uytterhoeven 
---
 drivers/staging/board/board.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index 3eb5eb8f069c..965afc79aadd 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -187,6 +187,9 @@ int __init board_staging_register_device(const struct 
board_staging_dev *dev)
for (i = 0; i < dev->nclocks; i++)
board_staging_register_clock(&dev->clocks[i]);
 
+   if (dev->domain)
+   board_staging_add_dev_domain(pdev, dev->domain);
+
error = platform_device_register(pdev);
if (error) {
pr_err("Failed to register device %s (%d)\n", pdev->name,
@@ -194,9 +197,6 @@ int __init board_staging_register_device(const struct 
board_staging_dev *dev)
return error;
}
 
-   if (dev->domain)
-   board_staging_add_dev_domain(pdev, dev->domain);
-
return error;
 }
 
-- 
2.5.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: board: Set PM domain before probe

2015-10-27 Thread Geert Uytterhoeven
On Tue, Oct 27, 2015 at 3:27 PM, Tomeu Vizoso
 wrote:
> PM domains shouldn't be modified after a device is probed, so set it
> before device registration to be sure of that.
>
> In the future the PM domain pointer will be set through a setter that
> will WARN if the device has been probed already.
>
> Signed-off-by: Tomeu Vizoso 
> Cc: Geert Uytterhoeven 

Tested-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 05/20] staging: rtl8188eu: ternary operator (?:) replaced by min_t kernel macro

2015-10-27 Thread Ivan Safonov
min_t macro better conveys the meaning of the code.

Signed-off-by: Ivan Safonov 
---
Changes in v2:
  - min replaced by mit_t.

 drivers/staging/rtl8188eu/core/rtw_efuse.c | 2 +-
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c  | 2 +-
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c 
b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index 685ce98..eb89423 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -268,7 +268,7 @@ static void efuse_read_phymap_from_txpktbuf(
aaa = le16_to_cpup((__le16 *)&lo32);
len = le16_to_cpu(*((__le16 *)&lo32));
 
-   limit = (len-2 < limit) ? len-2 : limit;
+   limit = min_t(u16, len-2, limit);
 
DBG_88E("%s len:%u, lenbak:%u, aaa:%u, aaabak:%u\n", 
__func__, len, lenbak, aaa, aaabak);
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index cc5806f..4e6f1a8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -3239,7 +3239,7 @@ static unsigned int OnAssocReq(struct adapter *padapter,
pstat->flags |= WLAN_STA_WPS;
copy_len = 0;
} else {
-   copy_len = ((wpa_ie_len+2) > sizeof(pstat->wpa_ie)) ? 
(sizeof(pstat->wpa_ie)) : (wpa_ie_len+2);
+   copy_len = min_t(int, wpa_ie_len + 2, 
sizeof(pstat->wpa_ie));
}
if (copy_len > 0)
memcpy(pstat->wpa_ie, wpa_ie-2, copy_len);
diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 9c11ef4..a076ede 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -2669,7 +2669,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, 
struct ieee_param *param)
int copy_len;
 
wpa_ie_len = psta->wpa_ie[1];
-   copy_len = ((wpa_ie_len+2) > sizeof(psta->wpa_ie)) ? 
(sizeof(psta->wpa_ie)) : (wpa_ie_len+2);
+   copy_len = min_t(int, wpa_ie_len + 2, 
sizeof(psta->wpa_ie));
param->u.wpa_ie.len = copy_len;
memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, 
copy_len);
} else {
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 08/20] staging: rtl8188eu: unused MEM_ALIGNMENT_OFFSET and MEM_ALIGNMENT_PADDING macros removed

2015-10-27 Thread Ivan Safonov
This patch removes unused MEM_ALIGNMENT_OFFSET and MEM_ALIGNMENT_PADDING macros
from include/basic_types.h.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/include/basic_types.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/include/basic_types.h 
b/drivers/staging/rtl8188eu/include/basic_types.h
index 485d5c7..6a2a147 100644
--- a/drivers/staging/rtl8188eu/include/basic_types.h
+++ b/drivers/staging/rtl8188eu/include/basic_types.h
@@ -27,9 +27,6 @@ typedef void (*proc_t)(void *);
 
 #define FIELD_OFFSET(s, field) ((ssize_t)&((s *)(0))->field)
 
-#define MEM_ALIGNMENT_OFFSET   (sizeof(size_t))
-#define MEM_ALIGNMENT_PADDING  (sizeof(size_t) - 1)
-
 /* port from fw */
 /*  TODO: Macros Below are Sync from SD7-Driver. It is necessary
  * to check correctness */
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 17/20] staging: rtl8188eu: checkpatch fixes: line over 80 characters splited into two parts

2015-10-27 Thread Ivan Safonov
This is checkpatch fixes for hal/bb_cfg.c file:
line over 80 characters.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/hal/bb_cfg.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c 
b/drivers/staging/rtl8188eu/hal/bb_cfg.c
index 82990ed..5ab8277 100644
--- a/drivers/staging/rtl8188eu/hal/bb_cfg.c
+++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c
@@ -500,7 +500,8 @@ static u32 array_phy_reg_pg_8188e[] = {
 
 };
 
-static void store_pwrindex_offset(struct adapter *Adapter, u32 regaddr, u32 
bitmask, u32 data)
+static void store_pwrindex_offset(struct adapter *Adapter,
+ u32 regaddr, u32 bitmask, u32 data)
 {
struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter);
 u8 pwrGrpCnt = hal_data->pwrGroupCnt;
@@ -705,18 +706,21 @@ bool rtl88eu_phy_bb_config(struct adapter *adapt)
 
/*  Enable BB and RF */
regval = usb_read16(adapt, REG_SYS_FUNC_EN);
-   usb_write16(adapt, REG_SYS_FUNC_EN, (u16)(regval | BIT(13) | BIT(0) | 
BIT(1)));
+   usb_write16(adapt, REG_SYS_FUNC_EN,
+   (u16)(regval | BIT(13) | BIT(0) | BIT(1)));
 
usb_write8(adapt, REG_RF_CTRL, RF_EN | RF_RSTB | RF_SDMRSTB);
 
-   usb_write8(adapt, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | 
FEN_BB_GLB_RSTn | FEN_BBRSTB);
+   usb_write8(adapt, REG_SYS_FUNC_EN, FEN_USBA |
+  FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB);
 
/*  Config BB and AGC */
rtstatus = config_parafile(adapt);
 
/*  write 0x24[16:11] = 0x24[22:17] = crystal_cap */
crystal_cap = hal_data->CrystalCap & 0x3F;
-   phy_set_bb_reg(adapt, REG_AFE_XTAL_CTRL, 0x7ff800, (crystal_cap | 
(crystal_cap << 6)));
+   phy_set_bb_reg(adapt, REG_AFE_XTAL_CTRL, 0x7ff800,
+  (crystal_cap | (crystal_cap << 6)));
 
return rtstatus;
 }
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 03/20] staging: rtl8188eu: ternary operator (?:) replaced by min/max kernel macro

2015-10-27 Thread Ivan Safonov
min (or max) kernel macro better conveys the meaning of the code.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/hal/odm_RTL8188E.c   | 6 ++
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 ++--
 drivers/staging/rtl8188eu/os_dep/xmit_linux.c  | 2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c 
b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c
index 0be6c05..c0242a0 100644
--- a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c
+++ b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c
@@ -292,8 +292,7 @@ static void rtl88eu_dm_hw_ant_div(struct odm_dm_struct 
*dm_odm)

(dm_fat_tbl->AuxAnt_Sum[i]/dm_fat_tbl->AuxAnt_Cnt[i]) : 0;
target_ant = (main_rssi >= aux_rssi) ? MAIN_ANT : 
AUX_ANT;
/* 2 Select max_rssi for DIG */
-   local_max_rssi = (main_rssi > aux_rssi) ?
- main_rssi : aux_rssi;
+   local_max_rssi = max(main_rssi, aux_rssi);
if ((local_max_rssi > ant_div_max_rssi) &&
(local_max_rssi < 40))
ant_div_max_rssi = local_max_rssi;
@@ -308,8 +307,7 @@ static void rtl88eu_dm_hw_ant_div(struct odm_dm_struct 
*dm_odm)
 (aux_rssi == 0))
aux_rssi = main_rssi;
 
-   local_min_rssi = (main_rssi > aux_rssi) ?
- aux_rssi : main_rssi;
+   local_min_rssi = min(main_rssi, aux_rssi);
if (local_min_rssi < min_rssi) {
min_rssi = local_min_rssi;
RxIdleAnt = target_ant;
diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index bda423e..fd01ca4 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -604,7 +604,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char 
*pie, unsigned short ie
if ((eid == _VENDOR_SPECIFIC_IE_) && 
(!memcmp(&buf[cnt+2], wps_oui, 4))) {
DBG_88E("SET WPS_IE\n");
 
-   padapter->securitypriv.wps_ie_len = 
((buf[cnt+1]+2) < (MAX_WPA_IE_LEN<<2)) ? (buf[cnt+1]+2) : (MAX_WPA_IE_LEN<<2);
+   padapter->securitypriv.wps_ie_len = 
min(buf[cnt + 1] + 2, MAX_WPA_IE_LEN << 2);
 
memcpy(padapter->securitypriv.wps_ie, 
&buf[cnt], padapter->securitypriv.wps_ie_len);
 
@@ -2974,7 +2974,7 @@ static int rtw_wx_set_priv(struct net_device *dev,
 
if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) &&
(!memcmp(&probereq_wpsie[2], wps_oui, 4))) {
-   cp_sz = probereq_wpsie_len > MAX_WPS_IE_LEN ? 
MAX_WPS_IE_LEN : probereq_wpsie_len;
+   cp_sz = min(probereq_wpsie_len, MAX_WPS_IE_LEN);
 
pmlmepriv->wps_probe_req_ie_len = 0;
kfree(pmlmepriv->wps_probe_req_ie);
diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c 
b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
index 5acf9a9..1593e28 100644
--- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
@@ -52,7 +52,7 @@ uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint 
rlen)
 
 
len =  rtw_remainder_len(pfile);
-   len = (rlen > len) ? len : rlen;
+   len = min(rlen, len);
 
if (rmem)
skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len, rmem, 
len);
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 18/20] staging: rtl8188eu: checkpatch fixes: 'Avoid CamelCase' in hal/bb_cfg.c

2015-10-27 Thread Ivan Safonov
This is checkpatch fixes for hal/bb_cfg.c file: Avoid CamelCase.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/hal/bb_cfg.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c 
b/drivers/staging/rtl8188eu/hal/bb_cfg.c
index 5ab8277..a553468 100644
--- a/drivers/staging/rtl8188eu/hal/bb_cfg.c
+++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c
@@ -500,10 +500,10 @@ static u32 array_phy_reg_pg_8188e[] = {
 
 };
 
-static void store_pwrindex_offset(struct adapter *Adapter,
+static void store_pwrindex_offset(struct adapter *adapter,
  u32 regaddr, u32 bitmask, u32 data)
 {
-   struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter);
+   struct hal_data_8188e *hal_data = GET_HAL_DATA(adapter);
 u8 pwrGrpCnt = hal_data->pwrGroupCnt;
 
if (regaddr == rTxAGC_A_Rate18_06)
@@ -590,9 +590,9 @@ static bool config_bb_with_pgheader(struct adapter *adapt)
return true;
 }
 
-static void rtl88e_phy_init_bb_rf_register_definition(struct adapter *Adapter)
+static void rtl88e_phy_init_bb_rf_register_definition(struct adapter *adapter)
 {
-   struct hal_data_8188e   *hal_data = GET_HAL_DATA(Adapter);
+   struct hal_data_8188e   *hal_data = GET_HAL_DATA(adapter);
struct bb_reg_def   *reg[4];
 
reg[RF_PATH_A] = &hal_data->PHYRegDef[RF_PATH_A];
@@ -681,13 +681,13 @@ static void 
rtl88e_phy_init_bb_rf_register_definition(struct adapter *Adapter)
 
 static bool config_parafile(struct adapter *adapt)
 {
-   struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(adapt);
+   struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt);
struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt);
 
set_baseband_phy_config(adapt);
 
/* If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */
-   if (!pEEPROM->bautoload_fail_flag) {
+   if (!eeprom->bautoload_fail_flag) {
hal_data->pwrGroupCnt = 0;
config_bb_with_pgheader(adapt);
}
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 02/20] staging: rtl8188eu: clamp kernel macro used in proc_get_rx_signal

2015-10-27 Thread Ivan Safonov
To limit the range of integers there is clamp macro.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/core/rtw_debug.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_debug.c 
b/drivers/staging/rtl8188eu/core/rtw_debug.c
index 993c7db..2c4afb8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_debug.c
+++ b/drivers/staging/rtl8188eu/core/rtw_debug.c
@@ -594,8 +594,7 @@ int proc_set_rx_signal(struct file *file, const char __user 
*buffer,
if (is_signal_dbg && num != 2)
return count;
 
-   signal_strength = signal_strength > 100 ? 100 : signal_strength;
-   signal_strength = signal_strength < 0 ? 0 : signal_strength;
+   signal_strength = clamp(signal_strength, 0, 100);
 
padapter->recvpriv.is_signal_dbg = is_signal_dbg;
padapter->recvpriv.signal_strength_dbg = signal_strength;
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 09/20] staging: rtl8188eu: unused MIN macro removed

2015-10-27 Thread Ivan Safonov
This patch removes unused MIN macro from include/rtw_security.h.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/include/rtw_security.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/include/rtw_security.h 
b/drivers/staging/rtl8188eu/include/rtw_security.h
index abe7e21..a1aebe6 100644
--- a/drivers/staging/rtl8188eu/include/rtw_security.h
+++ b/drivers/staging/rtl8188eu/include/rtw_security.h
@@ -336,9 +336,6 @@ static const unsigned long K[64] = {
 #define Sigma1(x)   (S(x, 6) ^ S(x, 11) ^ S(x, 25))
 #define Gamma0(x)   (S(x, 7) ^ S(x, 18) ^ R(x, 3))
 #define Gamma1(x)   (S(x, 17) ^ S(x, 19) ^ R(x, 10))
-#ifndef MIN
-#define MIN(x, y) (((x) < (y)) ? (x) : (y))
-#endif
 
 void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key);
 void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b);
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 10/20] staging: rtl8188eu: while loop replaced by for loop in rtw_restruct_wmm_ie

2015-10-27 Thread Ivan Safonov
This patch replaces while loop with for loop, because the initial condition and 
the increment clearly and briefly defined for this loop.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/core/rtw_mlme.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index 2b917a1..c1b82f7 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -1709,8 +1709,8 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 
*in_ie, u8 *out_ie, uint in_
unsignedint ielength = 0;
unsigned int i, j;
 
-   i = 12; /* after the fixed IE */
-   while (i < in_len) {
+   /* i = 12; after the fixed IE */
+   for (i = 12; i < in_len; i += (in_ie[i + 1] + 2) /* to the next IE 
element */) {
ielength = initial_out_len;
 
if (in_ie[i] == 0xDD && in_ie[i+2] == 0x00 && in_ie[i+3] == 
0x50  && in_ie[i+4] == 0xF2 && in_ie[i+5] == 0x02 && i+5 < in_len) {
@@ -1726,7 +1726,6 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 
*in_ie, u8 *out_ie, uint in_
out_ie[initial_out_len + 8] = 0x00;
break;
}
-   i += (in_ie[i+1]+2); /*  to the next IE element */
}
return ielength;
 }
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 16/20] staging: rtl8188eu: checkpatch fixes: alignment should match open parenthesis

2015-10-27 Thread Ivan Safonov
This is checkpatch fixes for hal/bb_cfg.c file:
alignment should match open parenthesis.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/hal/bb_cfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c 
b/drivers/staging/rtl8188eu/hal/bb_cfg.c
index 167b6a0..82990ed 100644
--- a/drivers/staging/rtl8188eu/hal/bb_cfg.c
+++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c
@@ -546,7 +546,7 @@ static void store_pwrindex_offset(struct adapter *Adapter, 
u32 regaddr, u32 bitm
 }
 
 static void rtl_addr_delay(struct adapter *adapt,
-   u32 addr, u32 bit_mask, u32 data)
+  u32 addr, u32 bit_mask, u32 data)
 {
switch (addr) {
case 0xfe:
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 04/20] staging: rtl8188eu: ternary operator (?:) replaced by min_t kernel macro

2015-10-27 Thread Ivan Safonov
min_t macro better conveys the meaning of the code.

Signed-off-by: Ivan Safonov 
---
Changes in v2:
  - min replaced by mit_t.

 drivers/staging/rtl8188eu/core/rtw_ap.c|  2 +-
 drivers/staging/rtl8188eu/core/rtw_ieee80211.c |  2 +-
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c  |  4 ++--
 drivers/staging/rtl8188eu/core/rtw_wlan_util.c |  4 ++--
 drivers/staging/rtl8188eu/hal/odm_HWConfig.c   |  2 +-
 drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c   |  2 +-
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 20 ++--
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c  |  5 ++---
 8 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 5c45f8a..3cdb40f 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -1795,7 +1795,7 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 
new_ch, u8 ch_offset)
plist = plist->next;
 
issue_action_spct_ch_switch(padapter, psta->hwaddr, new_ch, 
ch_offset);
-   psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : 
(pstapriv->expire_to * 2);
+   psta->expire_to = min_t(unsigned int, pstapriv->expire_to * 2, 
5);
}
spin_unlock_bh(&pstapriv->asoc_list_lock);
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c 
b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
index 82d4e88..742b29c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
@@ -1392,6 +1392,6 @@ static const char *_action_public_str[] = {
 
 const char *action_public_str(u8 action)
 {
-   action = (action >= ACT_PUBLIC_MAX) ? ACT_PUBLIC_MAX : action;
+   action = min_t(u8, action, ACT_PUBLIC_MAX);
return _action_public_str[action];
 }
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index e15c198..cc5806f 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -418,7 +418,7 @@ static void issue_beacon(struct adapter *padapter, int 
timeout_ms)
 
/*  supported rates... */
rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
-   pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : 
rate_len), cur_network->SupportedRates, &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, min_t(unsigned int, 
rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen);
 
/*  DS parameter set */
pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char 
*)&(cur_network->Configuration.DSConfig), &pattrib->pktlen);
@@ -578,7 +578,7 @@ static void issue_probersp(struct adapter *padapter, 
unsigned char *da)
 
/*  supported rates... */
rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
-   pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 
8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, min_t(unsigned 
int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen);
 
/*  DS parameter set */
pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char 
*)&(cur_network->Configuration.DSConfig), &pattrib->pktlen);
diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c 
b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
index 3bb40a7fe..59b4432 100644
--- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
@@ -1227,7 +1227,7 @@ unsigned int update_basic_rate(unsigned char *ptn, 
unsigned int ptn_sz)
unsigned int i, num_of_rate;
unsigned int mask = 0;
 
-   num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz;
+   num_of_rate = min_t(unsigned int, ptn_sz, NumRates);
 
for (i = 0; i < num_of_rate; i++) {
if ((*(ptn + i)) & 0x80)
@@ -1241,7 +1241,7 @@ unsigned int update_supported_rate(unsigned char *ptn, 
unsigned int ptn_sz)
unsigned int i, num_of_rate;
unsigned int mask = 0;
 
-   num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz;
+   num_of_rate = min_t(unsigned int, ptn_sz, NumRates);
 
for (i = 0; i < num_of_rate; i++)
mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i));
diff --git a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c 
b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c
index 3dd6cff..28b9f7f 100644
--- a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c
+++ b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c
@@ -394,7 +394,7 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct 
*dm_odm,
OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap>>i) & 
BIT(0);
 
if (pEntry->rssi_stat.ValidBit == 64) {
-   Weighting = ((OFDM_pkt<<4) > 64) ? 64 : (O

[PATCH v2 00/20] staging: rtl8188eu: code cleanups

2015-10-27 Thread Ivan Safonov
Kernel macros used,
unnecessary macro removed,
some checkpatch fixes performed
and other changes added.
---
Changes in v2:
  - patch 21 subject corrected.
  - patch 15 (staging: rtl8188eu: BITn macro replaced by BIT(n) in hal/bb_cfg.c)
removed. It is no longer relevant.
  - min replaced by mit_t in 4 and 5 patch.

Ivan Safonov (20):
  staging: rtl8188eu: sizeof/sizeof replaced by ARRAY_SIZE kernel macro
  staging: rtl8188eu: clamp kernel macro used in proc_get_rx_signal
  staging: rtl8188eu: ternary operator (?:) replaced by min/max kernel
macro
  staging: rtl8188eu: ternary operator (?:) replaced by min_t kernel
macro
  staging: rtl8188eu: ternary operator (?:) replaced by min_t kernel
macro
  staging: rtl8188eu: abs kernel macro used in simularity_compare
function
  staging: rtl8188eu: unused SUCCESS and FAIL macros removed
  staging: rtl8188eu: unused MEM_ALIGNMENT_OFFSET and
MEM_ALIGNMENT_PADDING macros removed
  staging: rtl8188eu: unused MIN macro removed
  staging: rtl8188eu: while loop replaced by for loop in
rtw_restruct_wmm_ie
  staging: rtl8188eu: increment placed into for loop header
  staging: rtl8188eu: occurrence of the 5 GHz code marked
  staging: rtl8188eu: operator = replaced by += in loop increment
  staging: rtl8188eu: checkpatch fixes: spaces preferred around that '|'
in hal/bb_cfg.c
  staging: rtl8188eu: checkpatch fixes: unnecessary parentheses removed
in hal/bb_cfg.c
  staging: rtl8188eu: checkpatch fixes: alignment should match open
parenthesis
  staging: rtl8188eu: checkpatch fixes: line over 80 characters splited
into two parts
  staging: rtl8188eu: checkpatch fixes: 'Avoid CamelCase' in
hal/bb_cfg.c
  staging: rtl8188eu: new variable for
hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt] in
store_pwrindex_offset function
  staging: rtl8188eu: pwrGrpCnt variable removed in
store_pwrindex_offset function

 drivers/staging/rtl8188eu/core/rtw_ap.c   |  2 +-
 drivers/staging/rtl8188eu/core/rtw_debug.c|  3 +-
 drivers/staging/rtl8188eu/core/rtw_efuse.c|  2 +-
 drivers/staging/rtl8188eu/core/rtw_ieee80211.c|  2 +-
 drivers/staging/rtl8188eu/core/rtw_mlme.c |  5 +-
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c |  9 ++-
 drivers/staging/rtl8188eu/core/rtw_recv.c |  6 +-
 drivers/staging/rtl8188eu/core/rtw_wlan_util.c|  4 +-
 drivers/staging/rtl8188eu/hal/bb_cfg.c| 69 ---
 drivers/staging/rtl8188eu/hal/mac_cfg.c   |  4 +-
 drivers/staging/rtl8188eu/hal/odm_HWConfig.c  |  2 +-
 drivers/staging/rtl8188eu/hal/odm_RTL8188E.c  |  6 +-
 drivers/staging/rtl8188eu/hal/phy.c   |  2 +-
 drivers/staging/rtl8188eu/hal/rf_cfg.c|  2 +-
 drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c  |  2 +-
 drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c |  3 +
 drivers/staging/rtl8188eu/include/basic_types.h   |  6 --
 drivers/staging/rtl8188eu/include/rtw_security.h  |  3 -
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c| 28 -
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c |  5 +-
 drivers/staging/rtl8188eu/os_dep/xmit_linux.c |  2 +-
 21 files changed, 80 insertions(+), 87 deletions(-)

-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 01/20] staging: rtl8188eu: sizeof/sizeof replaced by ARRAY_SIZE kernel macro

2015-10-27 Thread Ivan Safonov
ARRAY_SIZE shorter and more difficult to create bugs.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/hal/mac_cfg.c| 2 +-
 drivers/staging/rtl8188eu/hal/rf_cfg.c | 2 +-
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/mac_cfg.c 
b/drivers/staging/rtl8188eu/hal/mac_cfg.c
index febc83a..b867db5 100644
--- a/drivers/staging/rtl8188eu/hal/mac_cfg.c
+++ b/drivers/staging/rtl8188eu/hal/mac_cfg.c
@@ -123,7 +123,7 @@ bool rtl88eu_phy_mac_config(struct adapter *adapt)
u32 arraylength;
u32 *ptrarray;
 
-   arraylength = sizeof(array_MAC_REG_8188E)/sizeof(u32);
+   arraylength = ARRAY_SIZE(array_MAC_REG_8188E);
ptrarray = array_MAC_REG_8188E;
 
for (i = 0; i < arraylength; i = i + 2)
diff --git a/drivers/staging/rtl8188eu/hal/rf_cfg.c 
b/drivers/staging/rtl8188eu/hal/rf_cfg.c
index a3f1aba..4494542 100644
--- a/drivers/staging/rtl8188eu/hal/rf_cfg.c
+++ b/drivers/staging/rtl8188eu/hal/rf_cfg.c
@@ -198,7 +198,7 @@ static void rtl8188e_config_rf_reg(struct adapter *adapt,
 static bool rtl88e_phy_config_rf_with_headerfile(struct adapter *adapt)
 {
u32 i;
-   u32 array_len = sizeof(Array_RadioA_1T_8188E)/sizeof(u32);
+   u32 array_len = ARRAY_SIZE(Array_RadioA_1T_8188E);
u32 *array = Array_RadioA_1T_8188E;
 
for (i = 0; i < array_len; i += 2) {
diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 9695749..bda423e 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -3091,7 +3091,7 @@ static struct iw_statistics 
*rtw_get_wireless_stats(struct net_device *dev)
 
 struct iw_handler_def rtw_handlers_def = {
.standard = rtw_handlers,
-   .num_standard = sizeof(rtw_handlers) / sizeof(iw_handler),
+   .num_standard = ARRAY_SIZE(rtw_handlers),
.get_wireless_stats = rtw_get_wireless_stats,
 };
 
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 06/20] staging: rtl8188eu: abs kernel macro used in simularity_compare function

2015-10-27 Thread Ivan Safonov
abs macro is useful for determining the difference between the two integers.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/hal/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/phy.c 
b/drivers/staging/rtl8188eu/hal/phy.c
index bb3c777..d3e8a8e 100644
--- a/drivers/staging/rtl8188eu/hal/phy.c
+++ b/drivers/staging/rtl8188eu/hal/phy.c
@@ -1013,7 +1013,7 @@ static bool simularity_compare(struct adapter *adapt, s32 
resulta[][8],
tmp2 = resulta[c2][i];
}
 
-   diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1);
+   diff = abs(tmp1 - tmp2);
 
if (diff > MAX_TOLERANCE) {
if ((i == 2 || i == 6) && !sim_bitmap) {
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 15/20] staging: rtl8188eu: checkpatch fixes: unnecessary parentheses removed in hal/bb_cfg.c

2015-10-27 Thread Ivan Safonov
This is checkpatch fixes for hal/bb_cfg.c file:
unnecessary parentheses around .

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/hal/bb_cfg.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c 
b/drivers/staging/rtl8188eu/hal/bb_cfg.c
index 6042c1a..167b6a0 100644
--- a/drivers/staging/rtl8188eu/hal/bb_cfg.c
+++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c
@@ -594,10 +594,10 @@ static void 
rtl88e_phy_init_bb_rf_register_definition(struct adapter *Adapter)
struct hal_data_8188e   *hal_data = GET_HAL_DATA(Adapter);
struct bb_reg_def   *reg[4];
 
-   reg[RF_PATH_A] = &(hal_data->PHYRegDef[RF_PATH_A]);
-   reg[RF_PATH_B] = &(hal_data->PHYRegDef[RF_PATH_B]);
-   reg[RF_PATH_C] = &(hal_data->PHYRegDef[RF_PATH_C]);
-   reg[RF_PATH_D] = &(hal_data->PHYRegDef[RF_PATH_D]);
+   reg[RF_PATH_A] = &hal_data->PHYRegDef[RF_PATH_A];
+   reg[RF_PATH_B] = &hal_data->PHYRegDef[RF_PATH_B];
+   reg[RF_PATH_C] = &hal_data->PHYRegDef[RF_PATH_C];
+   reg[RF_PATH_D] = &hal_data->PHYRegDef[RF_PATH_D];
 
reg[RF_PATH_A]->rfintfs = rFPGA0_XAB_RFInterfaceSW;
reg[RF_PATH_B]->rfintfs = rFPGA0_XAB_RFInterfaceSW;
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 14/20] staging: rtl8188eu: checkpatch fixes: spaces preferred around that '|' in hal/bb_cfg.c

2015-10-27 Thread Ivan Safonov
This is checkpatch fixes for hal/bb_cfg.c file:
spaces preferred around that '|'.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/hal/bb_cfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c 
b/drivers/staging/rtl8188eu/hal/bb_cfg.c
index 264d7e3..6042c1a 100644
--- a/drivers/staging/rtl8188eu/hal/bb_cfg.c
+++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c
@@ -707,7 +707,7 @@ bool rtl88eu_phy_bb_config(struct adapter *adapt)
regval = usb_read16(adapt, REG_SYS_FUNC_EN);
usb_write16(adapt, REG_SYS_FUNC_EN, (u16)(regval | BIT(13) | BIT(0) | 
BIT(1)));
 
-   usb_write8(adapt, REG_RF_CTRL, RF_EN|RF_RSTB|RF_SDMRSTB);
+   usb_write8(adapt, REG_RF_CTRL, RF_EN | RF_RSTB | RF_SDMRSTB);
 
usb_write8(adapt, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | 
FEN_BB_GLB_RSTn | FEN_BBRSTB);
 
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 13/20] staging: rtl8188eu: operator = replaced by += in loop increment

2015-10-27 Thread Ivan Safonov
x = x + a and x += a equivalen, but second preferably.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/core/rtw_recv.c | 6 +++---
 drivers/staging/rtl8188eu/hal/mac_cfg.c   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index cb90ad5..110b8c0 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -1277,7 +1277,7 @@ static int validate_recv_frame(struct adapter *adapter,
int i;
DBG_88E("#\n");
 
-   for (i = 0; i < 64; i = i+8)
+   for (i = 0; i < 64; i += 8)
DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", 
*(ptr+i),
*(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), 
*(ptr+i+5), *(ptr+i+6), *(ptr+i+7));
DBG_88E("#\n");
@@ -1286,7 +1286,7 @@ static int validate_recv_frame(struct adapter *adapter,
int i;
DBG_88E("#\n");
 
-   for (i = 0; i < 64; i = i+8)
+   for (i = 0; i < 64; i += 8)

DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i),
*(ptr+i+1), *(ptr+i+2), *(ptr+i+3), 
*(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7));
DBG_88E("#\n");
@@ -1296,7 +1296,7 @@ static int validate_recv_frame(struct adapter *adapter,
int i;
DBG_88E("#\n");
 
-   for (i = 0; i < 64; i = i+8)
+   for (i = 0; i < 64; i += 8)

DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i),
*(ptr+i+1), *(ptr+i+2), *(ptr+i+3), 
*(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7));
DBG_88E("#\n");
diff --git a/drivers/staging/rtl8188eu/hal/mac_cfg.c 
b/drivers/staging/rtl8188eu/hal/mac_cfg.c
index b867db5..0bc1b21 100644
--- a/drivers/staging/rtl8188eu/hal/mac_cfg.c
+++ b/drivers/staging/rtl8188eu/hal/mac_cfg.c
@@ -126,7 +126,7 @@ bool rtl88eu_phy_mac_config(struct adapter *adapt)
arraylength = ARRAY_SIZE(array_MAC_REG_8188E);
ptrarray = array_MAC_REG_8188E;
 
-   for (i = 0; i < arraylength; i = i + 2)
+   for (i = 0; i < arraylength; i += 2)
usb_write8(adapt, ptrarray[i], (u8)ptrarray[i + 1]);
 
usb_write8(adapt, REG_MAX_AGGR_NUM, MAX_AGGR_NUM);
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 20/20] staging: rtl8188eu: pwrGrpCnt variable removed in store_pwrindex_offset function

2015-10-27 Thread Ivan Safonov
This variable used only once in the beginning of the function,
it can be removed.

Signed-off-by: Ivan Safonov 
---
Changes in v2:
  - subject corrected.

 drivers/staging/rtl8188eu/hal/bb_cfg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c 
b/drivers/staging/rtl8188eu/hal/bb_cfg.c
index 7c52303..f58a822 100644
--- a/drivers/staging/rtl8188eu/hal/bb_cfg.c
+++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c
@@ -504,9 +504,8 @@ static void store_pwrindex_offset(struct adapter *adapter,
  u32 regaddr, u32 bitmask, u32 data)
 {
struct hal_data_8188e *hal_data = GET_HAL_DATA(adapter);
-u8 pwrGrpCnt = hal_data->pwrGroupCnt;
u32 * const power_level_offset =
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt];
+   hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt];
 
if (regaddr == rTxAGC_A_Rate18_06)
power_level_offset[0] = data;
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 11/20] staging: rtl8188eu: increment placed into for loop header

2015-10-27 Thread Ivan Safonov
The increment at the end of the cycle, and it can be placed in the loop header.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 4e6f1a8..d900546 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -1181,7 +1181,7 @@ static void issue_assocreq(struct adapter *padapter)
}
 
/* vendor specific IE, such as WPA, WMM, WPS */
-   for (i = sizeof(struct ndis_802_11_fixed_ie); i < 
pmlmeinfo->network.IELength;) {
+   for (i = sizeof(struct ndis_802_11_fixed_ie); i < 
pmlmeinfo->network.IELength; i += (pIE->Length + 2)) {
pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.IEs + i);
 
switch (pIE->ElementID) {
@@ -1202,7 +1202,6 @@ static void issue_assocreq(struct adapter *padapter)
default:
break;
}
-   i += (pIE->Length + 2);
}
 
if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK)
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 07/20] staging: rtl8188eu: unused SUCCESS and FAIL macros removed

2015-10-27 Thread Ivan Safonov
This patch removes unused SUCCESS and FAIL macros in include/basic_types.h.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/include/basic_types.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/include/basic_types.h 
b/drivers/staging/rtl8188eu/include/basic_types.h
index 8a7ca99..485d5c7 100644
--- a/drivers/staging/rtl8188eu/include/basic_types.h
+++ b/drivers/staging/rtl8188eu/include/basic_types.h
@@ -20,9 +20,6 @@
 #ifndef __BASIC_TYPES_H__
 #define __BASIC_TYPES_H__
 
-#define SUCCESS0
-#define FAIL   (-1)
-
 #include 
 #define NDIS_OID uint
 
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 19/20] staging: rtl8188eu: new variable for hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt] in store_pwrindex_offset function

2015-10-27 Thread Ivan Safonov
hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt] frequent in this function, 
so it replaced by the power_level_offset new variable.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/hal/bb_cfg.c | 34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c 
b/drivers/staging/rtl8188eu/hal/bb_cfg.c
index a553468..7c52303 100644
--- a/drivers/staging/rtl8188eu/hal/bb_cfg.c
+++ b/drivers/staging/rtl8188eu/hal/bb_cfg.c
@@ -505,42 +505,44 @@ static void store_pwrindex_offset(struct adapter *adapter,
 {
struct hal_data_8188e *hal_data = GET_HAL_DATA(adapter);
 u8 pwrGrpCnt = hal_data->pwrGroupCnt;
+   u32 * const power_level_offset =
+   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt];
 
if (regaddr == rTxAGC_A_Rate18_06)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][0] = data;
+   power_level_offset[0] = data;
if (regaddr == rTxAGC_A_Rate54_24)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][1] = data;
+   power_level_offset[1] = data;
if (regaddr == rTxAGC_A_CCK1_Mcs32)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][6] = data;
+   power_level_offset[6] = data;
if (regaddr == rTxAGC_B_CCK11_A_CCK2_11 && bitmask == 0xff00)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][7] = data;
+   power_level_offset[7] = data;
if (regaddr == rTxAGC_A_Mcs03_Mcs00)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][2] = data;
+   power_level_offset[2] = data;
if (regaddr == rTxAGC_A_Mcs07_Mcs04)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][3] = data;
+   power_level_offset[3] = data;
if (regaddr == rTxAGC_A_Mcs11_Mcs08)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][4] = data;
+   power_level_offset[4] = data;
if (regaddr == rTxAGC_A_Mcs15_Mcs12) {
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][5] = data;
+   power_level_offset[5] = data;
if (hal_data->rf_type == RF_1T1R)
hal_data->pwrGroupCnt++;
}
if (regaddr == rTxAGC_B_Rate18_06)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][8] = data;
+   power_level_offset[8] = data;
if (regaddr == rTxAGC_B_Rate54_24)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][9] = data;
+   power_level_offset[9] = data;
if (regaddr == rTxAGC_B_CCK1_55_Mcs32)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][14] = data;
+   power_level_offset[14] = data;
if (regaddr == rTxAGC_B_CCK11_A_CCK2_11 && bitmask == 0x00ff)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][15] = data;
+   power_level_offset[15] = data;
if (regaddr == rTxAGC_B_Mcs03_Mcs00)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][10] = data;
+   power_level_offset[10] = data;
if (regaddr == rTxAGC_B_Mcs07_Mcs04)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][11] = data;
+   power_level_offset[11] = data;
if (regaddr == rTxAGC_B_Mcs11_Mcs08)
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][12] = data;
+   power_level_offset[12] = data;
if (regaddr == rTxAGC_B_Mcs15_Mcs12) {
-   hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][13] = data;
+   power_level_offset[13] = data;
if (hal_data->rf_type != RF_1T1R)
hal_data->pwrGroupCnt++;
}
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 12/20] staging: rtl8188eu: occurrence of the 5 GHz code marked

2015-10-27 Thread Ivan Safonov
Channel numbers greater than 14 are used here, which are possible only
for the 5 GHz frequency.

Signed-off-by: Ivan Safonov 
---
Changes in v2: no changes.

 drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c 
b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c
index 29353bf..e3e5d6f 100644
--- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c
@@ -444,6 +444,9 @@ static u8 Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup)
else if (chnl == 14)/*  Channel 14 */
*pGroup = 5;
} else {
+
+   /* probably, this branch is suitable only for 5 GHz */
+
bIn24G = false;
 
if (chnl <= 40)
-- 
2.4.10

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/16] staging: comedi: comedi_test: reformat multi-line comments

2015-10-27 Thread Ian Abbott
Use the preferred style for multi-line comments.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 94 ++--
 1 file changed, 47 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 80d613c..899faf7 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -1,49 +1,49 @@
 /*
-comedi/drivers/comedi_test.c
+ * comedi/drivers/comedi_test.c
+ *
+ * Generates fake waveform signals that can be read through
+ * the command interface.  It does _not_ read from any board;
+ * it just generates deterministic waveforms.
+ * Useful for various testing purposes.
+ *
+ * Copyright (C) 2002 Joachim Wuttke 
+ * Copyright (C) 2002 Frank Mori Hess 
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 2000 David A. Schleef 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
 
-Generates fake waveform signals that can be read through
-the command interface.  It does _not_ read from any board;
-it just generates deterministic waveforms.
-Useful for various testing purposes.
-
-Copyright (C) 2002 Joachim Wuttke 
-Copyright (C) 2002 Frank Mori Hess 
-
-COMEDI - Linux Control and Measurement Device Interface
-Copyright (C) 2000 David A. Schleef 
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-*/
 /*
-Driver: comedi_test
-Description: generates fake waveforms
-Author: Joachim Wuttke , Frank Mori Hess
-  , ds
-Devices:
-Status: works
-Updated: Sat, 16 Mar 2002 17:34:48 -0800
-
-This driver is mainly for testing purposes, but can also be used to
-generate sample waveforms on systems that don't have data acquisition
-hardware.
-
-Configuration options:
-  [0] - Amplitude in microvolts for fake waveforms (default 1 volt)
-  [1] - Period in microseconds for fake waveforms (default 0.1 sec)
-
-Generates a sawtooth wave on channel 0, square wave on channel 1, additional
-waveforms could be added to other channels (currently they return flatline
-zero volts).
-
-*/
+ * Driver: comedi_test
+ * Description: generates fake waveforms
+ * Author: Joachim Wuttke , Frank Mori Hess
+ *   , ds
+ * Devices:
+ * Status: works
+ * Updated: Sat, 16 Mar 2002 17:34:48 -0800
+ *
+ * This driver is mainly for testing purposes, but can also be used to
+ * generate sample waveforms on systems that don't have data acquisition
+ * hardware.
+ *
+ * Configuration options:
+ *   [0] - Amplitude in microvolts for fake waveforms (default 1 volt)
+ *   [1] - Period in microseconds for fake waveforms (default 0.1 sec)
+ *
+ * Generates a sawtooth wave on channel 0, square wave on channel 1, additional
+ * waveforms could be added to other channels (currently they return flatline
+ * zero volts).
+ */
 
 #include 
 #include "../comedidev.h"
@@ -160,10 +160,10 @@ static unsigned short fake_waveform(struct comedi_device 
*dev,
 }
 
 /*
-   This is the background routine used to generate arbitrary data.
-   It should run in the background; therefore it is scheduled by
-   a timer mechanism.
-*/
+ * This is the background routine used to generate arbitrary data.
+ * It should run in the background; therefore it is scheduled by
+ * a timer mechanism.
+ */
 static void waveform_ai_interrupt(unsigned long arg)
 {
struct comedi_device *dev = (struct comedi_device *)arg;
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/16] staging: comedi: comedi_test: saturate fake waveform values

2015-10-27 Thread Ian Abbott
While an asynchronous command is running on the analog input subdevice,
fake waveform generators are connected to each channel to provide the
input voltages that are converted to sample value.  Channel 0 is
connected to a sawtooth generator, channel 1 is connected to a
squarewave generator, and the remaining channels are connected to a
flatline generator.  The non-flatline generators share the same
amplitude (in microvolts) and period (in microseconds) which are
configured when the COMEDI device is attached.  All waveforms are
centered around 0 microvolts and the non-flatline waveforms go between
-amplitude and +amplitude.

It is possible for the waveforms to swing outside the input range of the
channels to which they are connected.  When that happens, the sample
values resulting from simulated A-to-D conversion will wrap around due
to integer overflow.  Prevent that by clamping the sample values that
would go out of range.  This is closer to how a real hardware device
would behave (assuming the input voltage is not high enough to damage
the hardware!).

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 29 ++--
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 899faf7..53c9a5c 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -104,9 +104,17 @@ static unsigned short fake_sawtooth(struct comedi_device 
*dev,
value = current_time;
value *= binary_amplitude * 2;
do_div(value, devpriv->usec_period);
-   value -= binary_amplitude;  /* get rid of sawtooth's dc offset */
+   value += offset;
+   /* get rid of sawtooth's dc offset and clamp value */
+   if (value < binary_amplitude) {
+   value = 0;  /* negative saturation */
+   } else {
+   value -= binary_amplitude;
+   if (value > s->maxdata)
+   value = s->maxdata; /* positive saturation */
+   }
 
-   return offset + value;
+   return value;
 }
 
 static unsigned short fake_squarewave(struct comedi_device *dev,
@@ -119,16 +127,25 @@ static unsigned short fake_squarewave(struct 
comedi_device *dev,
u64 value;
const struct comedi_krange *krange =
&s->range_table->range[range_index];
-   current_time %= devpriv->usec_period;
 
+   current_time %= devpriv->usec_period;
value = s->maxdata;
value *= devpriv->uvolt_amplitude;
do_div(value, krange->max - krange->min);
 
-   if (current_time < devpriv->usec_period / 2)
-   value *= -1;
+   /* get one of two values for square-wave and clamp */
+   if (current_time < devpriv->usec_period / 2) {
+   if (offset < value)
+   value = 0;  /* negative saturation */
+   else
+   value = offset - value;
+   } else {
+   value += offset;
+   if (value > s->maxdata)
+   value = s->maxdata; /* positive saturation */
+   }
 
-   return offset + value;
+   return value;
 }
 
 static unsigned short fake_flatline(struct comedi_device *dev,
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/16] staging: comedi: comedi_test: limit maximum convert_arg

2015-10-27 Thread Ian Abbott
When testing the parameters for setting up an asynchronous command on
the AI subdevice, limit the maximum conversion period
(`cmd->convert_arg`) so that the number of conversions in a scan
(`cmd->scan_end_arg`, same as `cmd->chanlist_len`) multiplied by the
conversion period fits within an `unsigned int`, as that is used to
limit the minimum scan period (`cmd->scan_begin_arg`).

Also ensure rounding of the conversion period and scan period to the
nearest microsecond both fit in an `unsigned int`.  Do all this in stage
4 ("fix up any arguments") of the command testing.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 42 ++--
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index d9810ca..f011fbd 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -234,7 +234,7 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
   struct comedi_cmd *cmd)
 {
int err = 0;
-   unsigned int arg;
+   unsigned int arg, limit;
 
/* Step 1 : check if triggers are trivially valid */
 
@@ -265,16 +265,8 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
if (cmd->convert_src == TRIG_NOW)
err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
 
-   if (cmd->scan_begin_src == TRIG_TIMER) {
-   err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
-   NSEC_PER_USEC);
-   if (cmd->convert_src == TRIG_TIMER) {
-   err |= comedi_check_trigger_arg_min(&cmd->
-   scan_begin_arg,
-   cmd->convert_arg *
-   cmd->chanlist_len);
-   }
-   }
+   err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+   NSEC_PER_USEC);
 
err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
@@ -290,21 +282,29 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
 
/* step 4: fix up any arguments */
 
-   if (cmd->scan_begin_src == TRIG_TIMER) {
-   arg = cmd->scan_begin_arg;
-   /* round to nearest microsec */
-   arg = NSEC_PER_USEC *
- ((arg + (NSEC_PER_USEC / 2)) / NSEC_PER_USEC);
-   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
-   }
if (cmd->convert_src == TRIG_TIMER) {
+   /* round convert_arg to nearest microsecond */
arg = cmd->convert_arg;
-   /* round to nearest microsec */
-   arg = NSEC_PER_USEC *
- ((arg + (NSEC_PER_USEC / 2)) / NSEC_PER_USEC);
+   arg = min(arg,
+ rounddown(UINT_MAX, (unsigned int)NSEC_PER_USEC));
+   arg = NSEC_PER_USEC * DIV_ROUND_CLOSEST(arg, NSEC_PER_USEC);
+   /* limit convert_arg to keep scan_begin_arg in range */
+   limit = UINT_MAX / cmd->scan_end_arg;
+   limit = rounddown(limit, (unsigned int)NSEC_PER_SEC);
+   arg = min(arg, limit);
err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
}
 
+   /* round scan_begin_arg to nearest microsecond */
+   arg = cmd->scan_begin_arg;
+   arg = min(arg, rounddown(UINT_MAX, (unsigned int)NSEC_PER_USEC));
+   arg = NSEC_PER_USEC * DIV_ROUND_CLOSEST(arg, NSEC_PER_USEC);
+   if (cmd->convert_src == TRIG_TIMER) {
+   /* but ensure scan_begin_arg is large enough */
+   arg = max(arg, cmd->convert_arg * cmd->scan_end_arg);
+   }
+   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+
if (err)
return 4;
 
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/16] staging: comedi: comedi_test: support scan_begin_src == TRIG_FOLLOW

2015-10-27 Thread Ian Abbott
It is quite common for COMEDI subdevices that support commands to
support setting `scan_begin_src` to `TRIG_FOLLOW`.  This means the next
scan begins once all conversions in the current scan are complete.
Support the following timing combinations for the AI subdevice:

  scan_begin_src == TRIG_TIMER && convert_src == TRIG_TIMER
  scan_begin_src == TRIG_TIMER && convert_src == TRIG_NOW
  scan_begin_src == TRIG_FOLLOW && convert_src == TRIG_TIMER

The actual scan period in microseconds is stored in the `scan_period`
member of the private data structure `struct waveform_private`.  An
`unsigned int` is still wide enough, because the conversion period is no
more than `UINT_MAX / 1000` microseconds and the number of conversions
is no more than 16 (`N_CHANS * 2`).

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 64 +++-
 1 file changed, 44 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index f011fbd..cc35bd6 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -239,7 +239,8 @@ static int waveform_ai_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_TIMER);
+   err |= comedi_check_trigger_src(&cmd->scan_begin_src,
+   TRIG_FOLLOW | TRIG_TIMER);
err |= comedi_check_trigger_src(&cmd->convert_src,
TRIG_NOW | TRIG_TIMER);
err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
@@ -255,6 +256,9 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
 
/* Step 2b : and mutually compatible */
 
+   if (cmd->scan_begin_src == TRIG_FOLLOW && cmd->convert_src == TRIG_NOW)
+   err |= -EINVAL; /* scan period would be 0 */
+
if (err)
return 2;
 
@@ -262,11 +266,21 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
 
err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-   if (cmd->convert_src == TRIG_NOW)
+   if (cmd->convert_src == TRIG_NOW) {
err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+   } else {/* cmd->convert_src == TRIG_TIMER */
+   if (cmd->scan_begin_src == TRIG_FOLLOW) {
+   err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+   NSEC_PER_USEC);
+   }
+   }
 
-   err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
-   NSEC_PER_USEC);
+   if (cmd->scan_begin_src == TRIG_FOLLOW) {
+   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+   } else {/* cmd->scan_begin_src == TRIG_TIMER */
+   err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+   NSEC_PER_USEC);
+   }
 
err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
@@ -274,7 +288,7 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
 
if (cmd->stop_src == TRIG_COUNT)
err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
-   else/* TRIG_NONE */
+   else/* cmd->stop_src == TRIG_NONE */
err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
if (err)
@@ -288,22 +302,27 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
arg = min(arg,
  rounddown(UINT_MAX, (unsigned int)NSEC_PER_USEC));
arg = NSEC_PER_USEC * DIV_ROUND_CLOSEST(arg, NSEC_PER_USEC);
-   /* limit convert_arg to keep scan_begin_arg in range */
-   limit = UINT_MAX / cmd->scan_end_arg;
-   limit = rounddown(limit, (unsigned int)NSEC_PER_SEC);
-   arg = min(arg, limit);
+   if (cmd->scan_begin_arg == TRIG_TIMER) {
+   /* limit convert_arg to keep scan_begin_arg in range */
+   limit = UINT_MAX / cmd->scan_end_arg;
+   limit = rounddown(limit, (unsigned int)NSEC_PER_SEC);
+   arg = min(arg, limit);
+   }
err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
}
 
-   /* round scan_begin_arg to nearest microsecond */
-   arg = cmd->scan_begin_arg;
-   arg = min(arg, rounddown(UINT_MAX, (unsigned int)NSEC_PER_USEC));
-   arg = NSEC_PER_USEC * DIV_ROUND_CLOSEST(arg, NSEC_PER_USEC);
-   if (cmd->convert_src == TRIG_TIMER) {
-   /* but ensure scan_begin_arg is large enough */
-   arg = max(arg, cmd->conv

[PATCH 00/16] staging: comedi: comedi_test: enhancements

2015-10-27 Thread Ian Abbott
The "comedi_test" module is a driver for a dummy COMEDI device.  It has
an analog input subdevice and an analog output subdevice.  The analog
input subdevice supports COMEDI asynchronous acquisition commands using
waveform generators to generate the input data for each channel.  A
kernel timer is used to driver the acquisition.

This series of patches cleans up the driver, enhances the existing
asynchronous command support on the analog input subdevice, and adds
asynchronous command support on the analog output subdevice.

01) staging: comedi: comedi_test: reformat multi-line comments
02) staging: comedi: comedi_test: saturate fake waveform values
03) staging: comedi: comedi_test: remove nano_per_micro
04) staging: comedi: comedi_test: limit maximum convert_arg
05) staging: comedi: comedi_test: support scan_begin_src == TRIG_FOLLOW
06) staging: comedi: comedi_test: move modulo operations for waveform
07) staging: comedi: comedi_test: use unsigned int for waveform timing
08) staging: comedi: comedi_test: simplify time since last AI scan
09) staging: comedi: comedi_test: rename members for AI commands
10) staging: comedi: comedi_test: rename waveform members
11) staging: comedi: comedi_test: make timer rate similar to scan rate
12) staging: comedi: comedi_test: use unsigned short for loopback values
13) staging: comedi: comedi_test: allow read-back of AO channels
14) staging: comedi: comedi_test: handle partial scans in timer routine
15) staging: comedi: comedi_test: rename waveform_ai_interrupt()
16) staging: comedi: comedi_test: implement commands on AO subdevice

 drivers/staging/comedi/drivers/comedi_test.c | 565 ---
 1 file changed, 416 insertions(+), 149 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/16] staging: comedi: comedi_test: rename waveform members

2015-10-27 Thread Ian Abbott
Rename the members `struct waveform_private` associated with fake
waveform generation.  The affected members are `uvolt_amplitude` -->
`wf_amplitude` (the amplitude of the waveform), `usec_period` -->
`wf_period` (the period of the waveform), and `usec_current` -->
`wf_current` (the current time within a waveform period).

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 40 ++--
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 8e618ea..1b3ad7f 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -63,9 +63,9 @@ enum waveform_state_bits {
 struct waveform_private {
struct timer_list ai_timer; /* timer for AI commands */
u64 ai_last_scan_time;  /* time of last AI scan in usec */
-   unsigned int uvolt_amplitude;   /* waveform amplitude in microvolts */
-   unsigned int usec_period;   /* waveform period in microseconds */
-   unsigned int usec_current;  /* current time (mod waveform period) */
+   unsigned int wf_amplitude;  /* waveform amplitude in microvolts */
+   unsigned int wf_period; /* waveform period in microseconds */
+   unsigned int wf_current;/* current time in waveform period */
unsigned long state_bits;
unsigned int ai_scan_period;/* AI scan period in usec */
unsigned int ai_convert_period; /* AI conversion period in usec */
@@ -93,12 +93,12 @@ static unsigned short fake_sawtooth(struct comedi_device 
*dev,
u64 binary_amplitude;
 
binary_amplitude = s->maxdata;
-   binary_amplitude *= devpriv->uvolt_amplitude;
+   binary_amplitude *= devpriv->wf_amplitude;
do_div(binary_amplitude, krange->max - krange->min);
 
value = current_time;
value *= binary_amplitude * 2;
-   do_div(value, devpriv->usec_period);
+   do_div(value, devpriv->wf_period);
value += offset;
/* get rid of sawtooth's dc offset and clamp value */
if (value < binary_amplitude) {
@@ -124,11 +124,11 @@ static unsigned short fake_squarewave(struct 
comedi_device *dev,
&s->range_table->range[range_index];
 
value = s->maxdata;
-   value *= devpriv->uvolt_amplitude;
+   value *= devpriv->wf_amplitude;
do_div(value, krange->max - krange->min);
 
/* get one of two values for square-wave and clamp */
-   if (current_time < devpriv->usec_period / 2) {
+   if (current_time < devpriv->wf_period / 2) {
if (offset < value)
value = 0;  /* negative saturation */
else
@@ -200,20 +200,20 @@ static void waveform_ai_interrupt(unsigned long arg)
for (j = 0; j < cmd->chanlist_len; j++) {
unsigned short sample;
 
-   if (devpriv->usec_current >= devpriv->usec_period)
-   devpriv->usec_current %= devpriv->usec_period;
+   if (devpriv->wf_current >= devpriv->wf_period)
+   devpriv->wf_current %= devpriv->wf_period;
sample = fake_waveform(dev, CR_CHAN(cmd->chanlist[j]),
   CR_RANGE(cmd->chanlist[j]),
-  devpriv->usec_current);
+  devpriv->wf_current);
comedi_buf_write_samples(s, &sample, 1);
-   devpriv->usec_current += devpriv->ai_convert_period;
+   devpriv->wf_current += devpriv->ai_convert_period;
scan_remain_period -= devpriv->ai_convert_period;
}
-   devpriv->usec_current += scan_remain_period;
+   devpriv->wf_current += scan_remain_period;
devpriv->ai_last_scan_time += devpriv->ai_scan_period;
}
-   if (devpriv->usec_current >= devpriv->usec_period)
-   devpriv->usec_current %= devpriv->usec_period;
+   if (devpriv->wf_current >= devpriv->wf_period)
+   devpriv->wf_current %= devpriv->wf_period;
 
if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)
async->events |= COMEDI_CB_EOA;
@@ -329,7 +329,7 @@ static int waveform_ai_cmd(struct comedi_device *dev,
 {
struct waveform_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
-   u64 usec_current;
+   u64 wf_current;
 
if (cmd->flags & CMDF_PRIORITY) {
dev_err(dev->class_dev,
@@ -351,8 +351,8 @@ static int waveform_ai_cmd(struct comedi_device *dev,
 
devpriv->ai_last_scan_time = ktime_to_us(ktime_get());
/* Determine time within waveform period. */
-   usec_current = devpriv->ai_la

[PATCH 13/16] staging: comedi: comedi_test: allow read-back of AO channels

2015-10-27 Thread Ian Abbott
COMEDI drivers often allow the last value written to a channel on an
analog output subdevice to be read back via the "insn_read" handler.
The "comedi_test" driver does not currently support that.  It is a bit
special because it loops back the last values written to the channel on
the analog output subdevice to be read back via corresponding channels
on the analog input subdevice.  The "insn_read" handler for the analog
input subdevice is `waveform_ai_insn_read()`.  Set that as the
"insn_read" handler for the analog output subdevice as well.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index a750f84..468847a 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -457,6 +457,7 @@ static int waveform_attach(struct comedi_device *dev,
s->maxdata = 0x;
s->range_table = &waveform_ai_ranges;
s->insn_write = waveform_ao_insn_write;
+   s->insn_read = waveform_ai_insn_read;   /* do same as AI insn_read */
 
/* Our default loopback value is just a 0V flatline */
for (i = 0; i < s->n_chan; i++)
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 16/16] staging: comedi: comedi_test: implement commands on AO subdevice

2015-10-27 Thread Ian Abbott
Implement COMEDI asynchronous commands on the fake analog output
subdevice.  This is useful for testing asynchronous commands in the
"write" direction when no real hardware is available.

A normal kernel timer is used to drive the command.  The new timer
expiry function `waveform_ao_timer()` handles whole "scans" at a time
according to the number of scan period that have elapsed since the last
scan.  Data for each channel in the scan is written to the internal
loopback array `devpriv->ao_loopbacks[]` and can be read back on the
analog input channels.  However, if several scan periods are outstanding
in the timer expiry function, only the latest available scan data is
written to the loopback array in order to save processing time.  The
expiry function also checks for underrun conditions, and checks for
normal termination of the asynchronous command when a "stop" scan count
is reached.

After the command is tested by `waveform_ao_cmdtest()` and set up by
`waveform_ao_cmd()`, it is not started until an internal trigger
function `waveform_ao_inttrig_start()` is called as a result of the user
performing an `INSN_INTTRIG` instruction on the subdevice.  The command
is stopped when the "cancel" handler `waveform_ao_cancel()` is called.
This may be due to the command terminating due to completion or an
error, or as a result of the user cancelling the command.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 212 ++-
 1 file changed, 209 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 14a0b62..4ab1866 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -57,7 +57,8 @@
 #define N_CHANS 8
 
 enum waveform_state_bits {
-   WAVEFORM_AI_RUNNING = 0
+   WAVEFORM_AI_RUNNING,
+   WAVEFORM_AO_RUNNING
 };
 
 /* Data unique to this driver */
@@ -70,6 +71,9 @@ struct waveform_private {
unsigned long state_bits;
unsigned int ai_scan_period;/* AI scan period in usec */
unsigned int ai_convert_period; /* AI conversion period in usec */
+   struct timer_list ao_timer; /* timer for AO commands */
+   u64 ao_last_scan_time;  /* time of previous AO scan in usec */
+   unsigned int ao_scan_period;/* AO scan period in usec */
unsigned short ao_loopbacks[N_CHANS];
 };
 
@@ -417,6 +421,201 @@ static int waveform_ai_insn_read(struct comedi_device 
*dev,
return insn->n;
 }
 
+/*
+ * This is the background routine to handle AO commands, scheduled by
+ * a timer mechanism.
+ */
+static void waveform_ao_timer(unsigned long arg)
+{
+   struct comedi_device *dev = (struct comedi_device *)arg;
+   struct waveform_private *devpriv = dev->private;
+   struct comedi_subdevice *s = dev->write_subdev;
+   struct comedi_async *async = s->async;
+   struct comedi_cmd *cmd = &async->cmd;
+   u64 now;
+   u64 scans_since;
+   unsigned int scans_avail = 0;
+
+   /* check command is still active */
+   if (!test_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits))
+   return;
+
+   /* determine number of scan periods since last time */
+   now = ktime_to_us(ktime_get());
+   scans_since = now - devpriv->ao_last_scan_time;
+   do_div(scans_since, devpriv->ao_scan_period);
+   if (scans_since) {
+   unsigned int i;
+
+   /* determine scans in buffer, limit to scans to do this time */
+   scans_avail = comedi_nscans_left(s, 0);
+   if (scans_avail > scans_since)
+   scans_avail = scans_since;
+   if (scans_avail) {
+   /* skip all but the last scan to save processing time */
+   if (scans_avail > 1) {
+   unsigned int skip_bytes, nbytes;
+
+   skip_bytes =
+   comedi_samples_to_bytes(s, cmd->scan_end_arg *
+  (scans_avail - 1));
+   nbytes = comedi_buf_read_alloc(s, skip_bytes);
+   comedi_buf_read_free(s, nbytes);
+   comedi_inc_scan_progress(s, nbytes);
+   if (nbytes < skip_bytes) {
+   /* unexpected underrun! (cancelled?) */
+   async->events |= COMEDI_CB_OVERFLOW;
+   goto underrun;
+   }
+   }
+   /* output the last scan */
+   for (i = 0; i < cmd->scan_end_arg; i++) {
+   unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+
+   if (comedi_buf_read_samples(s,
+  

[PATCH 12/16] staging: comedi: comedi_test: use unsigned short for loopback values

2015-10-27 Thread Ian Abbott
The last sample values written to the AO subdevice channels by its
"insn_write" handler `waveform_ao_insn_write()` are stored in the member
array `ao_loopbacks[]` in the device private data `struct
waveform_private`.  They can be read back via the "insn_read" handler of
the AI subdevice `waveform_ai_insn_read()`.  As the stored sample values
are only 16 bits wide, change the type of the `ao_loopbacks[]` member to
`unsigned short` to save some space.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 9655dc3..a750f84 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -70,7 +70,7 @@ struct waveform_private {
unsigned long state_bits;
unsigned int ai_scan_period;/* AI scan period in usec */
unsigned int ai_convert_period; /* AI conversion period in usec */
-   unsigned int ao_loopbacks[N_CHANS];
+   unsigned short ao_loopbacks[N_CHANS];
 };
 
 /* fake analog input ranges */
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/16] staging: comedi: comedi_test: use unsigned int for waveform timing

2015-10-27 Thread Ian Abbott
Use `unsigned int` instead of `unsigned long` to hold the period of the
fake waveform generator and the current time within each waveform.  The
waveform period will be no more than `INT_MAX` and the current time
within the waveform (prior to the modulo operation to bring it actually
within the waveform period) will be no more than `INT_MAX + UINT_MAX /
1000`.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 0215228..158e090 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -64,8 +64,8 @@ struct waveform_private {
struct timer_list timer;
ktime_t last;   /* time last timer interrupt occurred */
unsigned int uvolt_amplitude;   /* waveform amplitude in microvolts */
-   unsigned long usec_period;  /* waveform period in microseconds */
-   unsigned long usec_current; /* current time (mod waveform period) */
+   unsigned int usec_period;   /* waveform period in microseconds */
+   unsigned int usec_current;  /* current time (mod waveform period) */
unsigned long usec_remainder;   /* usec since last scan */
unsigned long state_bits;
unsigned int scan_period;   /* scan period in usec */
@@ -83,7 +83,7 @@ static const struct comedi_lrange waveform_ai_ranges = {
 
 static unsigned short fake_sawtooth(struct comedi_device *dev,
unsigned int range_index,
-   unsigned long current_time)
+   unsigned int current_time)
 {
struct waveform_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
@@ -115,7 +115,7 @@ static unsigned short fake_sawtooth(struct comedi_device 
*dev,
 
 static unsigned short fake_squarewave(struct comedi_device *dev,
  unsigned int range_index,
- unsigned long current_time)
+ unsigned int current_time)
 {
struct waveform_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
@@ -145,7 +145,7 @@ static unsigned short fake_squarewave(struct comedi_device 
*dev,
 
 static unsigned short fake_flatline(struct comedi_device *dev,
unsigned int range_index,
-   unsigned long current_time)
+   unsigned int current_time)
 {
return dev->read_subdev->maxdata / 2;
 }
@@ -153,7 +153,7 @@ static unsigned short fake_flatline(struct comedi_device 
*dev,
 /* generates a different waveform depending on what channel is read */
 static unsigned short fake_waveform(struct comedi_device *dev,
unsigned int channel, unsigned int range,
-   unsigned long current_time)
+   unsigned int current_time)
 {
enum {
SAWTOOTH_CHAN,
@@ -468,7 +468,7 @@ static int waveform_attach(struct comedi_device *dev,
(unsigned long)dev);
 
dev_info(dev->class_dev,
-"%s: %i microvolt, %li microsecond waveform attached\n",
+"%s: %u microvolt, %u microsecond waveform attached\n",
 dev->board_name,
 devpriv->uvolt_amplitude, devpriv->usec_period);
 
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/16] staging: comedi: comedi_test: remove nano_per_micro

2015-10-27 Thread Ian Abbott
The `static const int nano_per_micro` variable is set to 1000, the
number of nanoseconds in a microsecond.  Remove it and use the
`NSEC_PER_USEC` macro from  instead.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 53c9a5c..d9810ca 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -73,9 +73,6 @@ struct waveform_private {
unsigned int ao_loopbacks[N_CHANS];
 };
 
-/* 1000 nanosec in a microsec */
-static const int nano_per_micro = 1000;
-
 /* fake analog input ranges */
 static const struct comedi_lrange waveform_ai_ranges = {
2, {
@@ -270,7 +267,7 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
 
if (cmd->scan_begin_src == TRIG_TIMER) {
err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
-   nano_per_micro);
+   NSEC_PER_USEC);
if (cmd->convert_src == TRIG_TIMER) {
err |= comedi_check_trigger_arg_min(&cmd->
scan_begin_arg,
@@ -296,15 +293,15 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
if (cmd->scan_begin_src == TRIG_TIMER) {
arg = cmd->scan_begin_arg;
/* round to nearest microsec */
-   arg = nano_per_micro *
- ((arg + (nano_per_micro / 2)) / nano_per_micro);
+   arg = NSEC_PER_USEC *
+ ((arg + (NSEC_PER_USEC / 2)) / NSEC_PER_USEC);
err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
}
if (cmd->convert_src == TRIG_TIMER) {
arg = cmd->convert_arg;
/* round to nearest microsec */
-   arg = nano_per_micro *
- ((arg + (nano_per_micro / 2)) / nano_per_micro);
+   arg = NSEC_PER_USEC *
+ ((arg + (NSEC_PER_USEC / 2)) / NSEC_PER_USEC);
err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
}
 
@@ -326,12 +323,12 @@ static int waveform_ai_cmd(struct comedi_device *dev,
return -1;
}
 
-   devpriv->scan_period = cmd->scan_begin_arg / nano_per_micro;
+   devpriv->scan_period = cmd->scan_begin_arg / NSEC_PER_USEC;
 
if (cmd->convert_src == TRIG_NOW)
devpriv->convert_period = 0;
else/* TRIG_TIMER */
-   devpriv->convert_period = cmd->convert_arg / nano_per_micro;
+   devpriv->convert_period = cmd->convert_arg / NSEC_PER_USEC;
 
devpriv->last = ktime_get();
devpriv->usec_current =
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/16] staging: comedi: comedi_test: move modulo operations for waveform

2015-10-27 Thread Ian Abbott
The fake waveform generator functions, `fake_sawtooth()` and
`fake_squarewave()`, called from `fake_waveform()`, have a
`current_time` parameter which is the time since the start of a waveform
period.  The parameter value may be greater than the waveform period so
they do a modulo operation to bring it into range.  Do the modulo
operations outside the functions in `waveform_ai_interrupt()` so that
the waveform generator functions always get a `current_time` parameter
less than the waveform period and do not have to do the modulo operation
themselves.  Also, only do the modulo operations when the time since the
start of a waveform exceeds the waveform period.  Usually, several
samples are produced in each waveform period and modulo operations are
typically more expensive than a simple comparison.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index cc35bd6..0215228 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -97,7 +97,6 @@ static unsigned short fake_sawtooth(struct comedi_device *dev,
binary_amplitude *= devpriv->uvolt_amplitude;
do_div(binary_amplitude, krange->max - krange->min);
 
-   current_time %= devpriv->usec_period;
value = current_time;
value *= binary_amplitude * 2;
do_div(value, devpriv->usec_period);
@@ -125,7 +124,6 @@ static unsigned short fake_squarewave(struct comedi_device 
*dev,
const struct comedi_krange *krange =
&s->range_table->range[range_index];
 
-   current_time %= devpriv->usec_period;
value = s->maxdata;
value *= devpriv->uvolt_amplitude;
do_div(value, krange->max - krange->min);
@@ -206,20 +204,24 @@ static void waveform_ai_interrupt(unsigned long arg)
 
num_scans = comedi_nscans_left(s, num_scans);
for (i = 0; i < num_scans; i++) {
+   unsigned long scan_remain_period = devpriv->scan_period;
+
for (j = 0; j < cmd->chanlist_len; j++) {
unsigned short sample;
 
+   if (devpriv->usec_current >= devpriv->usec_period)
+   devpriv->usec_current %= devpriv->usec_period;
sample = fake_waveform(dev, CR_CHAN(cmd->chanlist[j]),
   CR_RANGE(cmd->chanlist[j]),
-  devpriv->usec_current +
-  i * devpriv->scan_period +
-  j * devpriv->convert_period);
+  devpriv->usec_current);
comedi_buf_write_samples(s, &sample, 1);
+   devpriv->usec_current += devpriv->convert_period;
+   scan_remain_period -= devpriv->convert_period;
}
+   devpriv->usec_current += scan_remain_period;
}
-
-   devpriv->usec_current += elapsed_time;
-   devpriv->usec_current %= devpriv->usec_period;
+   if (devpriv->usec_current >= devpriv->usec_period)
+   devpriv->usec_current %= devpriv->usec_period;
 
if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)
async->events |= COMEDI_CB_EOA;
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/16] staging: comedi: comedi_test: simplify time since last AI scan

2015-10-27 Thread Ian Abbott
The private data structure `struct waveform_private` currently uses
member `last` to remember the time of the last timer interrupt, and the
member `usec_remainder` to keep track of how far into a simulated scan
the interrupt occurred.  Replace these with a single new member
`ai_last_scan_time` that records the time of the last scan.  This
simplifies the calculation of the number of scans to simulate in the
timer routine, `waveform_ai_interrupt()`.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 27 ++-
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 158e090..78fde3a 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -62,11 +62,10 @@ enum waveform_state_bits {
 /* Data unique to this driver */
 struct waveform_private {
struct timer_list timer;
-   ktime_t last;   /* time last timer interrupt occurred */
+   u64 ai_last_scan_time;  /* time of last AI scan in usec */
unsigned int uvolt_amplitude;   /* waveform amplitude in microvolts */
unsigned int usec_period;   /* waveform period in microseconds */
unsigned int usec_current;  /* current time (mod waveform period) */
-   unsigned long usec_remainder;   /* usec since last scan */
unsigned long state_bits;
unsigned int scan_period;   /* scan period in usec */
unsigned int convert_period;/* conversion period in usec */
@@ -184,27 +183,19 @@ static void waveform_ai_interrupt(unsigned long arg)
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int i, j;
-   /* all times in microsec */
unsigned long elapsed_time;
unsigned int num_scans;
-   ktime_t now;
 
/* check command is still active */
if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits))
return;
 
-   now = ktime_get();
-
-   elapsed_time = ktime_to_us(ktime_sub(now, devpriv->last));
-   devpriv->last = now;
-   num_scans =
-   (devpriv->usec_remainder + elapsed_time) / devpriv->scan_period;
-   devpriv->usec_remainder =
-   (devpriv->usec_remainder + elapsed_time) % devpriv->scan_period;
+   elapsed_time = ktime_to_us(ktime_get()) - devpriv->ai_last_scan_time;
+   num_scans = elapsed_time / devpriv->scan_period;
 
num_scans = comedi_nscans_left(s, num_scans);
for (i = 0; i < num_scans; i++) {
-   unsigned long scan_remain_period = devpriv->scan_period;
+   unsigned int scan_remain_period = devpriv->scan_period;
 
for (j = 0; j < cmd->chanlist_len; j++) {
unsigned short sample;
@@ -219,6 +210,7 @@ static void waveform_ai_interrupt(unsigned long arg)
scan_remain_period -= devpriv->convert_period;
}
devpriv->usec_current += scan_remain_period;
+   devpriv->ai_last_scan_time += devpriv->scan_period;
}
if (devpriv->usec_current >= devpriv->usec_period)
devpriv->usec_current %= devpriv->usec_period;
@@ -337,6 +329,7 @@ static int waveform_ai_cmd(struct comedi_device *dev,
 {
struct waveform_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
+   u64 usec_current;
 
if (cmd->flags & CMDF_PRIORITY) {
dev_err(dev->class_dev,
@@ -356,10 +349,10 @@ static int waveform_ai_cmd(struct comedi_device *dev,
devpriv->scan_period = cmd->scan_begin_arg / NSEC_PER_USEC;
}
 
-   devpriv->last = ktime_get();
-   devpriv->usec_current =
-   ((u32)ktime_to_us(devpriv->last)) % devpriv->usec_period;
-   devpriv->usec_remainder = 0;
+   devpriv->ai_last_scan_time = ktime_to_us(ktime_get());
+   /* Determine time within waveform period. */
+   usec_current = devpriv->ai_last_scan_time;
+   devpriv->usec_current = do_div(usec_current, devpriv->usec_period);
 
devpriv->timer.expires = jiffies + 1;
/* mark command as active */
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/16] staging: comedi: comedi_test: rename members for AI commands

2015-10-27 Thread Ian Abbott
Rename the members of `struct waveform_private` that are used to handle
AI commands, apart from those members used to control fake waveform
generation.  The renames are `timer` --> `ai_timer`, `scan_period` -->
`ai_scan_period`, and `convert_period` --> `ai_convert_period`.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 38 ++--
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 78fde3a..8e618ea 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -61,14 +61,14 @@ enum waveform_state_bits {
 
 /* Data unique to this driver */
 struct waveform_private {
-   struct timer_list timer;
+   struct timer_list ai_timer; /* timer for AI commands */
u64 ai_last_scan_time;  /* time of last AI scan in usec */
unsigned int uvolt_amplitude;   /* waveform amplitude in microvolts */
unsigned int usec_period;   /* waveform period in microseconds */
unsigned int usec_current;  /* current time (mod waveform period) */
unsigned long state_bits;
-   unsigned int scan_period;   /* scan period in usec */
-   unsigned int convert_period;/* conversion period in usec */
+   unsigned int ai_scan_period;/* AI scan period in usec */
+   unsigned int ai_convert_period; /* AI conversion period in usec */
unsigned int ao_loopbacks[N_CHANS];
 };
 
@@ -191,11 +191,11 @@ static void waveform_ai_interrupt(unsigned long arg)
return;
 
elapsed_time = ktime_to_us(ktime_get()) - devpriv->ai_last_scan_time;
-   num_scans = elapsed_time / devpriv->scan_period;
+   num_scans = elapsed_time / devpriv->ai_scan_period;
 
num_scans = comedi_nscans_left(s, num_scans);
for (i = 0; i < num_scans; i++) {
-   unsigned int scan_remain_period = devpriv->scan_period;
+   unsigned int scan_remain_period = devpriv->ai_scan_period;
 
for (j = 0; j < cmd->chanlist_len; j++) {
unsigned short sample;
@@ -206,11 +206,11 @@ static void waveform_ai_interrupt(unsigned long arg)
   CR_RANGE(cmd->chanlist[j]),
   devpriv->usec_current);
comedi_buf_write_samples(s, &sample, 1);
-   devpriv->usec_current += devpriv->convert_period;
-   scan_remain_period -= devpriv->convert_period;
+   devpriv->usec_current += devpriv->ai_convert_period;
+   scan_remain_period -= devpriv->ai_convert_period;
}
devpriv->usec_current += scan_remain_period;
-   devpriv->ai_last_scan_time += devpriv->scan_period;
+   devpriv->ai_last_scan_time += devpriv->ai_scan_period;
}
if (devpriv->usec_current >= devpriv->usec_period)
devpriv->usec_current %= devpriv->usec_period;
@@ -218,7 +218,7 @@ static void waveform_ai_interrupt(unsigned long arg)
if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)
async->events |= COMEDI_CB_EOA;
else
-   mod_timer(&devpriv->timer, jiffies + 1);
+   mod_timer(&devpriv->ai_timer, jiffies + 1);
 
comedi_handle_events(dev, s);
 }
@@ -338,15 +338,15 @@ static int waveform_ai_cmd(struct comedi_device *dev,
}
 
if (cmd->convert_src == TRIG_NOW)
-   devpriv->convert_period = 0;
+   devpriv->ai_convert_period = 0;
else/* cmd->convert_src == TRIG_TIMER */
-   devpriv->convert_period = cmd->convert_arg / NSEC_PER_USEC;
+   devpriv->ai_convert_period = cmd->convert_arg / NSEC_PER_USEC;
 
if (cmd->scan_begin_src == TRIG_FOLLOW) {
-   devpriv->scan_period = devpriv->convert_period *
-  cmd->scan_end_arg;
+   devpriv->ai_scan_period = devpriv->ai_convert_period *
+ cmd->scan_end_arg;
} else {/* cmd->scan_begin_src == TRIG_TIMER */
-   devpriv->scan_period = cmd->scan_begin_arg / NSEC_PER_USEC;
+   devpriv->ai_scan_period = cmd->scan_begin_arg / NSEC_PER_USEC;
}
 
devpriv->ai_last_scan_time = ktime_to_us(ktime_get());
@@ -354,12 +354,12 @@ static int waveform_ai_cmd(struct comedi_device *dev,
usec_current = devpriv->ai_last_scan_time;
devpriv->usec_current = do_div(usec_current, devpriv->usec_period);
 
-   devpriv->timer.expires = jiffies + 1;
+   devpriv->ai_timer.expires = jiffies + 1;
/* mark command as active */
smp_mb__before_atomic();
set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);
s

[PATCH 11/16] staging: comedi: comedi_test: make timer rate similar to scan rate

2015-10-27 Thread Ian Abbott
The asynchronous command handling for the analog input subdevice uses a
kernel timer which expires approximately `HZ` times a second.  However,
it only needs to do anything after each scan period.  Set the timer to
expire just after the next scan period.

Although the timer expiry function `waveform_ai_interrupt()` uses
precise time values to generate the fake waveforms used to generate the
data, those time values are constructed in a precise sequence, and do
not depend on the time the timer expiry function is actually called.  So
the timer expiry rate does not have to be very precise.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 1b3ad7f..9655dc3 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -52,6 +52,7 @@
 
 #include 
 #include 
+#include 
 
 #define N_CHANS 8
 
@@ -215,10 +216,12 @@ static void waveform_ai_interrupt(unsigned long arg)
if (devpriv->wf_current >= devpriv->wf_period)
devpriv->wf_current %= devpriv->wf_period;
 
-   if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)
+   if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) {
async->events |= COMEDI_CB_EOA;
-   else
-   mod_timer(&devpriv->ai_timer, jiffies + 1);
+   } else {
+   mod_timer(&devpriv->ai_timer,
+ jiffies + usecs_to_jiffies(devpriv->ai_scan_period));
+   }
 
comedi_handle_events(dev, s);
 }
@@ -354,7 +357,9 @@ static int waveform_ai_cmd(struct comedi_device *dev,
wf_current = devpriv->ai_last_scan_time;
devpriv->wf_current = do_div(wf_current, devpriv->wf_period);
 
-   devpriv->ai_timer.expires = jiffies + 1;
+   devpriv->ai_timer.expires =
+   jiffies + usecs_to_jiffies(devpriv->ai_scan_period);
+
/* mark command as active */
smp_mb__before_atomic();
set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/16] staging: comedi: comedi_test: rename waveform_ai_interrupt()

2015-10-27 Thread Ian Abbott
`waveform_ai_interrupt()` is a timer expiry function used to generate
fake waveform data for an analog input subdevice.  Rename it to
`waveform_ai_timer()`.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 318340c..14a0b62 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -176,7 +176,7 @@ static unsigned short fake_waveform(struct comedi_device 
*dev,
  * It should run in the background; therefore it is scheduled by
  * a timer mechanism.
  */
-static void waveform_ai_interrupt(unsigned long arg)
+static void waveform_ai_timer(unsigned long arg)
 {
struct comedi_device *dev = (struct comedi_device *)arg;
struct waveform_private *devpriv = dev->private;
@@ -486,8 +486,7 @@ static int waveform_attach(struct comedi_device *dev,
for (i = 0; i < s->n_chan; i++)
devpriv->ao_loopbacks[i] = s->maxdata / 2;
 
-   setup_timer(&devpriv->ai_timer, waveform_ai_interrupt,
-   (unsigned long)dev);
+   setup_timer(&devpriv->ai_timer, waveform_ai_timer, (unsigned long)dev);
 
dev_info(dev->class_dev,
 "%s: %u microvolt, %u microsecond waveform attached\n",
-- 
2.6.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/16] staging: comedi: comedi_test: handle partial scans in timer routine

2015-10-27 Thread Ian Abbott
For asynchronous command handling on the analog input subdevice, a
kernel timer routine is used to generate the fake waveform data.  A
"scan" consists of a number of conversions separated in time by a
conversion period.  Successive scans are separated in time by a scan
period, which is at least the conversion period multiplied by the number
of conversions per scan.  Currently, the timer routine does not generate
any data until the end of a scan period, generating whole scans of data
at a time.  Change it to generate data at the end of each conversion
period, with an extra delay after the final conversion in each scan if
necessary.  Use new member `ai_convert_time` in the private data
structure `struct waveform_private` to keep track of when the next
conversion is due.  This replaces the old member `ai_last_scan_time`
which kept track of the time of the previous scan.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/comedi_test.c | 85 ++--
 1 file changed, 54 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 468847a..318340c 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -63,7 +63,7 @@ enum waveform_state_bits {
 /* Data unique to this driver */
 struct waveform_private {
struct timer_list ai_timer; /* timer for AI commands */
-   u64 ai_last_scan_time;  /* time of last AI scan in usec */
+   u64 ai_convert_time;/* time of next AI conversion in usec */
unsigned int wf_amplitude;  /* waveform amplitude in microvolts */
unsigned int wf_period; /* waveform period in microseconds */
unsigned int wf_current;/* current time in waveform period */
@@ -183,46 +183,51 @@ static void waveform_ai_interrupt(unsigned long arg)
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
-   unsigned int i, j;
-   unsigned long elapsed_time;
-   unsigned int num_scans;
+   u64 now;
+   unsigned int nsamples;
+   unsigned int time_increment;
 
/* check command is still active */
if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits))
return;
 
-   elapsed_time = ktime_to_us(ktime_get()) - devpriv->ai_last_scan_time;
-   num_scans = elapsed_time / devpriv->ai_scan_period;
-
-   num_scans = comedi_nscans_left(s, num_scans);
-   for (i = 0; i < num_scans; i++) {
-   unsigned int scan_remain_period = devpriv->ai_scan_period;
-
-   for (j = 0; j < cmd->chanlist_len; j++) {
-   unsigned short sample;
-
-   if (devpriv->wf_current >= devpriv->wf_period)
-   devpriv->wf_current %= devpriv->wf_period;
-   sample = fake_waveform(dev, CR_CHAN(cmd->chanlist[j]),
-  CR_RANGE(cmd->chanlist[j]),
-  devpriv->wf_current);
-   comedi_buf_write_samples(s, &sample, 1);
-   devpriv->wf_current += devpriv->ai_convert_period;
-   scan_remain_period -= devpriv->ai_convert_period;
+   now = ktime_to_us(ktime_get());
+   nsamples = comedi_nsamples_left(s, UINT_MAX);
+
+   while (nsamples && devpriv->ai_convert_time < now) {
+   unsigned int chanspec = cmd->chanlist[async->cur_chan];
+   unsigned short sample;
+
+   sample = fake_waveform(dev, CR_CHAN(chanspec),
+  CR_RANGE(chanspec), devpriv->wf_current);
+   if (comedi_buf_write_samples(s, &sample, 1) == 0)
+   goto overrun;
+   time_increment = devpriv->ai_convert_period;
+   if (async->scan_progress == 0) {
+   /* done last conversion in scan, so add dead time */
+   time_increment += devpriv->ai_scan_period -
+ devpriv->ai_convert_period *
+ cmd->scan_end_arg;
}
-   devpriv->wf_current += scan_remain_period;
-   devpriv->ai_last_scan_time += devpriv->ai_scan_period;
+   devpriv->wf_current += time_increment;
+   if (devpriv->wf_current >= devpriv->wf_period)
+   devpriv->wf_current %= devpriv->wf_period;
+   devpriv->ai_convert_time += time_increment;
+   nsamples--;
}
-   if (devpriv->wf_current >= devpriv->wf_period)
-   devpriv->wf_current %= devpriv->wf_period;
 
if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) {
async->events |= COMEDI_CB_EOA;
} else {
+ 

RE: [PATCH v3 4/7] PCI: Record an fwnode associated with root PCI buses, optionally

2015-10-27 Thread Jake Oshins
> -Original Message-
> From: Jiang Liu [mailto:jiang@linux.intel.com]
> Sent: Tuesday, October 27, 2015 12:10 AM
> To: Jake Oshins ; gre...@linuxfoundation.org; KY
> Srinivasan ; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> vkuzn...@redhat.com; t...@linutronix.de; Haiyang Zhang
> ; marc.zyng...@arm.com;
> bhelg...@google.com; linux-...@vger.kernel.org
> Subject: Re: [PATCH v3 4/7] PCI: Record an fwnode associated with root PCI
> buses, optionally
> 
> On 2015/10/27 7:15, ja...@microsoft.com wrote:
> > From: Jake Oshins 
> >
> > This patch allows a PCI front-end implementation to supply an
> fwnode_handle
> > associated with a root PCI bus, optionally.  If supplied, the PCI driver
> > records this.
> >
> > This patch supports the next patch in the series, which looks up an IRQ
> domain
> > through this handle.
> Hi JaKeo,
>   Instead of changing the pci_create_root_bus() interface,
> how about packing fwnode into sysdata, then we may
> either 1) introduce a helper to retrieve fwnode from sysdata
> or 2) set host_bridge->fwnode = sysdata in function
> pcibios_root_bridge_prepare.
> 
> Thanks,
> Gerry
> 

Thanks for the review.  I'll work up a version that uses this suggestion and 
resend.  (I'll respond to your feedback on the other patches, too.)

-- Jake Oshins

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] Staging: wilc1000: Prefer eth_broadcast_addr over memset()

2015-10-27 Thread Punit Vara
This patch is to the host_interface.c that fixes up following
warning by checkpatch:

-prefer eth_broadcast_addr() over memset()

Signed-off-by: Punit Vara 
---
 drivers/staging/wilc1000/host_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 5f81eab..53e21cd 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -4642,7 +4642,7 @@ s32 host_int_del_station(struct host_if_drv *hif_drv, 
const u8 *pu8MacAddr)
msg.drv = hif_drv;
 
if (!pu8MacAddr)
-   memset(pstrDelStationMsg->mac_addr, 255, ETH_ALEN);
+   eth_broadcast_addr(pstrDelStationMsg->mac_addr);
else
memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
 
-- 
2.5.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 01/20] staging: rtl8188eu: sizeof/sizeof replaced by ARRAY_SIZE kernel macro

2015-10-27 Thread Albino B Neto
2015-10-27 13:13 GMT-02:00 Ivan Safonov :
> ARRAY_SIZE shorter and more difficult to create bugs.
>
> Signed-off-by: Ivan Safonov 

You tested ?

   Albino
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 01/20] staging: rtl8188eu: sizeof/sizeof replaced by ARRAY_SIZE kernel macro

2015-10-27 Thread Ivan Safonov

On 10/28/2015 12:05 AM, Albino B Neto wrote:

2015-10-27 13:13 GMT-02:00 Ivan Safonov :

ARRAY_SIZE shorter and more difficult to create bugs.

Signed-off-by: Ivan Safonov 

You tested ?

Albino


Not tested. Is this transformation can to break the code?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   >