Re: [linux-sunxi] [PATCH v2 15/15] arm64: dts: allwinner: a64: Add Video Engine node

2018-12-10 Thread Paul Kocialkowski
Hi,

On Fri, 2018-12-07 at 22:22 +0100, Jernej Škrabec wrote:
> Hi!
> 
> Dne sreda, 05. december 2018 ob 10:24:44 CET je Paul Kocialkowski napisal(a):
> > This adds the Video Engine node for the A64. Since it can map the whole
> > DRAM range, there is no particular need for a reserved memory node
> > (unlike platforms preceding the A33).
> > 
> > Signed-off-by: Paul Kocialkowski 
> > ---
> >  arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 11 +++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> > b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi index
> > 8557d52c7c99..8d024c10d7cb 100644
> > --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> > +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> > @@ -397,6 +397,17 @@
> > };
> > };
> > 
> > +   video-codec@1c0e000 {
> > +   compatible = "allwinner,sun50i-h5-video-engine";
> 
> You meant A64 instead of H5, right?

Ah yes definitely, that's a mistake right here.

I'll send a follow-up patch for switching the compatible to describe
the a64 instead of the h5. In practice, having the a64 use the h5
compatible doesn't cause any issue, but it should be fixed
nevertheless.

Cheers,

Paul

> Best regards,
> Jernej
> 
> > +   reg = <0x01c0e000 0x1000>;
> > +   clocks = <&ccu CLK_BUS_VE>, <&ccu CLK_VE>,
> > +<&ccu CLK_DRAM_VE>;
> > +   clock-names = "ahb", "mod", "ram";
> > +   resets = <&ccu RST_BUS_VE>;
> > +   interrupts = ;
> > +   allwinner,sram = <&ve_sram 1>;
> > +   };
> > +
> > mmc0: mmc@1c0f000 {
> > compatible = "allwinner,sun50i-a64-mmc";
> > reg = <0x01c0f000 0x1000>;
> 
> 
> 
-- 
Paul Kocialkowski, Bootlin (formerly Free Electrons)
Embedded Linux and kernel engineering
https://bootlin.com

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


[PATCH 1/2] staging: rtl8723bs: remove dead code, rtw_port_switch_chk()

2018-12-10 Thread Michael Straube
The function rtw_port_switch_chk() returns always false.
Remove the function and related dead code.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 34 ---
 .../staging/rtl8723bs/include/rtw_mlme_ext.h  |  1 -
 2 files changed, 35 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 8445d516c93d..35003d8d9ba4 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -5334,13 +5334,6 @@ void report_add_sta_event(struct adapter *padapter, 
unsigned char *MacAddr, int
return;
 }
 
-
-bool rtw_port_switch_chk(struct adapter *adapter)
-{
-   bool switch_needed = false;
-   return switch_needed;
-}
-
 /
 
 Following are the event callback functions
@@ -5414,7 +5407,6 @@ static void rtw_mlmeext_disconnect(struct adapter 
*padapter)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
struct wlan_bssid_ex*pnetwork = (struct wlan_bssid_ex 
*)(&(pmlmeinfo->network));
-   u8 state_backup = (pmlmeinfo->state&0x03);
 
/* set_opmode_cmd(padapter, infra_client_with_mlme); */
 
@@ -5440,17 +5432,6 @@ static void rtw_mlmeext_disconnect(struct adapter 
*padapter)
 
pmlmeinfo->state = WIFI_FW_NULL_STATE;
 
-   if (state_backup == WIFI_FW_STATION_STATE) {
-   if (rtw_port_switch_chk(padapter)) {
-   rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
-   {
-   struct adapter *port0_iface = 
dvobj_get_port0_adapter(adapter_to_dvobj(padapter));
-   if (port0_iface)
-   rtw_lps_ctrl_wk_cmd(port0_iface, 
LPS_CTRL_CONNECT, 0);
-   }
-   }
-   }
-
/* switch to the 20M Hz mode after disconnect */
pmlmeext->cur_bwmode = CHANNEL_WIDTH_20;
pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
@@ -5530,9 +5511,6 @@ void mlmeext_joinbss_event_callback(struct adapter 
*padapter, int join_res)
rtw_hal_macid_wakeup(padapter, psta->mac_id);
}
 
-   if (rtw_port_switch_chk(padapter))
-   rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
-
join_type = 2;
rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
 
@@ -6087,18 +6065,6 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf)
rtw_auto_ap_start_beacon(padapter);
 #endif
 
-   if (rtw_port_switch_chk(padapter)) {
-   rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
-
-   if (psetop->mode == Ndis802_11APMode)
-   adapter_to_pwrctl(padapter)->fw_psmode_iface_id = 0xff; 
/* ap mode won't dowload rsvd pages */
-   else if (psetop->mode == Ndis802_11Infrastructure) {
-   struct adapter *port0_iface = 
dvobj_get_port0_adapter(adapter_to_dvobj(padapter));
-   if (port0_iface)
-   rtw_lps_ctrl_wk_cmd(port0_iface, 
LPS_CTRL_CONNECT, 0);
-   }
-   }
-
if (psetop->mode == Ndis802_11APMode) {
/*  Do this after port switch to */
/*  prevent from downloading rsvd page to wrong port */
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h 
b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
index 4c3141882143..f6eabad4bbe0 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
@@ -648,7 +648,6 @@ void report_survey_event(struct adapter *padapter, union 
recv_frame *precv_frame
 void report_surveydone_event(struct adapter *padapter);
 void report_del_sta_event(struct adapter *padapter, unsigned char* MacAddr, 
unsigned short reason);
 void report_add_sta_event(struct adapter *padapter, unsigned char* MacAddr, 
int cam_idx);
-bool rtw_port_switch_chk(struct adapter *adapter);
 void report_wmm_edca_update(struct adapter *padapter);
 
 void beacon_timing_control(struct adapter *padapter);
-- 
2.19.2

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


[PATCH 2/2] staging: rtl8723bs: fix typo in the TODO file

2018-12-10 Thread Michael Straube
HGz -> GHz

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8723bs/TODO | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/TODO b/drivers/staging/rtl8723bs/TODO
index 80dbdaca3a8f..58e02f944b6d 100644
--- a/drivers/staging/rtl8723bs/TODO
+++ b/drivers/staging/rtl8723bs/TODO
@@ -1,6 +1,6 @@
 TODO:
 - find and remove code blocks guarded by never set CONFIG_FOO defines
-- find and remove remaining code valid only for 5 HGz. Most of the obvious
+- find and remove remaining code valid only for 5 GHz. Most of the obvious
   ones have been removed, but things like channel > 14 still exist.
 - find and remove any code for other chips that is left over
 - convert any remaining unusual variable types
-- 
2.19.2

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


Re: [PATCH v2] staging: comedi: change do_insn*_ioctl to allow more samples

2018-12-10 Thread Ian Abbott

On 04/12/2018 19:07, Spencer E. Olson wrote:

Changes do_insn*_ioctl functions to allow for data lengths for each
comedi_insn of up to 2^16.  This patch also changes these functions to only
allocate as much memory as is necessary for each comedi_insn, rather than
allocating a fixed-sized scratch space.

In testing some user-space code for the new INSN_DEVICE_CONFIG_GET_ROUTES
facility with some newer hardware, I discovered that do_insn_ioctl and
do_insnlist_ioctl limited the amount of data that can be passed into the
kernel for insn's to a length of 256.  For some newer hardware, the number
of routes can be greater than 1000.  Working around the old limits (256)
would complicate the user-space/kernel interaction.

The new upper limit is reasonable with current memory available and does
not otherwise impact the memory footprint for any current or otherwise
typical configuration.

Signed-off-by: Spencer E. Olson 
---
Implements Ian's suggestions to:
1) Provide a minimum amount of space to allocate (16*sizeof(uint)) to protect
drivers that do not (yet) check the size of the instruction data (Ian has
submitted several patches fixing this for other drivers already).  In case
insn.n does not get set, this minimum amount also avoids trying to allocate
zero-length data.
2) Allocate the maximum required space needed for any of the instructions in an
instruction list before executing the list of instructions (this, rather 
than
allocating and freeing memory separately while iterating through the
instruction list and executing each instruction).

  drivers/staging/comedi/comedi_fops.c | 48 ++--
  1 file changed, 31 insertions(+), 17 deletions(-)



Looks good, thanks!  (I still need to crack on and fix up the remaining 
drivers that ignore insn->n.)


Reviewed-by: Ian Abbott 

--
-=( Ian Abbott  || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:)=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v4 1/2] staging: iio: ad7606: Move out of staging

2018-12-10 Thread Stefan Popa
Move ad7606 ADC driver out of staging and into the mainline.

Signed-off-by: Stefan Popa 
---
Changes in v2:
- Simplified the Kconfig menu.
- Added SPDX-License-Identifier.
- Ordered the includes alphabetically.
- Used a threaded interrupt.
- Replaced ad7606_poll_bh_to_ring() with ad7606_trigger_handler().
- Used a trigger. 
- Replaced wait_event_interruptible() with 
wait_for_completion_timeout().
- Replaced wake_up_interruptible() with complete().
- Used devm_iio_triggered_buffer_setup().
- Added buffer_ops.
- Used single line comments where needed.
- Removed the gap between docs and struct.
- Added ad7606_of_match[].
Changes in v3:
- Added a comment which offers more information of the way the interrupt
  is triggered.
- Fixed the way a new conversion is triggered.
- endianness = IIO_CPU
- Removed unnecessary mutex locks.
- Removed the buffer_postdisable ops and replaced it with 
buffer_predisable.
- Added a devm_add_action_or_reset() which deals with 
regulator_disable().
- Misc style fixes.
Changes in v4:
- Removed unused fields from the ad7606_state struct.
- Used the find_closest() macro when searching for the available scale
and the oversampling ratios.

 MAINTAINERS  |   7 +
 drivers/iio/adc/Kconfig  |  28 ++
 drivers/iio/adc/Makefile |   3 +
 drivers/iio/adc/ad7606.c | 588 +++
 drivers/iio/adc/ad7606.h |  99 ++
 drivers/iio/adc/ad7606_par.c | 105 +++
 drivers/iio/adc/ad7606_spi.c |  82 +
 drivers/staging/iio/adc/Kconfig  |  34 --
 drivers/staging/iio/adc/Makefile |   3 -
 drivers/staging/iio/adc/ad7606.c | 565 -
 drivers/staging/iio/adc/ad7606.h | 106 ---
 drivers/staging/iio/adc/ad7606_par.c | 113 ---
 drivers/staging/iio/adc/ad7606_spi.c |  79 -
 13 files changed, 912 insertions(+), 900 deletions(-)
 create mode 100644 drivers/iio/adc/ad7606.c
 create mode 100644 drivers/iio/adc/ad7606.h
 create mode 100644 drivers/iio/adc/ad7606_par.c
 create mode 100644 drivers/iio/adc/ad7606_spi.c
 delete mode 100644 drivers/staging/iio/adc/ad7606.c
 delete mode 100644 drivers/staging/iio/adc/ad7606.h
 delete mode 100644 drivers/staging/iio/adc/ad7606_par.c
 delete mode 100644 drivers/staging/iio/adc/ad7606_spi.c

diff --git a/MAINTAINERS b/MAINTAINERS
index f642044..843545d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -839,6 +839,13 @@ S: Supported
 F: drivers/iio/dac/ad5758.c
 F: Documentation/devicetree/bindings/iio/dac/ad5758.txt
 
+ANALOG DEVICES INC AD7606 DRIVER
+M: Stefan Popa 
+L: linux-...@vger.kernel.org
+W: http://ez.analog.com/community/linux-device-drivers
+S: Supported
+F: drivers/iio/adc/ad7606.c
+
 ANALOG DEVICES INC AD9389B DRIVER
 M: Hans Verkuil 
 L: linux-me...@vger.kernel.org
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index a52fea8..c3f61c9 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -58,6 +58,34 @@ config AD7476
  To compile this driver as a module, choose M here: the
  module will be called ad7476.
 
+config AD7606
+   tristate
+   depends on GPIOLIB || COMPILE_TEST
+   depends on HAS_IOMEM
+   select IIO_BUFFER
+   select IIO_TRIGGERED_BUFFER
+
+config AD7606_IFACE_PARALLEL
+   tristate "Analog Devices AD7606 ADC driver with parallel interface 
support"
+   select AD7606
+   help
+ Say yes here to build parallel interface support for Analog Devices:
+ ad7605-4, ad7606, ad7606-6, ad7606-4 analog to digital converters 
(ADC).
+
+ To compile this driver as a module, choose M here: the
+ module will be called ad7606_parallel.
+
+config AD7606_IFACE_SPI
+   tristate "Analog Devices AD7606 ADC driver with spi interface support"
+   depends on SPI
+   select AD7606
+   help
+ Say yes here to build spi interface support for Analog Devices:
+ ad7605-4, ad7606, ad7606-6, ad7606-4 analog to digital converters 
(ADC).
+
+ To compile this driver as a module, choose M here: the
+ module will be called ad7606_spi.
+
 config AD7766
tristate "Analog Devices AD7766/AD7767 ADC driver"
depends on SPI_MASTER
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index a6e6a0b..b734f4f 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -8,6 +8,9 @@ obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o
 obj-$(CONFIG_AD7266) += ad7266.o
 obj-$(CONFIG_AD7291) += ad7291.o
 obj-$(CONFIG_AD7298) += ad7298.o
+obj-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o
+obj-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o
+obj-$(CONFIG_AD7606) += ad7606.o
 obj-$(CONFIG_AD7923) += ad7923.o
 obj-$(CONFIG

Re: [PATCH 1/2] staging: rtl8723bs: remove dead code, rtw_port_switch_chk()

2018-12-10 Thread Hans de Goede

Hi,

Thank you for the patches.

On 10-12-18 10:52, Michael Straube wrote:

The function rtw_port_switch_chk() returns always false.
Remove the function and related dead code.

Signed-off-by: Michael Straube 


Both patches look good to me:

Acked-by: Hans de Goede 

Regards,

Hans




---
  drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 34 ---
  .../staging/rtl8723bs/include/rtw_mlme_ext.h  |  1 -
  2 files changed, 35 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 8445d516c93d..35003d8d9ba4 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -5334,13 +5334,6 @@ void report_add_sta_event(struct adapter *padapter, 
unsigned char *MacAddr, int
return;
  }
  
-

-bool rtw_port_switch_chk(struct adapter *adapter)
-{
-   bool switch_needed = false;
-   return switch_needed;
-}
-
  /
  
  Following are the event callback functions

@@ -5414,7 +5407,6 @@ static void rtw_mlmeext_disconnect(struct adapter 
*padapter)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
struct wlan_bssid_ex*pnetwork = (struct wlan_bssid_ex 
*)(&(pmlmeinfo->network));
-   u8 state_backup = (pmlmeinfo->state&0x03);
  
  	/* set_opmode_cmd(padapter, infra_client_with_mlme); */
  
@@ -5440,17 +5432,6 @@ static void rtw_mlmeext_disconnect(struct adapter *padapter)
  
  	pmlmeinfo->state = WIFI_FW_NULL_STATE;
  
-	if (state_backup == WIFI_FW_STATION_STATE) {

-   if (rtw_port_switch_chk(padapter)) {
-   rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
-   {
-   struct adapter *port0_iface = 
dvobj_get_port0_adapter(adapter_to_dvobj(padapter));
-   if (port0_iface)
-   rtw_lps_ctrl_wk_cmd(port0_iface, 
LPS_CTRL_CONNECT, 0);
-   }
-   }
-   }
-
/* switch to the 20M Hz mode after disconnect */
pmlmeext->cur_bwmode = CHANNEL_WIDTH_20;
pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
@@ -5530,9 +5511,6 @@ void mlmeext_joinbss_event_callback(struct adapter 
*padapter, int join_res)
rtw_hal_macid_wakeup(padapter, psta->mac_id);
}
  
-	if (rtw_port_switch_chk(padapter))

-   rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
-
join_type = 2;
rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
  
@@ -6087,18 +6065,6 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf)

rtw_auto_ap_start_beacon(padapter);
  #endif
  
-	if (rtw_port_switch_chk(padapter)) {

-   rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL);
-
-   if (psetop->mode == Ndis802_11APMode)
-   adapter_to_pwrctl(padapter)->fw_psmode_iface_id = 0xff; 
/* ap mode won't dowload rsvd pages */
-   else if (psetop->mode == Ndis802_11Infrastructure) {
-   struct adapter *port0_iface = 
dvobj_get_port0_adapter(adapter_to_dvobj(padapter));
-   if (port0_iface)
-   rtw_lps_ctrl_wk_cmd(port0_iface, 
LPS_CTRL_CONNECT, 0);
-   }
-   }
-
if (psetop->mode == Ndis802_11APMode) {
/*  Do this after port switch to */
/*  prevent from downloading rsvd page to wrong port */
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h 
b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
index 4c3141882143..f6eabad4bbe0 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
@@ -648,7 +648,6 @@ void report_survey_event(struct adapter *padapter, union 
recv_frame *precv_frame
  void report_surveydone_event(struct adapter *padapter);
  void report_del_sta_event(struct adapter *padapter, unsigned char* MacAddr, 
unsigned short reason);
  void report_add_sta_event(struct adapter *padapter, unsigned char* MacAddr, 
int cam_idx);
-bool rtw_port_switch_chk(struct adapter *adapter);
  void report_wmm_edca_update(struct adapter *padapter);
  
  void beacon_timing_control(struct adapter *padapter);



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


Re: [PATCH 1/4] arm64: hyperv: Add core Hyper-V include files

2018-12-10 Thread Vitaly Kuznetsov
k...@linuxonhyperv.com writes:

> +
> +static inline u64 hv_read_tsc_page_tsc(const struct ms_hyperv_tsc_page 
> *tsc_pg,
> +u64 *cur_tsc)
> +{
> + u64 scale, offset;
> + u32 sequence;
> +
> + /*
> +  * The protocol for reading Hyper-V TSC page is specified in Hypervisor
> +  * Top-Level Functional Specification.  To get the reference time we
> +  * must do the following:
> +  * - READ ReferenceTscSequence
> +  *   A special '0' value indicates the time source is unreliable and we
> +  *   need to use something else.
> +  * - ReferenceTime =
> +  * ((HWclock val) * ReferenceTscScale) >> 64) + ReferenceTscOffset
> +  * - READ ReferenceTscSequence again. In case its value has changed
> +  *   since our first reading we need to discard ReferenceTime and repeat
> +  *   the whole sequence as the hypervisor was updating the page in
> +  *   between.
> +  */
> + do {
> + sequence = READ_ONCE(tsc_pg->tsc_sequence);

(sorry if this was already discussed before)

Current x86 code doing this actually checks for '0' here (note the
comment about this special value above):

sequence = READ_ONCE(tsc_pg->tsc_sequence);
if (!sequence)
return U64_MAX;

Was it removed intentionally (and we need to fix the comment then)? 

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


[PATCH] uio_hv_generic: set callbacks on open

2018-12-10 Thread Stephen Hemminger
This fixes the problem where uio application was unable to
use multple queues on restart. The root cause is that the callbacks
are cleared on disconnect. Change to setting up callbacks
everytime in open.

Fixes: cdfa835c6e5e ("uio_hv_generic: defer opening vmbus until first use")
Reported-by: Mohammed Gamal 
Signed-off-by: Stephen Hemminger 
---
 drivers/uio/uio_hv_generic.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index c2493d011225..3c5169eb23f5 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -204,9 +204,11 @@ hv_uio_open(struct uio_info *info, struct inode *inode)
if (atomic_inc_return(&pdata->refcnt) != 1)
return 0;
 
+   vmbus_set_chn_rescind_callback(dev->channel, hv_uio_rescind);
+   vmbus_set_sc_create_callback(dev->channel, hv_uio_new_channel);
+
ret = vmbus_connect_ring(dev->channel,
 hv_uio_channel_cb, dev->channel);
-
if (ret == 0)
dev->channel->inbound.ring_buffer->interrupt_mask = 1;
else
@@ -334,9 +336,6 @@ hv_uio_probe(struct hv_device *dev,
goto fail_close;
}
 
-   vmbus_set_chn_rescind_callback(channel, hv_uio_rescind);
-   vmbus_set_sc_create_callback(channel, hv_uio_new_channel);
-
ret = sysfs_create_bin_file(&channel->kobj, &ring_buffer_bin_attr);
if (ret)
dev_notice(&dev->device,
-- 
2.19.2

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


[PATCH] staging: vchiq: rework remove_event handling

2018-12-10 Thread Arnd Bergmann
I had started the removal of semaphores in this driver without knowing
that Nicolas Saenz Julienne also worked on this. In case of the "remote
event" infrastructure, my solution seemed significantly better, so I'm
proposing this as a change on top.

The problem with using either semaphores or completions here is that
it's an overly complex way of waking up a thread, and it looks like the
'count' of the semaphore can easily get out of sync, even though I found
it hard to come up with a specific example.

Changing it to a 'wait_queue_head_t' instead of a completion simplifies
this by letting us wait directly on the 'event->fired' variable that is
set by the videocore.

Another simplification is passing the wait queue directly into the helper
functions instead of going through the fragile logic of recording the
offset inside of a structure as part of a shared memory variable. This
also avoids one uncached memory read and should be faster.

Note that I'm changing it back to 'killable' after the previous patch
changed 'killable' to 'interruptible', apparently based on a misunderstanding
of the subtle down_interruptible() macro override in vchiq_killable.h.

Fixes: f27e47bc6b8b ("staging: vchiq: use completions instead of semaphores")
Signed-off-by: Arnd Bergmann 
---
 .../interface/vchiq_arm/vchiq_core.c  | 63 +++
 .../interface/vchiq_arm/vchiq_core.h  | 12 ++--
 2 files changed, 30 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 482b5daf6c0c..eda3004a0c6a 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -417,26 +417,23 @@ vchiq_set_conn_state(VCHIQ_STATE_T *state, 
VCHIQ_CONNSTATE_T newstate)
 }
 
 static inline void
-remote_event_create(REMOTE_EVENT_T *event)
+remote_event_create(wait_queue_head_t *wq, REMOTE_EVENT_T *event)
 {
event->armed = 0;
/* Don't clear the 'fired' flag because it may already have been set
** by the other side. */
+   init_waitqueue_head(wq);
 }
 
 static inline int
-remote_event_wait(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event)
+remote_event_wait(wait_queue_head_t *wq, REMOTE_EVENT_T *event)
 {
if (!event->fired) {
event->armed = 1;
dsb(sy);
-   if (!event->fired) {
-   if (wait_for_completion_interruptible(
-   (struct completion *)
-   ((char *)state + event->event))) {
-   event->armed = 0;
-   return 0;
-   }
+   if (wait_event_killable(*wq, event->fired)) {
+   event->armed = 0;
+   return 0;
}
event->armed = 0;
wmb();
@@ -447,26 +444,26 @@ remote_event_wait(VCHIQ_STATE_T *state, REMOTE_EVENT_T 
*event)
 }
 
 static inline void
-remote_event_signal_local(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event)
+remote_event_signal_local(wait_queue_head_t *wq, REMOTE_EVENT_T *event)
 {
event->armed = 0;
-   complete((struct completion *)((char *)state + event->event));
+   wake_up_all(wq);
 }
 
 static inline void
-remote_event_poll(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event)
+remote_event_poll(wait_queue_head_t *wq, REMOTE_EVENT_T *event)
 {
if (event->fired && event->armed)
-   remote_event_signal_local(state, event);
+   remote_event_signal_local(wq, event);
 }
 
 void
 remote_event_pollall(VCHIQ_STATE_T *state)
 {
-   remote_event_poll(state, &state->local->sync_trigger);
-   remote_event_poll(state, &state->local->sync_release);
-   remote_event_poll(state, &state->local->trigger);
-   remote_event_poll(state, &state->local->recycle);
+   remote_event_poll(&state->sync_trigger_event, 
&state->local->sync_trigger);
+   remote_event_poll(&state->sync_release_event, 
&state->local->sync_release);
+   remote_event_poll(&state->trigger_event, &state->local->trigger);
+   remote_event_poll(&state->recycle_event, &state->local->recycle);
 }
 
 /* Round up message sizes so that any space at the end of a slot is always big
@@ -550,7 +547,7 @@ request_poll(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T 
*service, int poll_type)
wmb();
 
/* ... and ensure the slot handler runs. */
-   remote_event_signal_local(state, &state->local->trigger);
+   remote_event_signal_local(&state->trigger_event, 
&state->local->trigger);
 }
 
 /* Called from queue_message, by the slot handler and application threads,
@@ -1069,7 +1066,7 @@ queue_message_sync(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T 
*service,
(mutex_lock_killable(&state->sync_mutex) != 0))
return VCHIQ_RETRY;
 
-   remote_eve

Re: [PATCH 3/3] staging: iio: ad5933: add binding doc for ad5933

2018-12-10 Thread Jonathan Cameron
On Sat, 8 Dec 2018 16:19:59 -0200
Marcelo Schmitt  wrote:

> Add a devicetree documentation for the ad5933 and ad5934 impedance
> converter, network analyzer.
> 
> Signed-off-by: Marcelo Schmitt 
> Signed-off-by: Gabriel Capella 
> Co-Developed-by: Gabriel Capella 
Device tree binding patches need to also go to the DT maintainers and list
for review.

This looks fine to me but they are the specialists in these!

+cc Rob, Mark and DT list.

Jonathan
> ---
>  .../iio/impedance-analyzer/ad5933.txt | 26 +++
>  1 file changed, 26 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
> 
> diff --git 
> a/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt 
> b/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
> new file mode 100644
> index ..5ff38728ff91
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
> @@ -0,0 +1,26 @@
> +Analog Devices AD5933/AD5934 Impedance Converter, Network Analyzer
> +
> +https://www.analog.com/media/en/technical-documentation/data-sheets/AD5933.pdf
> +https://www.analog.com/media/en/technical-documentation/data-sheets/AD5934.pdf
> +
> +Required properties:
> + - compatible : should be one of
> + "adi,ad5933"
> + "adi,ad5934"
> + - reg : the I2C address.
> + - vdd-supply : The regulator supply for DVDD, AVDD1 and AVDD2 when they
> +   are connected together.
> +
> +Optional properties:
> +- clocks : external clock reference.
> +- clock-names : must be "mclk" if clocks is set.
> +
> +Example for a I2C device node:
> +
> + impedance-analyzer@0d {
> + compatible = "adi,adxl345";
> + reg = <0x0d>;
> + vdd-supply = <&vdd_supply>;
> + clocks = <&ref_clk>;
> + clock-names = "mclk";
> + };

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


Re: [PATCH 0/3] Add devicetree support for ad5933

2018-12-10 Thread Jonathan Cameron
On Sat, 8 Dec 2018 22:10:43 +0100
Greg KH  wrote:

> On Sat, Dec 08, 2018 at 04:56:45PM -0200, Marcelo Schmitt wrote:
> > Parts of this work came from contributions of Alexandru Ardelean and
> > Dragos Bogdan, I and Gabriel would like to thank for the insights
> > provided by their previous patches. Maybe it would be the case to add
> > them as co-authors of this patch set.  
> 
> That's what the Co-developed-by: tag is for, please use it :)
> 
Alexandru, Dragos.  No idea how involved you were in the actual
patch...

Work amongst amongst the 4 of you what you would like to do and
let us know!

Patches look fine, though we need to let the DT maintainers have a few
days at least to get around to looking if they want to (they don't always
on simple bindings like these).

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


Re: [PATCH v4 1/2] staging: iio: ad7606: Move out of staging

2018-12-10 Thread Jonathan Cameron
On Mon, 10 Dec 2018 13:03:33 +0200
Stefan Popa  wrote:

> Move ad7606 ADC driver out of staging and into the mainline.
> 
> Signed-off-by: Stefan Popa 

Looks good to me.  I'll let it sit for a few days though to give
time for a final review from anyone else who wants to and for
Rob to take a final look at the bindings if he wants to.

Thanks,

Jonathan

> ---
> Changes in v2:
>   - Simplified the Kconfig menu.
>   - Added SPDX-License-Identifier.
>   - Ordered the includes alphabetically.
>   - Used a threaded interrupt.
>   - Replaced ad7606_poll_bh_to_ring() with ad7606_trigger_handler().
>   - Used a trigger. 
>   - Replaced wait_event_interruptible() with 
> wait_for_completion_timeout().
>   - Replaced wake_up_interruptible() with complete().
>   - Used devm_iio_triggered_buffer_setup().
>   - Added buffer_ops.
>   - Used single line comments where needed.
>   - Removed the gap between docs and struct.
>   - Added ad7606_of_match[].
> Changes in v3:
>   - Added a comment which offers more information of the way the interrupt
> is triggered.
>   - Fixed the way a new conversion is triggered.
>   - endianness = IIO_CPU
>   - Removed unnecessary mutex locks.
>   - Removed the buffer_postdisable ops and replaced it with 
> buffer_predisable.
>   - Added a devm_add_action_or_reset() which deals with 
> regulator_disable().
>   - Misc style fixes.
> Changes in v4:
>   - Removed unused fields from the ad7606_state struct.
>   - Used the find_closest() macro when searching for the available scale
>   and the oversampling ratios.
> 
>  MAINTAINERS  |   7 +
>  drivers/iio/adc/Kconfig  |  28 ++
>  drivers/iio/adc/Makefile |   3 +
>  drivers/iio/adc/ad7606.c | 588 
> +++
>  drivers/iio/adc/ad7606.h |  99 ++
>  drivers/iio/adc/ad7606_par.c | 105 +++
>  drivers/iio/adc/ad7606_spi.c |  82 +
>  drivers/staging/iio/adc/Kconfig  |  34 --
>  drivers/staging/iio/adc/Makefile |   3 -
>  drivers/staging/iio/adc/ad7606.c | 565 -
>  drivers/staging/iio/adc/ad7606.h | 106 ---
>  drivers/staging/iio/adc/ad7606_par.c | 113 ---
>  drivers/staging/iio/adc/ad7606_spi.c |  79 -
>  13 files changed, 912 insertions(+), 900 deletions(-)
>  create mode 100644 drivers/iio/adc/ad7606.c
>  create mode 100644 drivers/iio/adc/ad7606.h
>  create mode 100644 drivers/iio/adc/ad7606_par.c
>  create mode 100644 drivers/iio/adc/ad7606_spi.c
>  delete mode 100644 drivers/staging/iio/adc/ad7606.c
>  delete mode 100644 drivers/staging/iio/adc/ad7606.h
>  delete mode 100644 drivers/staging/iio/adc/ad7606_par.c
>  delete mode 100644 drivers/staging/iio/adc/ad7606_spi.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f642044..843545d 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -839,6 +839,13 @@ S:   Supported
>  F:   drivers/iio/dac/ad5758.c
>  F:   Documentation/devicetree/bindings/iio/dac/ad5758.txt
>  
> +ANALOG DEVICES INC AD7606 DRIVER
> +M:   Stefan Popa 
> +L:   linux-...@vger.kernel.org
> +W:   http://ez.analog.com/community/linux-device-drivers
> +S:   Supported
> +F:   drivers/iio/adc/ad7606.c
> +
>  ANALOG DEVICES INC AD9389B DRIVER
>  M:   Hans Verkuil 
>  L:   linux-me...@vger.kernel.org
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index a52fea8..c3f61c9 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -58,6 +58,34 @@ config AD7476
> To compile this driver as a module, choose M here: the
> module will be called ad7476.
>  
> +config AD7606
> + tristate
> + depends on GPIOLIB || COMPILE_TEST
> + depends on HAS_IOMEM
> + select IIO_BUFFER
> + select IIO_TRIGGERED_BUFFER
> +
> +config AD7606_IFACE_PARALLEL
> + tristate "Analog Devices AD7606 ADC driver with parallel interface 
> support"
> + select AD7606
> + help
> +   Say yes here to build parallel interface support for Analog Devices:
> +   ad7605-4, ad7606, ad7606-6, ad7606-4 analog to digital converters 
> (ADC).
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called ad7606_parallel.
> +
> +config AD7606_IFACE_SPI
> + tristate "Analog Devices AD7606 ADC driver with spi interface support"
> + depends on SPI
> + select AD7606
> + help
> +   Say yes here to build spi interface support for Analog Devices:
> +   ad7605-4, ad7606, ad7606-6, ad7606-4 analog to digital converters 
> (ADC).
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called ad7606_spi.
> +
>  config AD7766
>   tristate "Analog Devices AD7766/AD7767 ADC driver"
>   depends on SPI_MASTER
> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> index a6e6a0b..b734f4f 100644
> --- a/drivers

[PATCH 3/3] staging: rtl8723bs: remove semaphore remnants

2018-12-10 Thread Arnd Bergmann
Nothing uses the semaphores any more in this driver, so remove
all references to that type.

Signed-off-by: Arnd Bergmann 
---
 drivers/staging/rtl8723bs/core/rtw_pwrctrl.c| 1 -
 drivers/staging/rtl8723bs/include/osdep_service_linux.h | 2 --
 drivers/staging/rtl8723bs/include/rtw_io.h  | 1 -
 drivers/staging/rtl8723bs/include/rtw_mp.h  | 1 -
 drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 5 -
 5 files changed, 10 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c 
b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index b7dd5fec9b31..eb27522a5444 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -1126,7 +1126,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter);
 
mutex_init(&pwrctrlpriv->lock);
-   sema_init(&pwrctrlpriv->check_32k_lock, 1);
pwrctrlpriv->rf_pwrstate = rf_on;
pwrctrlpriv->ips_enter_cnts = 0;
pwrctrlpriv->ips_leave_cnts = 0;
diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h 
b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
index 58d1e1019241..2f1b51e614fb 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
@@ -22,7 +22,6 @@
#include 
#include 
#include 
-   #include 
#include 
#include 
#include 
@@ -41,7 +40,6 @@
 #include 
#include 
 
-   typedef struct  semaphore _sema;
typedef spinlock_t  _lock;
typedef struct mutex_mutex;
typedef struct timer_list _timer;
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h 
b/drivers/staging/rtl8723bs/include/rtw_io.h
index 4f8be55da65d..99d104b3647a 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -115,7 +115,6 @@ struct io_req {
u32 command;
u32 status;
u8 *pbuf;
-   _sema   sema;
 
void (*_async_io_callback)(struct adapter *padater, struct io_req 
*pio_req, u8 *cnxt);
u8 *cnxt;
diff --git a/drivers/staging/rtl8723bs/include/rtw_mp.h 
b/drivers/staging/rtl8723bs/include/rtw_mp.h
index 839084733201..bb3970d58573 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mp.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mp.h
@@ -62,7 +62,6 @@ typedef struct _MPT_CONTEXT
/*  Indicate if the driver is unloading or unloaded. */
boolbMptDrvUnload;
 
-   _sema   MPh2c_Sema;
_timer  MPh2c_timeout_timer;
 /*  Event used to sync H2c for BT control */
 
diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h 
b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
index abf48ae01900..e2a4c680125f 100644
--- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
@@ -94,10 +94,6 @@ struct reportpwrstate_parm {
unsigned short rsvd;
 };
 
-
-typedef _sema _pwrlock;
-
-
 #define LPS_DELAY_TIME 1*HZ /*  1 sec */
 
 #define EXE_PWR_NONE   0x01
@@ -209,7 +205,6 @@ typedef struct pno_scan_info
 struct pwrctrl_priv
 {
struct mutex lock;
-   _pwrlockcheck_32k_lock;
volatile u8 rpwm; /*  requested power state for fw */
volatile u8 cpwm; /*  fw current power state. updated when 1. read from 
HCPWM 2. driver lowers power level */
volatile u8 tog; /*  toggling */
-- 
2.20.0

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


[PATCH 1/3] staging: rtl8723bs: change semaphores to completions

2018-12-10 Thread Arnd Bergmann
This driver uses many semaphores, most of them are equivalent to
completions. The other copies of this driver got moved over to
completions a while ago, so do the same here.

In this usage scenario, the two are equivalent, so the behavior
should not change.

Signed-off-by: Arnd Bergmann 
---
 drivers/staging/rtl8723bs/core/rtw_cmd.c  | 20 -
 drivers/staging/rtl8723bs/core/rtw_mlme.c |  2 --
 drivers/staging/rtl8723bs/core/rtw_pwrctrl.c  |  4 ++--
 drivers/staging/rtl8723bs/core/rtw_xmit.c |  8 +++
 .../staging/rtl8723bs/hal/rtl8723b_hal_init.c |  4 ++--
 .../staging/rtl8723bs/hal/rtl8723bs_xmit.c| 22 ---
 drivers/staging/rtl8723bs/hal/sdio_ops.c  |  2 +-
 drivers/staging/rtl8723bs/include/rtw_cmd.h   |  7 +++---
 drivers/staging/rtl8723bs/include/rtw_xmit.h  |  9 
 drivers/staging/rtl8723bs/os_dep/os_intfs.c   |  6 ++---
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c |  2 +-
 11 files changed, 39 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 830be63391b7..3d206c33eafa 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -166,10 +166,8 @@ sint   _rtw_init_cmd_priv(struct   cmd_priv 
*pcmdpriv)
 {
sint res = _SUCCESS;
 
-   sema_init(&(pcmdpriv->cmd_queue_sema), 0);
-   /* sema_init(&(pcmdpriv->cmd_done_sema), 0); */
-   sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
-
+   init_completion(&pcmdpriv->cmd_queue_comp);
+   init_completion(&pcmdpriv->terminate_cmdthread_comp);
 
_rtw_init_queue(&(pcmdpriv->cmd_queue));
 
@@ -369,7 +367,7 @@ u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct 
cmd_obj *cmd_obj)
res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj);
 
if (res == _SUCCESS)
-   up(&pcmdpriv->cmd_queue_sema);
+   complete(&pcmdpriv->cmd_queue_comp);
 
 exit:
return res;
@@ -410,8 +408,8 @@ void rtw_stop_cmd_thread(struct adapter *adapter)
atomic_read(&(adapter->cmdpriv.cmdthd_running)) == true &&
adapter->cmdpriv.stop_req == 0) {
adapter->cmdpriv.stop_req = 1;
-   up(&adapter->cmdpriv.cmd_queue_sema);
-   down(&adapter->cmdpriv.terminate_cmdthread_sema);
+   complete(&adapter->cmdpriv.cmd_queue_comp);
+   wait_for_completion(&adapter->cmdpriv.terminate_cmdthread_comp);
}
 }
 
@@ -435,13 +433,13 @@ int rtw_cmd_thread(void *context)
 
pcmdpriv->stop_req = 0;
atomic_set(&(pcmdpriv->cmdthd_running), true);
-   up(&pcmdpriv->terminate_cmdthread_sema);
+   complete(&pcmdpriv->terminate_cmdthread_comp);
 
RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x 
rtw_cmd_thread \n"));
 
while (1) {
-   if (down_interruptible(&pcmdpriv->cmd_queue_sema)) {
-   DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" 
down_interruptible(&pcmdpriv->cmd_queue_sema) return != 0, break\n", 
FUNC_ADPT_ARG(padapter));
+   if 
(wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp)) {
+   DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" 
wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp) return != 0, 
break\n", FUNC_ADPT_ARG(padapter));
break;
}
 
@@ -581,7 +579,7 @@ int rtw_cmd_thread(void *context)
rtw_free_cmd_obj(pcmd);
} while (1);
 
-   up(&pcmdpriv->terminate_cmdthread_sema);
+   complete(&pcmdpriv->terminate_cmdthread_comp);
atomic_set(&(pcmdpriv->cmdthd_running), false);
 
thread_exit();
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 4c5d5cf9dfe0..81505f3bce8b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -2373,8 +2373,6 @@ sint rtw_set_key(struct adapter *adapter, struct 
security_priv *psecuritypriv, s
 
INIT_LIST_HEAD(&pcmd->list);
 
-   /* sema_init(&(pcmd->cmd_sem), 0); */
-
res = rtw_enqueue_cmd(pcmdpriv, pcmd);
} else{
setkey_hdl(adapter, (u8 *)psetkeyparm);
diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c 
b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index 59a667753266..a0d8fbeecf9b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -745,10 +745,10 @@ void cpwm_int_hdl(
 
if (pwrpriv->cpwm >= PS_STATE_S2) {
if (pwrpriv->alives & CMD_ALIVE)
-   up(&padapter->cmdpriv.cmd_queue_sema);
+   complete(&padapter->cmdpriv.cmd_queue_comp);
 
if (pwrpriv->alives & XMIT_ALIVE)
-   up(&padapter->xmitpriv.xmit_sema);
+   complete(&padapter->xmitpriv.

[PATCH 2/3] staging: rtl8723bs: change pwrctrl lock to a mutex

2018-12-10 Thread Arnd Bergmann
This semaphore is used like a mutex, so it should use the regular
mutex API, as we do in the other copies of this driver.

Signed-off-by: Arnd Bergmann 
---
 drivers/staging/rtl8723bs/core/rtw_cmd.c  |  4 +-
 drivers/staging/rtl8723bs/core/rtw_pwrctrl.c  | 73 +--
 .../staging/rtl8723bs/include/rtw_pwrctrl.h   |  3 +-
 3 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 3d206c33eafa..984db6f2217c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -1621,7 +1621,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter 
*padapter, u8 dtim)
if (rtw_btcoex_IsBtControlLps(padapter) == true)
return;
 
-   down(&pwrpriv->lock);
+   mutex_lock(&pwrpriv->lock);
 
if (pwrpriv->dtim != dtim) {
DBG_871X("change DTIM from %d to %d, bFwCurrentInPSMode =%d, 
ps_mode =%d\n", pwrpriv->dtim, dtim,
@@ -1638,7 +1638,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter 
*padapter, u8 dtim)
rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 
*)(&ps_mode));
}
 
-   up(&pwrpriv->lock);
+   mutex_unlock(&pwrpriv->lock);
 }
 
 static void rtw_dm_ra_mask_hdl(struct adapter *padapter, struct sta_info *psta)
diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c 
b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index a0d8fbeecf9b..b7dd5fec9b31 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -45,9 +45,9 @@ void ips_enter(struct adapter *padapter)
 
rtw_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req);
 
-   down(&pwrpriv->lock);
+   mutex_lock(&pwrpriv->lock);
_ips_enter(padapter);
-   up(&pwrpriv->lock);
+   mutex_unlock(&pwrpriv->lock);
 }
 
 int _ips_leave(struct adapter *padapter)
@@ -85,9 +85,9 @@ int ips_leave(struct adapter *padapter)
if (!is_primary_adapter(padapter))
return _SUCCESS;
 
-   down(&pwrpriv->lock);
+   mutex_lock(&pwrpriv->lock);
ret = _ips_leave(padapter);
-   up(&pwrpriv->lock);
+   mutex_unlock(&pwrpriv->lock);
 
if (_SUCCESS == ret)
rtw_btcoex_IpsNotify(padapter, IPS_NONE);
@@ -158,9 +158,9 @@ void rtw_ps_processor(struct adapter *padapter)
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
u32 ps_deny = 0;
 
-   down(&adapter_to_pwrctl(padapter)->lock);
+   mutex_lock(&adapter_to_pwrctl(padapter)->lock);
ps_deny = rtw_ps_deny_get(padapter);
-   up(&adapter_to_pwrctl(padapter)->lock);
+   mutex_unlock(&adapter_to_pwrctl(padapter)->lock);
if (ps_deny != 0) {
DBG_871X(FUNC_ADPT_FMT ": ps_deny = 0x%08X, skip power save!\n",
FUNC_ADPT_ARG(padapter), ps_deny);
@@ -413,7 +413,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, 
u8 smart_ps, u8 bcn_a
return;
 
 
-   down(&pwrpriv->lock);
+   mutex_lock(&pwrpriv->lock);
 
/* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */
if (ps_mode == PS_MODE_ACTIVE) {
@@ -494,7 +494,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, 
u8 smart_ps, u8 bcn_a
}
}
 
-   up(&pwrpriv->lock);
+   mutex_unlock(&pwrpriv->lock);
 }
 
 /*
@@ -628,11 +628,11 @@ void LeaveAllPowerSaveModeDirect(struct adapter *Adapter)
return;
}
 
-   down(&pwrpriv->lock);
+   mutex_lock(&pwrpriv->lock);
 
rtw_set_rpwm(Adapter, PS_STATE_S4);
 
-   up(&pwrpriv->lock);
+   mutex_unlock(&pwrpriv->lock);
 
rtw_lps_ctrl_wk_cmd(pri_padapter, LPS_CTRL_LEAVE, 0);
} else{
@@ -696,7 +696,7 @@ void LPS_Leave_check(
cond_resched();
 
while (1) {
-   down(&pwrpriv->lock);
+   mutex_lock(&pwrpriv->lock);
 
if ((padapter->bSurpriseRemoved == true)
|| (padapter->hw_init_completed == false)
@@ -704,7 +704,7 @@ void LPS_Leave_check(
)
bReady = true;
 
-   up(&pwrpriv->lock);
+   mutex_unlock(&pwrpriv->lock);
 
if (true == bReady)
break;
@@ -732,11 +732,10 @@ void cpwm_int_hdl(
 
pwrpriv = adapter_to_pwrctl(padapter);
 
-   down(&pwrpriv->lock);
+   mutex_lock(&pwrpriv->lock);
 
if (pwrpriv->rpwm < PS_STATE_S2) {
DBG_871X("%s: Redundant CPWM Int. RPWM = 0x%02X CPWM = 
0x%02x\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm);
-   up(&pwrpriv->lock);
goto exit;
}
 
@@ -751,9 +750,9 @@ void cpwm_int_hdl(
complete(&padapter->xmitpriv.xmit_comp);
}
 
-   up(&pwrpriv->lock);
-
 exit:
+   mutex_unlock(

[PATCH] staging: speakup: change semaphore to completion

2018-12-10 Thread Arnd Bergmann
In this driver, both function the same way, but we want to eventually
kill off semaphores, so a completion is the better choice here.

Signed-off-by: Arnd Bergmann 
---
 drivers/staging/speakup/spk_ttyio.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/speakup/spk_ttyio.c 
b/drivers/staging/speakup/spk_ttyio.c
index 979e3ae249c1..c92bbd05516e 100644
--- a/drivers/staging/speakup/spk_ttyio.c
+++ b/drivers/staging/speakup/spk_ttyio.c
@@ -10,7 +10,7 @@
 
 struct spk_ldisc_data {
char buf;
-   struct semaphore sem;
+   struct completion completion;
bool buf_free;
 };
 
@@ -55,7 +55,7 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty)
if (!ldisc_data)
return -ENOMEM;
 
-   sema_init(&ldisc_data->sem, 0);
+   init_completion(&ldisc_data->completion);
ldisc_data->buf_free = true;
speakup_tty->disc_data = ldisc_data;
 
@@ -95,7 +95,7 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty,
 
ldisc_data->buf = cp[0];
ldisc_data->buf_free = false;
-   up(&ldisc_data->sem);
+   complete(&ldisc_data->completion);
 
return 1;
 }
@@ -286,7 +286,8 @@ static unsigned char ttyio_in(int timeout)
struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;
char rv;
 
-   if (down_timeout(&ldisc_data->sem, usecs_to_jiffies(timeout)) == 
-ETIME) {
+   if (wait_for_completion_timeout(&ldisc_data->completion,
+   usecs_to_jiffies(timeout)) == 0) {
if (timeout)
pr_warn("spk_ttyio: timeout (%d)  while waiting for 
input\n",
timeout);
-- 
2.20.0

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


Re: [PATCH] staging: speakup: change semaphore to completion

2018-12-10 Thread Samuel Thibault
Arnd Bergmann, le lun. 10 déc. 2018 22:41:50 +0100, a ecrit:
> In this driver, both function the same way, but we want to eventually
> kill off semaphores, so a completion is the better choice here.
> 
> Signed-off-by: Arnd Bergmann 

Reviewed-by: Samuel Thibault 

> ---
>  drivers/staging/speakup/spk_ttyio.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/speakup/spk_ttyio.c 
> b/drivers/staging/speakup/spk_ttyio.c
> index 979e3ae249c1..c92bbd05516e 100644
> --- a/drivers/staging/speakup/spk_ttyio.c
> +++ b/drivers/staging/speakup/spk_ttyio.c
> @@ -10,7 +10,7 @@
>  
>  struct spk_ldisc_data {
>   char buf;
> - struct semaphore sem;
> + struct completion completion;
>   bool buf_free;
>  };
>  
> @@ -55,7 +55,7 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty)
>   if (!ldisc_data)
>   return -ENOMEM;
>  
> - sema_init(&ldisc_data->sem, 0);
> + init_completion(&ldisc_data->completion);
>   ldisc_data->buf_free = true;
>   speakup_tty->disc_data = ldisc_data;
>  
> @@ -95,7 +95,7 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty,
>  
>   ldisc_data->buf = cp[0];
>   ldisc_data->buf_free = false;
> - up(&ldisc_data->sem);
> + complete(&ldisc_data->completion);
>  
>   return 1;
>  }
> @@ -286,7 +286,8 @@ static unsigned char ttyio_in(int timeout)
>   struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;
>   char rv;
>  
> - if (down_timeout(&ldisc_data->sem, usecs_to_jiffies(timeout)) == 
> -ETIME) {
> + if (wait_for_completion_timeout(&ldisc_data->completion,
> + usecs_to_jiffies(timeout)) == 0) {
>   if (timeout)
>   pr_warn("spk_ttyio: timeout (%d)  while waiting for 
> input\n",
>   timeout);
> -- 
> 2.20.0
> 

-- 
Samuel
Progress (n.): The process through which the Internet has evolved from
smart people in front of dumb terminals to dumb people in front of smart
terminals.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v1] binder: implement binderfs(Internet mail)

2018-12-10 Thread 周威
> chouryzhou@, can you confirm that this implementation works for your
> android-in-container use-case?
> 
> -Todd
> 
We are running Android Pie in container now. If it works for later Android 
release, it will works for us.

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


Re: [PATCH v1] binder: implement binderfs(Internet mail)

2018-12-10 Thread Christian Brauner
On Tue, Dec 11, 2018 at 03:44:48AM +, chouryzhou(周威) wrote:
> > chouryzhou@, can you confirm that this implementation works for your
> > android-in-container use-case?
> > 
> > -Todd
> > 
> We are running Android Pie in container now. If it works for later Android 
> release, it will works for us.

The patchset is absolutely agnostic as to what Android version is
running. :) It has no userspace consequences.
If at all it makes it possible for Android to upgrade its userspace to
use additional devices in the future without having to recompile the
kernel. There's a whole lot of interesting things one could potentially
do with this. :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] staging: erofs: unzip_vle_lz4.c,utils.c: rectify BUG_ONs

2018-12-10 Thread Gao Xiang
remove all redundant BUG_ONs, and turn the rest
useful usages to DBG_BUGONs.

Signed-off-by: Gao Xiang 
---
 drivers/staging/erofs/unzip_vle_lz4.c |  2 +-
 drivers/staging/erofs/utils.c | 12 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/erofs/unzip_vle_lz4.c 
b/drivers/staging/erofs/unzip_vle_lz4.c
index de0a5d1365a4..52797bd89da1 100644
--- a/drivers/staging/erofs/unzip_vle_lz4.c
+++ b/drivers/staging/erofs/unzip_vle_lz4.c
@@ -79,7 +79,7 @@ int z_erofs_vle_plain_copy(struct page **compressed_pages,
if (compressed_pages[j] != page)
continue;
 
-   BUG_ON(mirrored[j]);
+   DBG_BUGON(mirrored[j]);
memcpy(percpu_data + j * PAGE_SIZE, dst, PAGE_SIZE);
mirrored[j] = true;
break;
diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c
index d2e3ace91046..b535898ca753 100644
--- a/drivers/staging/erofs/utils.c
+++ b/drivers/staging/erofs/utils.c
@@ -23,9 +23,6 @@ struct page *erofs_allocpage(struct list_head *pool, gfp_t 
gfp)
list_del(&page->lru);
} else {
page = alloc_pages(gfp | __GFP_NOFAIL, 0);
-
-   BUG_ON(page == NULL);
-   BUG_ON(page->mapping != NULL);
}
return page;
 }
@@ -58,7 +55,7 @@ struct erofs_workgroup *erofs_find_workgroup(
/* decrease refcount added by erofs_workgroup_put */
if (unlikely(oldcount == 1))
atomic_long_dec(&erofs_global_shrink_cnt);
-   BUG_ON(index != grp->index);
+   DBG_BUGON(index != grp->index);
}
rcu_read_unlock();
return grp;
@@ -71,8 +68,11 @@ int erofs_register_workgroup(struct super_block *sb,
struct erofs_sb_info *sbi;
int err;
 
-   /* grp->refcount should not < 1 */
-   BUG_ON(!atomic_read(&grp->refcount));
+   /* grp shouldn't be broken or used before */
+   if (unlikely(atomic_read(&grp->refcount) != 1)) {
+   DBG_BUGON(1);
+   return -EINVAL;
+   }
 
err = radix_tree_preload(GFP_NOFS);
if (err)
-- 
2.14.4

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


[PATCH 1/2] staging: erofs: unzip_{pagevec.h,vle.c}: rectify BUG_ONs

2018-12-10 Thread Gao Xiang
remove all redundant BUG_ONs, and turn the rest
useful usages to DBG_BUGONs.

Signed-off-by: Gao Xiang 
---

 - separate into 2 patches in case that the subject line is too long.

 drivers/staging/erofs/unzip_pagevec.h |  2 +-
 drivers/staging/erofs/unzip_vle.c | 33 +
 2 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/erofs/unzip_pagevec.h 
b/drivers/staging/erofs/unzip_pagevec.h
index 0956615b86f7..23856ba2742d 100644
--- a/drivers/staging/erofs/unzip_pagevec.h
+++ b/drivers/staging/erofs/unzip_pagevec.h
@@ -150,7 +150,7 @@ z_erofs_pagevec_ctor_dequeue(struct z_erofs_pagevec_ctor 
*ctor,
erofs_vtptr_t t;
 
if (unlikely(ctor->index >= ctor->nr)) {
-   BUG_ON(ctor->next == NULL);
+   DBG_BUGON(!ctor->next);
z_erofs_pagevec_ctor_pagedown(ctor, true);
}
 
diff --git a/drivers/staging/erofs/unzip_vle.c 
b/drivers/staging/erofs/unzip_vle.c
index 500046f271cb..4ac1099a39c6 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -41,9 +41,6 @@ static struct kmem_cache *z_erofs_workgroup_cachep 
__read_mostly;
 
 void z_erofs_exit_zip_subsystem(void)
 {
-   BUG_ON(!z_erofs_workqueue);
-   BUG_ON(!z_erofs_workgroup_cachep);
-
destroy_workqueue(z_erofs_workqueue);
kmem_cache_destroy(z_erofs_workgroup_cachep);
 }
@@ -445,7 +442,10 @@ z_erofs_vle_work_register(const struct 
z_erofs_vle_work_finder *f,
struct z_erofs_vle_work *work;
 
/* if multiref is disabled, grp should never be nullptr */
-   BUG_ON(grp);
+   if (unlikely(grp)) {
+   DBG_BUGON(1);
+   return ERR_PTR(-EINVAL);
+   }
 
/* no available workgroup, let's allocate one */
grp = kmem_cache_alloc(z_erofs_workgroup_cachep, GFP_NOFS);
@@ -836,7 +836,7 @@ static inline void z_erofs_vle_read_endio(struct bio *bio)
bool cachemngd = false;
 
DBG_BUGON(PageUptodate(page));
-   BUG_ON(!page->mapping);
+   DBG_BUGON(!page->mapping);
 
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
if (unlikely(!mc && !z_erofs_is_stagingpage(page))) {
@@ -891,7 +891,7 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 
might_sleep();
work = z_erofs_vle_grab_primary_work(grp);
-   BUG_ON(!READ_ONCE(work->nr_pages));
+   DBG_BUGON(!READ_ONCE(work->nr_pages));
 
mutex_lock(&work->lock);
nr_pages = work->nr_pages;
@@ -940,8 +940,8 @@ static int z_erofs_vle_unzip(struct super_block *sb,
else
pagenr = z_erofs_onlinepage_index(page);
 
-   BUG_ON(pagenr >= nr_pages);
-   BUG_ON(pages[pagenr]);
+   DBG_BUGON(pagenr >= nr_pages);
+   DBG_BUGON(pages[pagenr]);
 
pages[pagenr] = page;
}
@@ -965,8 +965,7 @@ static int z_erofs_vle_unzip(struct super_block *sb,
continue;
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
if (page->mapping == MNGD_MAPPING(sbi)) {
-   BUG_ON(PageLocked(page));
-   BUG_ON(!PageUptodate(page));
+   DBG_BUGON(!PageUptodate(page));
continue;
}
 #endif
@@ -974,8 +973,8 @@ static int z_erofs_vle_unzip(struct super_block *sb,
/* only non-head page could be reused as a compressed page */
pagenr = z_erofs_onlinepage_index(page);
 
-   BUG_ON(pagenr >= nr_pages);
-   BUG_ON(pages[pagenr]);
+   DBG_BUGON(pagenr >= nr_pages);
+   DBG_BUGON(pages[pagenr]);
++sparsemem_pages;
pages[pagenr] = page;
 
@@ -985,9 +984,6 @@ static int z_erofs_vle_unzip(struct super_block *sb,
llen = (nr_pages << PAGE_SHIFT) - work->pageofs;
 
if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) {
-   /* FIXME! this should be fixed in the future */
-   BUG_ON(grp->llen != llen);
-
err = z_erofs_vle_plain_copy(compressed_pages, clusterpages,
pages, nr_pages, work->pageofs);
goto out;
@@ -1002,10 +998,8 @@ static int z_erofs_vle_unzip(struct super_block *sb,
if (err != -ENOTSUPP)
goto out_percpu;
 
-   if (sparsemem_pages >= nr_pages) {
-   BUG_ON(sparsemem_pages > nr_pages);
+   if (sparsemem_pages >= nr_pages)
goto skip_allocpage;
-   }
 
for (i = 0; i < nr_pages; ++i) {
if (pages[i])
@@ -1098,7 +1092,7 @@ static void z_erofs_vle_unzip_wq(struct work_struct *work)
struct z_erofs_vle_unzip_io_sb, io.u.work);
LIST_HEAD(page_pool);
 
-   BUG_ON(iosb->io.head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED);
+   DBG_BUGON(iosb->io.head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED);
z_erofs_vle_unzi

Re: [PATCH 2/2] staging: erofs: unzip_vle_lz4.c,utils.c: rectify BUG_ONs

2018-12-10 Thread Chao Yu
On 2018/12/11 15:17, Gao Xiang wrote:
> remove all redundant BUG_ONs, and turn the rest
> useful usages to DBG_BUGONs.
> 
> Signed-off-by: Gao Xiang 

Reviewed-by: Chao Yu 

Thanks,

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


Re: [PATCH 1/2] staging: erofs: unzip_{pagevec.h,vle.c}: rectify BUG_ONs

2018-12-10 Thread Chao Yu
On 2018/12/11 15:17, Gao Xiang wrote:
> remove all redundant BUG_ONs, and turn the rest
> useful usages to DBG_BUGONs.
> 
> Signed-off-by: Gao Xiang 

Reviewed-by: Chao Yu 

Thanks,

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