Re: [PATCH 4/6] Staging/iio/adc/touchscreen/MXS: add i.MX23 support to the LRADC touchscreen driver

2013-09-16 Thread Jürgen Beisert
Hi Jonathan,

On Sunday 15 September 2013 12:50:09 Jonathan Cameron wrote:
 On 09/11/13 09:18, Juergen Beisert wrote:
  Distinguish i.MX23 and i.MX28 at runtime and do the same for both SoC at
  least for the 4 wire touchscreen.
 
  Note: support for the remaining LRADC channels is not tested on an
  i.MX23 yet.

 An ominous comment. Are you likely to test them soon?

Sorry, currently no i.MX28 hardware available. Someone out here with an i.MX28 
based system with a touchscreen to test? 

 Minor code layout comment inline but otherwise I'm just looking for an
 ack from Marek.

  [...]
   static u32 mxs_lradc_drive_pressure(struct mxs_lradc *lradc)
   {
  +   if (lradc-soc == IMX23_LRADC)
  +   return LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_XM;
  return LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_XNNSW;

 Whilst it obviously doesn't actually matter, having an else
 in there would make the code more consistent so personally
 I would prefer it to be there.

I can change it. Anyone here with objections against such a change?

Regards
Juergen

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/6] Staging/iio/adc/touchscreen/MXS: simplify register access

2013-09-16 Thread Jürgen Beisert
Hi Jonathan,

On Sunday 15 September 2013 12:35:29 Jonathan Cameron wrote:
 [...]
  +static void mxs_lradc_reg_set(struct mxs_lradc *lradc, u32 val, u32 reg)
  +{
  +   writel(val, lradc-base + reg + STMP_OFFSET_REG_SET);
  +}
  +
  +static void mxs_lradc_reg_clear(struct mxs_lradc *lradc, u32 val, u32 reg)
  +{ 
  +   writel(val, lradc-base + reg + STMP_OFFSET_REG_CLR);
  +}
  +

 mxs_lradc_reg_write might be clearer?

I would prefer the shorter name. Due to long macro names and long function 
names the lines in the code below needs more and more line breaks which is 
IMHO less helpfull to read the code.

Regards,
Juergen

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread Dan Carpenter
The main thing is that could you improve the error handling in
hv_kbd_on_channel_callback() explained inline.

On Sun, Sep 15, 2013 at 10:28:54PM -0700, K. Y. Srinivasan wrote:
 Add a new driver to support synthetic keyboard. On the next generation
 Hyper-V guest firmware, many legacy devices will not be emulated and this
 driver will be required.
 
 I would like to thank Vojtech Pavlik vojt...@suse.cz for helping me with the
 details of the AT keyboard driver. 
 
 Signed-off-by: K. Y. Srinivasan k...@microsoft.com
 ---
  drivers/input/serio/Kconfig   |7 +
  drivers/input/serio/Makefile  |1 +
  drivers/input/serio/hyperv-keyboard.c |  379 
 +
  3 files changed, 387 insertions(+), 0 deletions(-)
  create mode 100644 drivers/input/serio/hyperv-keyboard.c
 
 diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
 index 1e691a3..f3996e7 100644
 --- a/drivers/input/serio/Kconfig
 +++ b/drivers/input/serio/Kconfig
 @@ -267,4 +267,11 @@ config SERIO_OLPC_APSP
 To compile this driver as a module, choose M here: the module will
 be called olpc_apsp.
  
 +config HYPERV_KEYBOARD
 + tristate Microsoft Synthetic Keyboard driver
 + depends on HYPERV
 + default HYPERV
 + help
 +   Select this option to enable the Hyper-V Keyboard driver.
 +
  endif
 diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
 index 12298b1..815d874 100644
 --- a/drivers/input/serio/Makefile
 +++ b/drivers/input/serio/Makefile
 @@ -28,3 +28,4 @@ obj-$(CONFIG_SERIO_ALTERA_PS2)  += altera_ps2.o
  obj-$(CONFIG_SERIO_ARC_PS2)  += arc_ps2.o
  obj-$(CONFIG_SERIO_APBPS2)   += apbps2.o
  obj-$(CONFIG_SERIO_OLPC_APSP)+= olpc_apsp.o
 +obj-$(CONFIG_HYPERV_KEYBOARD)+= hyperv-keyboard.o
 diff --git a/drivers/input/serio/hyperv-keyboard.c 
 b/drivers/input/serio/hyperv-keyboard.c
 new file mode 100644
 index 000..0d4625f
 --- /dev/null
 +++ b/drivers/input/serio/hyperv-keyboard.c
 @@ -0,0 +1,379 @@
 +/*
 + *  Copyright (c) 2013, Microsoft Corporation.
 + *
 + *  This program is free software; you can redistribute it and/or modify it
 + *  under the terms and conditions of the GNU General Public License,
 + *  version 2, as published by the Free Software Foundation.
 + *
 + *  This program is distributed in the hope 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.
 + */
 +#include linux/init.h
 +#include linux/module.h
 +#include linux/device.h
 +#include linux/completion.h
 +#include linux/hyperv.h
 +#include linux/serio.h
 +#include linux/slab.h
 +
 +

Extra blank line.

 +/*
 + * Current version 1.0
 + *
 + */
 +#define SYNTH_KBD_VERSION_MAJOR 1
 +#define SYNTH_KBD_VERSION_MINOR  0
 +#define SYNTH_KBD_VERSION(SYNTH_KBD_VERSION_MINOR | \
 +  (SYNTH_KBD_VERSION_MAJOR  16))
 +
 +
 +/*
 + * Message types in the synthetic input protocol
 + */
 +enum synth_kbd_msg_type {
 + SYNTH_KBD_PROTOCOL_REQUEST = 1,
 + SYNTH_KBD_PROTOCOL_RESPONSE = 2,
 + SYNTH_KBD_EVENT = 3,
 + SYNTH_KBD_LED_INDICATORS = 4,
 +};
 +
 +/*
 + * Basic message structures.
 + */
 +struct synth_kbd_msg_hdr {
 + enum synth_kbd_msg_type type;
 +};

Enum type is wrong here because sizeof(enum) is up to the compiler to
decide.

 +
 +struct synth_kbd_msg {
 + struct synth_kbd_msg_hdr header;
 + char data[1]; /* Enclosed message */
 +};

You could use a zero size array instead.

 +
 +union synth_kbd_version {
 + struct {
 + u16 minor_version;
 + u16 major_version;
 + };
 + u32 version;
 +};
 +
 +/*
 + * Protocol messages
 + */
 +struct synth_kbd_protocol_request {
 + struct synth_kbd_msg_hdr header;
 + union synth_kbd_version version_requested;
 +};
 +
 +struct synth_kbd_protocol_response {
 + struct synth_kbd_msg_hdr header;
 + u32 accepted:1;
 + u32 reserved:31;
 +};
 +
 +struct synth_kbd_keystroke {
 + struct synth_kbd_msg_hdr header;
 + u16 make_code;
 + u16 reserved0;
 + u32 is_unicode:1;
 + u32 is_break:1;
 + u32 is_e0:1;
 + u32 is_e1:1;
 + u32 reserved:28;
 +};
 +
 +

Extra blank line.

 +#define HK_MAXIMUM_MESSAGE_SIZE 256
 +
 +#define KBD_VSC_SEND_RING_BUFFER_SIZE(10 * PAGE_SIZE)
 +#define KBD_VSC_RECV_RING_BUFFER_SIZE(10 * PAGE_SIZE)
 +
 +#define XTKBD_EMUL0 0xe0
 +#define XTKBD_EMUL1 0xe1
 +#define XTKBD_RELEASE   0x80
 +
 +

Extra blank.

 +/*
 + * Represents a keyboard device
 + */
 +struct hv_kbd_dev {
 + unsigned char keycode[256];
 + struct hv_device*device;
 + struct synth_kbd_protocol_request protocol_req;
 + struct synth_kbd_protocol_response protocol_resp;
 + /* Synchronize the request/response if needed */
 + struct completion   

Re: [PATCH 5/6] Staging/iio/adc/touchscreen/MXS: add interrupt driven touch detection

2013-09-16 Thread Jürgen Beisert
Hi Jonathan,

On Sunday 15 September 2013 18:10:18 Jonathan Cameron wrote:
 On 09/15/13 11:56, Jonathan Cameron wrote:
  On 09/11/13 09:18, Juergen Beisert wrote:
  For battery driven systems it is a very bad idea to collect the
  touchscreen data within a kernel busy loop.
 
  This change uses the features of the hardware to delay and accumulate
  samples in hardware to avoid a high interrupt and CPU load.
 
  Note: this is only tested on an i.MX23 SoC yet.
 
  Signed-off-by: Juergen Beisert j...@pengutronix.de
  CC: linux-arm-ker...@lists.infradead.org
  CC: de...@driverdev.osuosl.org
  CC: Marek Vasut ma...@denx.de
  CC: Fabio Estevam fabio.este...@freescale.com
  CC: Jonathan Cameron ji...@cam.ac.uk
 
  While this driver is placed in IIO within staging at the moment, these
  changes are definitely input related.  Hence I have cc'd Dmitry and the
  input list.
 
  I am personaly a little uncomfortable that we have such a complex bit of
  input code sat within an IIO driver but such is life.

 The logic in here looks reasonable to me. I am far from a specialist in how
 these touch screens are normally handled though.

 One thing to note is that you really want to get a proposed device tree
 spec out asap as that can take longer to review than the driver.  If you
 are proposing to do that as a future patch, then take into account that
 you'll need to ensure these are the defaults if it is not specified in the
 device tree for ever more (which is more painful than hammering out he
 device tree stuff now!)
 ...

Will do.

Regards,
Juergen

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 5/6] Staging/iio/adc/touchscreen/MXS: add interrupt driven touch detection

2013-09-16 Thread Jürgen Beisert
Hi Jonathan,

On Monday 16 September 2013 10:10:22 Jürgen Beisert wrote:
 [...]
  While this driver is placed in IIO within staging at the moment, these
  changes are definitely input related.  Hence I have cc'd Dmitry and the
  input list.
 
  I am personaly a little uncomfortable that we have such a complex bit of
  input code sat within an IIO driver but such is life.

 Maybe an MFD for this ADC unit would be a better way to go? Currently I
 have a different problem with this driver, because the ADC unit monitors
 the battery as well. And the charging driver from the power subsystem needs
 these values to charge the battery in a correct manner.

I would suggest:

diff --git a/drivers/staging/iio/TODO b/drivers/staging/iio/TODO
index 04c2326..c22a0ed 100644
--- a/drivers/staging/iio/TODO
+++ b/drivers/staging/iio/TODO
@@ -13,6 +13,17 @@ Would be nice
 3) Expand device set. Lots of other maxim adc's have very
similar interfaces.
 
+MXS LRADC driver:
+This is a classic MFD device as it combines the following subdevices
+ - touchscreen controller (input subsystem related device)
+ - general purpose ADC channels
+ - battery voltage monitor (power subsystem related device)
+ - die temperature monitor (thermal management)
+
+At least the battery voltage and die temperature feature is required in-kernel
+by a driver of the SoC's battery charging unit to avoid any damage to the
+silicon and the battery.
+
 TSL2561
 Would be nice
 1) Open question of userspace vs kernel space balance when

Regards,
Juergen

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4] mfd: rtsx: Modify rts5249_optimize_phy

2013-09-16 Thread Lee Jones
On Fri, 13 Sep 2013, wei_w...@realsil.com.cn wrote:

 From: Wei WANG wei_w...@realsil.com.cn
 
 In some platforms, specially Thinkpad series, rts5249 won't be
 initialized properly. So we need adjust some phy parameters to
 improve the compatibility issue.
 
 It is a little different between simulation and real chip. We have
 no idea about which configuration is better before tape-out. We set
 default settings according to simulation, but need to tune these
 parameters after getting the real chip.
 
 I can't explain every change in detail here. The below information is
 just a rough description:
 
 PHY_REG_REV: Disable internal clkreq_tx, enable rx_pwst
 PHY_BPCR: No change, just turn the magic number to macro definitions
 PHY_PCR: Change OOBS sensitivity, from 60mV to 90mV
 PHY_RCR2: Control charge-pump current automatically
 PHY_FLD4: Use TX cmu reference clock
 PHY_RDR: Change RXDSEL from 30nF to 1.9nF
 PHY_RCR1: Change the duration between adp_st and asserting cp_en from
 0.32 us to 0.64us
 PHY_FLD3: Adjust internal timers
 PHY_TUNE: Fine tune the regulator12 output voltage
 
 Signed-off-by: Wei WANG wei_w...@realsil.com.cn
 ---
  drivers/mfd/rts5249.c|   48 --
  include/linux/mfd/rtsx_pci.h |   53 
 ++
  2 files changed, 99 insertions(+), 2 deletions(-)

Much better.

Applied, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 21/24] Staging: winbond: wb35tx: Replace printk with netdev_err

2013-09-16 Thread Iker Pedrosa
The previously used printk lacked the warning level, now we've got a more 
accurate way to know the error.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/wb35tx.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/winbond/wb35tx.c b/drivers/staging/winbond/wb35tx.c
index 8c25cbd..18b28f2 100644
--- a/drivers/staging/winbond/wb35tx.c
+++ b/drivers/staging/winbond/wb35tx.c
@@ -32,7 +32,7 @@ static void Wb35Tx_complete(struct urb *pUrb)
struct wb35_tx *pWb35Tx = pHwData-Wb35Tx;
struct wb35_mds *pMds = adapter-Mds;
 
-   printk(wb35: tx complete\n);
+   netdev_err(pUrb-dev, wb35: tx complete\n);
/* Variable setting */
pWb35Tx-EP4vm_state = VM_COMPLETED;
pWb35Tx-EP4VM_status = pUrb-status; /* Store the last result of Irp */
@@ -49,7 +49,7 @@ static void Wb35Tx_complete(struct urb *pUrb)
 
/* The URB is completed, check the result */
if (pWb35Tx-EP4VM_status != 0) {
-   printk(URB submission failed\n);
+   netdev_err(pUrb-dev, URB submission failed\n);
pWb35Tx-EP4vm_state = VM_STOP;
goto error;
}
@@ -96,7 +96,7 @@ static void Wb35Tx(struct wbsoft_priv *adapter)
pWb35Tx-EP4vm_state = VM_RUNNING;
retv = usb_submit_urb(pUrb, GFP_ATOMIC);
if (retv  0) {
-   printk(EP4 Tx Irp sending error\n);
+   netdev_err(pUrb-dev, EP4 Tx Irp sending error\n);
goto cleanup;
}
 
@@ -218,7 +218,7 @@ static void Wb35Tx_EP2VM_complete(struct urb *pUrb)
 
/* The Urb is completed, check the result */
if (pWb35Tx-EP2VM_status != 0) {
-   printk(EP2 IoCompleteRoutine return error\n);
+   netdev_err(pUrb-dev, EP2 IoCompleteRoutine return error\n);
pWb35Tx-EP2vm_state = VM_STOP;
goto error;
}
-- 
1.8.1.2

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


[PATCH v2 24/24] Staging: winbond: wbusb: changed sleep function from msleep to usleep

2013-09-16 Thread Iker Pedrosa
According to the documentation it is not recommended to use msleep for 1ms - 
20ms because it may sleep longer than 20ms. So, it is recommended to use usleep 
instead.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/wbusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
index a2868f2..f23bc1d 100644
--- a/drivers/staging/winbond/wbusb.c
+++ b/drivers/staging/winbond/wbusb.c
@@ -717,7 +717,7 @@ static int wb35_hw_init(struct ieee80211_hw *hw)
 
/* Waiting for HAL setting OK */
while (!hal_idle(pHwData))
-   msleep(10);
+   usleep(1);
 
MTO_Init(priv);
 
-- 
1.8.1.2

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


[PATCH v2 09/24] Staging: winbond: reg: first of the patches that fixes lines over 80 characters

2013-09-16 Thread Iker Pedrosa
First of the patches that fixes the lines over 80 characters in reg.c

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/reg.c | 26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/winbond/reg.c b/drivers/staging/winbond/reg.c
index c023fda..429c28e 100644
--- a/drivers/staging/winbond/reg.c
+++ b/drivers/staging/winbond/reg.c
@@ -809,12 +809,7 @@ u32 w89rf242_txvga_data[][5] = {
{(0x05  24) | 0x24C7CA, 34, 0x00292315, 0x0800FEFF, 0x72724242}
 };
 
-/* 
==
 */
-
-
-
 /*
- * 
=
  *  Uxx_ReadEthernetAddress --
  *
  *  Routine Description:
@@ -826,15 +821,15 @@ u32 w89rf242_txvga_data[][5] = {
  *  Return Value:
  *
  *The address is stored in EthernetIDAddr.
- * 
=
  */
 void Uxx_ReadEthernetAddress(struct hw_data *pHwData)
 {
u32 ltmp;
 
/*
-* Reading Ethernet address from EEPROM and set into hardware due to 
MAC address maybe change.
-* Only unplug and plug again can make hardware read EEPROM again.
+* Reading Ethernet address from EEPROM and set into hardware due to
+* MAC address maybe change. Only unplug and plug again can make
+* hardware read EEPROM again.
 */
Wb35Reg_WriteSync(pHwData, 0x03b4, 0x0800); /* Start EEPROM access 
+ Read + address(0x0d) */
Wb35Reg_ReadSync(pHwData, 0x03b4, ltmp);
@@ -852,18 +847,17 @@ void Uxx_ReadEthernetAddress(struct hw_data *pHwData)
 
 
 /*
- * 
===
  *  CardGetMulticastBit --
  *  Description:
- *For a given multicast address, returns the byte and bit in the card 
multicast registers that it hashes to.
- *Calls CardComputeCrc() to determine the CRC value.
+ *For a given multicast address, returns the byte and bit in the card
+ *multicast registers that it hashes to. Calls CardComputeCrc() to
+ *determine the CRC value.
  *  Arguments:
  *Address - the address
  *Byte - the byte that it hashes to
  *Value - will have a 1 in the relevant bit
  *  Return Value:
  *None.
- * 
==
  */
 void CardGetMulticastBit(u8 Address[ETH_ALEN], u8 *Byte, u8 *Value)
 {
@@ -926,7 +920,8 @@ static void Set_ChanIndep_RfData_al7230_24(struct hw_data 
*pHwData, u32 *pltmp,
u8  i;
for (i = 0; i  number; i++) {
pHwData-phy_para[i] = al7230_rf_data_24[i];
-   pltmp[i] = (1  31) | (0  30) | (24  24) | 
(al7230_rf_data_24[i]  0xff);
+   pltmp[i] = (1  31) | (0  30) | (24  24) |
+  (al7230_rf_data_24[i]  0xff);
}
 }
 
@@ -936,15 +931,14 @@ static void Set_ChanIndep_RfData_al7230_50(struct hw_data 
*pHwData, u32 *pltmp,
u8  i;
for (i = 0; i  number; i++) {
pHwData-phy_para[i] = al7230_rf_data_50[i];
-   pltmp[i] = (1  31) | (0  30) | (24  24) | 
(al7230_rf_data_50[i]  0xff);
+   pltmp[i] = (1  31) | (0  30) | (24  24)
+  | (al7230_rf_data_50[i]  0xff);
}
 }
 
 
 /*
- * 
=
  * RFSynthesizer_initial --
- * 
=
  */
 void RFSynthesizer_initial(struct hw_data *pHwData)
 {
-- 
1.8.1.2

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


[PATCH v2 18/24] Staging: winbond: wb35rx: changed sleep function from msleep to usleep

2013-09-16 Thread Iker Pedrosa
According to the documentation it is not recommended to use msleep for 1ms - 
20ms because it may sleep longer than 20ms. So, it is recommended to use usleep 
instead.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/wb35rx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/winbond/wb35rx.c b/drivers/staging/winbond/wb35rx.c
index 8d71bc2..48ed95c 100644
--- a/drivers/staging/winbond/wb35rx.c
+++ b/drivers/staging/winbond/wb35rx.c
@@ -339,9 +339,9 @@ void Wb35Rx_destroy(struct hw_data *pHwData)
struct wb35_rx *pWb35Rx = pHwData-Wb35Rx;
 
do {
-   msleep(10); /* Delay for waiting function enter */
+   usleep(1); /* Delay for waiting function enter */
} while (pWb35Rx-EP3vm_state != VM_STOP);
-   msleep(10); /* Delay for waiting function exit */
+   usleep(1); /* Delay for waiting function exit */
 
usb_free_urb(pWb35Rx-RxUrb);
pr_debug(Wb35Rx_destroy OK\n);
-- 
1.8.1.2

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


[PATCH v2 17/24] Staging: winbond: wb35reg_s: deleted space before tabulation

2013-09-16 Thread Iker Pedrosa
Deleted an space before a tabulation.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/wb35reg_s.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/winbond/wb35reg_s.h 
b/drivers/staging/winbond/wb35reg_s.h
index dc79faa..cdbbf35 100644
--- a/drivers/staging/winbond/wb35reg_s.h
+++ b/drivers/staging/winbond/wb35reg_s.h
@@ -12,7 +12,7 @@ struct hw_data;
  * HAL setting function
  *
  * 
- * |Uxx|   |Dxx|   |Mxx|   |BB||RF|
+ * |Uxx|   |Dxx|   |Mxx|   |BB||RF|
  * 
  * |   |
  * Wb35Reg_ReadWb35Reg_Write
-- 
1.8.1.2

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


[PATCH v2 08/24] Staging: winbond: reg: changed sleep function from msleep to usleep

2013-09-16 Thread Iker Pedrosa
According to the documentation it is not recommended to use msleep for 1ms - 
20ms because it may sleep longer than 20ms. So, it is recommended to use usleep 
instead.

In the first revision Greg KH pointed out that this change broke the build. In 
my computer it builds properly so if someone has the same problem please copy 
the output so that I can figure out what is the problem.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/reg.c | 54 +--
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/winbond/reg.c b/drivers/staging/winbond/reg.c
index 80b4b34..c023fda 100644
--- a/drivers/staging/winbond/reg.c
+++ b/drivers/staging/winbond/reg.c
@@ -890,9 +890,9 @@ void Uxx_power_on_procedure(struct hw_data *pHwData)
else {
Wb35Reg_WriteSync(pHwData, 0x03f4, 0xFF5807FF);
Wb35Reg_WriteSync(pHwData, 0x03d4, 0x80); /* regulator on only 
*/
-   msleep(10);
-   Wb35Reg_WriteSync(pHwData, 0x03d4, 0xb8); /* REG_ON RF_RSTN on, 
and */
-   msleep(10);
+   usleep(1);
+   Wb35Reg_WriteSync(pHwData, 0x03d4, 0xb8); /* REG_ON RF_RSTN on 
*/
+   usleep(1);
ltmp = 0x4968;
if ((pHwData-phy_type == RF_WB_242) ||
(RF_WB_242_1 == pHwData-phy_type))
@@ -905,7 +905,7 @@ void Uxx_power_on_procedure(struct hw_data *pHwData)
Wb35Reg_ReadSync(pHwData, 0x03d0, ltmp);
loop = 500; /* Wait for 5 second */
while (!(ltmp  0x20)  loop--) {
-   msleep(10);
+   usleep(1);
if (!Wb35Reg_ReadSync(pHwData, 0x03d0, ltmp))
break;
}
@@ -914,7 +914,7 @@ void Uxx_power_on_procedure(struct hw_data *pHwData)
}
 
Wb35Reg_WriteSync(pHwData, 0x03b0, 1); /* Reset hardware first */
-   msleep(10);
+   usleep(1);
 
/* Set burst write delay */
Wb35Reg_WriteSync(pHwData, 0x03f8, 0x7ff);
@@ -1055,18 +1055,18 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
case RF_AIROHA_2230:
ltmp = (1  31) | (0  30) | (20  24) | BitReverse((0x07  
20) | 0xE168E, 20);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
-   msleep(10);
+   usleep(1);
ltmp = (1  31) | (0  30) | (20  24) | 
BitReverse(al2230_rf_data[7], 20);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
-   msleep(10);
+   usleep(1);
case RF_AIROHA_2230S:
Wb35Reg_WriteSync(pHwData, 0x03d4, 0x80); /* regulator on only 
*/
-   msleep(10);
+   usleep(1);
Wb35Reg_WriteSync(pHwData, 0x03d4, 0xa0); /* PLL_PD REF_PD set 
to 0 */
-   msleep(10);
+   usleep(1);
Wb35Reg_WriteSync(pHwData, 0x03d4, 0xe0); /* MLK_EN */
Wb35Reg_WriteSync(pHwData, 0x03b0, 1); /* Reset hardware first 
*/
-   msleep(10);
+   usleep(1);
/* = */
 
/* The follow code doesn't use the burst-write mode */
@@ -1077,15 +1077,15 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
Wb35Reg_WriteSync(pHwData, 0x105c, ltmp);
pHwData-reg.BB50 |= 0x13; /* 
(MASK_IQCAL_MODE|MASK_CALIB_START) */
Wb35Reg_WriteSync(pHwData, 0x1050, pHwData-reg.BB50);
-   msleep(5);
+   usleep(5000);
 
ltmp = (1  31) | (0  30) | (20  24) | BitReverse((0x0F  
20) | 0xF01B0, 20);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
-   msleep(5);
+   usleep(5000);
 
ltmp = (1  31) | (0  30) | (20  24) | BitReverse((0x0F  
20) | 0xF01E0, 20);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
-   msleep(5);
+   usleep(5000);
 
ltmp = (1  31) | (0  30) | (20  24) | BitReverse((0x0F  
20) | 0xF01A0, 20);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
@@ -1102,13 +1102,13 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
/* 2.4GHz */
ltmp = (1  31) | (0  30) | (24  24) | 0x9ABA8F;
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
-   msleep(5);
+   usleep(5000);
ltmp = (1  31) | (0  30) | (24  24) | 0x3ABA8F;
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
-   msleep(5);
+   usleep(5000);
ltmp = (1  31) | (0  30) | (24  24) | 0x1ABA8F;
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
-   msleep(5);
+   usleep(5000);
 
/* 5GHz */
Wb35Reg_WriteSync(pHwData, 0x03dc, 

[PATCH v2 04/24] Staging: winbond: phy_calibration: first of the patches that fixes lines over 80 characters

2013-09-16 Thread Iker Pedrosa
First of the patches that fixes the lines over 80 characters in 
phy_calibration.c

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/phy_calibration.c | 46 ++-
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/winbond/phy_calibration.c 
b/drivers/staging/winbond/phy_calibration.c
index cfbfbbb..6635c85 100644
--- a/drivers/staging/winbond/phy_calibration.c
+++ b/drivers/staging/winbond/phy_calibration.c
@@ -27,10 +27,12 @@
 #define DEG2RAD(X)  (0.017453 * (X))
 
 static const s32 Angles[] = {
-   FIXED(DEG2RAD(45.0)), FIXED(DEG2RAD(26.565)),   
FIXED(DEG2RAD(14.0362)),
-   FIXED(DEG2RAD(7.12502)),  FIXED(DEG2RAD(3.57633)),  
FIXED(DEG2RAD(1.78991)),
-   FIXED(DEG2RAD(0.895174)), FIXED(DEG2RAD(0.447614)), 
FIXED(DEG2RAD(0.223811)),
-   FIXED(DEG2RAD(0.111906)), FIXED(DEG2RAD(0.055953)), 
FIXED(DEG2RAD(0.027977))
+   FIXED(DEG2RAD(45.0)), FIXED(DEG2RAD(26.565)),
+   FIXED(DEG2RAD(14.0362)),  FIXED(DEG2RAD(7.12502)),
+   FIXED(DEG2RAD(3.57633)),  FIXED(DEG2RAD(1.78991)),
+   FIXED(DEG2RAD(0.895174)), FIXED(DEG2RAD(0.447614)),
+   FIXED(DEG2RAD(0.223811)), FIXED(DEG2RAD(0.111906)),
+   FIXED(DEG2RAD(0.055953)), FIXED(DEG2RAD(0.027977))
 };
 
 /** LOCAL FUNCTION DECLARATION SECTION **/
@@ -296,7 +298,8 @@ void _sin_cos(s32 angle, s32 *sin, s32 *cos)
}
 }
 
-static unsigned char hal_get_dxx_reg(struct hw_data *pHwData, u16 number, u32 
*pValue)
+static unsigned char hal_get_dxx_reg(struct hw_data *pHwData, u16 number,
+u32 *pValue)
 {
if (number  0x1000)
number += 0x1000;
@@ -304,7 +307,8 @@ static unsigned char hal_get_dxx_reg(struct hw_data 
*pHwData, u16 number, u32 *p
 }
 #define hw_get_dxx_reg(_A, _B, _C) hal_get_dxx_reg(_A, _B, (u32 *)_C)
 
-static unsigned char hal_set_dxx_reg(struct hw_data *pHwData, u16 number, u32 
value)
+static unsigned char hal_set_dxx_reg(struct hw_data *pHwData, u16 number,
+u32 value)
 {
unsigned char ret;
 
@@ -407,7 +411,8 @@ void _rxadc_dc_offset_cancellation_winbond(struct hw_data 
*phw_data, u32 frequen
PHY_DEBUG(([CAL]** adc_dc_cal_i = %d (0x%04X)\n,
   _s9_to_s32(val0x01FF), val0x01FF));
PHY_DEBUG(([CAL]** adc_dc_cal_q = %d (0x%04X)\n,
-  _s9_to_s32((val0x0003FE00)9), 
(val0x0003FE00)9));
+  _s9_to_s32((val0x0003FE00)9),
+  (val0x0003FE00)9));
 #endif
 
hw_get_dxx_reg(phw_data, REG_MODE_CTRL, val);
@@ -535,7 +540,8 @@ void _txidac_dc_offset_cancellation_winbond(struct hw_data 
*phw_data)
}
 
PHY_DEBUG(([CAL]** fix_cancel_dc_i = %d (0x%04X)\n,
-  fix_cancel_dc_i, 
_s32_to_s5(fix_cancel_dc_i)));
+  fix_cancel_dc_i,
+  _s32_to_s5(fix_cancel_dc_i)));
 
if ((abs(mag_1-mag_0)*6)  mag_0)
break;
@@ -711,7 +717,8 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data,
loop = LOOP_TIMES;
 
while (loop  0) {
-   PHY_DEBUG(([CAL] [%d.] _tx_iq_calibration_loop\n, 
(LOOP_TIMES-loop+1)));
+   PHY_DEBUG(([CAL] [%d.] _tx_iq_calibration_loop\n,
+  (LOOP_TIMES-loop+1)));
 
iqcal_tone_i_avg = 0;
iqcal_tone_q_avg = 0;
@@ -719,8 +726,8 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data,
return 0;
for (capture_time = 0; capture_time  10; capture_time++) {
/*
-* a. Set iqcal_mode[1:0] to 0x2 and set calib_start 
to 0x1 to
-*enable IQ calibration Mode II
+* a. Set iqcal_mode[1:0] to 0x2 and set calib_start
+*to 0x1 to enable IQ calibration Mode II
 */
reg_mode_ctrl = ~(MASK_IQCAL_TONE_SEL|MASK_IQCAL_MODE);
reg_mode_ctrl = ~MASK_IQCAL_MODE;
@@ -749,8 +756,8 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data,
PHY_DEBUG(([CAL]MODE_CTRL (write) = 0x%08X\n, 
reg_mode_ctrl));
 
/*
-* d. Set iqcal_mode[1:0] to 0x3 and set calib_start 
to 0x1 to
-*enable IQ calibration Mode II
+* d. Set iqcal_mode[1:0] to 0x3 and set calib_start
+*to 0x1 to enable IQ calibration Mode II
 */
/* hw_get_dxx_reg(phw_data, REG_MODE_CTRL, val); */
hw_get_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl);
@@ -766,7 +773,7 @@ u8 

[PATCH v2 06/24] Staging: winbond: reg: erased trailing whitespace

2013-09-16 Thread Iker Pedrosa
Erased all the errors given by checkpatch stating trailing whitespace.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/reg.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/winbond/reg.c b/drivers/staging/winbond/reg.c
index 75b7752..5883d23 100644
--- a/drivers/staging/winbond/reg.c
+++ b/drivers/staging/winbond/reg.c
@@ -920,7 +920,7 @@ void Uxx_power_on_procedure(struct hw_data *pHwData)
Wb35Reg_WriteSync(pHwData, 0x03f8, 0x7ff);
 }
 
-static void Set_ChanIndep_RfData_al7230_24(struct hw_data *pHwData, u32 
*pltmp, 
+static void Set_ChanIndep_RfData_al7230_24(struct hw_data *pHwData, u32 *pltmp,
char number)
 {
u8  i;
@@ -930,7 +930,7 @@ static void Set_ChanIndep_RfData_al7230_24(struct hw_data 
*pHwData, u32 *pltmp,
}
 }
 
-static void Set_ChanIndep_RfData_al7230_50(struct hw_data *pHwData, u32 
*pltmp, 
+static void Set_ChanIndep_RfData_al7230_50(struct hw_data *pHwData, u32 *pltmp,
char number)
 {
u8  i;
@@ -1620,13 +1620,13 @@ void BBProcessor_initial(struct hw_data *pHwData)
reg-SQ3_filter[i] = 0x2f; /* half of Bit 0 ~ 6 */
 }
 
-static inline void set_tx_power_per_channel_max2829(struct hw_data *pHwData,  
+static inline void set_tx_power_per_channel_max2829(struct hw_data *pHwData,
struct chan_info Channel)
 {
RFSynthesizer_SetPowerIndex(pHwData, 100);
 }
 
-static void set_tx_power_per_channel_al2230(struct hw_data *pHwData,  
+static void set_tx_power_per_channel_al2230(struct hw_data *pHwData,
struct chan_info Channel)
 {
u8  index = 100;
@@ -1636,7 +1636,7 @@ static void set_tx_power_per_channel_al2230(struct 
hw_data *pHwData,
RFSynthesizer_SetPowerIndex(pHwData, index);
 }
 
-static void set_tx_power_per_channel_al7230(struct hw_data *pHwData,  
+static void set_tx_power_per_channel_al7230(struct hw_data *pHwData,
struct chan_info Channel)
 {
u8  i, index = 100;
@@ -1660,7 +1660,7 @@ static void set_tx_power_per_channel_al7230(struct 
hw_data *pHwData,
RFSynthesizer_SetPowerIndex(pHwData, index);
 }
 
-static void set_tx_power_per_channel_wb242(struct hw_data *pHwData,  
+static void set_tx_power_per_channel_wb242(struct hw_data *pHwData,
struct chan_info Channel)
 {
u8  index = 100;
-- 
1.8.1.2

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


[PATCH v2 01/24] Staging: winbond: mto: removed function declaration

2013-09-16 Thread Iker Pedrosa
The following function declarations have been removed because they aren't 
implemented.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/mto.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/winbond/mto.c b/drivers/staging/winbond/mto.c
index 560c0ab..0d0f9fb 100644
--- a/drivers/staging/winbond/mto.c
+++ b/drivers/staging/winbond/mto.c
@@ -46,10 +46,7 @@ static int retryrate_rec[MTO_MAX_DATA_RATE_LEVELS];
 static u8 boSparseTxTraffic;
 
 void MTO_Init(struct wbsoft_priv *adapter);
-void TxRateReductionCtrl(struct wbsoft_priv *adapter);
 void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 t0, u8 index);
-void MTO_TxFailed(struct wbsoft_priv *adapter);
-void hal_get_dto_para(struct wbsoft_priv *adapter, char *buffer);
 
 /*
  * ===
-- 
1.8.1.2

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


[PATCH v2 23/24] Staging: winbond: wbusb: fixed some lines over 80 characters

2013-09-16 Thread Iker Pedrosa
Fixed some lines over 80 characters.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/wbusb.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
index 3fa1ae4..a2868f2 100644
--- a/drivers/staging/winbond/wbusb.c
+++ b/drivers/staging/winbond/wbusb.c
@@ -169,7 +169,8 @@ static void hal_set_radio_mode(struct hw_data *pHwData, 
unsigned char radio_off)
Wb35Reg_Write(pHwData, 0x0824, reg-M24_MacControl);
 }
 
-static void hal_set_current_channel_ex(struct hw_data *pHwData, struct 
chan_info channel)
+static void hal_set_current_channel_ex(struct hw_data *pHwData,
+  struct chan_info channel)
 {
struct wb35_reg *reg = pHwData-reg;
 
@@ -186,7 +187,8 @@ static void hal_set_current_channel_ex(struct hw_data 
*pHwData, struct chan_info
   sizeof(struct chan_info));
 }
 
-static void hal_set_current_channel(struct hw_data *pHwData, struct chan_info 
channel)
+static void hal_set_current_channel(struct hw_data *pHwData,
+   struct chan_info channel)
 {
hal_set_current_channel_ex(pHwData, channel);
 }
@@ -206,7 +208,9 @@ static void hal_set_accept_broadcast(struct hw_data 
*pHwData, u8 enable)
Wb35Reg_Write(pHwData, 0x0800, reg-M00_MacControl);
 }
 
-/* For wep key error detection, we need to accept broadcast packets to be 
received temporary. */
+/* For wep key error detection, we need to accept broadcast packets to be
+ * received temporary.
+*/
 static void hal_set_accept_promiscuous(struct hw_data *pHwData, u8 enable)
 {
struct wb35_reg *reg = pHwData-reg;
@@ -290,7 +294,8 @@ static const struct ieee80211_ops wbsoft_ops = {
.get_tsf= wbsoft_get_tsf,
 };
 
-static void hal_set_ethernet_address(struct hw_data *pHwData, u8 
*current_address)
+static void hal_set_ethernet_address(struct hw_data *pHwData,
+u8 *current_address)
 {
u32 ltmp[2];
 
@@ -305,7 +310,8 @@ static void hal_set_ethernet_address(struct hw_data 
*pHwData, u8 *current_addres
Wb35Reg_BurstWrite(pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT);
 }
 
-static void hal_get_permanent_address(struct hw_data *pHwData, u8 
*pethernet_address)
+static void hal_get_permanent_address(struct hw_data *pHwData,
+ u8 *pethernet_address)
 {
if (pHwData-SurpriseRemove)
return;
-- 
1.8.1.2

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


[PATCH v2 11/24] Staging: winbond: reg: third of the patches that fixes lines over 80 characters

2013-09-16 Thread Iker Pedrosa
Third of the patches that fixes the lines over 80 characters in reg.c

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/reg.c | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/winbond/reg.c b/drivers/staging/winbond/reg.c
index a65e8ce..6aae4da 100644
--- a/drivers/staging/winbond/reg.c
+++ b/drivers/staging/winbond/reg.c
@@ -1083,15 +1083,18 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
Wb35Reg_WriteSync(pHwData, 0x1050, pHwData-reg.BB50);
usleep(5000);
 
-   ltmp = (1  31) | (0  30) | (20  24) | BitReverse((0x0F  
20) | 0xF01B0, 20);
+   ltmp = (1  31) | (0  30) | (20  24)
+  | BitReverse((0x0F  20) | 0xF01B0, 20);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
usleep(5000);
 
-   ltmp = (1  31) | (0  30) | (20  24) | BitReverse((0x0F  
20) | 0xF01E0, 20);
+   ltmp = (1  31) | (0  30) | (20  24)
+  | BitReverse((0x0F  20) | 0xF01E0, 20);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
usleep(5000);
 
-   ltmp = (1  31) | (0  30) | (20  24) | BitReverse((0x0F  
20) | 0xF01A0, 20);
+   ltmp = (1  31) | (0  30) | (20  24)
+  | BitReverse((0x0F  20) | 0xF01A0, 20);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
 
Wb35Reg_WriteSync(pHwData, 0x105c, pHwData-reg.BB5C);
@@ -1149,30 +1152,37 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
 
/* - Calibration (1). VCO frequency calibration */
/* Calibration (1a.0). Synthesizer reset */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0F24) | 0x00101E, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0F24) | 0x00101E, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
usleep(5000);
/* Calibration (1a). VCO frequency calibration mode ; waiting 
2msec VCO calibration time */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xFE69c0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xFE69c0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
usleep(2000);
 
/* - Calibration (2). TX baseband Gm-C filter auto-tuning */
/* Calibration (2a). turn off ENCAL signal */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xF8EBC0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xF8EBC0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
/* Calibration (2b.0). TX filter auto-tuning BW: TFLBW=101 
(TC5376A default) */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0724) | 0x0C68CE, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0724) | 0x0C68CE, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
/* Calibration (2b). send TX reset signal */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0F24) | 0x00201E, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0F24) | 0x00201E, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
/* Calibration (2c). turn-on TX Gm-C filter auto-tuning */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xFCEBC0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xFCEBC0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
udelay(150); /* Sleep 150 us */
/* turn off ENCAL signal */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xF8EBC0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xF8EBC0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
 
/* - Calibration (3). RX baseband Gm-C filter auto-tuning */
-- 
1.8.1.2

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


[PATCH v2 15/24] Staging: winbond: reg: seventh of the patches that fixes lines over 80 characters

2013-09-16 Thread Iker Pedrosa
Seventh of the patches that fixes the lines over 80 characters in reg.c

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/reg.c | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/winbond/reg.c b/drivers/staging/winbond/reg.c
index e51530e..3b19da8 100644
--- a/drivers/staging/winbond/reg.c
+++ b/drivers/staging/winbond/reg.c
@@ -2060,7 +2060,8 @@ u8 RFSynthesizer_SetWinbond242Power(struct hw_data 
*pHwData, u8 index)
i--;
 
/* Set TxVga into RF */
-   PowerData = (1  31) | (0  30) | (24  24) | 
BitReverse(w89rf242_txvga_data[i][0], 24);
+   PowerData = (1  31) | (0  30) | (24  24)
+   | BitReverse(w89rf242_txvga_data[i][0], 24);
Wb35Reg_Write(pHwData, 0x0864, PowerData);
 
/* Update BB48 BB4C BB58 for high precision txvga */
@@ -2136,11 +2137,15 @@ void Mxx_initial(struct hw_data *pHwData)
pltmp[4] = tmp;
 
/* M38 */
-   reg-M38_MacControl = (DEFAULT_RATE_RETRY_LIMIT  8) | 
(DEFAULT_LONG_RETRY_LIMIT  4) | DEFAULT_SHORT_RETRY_LIMIT;
+   reg-M38_MacControl = (DEFAULT_RATE_RETRY_LIMIT  8) |
+  (DEFAULT_LONG_RETRY_LIMIT  4) |
+  DEFAULT_SHORT_RETRY_LIMIT;
pltmp[5] = reg-M38_MacControl;
 
/* M3C */
-   tmp = (DEFAULT_PIFST  26) | (DEFAULT_EIFST  16) | (DEFAULT_DIFST  
8) | (DEFAULT_SIFST  4) | DEFAULT_OSIFST;
+   tmp = (DEFAULT_PIFST  26) | (DEFAULT_EIFST  16) |
+  (DEFAULT_DIFST  8) | (DEFAULT_SIFST  4) |
+  DEFAULT_OSIFST;
reg-M3C_MacControl = tmp;
pltmp[6] = tmp;
 
@@ -2163,7 +2168,9 @@ void Mxx_initial(struct hw_data *pHwData)
pltmp[9] = tmp;
 
/* M4C */
-   reg-M4C_MacStatus = (DEFAULT_PROTOCOL_VERSION  30) | 
(DEFAULT_MAC_POWER_STATE  28) | (DEFAULT_DTIM_ALERT_TIME  24);
+   reg-M4C_MacStatus = (DEFAULT_PROTOCOL_VERSION  30) |
+ (DEFAULT_MAC_POWER_STATE  28) |
+ (DEFAULT_DTIM_ALERT_TIME  24);
pltmp[10] = reg-M4C_MacStatus;
 
for (i = 0; i  11; i++)
@@ -2235,10 +2242,11 @@ void GetTxVgaFromEEPROM(struct hw_data *pHwData)
 }
 
 /*
- * This function will affect the TxVga parameter in HAL. If 
hal_set_current_channel
- * or RFSynthesizer_SetPowerIndex be called, new TxVga will take effect.
- * TxVgaSettingInEEPROM of sHwData is an u8 array point to EEPROM contain for 
IS89C35
- * This function will use default TxVgaSettingInEEPROM data to calculate new 
TxVga.
+ * This function will affect the TxVga parameter in HAL. If
+ * hal_set_current_channel or RFSynthesizer_SetPowerIndex be called, new TxVga
+ * will take effect. TxVgaSettingInEEPROM of sHwData is an u8 array point to
+ * EEPROM contain for IS89C35. This function will use default
+ * TxVgaSettingInEEPROM data to calculate new TxVga.
  */
 void EEPROMTxVgaAdjust(struct hw_data *pHwData)
 {
-- 
1.8.1.2

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


[PATCH v2 07/24] Staging: winbond: reg: white space deleted

2013-09-16 Thread Iker Pedrosa
White space deleted before semicolons.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/reg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/winbond/reg.c b/drivers/staging/winbond/reg.c
index 5883d23..80b4b34 100644
--- a/drivers/staging/winbond/reg.c
+++ b/drivers/staging/winbond/reg.c
@@ -1088,7 +1088,7 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
msleep(5);
 
ltmp = (1  31) | (0  30) | (20  24) | BitReverse((0x0F  
20) | 0xF01A0, 20);
-   Wb35Reg_WriteSync(pHwData, 0x0864, ltmp) ;
+   Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
 
Wb35Reg_WriteSync(pHwData, 0x105c, pHwData-reg.BB5C);
pHwData-reg.BB50 = ~0x13; /* 
(MASK_IQCAL_MODE|MASK_CALIB_START); */
@@ -2096,7 +2096,7 @@ void Mxx_initial(struct hw_data *pHwData)
pltmp[5] = reg-M38_MacControl;
 
/* M3C */
-   tmp = (DEFAULT_PIFST  26) | (DEFAULT_EIFST  16) | (DEFAULT_DIFST  
8) | (DEFAULT_SIFST  4) | DEFAULT_OSIFST ;
+   tmp = (DEFAULT_PIFST  26) | (DEFAULT_EIFST  16) | (DEFAULT_DIFST  
8) | (DEFAULT_SIFST  4) | DEFAULT_OSIFST;
reg-M3C_MacControl = tmp;
pltmp[6] = tmp;
 
-- 
1.8.1.2

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


[PATCH v2 03/24] Staging: winbond: mto: deleted extern functions

2013-09-16 Thread Iker Pedrosa
Deleted declaration of external functions that weren't used on this driver.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/mto.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/winbond/mto.h b/drivers/staging/winbond/mto.h
index 22bb264..8d41eed 100644
--- a/drivers/staging/winbond/mto.h
+++ b/drivers/staging/winbond/mto.h
@@ -129,10 +129,6 @@ extern u16 MTO_Frag_Th_Tbl[];
 
 void MTO_Init(struct wbsoft_priv *);
 void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 t0, u8 index);
-extern void MTO_PeriodicTimerExpired(struct wbsoft_priv *);
-extern void MTO_SetDTORateRange(struct wbsoft_priv *, u8 *, u8);
-extern u8 MTO_GetTxRate(struct wbsoft_priv *adapter, u32 fpdu_len);
-extern u8 MTO_GetTxFallbackRate(struct wbsoft_priv *adapter);
 
 #endif /* __MTO_H__ */
 
-- 
1.8.1.2

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


[PATCH v2 05/24] Staging: winbond: phy_calibration: second of the patches that fixes lines over 80 characters

2013-09-16 Thread Iker Pedrosa
Second of the patches that fixes the lines over 80 characters in 
phy_calibration.c

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/phy_calibration.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/winbond/phy_calibration.c 
b/drivers/staging/winbond/phy_calibration.c
index 6635c85..7fc95ee 100644
--- a/drivers/staging/winbond/phy_calibration.c
+++ b/drivers/staging/winbond/phy_calibration.c
@@ -1233,8 +1233,10 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data 
*phw_data, u16 factor, u32 fre
b_2 = (rot_image_q_b * 32768) / rot_tone_i_b -
phw_data-iq_rsdl_phase_tx_d2;
 
-   PHY_DEBUG(([CAL]** iq_rsdl_gain_tx_d2 = %d\n, 
phw_data-iq_rsdl_gain_tx_d2));
-   PHY_DEBUG(([CAL]** iq_rsdl_phase_tx_d2= %d\n, 
phw_data-iq_rsdl_phase_tx_d2));
+   PHY_DEBUG(([CAL]** iq_rsdl_gain_tx_d2 = %d\n,
+  phw_data-iq_rsdl_gain_tx_d2));
+   PHY_DEBUG(([CAL]** iq_rsdl_phase_tx_d2= %d\n,
+  phw_data-iq_rsdl_phase_tx_d2));
PHY_DEBUG(([CAL]* EPSILON/2 = %d\n, a_2));
PHY_DEBUG(([CAL]* THETA/2   = %d\n, b_2));
 
@@ -1280,7 +1282,8 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data 
*phw_data, u16 factor, u32 fre
 
/* e. */
pwr_tone = (iqcal_tone_i*iqcal_tone_i + 
iqcal_tone_q*iqcal_tone_q);
-   pwr_image = (iqcal_image_i*iqcal_image_i + 
iqcal_image_q*iqcal_image_q)*factor;
+   pwr_image = (iqcal_image_i*iqcal_image_i +
+iqcal_image_q*iqcal_image_q)*factor;
 
PHY_DEBUG(([CAL]** pwr_tone  = %d\n, pwr_tone));
PHY_DEBUG(([CAL]** pwr_image  = %d\n, pwr_image));
@@ -1577,7 +1580,8 @@ unsigned char adjust_TXVGA_for_iq_mag(struct hw_data 
*phw_data)
 
sqsum = iqcal_tone_i0*iqcal_tone_i0 + 
iqcal_tone_q0*iqcal_tone_q0;
iq_mag_0_tx = (s32) _sqrt(sqsum);
-   PHY_DEBUG(([CAL]** 
auto_adjust_txvga_for_iq_mag_0_tx=%d\n, iq_mag_0_tx));
+   PHY_DEBUG(([CAL]** auto_adjust_txvga_for_iq_mag_0_tx=%d\n,
+  iq_mag_0_tx));
 
if (iq_mag_0_tx = 700  iq_mag_0_tx = 1750)
break;
-- 
1.8.1.2

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


[PATCH v2 00/24] Staging: winbond: Fixed some coding style issues

2013-09-16 Thread Iker Pedrosa
Fixes some coding style issues from drivers/staging/winbond

Iker Pedrosa (24):
  Staging: winbond: mto: removed function declaration
  Staging: winbond: mto: avoided use of extern functions
  Staging: winbond: mto: deleted extern functions
  Staging: winbond: phy_calibration: first of the patches that fixes
lines over 80 characters
  Staging: winbond: phy_calibration: second of the patches that fixes
lines over 80 characters
  Staging: winbond: reg: erased trailing whitespace
  Staging: winbond: reg: white space deleted
  Staging: winbond: reg: changed sleep function from msleep to usleep
  Staging: winbond: reg: first of the patches that fixes lines over 80
characters
  Staging: winbond: reg: second of the patches that fixes lines over 80
characters
  Staging: winbond: reg: third of the patches that fixes lines over 80
characters
  Staging: winbond: reg: fourth of the patches that fixes lines over 80
characters
  Staging: winbond: reg: fifth of the patches that fixes lines over 80
characters
  Staging: winbond: reg: sixth of the patches that fixes lines over 80
characters
  Staging: winbond: reg: seventh of the patches that fixes lines over 80
characters
  Staging: winbond: wb35reg_f: fixed lines over 80 characters
  Staging: winbond: wb35reg_s: deleted space before tabulation
  Staging: winbond: wb35rx: changed sleep function from msleep to usleep
  Staging: winbond: wb35rx: fixed some lines over 80 characters
  Staging: winbond: wb35tx: changed sleep function from msleep to usleep
  Staging: winbond: wb35tx: Replace printk with netdev_err
  Staging: winbond: wb35tx_s: erased the spaces after opening a '['
  Staging: winbond: wbusb: fixed some lines over 80 characters
  Staging: winbond: wbusb: changed sleep function from msleep to usleep

 drivers/staging/winbond/mto.c |   7 +-
 drivers/staging/winbond/mto.h |   8 +-
 drivers/staging/winbond/phy_calibration.c |  58 ---
 drivers/staging/winbond/reg.c | 272 ++
 drivers/staging/winbond/wb35reg_f.h   |  18 +-
 drivers/staging/winbond/wb35reg_s.h   |   2 +-
 drivers/staging/winbond/wb35rx.c  |  11 +-
 drivers/staging/winbond/wb35tx.c  |  12 +-
 drivers/staging/winbond/wb35tx_s.h|   2 +-
 drivers/staging/winbond/wbusb.c   |  18 +-
 10 files changed, 239 insertions(+), 169 deletions(-)

-- 
1.8.1.2

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


[PATCH v2 12/24] Staging: winbond: reg: fourth of the patches that fixes lines over 80 characters

2013-09-16 Thread Iker Pedrosa
Fourth of the patches that fixes the lines over 80 characters in reg.c

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/reg.c | 33 ++---
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/winbond/reg.c b/drivers/staging/winbond/reg.c
index 6aae4da..6d2ab1e 100644
--- a/drivers/staging/winbond/reg.c
+++ b/drivers/staging/winbond/reg.c
@@ -1187,46 +1187,57 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
 
/* - Calibration (3). RX baseband Gm-C filter auto-tuning */
/* Calibration (3a). turn off ENCAL signal */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xFAEDC0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xFAEDC0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
/* Calibration (3b.0). RX filter auto-tuning BW: RFLBW=100 
(TC5376A+corner default;) */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0724) | 0x0C68CE, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0724) | 0x0C68CE, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
/* Calibration (3b). send RX reset signal */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0F24) | 0x00401E, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0F24) | 0x00401E, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
/* Calibration (3c). turn-on RX Gm-C filter auto-tuning */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xFEEDC0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xFEEDC0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
udelay(150); /* Sleep 150 us */
/* Calibration (3e). turn off ENCAL signal */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xFAEDC0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xFAEDC0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
 
/* - Calibration (4). TX LO leakage calibration */
/* Calibration (4a). TX LO leakage calibration */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xFD6BC0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xFD6BC0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
udelay(150); /* Sleep 150 us */
 
/* - Calibration (5). RX DC offset calibration */
/* Calibration (5a). turn off ENCAL signal and set to RX SW DC 
calibration mode */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xFAEDC0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xFAEDC0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
/* Calibration (5b). turn off AGC servo-loop  RSSI */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0124) | 0xEBFFC2, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0124) | 0xEBFFC2, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
 
/* for LNA=11  */
/* Calibration (5c-h). RX DC offset current bias ON;  LNA=11; 
RXVGA=11 */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0624) | 0x343FCC, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0624) | 0x343FCC, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
/* Calibration (5d). turn on RX DC offset cal function; and 
waiting 2 msec cal time */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xFF6DC0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xFF6DC0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
usleep(2000);
/* Calibration (5f). turn off ENCAL signal */
-   ltmp = (1  31) | (0  30) | (24  24) | 
BitReverse((0x0024) | 0xFAEDC0, 24);
+   ltmp = (1  31) | (0  30) | (24  24)
+  | BitReverse((0x0024) | 0xFAEDC0, 24);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
 
/* for LNA=10  */
-- 
1.8.1.2

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


[PATCH v2 02/24] Staging: winbond: mto: avoided use of extern functions

2013-09-16 Thread Iker Pedrosa
Prototype of two functions added to the header to avoid the use of extern.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/mto.c | 4 +---
 drivers/staging/winbond/mto.h | 4 ++--
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/winbond/mto.c b/drivers/staging/winbond/mto.c
index 0d0f9fb..b031ecd 100644
--- a/drivers/staging/winbond/mto.c
+++ b/drivers/staging/winbond/mto.c
@@ -21,6 +21,7 @@
 #include wbhal.h
 #include wb35reg_f.h
 #include core.h
+#include mto.h
 
 /* Declare SQ3 to rate and fragmentation threshold table */
 /* Declare fragmentation threshold table */
@@ -45,9 +46,6 @@ static int retryrate_rec[MTO_MAX_DATA_RATE_LEVELS];
 
 static u8 boSparseTxTraffic;
 
-void MTO_Init(struct wbsoft_priv *adapter);
-void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 t0, u8 index);
-
 /*
  * ===
  * MTO_Init --
diff --git a/drivers/staging/winbond/mto.h b/drivers/staging/winbond/mto.h
index a0f659c..22bb264 100644
--- a/drivers/staging/winbond/mto.h
+++ b/drivers/staging/winbond/mto.h
@@ -127,12 +127,12 @@ extern u16 MTO_Frag_Th_Tbl[];
 #define MTO_DATA_RATE()
MTO_Data_Rate_Tbl[MTO_RATE_LEVEL()]
 #define MTO_FRAG_TH()  MTO_Frag_Th_Tbl[MTO_FRAG_TH_LEVEL()]
 
-extern void MTO_Init(struct wbsoft_priv *);
+void MTO_Init(struct wbsoft_priv *);
+void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 t0, u8 index);
 extern void MTO_PeriodicTimerExpired(struct wbsoft_priv *);
 extern void MTO_SetDTORateRange(struct wbsoft_priv *, u8 *, u8);
 extern u8 MTO_GetTxRate(struct wbsoft_priv *adapter, u32 fpdu_len);
 extern u8 MTO_GetTxFallbackRate(struct wbsoft_priv *adapter);
-extern void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 t0, u8 index);
 
 #endif /* __MTO_H__ */
 
-- 
1.8.1.2

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


[PATCH v2 19/24] Staging: winbond: wb35rx: fixed some lines over 80 characters

2013-09-16 Thread Iker Pedrosa
Fixed some lines over 80 characters.

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/wb35rx.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/winbond/wb35rx.c b/drivers/staging/winbond/wb35rx.c
index 48ed95c..999b7046 100644
--- a/drivers/staging/winbond/wb35rx.c
+++ b/drivers/staging/winbond/wb35rx.c
@@ -16,7 +16,8 @@
 #include core.h
 #include wb35rx_f.h
 
-static void packet_came(struct ieee80211_hw *hw, char *pRxBufferAddress, int 
PacketSize)
+static void packet_came(struct ieee80211_hw *hw, char *pRxBufferAddress,
+   int PacketSize)
 {
struct wbsoft_priv *priv = hw-priv;
struct sk_buff *skb;
@@ -306,7 +307,9 @@ static void Wb35Rx_reset_descriptor(struct hw_data *pHwData)
pWb35Rx-EP3vm_state = VM_STOP;
pWb35Rx-rx_halt = 0;
 
-   /* Initial the Queue. The last buffer is reserved for used if the Rx 
resource is unavailable. */
+   /* Initial the Queue. The last buffer is reserved for used if the Rx
+* resource is unavailable.
+   */
for (i = 0; i  MAX_USB_RX_BUFFER_NUMBER; i++)
pWb35Rx-RxOwner[i] = 1;
 }
-- 
1.8.1.2

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


[PATCH v2 10/24] Staging: winbond: reg: second of the patches that fixes lines over 80 characters

2013-09-16 Thread Iker Pedrosa
Second of the patches that fixes the lines over 80 characters in reg.c

Signed-off-by: Iker Pedrosa ikerpedro...@gmail.com
---
 drivers/staging/winbond/reg.c | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/winbond/reg.c b/drivers/staging/winbond/reg.c
index 429c28e..a65e8ce 100644
--- a/drivers/staging/winbond/reg.c
+++ b/drivers/staging/winbond/reg.c
@@ -964,42 +964,48 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
number = ARRAY_SIZE(max2825_rf_data);
for (i = 0; i  number; i++) {
pHwData-phy_para[i] = max2825_rf_data[i]; /* Backup Rf 
parameter */
-   pltmp[i] = (1  31) | (0  30) | (18  24) | 
BitReverse(max2825_rf_data[i], 18);
+   pltmp[i] = (1  31) | (0  30) | (18  24)
+  | BitReverse(max2825_rf_data[i], 18);
}
break;
case RF_MAXIM_2827:
number = ARRAY_SIZE(max2827_rf_data);
for (i = 0; i  number; i++) {
pHwData-phy_para[i] = max2827_rf_data[i];
-   pltmp[i] = (1  31) | (0  30) | (18  24) | 
BitReverse(max2827_rf_data[i], 18);
+   pltmp[i] = (1  31) | (0  30) | (18  24)
+  | BitReverse(max2827_rf_data[i], 18);
}
break;
case RF_MAXIM_2828:
number = ARRAY_SIZE(max2828_rf_data);
for (i = 0; i  number; i++) {
pHwData-phy_para[i] = max2828_rf_data[i];
-   pltmp[i] = (1  31) | (0  30) | (18  24) | 
BitReverse(max2828_rf_data[i], 18);
+   pltmp[i] = (1  31) | (0  30) | (18  24)
+  | BitReverse(max2828_rf_data[i], 18);
}
break;
case RF_MAXIM_2829:
number = ARRAY_SIZE(max2829_rf_data);
for (i = 0; i  number; i++) {
pHwData-phy_para[i] = max2829_rf_data[i];
-   pltmp[i] = (1  31) | (0  30) | (18  24) | 
BitReverse(max2829_rf_data[i], 18);
+   pltmp[i] = (1  31) | (0  30) | (18  24)
+  | BitReverse(max2829_rf_data[i], 18);
}
break;
case RF_AIROHA_2230:
number = ARRAY_SIZE(al2230_rf_data);
for (i = 0; i  number; i++) {
pHwData-phy_para[i] = al2230_rf_data[i];
-   pltmp[i] = (1  31) | (0  30) | (20  24) | 
BitReverse(al2230_rf_data[i], 20);
+   pltmp[i] = (1  31) | (0  30) | (20  24)
+  | BitReverse(al2230_rf_data[i], 20);
}
break;
case RF_AIROHA_2230S:
number = ARRAY_SIZE(al2230s_rf_data);
for (i = 0; i  number; i++) {
pHwData-phy_para[i] = al2230s_rf_data[i];
-   pltmp[i] = (1  31) | (0  30) | (20  24) | 
BitReverse(al2230s_rf_data[i], 20);
+   pltmp[i] = (1  31) | (0  30) | (20  24)
+  | BitReverse(al2230s_rf_data[i], 20);
}
break;
case RF_AIROHA_7230:
@@ -1020,7 +1026,8 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
}
 
pHwData-phy_para[i] = ltmp;
-   pltmp[i] = (1  31) | (0  30) | (24  24) | 
BitReverse(ltmp, 24);
+   pltmp[i] = (1  31) | (0  30) | (24  24)
+  | BitReverse(ltmp, 24);
}
break;
}
@@ -1047,10 +1054,12 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
 
switch (pHwData-phy_type) {
case RF_AIROHA_2230:
-   ltmp = (1  31) | (0  30) | (20  24) | BitReverse((0x07  
20) | 0xE168E, 20);
+   ltmp = (1  31) | (0  30) | (20  24)
+  | BitReverse((0x07  20) | 0xE168E, 20);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
usleep(1);
-   ltmp = (1  31) | (0  30) | (20  24) | 
BitReverse(al2230_rf_data[7], 20);
+   ltmp = (1  31) | (0  30) | (20  24)
+  | BitReverse(al2230_rf_data[7], 20);
Wb35Reg_WriteSync(pHwData, 0x0864, ltmp);
usleep(1);
case RF_AIROHA_2230S:
@@ -1064,7 +1073,8 @@ void RFSynthesizer_initial(struct hw_data *pHwData)
/* = */
 
/* The follow code doesn't use the burst-write mode */
-   ltmp = (1  31) | (0  30) | (20  24) | 
BitReverse((0x0F20) | 0xF01A0, 20);
+   ltmp = (1  31) | (0  30) | (20  24)
+

Re: [PATCH 4/6] Staging/iio/adc/touchscreen/MXS: add i.MX23 support to the LRADC touchscreen driver

2013-09-16 Thread Marek Vasut
Dear Jürgen Beisert,

 Hi Jonathan,
 
 On Sunday 15 September 2013 12:50:09 Jonathan Cameron wrote:
  On 09/11/13 09:18, Juergen Beisert wrote:
   Distinguish i.MX23 and i.MX28 at runtime and do the same for both SoC
   at least for the 4 wire touchscreen.
   
   Note: support for the remaining LRADC channels is not tested on an
   i.MX23 yet.
  
  An ominous comment. Are you likely to test them soon?
 
 Sorry, currently no i.MX28 hardware available. Someone out here with an
 i.MX28 based system with a touchscreen to test?

You mean 23, no? I can test both, I have the DENX EVK as well as both MX23EVK 
and MX28EVK. Just need to find some more time to do my maintainance rounds, but 
that should happen this week nonetheless. If I do forget, please ping me again.

  Minor code layout comment inline but otherwise I'm just looking for an
  ack from Marek.
  
   [...]
   
static u32 mxs_lradc_drive_pressure(struct mxs_lradc *lradc)
{
   
   + if (lradc-soc == IMX23_LRADC)
   + return LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_XM;
   
 return LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_XNNSW;
  
  Whilst it obviously doesn't actually matter, having an else
  in there would make the code more consistent so personally
  I would prefer it to be there.
 
 I can change it. Anyone here with objections against such a change?
 
 Regards
 Juergen

Best regards,
Marek Vasut
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 5/6] Staging/iio/adc/touchscreen/MXS: add interrupt driven touch detection

2013-09-16 Thread Marek Vasut
Dear Jürgen Beisert,

 Hi Jonathan,
 
 On Sunday 15 September 2013 12:56:25 Jonathan Cameron wrote:
  On 09/11/13 09:18, Juergen Beisert wrote:
   For battery driven systems it is a very bad idea to collect the
   touchscreen data within a kernel busy loop.
   
   This change uses the features of the hardware to delay and accumulate
   samples in hardware to avoid a high interrupt and CPU load.
   
   Note: this is only tested on an i.MX23 SoC yet.
   
   Signed-off-by: Juergen Beisert j...@pengutronix.de
   CC: linux-arm-ker...@lists.infradead.org
   CC: de...@driverdev.osuosl.org
   CC: Marek Vasut ma...@denx.de
   CC: Fabio Estevam fabio.este...@freescale.com
   CC: Jonathan Cameron ji...@cam.ac.uk
  
  While this driver is placed in IIO within staging at the moment, these
  changes are definitely input related.  Hence I have cc'd Dmitry and the
  input list.
  
  I am personaly a little uncomfortable that we have such a complex bit of
  input code sat within an IIO driver but such is life.
 
 Maybe an MFD for this ADC unit would be a better way to go? Currently I
 have a different problem with this driver, because the ADC unit monitors
 the battery as well. And the charging driver from the power subsystem
 needs these values to charge the battery in a correct manner.

Are you planning to post the power block patches too ?

Best regards,
Marek Vasut
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread KY Srinivasan


 -Original Message-
 From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
 Sent: Monday, September 16, 2013 1:21 AM
 To: KY Srinivasan
 Cc: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
 de...@linuxdriverproject.org; linux-in...@vger.kernel.org;
 dmitry.torok...@gmail.com; vojt...@suse.cz; o...@aepfle.de;
 a...@canonical.com; jasow...@redhat.com
 Subject: Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V
 synthetic keyboard
 
 The main thing is that could you improve the error handling in
 hv_kbd_on_channel_callback() explained inline.

Thanks Dan. I will address all the relevant issues you have pointed out.
I have answered/responded to your comments in-line.
 
 On Sun, Sep 15, 2013 at 10:28:54PM -0700, K. Y. Srinivasan wrote:
  Add a new driver to support synthetic keyboard. On the next generation
  Hyper-V guest firmware, many legacy devices will not be emulated and this
  driver will be required.
 
  I would like to thank Vojtech Pavlik vojt...@suse.cz for helping me with 
  the
  details of the AT keyboard driver.
 
  Signed-off-by: K. Y. Srinivasan k...@microsoft.com
  ---
   drivers/input/serio/Kconfig   |7 +
   drivers/input/serio/Makefile  |1 +
   drivers/input/serio/hyperv-keyboard.c |  379
 +
   3 files changed, 387 insertions(+), 0 deletions(-)
   create mode 100644 drivers/input/serio/hyperv-keyboard.c
 
  diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
  index 1e691a3..f3996e7 100644
  --- a/drivers/input/serio/Kconfig
  +++ b/drivers/input/serio/Kconfig
  @@ -267,4 +267,11 @@ config SERIO_OLPC_APSP
To compile this driver as a module, choose M here: the module will
be called olpc_apsp.
 
  +config HYPERV_KEYBOARD
  +   tristate Microsoft Synthetic Keyboard driver
  +   depends on HYPERV
  +   default HYPERV
  +   help
  + Select this option to enable the Hyper-V Keyboard driver.
  +
   endif
  diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
  index 12298b1..815d874 100644
  --- a/drivers/input/serio/Makefile
  +++ b/drivers/input/serio/Makefile
  @@ -28,3 +28,4 @@ obj-$(CONFIG_SERIO_ALTERA_PS2)+= altera_ps2.o
   obj-$(CONFIG_SERIO_ARC_PS2)+= arc_ps2.o
   obj-$(CONFIG_SERIO_APBPS2) += apbps2.o
   obj-$(CONFIG_SERIO_OLPC_APSP)  += olpc_apsp.o
  +obj-$(CONFIG_HYPERV_KEYBOARD)  += hyperv-keyboard.o
  diff --git a/drivers/input/serio/hyperv-keyboard.c
 b/drivers/input/serio/hyperv-keyboard.c
  new file mode 100644
  index 000..0d4625f
  --- /dev/null
  +++ b/drivers/input/serio/hyperv-keyboard.c
  @@ -0,0 +1,379 @@
  +/*
  + *  Copyright (c) 2013, Microsoft Corporation.
  + *
  + *  This program is free software; you can redistribute it and/or modify it
  + *  under the terms and conditions of the GNU General Public License,
  + *  version 2, as published by the Free Software Foundation.
  + *
  + *  This program is distributed in the hope 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.
  + */
  +#include linux/init.h
  +#include linux/module.h
  +#include linux/device.h
  +#include linux/completion.h
  +#include linux/hyperv.h
  +#include linux/serio.h
  +#include linux/slab.h
  +
  +
 
 Extra blank line.
 
  +/*
  + * Current version 1.0
  + *
  + */
  +#define SYNTH_KBD_VERSION_MAJOR 1
  +#define SYNTH_KBD_VERSION_MINOR0
  +#define SYNTH_KBD_VERSION  (SYNTH_KBD_VERSION_MINOR |
 \
  +(SYNTH_KBD_VERSION_MAJOR  16))
  +
  +
  +/*
  + * Message types in the synthetic input protocol
  + */
  +enum synth_kbd_msg_type {
  +   SYNTH_KBD_PROTOCOL_REQUEST = 1,
  +   SYNTH_KBD_PROTOCOL_RESPONSE = 2,
  +   SYNTH_KBD_EVENT = 3,
  +   SYNTH_KBD_LED_INDICATORS = 4,
  +};
  +
  +/*
  + * Basic message structures.
  + */
  +struct synth_kbd_msg_hdr {
  +   enum synth_kbd_msg_type type;
  +};
 
 Enum type is wrong here because sizeof(enum) is up to the compiler to
 decide.
 
  +
  +struct synth_kbd_msg {
  +   struct synth_kbd_msg_hdr header;
  +   char data[1]; /* Enclosed message */
  +};
 
 You could use a zero size array instead.
 
  +
  +union synth_kbd_version {
  +   struct {
  +   u16 minor_version;
  +   u16 major_version;
  +   };
  +   u32 version;
  +};
  +
  +/*
  + * Protocol messages
  + */
  +struct synth_kbd_protocol_request {
  +   struct synth_kbd_msg_hdr header;
  +   union synth_kbd_version version_requested;
  +};
  +
  +struct synth_kbd_protocol_response {
  +   struct synth_kbd_msg_hdr header;
  +   u32 accepted:1;
  +   u32 reserved:31;
  +};
  +
  +struct synth_kbd_keystroke {
  +   struct synth_kbd_msg_hdr header;
  +   u16 make_code;
  +   u16 reserved0;
  +   u32 is_unicode:1;
  +   u32 is_break:1;
  +   u32 is_e0:1;
  +   u32 is_e1:1;
  +   u32 reserved:28;
  +};
  +
  +
 

Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread Dan Carpenter
On Mon, Sep 16, 2013 at 02:46:24PM +, KY Srinivasan wrote:
   + case VM_PKT_DATA_INBAND:
   + hv_kbd_on_receive(device, desc);
  
  This is the error handling I mentioned at the top.  hv_kbd_on_receive()
  doesn't take into consideration the amount of data we recieved, it
  trusts the offset we recieved from the user.  There is an out of bounds
  read.
 
 What user are you referring to. The message is sent by the host - the user 
 keystroke
 is normalized into a fixed size packet by the host and sent to the  guest. We 
 will parse this
 packet, based on the host specified layout here.
 

The user means the hypervisor, yes.

I don't want the hypervisor accessing outside of the buffer.  It is
robustness issue.  Just check the offset against bytes_recvd.  It's
not complicated.

If you have a different place where the guest does this then tell me
which function to look at.

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


Re: [PATCH 5/6] Staging/iio/adc/touchscreen/MXS: add interrupt driven touch detection

2013-09-16 Thread Marek Vasut
Dear Jürgen Beisert,

 Hi Marek,
 
 On Monday 16 September 2013 16:23:48 Marek Vasut wrote:
   On Sunday 15 September 2013 12:56:25 Jonathan Cameron wrote:
On 09/11/13 09:18, Juergen Beisert wrote:
 For battery driven systems it is a very bad idea to collect the
 touchscreen data within a kernel busy loop.
 
 This change uses the features of the hardware to delay and
 accumulate samples in hardware to avoid a high interrupt and CPU
 load.
 
 Note: this is only tested on an i.MX23 SoC yet.
 
 Signed-off-by: Juergen Beisert j...@pengutronix.de
 CC: linux-arm-ker...@lists.infradead.org
 CC: de...@driverdev.osuosl.org
 CC: Marek Vasut ma...@denx.de
 CC: Fabio Estevam fabio.este...@freescale.com
 CC: Jonathan Cameron ji...@cam.ac.uk

While this driver is placed in IIO within staging at the moment,
these changes are definitely input related.  Hence I have cc'd
Dmitry and the input list.

I am personaly a little uncomfortable that we have such a complex bit
of input code sat within an IIO driver but such is life.
   
   Maybe an MFD for this ADC unit would be a better way to go? Currently I
   have a different problem with this driver, because the ADC unit
   monitors the battery as well. And the charging driver from the power
   subsystem needs these values to charge the battery in a correct
   manner.
  
  Are you planning to post the power block patches too ?
 
 When they will work: yes. Currently it crashes all the time. The PMIC is a
 beast...

Full ACK

Best regards,
Marek Vasut
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread Dmitry Torokhov
Hi K. Y.

On Sun, Sep 15, 2013 at 10:28:54PM -0700, K. Y. Srinivasan wrote:
 Add a new driver to support synthetic keyboard. On the next generation
 Hyper-V guest firmware, many legacy devices will not be emulated and this
 driver will be required.
 
 I would like to thank Vojtech Pavlik vojt...@suse.cz for helping me with the
 details of the AT keyboard driver. 
 

In addition to what Dan said:

 +
 +struct synth_kbd_protocol_response {
 + struct synth_kbd_msg_hdr header;
 + u32 accepted:1;
 + u32 reserved:31;
 +};

Use of bitfields for on the wire structures makes me uneasy. I know that
currently you only going to run LE on LE, but still, maybe using
explicit shifts and masks would be better,

 +
 +struct synth_kbd_keystroke {
 + struct synth_kbd_msg_hdr header;
 + u16 make_code;
 + u16 reserved0;
 + u32 is_unicode:1;
 + u32 is_break:1;
 + u32 is_e0:1;
 + u32 is_e1:1;
 + u32 reserved:28;
 +};

Same here.

 +
 +
 +#define HK_MAXIMUM_MESSAGE_SIZE 256
 +
 +#define KBD_VSC_SEND_RING_BUFFER_SIZE(10 * PAGE_SIZE)
 +#define KBD_VSC_RECV_RING_BUFFER_SIZE(10 * PAGE_SIZE)
 +
 +#define XTKBD_EMUL0 0xe0
 +#define XTKBD_EMUL1 0xe1
 +#define XTKBD_RELEASE   0x80
 +
 +
 +/*
 + * Represents a keyboard device
 + */
 +struct hv_kbd_dev {
 + unsigned char keycode[256];

I do not see anything using keycode table? This is wrong level for it
regardless.

 + struct hv_device*device;
 + struct synth_kbd_protocol_request protocol_req;
 + struct synth_kbd_protocol_response protocol_resp;
 + /* Synchronize the request/response if needed */
 + struct completion   wait_event;
 + struct serio*hv_serio;
 +};
 +
 +
 +static struct hv_kbd_dev *hv_kbd_alloc_device(struct hv_device *device)
 +{
 + struct hv_kbd_dev *kbd_dev;
 + struct serio*hv_serio;

You are aligning with tabs half of declarations, leaving the others. Can
we not align at all?

 +
 + kbd_dev = kzalloc(sizeof(struct hv_kbd_dev), GFP_KERNEL);
 +
 + if (!kbd_dev)
 + return NULL;
 +
 + hv_serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
 +
 + if (hv_serio == NULL) {
 + kfree(kbd_dev);
 + return NULL;
 + }
 +
 + hv_serio-id.type   = SERIO_8042_XL;
 + strlcpy(hv_serio-name, dev_name(device-device),
 + sizeof(hv_serio-name));
 + strlcpy(hv_serio-phys, dev_name(device-device),
 + sizeof(hv_serio-phys));
 + hv_serio-dev.parent  = device-device;

Do you also want to set up serio's parent device to point to hv device?

 +
 +
 + kbd_dev-device = device;
 + kbd_dev-hv_serio = hv_serio;
 + hv_set_drvdata(device, kbd_dev);
 + init_completion(kbd_dev-wait_event);
 +
 + return kbd_dev;
 +}
 +
 +static void hv_kbd_free_device(struct hv_kbd_dev *device)
 +{
 + serio_unregister_port(device-hv_serio);
 + kfree(device-hv_serio);

Serio ports are refcounted, do not free them explicitly after they have
been registered.

 + hv_set_drvdata(device-device, NULL);
 + kfree(device);
 +}


Thanks.

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


Re: [PATCH 5/6] Staging/iio/adc/touchscreen/MXS: add interrupt driven touch detection

2013-09-16 Thread Dmitry Torokhov
On Sun, Sep 15, 2013 at 11:56:25AM +0100, Jonathan Cameron wrote:
 On 09/11/13 09:18, Juergen Beisert wrote:
  For battery driven systems it is a very bad idea to collect the touchscreen
  data within a kernel busy loop.
  
  This change uses the features of the hardware to delay and accumulate 
  samples in
  hardware to avoid a high interrupt and CPU load.
  
  Note: this is only tested on an i.MX23 SoC yet.
  
  Signed-off-by: Juergen Beisert j...@pengutronix.de
  CC: linux-arm-ker...@lists.infradead.org
  CC: de...@driverdev.osuosl.org
  CC: Marek Vasut ma...@denx.de
  CC: Fabio Estevam fabio.este...@freescale.com
  CC: Jonathan Cameron ji...@cam.ac.uk
 While this driver is placed in IIO within staging at the moment, these 
 changes are definitely
 input related.  Hence I have cc'd Dmitry and the input list.
 
 I am personaly a little uncomfortable that we have such a complex bit of 
 input code sat
 within an IIO driver but such is life.
 

...

   
   static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
  @@ -641,6 +1056,7 @@ static void mxs_lradc_ts_unregister(struct mxs_lradc 
  *lradc)
   
  cancel_work_sync(lradc-ts_work);
   
  +   mxs_lradc_disable_ts(lradc);
  input_unregister_device(lradc-ts_input);
   }

This looks iffy... Normally you disable the device so that it does not
generate more interrupts, and then cancel outstanding work(s), otherwise
newly generated interrupts may cause more work to be scheduled. Or I
missed some of the context and this is not a concern here?

Thanks.

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


Re: [PATCH 5/6] Staging/iio/adc/touchscreen/MXS: add interrupt driven touch detection

2013-09-16 Thread Jonathan Cameron


Jürgen Beisert j...@pengutronix.de wrote:
Hi Jonathan,

On Sunday 15 September 2013 12:56:25 Jonathan Cameron wrote:
 On 09/11/13 09:18, Juergen Beisert wrote:
  For battery driven systems it is a very bad idea to collect the
  touchscreen data within a kernel busy loop.
 
  This change uses the features of the hardware to delay and
accumulate
  samples in hardware to avoid a high interrupt and CPU load.
 
  Note: this is only tested on an i.MX23 SoC yet.
 
  Signed-off-by: Juergen Beisert j...@pengutronix.de
  CC: linux-arm-ker...@lists.infradead.org
  CC: de...@driverdev.osuosl.org
  CC: Marek Vasut ma...@denx.de
  CC: Fabio Estevam fabio.este...@freescale.com
  CC: Jonathan Cameron ji...@cam.ac.uk

 While this driver is placed in IIO within staging at the moment,
these
 changes are definitely input related.  Hence I have cc'd Dmitry and
the
 input list.

 I am personaly a little uncomfortable that we have such a complex bit
of
 input code sat within an IIO driver but such is life.

Maybe an MFD for this ADC unit would be a better way to go?
That would be great and is definitely the preferred method.


 Currently I
have a 
different problem with this driver, because the ADC unit monitors the
battery 
as well. And the charging driver from the power subsystem needs these
values 
to charge the battery in a correct manner.

There is an iio client battery driver as generic_ADC_battery.c but it is 
currently only doing polled access. Not too hard to add buffered access though 
ideally we would want a generic way of combining consumers doing polled and 
interrupt driven accesses.

 [...]

Regards,
Juergen

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread KY Srinivasan


 -Original Message-
 From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com]
 Sent: Monday, September 16, 2013 8:20 AM
 To: KY Srinivasan
 Cc: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
 de...@linuxdriverproject.org; linux-in...@vger.kernel.org; vojt...@suse.cz;
 o...@aepfle.de; a...@canonical.com; jasow...@redhat.com
 Subject: Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V
 synthetic keyboard
 
 Hi K. Y.
 
 On Sun, Sep 15, 2013 at 10:28:54PM -0700, K. Y. Srinivasan wrote:
  Add a new driver to support synthetic keyboard. On the next generation
  Hyper-V guest firmware, many legacy devices will not be emulated and this
  driver will be required.
 
  I would like to thank Vojtech Pavlik vojt...@suse.cz for helping me with 
  the
  details of the AT keyboard driver.
 
 
 In addition to what Dan said:
 
  +
  +struct synth_kbd_protocol_response {
  +   struct synth_kbd_msg_hdr header;
  +   u32 accepted:1;
  +   u32 reserved:31;
  +};
 
 Use of bitfields for on the wire structures makes me uneasy. I know that
 currently you only going to run LE on LE, but still, maybe using
 explicit shifts and masks would be better,

This definition of the data structure is defined by the host. I will see what I
can do here.

 
  +
  +struct synth_kbd_keystroke {
  +   struct synth_kbd_msg_hdr header;
  +   u16 make_code;
  +   u16 reserved0;
  +   u32 is_unicode:1;
  +   u32 is_break:1;
  +   u32 is_e0:1;
  +   u32 is_e1:1;
  +   u32 reserved:28;
  +};
 
 Same here.
 
  +
  +
  +#define HK_MAXIMUM_MESSAGE_SIZE 256
  +
  +#define KBD_VSC_SEND_RING_BUFFER_SIZE  (10 * PAGE_SIZE)
  +#define KBD_VSC_RECV_RING_BUFFER_SIZE  (10 * PAGE_SIZE)
  +
  +#define XTKBD_EMUL0 0xe0
  +#define XTKBD_EMUL1 0xe1
  +#define XTKBD_RELEASE   0x80
  +
  +
  +/*
  + * Represents a keyboard device
  + */
  +struct hv_kbd_dev {
  +   unsigned char keycode[256];
 
 I do not see anything using keycode table? This is wrong level for it
 regardless.
 
  +   struct hv_device*device;
  +   struct synth_kbd_protocol_request protocol_req;
  +   struct synth_kbd_protocol_response protocol_resp;
  +   /* Synchronize the request/response if needed */
  +   struct completion   wait_event;
  +   struct serio*hv_serio;
  +};
  +
  +
  +static struct hv_kbd_dev *hv_kbd_alloc_device(struct hv_device *device)
  +{
  +   struct hv_kbd_dev *kbd_dev;
  +   struct serio*hv_serio;
 
 You are aligning with tabs half of declarations, leaving the others. Can
 we not align at all?
 
  +
  +   kbd_dev = kzalloc(sizeof(struct hv_kbd_dev), GFP_KERNEL);
  +
  +   if (!kbd_dev)
  +   return NULL;
  +
  +   hv_serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
  +
  +   if (hv_serio == NULL) {
  +   kfree(kbd_dev);
  +   return NULL;
  +   }
  +
  +   hv_serio-id.type   = SERIO_8042_XL;
  +   strlcpy(hv_serio-name, dev_name(device-device),
  +   sizeof(hv_serio-name));
  +   strlcpy(hv_serio-phys, dev_name(device-device),
  +   sizeof(hv_serio-phys));
  +   hv_serio-dev.parent  = device-device;
 
 Do you also want to set up serio's parent device to point to hv device?

Is there an issue here; I could setup the parent as the vmbus device.

 
  +
  +
  +   kbd_dev-device = device;
  +   kbd_dev-hv_serio = hv_serio;
  +   hv_set_drvdata(device, kbd_dev);
  +   init_completion(kbd_dev-wait_event);
  +
  +   return kbd_dev;
  +}
  +
  +static void hv_kbd_free_device(struct hv_kbd_dev *device)
  +{
  +   serio_unregister_port(device-hv_serio);
  +   kfree(device-hv_serio);
 
 Serio ports are refcounted, do not free them explicitly after they have
 been registered.

Thank you. I will fix this.

 
  +   hv_set_drvdata(device-device, NULL);
  +   kfree(device);
  +}
 
 
 Thanks.


Thank you!.

Regards,

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


RE: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread KY Srinivasan


 -Original Message-
 From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
 Sent: Monday, September 16, 2013 8:06 AM
 To: KY Srinivasan
 Cc: o...@aepfle.de; gre...@linuxfoundation.org; jasow...@redhat.com;
 dmitry.torok...@gmail.com; linux-ker...@vger.kernel.org; vojt...@suse.cz;
 linux-in...@vger.kernel.org; a...@canonical.com; de...@linuxdriverproject.org
 Subject: Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V
 synthetic keyboard
 
 On Mon, Sep 16, 2013 at 02:46:24PM +, KY Srinivasan wrote:
+   case VM_PKT_DATA_INBAND:
+   hv_kbd_on_receive(device, desc);
  
   This is the error handling I mentioned at the top.  hv_kbd_on_receive()
   doesn't take into consideration the amount of data we recieved, it
   trusts the offset we recieved from the user.  There is an out of bounds
   read.
 
  What user are you referring to. The message is sent by the host - the user
 keystroke
  is normalized into a fixed size packet by the host and sent to the  guest. 
  We will
 parse this
  packet, based on the host specified layout here.
 
 
 The user means the hypervisor, yes.
 
 I don't want the hypervisor accessing outside of the buffer.  It is
 robustness issue.  Just check the offset against bytes_recvd.  It's
 not complicated.

At the outset, let me apologize for not understanding your concern.
You say:  I don't want the hypervisor accessing outside of the buffer
Where did you see the hypervisor accessing anything outside the buffer?
The buffer is allocated by this driver and a packet from vmbus is read into this
buffer - this is the call to vmbus_recvpacket(). If the specified buffer is 
smaller
than the packet that needs to be read, then nothing will be read. Once the read
completes, we can be sure we have read a valid packet and can proceed to parse 
it in
this driver.

I don't want to be argumentative, I am just not seeing the issue.

Regards,

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


Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread Dmitry Torokhov
On Mon, Sep 16, 2013 at 03:52:18PM +, KY Srinivasan wrote:
 
 
  -Original Message-
  From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com]
  Sent: Monday, September 16, 2013 8:20 AM
  To: KY Srinivasan
  Cc: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
  de...@linuxdriverproject.org; linux-in...@vger.kernel.org; vojt...@suse.cz;
  o...@aepfle.de; a...@canonical.com; jasow...@redhat.com
  Subject: Re: [PATCH 1/1] Drivers: input: serio: New driver to support 
  Hyper-V
  synthetic keyboard
  
  Hi K. Y.
  
  On Sun, Sep 15, 2013 at 10:28:54PM -0700, K. Y. Srinivasan wrote:
   Add a new driver to support synthetic keyboard. On the next generation
   Hyper-V guest firmware, many legacy devices will not be emulated and this
   driver will be required.
  
   I would like to thank Vojtech Pavlik vojt...@suse.cz for helping me 
   with the
   details of the AT keyboard driver.
  
  
  In addition to what Dan said:
  
   +
   +struct synth_kbd_protocol_response {
   + struct synth_kbd_msg_hdr header;
   + u32 accepted:1;
   + u32 reserved:31;
   +};
  
  Use of bitfields for on the wire structures makes me uneasy. I know that
  currently you only going to run LE on LE, but still, maybe using
  explicit shifts and masks would be better,
 
 This definition of the data structure is defined by the host. I will see what 
 I
 can do here.

You do not really need to change protocol, you just sat that accepted is
the bit 0 of the word and define endianness (LE in your case). Then you
do:

struct synth_kbd_protocol_response {
struct synth_kbd_msg_hdr header;
__le32 status;
}

#define KBD_PROTOCOL_ACCEPTED BIT(0)

...

status = _le32_to_cpu(response-status);
accepted = status  KBD_PROTOCOL_ACCEPTED;

Thanks.

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


[v3.11][Regression] HID: hyperv: convert alloc+memcpy to memdup

2013-09-16 Thread Joseph Salisbury
Hi Thomas,

A bug was opened against the Ubuntu kernel[0].  After a kernel bisect,
it was found that reverting the following commit resolved
this bug:

commit a4a23f6d68ad2c86ee8df6a6f89c9d315c0a761c
Author: Thomas Meyer tho...@m3y3r.de
Date:   Sat Jun 1 11:40:31 2013 +0200

HID: hyperv: convert alloc+memcpy to memdup


The regression was introduced as of v3.11-rc1.  The bug causes a system
to lockup when connecting a bluetooth trackpad and has been reported on
multiple machines. 

I wanted to ping you since you are the author of this patch.  I was
thinking of requesting a revert for v3.12 and v3.11, but I wanted to get
your feedback first.

Reverting the patch changes the driver back to useing kzalloc() and
memcpy() instead of  kmemdup.  Doing so has uncovered another bug, which
causes an oops on memcpy()[1].  We are in the process of bisecting that
one now and will provide the results.


Thanks,

Joe

[0] pad.lv/1218004
[1]
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1218004/+attachment/3818671/+files/kern.log

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


Re: [PATCH 3/6] Staging/iio/adc/touchscreen/MXS: simplify register access

2013-09-16 Thread Jonathan Cameron
On 09/16/13 09:17, Jürgen Beisert wrote:
 Hi Jonathan,
 
 On Sunday 15 September 2013 12:35:29 Jonathan Cameron wrote:
 [...]
 +static void mxs_lradc_reg_set(struct mxs_lradc *lradc, u32 val, u32 reg)
 +{
 +   writel(val, lradc-base + reg + STMP_OFFSET_REG_SET);
 +}
 +
 +static void mxs_lradc_reg_clear(struct mxs_lradc *lradc, u32 val, u32 reg)
 +{ 
 +   writel(val, lradc-base + reg + STMP_OFFSET_REG_CLR);
 +}
 +

 mxs_lradc_reg_write might be clearer?
 
 I would prefer the shorter name. Due to long macro names and long function 
 names the lines in the code below needs more and more line breaks which is 
 IMHO less helpfull to read the code.
Hmm.  It's not entirely obvious what else this might be doing, but it is
also not obvious from the name that it is writing to the register...

I remain unconvinced by the short name!

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


RE: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread KY Srinivasan


 -Original Message-
 From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
 Sent: Monday, September 16, 2013 11:33 AM
 To: KY Srinivasan
 Cc: Dmitry Torokhov; o...@aepfle.de; gre...@linuxfoundation.org;
 jasow...@redhat.com; linux-ker...@vger.kernel.org; vojt...@suse.cz; linux-
 in...@vger.kernel.org; a...@canonical.com; de...@linuxdriverproject.org
 Subject: Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V
 synthetic keyboard
 
 Just roll something like the following into your patch.
 
 regards,
 dan carpenter
 
 diff --git a/drivers/input/serio/hyperv-keyboard.c 
 b/drivers/input/serio/hyperv-
 keyboard.c
 index 0d4625f..262721b 100644
 --- a/drivers/input/serio/hyperv-keyboard.c
 +++ b/drivers/input/serio/hyperv-keyboard.c
 @@ -151,15 +151,18 @@ static void hv_kbd_free_device(struct hv_kbd_dev
 *device)
  }
 
  static void hv_kbd_on_receive(struct hv_device *device,
 - struct vmpacket_descriptor *packet)
 +   struct vmpacket_descriptor *packet, size_t size)
  {
   struct synth_kbd_msg *msg;
   struct hv_kbd_dev *kbd_dev = hv_get_drvdata(device);
   struct synth_kbd_keystroke *ks_msg;
 + int offset;
   u16 scan_code;
 
 - msg = (struct synth_kbd_msg *)((unsigned long)packet +
 - (packet-offset8  3));
 + offset = packet-offset8  3;
 + if (offset + sizeof(struct synth_kbd_protocol_response)  size)
 + return;
 + msg = (void *)packet + offset;
 
   switch (msg-header.type) {
   case SYNTH_KBD_PROTOCOL_RESPONSE:
 @@ -220,7 +223,7 @@ static void hv_kbd_on_channel_callback(void *context)
   break;
 
   case VM_PKT_DATA_INBAND:
 - hv_kbd_on_receive(device, desc);
 + hv_kbd_on_receive(device, desc, bytes_recvd);
   break;
 
   default:

Dan,

Rolling the changes you have indicated is not the issue; this can trivially be 
done.
My contention is that it is not needed given that the underlying function is 
already
doing that. Look at the function  vmbus_recvpacket_raw() in 
drivers/hv/channel.c.

Regards,

K. Y


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


Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread Dan Carpenter
On Mon, Sep 16, 2013 at 06:42:25PM +, KY Srinivasan wrote:
 Dan,
 
 Rolling the changes you have indicated is not the issue; this can trivially 
 be done.
 My contention is that it is not needed given that the underlying function is 
 already
 doing that. Look at the function  vmbus_recvpacket_raw() in 
 drivers/hv/channel.c.
 

I'm confused.

There is no mention of -offset8 in vmbus_recvpacket_raw().

It's a good idea to add a check there but the lower levels don't know
about the sizeof(synth_kbd_protocol_response) so we would still need
something like my check.

regards,
dan carpenter

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


Re: [v3.11][Regression] HID: hyperv: convert alloc+memcpy to memdup

2013-09-16 Thread Joseph Salisbury
On 09/16/2013 04:38 PM, Dan Carpenter wrote:
 On Mon, Sep 16, 2013 at 01:42:35PM -0400, Joseph Salisbury wrote:
 Reverting the patch changes the driver back to useing kzalloc() and
 memcpy() instead of  kmemdup.  Doing so has uncovered another bug, which
 causes an oops on memcpy()[1].  We are in the process of bisecting that
 one now and will provide the results.
 The two bugs are the same it's that the code has shifted a little.  Mark
 the commit as buggy and continue with the git bisect.

 regards,
 dan carpenter
Can you explain a little further?  Mark commit a4a23f6 as bad?  An
initial bisect already reported that was the first bad commit, so it
can't be marked bad.  The oops on memcpy() happens after commit a4a23f6
is reverted.  The oops on memcpy() did not happen before a4a23f6 was
committed, so I assume this new oops was introduced by a change later.

Right now I'm bisecting down the oops on memcpy() by updating the bisect
with good or bad, depending if the test kernel hit the oops.  I then
revert a4a23f6, so that revert is the HEAD of the tree each time before
building the kernel again(As long as the commit spit out by bisect is
after when a4a23f6 was introduced).

Thanks,

Joe


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


Re: [v3.11][Regression] HID: hyperv: convert alloc+memcpy to memdup

2013-09-16 Thread Dan Carpenter
On Mon, Sep 16, 2013 at 04:49:29PM -0400, Joseph Salisbury wrote:
 On 09/16/2013 04:38 PM, Dan Carpenter wrote:
  On Mon, Sep 16, 2013 at 01:42:35PM -0400, Joseph Salisbury wrote:
  Reverting the patch changes the driver back to useing kzalloc() and
  memcpy() instead of  kmemdup.  Doing so has uncovered another bug, which
  causes an oops on memcpy()[1].  We are in the process of bisecting that
  one now and will provide the results.
  The two bugs are the same it's that the code has shifted a little.  Mark
  the commit as buggy and continue with the git bisect.
 
  regards,
  dan carpenter
 Can you explain a little further?  Mark commit a4a23f6 as bad?  An
 initial bisect already reported that was the first bad commit, so it
 can't be marked bad.  The oops on memcpy() happens after commit a4a23f6
 is reverted.  The oops on memcpy() did not happen before a4a23f6 was
 committed, so I assume this new oops was introduced by a change later.
 
 Right now I'm bisecting down the oops on memcpy() by updating the bisect
 with good or bad, depending if the test kernel hit the oops.  I then
 revert a4a23f6, so that revert is the HEAD of the tree each time before
 building the kernel again(As long as the commit spit out by bisect is
 after when a4a23f6 was introduced).

Yep.  Please continue bisecting the memcpy() oops.

kmemdup() is just a kzalloc() followed by a memcpy().  When we split it
apart by reverting the patch then we would expect the oops to move to
the memcpy() part.  Somehow desc is a bogus pointer, but I don't
immediately see how that is possible.

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


Re: [v3.11][Regression] HID: hyperv: convert alloc+memcpy to memdup

2013-09-16 Thread Dan Carpenter
On Mon, Sep 16, 2013 at 01:42:35PM -0400, Joseph Salisbury wrote:
 Reverting the patch changes the driver back to useing kzalloc() and
 memcpy() instead of  kmemdup.  Doing so has uncovered another bug, which
 causes an oops on memcpy()[1].  We are in the process of bisecting that
 one now and will provide the results.

The two bugs are the same it's that the code has shifted a little.  Mark
the commit as buggy and continue with the git bisect.

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


RE: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread KY Srinivasan


 -Original Message-
 From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
 Sent: Monday, September 16, 2013 1:13 PM
 To: KY Srinivasan
 Cc: o...@aepfle.de; gre...@linuxfoundation.org; jasow...@redhat.com; Dmitry
 Torokhov; linux-ker...@vger.kernel.org; vojt...@suse.cz; linux-
 in...@vger.kernel.org; a...@canonical.com; de...@linuxdriverproject.org
 Subject: Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V
 synthetic keyboard
 
 On Mon, Sep 16, 2013 at 06:42:25PM +, KY Srinivasan wrote:
  Dan,
 
  Rolling the changes you have indicated is not the issue; this can trivially 
  be
 done.
  My contention is that it is not needed given that the underlying function is
 already
  doing that. Look at the function  vmbus_recvpacket_raw() in
 drivers/hv/channel.c.
 
 
 I'm confused.
 
 There is no mention of -offset8 in vmbus_recvpacket_raw().

As you can see the vmbus_recvpacket_raw() ensures that the complete
packet is read and if the buffer specified is not large enough nothing is 
read. The packet header has information about the length of the packet
and the offset where the payload is.  
 
 It's a good idea to add a check there but the lower levels don't know
 about the sizeof(synth_kbd_protocol_response) so we would still need
 something like my check.

Why would the lower level code need to know  anything about the layout of a
particular message type. The lower level code is guaranteeing that a complete
packet has been read in and that should be sufficient - assuming we trust the 
host.

We have already spent more time on this than we should; I will make the 
necessary
changes.

Regards,

K. Y
 
 regards,
 dan carpenter

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


[patch] hv: vmbus: fix vmbus_recvpacket_raw() return code

2013-09-16 Thread Dan Carpenter
Don't return success if the buffer has not been initialized.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 6de6c98..b05293c 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -855,6 +855,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, 
void *buffer,
if (signal)
vmbus_setevent(channel);
 
-   return 0;
+   return ret;
 }
 EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw);
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [patch] hv: vmbus: fix vmbus_recvpacket_raw() return code

2013-09-16 Thread KY Srinivasan


 -Original Message-
 From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
 Sent: Monday, September 16, 2013 2:59 PM
 To: KY Srinivasan
 Cc: Haiyang Zhang; de...@linuxdriverproject.org
 Subject: [patch] hv: vmbus: fix vmbus_recvpacket_raw() return code
 
 Don't return success if the buffer has not been initialized.
 
 Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
Signed-off-by: K. Y. Srinivasan k...@microsoft.com
 
 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
 index 6de6c98..b05293c 100644
 --- a/drivers/hv/channel.c
 +++ b/drivers/hv/channel.c
 @@ -855,6 +855,6 @@ int vmbus_recvpacket_raw(struct vmbus_channel
 *channel, void *buffer,
   if (signal)
   vmbus_setevent(channel);
 
 - return 0;
 + return ret;

Thanks Dan. In this case, by the time we get here, all other failure conditions 
have been
handled and that is the reason I had returned 0. 

  }
  EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw);
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread Dan Carpenter
On Mon, Sep 16, 2013 at 09:55:44PM +, KY Srinivasan wrote:
 
 
  -Original Message-
  From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
  Sent: Monday, September 16, 2013 1:13 PM
  To: KY Srinivasan
  Cc: o...@aepfle.de; gre...@linuxfoundation.org; jasow...@redhat.com; Dmitry
  Torokhov; linux-ker...@vger.kernel.org; vojt...@suse.cz; linux-
  in...@vger.kernel.org; a...@canonical.com; de...@linuxdriverproject.org
  Subject: Re: [PATCH 1/1] Drivers: input: serio: New driver to support 
  Hyper-V
  synthetic keyboard
  
  On Mon, Sep 16, 2013 at 06:42:25PM +, KY Srinivasan wrote:
   Dan,
  
   Rolling the changes you have indicated is not the issue; this can 
   trivially be
  done.
   My contention is that it is not needed given that the underlying function 
   is
  already
   doing that. Look at the function  vmbus_recvpacket_raw() in
  drivers/hv/channel.c.
  
  
  I'm confused.
  
  There is no mention of -offset8 in vmbus_recvpacket_raw().
 
 As you can see the vmbus_recvpacket_raw() ensures that the complete
 packet is read and if the buffer specified is not large enough nothing is 
 read. The packet header has information about the length of the packet
 and the offset where the payload is.  
  

No one is talking about the -len8.  I'm saying that we should check
-offset8.

  It's a good idea to add a check there but the lower levels don't know
  about the sizeof(synth_kbd_protocol_response) so we would still need
  something like my check.
 
 Why would the lower level code need to know  anything about the layout of a
 particular message type. The lower level code is guaranteeing that a complete
 packet has been read in and that should be sufficient - assuming we trust the 
 host.
 

Of course, we don't need to check anything if we trust the host.  I said
that already.  Just add the check for robustness.

 We have already spent more time on this than we should; I will make the 
 necessary
 changes.

Thank you.

regards,
dan carpenter

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


Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard

2013-09-16 Thread Dmitry Torokhov
On Mon, Sep 16, 2013 at 06:29:45PM +, KY Srinivasan wrote:
 
 
  -Original Message-
  From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com]
  Sent: Monday, September 16, 2013 10:10 AM
  To: KY Srinivasan
  Cc: Dan Carpenter; o...@aepfle.de; gre...@linuxfoundation.org;
  jasow...@redhat.com; linux-ker...@vger.kernel.org; vojt...@suse.cz; linux-
  in...@vger.kernel.org; a...@canonical.com; de...@linuxdriverproject.org
  Subject: Re: [PATCH 1/1] Drivers: input: serio: New driver to support 
  Hyper-V
  synthetic keyboard
  
  On Mon, Sep 16, 2013 at 04:56:03PM +, KY Srinivasan wrote:
  
  
-Original Message-
From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
Sent: Monday, September 16, 2013 8:06 AM
To: KY Srinivasan
Cc: o...@aepfle.de; gre...@linuxfoundation.org; jasow...@redhat.com;
dmitry.torok...@gmail.com; linux-ker...@vger.kernel.org;
  vojt...@suse.cz;
linux-in...@vger.kernel.org; a...@canonical.com;
  de...@linuxdriverproject.org
Subject: Re: [PATCH 1/1] Drivers: input: serio: New driver to support 
Hyper-V
synthetic keyboard
   
On Mon, Sep 16, 2013 at 02:46:24PM +, KY Srinivasan wrote:
   + case VM_PKT_DATA_INBAND:
   + hv_kbd_on_receive(device, desc);
 
  This is the error handling I mentioned at the top.  
  hv_kbd_on_receive()
  doesn't take into consideration the amount of data we recieved, it
  trusts the offset we recieved from the user.  There is an out of 
  bounds
  read.

 What user are you referring to. The message is sent by the host - the 
 user
keystroke
 is normalized into a fixed size packet by the host and sent to the  
 guest. We
  will
parse this
 packet, based on the host specified layout here.

   
The user means the hypervisor, yes.
   
I don't want the hypervisor accessing outside of the buffer.  It is
robustness issue.  Just check the offset against bytes_recvd.  It's
not complicated.
  
   At the outset, let me apologize for not understanding your concern.
   You say:  I don't want the hypervisor accessing outside of the buffer
   Where did you see the hypervisor accessing anything outside the buffer?
   The buffer is allocated by this driver and a packet from vmbus is read 
   into this
   buffer - this is the call to vmbus_recvpacket(). If the specified buffer 
   is smaller
   than the packet that needs to be read, then nothing will be read. Once 
   the read
   completes, we can be sure we have read a valid packet and can proceed to
  parse it in
   this driver.
  
  The concern is that number of bytes received and contents of a packet
  are not in sync. Imagine if we were told that 16 butes was received but
  in the packet offset is 78. Then we'll try reading well past the buffer
  boundary that we allocated for the packets.
 
 I am not sure how this would be the case. Following are the semantics of the 
 function
 vmbus_recvpacket_raw():
 
 If the packet to be read is larger than the buffer specified; nothing will be 
 read and 
 appropriate error is returned. If a  packet is read, the complete packet is 
 read and 
 so we can safely peek into this packet based on the information in the header.

No, you can not safely use contents of the packet because it has not
been vetted. The semantics you are talking about is provided by
vmbus_recvpacket(). That function does indeed look inside the packet end
ensures that offset specified in the packet is sane and would not exceed
the buffer. The vmbus_recvpacket_raw() does not do such validation.

Thanks.

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


Re: staging: Add dm-writeboost

2013-09-16 Thread Dan Carpenter
On Mon, Sep 16, 2013 at 05:53:57PM -0400, Mike Snitzer wrote:
 - variable names need to be a bit more verbose (arr = array)

struct array  is a horrible name.  :P  Please don't use either arr
or array.

regards,
dan carpenter

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


Re: [PATCH -next] ashmem: Fix ashmem_shrink deadlock.

2013-09-16 Thread Raul Xiong
2013/5/17 Robert Love rl...@google.com:
 On Thu, May 16, 2013 at 1:19 PM, Andrew Morton
 a...@linux-foundation.org wrote:
 On Thu, 16 May 2013 13:08:17 -0400 Robert Love rl...@google.com wrote:
 This problem seems a rare proper use of mutex_trylock.

 Not really.  The need for a trylock is often an indication that a
 subsystem has a locking misdesign.  That is indeed the case here.

 It is exactly the same as PF_MEMALLOC. We've got an effectively
 asynchronous event (shrinking) that can occur while you are holding
 locks requisite to that shrinking. Given that the shrinkage is best
 effort, a trylock actually communicates the intent pretty well: If
 possible, grab this lock and shrink.

 I think the idiomatic fix is to introduce a GFP_SHMEM but that seems
 overkill. Lots of the GFP flags are really just preventing recursing
 into the shrinkage code and it seems ill-designed that we require
 developers to know where they might end up. But we can disagree. :)

 Well, it's not exactly a ton of work, but adding a per-ashmem_area lock
 to protect -file would rather be putting lipstick on a pig.  I suppose
 we can put the trylock in there and run away, but it wouldn't hurt to
 drop in a big fat comment somewhere explaining that the driver should be
 migrated to a per-object locking scheme.

 Unfortunately I think ashmem_shrink would need to grab the per-object
 lock too; it needs to update the ranges. I'm sure we could re-design
 this but I don't think it is as easy as simply pushing the locking
 into the objects.

Robert

Hi all,
I am wondering if this is fixed in latest kernel? We are continuously
seeing this deadlock issue.

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