[PATCH] Staging: comedi: das16: Fixed a const struct coding style issue

2017-11-25 Thread Alex Frappier Lachapelle
Fixed a coding style issue.

Signed-off-by: Alex Frappier Lachapelle 
---
 drivers/staging/comedi/drivers/das16.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index ddd4aeab6365..ed1e9e9b651d 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -967,7 +967,7 @@ static const struct comedi_lrange *das16_ai_range(struct 
comedi_device *dev,
 
/* get any user-defined input range */
if (pg_type == das16_pg_none && (min || max)) {
-   struct comedi_lrange *lrange;
+   const struct comedi_lrange *lrange;
struct comedi_krange *krange;
 
/* allocate single-range range table */
@@ -1001,7 +1001,7 @@ static const struct comedi_lrange *das16_ao_range(struct 
comedi_device *dev,
 
/* get any user-defined output range */
if (min || max) {
-   struct comedi_lrange *lrange;
+   const struct comedi_lrange *lrange;
struct comedi_krange *krange;
 
/* allocate single-range range table */
-- 
2.15.0

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


[PATCH v2] Staging: sm750fb: Fix coding style issue in ddk750_sii164.c

2017-11-25 Thread Jeremy Lacomis
This is a patch to the ddk750_sii164.c file that fixes line length warnings
found by the checkpatch.pl script

Signed-off-by: Jeremy Lacomis 
---
Changes in v2:
- Change definition of i2cReadReg/i2cWriteReg
- Remove unnecessary casts

 drivers/staging/sm750fb/ddk750_sii164.c | 87 -
 1 file changed, 43 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_sii164.c 
b/drivers/staging/sm750fb/ddk750_sii164.c
index c787a74c4f9c..66092c4645fc 100644
--- a/drivers/staging/sm750fb/ddk750_sii164.c
+++ b/drivers/staging/sm750fb/ddk750_sii164.c
@@ -12,11 +12,13 @@
 #define USE_HW_I2C
 
 #ifdef USE_HW_I2C
-#define i2cWriteReg sm750_hw_i2c_write_reg
-#define i2cReadReg  sm750_hw_i2c_read_reg
+#define i2c_write_reg(reg, config) sm750_hw_i2c_write_reg(SII164_I2C_ADDRESS, \
+ reg, config)
+#define i2c_read_reg(reg) sm750_hw_i2c_read_reg(SII164_I2C_ADDRESS, reg)
 #else
-#define i2cWriteReg sm750_sw_i2c_write_reg
-#define i2cReadReg  sm750_sw_i2c_read_reg
+#define i2c_write_reg(reg, config) sm750_sw_i2c_write_reg(SII164_I2C_ADDRESS, \
+ reg, config)
+#define i2c_read_reg(reg) sm750_sw_i2c_read_reg(SII164_I2C_ADDRESS, reg)
 #endif
 
 /* SII164 Vendor and Device ID */
@@ -39,8 +41,8 @@ unsigned short sii164GetVendorID(void)
 {
unsigned short vendorID;
 
-   vendorID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
SII164_VENDOR_ID_HIGH) << 8) |
-   (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
SII164_VENDOR_ID_LOW);
+   vendorID = (i2c_read_reg(SII164_VENDOR_ID_HIGH) << 8) |
+   i2c_read_reg(SII164_VENDOR_ID_LOW);
 
return vendorID;
 }
@@ -56,15 +58,16 @@ unsigned short sii164GetDeviceID(void)
 {
unsigned short deviceID;
 
-   deviceID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
SII164_DEVICE_ID_HIGH) << 8) |
-   (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
SII164_DEVICE_ID_LOW);
+   deviceID = (i2c_read_reg(SII164_DEVICE_ID_HIGH) << 8) |
+   i2c_read_reg(SII164_DEVICE_ID_LOW);
 
return deviceID;
 }
 
-
-
-/* DVI.C will handle all SiI164 chip stuffs and try it best to make code 
minimal and useful */
+/*
+ * DVI.C will handle all SiI164 chip stuffs and try it best to make code 
minimal
+ * and useful
+ */
 
 /*
  *  sii164InitChip
@@ -72,10 +75,10 @@ unsigned short sii164GetDeviceID(void)
  *
  *  Input:
  *  edgeSelect  - Edge Select:
- *  0 = Input data is falling edge latched 
(falling edge
- *  latched first in dual edge mode)
- *  1 = Input data is rising edge latched (rising 
edge
- *  latched first in dual edge mode)
+ *  0 = Input data is falling edge latched (falling
+ *  edge latched first in dual edge mode)
+ *  1 = Input data is rising edge latched (rising
+ *  edge latched first in dual edge mode)
  *  busSelect   - Input Bus Select:
  *  0 = Input data bus is 12-bits wide
  *  1 = Input data bus is 24-bits wide
@@ -135,7 +138,8 @@ long sii164InitChip(unsigned char edgeSelect,
 #endif
 
/* Check if SII164 Chip exists */
-   if ((sii164GetVendorID() == SII164_VENDOR_ID) && (sii164GetDeviceID() 
== SII164_DEVICE_ID)) {
+   if ((sii164GetVendorID() == SII164_VENDOR_ID) &&
+   (sii164GetDeviceID() == SII164_DEVICE_ID)) {
/*
 *  Initialize SII164 controller chip.
 */
@@ -170,7 +174,7 @@ long sii164InitChip(unsigned char edgeSelect,
else
config |= SII164_CONFIGURATION_VSYNC_AS_IS;
 
-   i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
+   i2c_write_reg(SII164_CONFIGURATION, config);
 
/*
 * De-skew enabled with default 111b value.
@@ -208,7 +212,7 @@ long sii164InitChip(unsigned char edgeSelect,
config |= SII164_DESKEW_8_STEP;
break;
}
-   i2cWriteReg(SII164_I2C_ADDRESS, SII164_DESKEW, config);
+   i2c_write_reg(SII164_DESKEW, config);
 
/* Enable/Disable Continuous Sync. */
if (continuousSyncEnable == 0)
@@ -225,12 +229,12 @@ long sii164InitChip(unsigned char edgeSelect,
/* Set the PLL Filter value */
config |= ((pllFilterValue & 0x07) << 1);
 
-   i2cWriteReg(SII164_I2C_ADDRESS, SII164_PLL, config);
+   i2c_write_reg(SII164_PLL, config);
 
/* Recover from Power Down and enable output. */
-   config = i2cReadReg(SII164_I2C_ADD

Re: [PATCH 2/2] staging: rtl8188eu: Fix private WEXT IOCTL calls

2017-11-25 Thread Ishraq Ibne Ashraf
Hi,

What was broken was private/device specific IOCTL calls implemented by this 
driver. The standard IOCTL calls worked and the driver worked as it was in 
client mode.

But in AP mode with hostapd (https://w1.fi/hostapd/) the rtl871xdrv driver of 
hostapd (which is required for using devices that use this driver in AP mode) 
invokes private/device specific IOCTL calls and in the existing driver they 
could only be invoked through the ndo_do_ioctl interface of the driver. Support 
for which was removed in the mentioned commit by Johannes Berg. Hence the 
driver stopped working in AP mode with hostapd using rtl871xdrv driver.

The solution was to implement equivalent versions of the existing 
private/device specific IOCTLs which will be invoked by the iw_handler_def 
interface.


Cheers,
Ishraq


On 11/25/2017 05:40 AM, Dan Carpenter wrote:
> I added Johannes to the CC list again because this is sort of his
> fault...  To be honest, I'm a little bit puzzled.  I would have thought
> Johannes's change would have made some code unused and that we could
> delete it now.  I haven't looked at this.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: sm750fb: Fix coding style issue in ddk750_sii164.c

2017-11-25 Thread Joe Perches
On Sat, 2017-11-25 at 12:59 -0500, Jeremy Lacomis wrote:
> This is a patch to the ddk750_sii164.c file that fixes line length warnings
> found by the checkpatch.pl script
> 
> Signed-off-by: Jeremy Lacomis 
> ---
>  drivers/staging/sm750fb/ddk750_sii164.c | 39 
> +++--
>  1 file changed, 23 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/staging/sm750fb/ddk750_sii164.c 
> b/drivers/staging/sm750fb/ddk750_sii164.c
> index c787a74c4f9c..d081ecbb3e3d 100644
> --- a/drivers/staging/sm750fb/ddk750_sii164.c
> +++ b/drivers/staging/sm750fb/ddk750_sii164.c
> @@ -39,8 +39,10 @@ unsigned short sii164GetVendorID(void)
>  {
>   unsigned short vendorID;
>  
> - vendorID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
> SII164_VENDOR_ID_HIGH) << 8) |
> - (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
> SII164_VENDOR_ID_LOW);
> + vendorID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS,
> + SII164_VENDOR_ID_HIGH) << 8) |
> + (unsigned short) i2cReadReg(SII164_I2C_ADDRESS,
> + SII164_VENDOR_ID_LOW);
>  
>   return vendorID;
>  }
> @@ -56,15 +58,20 @@ unsigned short sii164GetDeviceID(void)
>  {
>   unsigned short deviceID;
>  
> - deviceID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
> SII164_DEVICE_ID_HIGH) << 8) |
> - (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
> SII164_DEVICE_ID_LOW);
> + deviceID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS,
> + SII164_DEVICE_ID_HIGH) << 8) |
> + (unsigned short) i2cReadReg(SII164_I2C_ADDRESS,
> + SII164_DEVICE_ID_LOW);
>  
>   return deviceID;
>  }

i2cReadReg is always used with SII154_I2C_ADDRESS.

Perhaps it'd be better to redefine i2cReadReg to something else.
i2cReadReg also returns an unsigned char so this cast isn't
particularly sensible.

Perhaps something like:

#define sii164_i2c_read_reg(reg)i2cReadReg(SII164_I2C_ADDRESS, reg)

device_id = sii164_i2c_read_reg(SII164_DEVICE_ID_HIGH) << 8 |
sii164_i2c_read_reg(SII164_DEVICE_ID_LOW);


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


[PATCH v2] staging: sm750b: Fix coding style issues in sm750_accel.c

2017-11-25 Thread Jeremy Lacomis
This is a patch to sm750_accel.c that fixes 80-character line length
warnings found by checkpatch.pl. It also fixes some grammatical errors
in comments and moves parameter-specific comments from inline to before
the function.

Signed-off-by: Jeremy Lacomis 
---
Changes in v2:
- Change function comments to the kernel-doc format

 drivers/staging/sm750fb/sm750_accel.c | 189 ++
 1 file changed, 103 insertions(+), 86 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_accel.c 
b/drivers/staging/sm750fb/sm750_accel.c
index 1035e91e7cd3..42cd920111bf 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0
+/* SPDX-License-Identifier: GPL-2.0 */
 #include 
 #include 
 #include 
@@ -68,11 +68,10 @@ void sm750_hw_de_init(struct lynx_accel *accel)
 }
 
 /*
- * set2dformat only be called from setmode functions
- * but if you need dual framebuffer driver,need call set2dformat
- * every time you use 2d function
+ * set2dformat can only be called from setmode functions, but if you need a 
dual
+ * framebuffer driver, set2dformat must be called every time a 2D function is
+ * used
  */
-
 void sm750_hw_set2dformat(struct lynx_accel *accel, int fmt)
 {
u32 reg;
@@ -94,7 +93,7 @@ int sm750_hw_fillrect(struct lynx_accel *accel,
 
if (accel->de_wait() != 0) {
/*
-* int time wait and always busy,seems hardware
+* int time wait and always busy, seems hardware
 * got something error
 */
pr_debug("De engine always busy\n");
@@ -130,80 +129,88 @@ int sm750_hw_fillrect(struct lynx_accel *accel,
return 0;
 }
 
-int sm750_hw_copyarea(
-struct lynx_accel *accel,
-unsigned int sBase,  /* Address of source: offset in frame buffer */
-unsigned int sPitch, /* Pitch value of source surface in BYTE */
-unsigned int sx,
-unsigned int sy, /* Starting coordinate of source surface */
-unsigned int dBase,  /* Address of destination: offset in frame buffer */
-unsigned int dPitch, /* Pitch value of destination surface in BYTE */
-unsigned int Bpp,/* Color depth of destination surface */
-unsigned int dx,
-unsigned int dy, /* Starting coordinate of destination surface */
-unsigned int width,
-unsigned int height, /* width and height of rectangle in pixel value */
-unsigned int rop2)   /* ROP value */
+/**
+ * sm750_hw_copyarea()
+ * @sBase: Address of the source offset in the frame buffer
+ * @sPitch: Pitch value of the source surface in BYTE
+ * @sx: Starting x-coordinate of the source surface
+ * @sy: Starting y-coordinate of the source surface
+ * @dBase: Address of the destination offset in the frame buffer
+ * @dPitch: Pitch value of the destination surface in BYTE
+ * @Bpp: Color depth of the destination surface
+ * @dx: Starting x-coordinate of the destination surface
+ * @dy: Starting y-coordinate of the destination surface
+ * @width: Width of the rectangle in pixels
+ * @height: Height of the rectangle in pixels
+ * @rop2: ROP value
+ */
+int sm750_hw_copyarea(struct lynx_accel *accel, unsigned int sBase,
+ unsigned int sPitch, unsigned int sx, unsigned int sy,
+ unsigned int dBase, unsigned int dPitch, unsigned int Bpp,
+ unsigned int dx, unsigned int dy, unsigned int width,
+ unsigned int height, unsigned int rop2)
 {
unsigned int nDirection, de_ctrl;
 
nDirection = LEFT_TO_RIGHT;
-   /* Direction of ROP2 operation: 1 = Left to Right, (-1) = Right to Left 
*/
+   /*
+* Direction of ROP2 operation:
+* 1  = Left to Right
+* -1 = Right to Left
+*/
de_ctrl = 0;
 
-   /* If source and destination are the same surface, need to check for 
overlay cases */
+   /*
+* If the source and destination are the same surface, need to check for
+* overlay cases
+*/
if (sBase == dBase && sPitch == dPitch) {
/* Determine direction of operation */
-   if (sy < dy) {
-   /* +--+
-* |S |
-* |   +--+
-* |   |  |   |
-* |   |  |   |
-* +---|--+   |
-* | D|
-* +--+
-*/
 
+   /* +--+
+* |S |
+* |   +--+
+* |   |  |   |
+* |   |  |   |
+* +---|--+   |
+* | D|
+* +--+
+*/
+   if (sy < dy) {
nDirection = BOTTOM_TO_TOP;
-   } else if (sy > dy) {
-   /* +--+
- 

Re: [PATCH 2/2] staging: sm750b: Fix coding style issues in sm750_accel.c

2017-11-25 Thread Joe Perches
On Sat, 2017-11-25 at 13:26 -0500, Jeremy Lacomis wrote:
> This is a patch to sm750_accel.c that fixes 80-character line length
> warnings found by checkpatch.pl. It also fixes some grammatical errors
> in comments and moves parameter-specific comments from inline to before
> the function.
[]
> + * Notes on these parameters:
> + * sBase: Address of the source offset in the frame buffer
> + * sPitch: Pitch value of the source surface in BYTE
> + * sx, sy: Starting coordinate of the source surface
> + * dBase: Address of the destination offset in the frame buffer
> + * dPitch: Pitch value of the destination surface in BYTE
> + * Bpp: Color depth of the destination surface
> + * dx, dy: Starting coordinate of the destination surface
> + * width, height: Dimensions of the rectangle in pixels
> + * rop2: ROP value

Use kernel-doc format instead.

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


Re: [PATCH v3] staging: rtl8188eu: Fix private WEXT IOCTL calls

2017-11-25 Thread Dan Carpenter
Thanks.  This is looking *much* better...

On Sat, Nov 25, 2017 at 07:29:41PM +0100, ishraq.i.ash...@gmail.com wrote:
> From: Ishraq Ibne Ashraf 
> 
> Commit 8bfb36766064 ("wireless: wext: remove ndo_do_ioctl fallback") breaks 
> private WEXT
> IOCTL calls of this driver as these are not invoked through ndo_do_ioctl
> interface anymore. As a result hostapd stops working with this driver. In
> this patch this problem is solved by implementing equivalent private IOCTL
> functions of the existing ones which are accessed via iw_handler_def
> interface.
> 
> Signed-off-by: Ishraq Ibne Ashraf 
> ---
>  drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 1077 
> 
>  1 file changed, 1077 insertions(+)
> 
> diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
> b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
> index c0664dc..8d99f99 100644
> --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
> @@ -3061,6 +3061,1081 @@ static iw_handler rtw_handlers[] = {
>   NULL,   /*---hole---*/
>  };
>  
> +static int get_private_handler_ieee_param(struct adapter *padapter,
> +   union iwreq_data *wrqu,
> +   void *param)
> +{
> + /*
> +  * This function is expected to be called in master mode, which allows 
> no
> +  * power saving. So we just check hw_init_completed.
> +  */
> + if (!padapter->hw_init_completed)
> + return -EPERM;

This check doesn't belong here.  ->hw_init_completed is set to true in
rtw_hal_init() and false in rtw_hal_deinit().  Can it ever be false
here?  I really doubt it and if I'm wrong then we are pretty screwed
already...  Anyway, move the check or delete it.  Then this function and
the kmalloc() can be replaced with memdup_user().

> +
> + if (copy_from_user(param, wrqu->data.pointer, wrqu->data.length))
> + return -EFAULT;
> +
> + return 0;
> +}
> +
> +static int rtw_hostapd_sta_flush_pvt(struct net_device *dev,
> +  struct iw_request_info *info,
> +  union iwreq_data *wrqu,
> +  char *extra)
> +{
> + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);

Add a blank line after declarations.

> + flush_all_cam_entry(padapter); /* Clear CAM. */
> + return rtw_sta_flush(padapter);
> +}
> +
> +static int rtw_add_sta_pvt(struct net_device *dev,
> +struct iw_request_info *info,
> +union iwreq_data *wrqu,
> +char *extra)
> +{
> + int ret;
> + int flags;
> + struct sta_info *psta;
> + struct ieee_param *param;
> + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
> + struct sta_priv *pstapriv = &padapter->stapriv;
> + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
> +
> + param = (struct ieee_param *)kmalloc(wrqu->data.length, GFP_KERNEL);
> + if (!param)
> + return -ENOMEM;
> +
> + ret = get_private_handler_ieee_param(padapter, wrqu, param);
> + if (ret)
> + goto err_free_param;

Then these lines become:

param = memdup_user(wrqu->data.pointer, wrqu->data.length);
if (IS_ERR(param))
return PTR_ERR(param);

> +
> + DBG_88E("rtw_add_sta(aid =%d) =%pM\n",
> + param->u.add_sta.aid,
> + (param->sta_addr));
> +
> + if (!check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE))) {
> + ret = -EINVAL;
> + goto err_free_param;
> + }
> +
> + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
> + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
> + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
> + ret = -EINVAL;
> + goto err_free_param;
> + }
> +
> + psta = rtw_get_stainfo(pstapriv, param->sta_addr);
> + if (!psta) {
> + ret = -ENOMEM;
> + goto err_free_param;
> + }
> +
> + flags = param->u.add_sta.flags;
> + psta->aid = param->u.add_sta.aid; /* aid = 1~2007. */
> +
> + memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16);
> +
> + /* Check WMM cap. */
> + if (WLAN_STA_WME&flags)


Add spaces around the & and reverse the order.

if (flags & WLAN_STA_HT) {

> + psta->qos_option = 1;
> + else
> + psta->qos_option = 0;
> +
> + if (pmlmepriv->qospriv.qos_option == 0)
> + psta->qos_option = 0;
> +
> + /* Check 802.11n HT cap. */
> + if (WLAN_STA_HT&flags) {

Add spaces and reverse.

> + psta->htpriv.ht_option = true;
> + psta->qos_option = 1;
> + memcpy(&psta->htpriv.ht_cap,
> +¶m->u.add_sta.ht_cap,
> +sizeof(struct ieee80211_ht_cap));
>

[PATCH V2] staging: rtl8188eu: Fix incorrect response to SIOCGIWESSID

2017-11-25 Thread Larry Finger
When not associated with an AP, wifi device drivers should respond to the
SIOCGIWESSID ioctl with a zero-length string for the SSID, which is the
behavior expected by dhcpcd.

Currently, this driver returns an error code (-1) from the ioctl call,
which causes dhcpcd to assume that the device is not a wireless interface
and therefore it fails to work correctly with it thereafter.

This problem was reported and tested at
https://github.com/lwfinger/rtl8188eu/issues/234.

Signed-off-by: Larry Finger 
---

v2 - completed missing subject
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index c0664dc80bf2..446310775e90 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -1395,19 +1395,13 @@ static int rtw_wx_get_essid(struct net_device *dev,
if ((check_fwstate(pmlmepriv, _FW_LINKED)) ||
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) {
len = pcur_bss->Ssid.SsidLength;
-
-   wrqu->essid.length = len;
-
memcpy(extra, pcur_bss->Ssid.Ssid, len);
-
-   wrqu->essid.flags = 1;
} else {
-   ret = -1;
-   goto exit;
+   len = 0;
+   *extra = 0;
}
-
-exit:
-
+   wrqu->essid.length = len;
+   wrqu->essid.flags = 1;
 
return ret;
 }
-- 
2.13.6

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


[PATCH v3] staging: rtl8188eu: Fix private WEXT IOCTL calls

2017-11-25 Thread ishraq . i . ashraf
From: Ishraq Ibne Ashraf 

Commit 8bfb36766064 ("wireless: wext: remove ndo_do_ioctl fallback") breaks 
private WEXT
IOCTL calls of this driver as these are not invoked through ndo_do_ioctl
interface anymore. As a result hostapd stops working with this driver. In
this patch this problem is solved by implementing equivalent private IOCTL
functions of the existing ones which are accessed via iw_handler_def
interface.

Signed-off-by: Ishraq Ibne Ashraf 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 1077 
 1 file changed, 1077 insertions(+)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index c0664dc..8d99f99 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -3061,6 +3061,1081 @@ static iw_handler rtw_handlers[] = {
NULL,   /*---hole---*/
 };
 
+static int get_private_handler_ieee_param(struct adapter *padapter,
+ union iwreq_data *wrqu,
+ void *param)
+{
+   /*
+* This function is expected to be called in master mode, which allows 
no
+* power saving. So we just check hw_init_completed.
+*/
+   if (!padapter->hw_init_completed)
+   return -EPERM;
+
+   if (copy_from_user(param, wrqu->data.pointer, wrqu->data.length))
+   return -EFAULT;
+
+   return 0;
+}
+
+static int rtw_hostapd_sta_flush_pvt(struct net_device *dev,
+struct iw_request_info *info,
+union iwreq_data *wrqu,
+char *extra)
+{
+   struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
+   flush_all_cam_entry(padapter); /* Clear CAM. */
+   return rtw_sta_flush(padapter);
+}
+
+static int rtw_add_sta_pvt(struct net_device *dev,
+  struct iw_request_info *info,
+  union iwreq_data *wrqu,
+  char *extra)
+{
+   int ret;
+   int flags;
+   struct sta_info *psta;
+   struct ieee_param *param;
+   struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
+   struct sta_priv *pstapriv = &padapter->stapriv;
+   struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+
+   param = (struct ieee_param *)kmalloc(wrqu->data.length, GFP_KERNEL);
+   if (!param)
+   return -ENOMEM;
+
+   ret = get_private_handler_ieee_param(padapter, wrqu, param);
+   if (ret)
+   goto err_free_param;
+
+   DBG_88E("rtw_add_sta(aid =%d) =%pM\n",
+   param->u.add_sta.aid,
+   (param->sta_addr));
+
+   if (!check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE))) {
+   ret = -EINVAL;
+   goto err_free_param;
+   }
+
+   if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
+   param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
+   param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+   ret = -EINVAL;
+   goto err_free_param;
+   }
+
+   psta = rtw_get_stainfo(pstapriv, param->sta_addr);
+   if (!psta) {
+   ret = -ENOMEM;
+   goto err_free_param;
+   }
+
+   flags = param->u.add_sta.flags;
+   psta->aid = param->u.add_sta.aid; /* aid = 1~2007. */
+
+   memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16);
+
+   /* Check WMM cap. */
+   if (WLAN_STA_WME&flags)
+   psta->qos_option = 1;
+   else
+   psta->qos_option = 0;
+
+   if (pmlmepriv->qospriv.qos_option == 0)
+   psta->qos_option = 0;
+
+   /* Check 802.11n HT cap. */
+   if (WLAN_STA_HT&flags) {
+   psta->htpriv.ht_option = true;
+   psta->qos_option = 1;
+   memcpy(&psta->htpriv.ht_cap,
+  ¶m->u.add_sta.ht_cap,
+  sizeof(struct ieee80211_ht_cap));
+   } else {
+   psta->htpriv.ht_option = false;
+   }
+
+   if (pmlmepriv->htpriv.ht_option == false)
+   psta->htpriv.ht_option = false;
+
+   update_sta_info_apmode(padapter, psta);
+
+   if (copy_to_user(wrqu->data.pointer, param, wrqu->data.length)) {
+   ret = -EFAULT;
+   goto err_free_param;
+   }
+
+   kfree(param);
+   return 0;
+
+err_free_param:
+   kfree(param);
+   return ret;
+}
+
+static int rtw_del_sta_pvt(struct net_device *dev,
+  struct iw_request_info *info,
+  union iwreq_data *wrqu,
+  char *extra)
+{
+   int ret;
+   int updated;
+   struct sta_info *psta;
+   struct ieee_param *param;
+   struct adapter *padapter = (struct adapter *)rtw_netdev_priv(

[PATCH 1/2] staging: sm750fb: Fix coding style in ddk750_sii164.h

2017-11-25 Thread Jeremy Lacomis
This patch to ddk750_sii164.h fixes line length warnings found by the
checkpatch.pl script and reformats comments uniformly.

Signed-off-by: Jeremy Lacomis 
---
 drivers/staging/sm750fb/ddk750_sii164.h | 57 +
 1 file changed, 22 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_sii164.h 
b/drivers/staging/sm750fb/ddk750_sii164.h
index 2e9a88cd6af3..393a3c5be3ae 100644
--- a/drivers/staging/sm750fb/ddk750_sii164.h
+++ b/drivers/staging/sm750fb/ddk750_sii164.h
@@ -4,15 +4,20 @@
 
 #define USE_DVICHIP
 
-/* Hot Plug detection mode structure */
+/*
+ * Hot Plug detection mode structure:
+ *  Disable Hot Plug output bit (always high).
+ *  Use Monitor Detect Interrupt bit.
+ *  Use Receiver Sense detect bit.
+ *  Use Hot Plug detect bit.
+ */
 enum sii164_hot_plug_mode {
-   SII164_HOTPLUG_DISABLE = 0, /* Disable Hot Plug output bit 
(always high). */
-   SII164_HOTPLUG_USE_MDI, /* Use Monitor Detect Interrupt 
bit. */
-   SII164_HOTPLUG_USE_RSEN,/* Use Receiver Sense detect bit. */
-   SII164_HOTPLUG_USE_HTPLG/* Use Hot Plug detect bit. */
+   SII164_HOTPLUG_DISABLE = 0,
+   SII164_HOTPLUG_USE_MDI,
+   SII164_HOTPLUG_USE_RSEN,
+   SII164_HOTPLUG_USE_HTPLG
 };
 
-
 /* Silicon Image SiI164 chip prototype */
 long sii164InitChip(unsigned char edgeSelect,
unsigned char busSelect,
@@ -28,7 +33,6 @@ long sii164InitChip(unsigned char edgeSelect,
 unsigned short sii164GetVendorID(void);
 unsigned short sii164GetDeviceID(void);
 
-
 #ifdef SII164_FULL_FUNCTIONS
 void sii164ResetChip(void);
 char *sii164GetChipString(void);
@@ -39,35 +43,26 @@ unsigned char sii164CheckInterrupt(void);
 void sii164ClearInterrupt(void);
 #endif
 /*
- * below register definition is used for
+ * The below register definition is used for the
  * Silicon Image SiI164 DVI controller chip
  */
-/*
- * Vendor ID registers
- */
+
+/* Vendor ID registers */
 #define SII164_VENDOR_ID_LOW0x00
 #define SII164_VENDOR_ID_HIGH   0x01
 
-/*
- * Device ID registers
- */
+/* Device ID registers */
 #define SII164_DEVICE_ID_LOW0x02
 #define SII164_DEVICE_ID_HIGH   0x03
 
-/*
- * Device Revision
- */
+/* Device Revision */
 #define SII164_DEVICE_REVISION  0x04
 
-/*
- * Frequency Limitation registers
- */
+/* Frequency Limitation registers */
 #define SII164_FREQUENCY_LIMIT_LOW  0x06
 #define SII164_FREQUENCY_LIMIT_HIGH 0x07
 
-/*
- * Power Down and Input Signal Configuration registers
- */
+/* Power Down and Input Signal Configuration registers */
 #define SII164_CONFIGURATION0x08
 
 /* Power down (PD) */
@@ -95,9 +90,7 @@ void sii164ClearInterrupt(void);
 #define SII164_CONFIGURATION_VSYNC_FORCE_LOW0x00
 #define SII164_CONFIGURATION_VSYNC_AS_IS0x20
 
-/*
- * Detection registers
- */
+/* Detection registers */
 #define SII164_DETECT   0x09
 
 /* Monitor Detect Interrupt (MDI) */
@@ -127,9 +120,7 @@ void sii164ClearInterrupt(void);
 #define SII164_DETECT_MONITOR_SENSE_OUTPUT_HTPLG0x30
 #define SII164_DETECT_MONITOR_SENSE_OUTPUT_FLAG 0x30
 
-/*
- * Skewing registers
- */
+/* Skewing registers */
 #define SII164_DESKEW   0x0A
 
 /* General Purpose Input (CTL[3:1]) */
@@ -149,14 +140,10 @@ void sii164ClearInterrupt(void);
 #define SII164_DESKEW_7_STEP0xC0
 #define SII164_DESKEW_8_STEP0xE0
 
-/*
- * User Configuration Data registers (CFG 7:0)
- */
+/* User Configuration Data registers (CFG 7:0) */
 #define SII164_USER_CONFIGURATION   0x0B
 
-/*
- * PLL registers
- */
+/* PLL registers */
 #define SII164_PLL  0x0C
 
 /* PLL Filter Value (PLLF) */
-- 
2.11.0

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


[PATCH 2/2] staging: sm750b: Fix coding style issues in sm750_accel.c

2017-11-25 Thread Jeremy Lacomis
This is a patch to sm750_accel.c that fixes 80-character line length
warnings found by checkpatch.pl. It also fixes some grammatical errors
in comments and moves parameter-specific comments from inline to before
the function.

Signed-off-by: Jeremy Lacomis 
---
 drivers/staging/sm750fb/sm750_accel.c | 184 ++
 1 file changed, 98 insertions(+), 86 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_accel.c 
b/drivers/staging/sm750fb/sm750_accel.c
index 1035e91e7cd3..085e5064188f 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0
+/* SPDX-License-Identifier: GPL-2.0 */
 #include 
 #include 
 #include 
@@ -68,11 +68,10 @@ void sm750_hw_de_init(struct lynx_accel *accel)
 }
 
 /*
- * set2dformat only be called from setmode functions
- * but if you need dual framebuffer driver,need call set2dformat
- * every time you use 2d function
+ * set2dformat can only be called from setmode functions, but if you need a 
dual
+ * framebuffer driver, set2dformat must be called every time a 2D function is
+ * used
  */
-
 void sm750_hw_set2dformat(struct lynx_accel *accel, int fmt)
 {
u32 reg;
@@ -94,7 +93,7 @@ int sm750_hw_fillrect(struct lynx_accel *accel,
 
if (accel->de_wait() != 0) {
/*
-* int time wait and always busy,seems hardware
+* int time wait and always busy, seems hardware
 * got something error
 */
pr_debug("De engine always busy\n");
@@ -130,80 +129,85 @@ int sm750_hw_fillrect(struct lynx_accel *accel,
return 0;
 }
 
-int sm750_hw_copyarea(
-struct lynx_accel *accel,
-unsigned int sBase,  /* Address of source: offset in frame buffer */
-unsigned int sPitch, /* Pitch value of source surface in BYTE */
-unsigned int sx,
-unsigned int sy, /* Starting coordinate of source surface */
-unsigned int dBase,  /* Address of destination: offset in frame buffer */
-unsigned int dPitch, /* Pitch value of destination surface in BYTE */
-unsigned int Bpp,/* Color depth of destination surface */
-unsigned int dx,
-unsigned int dy, /* Starting coordinate of destination surface */
-unsigned int width,
-unsigned int height, /* width and height of rectangle in pixel value */
-unsigned int rop2)   /* ROP value */
+/*
+ * Notes on these parameters:
+ * sBase: Address of the source offset in the frame buffer
+ * sPitch: Pitch value of the source surface in BYTE
+ * sx, sy: Starting coordinate of the source surface
+ * dBase: Address of the destination offset in the frame buffer
+ * dPitch: Pitch value of the destination surface in BYTE
+ * Bpp: Color depth of the destination surface
+ * dx, dy: Starting coordinate of the destination surface
+ * width, height: Dimensions of the rectangle in pixels
+ * rop2: ROP value
+ */
+int sm750_hw_copyarea(struct lynx_accel *accel, unsigned int sBase,
+ unsigned int sPitch, unsigned int sx, unsigned int sy,
+ unsigned int dBase, unsigned int dPitch, unsigned int Bpp,
+ unsigned int dx, unsigned int dy, unsigned int width,
+ unsigned int height, unsigned int rop2)
 {
unsigned int nDirection, de_ctrl;
 
nDirection = LEFT_TO_RIGHT;
-   /* Direction of ROP2 operation: 1 = Left to Right, (-1) = Right to Left 
*/
+   /*
+* Direction of ROP2 operation:
+* 1  = Left to Right
+* -1 = Right to Left
+*/
de_ctrl = 0;
 
-   /* If source and destination are the same surface, need to check for 
overlay cases */
+   /*
+* If the source and destination are the same surface, need to check for
+* overlay cases
+*/
if (sBase == dBase && sPitch == dPitch) {
/* Determine direction of operation */
-   if (sy < dy) {
-   /* +--+
-* |S |
-* |   +--+
-* |   |  |   |
-* |   |  |   |
-* +---|--+   |
-* | D|
-* +--+
-*/
 
+   /* +--+
+* |S |
+* |   +--+
+* |   |  |   |
+* |   |  |   |
+* +---|--+   |
+* | D|
+* +--+
+*/
+   if (sy < dy) {
nDirection = BOTTOM_TO_TOP;
-   } else if (sy > dy) {
-   /* +--+
-* |D |
-* |   +--+
-* |   |  |   |
-  

[PATCH] staging: rtl8188eu:

2017-11-25 Thread Larry Finger
When not associated with an AP, wifi device drivers should respond to the
SIOCGIWESSID ioctl with a zero-length string for the SSID, which is the
behavior expected by dhcpcd.

Currently, this driver returns an error code (-1) from the ioctl call,
which causes dhcpcd to assume that the device is not a wireless interface
and therefore it fails to work correctly with it thereafter.

This problem was reported and tested at
https://github.com/lwfinger/rtl8188eu/issues/234.

Signed-off-by: Larry Finger 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index c0664dc80bf2..446310775e90 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -1395,19 +1395,13 @@ static int rtw_wx_get_essid(struct net_device *dev,
if ((check_fwstate(pmlmepriv, _FW_LINKED)) ||
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) {
len = pcur_bss->Ssid.SsidLength;
-
-   wrqu->essid.length = len;
-
memcpy(extra, pcur_bss->Ssid.Ssid, len);
-
-   wrqu->essid.flags = 1;
} else {
-   ret = -1;
-   goto exit;
+   len = 0;
+   *extra = 0;
}
-
-exit:
-
+   wrqu->essid.length = len;
+   wrqu->essid.flags = 1;
 
return ret;
 }
-- 
2.13.6

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


Re: [PATCH 2/2] staging: rtl8188eu: Fix private WEXT IOCTL calls

2017-11-25 Thread Ishraq Ibne Ashraf
Hi,

What was broken was private/device specific IOCTL calls implemented by this 
driver. The standard IOCTL calls worked and the driver worked as it was in 
client mode.

But in AP mode with hostapd (https://w1.fi/hostapd/) the rtl871xdrv driver of 
hostapd (which is required for using devices that use this driver in AP mode) 
invokes private/device specific IOCTL calls and in the existing driver they 
could only be invoked through the ndo_do_ioctl interface of the driver. Support 
for which was removed in the mentioned commit by Johannes Berg. Hence the 
driver stopped working in AP mode with hostapd using rtl871xdrv driver.

The solution was to implement equivalent versions of the existing 
private/device specific IOCTLs which will be invoked by the iw_handler_def 
interface.


Cheers,
Ishraq


On 11/25/2017 05:40 AM, Dan Carpenter wrote:
> I added Johannes to the CC list again because this is sort of his
> fault...  To be honest, I'm a little bit puzzled.  I would have thought
> Johannes's change would have made some code unused and that we could
> delete it now.  I haven't looked at this.

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


[PATCH] Staging: sm750fb: Fix coding style issue in ddk750_sii164.c

2017-11-25 Thread Jeremy Lacomis
This is a patch to the ddk750_sii164.c file that fixes line length warnings
found by the checkpatch.pl script

Signed-off-by: Jeremy Lacomis 
---
 drivers/staging/sm750fb/ddk750_sii164.c | 39 +++--
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_sii164.c 
b/drivers/staging/sm750fb/ddk750_sii164.c
index c787a74c4f9c..d081ecbb3e3d 100644
--- a/drivers/staging/sm750fb/ddk750_sii164.c
+++ b/drivers/staging/sm750fb/ddk750_sii164.c
@@ -39,8 +39,10 @@ unsigned short sii164GetVendorID(void)
 {
unsigned short vendorID;
 
-   vendorID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
SII164_VENDOR_ID_HIGH) << 8) |
-   (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
SII164_VENDOR_ID_LOW);
+   vendorID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS,
+   SII164_VENDOR_ID_HIGH) << 8) |
+   (unsigned short) i2cReadReg(SII164_I2C_ADDRESS,
+   SII164_VENDOR_ID_LOW);
 
return vendorID;
 }
@@ -56,15 +58,20 @@ unsigned short sii164GetDeviceID(void)
 {
unsigned short deviceID;
 
-   deviceID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
SII164_DEVICE_ID_HIGH) << 8) |
-   (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, 
SII164_DEVICE_ID_LOW);
+   deviceID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS,
+   SII164_DEVICE_ID_HIGH) << 8) |
+   (unsigned short) i2cReadReg(SII164_I2C_ADDRESS,
+   SII164_DEVICE_ID_LOW);
 
return deviceID;
 }
 
 
 
-/* DVI.C will handle all SiI164 chip stuffs and try it best to make code 
minimal and useful */
+/*
+ * DVI.C will handle all SiI164 chip stuffs and try it best to make code 
minimal
+ * and useful
+ */
 
 /*
  *  sii164InitChip
@@ -72,10 +79,10 @@ unsigned short sii164GetDeviceID(void)
  *
  *  Input:
  *  edgeSelect  - Edge Select:
- *  0 = Input data is falling edge latched 
(falling edge
- *  latched first in dual edge mode)
- *  1 = Input data is rising edge latched (rising 
edge
- *  latched first in dual edge mode)
+ *  0 = Input data is falling edge latched (falling
+ *  edge latched first in dual edge mode)
+ *  1 = Input data is rising edge latched (rising
+ *  edge latched first in dual edge mode)
  *  busSelect   - Input Bus Select:
  *  0 = Input data bus is 12-bits wide
  *  1 = Input data bus is 24-bits wide
@@ -135,7 +142,8 @@ long sii164InitChip(unsigned char edgeSelect,
 #endif
 
/* Check if SII164 Chip exists */
-   if ((sii164GetVendorID() == SII164_VENDOR_ID) && (sii164GetDeviceID() 
== SII164_DEVICE_ID)) {
+   if ((sii164GetVendorID() == SII164_VENDOR_ID) &&
+   (sii164GetDeviceID() == SII164_DEVICE_ID)) {
/*
 *  Initialize SII164 controller chip.
 */
@@ -260,8 +268,8 @@ void sii164ResetChip(void)
 
 /*
  * sii164GetChipString
- *  This function returns a char string name of the current DVI Controller 
chip.
- *  It's convenient for application need to display the chip name.
+ *  This function returns a char string name of the current DVI Controller
+ *  chip.  It's convenient for application need to display the chip name.
  */
 char *sii164GetChipString(void)
 {
@@ -336,8 +344,9 @@ void sii164EnableHotPlugDetection(unsigned char 
enableHotPlug)
 
detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT);
 
-   /* Depending on each DVI controller, need to enable the hot plug based 
on each
-* individual chip design.
+   /*
+* Depending on each DVI controller, need to enable the hot plug based
+* on each individual chip design.
 */
if (enableHotPlug != 0)
sii164SelectHotPlugDetectionMode(SII164_HOTPLUG_USE_MDI);
@@ -402,5 +411,3 @@ void sii164ClearInterrupt(void)
 #endif
 
 #endif
-
-
-- 
2.11.0

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