[PATCH] staging/xgifb: fix dumpVGAReg compile error if DEBUG is set

2015-07-24 Thread Peter Huewe
If DEBUG is set dumpVGAReg is called and tries to access
XGISR which is defined as (xgifb_info->dev_info.P3c4)
which is not known within this function.

-> add as parameter to dumpVGAReg so xgifb_info becomes known

Signed-off-by: Peter Huewe 
---
 drivers/staging/xgifb/XGI_main_26.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 943d463cf193..f3738400acd0 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -29,7 +29,7 @@ static unsigned int refresh_rate;
 /*  Macro definitions  */
 
 #ifdef DEBUG
-static void dumpVGAReg(void)
+static void dumpVGAReg(struct xgifb_video_info *xgifb_info)
 {
u8 i, reg;
 
@@ -48,7 +48,7 @@ static void dumpVGAReg(void)
}
 }
 #else
-static inline void dumpVGAReg(void)
+static inline void dumpVGAReg(struct xgifb_video_info *xgifb_info)
 {
 }
 #endif
@@ -1073,7 +1073,7 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo 
*var, int isactive,
}
XGIfb_bpp_to_var(xgifb_info, var); /*update ARGB info*/
 
-   dumpVGAReg();
+   dumpVGAReg(xgifb_info);
return 0;
 }
 
@@ -2019,7 +2019,7 @@ static int xgifb_probe(struct pci_dev *pdev,
goto error_mtrr;
}
 
-   dumpVGAReg();
+   dumpVGAReg(xgifb_info);
 
return 0;
 
-- 
2.3.6

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


[PATCH] staging: unisys: avoid format string parsing

2015-07-24 Thread Kees Cook
This makes sure the kthread name can't be parsed as a format string.

Signed-off-by: Kees Cook 
---
 drivers/staging/unisys/visornic/visornic_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index 710074437737..9af4ed8d6f10 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -296,7 +296,7 @@ static int visor_thread_start(struct visor_thread_info 
*thrinfo,
 {
/* used to stop the thread */
init_completion(&thrinfo->has_stopped);
-   thrinfo->task = kthread_run(threadfn, thrcontext, name);
+   thrinfo->task = kthread_run(threadfn, thrcontext, "%s", name);
if (IS_ERR(thrinfo->task)) {
thrinfo->id = 0;
return -EINVAL;
-- 
1.9.1


-- 
Kees Cook
Chrome OS Security
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/7] staging: unisys: visornic: fix serialization mechanism around usage atomic

2015-07-24 Thread Neil Horman
On Fri, Jul 24, 2015 at 01:35:51PM -0700, Greg KH wrote:
> On Fri, Jul 24, 2015 at 12:00:19PM -0400, Benjamin Romer wrote:
> > From: Neil Horman 
> > 
> > Missed this in my initial review.  The usage counter that guards against
> > kthread task is horribly racy.  The atomic is self consistent, but theres
> > nothing that prevents the service_resp_queue function from re-incrementing
> > it immediately after the check in disable_with_timeout is complete.  Its
> > just a improper usage of atomics as a serialization mechanism.
> > 
> > Instead use kthread_park to pause the thread in its activity so that
> > buffers can be properly freed without racing against usage in
> > service_resp_queue
> > 
> > Signed-off-by: Neil Horman 
> > Signed-off-by: Benjamin Romer 
> > ---
> >  drivers/staging/unisys/visornic/visornic_main.c | 23 
> > ++-
> >  kernel/kthread.c|  4 
> 
> Sorry, staging drivers can not modify other parts of the kernel.  Adding
> exports for these kthread functions needs to happen as a "real" patch
> that the kthread maintainer accepts, I can't take this.
> 
> greg k-h

Thats fine, we can split out the kthread_park exports and propose them on lkml
separately. 

Thanks
Neil

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


Re: [PATCH 0/9] Staging: most: Patchset to add Microchip's MOST driver to kernel 4.1.2

2015-07-24 Thread Greg KH
On Fri, Jul 24, 2015 at 04:11:47PM +0200, Christian Gromm wrote:
> This patchset adds the components of the Media Oriented Systems Transport
> (MOST) driver to the kernel's driver staging area and adapts the build
> system accordingly. By including this driver Linux applications will be
> able to access a MOST network: The Automotive Information Backbone and the
> de-facto standard for high-bandwidth automotive multimedia networking.
> 
> MOST defines the protocol, hardware and software layers necessary to allow
> for the efficient and low-cost transport of control, real-time and packet
> data using a single medium (physical layer). Media currently in use are
> fiber optics, unshielded twisted pair cables (UTP) and coax cables. MOST
> also supports various speed grades up to 150 Mbps.
> For more information on MOST, visit the MOST Cooperation website:
> www.mostcooperation.com.
> 
> Cars continue to evolve into sophisticated consumer electronics platforms,
> increasing the demand for reliable and simple solutions to support audio,
> video and data communications. MOST can be used to connect multiple
> consumer devices via optical or electrical physical layers directly to one
> another or in a network configuration. As a synchronous network, MOST
> provides excellent Quality of Service and seamless connectivity for
> audio/video streaming. Therefore, the driver perfectly fits to the mission
> of Automotive Grade Linux to create open source software solutions for
> automotive applications.
> 
> The driver consists basically of three layers. The hardware layer, the
> core layer and the application layer. The core layer consists of the core
> module only. This module handles the communication flow through all three
> layers, the configuration of the driver, the configuration interface
> representation in sysfs, and the buffer management.
> For each of the other two layers a selection of modules is provided. These
> modules can arbitrarily be combined to meet the needs of the desired
> system architecture. A module of the hardware layer is referred to as an
> HDM (hardware dependent module). Each module of this layer handles exactly
> one of the peripheral interfaces of a network interface controller (e.g.
> USB, MediaLB, I2C). A module of the application layer is referred to as an
> AIM (application interfacing module). The modules of this layer give access
> to MOST via one the following ways: character devices, ALSA, Networking or
> V4L2.
> 
> To physically access MOST, an Intelligent Network Interface Controller
> (INIC) is needed. For more information on available controllers visit:
> www.microchip.com

All looks good, I've now queued these up.

thanks for doing the work to clean up and split these into patches that
can be applied properly.

Now the real work begins :)

thanks,

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


Re: [PATCH 1/9] Staging: most: add MOST driver's core module

2015-07-24 Thread Greg KH
On Fri, Jul 24, 2015 at 04:11:48PM +0200, Christian Gromm wrote:
> This patch adds the core module of the MOST driver to the kernel's driver
> staging area. This module is part of the MOST driver and handles the
> configuration interface in sysfs, the buffer management and the data
> routing.



I put the information you placed below the --- line into the changelog
itself, as it should belong in the tree.  No need for that to never be
seen by anyone :)

thanks,

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


Re: [PATCH 6/7] staging: unisys: visornic - consolidate+simplify xmit watermark checks

2015-07-24 Thread Greg KH
On Fri, Jul 24, 2015 at 12:00:24PM -0400, Benjamin Romer wrote:
> From: Tim Sell 
> 
> The code that tests for high and low xmit watermarks was consolidated and
> simplified. The output behavior should be identical, with the exception
> of an off-by-one error being corrected in the tests done when the counters
> overflowed.
> 
> Note that the literals passed to max() macros need to be explicitly
> specified as unsigned long (UL), in order to prevent gcc warnings:
> 
> warning: comparison of distinct pointer types lacks a cast

You do know about max_t(), right?  Please redo this with that call
instead of the odd casting.

thanks,

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


Re: [PATCH RESEND] staging: rtl8188eu: don't duplicate ieee80211 WLAN_EID_* constants

2015-07-24 Thread Greg Kroah-Hartman
On Fri, Jul 24, 2015 at 05:12:38PM +0200, Jakub Sitnicki wrote:
> linux/ieee80211.h already defines constants for information element IDs.
> Include it where needed, resolve discrepancies in naming, and remove the
> duplicated definitions.
> 
> While at it, wrap a line that was too long and remove extra parentheses
> in an expression that mixes only equality and logical operators.

This patch doesn't apply at all.

Also, don't do more than one thing in a single patch, this should be
broken up into multiple ones.

thanks,

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


Re: [PATCH 2/7] staging: unisys: add simple error-check into visornic receive path

2015-07-24 Thread Greg KH
On Fri, Jul 24, 2015 at 12:00:20PM -0400, Benjamin Romer wrote:
> From: Tim Sell 
> 
> Add an error check here for use with dynamic debugging.
> 
> Signed-off-by: Benjamin Romer 
> Signed-off-by: Tim Sell 
> ---
>  drivers/staging/unisys/visornic/visornic_main.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
> b/drivers/staging/unisys/visornic/visornic_main.c
> index aeecb14..6ce3fc2 100644
> --- a/drivers/staging/unisys/visornic/visornic_main.c
> +++ b/drivers/staging/unisys/visornic/visornic_main.c
> @@ -1253,13 +1253,13 @@ visornic_rx(struct uiscmdrsp *cmdrsp)
>   curr->data_len = 0;
>   off += currsize;
>   }
> -#ifdef DEBUG
>   /* assert skb->len == off */
>   if (skb->len != off) {
>   dev_err(&devdata->netdev->dev,
> - "%s something wrong; skb->len:%d != off:%d\n",
> - netdev->name, skb->len, off);
> + "something wrong; skb->len:%d != off:%d\n",
> + skb->len, off);

The changelog comment doesn't match what you are doing here.

Also, shouldn't this be netdev_err() instead?

thanks,

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


Re: [PATCH 1/7] staging: unisys: visornic: fix serialization mechanism around usage atomic

2015-07-24 Thread Greg KH
On Fri, Jul 24, 2015 at 12:00:19PM -0400, Benjamin Romer wrote:
> From: Neil Horman 
> 
> Missed this in my initial review.  The usage counter that guards against
> kthread task is horribly racy.  The atomic is self consistent, but theres
> nothing that prevents the service_resp_queue function from re-incrementing
> it immediately after the check in disable_with_timeout is complete.  Its
> just a improper usage of atomics as a serialization mechanism.
> 
> Instead use kthread_park to pause the thread in its activity so that
> buffers can be properly freed without racing against usage in
> service_resp_queue
> 
> Signed-off-by: Neil Horman 
> Signed-off-by: Benjamin Romer 
> ---
>  drivers/staging/unisys/visornic/visornic_main.c | 23 ++-
>  kernel/kthread.c|  4 

Sorry, staging drivers can not modify other parts of the kernel.  Adding
exports for these kthread functions needs to happen as a "real" patch
that the kthread maintainer accepts, I can't take this.

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


Re: [PATCH 3/5] staging: rtl8712: remove duplicate struct

2015-07-24 Thread Greg Kroah-Hartman
On Thu, Jul 23, 2015 at 09:57:50PM -0700, Joshua Clayton wrote:
> struct ndis_wlan_bssid_ex is a dopelganger of
> struct wlan_bssid_ex, and is used about a third as often
> 
> Switch all instances to wlan_bssid_ex
> 
> This also gets rid of a use of typedef NDIS_802_11_RATES_EX
> 
> Signed-off-by: Joshua Clayton 
> ---
>  drivers/staging/rtl8712/rtl871x_cmd.c | 17 ++---
>  drivers/staging/rtl8712/rtl871x_cmd.h |  4 +--
>  drivers/staging/rtl8712/rtl871x_event.h   |  2 +-
>  drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 10 
>  drivers/staging/rtl8712/rtl871x_mlme.c| 35 
> +--
>  drivers/staging/rtl8712/rtl871x_mlme.h|  2 +-
>  drivers/staging/rtl8712/rtl871x_mp_ioctl.c|  6 ++---
>  drivers/staging/rtl8712/wlan_bssdef.h | 23 ++
>  8 files changed, 38 insertions(+), 61 deletions(-)
> 
> diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c 
> b/drivers/staging/rtl8712/rtl871x_cmd.c
> index f07050d..ef71829 100644
> --- a/drivers/staging/rtl8712/rtl871x_cmd.c
> +++ b/drivers/staging/rtl8712/rtl871x_cmd.c
> @@ -456,9 +456,7 @@ u8 r8712_createbss_cmd(struct _adapter *padapter)
>   INIT_LIST_HEAD(&pcmd->list);
>   pcmd->cmdcode = _CreateBss_CMD_;
>   pcmd->parmbuf = (unsigned char *)pdev_network;
> - pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz((
> - struct ndis_wlan_bssid_ex *)
> - pdev_network);
> + pcmd->cmdsz = r8712_get_wlan_bssid_ex_sz(pdev_network);
>   pcmd->rsp = NULL;
>   pcmd->rspsz = 0;
>   /* notes: translate IELength & Length after assign to cmdsz; */
> @@ -471,7 +469,7 @@ u8 r8712_createbss_cmd(struct _adapter *padapter)
>  
>  u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network 
> *pnetwork)

Patch is line-wrapped and can not be applied :(

Can you redo this whole series and resend properly?  Your 0/5 email
needs a subject as well...

thanks,

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


RE: [PATCH 0/6] staging: comedi: usbduxsigma: fix some problems in command handling

2015-07-24 Thread Hartley Sweeten
On Thursday, July 23, 2015 8:47 AM, Ian Abbott wrote:
>
> Fix some minor problems in the testing of asynchronous commands for the AI
> and AO subdevices and remove some redundant code.
>
> The main problem is that the testing of a new command can affect the
> operation of an already running command, which it isn't supposed to do.  (In
> practice, applications don't tend to test new commands while a command is
> running on the same subdevice, so the bug can be classed as minor.)  This is
> corrected by the patches 1 and 2, for the AI and AO subdevices,
> respectively.
>
> 1) staging: comedi: usbduxsigma: don't clobber ai_timer in command test
> 2) staging: comedi: usbduxsigma: don't clobber ao_timer in command test
> 3) staging: comedi: usbduxsigma: remove AI scan_begin_src == TRIG_FOLLOW
> 4) staging: comedi: usbduxsigma: round down AI scan_begin_arg at step 4.
> 5) staging: comedi: usbduxsigma: remove unused "convert" timing for AO
> 6) staging: comedi: usbduxsigma: round down AO scan_begin_arg at step 4.
>
>  drivers/staging/comedi/drivers/usbduxsigma.c | 139 
> +++
>  1 file changed, 54 insertions(+), 85 deletions(-)

Reviewed-by: H Hartley Sweeten 

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


Re: [PATCH 1/6] staging: comedi: usbduxsigma: don't clobber ai_timer in command test

2015-07-24 Thread Bernd Porr

Reviewed-by: Bernd Porr 

Ian Abbott wrote:

`devpriv->ai_timer` is used while an asynchronous command is running on
the AI subdevice.  It also gets modified by the subdevice's `cmdtest`
handler for checking new asynchronous commands
(`usbduxsigma_ai_cmdtest()`), which is not correct as it's allowed to
check new commands while an old command is still running.  Fix it by
moving the code which sets up `devpriv->ai_timer` and
`devpriv->ai_interval` into the subdevice's `cmd` handler,
`usbduxsigma_ai_cmd()`.

Note that the removed code in `usbduxsigma_ai_cmdtest()` checked that
`devpriv->ai_timer` did not end up less than than 1, but that could not
happen because `cmd->scan_begin_arg` had already been checked to be at
least the minimum required value (at least when `cmd->scan_begin_src ==
TRIG_TIMER`, which had also been checked to be the case).

Fixes: b986be8527c7 ("staging: comedi: usbduxsigma: tidy up analog input 
command support)
Signed-off-by: Ian Abbott 
Cc:  # 3.19 onwards
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 37 
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index eaa9add..22517de 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -550,27 +550,6 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device 
*dev,
if (err)
return 3;
 
-	/* Step 4: fix up any arguments */

-
-   if (high_speed) {
-   /*
-* every 2 channels get a time window of 125us. Thus, if we
-* sample all 16 channels we need 1ms. If we sample only one
-* channel we need only 125us
-*/
-   devpriv->ai_interval = interval;
-   devpriv->ai_timer = cmd->scan_begin_arg / (125000 * interval);
-   } else {
-   /* interval always 1ms */
-   devpriv->ai_interval = 1;
-   devpriv->ai_timer = cmd->scan_begin_arg / 100;
-   }
-   if (devpriv->ai_timer < 1)
-   err |= -EINVAL;
-
-   if (err)
-   return 4;
-
return 0;
 }
 
@@ -668,6 +647,22 @@ static int usbduxsigma_ai_cmd(struct comedi_device *dev,
 
 	down(&devpriv->sem);
 
+	if (devpriv->high_speed) {

+   /*
+* every 2 channels get a time window of 125us. Thus, if we
+* sample all 16 channels we need 1ms. If we sample only one
+* channel we need only 125us
+*/
+   unsigned int interval = usbduxsigma_chans_to_interval(len);
+
+   devpriv->ai_interval = interval;
+   devpriv->ai_timer = cmd->scan_begin_arg / (125000 * interval);
+   } else {
+   /* interval always 1ms */
+   devpriv->ai_interval = 1;
+   devpriv->ai_timer = cmd->scan_begin_arg / 100;
+   }
+
for (i = 0; i < len; i++) {
unsigned int chan  = CR_CHAN(cmd->chanlist[i]);
 


--
http://www.berndporr.me.uk
http://www.linux-usb-daq.co.uk
http://www.imdb.com/name/nm3293421/
+44 (0)7840 340069
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/6] staging: comedi: usbduxsigma: remove AI scan_begin_src == TRIG_FOLLOW

2015-07-24 Thread Bernd Porr

Reviewed-by: Bernd Porr 

Ian Abbott wrote:

The AI subdevice `cmdtest` handler `usbduxsigma_ai_cmdtest()` ensures
that `cmd->scan_begin_src == TRIG_TIMER` by the end of step 2 of the
command checking code, so assume that this is the case for step 3
onwards and remove the redundant code.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index dc0b25a..65a0df4 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -481,6 +481,7 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device *dev,
struct usbduxsigma_private *devpriv = dev->private;
int high_speed = devpriv->high_speed;
int interval = usbduxsigma_chans_to_interval(cmd->chanlist_len);
+   unsigned int tmp;
int err = 0;
 
 	/* Step 1 : check if triggers are trivially valid */

@@ -508,36 +509,26 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device 
*dev,
 
 	err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-	if (cmd->scan_begin_src == TRIG_FOLLOW)	/* internal trigger */

-   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+   if (high_speed) {
+   /*
+* In high speed mode microframes are possible.
+* However, during one microframe we can roughly
+* sample two channels. Thus, the more channels
+* are in the channel list the more time we need.
+*/
+   err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+   (125000 * interval));
 
-	if (cmd->scan_begin_src == TRIG_TIMER) {

-   unsigned int tmp;
-
-   if (high_speed) {
-   /*
-* In high speed mode microframes are possible.
-* However, during one microframe we can roughly
-* sample two channels. Thus, the more channels
-* are in the channel list the more time we need.
-*/
-   err |= comedi_check_trigger_arg_min(&cmd->
-   scan_begin_arg,
-   (100 / 8 *
-interval));
-
-   tmp = (cmd->scan_begin_arg / 125000) * 125000;
-   } else {
-   /* full speed */
-   /* 1kHz scans every USB frame */
-   err |= comedi_check_trigger_arg_min(&cmd->
-   scan_begin_arg,
-   100);
-
-   tmp = (cmd->scan_begin_arg / 100) * 100;
-   }
-   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, tmp);
+   tmp = (cmd->scan_begin_arg / 125000) * 125000;
+   } else {
+   /* full speed */
+   /* 1kHz scans every USB frame */
+   err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+   100);
+
+   tmp = (cmd->scan_begin_arg / 100) * 100;
}
+   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, tmp);
 
 	err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,

   cmd->chanlist_len);


--
http://www.berndporr.me.uk
http://www.linux-usb-daq.co.uk
http://www.imdb.com/name/nm3293421/
+44 (0)7840 340069
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/6] staging: comedi: usbduxsigma: round down AI scan_begin_arg at step 4.

2015-07-24 Thread Bernd Porr

Reviewed-by: Bernd Porr 

Ian Abbott wrote:

The return value of the `cmdtest` handler for a subdevice checks the
prospective new command in various steps and returns the step number at
which any problem was detected, or 0 if no problem was detected.  It is
allowed to modify the command in various ways at each step.  Corrections
for out-of-range values are generally made at step 3, and minor
adjustments such as rounding are generally made at step 4.

The `cmdtest` handler for the AI subdevice (`usbduxsigma_ai_cmdtest()`)
currently modifies `cmd->scan_begin_arg` to bring it into range and
round it down at step 3.  Move the rounding down part to step 4 to
follow the usual Comedi convention.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 65a0df4..4655048 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -518,17 +518,12 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device 
*dev,
 */
err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
(125000 * interval));
-
-   tmp = (cmd->scan_begin_arg / 125000) * 125000;
} else {
/* full speed */
/* 1kHz scans every USB frame */
err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
100);
-
-   tmp = (cmd->scan_begin_arg / 100) * 100;
}
-   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, tmp);
 
 	err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,

   cmd->chanlist_len);
@@ -541,6 +536,14 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device 
*dev,
if (err)
return 3;
 
+	/* Step 4: fix up any arguments */

+
+   tmp = rounddown(cmd->scan_begin_arg, high_speed ? 125000 : 100);
+   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, tmp);
+
+   if (err)
+   return 4;
+
return 0;
 }
 


--
http://www.berndporr.me.uk
http://www.linux-usb-daq.co.uk
http://www.imdb.com/name/nm3293421/
+44 (0)7840 340069
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 6/6] staging: comedi: usbduxsigma: round down AO scan_begin_arg at step 4.

2015-07-24 Thread Bernd Porr

Reviewed-by: Bernd Porr 

Ian Abbott wrote:

The return value of the `cmdtest` handler for a subdevice checks the
prospective new command in various steps and returns the step number at
which any problem was detected, or 0 if no problem was detected.  It is
allowed to modify the command in various ways at each step.  Corrections
for out-of-range values are generally made at step 3, and minor
adjustments such as rounding are generally made at step 4.

The `cmdtest` handler for the AO subdevice (`usbduxsigma_ao_cmdtest()`)
currently range checks the timings at step 3.  Since the running command
will round down the timings, add code to round them down at step 4.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index d97253e..e22c374 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -837,6 +837,7 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device *dev,
  struct comedi_cmd *cmd)
 {
struct usbduxsigma_private *devpriv = dev->private;
+   unsigned int tmp;
int err = 0;
 
 	/* Step 1 : check if triggers are trivially valid */

@@ -888,6 +889,14 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device 
*dev,
if (err)
return 3;
 
+	/* Step 4: fix up any arguments */

+
+   tmp = rounddown(cmd->scan_begin_arg, 100);
+   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, tmp);
+
+   if (err)
+   return 4;
+
return 0;
 }
 


--
http://www.berndporr.me.uk
http://www.linux-usb-daq.co.uk
http://www.imdb.com/name/nm3293421/
+44 (0)7840 340069
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 5/6] staging: comedi: usbduxsigma: remove unused "convert" timing for AO

2015-07-24 Thread Bernd Porr

Reviewed-by: Bernd Porr 

Ian Abbott wrote:

The `cmdtest` and `cmd` handlers for the AO subdevice
(`usbduxsigma_ao_cmdtest()` and `usbduxsigma_ao_cmd()`) support "scan"
timing of commands with all channels updated every "scan" period.  There
is some disabled code to use "convert" timing in high speed mode.  That
would allow channels to be updated sequentially every "convert" period.
Since that code is incomplete and currently disabled, remove it to
simplify the existing code.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 4655048..d97253e 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -838,28 +838,20 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device 
*dev,
 {
struct usbduxsigma_private *devpriv = dev->private;
int err = 0;
-   int high_speed;
-   unsigned int flags;
-
-   /* high speed conversions are not used yet */
-   high_speed = 0; /* (devpriv->high_speed) */
 
 	/* Step 1 : check if triggers are trivially valid */
 
 	err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
 
-	if (high_speed) {

-   /*
-* start immediately a new scan
-* the sampling rate is set by the coversion rate
-*/
-   flags = TRIG_FOLLOW;
-   } else {
-   /* start a new scan (output at once) with a timer */
-   flags = TRIG_TIMER;
-   }
-   err |= comedi_check_trigger_src(&cmd->scan_begin_src, flags);
-
+   /*
+* For now, always use "scan" timing with all channels updated at once
+* (cmd->scan_begin_src == TRIG_TIMER, cmd->convert_src == TRIG_NOW).
+*
+* In a future version, "convert" timing with channels updated
+* indivually may be supported in high speed mode
+* (cmd->scan_begin_src == TRIG_FOLLOW, cmd->convert_src == TRIG_TIMER).
+*/
+   err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
@@ -883,17 +875,7 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device 
*dev,
 
 	err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-	if (cmd->scan_begin_src == TRIG_FOLLOW)	/* internal trigger */

-   err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-
-   if (cmd->scan_begin_src == TRIG_TIMER) {
-   err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
-   100);
-   }
-
-   /* not used now, is for later use */
-   if (cmd->convert_src == TRIG_TIMER)
-   err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 125000);
+   err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg, 100);
 
 	err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,

   cmd->chanlist_len);
@@ -918,19 +900,13 @@ static int usbduxsigma_ao_cmd(struct comedi_device *dev,
 
 	down(&devpriv->sem);
 
-	if (cmd->convert_src == TRIG_TIMER) {

-   /*
-* timing of the conversion itself: every 125 us
-* at high speed (not used yet)
-*/
-   devpriv->ao_timer = cmd->convert_arg / 125000;
-   } else {
-   /*
-* timing of the scan: every 1ms
-* we get all channels at once
-*/
-   devpriv->ao_timer = cmd->scan_begin_arg / 100;
-   }
+   /*
+* For now, only "scan" timing is supported.  A future version may
+* support "convert" timing in high speed mode.
+*
+* Timing of the scan: every 1ms all channels updated at once.
+*/
+   devpriv->ao_timer = cmd->scan_begin_arg / 100;
 
 	devpriv->ao_counter = devpriv->ao_timer;
 


--
http://www.berndporr.me.uk
http://www.linux-usb-daq.co.uk
http://www.imdb.com/name/nm3293421/
+44 (0)7840 340069
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/6] staging: comedi: usbduxsigma: don't clobber ao_timer in command test

2015-07-24 Thread Bernd Porr

Reviewed-by: Bernd Porr 

Ian Abbott wrote:

`devpriv->ao_timer` is used while an asynchronous command is running on
the AO subdevice.  It also gets modified by the subdevice's `cmdtest`
handler for checking new asynchronous commands,
`usbduxsigma_ao_cmdtest()`, which is not correct as it's allowed to
check new commands while an old command is still running.  Fix it by
moving the code which sets up `devpriv->ao_timer` into the subdevice's
`cmd` handler, `usbduxsigma_ao_cmd()`.

Note that the removed code in `usbduxsigma_ao_cmdtest()` checked that
`devpriv->ao_timer` did not end up less that 1, but that could not
happen due because `cmd->scan_begin_arg` or `cmd->convert_arg` had
already been range-checked.

Also note that we tested the `high_speed` variable in the old code, but
that is currently always 0 and means that we always use "scan" timing
(`cmd->scan_begin_src == TRIG_TIMER` and `cmd->convert_src == TRIG_NOW`)
and never "convert" (individual sample) timing (`cmd->scan_begin_src ==
TRIG_FOLLOW` and `cmd->convert_src == TRIG_TIMER`).  The moved code
tests `cmd->convert_src` instead to decide whether "scan" or "convert"
timing is being used, although currently only "scan" timing is
supported.

Fixes: fb1ef622e7a3 ("staging: comedi: usbduxsigma: tidy up analog output command 
support")
Signed-off-by: Ian Abbott 
Cc:  # 3.19 onwards
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 33 
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 22517de..dc0b25a 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -912,25 +912,6 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device 
*dev,
if (err)
return 3;
 
-	/* Step 4: fix up any arguments */

-
-   /* we count in timer steps */
-   if (high_speed) {
-   /* timing of the conversion itself: every 125 us */
-   devpriv->ao_timer = cmd->convert_arg / 125000;
-   } else {
-   /*
-* timing of the scan: every 1ms
-* we get all channels at once
-*/
-   devpriv->ao_timer = cmd->scan_begin_arg / 100;
-   }
-   if (devpriv->ao_timer < 1)
-   err |= -EINVAL;
-
-   if (err)
-   return 4;
-
return 0;
 }
 
@@ -943,6 +924,20 @@ static int usbduxsigma_ao_cmd(struct comedi_device *dev,
 
 	down(&devpriv->sem);
 
+	if (cmd->convert_src == TRIG_TIMER) {

+   /*
+* timing of the conversion itself: every 125 us
+* at high speed (not used yet)
+*/
+   devpriv->ao_timer = cmd->convert_arg / 125000;
+   } else {
+   /*
+* timing of the scan: every 1ms
+* we get all channels at once
+*/
+   devpriv->ao_timer = cmd->scan_begin_arg / 100;
+   }
+
devpriv->ao_counter = devpriv->ao_timer;
 
 	if (cmd->start_src == TRIG_NOW) {


--
http://www.berndporr.me.uk
http://www.linux-usb-daq.co.uk
http://www.imdb.com/name/nm3293421/
+44 (0)7840 340069
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: lustre: Replace strtoul with simple_strtoul

2015-07-24 Thread Guenter Roeck
Defining and using strtoul in lustre code results in the following
compile warnings (arm64:allmodconfig).

include/linux/libcfs/libcfs_string.h:105:0: warning: "strtoul" redefined
#define strtoul(str, endp, base) simple_strtoul(str, endp, base)
include/acpi/platform/aclinux.h:122:0: note:
this is the location of the previous definition
#define strtoul simple_strtoul

Remove the definition and use simple_strtoul() directly. Note that we
can not replace simple_strtoul with kstrtoul since the end pointer
is used by the code.

Signed-off-by: Guenter Roeck 
---
 drivers/staging/lustre/include/linux/libcfs/libcfs_string.h | 2 --
 drivers/staging/lustre/lustre/include/obd.h | 2 +-
 drivers/staging/lustre/lustre/libcfs/libcfs_string.c| 2 +-
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
index 509dc1e5c3b1..478e9582ff54 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
@@ -102,6 +102,4 @@ int cfs_ip_addr_parse(char *str, int len, struct list_head 
*list);
 int cfs_ip_addr_match(__u32 addr, struct list_head *list);
 void cfs_ip_addr_free(struct list_head *list);
 
-#definestrtoul(str, endp, base)simple_strtoul(str, endp, base)
-
 #endif
diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index 55452e562bd4..9ad8c268da10 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -1472,7 +1472,7 @@ static inline bool filename_is_volatile(const char *name, 
int namelen, int *idx)
}
/* we have an idx, read it */
start = name + LUSTRE_VOLATILE_HDR_LEN + 1;
-   *idx = strtoul(start, &end, 0);
+   *idx = simple_strtoul(start, &end, 0);
/* error cases:
 * no digit, no trailing :, negative value
 */
diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c 
b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
index 76d4392bd282..4dde8e08c0ba 100644
--- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
+++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
@@ -231,7 +231,7 @@ cfs_str2num_check(char *str, int nob, unsigned *num,
char*endp;
 
str = cfs_trimwhite(str);
-   *num = strtoul(str, &endp, 0);
+   *num = simple_strtoul(str, &endp, 0);
if (endp == str)
return 0;
 
-- 
2.1.0

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


[PATCH 3/6] drivers, staging, unisys Add modalias files to visorbus devices

2015-07-24 Thread Benjamin Romer
From: Prarit Bhargava 

This patch adds modalias files that export the device UUID type to sysfs
so that udev can autoload the appropriate device driver on demand.  Note
that is required a minor name change to the channel device sysfs files
which are currently named visorbus_dev_groups, and are now named
visorbus_channel_groups.

Signed-off-by: Prarit Bhargava 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 45 +++--
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 403c13b..cc4a029 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -69,6 +69,38 @@ static const struct attribute_group *visorbus_bus_groups[] = 
{
NULL,
 };
 
+/*
+ * DEVICE type attributes
+ *
+ * The modalias file will contain the guid of the device.
+ */
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct visor_device *vdev;
+   uuid_le guid;
+
+   vdev = to_visor_device(dev);
+   guid = visorchannel_get_uuid(vdev->visorchannel);
+   return snprintf(buf, PAGE_SIZE, "visorbus:%pUl\n", &guid);
+}
+static DEVICE_ATTR_RO(modalias);
+
+static struct attribute *visorbus_dev_attrs[] = {
+   &dev_attr_modalias.attr,
+   NULL,
+};
+
+/* sysfs example for bridge-only sysfs files using device_type's */
+static const struct attribute_group visorbus_dev_group = {
+   .attrs = visorbus_dev_attrs,
+};
+
+const struct attribute_group *visorbus_dev_groups[] = {
+   &visorbus_dev_group,
+   NULL,
+};
+
 /** This describes the TYPE of bus.
  *  (Don't confuse this with an INSTANCE of the bus.)
  */
@@ -76,6 +108,7 @@ struct bus_type visorbus_type = {
.name = "visorbus",
.match = visorbus_match,
.uevent = visorbus_uevent,
+   .dev_groups = visorbus_dev_groups,
.bus_groups = visorbus_bus_groups,
 };
 
@@ -128,7 +161,13 @@ static LIST_HEAD(list_all_device_instances);
 static int
 visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env)
 {
-   if (add_uevent_var(env, "VERSION=%s", VERSION))
+   struct visor_device *dev;
+   uuid_le guid;
+
+   dev = to_visor_device(xdev);
+   guid = visorchannel_get_uuid(dev->visorchannel);
+
+   if (add_uevent_var(env, "MODALIAS=visorbus:%pUl", &guid))
return -ENOMEM;
return 0;
 }
@@ -477,7 +516,7 @@ static struct attribute_group channel_attr_grp = {
.attrs = channel_attrs,
 };
 
-static const struct attribute_group *visorbus_dev_groups[] = {
+static const struct attribute_group *visorbus_channel_groups[] = {
&channel_attr_grp,
NULL
 };
@@ -936,7 +975,7 @@ create_visor_device(struct visor_device *dev)
 
sema_init(&dev->visordriver_callback_lock, 1);  /* unlocked */
dev->device.bus = &visorbus_type;
-   dev->device.groups = visorbus_dev_groups;
+   dev->device.groups = visorbus_channel_groups;
device_initialize(&dev->device);
dev->device.release = visorbus_release_device;
/* keep a reference just for us (now 2) */
-- 
2.1.4

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


[PATCH 4/6] drivers, staging, unisys Add visorbus module autoloading code

2015-07-24 Thread Benjamin Romer
From: Prarit Bhargava 

This patch adds an module alias and a MODULE_DEVICE_TABLE to autoload the
visorhba driver when an appropriate device is created by the visorbus.

Signed-off-by: Prarit Bhargava 
---
 drivers/staging/unisys/visorhba/visorhba_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c 
b/drivers/staging/unisys/visorhba/visorhba_main.c
index 031c6fa..50ecdf2 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -80,6 +80,8 @@ static struct visor_driver visorhba_driver = {
.resume = visorhba_resume,
.channel_interrupt = NULL,
 };
+MODULE_DEVICE_TABLE(visorbus, visorhba_channel_types);
+MODULE_ALIAS("visorbus:" SPAR_VHBA_CHANNEL_PROTOCOL_UUID_STR);
 
 struct visor_thread_info {
struct task_struct *task;
-- 
2.1.4

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


[PATCH 6/6] drivers, staging, unisys Add visorhid module autoloading code

2015-07-24 Thread Benjamin Romer
From: Prarit Bhargava 

This patch adds an module alias and a MODULE_DEVICE_TABLE to autoload
the
visorhid driver when an appropriate device is created by the visorbus.
Additional code cleanups to match the other visor* drivers.

Signed-off-by: Prarit Bhargava 
---
 drivers/staging/unisys/visorhid/keyboardchannel.h |  3 ++-
 drivers/staging/unisys/visorhid/mousechannel.h|  4 +++-
 drivers/staging/unisys/visorhid/visorhid.c| 18 ++
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/unisys/visorhid/keyboardchannel.h 
b/drivers/staging/unisys/visorhid/keyboardchannel.h
index 1d11966..2ed2602 100644
--- a/drivers/staging/unisys/visorhid/keyboardchannel.h
+++ b/drivers/staging/unisys/visorhid/keyboardchannel.h
@@ -21,10 +21,11 @@
 #include "channel.h"
 #include "ultrainputreport.h"
 
-/* {C73416D0-B0B8-44af-B304-9D2AE99F1B3D} */
+/* {c73416d0-b0b8-44af-b304-9d2ae99f1b3d} */
 #define SPAR_KEYBOARD_CHANNEL_PROTOCOL_UUID\
UUID_LE(0xc73416d0, 0xb0b8, 0x44af, \
0xb3, 0x4, 0x9d, 0x2a, 0xe9, 0x9f, 0x1b, 0x3d)
+#define SPAR_KEYBOARD_CHANNEL_PROTOCOL_UUID_STR 
"c73416d0-b0b8-44af-b304-9d2ae99f1b3d"
 #define SPAR_KEYBOARD_CHANNEL_PROTOCOL_VERSIONID 1
 #define KEYBOARD_MAXINPUTREPORTS 50
 
diff --git a/drivers/staging/unisys/visorhid/mousechannel.h 
b/drivers/staging/unisys/visorhid/mousechannel.h
index 2633078..256477a 100644
--- a/drivers/staging/unisys/visorhid/mousechannel.h
+++ b/drivers/staging/unisys/visorhid/mousechannel.h
@@ -21,10 +21,12 @@
 #include "channel.h"
 #include "ultrainputreport.h"
 
-/* {ADDF07D4-94A9-46e2-81C3-61ABCDBDBD87} */
+/* {addf07d4-94a9-46e2-81c3-61abcdbdbd87} */
 #define SPAR_MOUSE_CHANNEL_PROTOCOL_UUID  \
UUID_LE(0xaddf07d4, 0x94a9, 0x46e2, \
0x81, 0xc3, 0x61, 0xab, 0xcd, 0xbd, 0xbd, 0x87)
+#define SPAR_MOUSE_CHANNEL_PROTOCOL_UUID_STR \
+   "addf07d4-94a9-46e2-81c3-61abcdbdbd87"
 #define SPAR_MOUSE_CHANNEL_PROTOCOL_VERSIONID 1
 #define MOUSE_MAXINPUTREPORTS 50
 
diff --git a/drivers/staging/unisys/visorhid/visorhid.c 
b/drivers/staging/unisys/visorhid/visorhid.c
index 1eaade0..7785088 100644
--- a/drivers/staging/unisys/visorhid/visorhid.c
+++ b/drivers/staging/unisys/visorhid/visorhid.c
@@ -53,19 +53,13 @@ static void unregister_client_input(struct input_dev 
*visorinput_dev);
 
 /* GUIDS for all channel types supported by this driver. */
 static struct visor_channeltype_descriptor visorhid_channel_types[] = {
-   {
-   .guid = SPAR_KEYBOARD_CHANNEL_PROTOCOL_UUID,
-   .name = "keyboard"
-   },
-   {
-   .guid = SPAR_MOUSE_CHANNEL_PROTOCOL_UUID,
-   .name = "mouse"
-   },
-   {
-   .guid = NULL_UUID_LE,
-   .name = NULL
-   }
+   { SPAR_KEYBOARD_CHANNEL_PROTOCOL_UUID, "keyboard"},
+   { SPAR_MOUSE_CHANNEL_PROTOCOL_UUID, "mouse"},
+   { NULL_UUID_LE, NULL }
 };
+MODULE_DEVICE_TABLE(visorbus, visorhid_channel_types);
+MODULE_ALIAS("visorbus:" SPAR_MOUSE_CHANNEL_PROTOCOL_UUID_STR);
+MODULE_ALIAS("visorbus:" SPAR_KEYBOARD_CHANNEL_PROTOCOL_UUID_STR);
 
 /** This is used to tell the visor bus driver which types of visor devices
  *  we support, and what functions to call when a visor device that we support
-- 
2.1.4

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


[PATCH 1/6] drivers, staging, unisys, cleanup channel_guid.h

2015-07-24 Thread Benjamin Romer
From: Prarit Bhargava 

This file has a lot of dead comments and needs to be cleaned up.

Signed-off-by: Prarit Bhargava 
---
 drivers/staging/unisys/include/channel_guid.h | 20 +---
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/unisys/include/channel_guid.h 
b/drivers/staging/unisys/include/channel_guid.h
index 706363fc..2cc4b0b 100644
--- a/drivers/staging/unisys/include/channel_guid.h
+++ b/drivers/staging/unisys/include/channel_guid.h
@@ -17,35 +17,27 @@
  * CHANNEL Guids
  */
 
-/* Used in IOChannel
- * {414815ed-c58c-11da-95a9-00e08161165f}
- */
+/* {414815ed-c58c-11da-95a9-00e08161165f} */
 #define SPAR_VHBA_CHANNEL_PROTOCOL_UUID \
UUID_LE(0x414815ed, 0xc58c, 0x11da, \
0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
 static const uuid_le spar_vhba_channel_protocol_uuid =
SPAR_VHBA_CHANNEL_PROTOCOL_UUID;
 
-/* Used in IOChannel
- * {8cd5994d-c58e-11da-95a9-00e08161165f}
- */
+/* {8cd5994d-c58e-11da-95a9-00e08161165f} */
 #define SPAR_VNIC_CHANNEL_PROTOCOL_UUID \
UUID_LE(0x8cd5994d, 0xc58e, 0x11da, \
0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
 static const uuid_le spar_vnic_channel_protocol_uuid =
SPAR_VNIC_CHANNEL_PROTOCOL_UUID;
 
-/* Used in IOChannel
- * {72120008-4AAB-11DC-8530-444553544200}
- */
+/* {72120008-4AAB-11DC-8530-444553544200} */
 #define SPAR_SIOVM_UUID \
UUID_LE(0x72120008, 0x4AAB, 0x11DC, \
0x85, 0x30, 0x44, 0x45, 0x53, 0x54, 0x42, 0x00)
 static const uuid_le spar_siovm_uuid = SPAR_SIOVM_UUID;
 
-/* Used in visornoop/visornoop_main.c
- * {5b52c5ac-e5f5-4d42-8dff-429eaecd221f}
- */
+/* {5b52c5ac-e5f5-4d42-8dff-429eaecd221f} */
 #define SPAR_CONTROLDIRECTOR_CHANNEL_PROTOCOL_UUID  \
UUID_LE(0x5b52c5ac, 0xe5f5, 0x4d42, \
0x8d, 0xff, 0x42, 0x9e, 0xae, 0xcd, 0x22, 0x1f)
@@ -53,9 +45,7 @@ static const uuid_le spar_siovm_uuid = SPAR_SIOVM_UUID;
 static const uuid_le spar_controldirector_channel_protocol_uuid =
SPAR_CONTROLDIRECTOR_CHANNEL_PROTOCOL_UUID;
 
-/* Used in visorchipset/visorchipset_main.c
- * {B4E79625-AEDE-4EAA-9E11-D3EDDCD4504C}
- */
+/* {b4e79625-aede-4eAA-9e11-D3eddcd4504c} */
 #define SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID   \
UUID_LE(0xb4e79625, 0xaede, 0x4eaa, \
0x9e, 0x11, 0xd3, 0xed, 0xdc, 0xd4, 0x50, 0x4c)
-- 
2.1.4

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


[PATCH 2/6] staging: unisys: add UUID strings to channel_guid.h

2015-07-24 Thread Benjamin Romer
From: Prarit Bhargava 

Define additional strings for module loading code ease of use.

Signed-off-by: Prarit Bhargava 
---
 drivers/staging/unisys/include/channel_guid.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/unisys/include/channel_guid.h 
b/drivers/staging/unisys/include/channel_guid.h
index 2cc4b0b..17cb499 100644
--- a/drivers/staging/unisys/include/channel_guid.h
+++ b/drivers/staging/unisys/include/channel_guid.h
@@ -23,6 +23,8 @@
0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
 static const uuid_le spar_vhba_channel_protocol_uuid =
SPAR_VHBA_CHANNEL_PROTOCOL_UUID;
+#define SPAR_VHBA_CHANNEL_PROTOCOL_UUID_STR \
+   "414815ed-c58c-11da-95a9-00e08161165f"
 
 /* {8cd5994d-c58e-11da-95a9-00e08161165f} */
 #define SPAR_VNIC_CHANNEL_PROTOCOL_UUID \
@@ -30,6 +32,8 @@ static const uuid_le spar_vhba_channel_protocol_uuid =
0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
 static const uuid_le spar_vnic_channel_protocol_uuid =
SPAR_VNIC_CHANNEL_PROTOCOL_UUID;
+#define SPAR_VNIC_CHANNEL_PROTOCOL_UUID_STR \
+   "8cd5994d-c58e-11da-95a9-00e08161165f"
 
 /* {72120008-4AAB-11DC-8530-444553544200} */
 #define SPAR_SIOVM_UUID \
-- 
2.1.4

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


[PATCH 5/6] drivers, staging, unisys Add visornic module autoloading code

2015-07-24 Thread Benjamin Romer
From: Prarit Bhargava 

This patch adds an module alias and a MODULE_DEVICE_TABLE to autoload the
visornic driver when an appropriate device is created by the visorbus.

Signed-off-by: Prarit Bhargava 
---
 drivers/staging/unisys/visornic/visornic_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index 4b5fc07..bfc9727 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -71,6 +71,8 @@ static struct visor_channeltype_descriptor 
visornic_channel_types[] = {
{ SPAR_VNIC_CHANNEL_PROTOCOL_UUID, "ultravnic" },
{ NULL_UUID_LE, NULL }
 };
+MODULE_DEVICE_TABLE(visorbus, visornic_channel_types);
+MODULE_ALIAS("visorbus:" SPAR_VNIC_CHANNEL_PROTOCOL_UUID_STR);
 
 /* This is used to tell the visor bus driver which types of visor devices
  * we support, and what functions to call when a visor device that we support
-- 
2.1.4

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


[PATCH 0/6] staging: unisys: module autoload support

2015-07-24 Thread Benjamin Romer
This patch series adds support for automatically loading the unisys
drivers from modules.

Prarit Bhargava (6):
  drivers, staging, unisys, cleanup channel_guid.h
  staging: unisys: add UUID strings to channel_guid.h
  drivers, staging, unisys Add modalias files to visorbus devices
  drivers, staging, unisys Add visorbus module autoloading code
  drivers, staging, unisys Add visornic module autoloading code
  drivers, staging, unisys Add visorhid module autoloading code

 drivers/staging/unisys/include/channel_guid.h | 24 +---
 drivers/staging/unisys/visorbus/visorbus_main.c   | 45 +--
 drivers/staging/unisys/visorhba/visorhba_main.c   |  2 +
 drivers/staging/unisys/visorhid/keyboardchannel.h |  3 +-
 drivers/staging/unisys/visorhid/mousechannel.h|  4 +-
 drivers/staging/unisys/visorhid/visorhid.c| 18 +++--
 drivers/staging/unisys/visornic/visornic_main.c   |  2 +
 7 files changed, 66 insertions(+), 32 deletions(-)

-- 
2.1.4

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


[PATCH 2/7] staging: unisys: add simple error-check into visornic receive path

2015-07-24 Thread Benjamin Romer
From: Tim Sell 

Add an error check here for use with dynamic debugging.

Signed-off-by: Benjamin Romer 
Signed-off-by: Tim Sell 
---
 drivers/staging/unisys/visornic/visornic_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index aeecb14..6ce3fc2 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -1253,13 +1253,13 @@ visornic_rx(struct uiscmdrsp *cmdrsp)
curr->data_len = 0;
off += currsize;
}
-#ifdef DEBUG
/* assert skb->len == off */
if (skb->len != off) {
dev_err(&devdata->netdev->dev,
-   "%s something wrong; skb->len:%d != off:%d\n",
-   netdev->name, skb->len, off);
+   "something wrong; skb->len:%d != off:%d\n",
+   skb->len, off);
}
+#ifdef DEBUG
/* test code */
cc = util_copy_fragsinfo_from_skb("rcvchaintest", skb,
  RCVPOST_BUF_SIZE,
-- 
2.1.4

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


[PATCH 6/7] staging: unisys: visornic - consolidate+simplify xmit watermark checks

2015-07-24 Thread Benjamin Romer
From: Tim Sell 

The code that tests for high and low xmit watermarks was consolidated and
simplified. The output behavior should be identical, with the exception
of an off-by-one error being corrected in the tests done when the counters
overflowed.

Note that the literals passed to max() macros need to be explicitly
specified as unsigned long (UL), in order to prevent gcc warnings:

warning: comparison of distinct pointer types lacks a cast

Signed-off-by: Tim Sell 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visornic/visornic_main.c | 109 +++-
 1 file changed, 71 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index baa137e..bd58e15 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -134,15 +134,16 @@ struct visornic_devdata {
atomic_t num_rcvbuf_in_iovm;
unsigned long alloc_failed_in_if_needed_cnt;
unsigned long alloc_failed_in_repost_rtn_cnt;
-   int max_outstanding_net_xmits;   /* absolute max number of outstanding
- * xmits - should never hit this
- */
-   int upper_threshold_net_xmits;   /* high water mark for calling
- * netif_stop_queue()
- */
-   int lower_threshold_net_xmits;   /* high water mark for calling
- * netif_wake_queue()
- */
+   unsigned long max_outstanding_net_xmits; /* absolute max number of
+ * outstanding xmits - should
+ * never hit this
+ */
+   unsigned long upper_threshold_net_xmits;  /* high water mark for
+  * calling netif_stop_queue()
+  */
+   unsigned long lower_threshold_net_xmits; /* high water mark for calling
+ * netif_wake_queue()
+ */
struct sk_buff_head xmitbufhead; /* xmitbufhead is the head of the
  * xmit buffer list that have been
  * sent to the IOPART end
@@ -779,6 +780,53 @@ visornic_close(struct net_device *netdev)
 }
 
 /**
+ * devdata_xmits_outstanding - compute outstanding xmits
+ * @devdata: visornic_devdata for device
+ *
+ * Return value is the number of outstanding xmits.
+ */
+static unsigned long devdata_xmits_outstanding(struct visornic_devdata 
*devdata)
+{
+   if (devdata->chstat.sent_xmit >= devdata->chstat.got_xmit_done)
+   return devdata->chstat.sent_xmit -
+   devdata->chstat.got_xmit_done;
+   else
+   return (ULONG_MAX - devdata->chstat.got_xmit_done
+   + devdata->chstat.sent_xmit + 1);
+}
+
+/**
+ * vnic_hit_high_watermark
+ * @devdata: indicates visornic device we are checking
+ * @high_watermark: max num of unacked xmits we will tolerate,
+ *   before we will start throttling
+ *
+ *  Returns true iff the number of unacked xmits sent to
+ *  the IO partition is >= high_watermark.
+ */
+static inline bool vnic_hit_high_watermark(struct visornic_devdata *devdata,
+  ulong high_watermark)
+{
+   return (devdata_xmits_outstanding(devdata) >= high_watermark);
+}
+
+/**
+ * vnic_hit_low_watermark
+ * @devdata: indicates visornic device we are checking
+ * @low_watermark: we will wait until the num of unacked xmits
+ *  drops to this value or lower before we start
+ *  transmitting again
+ *
+ *  Returns true iff the number of unacked xmits sent to
+ *  the IO partition is <= low_watermark.
+ */
+static inline bool vnic_hit_low_watermark(struct visornic_devdata *devdata,
+ ulong low_watermark)
+{
+   return (devdata_xmits_outstanding(devdata) <= low_watermark);
+}
+
+/**
  * visornic_xmit - send a packet to the IO Partition
  * @skb: Packet to be sent
  * @netdev: net device the packet is being sent from
@@ -853,13 +901,8 @@ visornic_xmit(struct sk_buff *skb, struct net_device 
*netdev)
/* save the pointer to skb -- we'll need it for completion */
cmdrsp->net.buf = skb;
 
-   if (((devdata->chstat.sent_xmit >= devdata->chstat.got_xmit_done) &&
-(devdata->chstat.sent_xmit - devdata->chstat.got_xmit_done >=
-devdata->max_outstanding_net_xmits)) ||
-((devdata->chstat.sent_xmit < devdata->chstat.got_xmit_done) &&

[PATCH 5/7] staging: unisys: visornic - check visorchannel_signalinsert/remove failures

2015-07-24 Thread Benjamin Romer
From: Tim Sell 

Logic to check for failures of visorchannel_signalinsert() and
visorchannel_signalremove() were added, and a new sent_post_failed counter
tracks the number of times we failed to post a rcv buffer to the IO
partition.

Signed-off-by: Tim Sell 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visornic/visornic_main.c | 21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index 7541c49..baa137e 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -102,6 +102,7 @@ struct chanstat {
unsigned long sent_enbdis;
unsigned long sent_promisc;
unsigned long sent_post;
+   unsigned long sent_post_failed;
unsigned long sent_xmit;
unsigned long reject_count;
unsigned long extra_rcvbufs_sent;
@@ -478,11 +479,14 @@ post_skb(struct uiscmdrsp *cmdrsp,
if ((cmdrsp->net.rcvpost.frag.pi_off + skb->len) <= PI_PAGE_SIZE) {
cmdrsp->net.type = NET_RCV_POST;
cmdrsp->cmdtype = CMD_NET_TYPE;
-   visorchannel_signalinsert(devdata->dev->visorchannel,
+   if (visorchannel_signalinsert(devdata->dev->visorchannel,
  IOCHAN_TO_IOPART,
- cmdrsp);
-   atomic_inc(&devdata->num_rcvbuf_in_iovm);
-   devdata->chstat.sent_post++;
+ cmdrsp)) {
+   atomic_inc(&devdata->num_rcvbuf_in_iovm);
+   devdata->chstat.sent_post++;
+   } else {
+   devdata->chstat.sent_post_failed++;
+   }
}
 }
 
@@ -504,10 +508,10 @@ send_enbdis(struct net_device *netdev, int state,
devdata->cmdrsp_rcv->net.enbdis.context = netdev;
devdata->cmdrsp_rcv->net.type = NET_RCV_ENBDIS;
devdata->cmdrsp_rcv->cmdtype = CMD_NET_TYPE;
-   visorchannel_signalinsert(devdata->dev->visorchannel,
+   if (visorchannel_signalinsert(devdata->dev->visorchannel,
  IOCHAN_TO_IOPART,
- devdata->cmdrsp_rcv);
-   devdata->chstat.sent_enbdis++;
+ devdata->cmdrsp_rcv))
+   devdata->chstat.sent_enbdis++;
 }
 
 /**
@@ -1490,6 +1494,9 @@ static ssize_t info_debugfs_read(struct file *file, char 
__user *buf,
 " chstat.sent_post = %lu\n",
 devdata->chstat.sent_post);
str_pos += scnprintf(vbuf + str_pos, len - str_pos,
+" chstat.sent_post_failed = %lu\n",
+devdata->chstat.sent_post_failed);
+   str_pos += scnprintf(vbuf + str_pos, len - str_pos,
 " chstat.sent_xmit = %lu\n",
 devdata->chstat.sent_xmit);
str_pos += scnprintf(vbuf + str_pos, len - str_pos,
-- 
2.1.4

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


[PATCH v2] staging: unisys: Add s-Par visorhba

2015-07-24 Thread Benjamin Romer
From: David Kershner 

This driver create a host bus adapter device when s-Par sends a
device create message to create a storage adapter on the visorbus.
When the message is received by visorbus, the visorhba_probe function
is called and the hba device is created and managed by the visorhba
driver.

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
Signed-off-by: David Kershner 

---

v2:
* address comments from Greg, Jes, Dan, and David Milburn
---
 drivers/staging/unisys/Kconfig  |1 +
 drivers/staging/unisys/Makefile |1 +
 drivers/staging/unisys/include/iochannel.h  |   26 +-
 drivers/staging/unisys/visorhba/Kconfig |   14 +
 drivers/staging/unisys/visorhba/Makefile|   10 +
 drivers/staging/unisys/visorhba/visorhba_main.c | 1241 +++
 6 files changed, 1280 insertions(+), 13 deletions(-)
 create mode 100644 drivers/staging/unisys/visorhba/Kconfig
 create mode 100644 drivers/staging/unisys/visorhba/Makefile
 create mode 100644 drivers/staging/unisys/visorhba/visorhba_main.c

diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig
index ca850a8..5cbb791 100644
--- a/drivers/staging/unisys/Kconfig
+++ b/drivers/staging/unisys/Kconfig
@@ -14,5 +14,6 @@ if UNISYSSPAR
 source "drivers/staging/unisys/visorbus/Kconfig"
 source "drivers/staging/unisys/visornic/Kconfig"
 source "drivers/staging/unisys/visorhid/Kconfig"
+source "drivers/staging/unisys/visorhba/Kconfig"
 
 endif # UNISYSSPAR
diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile
index d071094..79c9036 100644
--- a/drivers/staging/unisys/Makefile
+++ b/drivers/staging/unisys/Makefile
@@ -4,3 +4,4 @@
 obj-$(CONFIG_UNISYS_VISORBUS)  += visorbus/
 obj-$(CONFIG_UNISYS_VISORNIC)  += visornic/
 obj-$(CONFIG_UNISYS_VISORHID)  += visorhid/
+obj-$(CONFIG_UNISYS_VISORHBA)  += visorhba/
diff --git a/drivers/staging/unisys/include/iochannel.h 
b/drivers/staging/unisys/include/iochannel.h
index a559812..14e656f 100644
--- a/drivers/staging/unisys/include/iochannel.h
+++ b/drivers/staging/unisys/include/iochannel.h
@@ -147,6 +147,10 @@ struct phys_info {
u16 pi_len;
 } __packed;
 
+#define MIN_NUMSIGNALS 64
+
+/* structs with pragma pack  */
+
 struct guest_phys_info {
u64 address;
u64 length;
@@ -183,7 +187,7 @@ struct vhba_config_max {/* 20 bytes */
 } __packed;
 
 struct uiscmdrsp_scsi {
-   void *scsicmd;  /* the handle to the cmd that was received -
+   u64 handle; /* the handle to the cmd that was received -
 * send it back as is in the rsp packet.  */
u8 cmnd[MAX_CMND_SIZE]; /* the cdb for the command */
u32 bufflen;/* length of data to be transferred out or in */
@@ -437,24 +441,22 @@ struct uiscmdrsp_scsitaskmgmt {
struct uisscsi_dest vdest;
 
/* the vdisk for which this task mgmt is generated */
-   void *scsicmd;
+   u64 handle;
 
-   /* This is some handle that the guest has saved off for its own use.
+   /* This is a handle that the guest has saved off for its own use.
 * Its value is preserved by iopart & returned as is in the task
 * mgmt rsp.
 */
-   void *notify;
+   u64 notify_handle;
 
   /* For linux guests, this is a pointer to wait_queue_head that a
* thread is waiting on to see if the taskmgmt command has completed.
-   * For windows guests, this is a pointer to a location that a waiting
-   * thread is testing to see if the taskmgmt command has completed.
* When the rsp is received by guest, the thread receiving the
* response uses this to notify the thread waiting for taskmgmt
* command completion.  Its value is preserved by iopart & returned
* as is in the task mgmt rsp.
*/
-   void *notifyresult;
+   u64 notifyresult_handle;
 
/* this is a handle to location in guest where the result of the
 * taskmgmt command (result field) is to saved off when the response
@@ -486,24 +488,22 @@ struct uiscmdrsp_vdiskmgmt {
struct uisscsi_dest vdest;
 
/* the vdisk for which this task mgmt is generated */
-   void *scsicmd;
+   u64 handle;
 
-   /* This is some handle that the guest has saved off for its own use.
+   /* This is a handle that the guest has saved off for its own use.
 * Its value is preserved by iopart & returned as is in the task
 * mgmt rsp.
 */
-   void *notify;
+   u64 notify_handle;
 
/* For linux guests, this is a pointer to wait_queue_head that a
 * thread is waiting on to see if the tskmgmt command has completed.
-* For win32 guests, this is a pointer to a location that a waiting
-* thread is testing to see 

[PATCH 1/7] staging: unisys: visornic: fix serialization mechanism around usage atomic

2015-07-24 Thread Benjamin Romer
From: Neil Horman 

Missed this in my initial review.  The usage counter that guards against
kthread task is horribly racy.  The atomic is self consistent, but theres
nothing that prevents the service_resp_queue function from re-incrementing
it immediately after the check in disable_with_timeout is complete.  Its
just a improper usage of atomics as a serialization mechanism.

Instead use kthread_park to pause the thread in its activity so that
buffers can be properly freed without racing against usage in
service_resp_queue

Signed-off-by: Neil Horman 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visornic/visornic_main.c | 23 ++-
 kernel/kthread.c|  4 
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index 4d49937..aeecb14 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -126,7 +126,6 @@ struct visornic_devdata {
unsigned short old_flags;   /* flags as they were prior to
 * set_multicast_list
 */
-   atomic_t usage; /* count of users */
int num_rcv_bufs;   /* indicates how many rcv buffers
 * the vnic will post
 */
@@ -565,19 +564,7 @@ visornic_disable_with_timeout(struct net_device *netdev, 
const int timeout)
spin_lock_irqsave(&devdata->priv_lock, flags);
}
 
-   /* Wait for usage to go to 1 (no other users) before freeing
-* rcv buffers
-*/
-   if (atomic_read(&devdata->usage) > 1) {
-   while (1) {
-   set_current_state(TASK_INTERRUPTIBLE);
-   spin_unlock_irqrestore(&devdata->priv_lock, flags);
-   schedule_timeout(msecs_to_jiffies(10));
-   spin_lock_irqsave(&devdata->priv_lock, flags);
-   if (atomic_read(&devdata->usage))
-   break;
-   }
-   }
+   kthread_park(devdata->threadinfo.task);
 
/* we've set enabled to 0, so we can give up the lock. */
spin_unlock_irqrestore(&devdata->priv_lock, flags);
@@ -594,6 +581,7 @@ visornic_disable_with_timeout(struct net_device *netdev, 
const int timeout)
}
}
 
+   kthread_unpark(devdata->threadinfo.task);
return 0;
 }
 
@@ -1622,7 +1610,7 @@ send_rcv_posts_if_needed(struct visornic_devdata *devdata)
  * Returns when response queue is empty or when the threadd stops.
  */
 static void
-drain_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata)
+service_resp_queue(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata)
 {
unsigned long flags;
struct net_device *netdev;
@@ -1742,6 +1730,8 @@ process_incoming_rsps(void *v)
devdata->rsp_queue, (atomic_read(
 &devdata->interrupt_rcvd) == 1),
msecs_to_jiffies(devdata->thread_wait_ms));
+   if (kthread_should_park())
+   kthread_parkme();
 
/* periodically check to see if there are any rcf bufs which
 * need to get sent to the IOSP. This can only happen if
@@ -1749,7 +1739,7 @@ process_incoming_rsps(void *v)
 */
atomic_set(&devdata->interrupt_rcvd, 0);
send_rcv_posts_if_needed(devdata);
-   drain_queue(cmdrsp, devdata);
+   service_resp_queue(cmdrsp, devdata);
}
 
kfree(cmdrsp);
@@ -1809,7 +1799,6 @@ static int visornic_probe(struct visor_device *dev)
init_waitqueue_head(&devdata->rsp_queue);
spin_lock_init(&devdata->priv_lock);
devdata->enabled = 0; /* not yet */
-   atomic_set(&devdata->usage, 1);
 
/* Setup rcv bufs */
channel_offset = offsetof(struct spar_io_channel_protocol,
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 10e489c..bad80c1 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -97,6 +97,7 @@ bool kthread_should_park(void)
 {
return test_bit(KTHREAD_SHOULD_PARK, &to_kthread(current)->flags);
 }
+EXPORT_SYMBOL(kthread_should_park);
 
 /**
  * kthread_freezable_should_stop - should this freezable kthread return now?
@@ -171,6 +172,7 @@ void kthread_parkme(void)
 {
__kthread_parkme(to_kthread(current));
 }
+EXPORT_SYMBOL(kthread_parkme);
 
 static int kthread(void *_create)
 {
@@ -411,6 +413,7 @@ void kthread_unpark(struct task_struct *k)
if (kthread)
__kthread_unpark(k, kthread);
 }
+EXPORT_SYMBOL(kthread_unpark);
 
 /**
  * kthread_park - park a thread created by kthread_create().
@@ -441,6 +444,7 @@ int kthread_p

[PATCH 7/7] staging: unisys: visornic - prevent NETDEV WATCHDOG timeouts after IO recovery

2015-07-24 Thread Benjamin Romer
From: Tim Sell 

After IO partition recovery, it was possible to get into a situation where
a visornic device would repeatedly report:

NETDEV WATCHDOG: eth0 (): transmit queue 0 timed out

The actual problem would affect any visornic device that was rapidly
transmitting at the same time the IO partition was being recovered. Once
you hit the problem, the only way to resume use of the nic would be to
reboot the Linux client partition.

The problem was caused by chstat.sent_xmit and chstat.got_xmit_done NOT
getting cleared during IO partition recovery. This is necessary because
outstanding xmits would essentially be "abandoned" during such recovery.
These fields are now cleared in virtnic_serverdown_complete().

Signed-off-by: Tim Sell 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visornic/visornic_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index bd58e15..4b5fc07 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -380,6 +380,8 @@ visornic_serverdown_complete(struct visornic_devdata 
*devdata)
rtnl_unlock();
 
atomic_set(&devdata->num_rcvbuf_in_iovm, 0);
+   devdata->chstat.sent_xmit = 0;
+   devdata->chstat.got_xmit_done = 0;
 
if (devdata->server_down_complete_func)
(*devdata->server_down_complete_func)(devdata->dev, 0);
-- 
2.1.4

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


[PATCH 4/7] staging: unisys: visornic - ensure proper net locking in tx reset logic

2015-07-24 Thread Benjamin Romer
From: Tim Sell 

visornic tx reset handling is done asynchronously via a workqueue in
visornic_timeout_reset().  As a result, it needs to use rtnl_lock() /
rtnl_unlock() to lock against possible simultaneous close() of the network
device.

(I consulted the bnx2 driver as a model here, as that driver also does
its tx reset handling asynchronously, just like visornic does.  See
bnx2_tx_timeout() and bnx2_reset_task().)

Signed-off-by: Tim Sell 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visornic/visornic_main.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index 8d600fa..7541c49 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -719,6 +719,12 @@ visornic_timeout_reset(struct work_struct *work)
devdata = container_of(work, struct visornic_devdata, timeout_reset);
netdev = devdata->netdev;
 
+   rtnl_lock();
+   if (!netif_running(netdev)) {
+   rtnl_unlock();
+   return;
+   }
+
response = visornic_disable_with_timeout(netdev,
 VISORNIC_INFINITE_RSP_WAIT);
if (response)
@@ -729,10 +735,13 @@ visornic_timeout_reset(struct work_struct *work)
if (response)
goto call_serverdown;
 
+   rtnl_unlock();
+
return;
 
 call_serverdown:
visornic_serverdown(devdata, NULL);
+   rtnl_unlock();
 }
 
 /**
-- 
2.1.4

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


[PATCH 0/7] staging: unisys: visornic testing fix series

2015-07-24 Thread Benjamin Romer
This patch series fixes more technical issues and bugs found in visornic
testing.

David Kershner (1):
  staging: unisys: Process more than one response per check

Neil Horman (1):
  staging: unisys: visornic: fix serialization mechanism around usage
atomic

Tim Sell (5):
  staging: unisys: add simple error-check into visornic receive path
  staging: unisys: visornic - ensure proper net locking in tx reset
logic
  staging: unisys: visornic - check visorchannel_signalinsert/remove
failures
  staging: unisys: visornic - consolidate+simplify xmit watermark checks
  staging: unisys: visornic - prevent NETDEV WATCHDOG timeouts after IO
recovery

 drivers/staging/unisys/visornic/visornic_main.c | 314 ++--
 kernel/kthread.c|   4 +
 2 files changed, 182 insertions(+), 136 deletions(-)

-- 
2.1.4

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


[PATCH 3/7] staging: unisys: Process more than one response per check

2015-07-24 Thread Benjamin Romer
From: David Kershner 

When s-Par is in polling mode it checks every 2 ms to see if there is
a response from the IO service partition in the queue. Currently it
just reads one entry per 2 ms, this needs to be changed so it drains
the queue on each check.

Signed-off-by: David Kershner 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visornic/visornic_main.c | 164 
 1 file changed, 83 insertions(+), 81 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index 6ce3fc2..8d600fa 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -1617,93 +1617,95 @@ service_resp_queue(struct uiscmdrsp *cmdrsp, struct 
visornic_devdata *devdata)
 
/* TODO: CLIENT ACQUIRE -- Don't really need this at the
 * moment */
-   if (!visorchannel_signalremove(devdata->dev->visorchannel,
-  IOCHAN_FROM_IOPART,
-  cmdrsp))
-   return; /* queue empty */
-
-   switch (cmdrsp->net.type) {
-   case NET_RCV:
-   devdata->chstat.got_rcv++;
-   /* process incoming packet */
-   visornic_rx(cmdrsp);
-   break;
-   case NET_XMIT_DONE:
-   spin_lock_irqsave(&devdata->priv_lock, flags);
-   devdata->chstat.got_xmit_done++;
-   if (cmdrsp->net.xmtdone.xmt_done_result)
-   devdata->chstat.xmit_fail++;
-   /* only call queue wake if we stopped it */
-   netdev = ((struct sk_buff *)cmdrsp->net.buf)->dev;
-   /* ASSERT netdev == vnicinfo->netdev; */
-   if ((netdev == devdata->netdev) &&
-   netif_queue_stopped(netdev)) {
-   /* check to see if we have crossed
-* the lower watermark for
-* netif_wake_queue()
-*/
-   if (((devdata->chstat.sent_xmit >=
-   devdata->chstat.got_xmit_done) &&
-   (devdata->chstat.sent_xmit -
-   devdata->chstat.got_xmit_done <=
-   devdata->lower_threshold_net_xmits)) ||
-   ((devdata->chstat.sent_xmit <
-   devdata->chstat.got_xmit_done) &&
-   (ULONG_MAX - devdata->chstat.got_xmit_done
-   + devdata->chstat.sent_xmit <=
-   devdata->lower_threshold_net_xmits))) {
-   /* enough NET_XMITs completed
-* so can restart netif queue
+   for (;;) {
+   if (!visorchannel_signalremove(devdata->dev->visorchannel,
+  IOCHAN_FROM_IOPART,
+  cmdrsp))
+   break; /* queue empty */
+
+   switch (cmdrsp->net.type) {
+   case NET_RCV:
+   devdata->chstat.got_rcv++;
+   /* process incoming packet */
+   visornic_rx(cmdrsp);
+   break;
+   case NET_XMIT_DONE:
+   spin_lock_irqsave(&devdata->priv_lock, flags);
+   devdata->chstat.got_xmit_done++;
+   if (cmdrsp->net.xmtdone.xmt_done_result)
+   devdata->chstat.xmit_fail++;
+   /* only call queue wake if we stopped it */
+   netdev = ((struct sk_buff *)cmdrsp->net.buf)->dev;
+   /* ASSERT netdev == vnicinfo->netdev; */
+   if ((netdev == devdata->netdev) &&
+   netif_queue_stopped(netdev)) {
+   /* check to see if we have crossed
+* the lower watermark for
+* netif_wake_queue()
 */
-   netif_wake_queue(netdev);
-   devdata->flow_control_lower_hits++;
+   if (((devdata->chstat.sent_xmit >=
+   devdata->chstat.got_xmit_done) &&
+   (devdata->chstat.sent_xmit -
+   devdata->chstat.got_xmit_done <=
+   devdata->lower_threshold_net_xmits)) ||
+   ((devdata->chstat.sent_xmit <
+   devdata->chstat.got_xmit_done) &&
+   (ULONG_MAX - devdata->chstat.got_xmit_done
+   + devdata->chstat.sent_xmit <=
+   devdata->lower_threshold_net_xmits))) {
+  

[PATCH net-next] hv_netvsc: Add structs and handlers for VF messages

2015-07-24 Thread Haiyang Zhang
This patch adds data structures and handlers for messages related
to SRIOV Virtual Function.

Signed-off-by: Haiyang Zhang 
Reviewed-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/hyperv_net.h |   29 ++
 drivers/net/hyperv/netvsc.c |   43 +-
 2 files changed, 62 insertions(+), 10 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 26cd14c..f225d1f 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -541,6 +541,29 @@ union nvsp_2_message_uber {
struct nvsp_2_free_rxbuf free_rxbuf;
 } __packed;
 
+struct nvsp_4_send_vf_association {
+   /* 1: allocated, serial number is valid. 0: not allocated */
+   u32 allocated;
+
+   /* Serial number of the VF to team with */
+   u32 serial;
+} __packed;
+
+enum nvsp_vm_datapath {
+   NVSP_DATAPATH_SYNTHETIC = 0,
+   NVSP_DATAPATH_VF,
+   NVSP_DATAPATH_MAX
+};
+
+struct nvsp_4_sw_datapath {
+   u32 active_datapath; /* active data path in VM */
+} __packed;
+
+union nvsp_4_message_uber {
+   struct nvsp_4_send_vf_association vf_assoc;
+   struct nvsp_4_sw_datapath active_dp;
+} __packed;
+
 enum nvsp_subchannel_operation {
NVSP_SUBCHANNEL_NONE = 0,
NVSP_SUBCHANNEL_ALLOCATE,
@@ -578,6 +601,7 @@ union nvsp_all_messages {
union nvsp_message_init_uber init_msg;
union nvsp_1_message_uber v1_msg;
union nvsp_2_message_uber v2_msg;
+   union nvsp_4_message_uber v4_msg;
union nvsp_5_message_uber v5_msg;
 } __packed;
 
@@ -689,6 +713,11 @@ struct netvsc_device {
 
/* The net device context */
struct net_device_context *nd_ctx;
+
+   /* 1: allocated, serial number is valid. 0: not allocated */
+   u32 vf_alloc;
+   /* Serial number of the VF to team with */
+   u32 vf_serial;
 };
 
 /* NdisInitialize message */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 23126a7..51e4c0f 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -453,13 +453,16 @@ static int negotiate_nvsp_ver(struct hv_device *device,
if (nvsp_ver == NVSP_PROTOCOL_VERSION_1)
return 0;
 
-   /* NVSPv2 only: Send NDIS config */
+   /* NVSPv2 or later: Send NDIS config */
memset(init_packet, 0, sizeof(struct nvsp_message));
init_packet->hdr.msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG;
init_packet->msg.v2_msg.send_ndis_config.mtu = net_device->ndev->mtu +
   ETH_HLEN;
init_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q = 1;
 
+   if (nvsp_ver >= NVSP_PROTOCOL_VERSION_5)
+   init_packet->msg.v2_msg.send_ndis_config.capability.sriov = 1;
+
ret = vmbus_sendpacket(device->channel, init_packet,
sizeof(struct nvsp_message),
(unsigned long)init_packet,
@@ -1064,11 +1067,10 @@ static void netvsc_receive(struct netvsc_device 
*net_device,
 
 
 static void netvsc_send_table(struct hv_device *hdev,
- struct vmpacket_descriptor *vmpkt)
+ struct nvsp_message *nvmsg)
 {
struct netvsc_device *nvscdev;
struct net_device *ndev;
-   struct nvsp_message *nvmsg;
int i;
u32 count, *tab;
 
@@ -1077,12 +1079,6 @@ static void netvsc_send_table(struct hv_device *hdev,
return;
ndev = nvscdev->ndev;
 
-   nvmsg = (struct nvsp_message *)((unsigned long)vmpkt +
-   (vmpkt->offset8 << 3));
-
-   if (nvmsg->hdr.msg_type != NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE)
-   return;
-
count = nvmsg->msg.v5_msg.send_table.count;
if (count != VRSS_SEND_TAB_SIZE) {
netdev_err(ndev, "Received wrong send-table size:%u\n", count);
@@ -1096,6 +1092,28 @@ static void netvsc_send_table(struct hv_device *hdev,
nvscdev->send_table[i] = tab[i];
 }
 
+static void netvsc_send_vf(struct netvsc_device *nvdev,
+  struct nvsp_message *nvmsg)
+{
+   nvdev->vf_alloc = nvmsg->msg.v4_msg.vf_assoc.allocated;
+   nvdev->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial;
+}
+
+static inline void netvsc_receive_inband(struct hv_device *hdev,
+struct netvsc_device *nvdev,
+struct nvsp_message *nvmsg)
+{
+   switch (nvmsg->hdr.msg_type) {
+   case NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE:
+   netvsc_send_table(hdev, nvmsg);
+   break;
+
+   case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION:
+   netvsc_send_vf(nvdev, nvmsg);
+   break;
+   }
+}
+
 void netvsc_channel_cb(void *context)
 {
int ret;
@@ -1108,6 +1126,7 @@ void netvsc_channel_cb(void *context)
unsigned char 

[PATCH RESEND] staging: rtl8188eu: don't duplicate ieee80211 WLAN_EID_* constants

2015-07-24 Thread Jakub Sitnicki
linux/ieee80211.h already defines constants for information element IDs.
Include it where needed, resolve discrepancies in naming, and remove the
duplicated definitions.

While at it, wrap a line that was too long and remove extra parentheses
in an expression that mixes only equality and logical operators.

Signed-off-by: Jakub Sitnicki 
---
 drivers/staging/rtl8188eu/core/rtw_ieee80211.c |  4 ++-
 drivers/staging/rtl8188eu/include/ieee80211.h  | 38 --
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c |  3 +-
 3 files changed, 5 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c 
b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
index 11b780d..c3c5828 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
@@ -19,6 +19,8 @@
  
**/
 #define _IEEE80211_C
 
+#include 
+
 #include 
 #include 
 #include 
@@ -1042,7 +1044,7 @@ enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint 
len,
elems->timeout_int = pos;
elems->timeout_int_len = elen;
break;
-   case WLAN_EID_HT_CAP:
+   case WLAN_EID_HT_CAPABILITY:
elems->ht_capabilities = pos;
elems->ht_capabilities_len = elen;
break;
diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h 
b/drivers/staging/rtl8188eu/include/ieee80211.h
index b129ad1..611877c 100644
--- a/drivers/staging/rtl8188eu/include/ieee80211.h
+++ b/drivers/staging/rtl8188eu/include/ieee80211.h
@@ -496,44 +496,6 @@ struct ieee80211_snap_hdr {
 /* Non standard?  Not in  */
 #define WLAN_REASON_EXPIRATION_CHK 65535
 
-/* Information Element IDs */
-#define WLAN_EID_SSID 0
-#define WLAN_EID_SUPP_RATES 1
-#define WLAN_EID_FH_PARAMS 2
-#define WLAN_EID_DS_PARAMS 3
-#define WLAN_EID_CF_PARAMS 4
-#define WLAN_EID_TIM 5
-#define WLAN_EID_IBSS_PARAMS 6
-#define WLAN_EID_CHALLENGE 16
-/* EIDs defined by IEEE 802.11h - START */
-#define WLAN_EID_PWR_CONSTRAINT 32
-#define WLAN_EID_PWR_CAPABILITY 33
-#define WLAN_EID_TPC_REQUEST 34
-#define WLAN_EID_TPC_REPORT 35
-#define WLAN_EID_SUPPORTED_CHANNELS 36
-#define WLAN_EID_CHANNEL_SWITCH 37
-#define WLAN_EID_MEASURE_REQUEST 38
-#define WLAN_EID_MEASURE_REPORT 39
-#define WLAN_EID_QUITE 40
-#define WLAN_EID_IBSS_DFS 41
-/* EIDs defined by IEEE 802.11h - END */
-#define WLAN_EID_ERP_INFO 42
-#define WLAN_EID_HT_CAP 45
-#define WLAN_EID_RSN 48
-#define WLAN_EID_EXT_SUPP_RATES 50
-#define WLAN_EID_MOBILITY_DOMAIN 54
-#define WLAN_EID_FAST_BSS_TRANSITION 55
-#define WLAN_EID_TIMEOUT_INTERVAL 56
-#define WLAN_EID_RIC_DATA 57
-#define WLAN_EID_HT_OPERATION 61
-#define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62
-#define WLAN_EID_20_40_BSS_COEXISTENCE 72
-#define WLAN_EID_20_40_BSS_INTOLERANT 73
-#define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
-#define WLAN_EID_MMIE 76
-#define WLAN_EID_VENDOR_SPECIFIC 221
-#define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC)
-
 #define IEEE80211_MGMT_HDR_LEN 24
 #define IEEE80211_DATA_HDR3_LEN 24
 #define IEEE80211_DATA_HDR4_LEN 30
diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 38dba14..dec089d 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -2666,7 +2666,8 @@ static int rtw_get_sta_wpaie(struct net_device *dev, 
struct ieee_param *param)
 
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
if (psta) {
-   if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == 
WLAN_EID_GENERIC)) {
+   if (psta->wpa_ie[0] == WLAN_EID_RSN ||
+   psta->wpa_ie[0] == WLAN_EID_VENDOR_SPECIFIC) {
int wpa_ie_len;
int copy_len;
 
-- 
2.1.0

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


[PATCH RESEND] staging: rtl8188eu: kill unused hal_data_8188e::fw_ractrl flag

2015-07-24 Thread Jakub Sitnicki
Flag is never set. Remove it and the code that is dead because of it.

Signed-off-by: Jakub Sitnicki 
---
 drivers/staging/rtl8188eu/hal/odm.c  | 11 --
 drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 21 --
 drivers/staging/rtl8188eu/hal/usb_halinit.c  | 27 ++--
 drivers/staging/rtl8188eu/include/rtl8188e_cmd.h |  1 -
 drivers/staging/rtl8188eu/include/rtl8188e_hal.h |  1 -
 drivers/staging/rtl8188eu/include/sta_info.h |  1 -
 6 files changed, 6 insertions(+), 56 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/odm.c 
b/drivers/staging/rtl8188eu/hal/odm.c
index 28b5e7b..710fdc3 100644
--- a/drivers/staging/rtl8188eu/hal/odm.c
+++ b/drivers/staging/rtl8188eu/hal/odm.c
@@ -1170,13 +1170,10 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct 
*pDM_Odm)
}
 
for (i = 0; i < sta_cnt; i++) {
-   if (PWDB_rssi[i] != (0)) {
-   if (pHalData->fw_ractrl) {
-   /*  Report every sta's RSSI to FW */
-   } else {
-   ODM_RA_SetRSSI_8188E(
-   &(pHalData->odmpriv), (PWDB_rssi[i]&0xFF), 
(u8)((PWDB_rssi[i]>>16) & 0xFF));
-   }
+   if (PWDB_rssi[i] != 0) {
+   ODM_RA_SetRSSI_8188E(&pHalData->odmpriv,
+PWDB_rssi[i] & 0xFF,
+(PWDB_rssi[i] >> 16) & 0xFF);
}
}
 
diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c 
b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
index 86347f2..0a62bfa 100644
--- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
+++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
@@ -127,27 +127,6 @@ exit:
return ret;
 }
 
-u8 rtl8188e_set_raid_cmd(struct adapter *adapt, u32 mask)
-{
-   u8 buf[3];
-   u8 res = _SUCCESS;
-   struct hal_data_8188e *haldata = GET_HAL_DATA(adapt);
-
-   if (haldata->fw_ractrl) {
-
-   memset(buf, 0, 3);
-   put_unaligned_le32(mask, buf);
-
-   FillH2CCmd_88E(adapt, H2C_DM_MACID_CFG, 3, buf);
-   } else {
-   DBG_88E("==>%s fw dont support RA\n", __func__);
-   res = _FAIL;
-   }
-
-
-   return res;
-}
-
 /* bitmap[0:27] = tx_rate_bitmap */
 /* bitmap[28:31]= Rate Adaptive id */
 /* arg[0:4] = macid */
diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c 
b/drivers/staging/rtl8188eu/hal/usb_halinit.c
index 8726222..bdbc78f 100644
--- a/drivers/staging/rtl8188eu/hal/usb_halinit.c
+++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c
@@ -743,19 +743,16 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter)
if (Adapter->registrypriv.mp_mode == 1) {
_InitRxSetting(Adapter);
Adapter->bFWReady = false;
-   haldata->fw_ractrl = false;
} else {
status = rtl88eu_download_fw(Adapter);
 
if (status) {
DBG_88E("%s: Download Firmware failed!!\n", __func__);
Adapter->bFWReady = false;
-   haldata->fw_ractrl = false;
return status;
} else {
RT_TRACE(_module_hci_hal_init_c_, _drv_info_, 
("Initializeadapt8192CSdio(): Download Firmware Success!!\n"));
Adapter->bFWReady = true;
-   haldata->fw_ractrl = false;
}
}
rtl8188e_InitializeFirmwareVars(Adapter);
@@ -2085,28 +2082,9 @@ static void UpdateHalRAMask8188EUsb(struct adapter 
*adapt, u32 mac_id, u8 rssi_l
 
init_rate = get_highest_rate_idx(mask)&0x3f;
 
-   if (haldata->fw_ractrl) {
-   u8 arg;
+   ODM_RA_UpdateRateInfo_8188E(&haldata->odmpriv, mac_id,
+   raid, mask, shortGIrate);
 
-   arg = mac_id & 0x1f;/* MACID */
-   arg |= BIT(7);
-   if (shortGIrate)
-   arg |= BIT(5);
-   mask |= ((raid << 28) & 0xf000);
-   DBG_88E("update raid entry, mask=0x%x, arg=0x%x\n", mask, arg);
-   psta->ra_mask = mask;
-   mask |= ((raid << 28) & 0xf000);
-
-   /* to do ,for 8188E-SMIC */
-   rtl8188e_set_raid_cmd(adapt, mask);
-   } else {
-   ODM_RA_UpdateRateInfo_8188E(&(haldata->odmpriv),
-   mac_id,
-   raid,
-   mask,
-   shortGIrate
-   );
-   }
/* set ra_id */
psta->raid = raid;
psta->init_rate = init_rate;
@@ -2156,7 +2134,6 @@ static void rtl8188eu_init_default_value(struct adapter 
*adapt)
pwrctrlpriv = &adapt->pwrctrlpriv;
 
/* init default value */
-   haldata->fw_ractrl = false;
  

[PATCH 6/9] Staging: most: add MOST driver's hdm-dim2 module

2015-07-24 Thread Christian Gromm
This patch adds the hdm-dim2 module of the MOST driver to the kernel's
driver staging area. This module is part of the MOST driver and handles
the MediaLB interface of the MOST network interface controller.

This patch is needed in order to use the MediaLB peripheral interface of
the network interface controller.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig|2 +
 drivers/staging/most/Makefile   |1 +
 drivers/staging/most/hdm-dim2/Kconfig   |   15 +
 drivers/staging/most/hdm-dim2/Makefile  |5 +
 drivers/staging/most/hdm-dim2/dim2_errors.h |   67 ++
 drivers/staging/most/hdm-dim2/dim2_hal.c|  919 +
 drivers/staging/most/hdm-dim2/dim2_hal.h|  124 
 drivers/staging/most/hdm-dim2/dim2_hdm.c|  964 +++
 drivers/staging/most/hdm-dim2/dim2_hdm.h|   26 +
 drivers/staging/most/hdm-dim2/dim2_reg.h|  176 +
 drivers/staging/most/hdm-dim2/dim2_sysfs.c  |  116 
 drivers/staging/most/hdm-dim2/dim2_sysfs.h  |   39 ++
 12 files changed, 2454 insertions(+)
 create mode 100644 drivers/staging/most/hdm-dim2/Kconfig
 create mode 100644 drivers/staging/most/hdm-dim2/Makefile
 create mode 100644 drivers/staging/most/hdm-dim2/dim2_errors.h
 create mode 100644 drivers/staging/most/hdm-dim2/dim2_hal.c
 create mode 100644 drivers/staging/most/hdm-dim2/dim2_hal.h
 create mode 100644 drivers/staging/most/hdm-dim2/dim2_hdm.c
 create mode 100644 drivers/staging/most/hdm-dim2/dim2_hdm.h
 create mode 100644 drivers/staging/most/hdm-dim2/dim2_reg.h
 create mode 100644 drivers/staging/most/hdm-dim2/dim2_sysfs.c
 create mode 100644 drivers/staging/most/hdm-dim2/dim2_sysfs.h

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 4582918..659c402 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -21,4 +21,6 @@ source "drivers/staging/most/aim-sound/Kconfig"
 
 source "drivers/staging/most/aim-v4l2/Kconfig"
 
+source "drivers/staging/most/hdm-dim2/Kconfig"
+
 endif
diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
index 6e319c4..7c68b3b 100644
--- a/drivers/staging/most/Makefile
+++ b/drivers/staging/most/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_AIM_CDEV)  += aim-cdev/
 obj-$(CONFIG_AIM_NETWORK)  += aim-network/
 obj-$(CONFIG_AIM_SOUND)+= aim-sound/
 obj-$(CONFIG_AIM_V4L2) += aim-v4l2/
+obj-$(CONFIG_HDM_DIM2) += hdm-dim2/
diff --git a/drivers/staging/most/hdm-dim2/Kconfig 
b/drivers/staging/most/hdm-dim2/Kconfig
new file mode 100644
index 000..4abeb54
--- /dev/null
+++ b/drivers/staging/most/hdm-dim2/Kconfig
@@ -0,0 +1,15 @@
+#
+# MediaLB configuration
+#
+
+config HDM_DIM2
+   tristate "DIM2 HDM"
+
+   ---help---
+ Say Y here if you want to connect via MediaLB to network tranceiver.
+ This device driver is platform dependent and needs an addtional
+ platform driver to be installed. For more information contact
+ maintainer of this driver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called hdm_dim2.
diff --git a/drivers/staging/most/hdm-dim2/Makefile 
b/drivers/staging/most/hdm-dim2/Makefile
new file mode 100644
index 000..6bbee87
--- /dev/null
+++ b/drivers/staging/most/hdm-dim2/Makefile
@@ -0,0 +1,5 @@
+obj-$(CONFIG_HDM_DIM2) += hdm_dim2.o
+
+hdm_dim2-objs := dim2_hdm.o dim2_hal.o dim2_sysfs.o
+ccflags-y += -Idrivers/staging/most/mostcore/
+ccflags-y += -Idrivers/staging/most/aim-network/
diff --git a/drivers/staging/most/hdm-dim2/dim2_errors.h 
b/drivers/staging/most/hdm-dim2/dim2_errors.h
new file mode 100644
index 000..314f7de
--- /dev/null
+++ b/drivers/staging/most/hdm-dim2/dim2_errors.h
@@ -0,0 +1,67 @@
+/*
+ * dim2_errors.h - Definitions of errors for DIM2 HAL API
+ * (MediaLB, Device Interface Macro IP, OS62420)
+ *
+ * Copyright (C) 2015, Microchip Technology Germany II GmbH & Co. KG
+ *
+ * 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.
+ *
+ * This file is licensed under GPLv2.
+ */
+
+#ifndef _MOST_DIM_ERRORS_H
+#define _MOST_DIM_ERRORS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * MOST DIM errors.
+ */
+enum dim_errors_t {
+   /** Not an error */
+   DIM_NO_ERROR = 0,
+
+   /** Bad base address for DIM2 IP */
+   DIM_INIT_ERR_DIM_ADDR = 0x10,
+
+   /**< Bad MediaLB clock */
+   DIM_INIT_ERR_MLB_CLOCK,
+
+   /** Bad channel address */
+   DIM_INIT_ERR_CHANNEL_ADDRESS,
+
+   /** Out of DBR memory */
+   DIM_INIT_ERR_OUT_OF_MEMORY,
+
+   /** DIM API is called while DIM is not initialized successfully */
+   DIM_ERR_DRIVER_NOT_INITIALIZED = 0x20,
+
+   /**
+* Configuration does not respect hardware limitations
+* for isochronous 

[PATCH 8/9] Staging: most: add MOST driver's hdm-usb module

2015-07-24 Thread Christian Gromm
This patch adds the hdm-usb module of the MOST driver to the kernel's
driver staging area. This module is part of the MOST driver and handles
the USB interface of the MOST network interface controller.

This patch is needed in order to use the USB peripheral interface of the
network interface controller.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig   |2 +
 drivers/staging/most/Makefile  |1 +
 drivers/staging/most/hdm-usb/Kconfig   |   14 +
 drivers/staging/most/hdm-usb/Makefile  |4 +
 drivers/staging/most/hdm-usb/hdm_usb.c | 1442 
 5 files changed, 1463 insertions(+)
 create mode 100644 drivers/staging/most/hdm-usb/Kconfig
 create mode 100644 drivers/staging/most/hdm-usb/Makefile
 create mode 100644 drivers/staging/most/hdm-usb/hdm_usb.c

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 2a9f926..d50de03 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -25,4 +25,6 @@ source "drivers/staging/most/hdm-dim2/Kconfig"
 
 source "drivers/staging/most/hdm-i2c/Kconfig"
 
+source "drivers/staging/most/hdm-usb/Kconfig"
+
 endif
diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
index 5056f2c..9ee981c 100644
--- a/drivers/staging/most/Makefile
+++ b/drivers/staging/most/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_AIM_SOUND) += aim-sound/
 obj-$(CONFIG_AIM_V4L2) += aim-v4l2/
 obj-$(CONFIG_HDM_DIM2) += hdm-dim2/
 obj-$(CONFIG_HDM_I2C)  += hdm-i2c/
+obj-$(CONFIG_HDM_USB)  += hdm-usb/
diff --git a/drivers/staging/most/hdm-usb/Kconfig 
b/drivers/staging/most/hdm-usb/Kconfig
new file mode 100644
index 000..a482c3f
--- /dev/null
+++ b/drivers/staging/most/hdm-usb/Kconfig
@@ -0,0 +1,14 @@
+#
+# MOST USB configuration
+#
+
+config HDM_USB
+   tristate "USB HDM"
+   depends on USB
+   select AIM_NETWORK
+   ---help---
+ Say Y here if you want to connect via USB to network tranceiver.
+ This device driver depends on the networking AIM.
+
+ To compile this driver as a module, choose M here: the
+ module will be called hdm_usb.
diff --git a/drivers/staging/most/hdm-usb/Makefile 
b/drivers/staging/most/hdm-usb/Makefile
new file mode 100644
index 000..6bbacb4
--- /dev/null
+++ b/drivers/staging/most/hdm-usb/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_HDM_USB) += hdm_usb.o
+
+ccflags-y += -Idrivers/staging/most/mostcore/
+ccflags-y += -Idrivers/staging/most/aim-network/
diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/hdm-usb/hdm_usb.c
new file mode 100644
index 000..a4a3e26
--- /dev/null
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -0,0 +1,1442 @@
+/*
+ * hdm_usb.c - Hardware dependent module for USB
+ *
+ * Copyright (C) 2013-2015 Microchip Technology Germany II GmbH & Co. KG
+ *
+ * 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.
+ *
+ * This file is licensed under GPLv2.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mostcore.h"
+#include "networking.h"
+
+#define USB_MTU512
+#define NO_ISOCHRONOUS_URB 0
+#define AV_PACKETS_PER_XACT2
+#define BUF_CHAIN_SIZE 0x
+#define MAX_NUM_ENDPOINTS  30
+#define MAX_SUFFIX_LEN 10
+#define MAX_STRING_LEN 80
+#define MAX_BUF_SIZE   0x
+#define CEILING(x, y)  (((x) + (y) - 1) / (y))
+
+#define USB_VENDOR_ID_SMSC 0x0424  /* VID: SMSC */
+#define USB_DEV_ID_BRDG0xC001  /* PID: USB Bridge */
+#define USB_DEV_ID_INIC0xCF18  /* PID: USB INIC */
+/* DRCI Addresses */
+#define DRCI_REG_NI_STATE  0x0100
+#define DRCI_REG_PACKET_BW 0x0101
+#define DRCI_REG_NODE_ADDR 0x0102
+#define DRCI_REG_NODE_POS  0x0103
+#define DRCI_REG_MEP_FILTER0x0140
+#define DRCI_REG_HASH_TBL0 0x0141
+#define DRCI_REG_HASH_TBL1 0x0142
+#define DRCI_REG_HASH_TBL2 0x0143
+#define DRCI_REG_HASH_TBL3 0x0144
+#define DRCI_REG_HW_ADDR_HI0x0145
+#define DRCI_REG_HW_ADDR_MI0x0146
+#define DRCI_REG_HW_ADDR_LO0x0147
+#define DRCI_READ_REQ  0xA0
+#define DRCI_WRITE_REQ 0xA1
+
+/**
+ * struct buf_anchor - used to create a list of pending URBs
+ * @urb: pointer to USB request block
+ * @clear_work_obj:
+ * @list: linked list
+ * @urb_completion:
+ */
+struct buf_anchor {
+   struct urb *urb;
+   struct work_struct clear_work_obj;
+   struct list_head list;
+   struct completion urb_compl;
+};
+#define to_buf_anchor(w) container_of(w, struct buf_anchor, clear_work_obj)
+
+/**
+ * struct most_dci_obj - Direct Com

[PATCH 9/9] Staging: most: add MOST driver's documentation

2015-07-24 Thread Christian Gromm
This patch adds the documentation to the MOST driver that describes its ABI
interface and the basic usage.

Signed-off-by: Christian Gromm 
---
 .../most/Documentation/ABI/sysfs-class-most.txt|  181 
 .../staging/most/Documentation/driver_usage.txt|  180 +++
 2 files changed, 361 insertions(+)
 create mode 100644 drivers/staging/most/Documentation/ABI/sysfs-class-most.txt
 create mode 100644 drivers/staging/most/Documentation/driver_usage.txt

diff --git a/drivers/staging/most/Documentation/ABI/sysfs-class-most.txt 
b/drivers/staging/most/Documentation/ABI/sysfs-class-most.txt
new file mode 100644
index 000..380c137
--- /dev/null
+++ b/drivers/staging/most/Documentation/ABI/sysfs-class-most.txt
@@ -0,0 +1,181 @@
+What:  /sys/class/most/mostcore/aims
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   List of AIMs that have been loaded.
+Users:
+
+What:  /sys/class/most/mostcore/aims//add_link
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   This is used to establish a connection of a channel and the
+   current AIM.
+Users:
+
+What:  /sys/class/most/mostcore/aims//remove_link
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   This is used to remove a connected channel from the
+   current AIM.
+Users:
+
+What:  /sys/class/most/mostcore/devices
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   List of attached MOST interfaces.
+Users:
+
+What:  /sys/class/most/mostcore/devices//description
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   Provides information about the interface type and the physical
+   location of the device. Hardware attached via USB, for instance,
+   might return 
+Users:
+
+What:  /sys/class/most/mostcore/devices//interface
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   Indicates the type of peripherial interface the current device
+   uses.
+Users:
+
+What:  /sys/class/most/mostcore/devices///
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   For every channel of the device a directory is created, whose
+   name is dictated by the HDM. This enables an application to
+   collect information about the channel's capabilities and
+   configure it.
+Users:
+
+What:  
/sys/class/most/mostcore/devices///available_datatypes
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   Indicates the data types the current channel can transport.
+Users:
+
+What:  
/sys/class/most/mostcore/devices///available_directions
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   Indicates the directions the current channel is capable of.
+Users:
+
+What:  
/sys/class/most/mostcore/devices///number_of_packet_buffers
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   Indicates the number of packet buffers the current channel can
+   handle.
+Users:
+
+What:  
/sys/class/most/mostcore/devices///number_of_stream_buffers
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   Indicates the number of streaming buffers the current channel 
can
+   handle.
+Users:
+
+What:  
/sys/class/most/mostcore/devices///size_of_packet_buffer
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   Indicates the size of a packet buffer the current channel can
+   handle.
+Users:
+
+What:  
/sys/class/most/mostcore/devices///size_of_stream_buffer
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   Indicates the size of a streaming buffer the current channel can
+   handle.
+Users:
+
+What:  
/sys/class/most/mostcore/devices///set_number_of_buffers
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   This is to configure the number of buffers of the current 
channel.
+Users:
+
+What:  
/sys/class/most/mostcore/devices///set_buffer_size
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   Christian Gromm 
+Description:
+   This is to configure the size of a buffer of the current 
channel.
+Users:
+
+What:  /sys/class/most/mostcore/devices///set_direction
+Date:  June 2015
+KernelVersion: 4.3
+Contact:   

[PATCH 7/9] Staging: most: add MOST driver's hdm-i2c module

2015-07-24 Thread Christian Gromm
This patch adds the hdm-i2c module of the MOST driver to the kernel's
driver staging area. This module is part of the MOST driver and handles
the I2C interface of the MOST network interface controller.

This patch is needed in order to use the I2C peripheral interface of the
network interface controller.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig   |2 +
 drivers/staging/most/Makefile  |1 +
 drivers/staging/most/hdm-i2c/Kconfig   |   12 +
 drivers/staging/most/hdm-i2c/Makefile  |3 +
 drivers/staging/most/hdm-i2c/hdm_i2c.c |  451 
 5 files changed, 469 insertions(+)
 create mode 100644 drivers/staging/most/hdm-i2c/Kconfig
 create mode 100644 drivers/staging/most/hdm-i2c/Makefile
 create mode 100644 drivers/staging/most/hdm-i2c/hdm_i2c.c

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 659c402..2a9f926 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -23,4 +23,6 @@ source "drivers/staging/most/aim-v4l2/Kconfig"
 
 source "drivers/staging/most/hdm-dim2/Kconfig"
 
+source "drivers/staging/most/hdm-i2c/Kconfig"
+
 endif
diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
index 7c68b3b..5056f2c 100644
--- a/drivers/staging/most/Makefile
+++ b/drivers/staging/most/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_AIM_NETWORK)   += aim-network/
 obj-$(CONFIG_AIM_SOUND)+= aim-sound/
 obj-$(CONFIG_AIM_V4L2) += aim-v4l2/
 obj-$(CONFIG_HDM_DIM2) += hdm-dim2/
+obj-$(CONFIG_HDM_I2C)  += hdm-i2c/
diff --git a/drivers/staging/most/hdm-i2c/Kconfig 
b/drivers/staging/most/hdm-i2c/Kconfig
new file mode 100644
index 000..6fd7983
--- /dev/null
+++ b/drivers/staging/most/hdm-i2c/Kconfig
@@ -0,0 +1,12 @@
+#
+# MOST I2C configuration
+#
+
+config HDM_I2C
+   tristate "I2C HDM"
+   depends on I2C
+   ---help---
+ Say Y here if you want to connect via I2C to network tranceiver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called hdm_i2c.
diff --git a/drivers/staging/most/hdm-i2c/Makefile 
b/drivers/staging/most/hdm-i2c/Makefile
new file mode 100644
index 000..03a4a59
--- /dev/null
+++ b/drivers/staging/most/hdm-i2c/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_HDM_I2C) += hdm_i2c.o
+
+ccflags-y += -Idrivers/staging/most/mostcore/
diff --git a/drivers/staging/most/hdm-i2c/hdm_i2c.c 
b/drivers/staging/most/hdm-i2c/hdm_i2c.c
new file mode 100644
index 000..029ded3
--- /dev/null
+++ b/drivers/staging/most/hdm-i2c/hdm_i2c.c
@@ -0,0 +1,451 @@
+/*
+ * hdm_i2c.c - Hardware Dependent Module for I2C Interface
+ *
+ * Copyright (C) 2013-2015, Microchip Technology Germany II GmbH & Co. KG
+ *
+ * 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.
+ *
+ * This file is licensed under GPLv2.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+enum { CH_RX, CH_TX, NUM_CHANNELS };
+
+#define MAX_BUFFERS_CONTROL 32
+#define MAX_BUF_SIZE_CONTROL 256
+
+/**
+ * list_first_mbo - get the first mbo from a list
+ * @ptr:   the list head to take the mbo from.
+ */
+#define list_first_mbo(ptr) \
+   list_first_entry(ptr, struct mbo, list)
+
+
+/* IRQ / Polling option */
+static bool polling_req;
+module_param(polling_req, bool, S_IRUGO);
+MODULE_PARM_DESC(polling_req, "Request Polling. Default = 0 (use irq)");
+
+/* Polling Rate */
+static int scan_rate = 100;
+module_param(scan_rate, int, 0644);
+MODULE_PARM_DESC(scan_rate, "Polling rate in times/sec. Default = 100");
+
+struct hdm_i2c {
+   bool is_open[NUM_CHANNELS];
+   bool polling_mode;
+   struct most_interface most_iface;
+   struct most_channel_capability capabilities[NUM_CHANNELS];
+   struct i2c_client *client;
+   struct rx {
+   struct delayed_work dwork;
+   wait_queue_head_t waitq;
+   struct list_head list;
+   struct mutex list_mutex;
+   } rx;
+   char name[64];
+};
+
+#define to_hdm(iface) container_of(iface, struct hdm_i2c, most_iface)
+
+/**
+ * configure_channel - called from MOST core to configure a channel
+ * @iface: interface the channel belongs to
+ * @channel: channel to be configured
+ * @channel_config: structure that holds the configuration information
+ *
+ * Return 0 on success, negative on failure.
+ *
+ * Receives configuration information from MOST core and initialize the
+ * corresponding channel.
+ */
+static int configure_channel(struct most_interface *most_iface,
+int ch_idx,
+struct most_channel_config *channel_config)
+{
+   struct hdm_i2c *dev = to_hdm(most_iface);
+
+   BUG_ON(ch_idx < 0 || ch_i

[PATCH 2/9] Staging: most: add MOST driver's aim-cdev module

2015-07-24 Thread Christian Gromm
This patch adds the aim-cdev module of the MOST driver to the kernel's
driver staging area. This module is part of the MOST driver and handles
user space interaction by means of character devices.

This patch is needed in order to have access to MOST data through
character devices.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig   |2 +
 drivers/staging/most/Makefile  |1 +
 drivers/staging/most/aim-cdev/Kconfig  |   12 +
 drivers/staging/most/aim-cdev/Makefile |4 +
 drivers/staging/most/aim-cdev/cdev.c   |  527 
 5 files changed, 546 insertions(+)
 create mode 100644 drivers/staging/most/aim-cdev/Kconfig
 create mode 100644 drivers/staging/most/aim-cdev/Makefile
 create mode 100644 drivers/staging/most/aim-cdev/cdev.c

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index b7db320..e29bee5 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -13,4 +13,6 @@ if MOST
 
 source "drivers/staging/most/mostcore/Kconfig"
 
+source "drivers/staging/most/aim-cdev/Kconfig"
+
 endif
diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
index 0144be0..b7b319b 100644
--- a/drivers/staging/most/Makefile
+++ b/drivers/staging/most/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_MOSTCORE) += mostcore/
+obj-$(CONFIG_AIM_CDEV) += aim-cdev/
diff --git a/drivers/staging/most/aim-cdev/Kconfig 
b/drivers/staging/most/aim-cdev/Kconfig
new file mode 100644
index 000..3c59f1b
--- /dev/null
+++ b/drivers/staging/most/aim-cdev/Kconfig
@@ -0,0 +1,12 @@
+#
+# MOST Cdev configuration
+#
+
+config AIM_CDEV
+   tristate "Cdev AIM"
+
+   ---help---
+ Say Y here if you want to commumicate via character devices.
+
+ To compile this driver as a module, choose M here: the
+ module will be called aim_cdev.
\ No newline at end of file
diff --git a/drivers/staging/most/aim-cdev/Makefile 
b/drivers/staging/most/aim-cdev/Makefile
new file mode 100644
index 000..0bcc6c6
--- /dev/null
+++ b/drivers/staging/most/aim-cdev/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_AIM_CDEV) += aim_cdev.o
+
+aim_cdev-objs := cdev.o
+ccflags-y += -Idrivers/staging/most/mostcore/
\ No newline at end of file
diff --git a/drivers/staging/most/aim-cdev/cdev.c 
b/drivers/staging/most/aim-cdev/cdev.c
new file mode 100644
index 000..d5fb4a0
--- /dev/null
+++ b/drivers/staging/most/aim-cdev/cdev.c
@@ -0,0 +1,527 @@
+/*
+ * cdev.c - Application interfacing module for character devices
+ *
+ * Copyright (C) 2013-2015 Microchip Technology Germany II GmbH & Co. KG
+ *
+ * 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.
+ *
+ * This file is licensed under GPLv2.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mostcore.h"
+
+static dev_t aim_devno;
+static struct class *aim_class;
+static struct ida minor_id;
+static unsigned int major;
+
+struct aim_channel {
+   wait_queue_head_t wq;
+   struct cdev cdev;
+   struct device *dev;
+   struct mutex io_mutex;
+   struct most_interface *iface;
+   struct most_channel_config *cfg;
+   unsigned int channel_id;
+   dev_t devno;
+   bool keep_mbo;
+   unsigned int mbo_offs;
+   struct mbo *stacked_mbo;
+   DECLARE_KFIFO_PTR(fifo, typeof(struct mbo *));
+   atomic_t access_ref;
+   struct list_head list;
+};
+#define to_channel(d) container_of(d, struct aim_channel, cdev)
+static struct list_head channel_list;
+static spinlock_t ch_list_lock;
+
+
+struct aim_channel *get_channel(struct most_interface *iface, int id)
+{
+   struct aim_channel *channel, *tmp;
+   unsigned long flags;
+   int found_channel = 0;
+
+   spin_lock_irqsave(&ch_list_lock, flags);
+   list_for_each_entry_safe(channel, tmp, &channel_list, list) {
+   if ((channel->iface == iface) && (channel->channel_id == id)) {
+   found_channel = 1;
+   break;
+   }
+   }
+   spin_unlock_irqrestore(&ch_list_lock, flags);
+   if (!found_channel)
+   return NULL;
+   return channel;
+}
+
+/**
+ * aim_open - implements the syscall to open the device
+ * @inode: inode pointer
+ * @filp: file pointer
+ *
+ * This stores the channel pointer in the private data field of
+ * the file structure and activates the channel within the core.
+ */
+static int aim_open(struct inode *inode, struct file *filp)
+{
+   struct aim_channel *channel;
+   int ret;
+
+   channel = to_channel(inode->i_cdev);
+   filp->private_data = channel;
+
+   if (((channel->cfg->direction == MOST_CH_RX) &&
+((filp->f_flags & O_ACCMODE) != O_RD

[PATCH 4/9] Staging: most: add MOST driver's aim-sound module

2015-07-24 Thread Christian Gromm
This patch adds the aim-sound module of the MOST driver to the kernel's
driver staging area. This module is part of the MOST driver and handles
user space interaction by means of ALSA devices.

This patch is needed in order to have access to MOST synchronous data
through ALSA devices.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig|2 +
 drivers/staging/most/Makefile   |1 +
 drivers/staging/most/aim-sound/Kconfig  |   12 +
 drivers/staging/most/aim-sound/Makefile |4 +
 drivers/staging/most/aim-sound/sound.c  |  758 +++
 5 files changed, 777 insertions(+)
 create mode 100644 drivers/staging/most/aim-sound/Kconfig
 create mode 100644 drivers/staging/most/aim-sound/Makefile
 create mode 100644 drivers/staging/most/aim-sound/sound.c

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 34a0b73..050abbe 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -17,4 +17,6 @@ source "drivers/staging/most/aim-cdev/Kconfig"
 
 source "drivers/staging/most/aim-network/Kconfig"
 
+source "drivers/staging/most/aim-sound/Kconfig"
+
 endif
diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
index 61c1c96..c639bbd 100644
--- a/drivers/staging/most/Makefile
+++ b/drivers/staging/most/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_MOSTCORE) += mostcore/
 obj-$(CONFIG_AIM_CDEV) += aim-cdev/
 obj-$(CONFIG_AIM_NETWORK)  += aim-network/
+obj-$(CONFIG_AIM_SOUND)+= aim-sound/
diff --git a/drivers/staging/most/aim-sound/Kconfig 
b/drivers/staging/most/aim-sound/Kconfig
new file mode 100644
index 000..b9e499c
--- /dev/null
+++ b/drivers/staging/most/aim-sound/Kconfig
@@ -0,0 +1,12 @@
+#
+# MOST ALSA configuration
+#
+
+config AIM_SOUND
+   tristate "ALSA AIM"
+   depends on SND
+   ---help---
+ Say Y here if you want to commumicate via ALSA/sound devices.
+
+ To compile this driver as a module, choose M here: the
+ module will be called aim_sound.
diff --git a/drivers/staging/most/aim-sound/Makefile 
b/drivers/staging/most/aim-sound/Makefile
new file mode 100644
index 000..beba958
--- /dev/null
+++ b/drivers/staging/most/aim-sound/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_AIM_SOUND) += aim_sound.o
+
+aim_sound-objs := sound.o
+ccflags-y += -Idrivers/staging/most/mostcore/
diff --git a/drivers/staging/most/aim-sound/sound.c 
b/drivers/staging/most/aim-sound/sound.c
new file mode 100644
index 000..860302e
--- /dev/null
+++ b/drivers/staging/most/aim-sound/sound.c
@@ -0,0 +1,758 @@
+/*
+ * sound.c - Audio Application Interface Module for Mostcore
+ *
+ * Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
+ *
+ * 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.
+ *
+ * This file is licensed under GPLv2.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_NAME "sound"
+
+static struct list_head dev_list;
+
+/**
+ * struct channel - private structure to keep channel specific data
+ * @substream: stores the substream structure
+ * @iface: interface for which the channel belongs to
+ * @cfg: channel configuration
+ * @card: registered sound card
+ * @list: list for private use
+ * @id: channel index
+ * @period_pos: current period position (ring buffer)
+ * @buffer_pos: current buffer position (ring buffer)
+ * @is_stream_running: identifies whether a stream is running or not
+ * @opened: set when the stream is opened
+ * @playback_task: playback thread
+ * @playback_waitq: waitq used by playback thread
+ */
+struct channel {
+   struct snd_pcm_substream *substream;
+   struct most_interface *iface;
+   struct most_channel_config *cfg;
+   struct snd_card *card;
+   struct list_head list;
+   int id;
+   unsigned int period_pos;
+   unsigned int buffer_pos;
+   bool is_stream_running;
+
+   struct task_struct *playback_task;
+   wait_queue_head_t playback_waitq;
+
+   void (*copy_fn)(void *alsa, void *most, unsigned int bytes);
+};
+
+#define MOST_PCM_INFO (SNDRV_PCM_INFO_MMAP | \
+  SNDRV_PCM_INFO_MMAP_VALID | \
+  SNDRV_PCM_INFO_BATCH | \
+  SNDRV_PCM_INFO_INTERLEAVED | \
+  SNDRV_PCM_INFO_BLOCK_TRANSFER)
+
+/**
+ * Initialization of struct snd_pcm_hardware
+ */
+static struct snd_pcm_hardware pcm_hardware_template = {
+   .info   = MOST_PCM_INFO,
+   .rates  = SNDRV_PCM_RATE_48000,
+   .rate_min   = 48000,
+   .rate_max   = 48000,
+   .channels_min   = 1,
+   .channels_max   = 8,
+};
+
+#define swap16(val) ( \
+   ((

[PATCH 5/9] Staging: most: add MOST driver's aim-v4l2 module

2015-07-24 Thread Christian Gromm
This patch adds the aim-v4l2 module of the MOST driver to the kernel's
driver staging area. This module is part of the MOST driver and handles
user space interaction by means of V4L2.

This patch is needed in order to have access to MOST isochronous AVP data
through V4L2 devices.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig   |2 +
 drivers/staging/most/Makefile  |1 +
 drivers/staging/most/aim-v4l2/Kconfig  |   12 +
 drivers/staging/most/aim-v4l2/Makefile |6 +
 drivers/staging/most/aim-v4l2/video.c  |  634 
 5 files changed, 655 insertions(+)
 create mode 100644 drivers/staging/most/aim-v4l2/Kconfig
 create mode 100644 drivers/staging/most/aim-v4l2/Makefile
 create mode 100644 drivers/staging/most/aim-v4l2/video.c

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 050abbe..4582918 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -19,4 +19,6 @@ source "drivers/staging/most/aim-network/Kconfig"
 
 source "drivers/staging/most/aim-sound/Kconfig"
 
+source "drivers/staging/most/aim-v4l2/Kconfig"
+
 endif
diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
index c639bbd..6e319c4 100644
--- a/drivers/staging/most/Makefile
+++ b/drivers/staging/most/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_MOSTCORE)  += mostcore/
 obj-$(CONFIG_AIM_CDEV) += aim-cdev/
 obj-$(CONFIG_AIM_NETWORK)  += aim-network/
 obj-$(CONFIG_AIM_SOUND)+= aim-sound/
+obj-$(CONFIG_AIM_V4L2) += aim-v4l2/
diff --git a/drivers/staging/most/aim-v4l2/Kconfig 
b/drivers/staging/most/aim-v4l2/Kconfig
new file mode 100644
index 000..d70eaaf
--- /dev/null
+++ b/drivers/staging/most/aim-v4l2/Kconfig
@@ -0,0 +1,12 @@
+#
+# MOST V4L2 configuration
+#
+
+config AIM_V4L2
+   tristate "V4L2 AIM"
+   depends on VIDEO_V4L2
+   ---help---
+ Say Y here if you want to commumicate via Video 4 Linux.
+
+ To compile this driver as a module, choose M here: the
+ module will be called aim_v4l2.
\ No newline at end of file
diff --git a/drivers/staging/most/aim-v4l2/Makefile 
b/drivers/staging/most/aim-v4l2/Makefile
new file mode 100644
index 000..28aa948
--- /dev/null
+++ b/drivers/staging/most/aim-v4l2/Makefile
@@ -0,0 +1,6 @@
+obj-$(CONFIG_AIM_V4L2) += aim_v4l2.o
+
+aim_v4l2-objs := video.o
+
+ccflags-y += -Idrivers/staging/most/mostcore/
+ccflags-y += -Idrivers/media/video
diff --git a/drivers/staging/most/aim-v4l2/video.c 
b/drivers/staging/most/aim-v4l2/video.c
new file mode 100644
index 000..a977b88
--- /dev/null
+++ b/drivers/staging/most/aim-v4l2/video.c
@@ -0,0 +1,634 @@
+/*
+ * V4L2 AIM - V4L2 Application Interface Module for MostCore
+ *
+ * Copyright (C) 2015, Microchip Technology Germany II GmbH & Co. KG
+ *
+ * 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.
+ *
+ * This file is licensed under GPLv2.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mostcore.h"
+
+
+#define V4L2_AIM_MAX_INPUT  1
+
+
+struct most_video_dev {
+   struct most_interface *iface;
+   int ch_idx;
+   struct list_head list;
+   bool mute;
+
+   struct list_head pending_mbos;
+   spinlock_t list_lock;
+
+   struct v4l2_device v4l2_dev;
+   atomic_t access_ref;
+   struct video_device *vdev;
+   unsigned int ctrl_input;
+
+   struct mutex lock;
+
+   wait_queue_head_t wait_data;
+};
+
+struct aim_fh {
+   /* must be the first field of this struct! */
+   struct v4l2_fh fh;
+   struct most_video_dev *mdev;
+   u32 offs;
+};
+
+
+static struct list_head video_devices = LIST_HEAD_INIT(video_devices);
+static struct spinlock list_lock;
+static struct most_aim aim_info;
+
+
+static inline bool data_ready(struct most_video_dev *mdev)
+{
+   return !list_empty(&mdev->pending_mbos);
+}
+
+static inline struct mbo *get_top_mbo(struct most_video_dev *mdev)
+{
+   return list_first_entry(&mdev->pending_mbos, struct mbo, list);
+}
+
+
+static int aim_vdev_open(struct file *filp)
+{
+   int ret;
+   struct video_device *vdev = video_devdata(filp);
+   struct most_video_dev *mdev = video_drvdata(filp);
+   struct aim_fh *fh;
+
+   pr_info("aim_vdev_open()\n");
+
+   switch (vdev->vfl_type) {
+   case VFL_TYPE_GRABBER:
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   fh = kzalloc(sizeof(struct aim_fh), GFP_KERNEL);
+   if (!fh)
+   return -ENOMEM;
+
+   if (!atomic_inc_and_test(&mdev->access_ref)) {
+   pr_err("too many clients\n");
+   ret = -EBUSY;
+

[PATCH 1/9] Staging: most: add MOST driver's core module

2015-07-24 Thread Christian Gromm
This patch adds the core module of the MOST driver to the kernel's driver
staging area. This module is part of the MOST driver and handles the
configuration interface in sysfs, the buffer management and the data
routing.

Signed-off-by: Christian Gromm 
---
This patchset adds the components of the Media Oriented Systems Transport
(MOST) driver to the kernel's driver staging area and adapts the build
system accordingly. By including this driver Linux applications will be
able to access a MOST network: The Automotive Information Backbone and the
de-facto standard for high-bandwidth automotive multimedia networking.

MOST defines the protocol, hardware and software layers necessary to allow
for the efficient and low-cost transport of control, real-time and packet
data using a single medium (physical layer). Media currently in use are
fiber optics, unshielded twisted pair cables (UTP) and coax cables. MOST
also supports various speed grades up to 150 Mbps.
For more information on MOST, visit the MOST Cooperation website:
www.mostcooperation.com.

Cars continue to evolve into sophisticated consumer electronics platforms,
increasing the demand for reliable and simple solutions to support audio,
video and data communications. MOST can be used to connect multiple
consumer devices via optical or electrical physical layers directly to one
another or in a network configuration. As a synchronous network, MOST
provides excellent Quality of Service and seamless connectivity for
audio/video streaming. Therefore, the driver perfectly fits to the mission
of Automotive Grade Linux to create open source software solutions for
automotive applications.

The driver consists basically of three layers. The hardware layer, the
core layer and the application layer. The core layer consists of the core
module only. This module handles the communication flow through all three
layers, the configuration of the driver, the configuration interface
representation in sysfs, and the buffer management.
For each of the other two layers a selection of modules is provided. These
modules can arbitrarily be combined to meet the needs of the desired
system architecture. A module of the hardware layer is referred to as an
HDM (hardware dependent module). Each module of this layer handles exactly
one of the peripheral interfaces of a network interface controller (e.g.
USB, MediaLB, I2C). A module of the application layer is referred to as an
AIM (application interfacing module). The modules of this layer give access
to MOST via one the following ways: character devices, ALSA, Networking or
V4L2.

To physically access MOST, an Intelligent Network Interface Controller
(INIC) is needed. For more information on available controllers visit:
www.microchip.com

 drivers/staging/Kconfig  |2 +
 drivers/staging/Makefile |1 +
 drivers/staging/most/Kconfig |   16 +
 drivers/staging/most/Makefile|1 +
 drivers/staging/most/TODO|8 +
 drivers/staging/most/mostcore/Kconfig|   13 +
 drivers/staging/most/mostcore/Makefile   |3 +
 drivers/staging/most/mostcore/core.c | 1931 ++
 drivers/staging/most/mostcore/mostcore.h |  316 +
 9 files changed, 2291 insertions(+)
 create mode 100644 drivers/staging/most/Kconfig
 create mode 100644 drivers/staging/most/Makefile
 create mode 100644 drivers/staging/most/TODO
 create mode 100644 drivers/staging/most/mostcore/Kconfig
 create mode 100644 drivers/staging/most/mostcore/Makefile
 create mode 100644 drivers/staging/most/mostcore/core.c
 create mode 100644 drivers/staging/most/mostcore/mostcore.h

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index bfacf69..279700d 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -112,4 +112,6 @@ source "drivers/staging/i2o/Kconfig"
 
 source "drivers/staging/fsl-mc/Kconfig"
 
+source "drivers/staging/most/Kconfig"
+
 endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 2bbd1bf..2585a4b 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -48,3 +48,4 @@ obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/
 obj-$(CONFIG_FB_TFT)   += fbtft/
 obj-$(CONFIG_I2O)  += i2o/
 obj-$(CONFIG_FSL_MC_BUS)   += fsl-mc/
+obj-$(CONFIG_MOST) += most/
diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
new file mode 100644
index 000..b7db320
--- /dev/null
+++ b/drivers/staging/most/Kconfig
@@ -0,0 +1,16 @@
+menuconfig MOST
+tristate "MOST driver"
+select MOSTCORE
+default n
+---help---
+  This option allows you to enable support for MOST Network 
transceivers.
+
+  If in doubt, say N here.
+
+
+
+if MOST
+
+source "drivers/staging/most/mostcore/Kconfig"
+
+endif
diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
new file mode 100644
index 000..0144be0
--- /d

[PATCH 3/9] Staging: most: add MOST driver's aim-network module

2015-07-24 Thread Christian Gromm
This patch adds the aim-network module of the MOST driver to the kernel's
driver staging area. This module is part of the MOST driver and handles
user space interaction by means of network devices.

This patch is needed in order to have access to MOST Ethernet Packets (MEP)
through a networking device.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/Kconfig  |2 +
 drivers/staging/most/Makefile |1 +
 drivers/staging/most/aim-network/Kconfig  |   12 +
 drivers/staging/most/aim-network/Makefile |4 +
 drivers/staging/most/aim-network/networking.c |  567 +
 drivers/staging/most/aim-network/networking.h |   23 +
 6 files changed, 609 insertions(+)
 create mode 100644 drivers/staging/most/aim-network/Kconfig
 create mode 100644 drivers/staging/most/aim-network/Makefile
 create mode 100644 drivers/staging/most/aim-network/networking.c
 create mode 100644 drivers/staging/most/aim-network/networking.h

diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index e29bee5..34a0b73 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -15,4 +15,6 @@ source "drivers/staging/most/mostcore/Kconfig"
 
 source "drivers/staging/most/aim-cdev/Kconfig"
 
+source "drivers/staging/most/aim-network/Kconfig"
+
 endif
diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
index b7b319b..61c1c96 100644
--- a/drivers/staging/most/Makefile
+++ b/drivers/staging/most/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_MOSTCORE) += mostcore/
 obj-$(CONFIG_AIM_CDEV) += aim-cdev/
+obj-$(CONFIG_AIM_NETWORK)  += aim-network/
diff --git a/drivers/staging/most/aim-network/Kconfig 
b/drivers/staging/most/aim-network/Kconfig
new file mode 100644
index 000..507232a
--- /dev/null
+++ b/drivers/staging/most/aim-network/Kconfig
@@ -0,0 +1,12 @@
+#
+# MOST Networking configuration
+#
+
+config AIM_NETWORK
+   tristate "Networking AIM"
+
+   ---help---
+ Say Y here if you want to commumicate via a networking device.
+
+ To compile this driver as a module, choose M here: the
+ module will be called aim_networking.
diff --git a/drivers/staging/most/aim-network/Makefile 
b/drivers/staging/most/aim-network/Makefile
new file mode 100644
index 000..840c1dd
--- /dev/null
+++ b/drivers/staging/most/aim-network/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_AIM_NETWORK) += aim_network.o
+
+aim_network-objs := networking.o
+ccflags-y += -Idrivers/staging/most/mostcore/
diff --git a/drivers/staging/most/aim-network/networking.c 
b/drivers/staging/most/aim-network/networking.c
new file mode 100644
index 000..4639c49
--- /dev/null
+++ b/drivers/staging/most/aim-network/networking.c
@@ -0,0 +1,567 @@
+/*
+ * Networking AIM - Networking Application Interface Module for MostCore
+ *
+ * Copyright (C) 2015, Microchip Technology Germany II GmbH & Co. KG
+ *
+ * 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.
+ *
+ * This file is licensed under GPLv2.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mostcore.h"
+#include "networking.h"
+
+
+#define MEP_HDR_LEN 8
+#define MDP_HDR_LEN 16
+#define MAMAC_DATA_LEN (1024 - MDP_HDR_LEN)
+
+#define PMHL 5
+
+#define PMS_TELID_UNSEGM_MAMAC 0x0A
+#define PMS_FIFONO_MDP 0x01
+#define PMS_FIFONO_MEP 0x04
+#define PMS_MSGTYPE_DATA   0x04
+#define PMS_DEF_PRIO   0
+#define MEP_DEF_RETRY  15
+
+#define PMS_FIFONO_MASK0x07
+#define PMS_FIFONO_SHIFT   3
+#define PMS_RETRY_SHIFT4
+#define PMS_TELID_MASK 0x0F
+#define PMS_TELID_SHIFT4
+
+#define HB(value)  ((u8)((u16)(value) >> 8))
+#define LB(value)  ((u8)(value))
+
+
+
+#define EXTRACT_BIT_SET(bitset_name, value) \
+   (((value) >> bitset_name##_SHIFT) & bitset_name##_MASK)
+
+#define PMS_IS_MEP(buf, len) \
+   ((len) > MEP_HDR_LEN && \
+EXTRACT_BIT_SET(PMS_FIFONO, (buf)[3]) == PMS_FIFONO_MEP)
+
+#define PMS_IS_MAMAC(buf, len) \
+   ((len) > MDP_HDR_LEN && \
+EXTRACT_BIT_SET(PMS_FIFONO, (buf)[3]) == PMS_FIFONO_MDP && \
+EXTRACT_BIT_SET(PMS_TELID, (buf)[14]) == PMS_TELID_UNSEGM_MAMAC)
+
+struct net_dev_channel {
+   bool linked;
+   int ch_id;
+};
+
+struct net_dev_context {
+   struct most_interface *iface;
+   bool channels_opened;
+   bool is_mamac;
+   unsigned char link_stat;
+   struct net_device *dev;
+   struct net_dev_channel rx;
+   struct net_dev_channel tx;
+   struct list_head list;
+};
+
+static struct list_head net_devices = LIST_HEAD_INIT(net_devices);
+static struct spinlock list_lock;
+static struct most_a

[PATCH 0/9] Staging: most: Patchset to add Microchip's MOST driver to kernel 4.1.2

2015-07-24 Thread Christian Gromm
This patchset adds the components of the Media Oriented Systems Transport
(MOST) driver to the kernel's driver staging area and adapts the build
system accordingly. By including this driver Linux applications will be
able to access a MOST network: The Automotive Information Backbone and the
de-facto standard for high-bandwidth automotive multimedia networking.

MOST defines the protocol, hardware and software layers necessary to allow
for the efficient and low-cost transport of control, real-time and packet
data using a single medium (physical layer). Media currently in use are
fiber optics, unshielded twisted pair cables (UTP) and coax cables. MOST
also supports various speed grades up to 150 Mbps.
For more information on MOST, visit the MOST Cooperation website:
www.mostcooperation.com.

Cars continue to evolve into sophisticated consumer electronics platforms,
increasing the demand for reliable and simple solutions to support audio,
video and data communications. MOST can be used to connect multiple
consumer devices via optical or electrical physical layers directly to one
another or in a network configuration. As a synchronous network, MOST
provides excellent Quality of Service and seamless connectivity for
audio/video streaming. Therefore, the driver perfectly fits to the mission
of Automotive Grade Linux to create open source software solutions for
automotive applications.

The driver consists basically of three layers. The hardware layer, the
core layer and the application layer. The core layer consists of the core
module only. This module handles the communication flow through all three
layers, the configuration of the driver, the configuration interface
representation in sysfs, and the buffer management.
For each of the other two layers a selection of modules is provided. These
modules can arbitrarily be combined to meet the needs of the desired
system architecture. A module of the hardware layer is referred to as an
HDM (hardware dependent module). Each module of this layer handles exactly
one of the peripheral interfaces of a network interface controller (e.g.
USB, MediaLB, I2C). A module of the application layer is referred to as an
AIM (application interfacing module). The modules of this layer give access
to MOST via one the following ways: character devices, ALSA, Networking or
V4L2.

To physically access MOST, an Intelligent Network Interface Controller
(INIC) is needed. For more information on available controllers visit:
www.microchip.com


Christian Gromm (9):
  Staging: most: add MOST driver's core module
  Staging: most: add MOST driver's aim-cdev module
  Staging: most: add MOST driver's aim-network module
  Staging: most: add MOST driver's aim-sound module
  Staging: most: add MOST driver's aim-v4l2 module
  Staging: most: add MOST driver's hdm-dim2 module
  Staging: most: add MOST driver's hdm-i2c module
  Staging: most: add MOST driver's hdm-usb module
  Staging: most: add MOST driver's documentation

 drivers/staging/Kconfig|2 +
 drivers/staging/Makefile   |1 +
 .../most/Documentation/ABI/sysfs-class-most.txt|  181 ++
 .../staging/most/Documentation/driver_usage.txt|  180 ++
 drivers/staging/most/Kconfig   |   30 +
 drivers/staging/most/Makefile  |8 +
 drivers/staging/most/TODO  |8 +
 drivers/staging/most/aim-cdev/Kconfig  |   12 +
 drivers/staging/most/aim-cdev/Makefile |4 +
 drivers/staging/most/aim-cdev/cdev.c   |  527 ++
 drivers/staging/most/aim-network/Kconfig   |   12 +
 drivers/staging/most/aim-network/Makefile  |4 +
 drivers/staging/most/aim-network/networking.c  |  567 ++
 drivers/staging/most/aim-network/networking.h  |   23 +
 drivers/staging/most/aim-sound/Kconfig |   12 +
 drivers/staging/most/aim-sound/Makefile|4 +
 drivers/staging/most/aim-sound/sound.c |  758 
 drivers/staging/most/aim-v4l2/Kconfig  |   12 +
 drivers/staging/most/aim-v4l2/Makefile |6 +
 drivers/staging/most/aim-v4l2/video.c  |  634 +++
 drivers/staging/most/hdm-dim2/Kconfig  |   15 +
 drivers/staging/most/hdm-dim2/Makefile |5 +
 drivers/staging/most/hdm-dim2/dim2_errors.h|   67 +
 drivers/staging/most/hdm-dim2/dim2_hal.c   |  919 ++
 drivers/staging/most/hdm-dim2/dim2_hal.h   |  124 ++
 drivers/staging/most/hdm-dim2/dim2_hdm.c   |  964 ++
 drivers/staging/most/hdm-dim2/dim2_hdm.h   |   26 +
 drivers/staging/most/hdm-dim2/dim2_reg.h   |  176 ++
 drivers/staging/most/hdm-dim2/dim2_sysfs.c |  116 ++
 drivers/staging/most/hdm-dim2/dim2_sysfs.h |   39 +
 drivers/staging/most/hdm-i2c/Kconfig   |   12 +
 drivers/staging/most/hdm-i2c/Makefile  |3 +
 drivers/staging/most

Re: [PATCH 5/5] staging: rtl8712: style fix:

2015-07-24 Thread Joshua Clayton
Dan,
On Friday, July 24, 2015 01:52:27 PM Dan Carpenter wrote:
> Write a better subject line.
> 
> On Thu, Jul 23, 2015 at 09:53:18PM -0700, Joshua Clayton wrote:
> > change instances SupportedRates to compliant and sane "rates"
> > This change in no way harms readability, and brings several lines
> > under the 80 character limit.
> 
> Yeah, but it does a some other stuff as well like removing casts.
I apologize. I thought it would make sense to double up (while I'm in there 
I'll just...).

> 
> > -   while ((pcur_bss->SupportedRates[i] != 0) &&
> > -   (pcur_bss->SupportedRates[i] != 0xFF)) {
> > -   rate = pcur_bss->SupportedRates[i] & 0x7F;
> > +   while (pcur_bss->rates[i] && (pcur_bss->rates[i] != 0xFF)) {
> > +   rate = pcur_bss->rates[i] & 0x7F;
> > 
> > if (rate > max_rate)
> > 
> > max_rate = rate;
> > 
> > wrqu->bitrate.fixed = 0;/* no auto select */
> 
> I actually like the != 0 here because we're talking about the number
> zero.  It should look like this:
> 
>   while (pcur_bss->rates[i] != 0 &&
>  pcur_bss->rates[i] != 0xFF) {
OK.

> 
> But removing the parens is something for a different patch.  I use a
> script to help review these so when you mix different changes together
> it means there is more manual review work for me.
Sorry about that.
I'll split or drop it in the next version
> 
> regards,
> dan carpenter

Joshua

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


Re: [PATCH 3/5] staging: rtl8712: remove duplicate struct

2015-07-24 Thread Dan Carpenter
On Fri, Jul 24, 2015 at 05:39:29AM -0700, Joshua Clayton wrote:
> On Friday, July 24, 2015 02:02:56 PM Sudip Mukherjee wrote:
> > On Thu, Jul 23, 2015 at 09:57:50PM -0700, Joshua Clayton wrote:
> > > struct ndis_wlan_bssid_ex is a dopelganger of
> > > struct wlan_bssid_ex, and is used about a third as often
> > > 
> > > Switch all instances to wlan_bssid_ex
> > > 
> > > This also gets rid of a use of typedef NDIS_802_11_RATES_EX
> > > 
> > > Signed-off-by: Joshua Clayton 
> > > ---
> > 
> > This patch seems to be corrupted. Did you try to edit the patch?
> > 
> > regards
> > sudip
> I did not manually edit it as far as I know.
> However, git-send-email (which sent the cover letter and patches 1,2,4, and 
> 5), died every time I try to send this patch.
> I opened it with kmail and it seemed to send successfully
> Perhaps there is something in the patch, or its size that trips up the smtp 
> server.
> 

kmail will screw up your patches.  There is a Kmail section in
Documentation/email-clients.txt.

Anyway, just figure it out and resend the entire series.  Don't send
attachments.  We are not in a rush.

regards,
dan carpenter

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


Re: [PATCH v9 4/7] staging: fpga manager: add sysfs interface document

2015-07-24 Thread Pavel Machek
On Fri 2015-07-24 07:39:15, atull wrote:
> On Fri, 24 Jul 2015, Pavel Machek wrote:
> 
> Hi Pavel,
> 
> Thanks for your your feedback in cleaning up these docs.
> 
> > Hi!
> > 
> > > +What:/sys/class/fpga_manager//state
> > > +Date:July 2015
> > > +KernelVersion:   4.2
> > > +Contact: Alan Tull 
> > > +Description: Read fpga manager state as a string.
> > 
> > fpga->FPGA.
> 
> Yep
> 
> > 
> > > + Valid states may vary by manufacturer; superset is:
> > > + * unknown   = can't determine state
> > > + * power off = FPGA power is off
> > > + * power up  = FPGA reports power is up
> > > + * reset = FPGA held in reset state
> > > + * firmware request  = firmware class request in progress
> > > + * firmware request error = firmware request failed
> > > + * write init= FPGA being prepared for programming
> > > + * write init error  = Error while preparing FPGA for
> > > +   programming
> > > + * write = FPGA ready to receive image data
> > > + * write error   = Error while programming
> > > + * write complete= Doing post programming steps
> > > + * write complete error  = Error while doing post programming
> > > + * operating = FPGA is programmed and operating
> > 
> 
> If I can make my intent clear, maybe we can figure out what will be most
> useful here.  
> 
> The intent is to provide enough detail that if something goes wrong with
> the FPGA programming (something that the driver can't take care of) then 
> userspace can know that.  Such as if the firmware request fails, that 
> could be due to not being able to find the firmware file.
> 
> > This will need some more details. "firmware request" is hardly a
> > hardware state, does it belong here? 
> 
> This is a superset of FPGA states and fpga manager driver states as the
> fpga manager driver is walking through the steps to get the FPGA into
> a known operating state.  So it's a sequence, though some steps may get
> skipped. If there is an error, then userspace can know what step failed.
> 
> Maybe this should be separated into fpga_state for hardware state and
> fpga_mgr_status (to report what step of progress the fpga manager driver
> is at during programming).  I want this to be useful and still not be 
> device (FPGA) specific.
> 
> > Is power off or on while firmware
> > is being requested? 
> 
> On.  It's a sequence.

Aha. Ok, so maybe noting that states normally go in the sequence (with
exception of various errors) would be enough?

Thanks,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/5] staging: rtl8712: remove duplicate struct

2015-07-24 Thread Joshua Clayton
On Friday, July 24, 2015 02:02:56 PM Sudip Mukherjee wrote:
> On Thu, Jul 23, 2015 at 09:57:50PM -0700, Joshua Clayton wrote:
> > struct ndis_wlan_bssid_ex is a dopelganger of
> > struct wlan_bssid_ex, and is used about a third as often
> > 
> > Switch all instances to wlan_bssid_ex
> > 
> > This also gets rid of a use of typedef NDIS_802_11_RATES_EX
> > 
> > Signed-off-by: Joshua Clayton 
> > ---
> 
> This patch seems to be corrupted. Did you try to edit the patch?
> 
> regards
> sudip
I did not manually edit it as far as I know.
However, git-send-email (which sent the cover letter and patches 1,2,4, and 
5), died every time I try to send this patch.
I opened it with kmail and it seemed to send successfully
Perhaps there is something in the patch, or its size that trips up the smtp 
server.

Here it is as an attachment

 >From c0adcc2aa0f82708e0f4594d9d9f9b63cfbdf39d Mon Sep 17 00:00:00 2001
From: Joshua Clayton 
Date: Thu, 23 Jul 2015 18:12:02 -0700
Subject: [PATCH 3/5] staging: rtl8712: remove duplicate struct

struct ndis_wlan_bssid_ex is a dopelganger of
struct wlan_bssid_ex, and is used about a third as often

Switch all instances to wlan_bssid_ex

This also gets rid of a use of typedef NDIS_802_11_RATES_EX

Signed-off-by: Joshua Clayton 
---
 drivers/staging/rtl8712/rtl871x_cmd.c | 17 ++---
 drivers/staging/rtl8712/rtl871x_cmd.h |  4 +--
 drivers/staging/rtl8712/rtl871x_event.h   |  2 +-
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 10 
 drivers/staging/rtl8712/rtl871x_mlme.c| 35 +--
 drivers/staging/rtl8712/rtl871x_mlme.h|  2 +-
 drivers/staging/rtl8712/rtl871x_mp_ioctl.c|  6 ++---
 drivers/staging/rtl8712/wlan_bssdef.h | 23 ++
 8 files changed, 38 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c
index f07050d..ef71829 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -456,9 +456,7 @@ u8 r8712_createbss_cmd(struct _adapter *padapter)
 	INIT_LIST_HEAD(&pcmd->list);
 	pcmd->cmdcode = _CreateBss_CMD_;
 	pcmd->parmbuf = (unsigned char *)pdev_network;
-	pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz((
-			struct ndis_wlan_bssid_ex *)
-			pdev_network);
+	pcmd->cmdsz = r8712_get_wlan_bssid_ex_sz(pdev_network);
 	pcmd->rsp = NULL;
 	pcmd->rspsz = 0;
 	/* notes: translate IELength & Length after assign to cmdsz; */
@@ -471,7 +469,7 @@ u8 r8712_createbss_cmd(struct _adapter *padapter)
 
 u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
 {
-	struct ndis_wlan_bssid_ex *psecnetwork;
+	struct wlan_bssid_ex *psecnetwork;
 	struct cmd_obj		*pcmd;
 	struct cmd_priv		*pcmdpriv = &padapter->cmdpriv;
 	struct mlme_priv	*pmlmepriv = &padapter->mlmepriv;
@@ -502,7 +500,7 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
 			break;
 		}
 	}
-	psecnetwork = (struct ndis_wlan_bssid_ex *)&psecuritypriv->sec_bss;
+	psecnetwork = &psecuritypriv->sec_bss;
 	if (psecnetwork == NULL) {
 		kfree(pcmd);
 		return _FAIL;
@@ -566,7 +564,7 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
 		memcpy(&psecuritypriv->supplicant_ie[1], &psecnetwork->IEs[0],
 			255);
 	/* get cmdsz before endian conversion */
-	pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz(psecnetwork);
+	pcmd->cmdsz = r8712_get_wlan_bssid_ex_sz(psecnetwork);
 #ifdef __BIG_ENDIAN
 	/* wlan_network endian conversion */
 	psecnetwork->Length = cpu_to_le32(psecnetwork->Length);
@@ -894,8 +892,7 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter,
 	struct sta_info *psta = NULL;
 	struct wlan_network *pwlan = NULL;
 	struct	mlme_priv *pmlmepriv = &padapter->mlmepriv;
-	struct ndis_wlan_bssid_ex *pnetwork = (struct ndis_wlan_bssid_ex *)
-	  pcmd->parmbuf;
+	struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf;
 	struct wlan_network *tgt_network = &(pmlmepriv->cur_network);
 
 	if (pcmd->res != H2C_SUCCESS)
@@ -949,11 +946,11 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter,
 		} else
 			list_add_tail(&(pwlan->list),
 	 &pmlmepriv->scanned_queue.queue);
-		pnetwork->Length = r8712_get_ndis_wlan_bssid_ex_sz(pnetwork);
+		pnetwork->Length = r8712_get_wlan_bssid_ex_sz(pnetwork);
 		memcpy(&(pwlan->network), pnetwork, pnetwork->Length);
 		pwlan->fixed = true;
 		memcpy(&tgt_network->network, pnetwork,
-			(r8712_get_ndis_wlan_bssid_ex_sz(pnetwork)));
+			(r8712_get_wlan_bssid_ex_sz(pnetwork)));
 		if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
 			pmlmepriv->fw_state ^= _FW_UNDER_LINKING;
 		/* we will set _FW_LINKED when there is one more sat to
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h
index cb8225b..8a91b80 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.h
+++ b/drivers/staging/rtl8712/rtl871x_cmd.h
@@ -128,7 +128,7 @@ struct usb_suspend_parm {
  * Comman

Re: [PATCH v9 4/7] staging: fpga manager: add sysfs interface document

2015-07-24 Thread atull
On Fri, 24 Jul 2015, Pavel Machek wrote:

Hi Pavel,

Thanks for your your feedback in cleaning up these docs.

> Hi!
> 
> > +What:  /sys/class/fpga_manager//state
> > +Date:  July 2015
> > +KernelVersion: 4.2
> > +Contact:   Alan Tull 
> > +Description:   Read fpga manager state as a string.
> 
> fpga->FPGA.

Yep

> 
> > +   Valid states may vary by manufacturer; superset is:
> > +   * unknown   = can't determine state
> > +   * power off = FPGA power is off
> > +   * power up  = FPGA reports power is up
> > +   * reset = FPGA held in reset state
> > +   * firmware request  = firmware class request in progress
> > +   * firmware request error = firmware request failed
> > +   * write init= FPGA being prepared for programming
> > +   * write init error  = Error while preparing FPGA for
> > + programming
> > +   * write = FPGA ready to receive image data
> > +   * write error   = Error while programming
> > +   * write complete= Doing post programming steps
> > +   * write complete error  = Error while doing post programming
> > +   * operating = FPGA is programmed and operating
> 

If I can make my intent clear, maybe we can figure out what will be most
useful here.  

The intent is to provide enough detail that if something goes wrong with
the FPGA programming (something that the driver can't take care of) then 
userspace can know that.  Such as if the firmware request fails, that 
could be due to not being able to find the firmware file.

> This will need some more details. "firmware request" is hardly a
> hardware state, does it belong here? 

This is a superset of FPGA states and fpga manager driver states as the
fpga manager driver is walking through the steps to get the FPGA into
a known operating state.  So it's a sequence, though some steps may get
skipped. If there is an error, then userspace can know what step failed.

Maybe this should be separated into fpga_state for hardware state and
fpga_mgr_status (to report what step of progress the fpga manager driver
is at during programming).  I want this to be useful and still not be 
device (FPGA) specific.

> Is power off or on while firmware
> is being requested? 

On.  It's a sequence.

> How does the fpga get into power up phase?
> Normally, you'd only power it on to do something more with it...?
> 
>   Pavel



> 
> -- 
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) 
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 1/4] i2c: tegra: implement slave mode

2015-07-24 Thread Wolfram Sang

> At the begin of my work on this patchset I even denied clock disable call if
> slave is registered (to minimize code that can affect transfer).

I hacked something like this, but it seems it was not enough.

> If only slave mode is used, then this logic is not needed.

This is not sufficent. We shouldn't break being a master only because we
also listen to a slave address (as long as the HW supports that of
course).

> tegra_i2c_init is called on probe and resume. Also it is called in case of
> xfer fail. If xfer is ok, then I think slave addr must be kept unchanged.

This is fragile. Try scanning the bus with i2cdetect and slave setup
will be gone.

> As far as I understand it is a loopback mode. Probably it will not work
> (Stephen Warren already mentioned this).

Just to make clear: I am not saying we should support talking to our own
slave address. But it should still be possible to communicate with other
remote devices on the bus.

Thanks,

   Wolfram


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


Re: [PATCH 5/5] staging: rtl8712: style fix:

2015-07-24 Thread Dan Carpenter
Write a better subject line.

On Thu, Jul 23, 2015 at 09:53:18PM -0700, Joshua Clayton wrote:
> change instances SupportedRates to compliant and sane "rates"
> This change in no way harms readability, and brings several lines
> under the 80 character limit.
> 

Yeah, but it does a some other stuff as well like removing casts.

> - while ((pcur_bss->SupportedRates[i] != 0) &&
> - (pcur_bss->SupportedRates[i] != 0xFF)) {
> - rate = pcur_bss->SupportedRates[i] & 0x7F;
> + while (pcur_bss->rates[i] && (pcur_bss->rates[i] != 0xFF)) {
> + rate = pcur_bss->rates[i] & 0x7F;
>   if (rate > max_rate)
>   max_rate = rate;
>   wrqu->bitrate.fixed = 0;/* no auto select */

I actually like the != 0 here because we're talking about the number
zero.  It should look like this:

while (pcur_bss->rates[i] != 0 &&
   pcur_bss->rates[i] != 0xFF) {

But removing the parens is something for a different patch.  I use a
script to help review these so when you mix different changes together
it means there is more manual review work for me.

regards,
dan carpenter

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


Re: [PATCH 1/5] staging: rtl8712: fix buggy size calculation

2015-07-24 Thread Dan Carpenter
On Thu, Jul 23, 2015 at 09:38:33PM -0700, Joshua Clayton wrote:
> r8712_get_ndis_wlan_bssid_ex_sz has a "6 * sizeof(unsigned long)"
> where the underlying struct has a 6 * unsigned char.
> Simplify the calculation by just subtracting the variable part from
> the size of the struct.
> 
> This also gets rid of a use of typedef NDIS_802_11_RATES_EX
> 
> Signed-off-by: Joshua Clayton 

Looks like you are right.

Reviewed-by: Dan Carpenter

regards,
dan carpenter

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


Re: [PATCH v3 1/4] i2c: tegra: implement slave mode

2015-07-24 Thread Andrey Danin

On 24.07.2015 12:27, Wolfram Sang wrote:

Still doesn't work for me and I think I understand why. Do you run your
I2C controller in slave mode only?


Yes.


That might work, but using it in
master/slave mode simultanously won't work yet as I see it:

* After every transfer (as master), clocks get disabled. I assume the IP
   core won't be able to detect its own address then.


At the begin of my work on this patchset I even denied clock disable 
call if slave is registered (to minimize code that can affect transfer). 
If only slave mode is used, then this logic is not needed.




* There is this code in tegra_i2c_init():

if (!i2c_dev->is_dvc) {
u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG);
sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL;
i2c_writel(i2c_dev, sl_cfg, I2C_SL_CNFG);
i2c_writel(i2c_dev, 0xfc, I2C_SL_ADDR1);
i2c_writel(i2c_dev, 0x00, I2C_SL_ADDR2);

}

   It probably messes up the slave initialization in tegra_reg_slave().
   At least I see that the slave address gets overwritten when I peek
   the register after boot.



tegra_i2c_init is called on probe and resume. Also it is called in case 
of xfer fail. If xfer is ok, then I think slave addr must be kept unchanged.



Does that make sense to you?


As far as I understand it is a loopback mode. Probably it will not work 
(Stephen Warren already mentioned this).

But we can try to run it.

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


Re: [PATCH v3 1/4] i2c: tegra: implement slave mode

2015-07-24 Thread Wolfram Sang
Hi Andrey,

On Mon, Jul 20, 2015 at 11:35:43PM +0300, Andrey Danin wrote:
> Initialization code is based on NVEC driver.
> 
> There is a HW bug in AP20 that was also mentioned in kernel sources
> for Toshiba AC100.
> 
> Signed-off-by: Andrey Danin 

Still doesn't work for me and I think I understand why. Do you run your
I2C controller in slave mode only? That might work, but using it in
master/slave mode simultanously won't work yet as I see it:

* After every transfer (as master), clocks get disabled. I assume the IP
  core won't be able to detect its own address then.

* There is this code in tegra_i2c_init():

if (!i2c_dev->is_dvc) {
u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG);
sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL;
i2c_writel(i2c_dev, sl_cfg, I2C_SL_CNFG);
i2c_writel(i2c_dev, 0xfc, I2C_SL_ADDR1);
i2c_writel(i2c_dev, 0x00, I2C_SL_ADDR2);

}

  It probably messes up the slave initialization in tegra_reg_slave().
  At least I see that the slave address gets overwritten when I peek
  the register after boot.

Does that make sense to you?

Thanks,

   Wolfram


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


Re: [PATCH V3 3/7] Drivers: hv: vmbus: add APIs to send/recv hvsock packet and get the r/w-ability

2015-07-24 Thread Dan Carpenter
On Fri, Jul 24, 2015 at 11:57:01AM +0530, Sudip Mukherjee wrote:
> This is also ok, the function is supposed to return ret or-ed with the
> relevant flags based on the scan position. It is considered error if 0
> is returned (without any flag).

Yeah.  You're right.  I looked through my list again this morning and
they all seem fine...

regards,
dan carpenter

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


Re: [PATCH 3/5] staging: rtl8712: remove duplicate struct

2015-07-24 Thread Sudip Mukherjee
On Thu, Jul 23, 2015 at 09:57:50PM -0700, Joshua Clayton wrote:
> struct ndis_wlan_bssid_ex is a dopelganger of
> struct wlan_bssid_ex, and is used about a third as often
> 
> Switch all instances to wlan_bssid_ex
> 
> This also gets rid of a use of typedef NDIS_802_11_RATES_EX
> 
> Signed-off-by: Joshua Clayton 
> ---
This patch seems to be corrupted. Did you try to edit the patch?

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


Re: [PATCH v9 4/7] staging: fpga manager: add sysfs interface document

2015-07-24 Thread Pavel Machek
Hi!

> +What:/sys/class/fpga_manager//state
> +Date:July 2015
> +KernelVersion:   4.2
> +Contact: Alan Tull 
> +Description: Read fpga manager state as a string.

fpga->FPGA.

> + Valid states may vary by manufacturer; superset is:
> + * unknown   = can't determine state
> + * power off = FPGA power is off
> + * power up  = FPGA reports power is up
> + * reset = FPGA held in reset state
> + * firmware request  = firmware class request in progress
> + * firmware request error = firmware request failed
> + * write init= FPGA being prepared for programming
> + * write init error  = Error while preparing FPGA for
> +   programming
> + * write = FPGA ready to receive image data
> + * write error   = Error while programming
> + * write complete= Doing post programming steps
> + * write complete error  = Error while doing post programming
> + * operating = FPGA is programmed and operating

This will need some more details. "firmware request" is hardly a
hardware state, does it belong here? Is power off or on while firmware
is being requested? How does the fpga get into power up phase?
Normally, you'd only power it on to do something more with it...?

Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel