Re: [Outreachy kernel] [PATCH] staging: qlge: Fix multiple assignments warning by splitting the assignement into two each

2019-10-09 Thread Julia Lawall



On Wed, 9 Oct 2019, Joe Perches wrote:

> On Wed, 2019-10-09 at 22:48 +0200, Julia Lawall wrote:
> > On Wed, 9 Oct 2019, Jules Irenge wrote:
> > > Fix multiple assignments warning " check
> > >  issued by checkpatch.pl tool:
> > > "CHECK: multiple assignments should be avoided".
> []
> > > diff --git a/drivers/staging/qlge/qlge_dbg.c 
> > > b/drivers/staging/qlge/qlge_dbg.c
> []
> > > @@ -141,8 +141,10 @@ static int ql_get_serdes_regs(struct ql_adapter 
> > > *qdev,
> > >   u32 *direct_ptr, temp;
> > >   u32 *indirect_ptr;
> > >
> > > - xfi_direct_valid = xfi_indirect_valid = 0;
> > > - xaui_direct_valid = xaui_indirect_valid = 1;
> > > + xfi_indirect_valid = 0;
> > > + xfi_direct_valid = xfi_indirect_valid;
> > > + xaui_indirect_valid = 1;
> > > + xaui_direct_valid = xaui_indirect_valid
> >
> > Despite checkpatch, I think that the original code was easier to
> > understand.
>
> It'd likely be easier to understand if all the
> _valid uses were bool and the ql_get_both_serdes
> _valid arguments were change to bool from
> unsigned int as well.

Indeed, given the names and the values, bool would be much better.

> btw: qlge likely is going to be deleted and not updated.

OK.  Jules, if you want to make this change, you can, but it could be
better to move on to some other driver.

thanks,
julia

>
> ---
>  drivers/staging/qlge/qlge_dbg.c | 22 ++
>  1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
> index 7e16066a3527..90ab37d4c49d 100644
> --- a/drivers/staging/qlge/qlge_dbg.c
> +++ b/drivers/staging/qlge/qlge_dbg.c
> @@ -112,7 +112,7 @@ static int ql_read_serdes_reg(struct ql_adapter *qdev, 
> u32 reg, u32 *data)
>
>  static void ql_get_both_serdes(struct ql_adapter *qdev, u32 addr,
>   u32 *direct_ptr, u32 *indirect_ptr,
> - unsigned int direct_valid, unsigned int indirect_valid)
> + bool direct_valid, bool indirect_valid)
>  {
>   unsigned int status;
>
> @@ -136,14 +136,12 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
>   struct ql_mpi_coredump *mpi_coredump)
>  {
>   int status;
> - unsigned int xfi_direct_valid, xfi_indirect_valid, xaui_direct_valid;
> - unsigned int xaui_indirect_valid, i;
> + bool xfi_direct_valid = false, xfi_indirect_valid = false;
> + bool xaui_direct_valid = true, xaui_indirect_valid = true;
> + unsigned int i;
>   u32 *direct_ptr, temp;
>   u32 *indirect_ptr;
>
> - xfi_direct_valid = xfi_indirect_valid = 0;
> - xaui_direct_valid = xaui_indirect_valid = 1;
> -
>   /* The XAUI needs to be read out per port */
>   status = ql_read_other_func_serdes_reg(qdev,
>   XG_SERDES_XAUI_HSS_PCS_START, );
> @@ -152,7 +150,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
>
>   if ((temp & XG_SERDES_ADDR_XAUI_PWR_DOWN) ==
>   XG_SERDES_ADDR_XAUI_PWR_DOWN)
> - xaui_indirect_valid = 0;
> + xaui_indirect_valid = false;
>
>   status = ql_read_serdes_reg(qdev, XG_SERDES_XAUI_HSS_PCS_START, );
>
> @@ -161,7 +159,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
>
>   if ((temp & XG_SERDES_ADDR_XAUI_PWR_DOWN) ==
>   XG_SERDES_ADDR_XAUI_PWR_DOWN)
> - xaui_direct_valid = 0;
> + xaui_direct_valid = false;
>
>   /*
>* XFI register is shared so only need to read one
> @@ -176,18 +174,18 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
>   /* now see if i'm NIC 1 or NIC 2 */
>   if (qdev->func & 1)
>   /* I'm NIC 2, so the indirect (NIC1) xfi is up. */
> - xfi_indirect_valid = 1;
> + xfi_indirect_valid = true;
>   else
> - xfi_direct_valid = 1;
> + xfi_direct_valid = true;
>   }
>   if ((temp & XG_SERDES_ADDR_XFI2_PWR_UP) ==
>   XG_SERDES_ADDR_XFI2_PWR_UP) {
>   /* now see if i'm NIC 1 or NIC 2 */
>   if (qdev->func & 1)
>   /* I'm NIC 2, so the indirect (NIC1) xfi is up. */
> - xfi_direct_valid = 1;
> + xfi_direct_valid = true;
>   else
> - xfi_indirect_valid = 1;
> + xfi_indirect_valid = true;
>   }
>
>   /* Get XAUI_AN register block. */
>
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 4/4] staging: rtl8723bs: Remove unnecessary blank lines

2019-10-09 Thread Wambui Karuga
Remove multiple blank lines in
drivers/staging/rtl8723bs/core/rtw_mlme.c.
Issues reported by checkpatch.pl as:
CHECK: Please don't use multiple blank lines

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 47 ---
 1 file changed, 47 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 17da4170e861..02bc60d8478f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -208,7 +208,6 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
 
pmlmepriv->num_of_scanned--;
 
-
/* DBG_871X("_rtw_free_network:SSID =%s\n", 
pnetwork->network.Ssid.Ssid); */
 
spin_unlock_bh(_queue->lock);
@@ -300,12 +299,8 @@ void rtw_free_network_queue(struct adapter *padapter, u8 
isfreeall)
spin_unlock_bh(_queue->lock);
 }
 
-
-
-
 sint rtw_if_up(struct adapter *padapter)
 {
-
sint res;
 
if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
@@ -317,7 +312,6 @@ sint rtw_if_up(struct adapter *padapter)
return res;
 }
 
-
 void rtw_generate_random_ibss(u8 *pibss)
 {
unsigned long curtime = jiffies;
@@ -335,7 +329,6 @@ u8 *rtw_get_capability_from_ie(u8 *ie)
return ie + 8 + 2;
 }
 
-
 u16 rtw_get_capability(struct wlan_bssid_ex *bss)
 {
__le16  val;
@@ -423,7 +416,6 @@ int is_same_network(struct wlan_bssid_ex *src, struct 
wlan_bssid_ex *dst, u8 fea
memcpy((u8 *), rtw_get_capability_from_ie(src->IEs), 2);
memcpy((u8 *), rtw_get_capability_from_ie(dst->IEs), 2);
 
-
s_cap = le16_to_cpu(tmps);
d_cap = le16_to_cpu(tmpd);
 
@@ -465,7 +457,6 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
 {
struct list_head*plist, *phead;
 
-
struct  wlan_network*pwlan = NULL;
struct  wlan_network*oldest = NULL;
 
@@ -577,12 +568,8 @@ static void update_current_network(struct adapter 
*adapter, struct wlan_bssid_ex
}
 }
 
-
 /*
-
 Caller must hold pmlmepriv->lock first.
-
-
 */
 void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex 
*target)
 {
@@ -623,7 +610,6 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
 
}
 
-
/* If we didn't find a match, then get a new network slot to initialize
 * with this beacon's information */
/* if (phead == plist) { */
@@ -759,7 +745,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
}
}
 
-
if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 
0)) {
DBG_871X("desired_encmode: %d, privacy: %d\n", desired_encmode, 
privacy);
bselected = false;
@@ -770,7 +755,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
bselected = false;
}
 
-
return bselected;
 }
 
@@ -780,7 +764,6 @@ void rtw_atimdone_event_callback(struct adapter 
*adapter, u8 *pbuf)
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive 
atimdone_event\n"));
 }
 
-
 void rtw_survey_event_callback(struct adapter  *adapter, u8 *pbuf)
 {
u32 len;
@@ -797,7 +780,6 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
return;
}
 
-
spin_lock_bh(>lock);
 
/*  update IBSS_network 's timestamp */
@@ -830,8 +812,6 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
spin_unlock_bh(>lock);
 }
 
-
-
 void rtw_surveydone_event_callback(struct adapter  *adapter, u8 *pbuf)
 {
u8 timer_cancelled = false;
@@ -862,7 +842,6 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
if (timer_cancelled)
_cancel_timer(>scan_to_timer, _cancelled);
 
-
spin_lock_bh(>lock);
 
rtw_set_signal_stat_timer(>recvpriv);
@@ -1002,7 +981,6 @@ static void find_network(struct adapter *adapter)
else
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("rtw_free_assoc_resources : pwlan == NULL\n\n"));
 
-
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) &&
(adapter->stapriv.asoc_sta_count == 1))
rtw_free_network_nolock(adapter, pwlan);
@@ -1181,7 +1159,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
psta->wireless_mode = pmlmeext->cur_wireless_mode;
psta->raid = networktype_to_raid_ex(padapter, psta);
 
-
/* sta mode */
rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true);
 
@@ -1213,7 +1190,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
padapter->securitypriv.wps_ie_len = 0;
}
 
-
   

[PATCH v2 3/4] staging: rtl8723bs: Remove comparisons to booleans in conditionals.

2019-10-09 Thread Wambui Karuga
Remove comparisons to true and false in multiple if statements in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
CHECK: Using comparison to false is error prone
CHECK: Using comparison to true is error prone

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 29 +++
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index b15b761782b8..17da4170e861 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -187,7 +187,7 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
if (!pnetwork)
return;
 
-   if (pnetwork->fixed == true)
+   if (pnetwork->fixed)
return;
 
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
@@ -222,7 +222,7 @@ void _rtw_free_network_nolock(structmlme_priv 
*pmlmepriv, struct wlan_network *
if (!pnetwork)
return;
 
-   if (pnetwork->fixed == true)
+   if (pnetwork->fixed)
return;
 
/* spin_lock_irqsave(_queue->lock, irqL); */
@@ -480,7 +480,7 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
 
pwlan = LIST_CONTAINOR(plist, struct wlan_network, list);
 
-   if (pwlan->fixed != true) {
+   if (!pwlan->fixed) {
if (oldest == NULL || time_after(oldest->last_scanned, 
pwlan->last_scanned))
oldest = pwlan;
}
@@ -867,7 +867,7 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
rtw_set_signal_stat_timer(>recvpriv);
 
-   if (pmlmepriv->to_join == true) {
+   if (pmlmepriv->to_join) {
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
if (check_fwstate(pmlmepriv, _FW_LINKED) == false) {
set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
@@ -1368,7 +1368,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, 
u8 *pbuf)
if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
/* s1. find ptarget_wlan */
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-   if (the_same_macaddr == true) {
+   if (the_same_macaddr) {
ptarget_wlan = 
rtw_find_network(>scanned_queue, cur_network->network.MacAddress);
} else {
pcur_wlan = 
rtw_find_network(>scanned_queue, cur_network->network.MacAddress);
@@ -1843,7 +1843,7 @@ static void rtw_auto_scan_handler(struct adapter 
*padapter)
goto exit;
}
 
-   if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) {
+   if (pmlmepriv->LinkDetectInfo.bBusyTraffic) {
DBG_871X(FUNC_ADPT_FMT" exit BusyTraffic\n", 
FUNC_ADPT_ARG(padapter));
goto exit;
}
@@ -1863,20 +1863,20 @@ void rtw_dynamic_check_timer_handler(struct adapter 
*adapter)
if (!adapter)
return;
 
-   if (adapter->hw_init_completed == false)
+   if (!adapter->hw_init_completed)
return;
 
-   if ((adapter->bDriverStopped == true) || (adapter->bSurpriseRemoved == 
true))
+   if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
return;
 
-   if (adapter->net_closed == true)
+   if (adapter->net_closed)
return;
 
if (is_primary_adapter(adapter))
DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", 
hal_btcoex_IsBtDisabled(adapter), hal_btcoex_IsBtControlLps(adapter));
 
-   if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode == true)
-   && (hal_btcoex_IsBtControlLps(adapter) == false)
+   if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+   && !(hal_btcoex_IsBtControlLps(adapter))
) {
u8 bEnterPS;
 
@@ -2047,7 +2047,7 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme
 
 
/* check bssid, if needed */
-   if (mlme->assoc_by_bssid == true) {
+   if (mlme->assoc_by_bssid) {
if (memcmp(competitor->network.MacAddress, mlme->assoc_bssid, 
ETH_ALEN))
goto exit;
}
@@ -2805,7 +2805,6 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, 
uint ie_len, u8 channe
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
u8 cbw40_enable = 0;
 
-
if (!phtpriv->ht_option)
return;
 
@@ -2815,7 +2814,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, 

[PATCH v2 2/4] staging: rtl8723bs: Remove unnecessary braces for single statements

2019-10-09 Thread Wambui Karuga
Clean up multiple unnecessary braces around single statement blocks in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
WARNING: braces {} are not necessary for single statement blocks or
WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 37 ---
 1 file changed, 12 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 7f27287223e8..b15b761782b8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -112,9 +112,8 @@ void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 {
if (pmlmepriv) {
rtw_free_mlme_priv_ie_data(pmlmepriv);
-   if (pmlmepriv->free_bss_buf) {
+   if (pmlmepriv->free_bss_buf)
vfree(pmlmepriv->free_bss_buf);
-   }
}
 }
 
@@ -753,11 +752,10 @@ int rtw_is_desired_network(struct adapter *adapter, 
struct wlan_network *pnetwor
 
if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) {
p = rtw_get_ie(pnetwork->network.IEs + 
_BEACON_IE_OFFSET_, _RSN_IE_2_, _len, (pnetwork->network.IELength - 
_BEACON_IE_OFFSET_));
-   if (p && ie_len > 0) {
+   if (p && ie_len > 0)
bselected = true;
-   } else {
+   else
bselected = false;
-   }
}
}
 
@@ -822,9 +820,8 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
/*  lock pmlmepriv->lock when you accessing network_q */
if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) {
-   if (pnetwork->Ssid.Ssid[0] == 0) {
+   if (pnetwork->Ssid.Ssid[0] == 0)
pnetwork->Ssid.SsidLength = 0;
-   }
rtw_add_network(adapter, pnetwork);
}
 
@@ -893,9 +890,8 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
pmlmepriv->fw_state = 
WIFI_ADHOC_MASTER_STATE;
 
-   if (rtw_createbss_cmd(adapter) != 
_SUCCESS) {
-   RT_TRACE(_module_rtl871x_mlme_c_, 
_drv_err_, ("Error =>rtw_createbss_cmd status FAIL\n"));
-   }
+   if (rtw_createbss_cmd(adapter) != 
_SUCCESS)
+   
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd status 
FAIL\n"));
 
pmlmepriv->to_join = false;
}
@@ -1166,9 +1162,8 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
 
psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
-   if (!psta) {
+   if (!psta)
psta = rtw_alloc_stainfo(pstapriv, 
pnetwork->network.MacAddress);
-   }
 
if (psta) { /* update ptarget_sta */
 
@@ -1347,11 +1342,10 @@ void rtw_joinbss_event_prehandle(struct adapter 
*adapter, u8 *pbuf)
rtw_get_encrypt_decrypt_from_registrypriv(adapter);
 
 
-   if (pmlmepriv->assoc_ssid.SsidLength == 0) {
+   if (pmlmepriv->assoc_ssid.SsidLength == 0)
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@   joinbss 
event call back  for Any SSid\n"));
-   } else {
+   else
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@   
rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid));
-   }
 
the_same_macaddr = !memcmp(pnetwork->network.MacAddress, 
cur_network->network.MacAddress, ETH_ALEN);
 
@@ -1723,13 +1717,8 @@ void rtw_stadel_event_callback(struct adapter *adapter, 
u8 *pbuf)
_clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE);
}
 
-   if (rtw_createbss_cmd(adapter) != _SUCCESS) {
-
+   if (rtw_createbss_cmd(adapter) != _SUCCESS)
RT_TRACE(_module_rtl871x_ioctl_set_c_, 
_drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd status 
FAIL***\n "));
-
-   }
-
-
}
 
}
@@ -1902,9 +1891,8 @@ void rtw_dynamic_check_timer_handler(struct adapter 
*adapter)
}
 
} else {
-   if (is_primary_adapter(adapter)) {
+   if (is_primary_adapter(adapter))
rtw_dynamic_chk_wk_cmd(adapter);
-   }
}
 
/* auto site survey */
@@ -2988,9 +2976,8 @@ void rtw_append_exented_cap(struct adapter *padapter, u8 
*out_ie, uint 

[PATCH v2 1/4] staging: rtl8723bs: Remove comparisons to NULL in conditionals

2019-10-09 Thread Wambui Karuga
Remove most comparisons to NULL in conditionals in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
CHECK: Comparison to NULL could be written

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 46 +++
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 0ac7712223af..7f27287223e8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -40,7 +40,7 @@ int   rtw_init_mlme_priv(struct adapter *padapter)
 
pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network)));
 
-   if (pbuf == NULL) {
+   if (!pbuf) {
res = _FAIL;
goto exit;
}
@@ -185,7 +185,7 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
 /* _irqL irqL; */
struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
 
-   if (pnetwork == NULL)
+   if (!pnetwork)
return;
 
if (pnetwork->fixed == true)
@@ -220,7 +220,7 @@ void _rtw_free_network_nolock(structmlme_priv 
*pmlmepriv, struct wlan_network *
 
struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
 
-   if (pnetwork == NULL)
+   if (!pnetwork)
return;
 
if (pnetwork->fixed == true)
@@ -633,7 +633,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
/* If there are no more slots, expire the oldest */
/* list_del_init(>list); */
pnetwork = oldest;
-   if (pnetwork == NULL) {
+   if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("\n\n\nsomething wrong here\n\n\n"));
goto exit;
}
@@ -654,7 +654,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
 
pnetwork = rtw_alloc_network(pmlmepriv); /*  will 
update scan_time */
 
-   if (pnetwork == NULL) {
+   if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("\n\n\nsomething wrong here\n\n\n"));
goto exit;
}
@@ -738,7 +738,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
privacy = pnetwork->network.Privacy;
 
if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
-   if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, 
pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, _ielen) != NULL)
+   if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, 
pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, _ielen))
return true;
else
return false;
@@ -1166,7 +1166,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
 
psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
-   if (psta == NULL) {
+   if (!psta) {
psta = rtw_alloc_stainfo(pstapriv, 
pnetwork->network.MacAddress);
}
 
@@ -1413,7 +1413,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, 
u8 *pbuf)
/* s3. find ptarget_sta & update ptarget_sta after 
update cur_network only for station mode */
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == 
true) {
ptarget_sta = 
rtw_joinbss_update_stainfo(adapter, pnetwork);
-   if (ptarget_sta == NULL) {
+   if (!ptarget_sta) {
RT_TRACE(_module_rtl871x_mlme_c_, 
_drv_err_, ("Can't update stainfo when joinbss_event callback\n"));

spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
goto ignore_joinbss_callback;
@@ -1503,7 +1503,7 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, 
struct sta_info *psta, u3
 {
u16 media_status_rpt;
 
-   if (psta == NULL)
+   if (!psta)
return;
 
media_status_rpt = (u16)((psta->mac_id<<8)|mstatus); /*   
MACID|OPMODE:1 connect */
@@ -1561,7 +1561,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, 
u8 *pbuf)
 
/* for AD-HOC mode */
psta = rtw_get_stainfo(>stapriv, pstassoc->macaddr);
-   if (psta != NULL) {
+   if (psta) {
/* the sta have been in sta_info_queue => do nothing */
 
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: 
rtw_stassoc_event_callback: sta has been in sta_hash_queue\n"));
@@ -1570,7 +1570,7 

[PATCH v2 0/4] staging: rtl8723bs: Style clean-up in rtw_mlme.c

2019-10-09 Thread Wambui Karuga
This patchset addresses multiple style and formatting issues reported by
checkpatch.pl in drivers/staging/rtl8723bs/core/rtw_mlme.c

PATCH v2 of the series corrects the "patchest" mispelling in the
original cover letter and provides a clearer subject line.

Wambui Karuga (4):
  staging: rtl8723bs: Remove comparisons to NULL in conditionals
  staging: rtl8723bs: Remove unnecessary braces for single statements
  staging: rtl8723bs: Remove comparisons to booleans in conditionals.
  staging: rtl8723bs: Remove unnecessary blank lines

 drivers/staging/rtl8723bs/core/rtw_mlme.c | 157 +++---
 1 file changed, 48 insertions(+), 109 deletions(-)

-- 
2.23.0

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


[PATCH] staging: octeon: Fix incorrect type in assignment

2019-10-09 Thread Wambui Karuga
Fix the following warning generated by sparse in
drivers/staging/octeon/ethernet-tx.c:

drivers/staging/octeon/ethernet-tx.c:563:50: warning: incorrect type in 
assignment (different base types)
drivers/staging/octeon/ethernet-tx.c:563:50:expected unsigned short 
[usertype] hw_chksum
drivers/staging/octeon/ethernet-tx.c:563:50:got restricted __wsum 
[usertype] csum

Warning generated by running:
make C=2 CF="-D__CHECK_ENDIAN__" drivers/staging/octeon/

Signed-off-by: Wambui Karuga 
---
 drivers/staging/octeon/octeon-stubs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/octeon/octeon-stubs.h 
b/drivers/staging/octeon/octeon-stubs.h
index 38954b6c89e1..b2e3c72205dd 100644
--- a/drivers/staging/octeon/octeon-stubs.h
+++ b/drivers/staging/octeon/octeon-stubs.h
@@ -123,7 +123,7 @@ union cvmx_pip_wqe_word0 {
struct {
uint64_t next_ptr:40;
uint8_t unused;
-   uint16_t hw_chksum;
+   __wsum hw_chksum;
} cn38xx;
struct {
uint64_t pknd:6;/* 0..5 */
-- 
2.23.0

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


[PATCH] staging: sm750fb: Potential uninitialized field in "pll"

2019-10-09 Thread Yizhuo
Inside function set_chip_clock(), struct pll is supposed to be
initialized in sm750_calc_pll_value(), if condition
"diff < mini_diff" in sm750_calc_pll_value() cannot be fulfilled,
then some field of pll will not be initialized but used in
function sm750_format_pll_reg(), which is potentially unsafe.

Signed-off-by: Yizhuo 
---
 drivers/staging/sm750fb/ddk750_chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c 
b/drivers/staging/sm750fb/ddk750_chip.c
index 5a317cc98a4b..31b3cf9c2d8b 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -55,7 +55,7 @@ static unsigned int get_mxclk_freq(void)
  */
 static void set_chip_clock(unsigned int frequency)
 {
-   struct pll_value pll;
+   struct pll_value pll = {};
unsigned int actual_mx_clk;
 
/* Cheok_0509: For SM750LE, the chip clock is fixed. Nothing to set. */
-- 
2.17.1

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


[PATCH 4/4] staging: rtl8723bs: Remove unnecessary blank lines

2019-10-09 Thread Wambui Karuga
Remove multiple blank lines in
drivers/staging/rtl8723bs/core/rtw_mlme.c.
Issues reported by checkpatch.pl as:
CHECK: Please don't use multiple blank lines

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 47 ---
 1 file changed, 47 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 17da4170e861..02bc60d8478f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -208,7 +208,6 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
 
pmlmepriv->num_of_scanned--;
 
-
/* DBG_871X("_rtw_free_network:SSID =%s\n", 
pnetwork->network.Ssid.Ssid); */
 
spin_unlock_bh(_queue->lock);
@@ -300,12 +299,8 @@ void rtw_free_network_queue(struct adapter *padapter, u8 
isfreeall)
spin_unlock_bh(_queue->lock);
 }
 
-
-
-
 sint rtw_if_up(struct adapter *padapter)
 {
-
sint res;
 
if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
@@ -317,7 +312,6 @@ sint rtw_if_up(struct adapter *padapter)
return res;
 }
 
-
 void rtw_generate_random_ibss(u8 *pibss)
 {
unsigned long curtime = jiffies;
@@ -335,7 +329,6 @@ u8 *rtw_get_capability_from_ie(u8 *ie)
return ie + 8 + 2;
 }
 
-
 u16 rtw_get_capability(struct wlan_bssid_ex *bss)
 {
__le16  val;
@@ -423,7 +416,6 @@ int is_same_network(struct wlan_bssid_ex *src, struct 
wlan_bssid_ex *dst, u8 fea
memcpy((u8 *), rtw_get_capability_from_ie(src->IEs), 2);
memcpy((u8 *), rtw_get_capability_from_ie(dst->IEs), 2);
 
-
s_cap = le16_to_cpu(tmps);
d_cap = le16_to_cpu(tmpd);
 
@@ -465,7 +457,6 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
 {
struct list_head*plist, *phead;
 
-
struct  wlan_network*pwlan = NULL;
struct  wlan_network*oldest = NULL;
 
@@ -577,12 +568,8 @@ static void update_current_network(struct adapter 
*adapter, struct wlan_bssid_ex
}
 }
 
-
 /*
-
 Caller must hold pmlmepriv->lock first.
-
-
 */
 void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex 
*target)
 {
@@ -623,7 +610,6 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
 
}
 
-
/* If we didn't find a match, then get a new network slot to initialize
 * with this beacon's information */
/* if (phead == plist) { */
@@ -759,7 +745,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
}
}
 
-
if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 
0)) {
DBG_871X("desired_encmode: %d, privacy: %d\n", desired_encmode, 
privacy);
bselected = false;
@@ -770,7 +755,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
bselected = false;
}
 
-
return bselected;
 }
 
@@ -780,7 +764,6 @@ void rtw_atimdone_event_callback(struct adapter 
*adapter, u8 *pbuf)
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive 
atimdone_event\n"));
 }
 
-
 void rtw_survey_event_callback(struct adapter  *adapter, u8 *pbuf)
 {
u32 len;
@@ -797,7 +780,6 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
return;
}
 
-
spin_lock_bh(>lock);
 
/*  update IBSS_network 's timestamp */
@@ -830,8 +812,6 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
spin_unlock_bh(>lock);
 }
 
-
-
 void rtw_surveydone_event_callback(struct adapter  *adapter, u8 *pbuf)
 {
u8 timer_cancelled = false;
@@ -862,7 +842,6 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
if (timer_cancelled)
_cancel_timer(>scan_to_timer, _cancelled);
 
-
spin_lock_bh(>lock);
 
rtw_set_signal_stat_timer(>recvpriv);
@@ -1002,7 +981,6 @@ static void find_network(struct adapter *adapter)
else
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("rtw_free_assoc_resources : pwlan == NULL\n\n"));
 
-
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) &&
(adapter->stapriv.asoc_sta_count == 1))
rtw_free_network_nolock(adapter, pwlan);
@@ -1181,7 +1159,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
psta->wireless_mode = pmlmeext->cur_wireless_mode;
psta->raid = networktype_to_raid_ex(padapter, psta);
 
-
/* sta mode */
rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true);
 
@@ -1213,7 +1190,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
padapter->securitypriv.wps_ie_len = 0;
}
 
-
   

[PATCH 3/4] staging: rtl8723bs: Remove comparisons to booleans in conditionals.

2019-10-09 Thread Wambui Karuga
Remove comparisons to true and false in multiple if statements in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
CHECK: Using comparison to false is error prone
CHECK: Using comparison to true is error prone

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 29 +++
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index b15b761782b8..17da4170e861 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -187,7 +187,7 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
if (!pnetwork)
return;
 
-   if (pnetwork->fixed == true)
+   if (pnetwork->fixed)
return;
 
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
@@ -222,7 +222,7 @@ void _rtw_free_network_nolock(structmlme_priv 
*pmlmepriv, struct wlan_network *
if (!pnetwork)
return;
 
-   if (pnetwork->fixed == true)
+   if (pnetwork->fixed)
return;
 
/* spin_lock_irqsave(_queue->lock, irqL); */
@@ -480,7 +480,7 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
 
pwlan = LIST_CONTAINOR(plist, struct wlan_network, list);
 
-   if (pwlan->fixed != true) {
+   if (!pwlan->fixed) {
if (oldest == NULL || time_after(oldest->last_scanned, 
pwlan->last_scanned))
oldest = pwlan;
}
@@ -867,7 +867,7 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
rtw_set_signal_stat_timer(>recvpriv);
 
-   if (pmlmepriv->to_join == true) {
+   if (pmlmepriv->to_join) {
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
if (check_fwstate(pmlmepriv, _FW_LINKED) == false) {
set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
@@ -1368,7 +1368,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, 
u8 *pbuf)
if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
/* s1. find ptarget_wlan */
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-   if (the_same_macaddr == true) {
+   if (the_same_macaddr) {
ptarget_wlan = 
rtw_find_network(>scanned_queue, cur_network->network.MacAddress);
} else {
pcur_wlan = 
rtw_find_network(>scanned_queue, cur_network->network.MacAddress);
@@ -1843,7 +1843,7 @@ static void rtw_auto_scan_handler(struct adapter 
*padapter)
goto exit;
}
 
-   if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) {
+   if (pmlmepriv->LinkDetectInfo.bBusyTraffic) {
DBG_871X(FUNC_ADPT_FMT" exit BusyTraffic\n", 
FUNC_ADPT_ARG(padapter));
goto exit;
}
@@ -1863,20 +1863,20 @@ void rtw_dynamic_check_timer_handler(struct adapter 
*adapter)
if (!adapter)
return;
 
-   if (adapter->hw_init_completed == false)
+   if (!adapter->hw_init_completed)
return;
 
-   if ((adapter->bDriverStopped == true) || (adapter->bSurpriseRemoved == 
true))
+   if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
return;
 
-   if (adapter->net_closed == true)
+   if (adapter->net_closed)
return;
 
if (is_primary_adapter(adapter))
DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", 
hal_btcoex_IsBtDisabled(adapter), hal_btcoex_IsBtControlLps(adapter));
 
-   if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode == true)
-   && (hal_btcoex_IsBtControlLps(adapter) == false)
+   if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+   && !(hal_btcoex_IsBtControlLps(adapter))
) {
u8 bEnterPS;
 
@@ -2047,7 +2047,7 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme
 
 
/* check bssid, if needed */
-   if (mlme->assoc_by_bssid == true) {
+   if (mlme->assoc_by_bssid) {
if (memcmp(competitor->network.MacAddress, mlme->assoc_bssid, 
ETH_ALEN))
goto exit;
}
@@ -2805,7 +2805,6 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, 
uint ie_len, u8 channe
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
u8 cbw40_enable = 0;
 
-
if (!phtpriv->ht_option)
return;
 
@@ -2815,7 +2814,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, 

[PATCH 0/4] Fix style and formatting issues in rtw_mlme.c

2019-10-09 Thread Wambui Karuga
This patchest addresses multiple style and formatting issues in the
file drivers/staging/rtl8723bs/core/rtw_mlme.c.
These issues are all reported by checkpatch.pl

Wambui Karuga (4):
  staging: rtl8723bs: Remove comparisons to NULL in conditionals
  staging: rtl8723bs: Remove unnecessary braces for single statements
  staging: rtl8723bs: Remove comparisons to booleans in conditionals.
  staging: rtl8723bs: Remove unnecessary blank lines

 drivers/staging/rtl8723bs/core/rtw_mlme.c | 157 +++---
 1 file changed, 48 insertions(+), 109 deletions(-)

-- 
2.23.0

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


[PATCH 1/4] staging: rtl8723bs: Remove comparisons to NULL in conditionals

2019-10-09 Thread Wambui Karuga
Remove most comparisons to NULL in conditionals in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
CHECK: Comparison to NULL could be written

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 46 +++
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 0ac7712223af..7f27287223e8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -40,7 +40,7 @@ int   rtw_init_mlme_priv(struct adapter *padapter)
 
pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network)));
 
-   if (pbuf == NULL) {
+   if (!pbuf) {
res = _FAIL;
goto exit;
}
@@ -185,7 +185,7 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
 /* _irqL irqL; */
struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
 
-   if (pnetwork == NULL)
+   if (!pnetwork)
return;
 
if (pnetwork->fixed == true)
@@ -220,7 +220,7 @@ void _rtw_free_network_nolock(structmlme_priv 
*pmlmepriv, struct wlan_network *
 
struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
 
-   if (pnetwork == NULL)
+   if (!pnetwork)
return;
 
if (pnetwork->fixed == true)
@@ -633,7 +633,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
/* If there are no more slots, expire the oldest */
/* list_del_init(>list); */
pnetwork = oldest;
-   if (pnetwork == NULL) {
+   if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("\n\n\nsomething wrong here\n\n\n"));
goto exit;
}
@@ -654,7 +654,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
 
pnetwork = rtw_alloc_network(pmlmepriv); /*  will 
update scan_time */
 
-   if (pnetwork == NULL) {
+   if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("\n\n\nsomething wrong here\n\n\n"));
goto exit;
}
@@ -738,7 +738,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
privacy = pnetwork->network.Privacy;
 
if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
-   if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, 
pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, _ielen) != NULL)
+   if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, 
pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, _ielen))
return true;
else
return false;
@@ -1166,7 +1166,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
 
psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
-   if (psta == NULL) {
+   if (!psta) {
psta = rtw_alloc_stainfo(pstapriv, 
pnetwork->network.MacAddress);
}
 
@@ -1413,7 +1413,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, 
u8 *pbuf)
/* s3. find ptarget_sta & update ptarget_sta after 
update cur_network only for station mode */
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == 
true) {
ptarget_sta = 
rtw_joinbss_update_stainfo(adapter, pnetwork);
-   if (ptarget_sta == NULL) {
+   if (!ptarget_sta) {
RT_TRACE(_module_rtl871x_mlme_c_, 
_drv_err_, ("Can't update stainfo when joinbss_event callback\n"));

spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
goto ignore_joinbss_callback;
@@ -1503,7 +1503,7 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, 
struct sta_info *psta, u3
 {
u16 media_status_rpt;
 
-   if (psta == NULL)
+   if (!psta)
return;
 
media_status_rpt = (u16)((psta->mac_id<<8)|mstatus); /*   
MACID|OPMODE:1 connect */
@@ -1561,7 +1561,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, 
u8 *pbuf)
 
/* for AD-HOC mode */
psta = rtw_get_stainfo(>stapriv, pstassoc->macaddr);
-   if (psta != NULL) {
+   if (psta) {
/* the sta have been in sta_info_queue => do nothing */
 
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: 
rtw_stassoc_event_callback: sta has been in sta_hash_queue\n"));
@@ -1570,7 +1570,7 

[PATCH 2/4] staging: rtl8723bs: Remove unnecessary braces for single statements

2019-10-09 Thread Wambui Karuga
Clean up multiple unnecessary braces around single statement blocks in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
WARNING: braces {} are not necessary for single statement blocks or
WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 37 ---
 1 file changed, 12 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 7f27287223e8..b15b761782b8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -112,9 +112,8 @@ void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 {
if (pmlmepriv) {
rtw_free_mlme_priv_ie_data(pmlmepriv);
-   if (pmlmepriv->free_bss_buf) {
+   if (pmlmepriv->free_bss_buf)
vfree(pmlmepriv->free_bss_buf);
-   }
}
 }
 
@@ -753,11 +752,10 @@ int rtw_is_desired_network(struct adapter *adapter, 
struct wlan_network *pnetwor
 
if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) {
p = rtw_get_ie(pnetwork->network.IEs + 
_BEACON_IE_OFFSET_, _RSN_IE_2_, _len, (pnetwork->network.IELength - 
_BEACON_IE_OFFSET_));
-   if (p && ie_len > 0) {
+   if (p && ie_len > 0)
bselected = true;
-   } else {
+   else
bselected = false;
-   }
}
}
 
@@ -822,9 +820,8 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
/*  lock pmlmepriv->lock when you accessing network_q */
if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) {
-   if (pnetwork->Ssid.Ssid[0] == 0) {
+   if (pnetwork->Ssid.Ssid[0] == 0)
pnetwork->Ssid.SsidLength = 0;
-   }
rtw_add_network(adapter, pnetwork);
}
 
@@ -893,9 +890,8 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
pmlmepriv->fw_state = 
WIFI_ADHOC_MASTER_STATE;
 
-   if (rtw_createbss_cmd(adapter) != 
_SUCCESS) {
-   RT_TRACE(_module_rtl871x_mlme_c_, 
_drv_err_, ("Error =>rtw_createbss_cmd status FAIL\n"));
-   }
+   if (rtw_createbss_cmd(adapter) != 
_SUCCESS)
+   
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd status 
FAIL\n"));
 
pmlmepriv->to_join = false;
}
@@ -1166,9 +1162,8 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
 
psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
-   if (!psta) {
+   if (!psta)
psta = rtw_alloc_stainfo(pstapriv, 
pnetwork->network.MacAddress);
-   }
 
if (psta) { /* update ptarget_sta */
 
@@ -1347,11 +1342,10 @@ void rtw_joinbss_event_prehandle(struct adapter 
*adapter, u8 *pbuf)
rtw_get_encrypt_decrypt_from_registrypriv(adapter);
 
 
-   if (pmlmepriv->assoc_ssid.SsidLength == 0) {
+   if (pmlmepriv->assoc_ssid.SsidLength == 0)
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@   joinbss 
event call back  for Any SSid\n"));
-   } else {
+   else
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@   
rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid));
-   }
 
the_same_macaddr = !memcmp(pnetwork->network.MacAddress, 
cur_network->network.MacAddress, ETH_ALEN);
 
@@ -1723,13 +1717,8 @@ void rtw_stadel_event_callback(struct adapter *adapter, 
u8 *pbuf)
_clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE);
}
 
-   if (rtw_createbss_cmd(adapter) != _SUCCESS) {
-
+   if (rtw_createbss_cmd(adapter) != _SUCCESS)
RT_TRACE(_module_rtl871x_ioctl_set_c_, 
_drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd status 
FAIL***\n "));
-
-   }
-
-
}
 
}
@@ -1902,9 +1891,8 @@ void rtw_dynamic_check_timer_handler(struct adapter 
*adapter)
}
 
} else {
-   if (is_primary_adapter(adapter)) {
+   if (is_primary_adapter(adapter))
rtw_dynamic_chk_wk_cmd(adapter);
-   }
}
 
/* auto site survey */
@@ -2988,9 +2976,8 @@ void rtw_append_exented_cap(struct adapter *padapter, u8 
*out_ie, uint 

Re: [PATCH v2 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding

2019-10-09 Thread Xin Ji
Hi Laurent Pinchart, thanks for your comments.


On Wed, Oct 09, 2019 at 03:10:03PM +0300, Laurent Pinchart wrote:
> Hi Xin Ji,
> 
> Thank you for the patch.
> 
> On Wed, Oct 09, 2019 at 09:27:07AM +, Xin Ji wrote:
> > The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> > for portable device. It converts MIPI to DisplayPort 1.3 4K.
> > 
> > You can add support to your board with binding.
> > 
> > Example:
> > anx_bridge: anx7625@58 {
> > compatible = "analogix,anx7625";
> > reg = <0x58>;
> > enable-gpios = < 45 GPIO_ACTIVE_LOW>;
> > reset-gpios = < 73 GPIO_ACTIVE_LOW>;
> > status = "okay";
> > port@0 {
> > reg = <0>;
> > anx7625_1_in: endpoint {
> > remote-endpoint = <_dsi_bridge_1>;
> > };
> > };
> > };
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/anx7625.yaml   | 79 
> > ++
> >  1 file changed, 79 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/display/bridge/anx7625.yaml 
> > b/Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> > new file mode 100644
> > index 000..0ef6271
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> > @@ -0,0 +1,79 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +# Copyright 2019 Analogix Semiconductor, Inc.
> > +%YAML 1.2
> > +---
> > +$id: "http://devicetree.org/schemas/display/bridge/anx7625.yaml#;
> > +$schema: "http://devicetree.org/meta-schemas/core.yaml#;
> > +
> > +title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
> > +
> > +maintainers:
> > +  - Xin Ji 
> > +
> > +description: |
> > +  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
> > +  designed for portable devices.
> > +
> > +properties:
> > +  compatible:
> > +items:
> > +  - const: analogix,anx7625
> > +
> > +  reg:
> > +maxItems: 1
> > +
> > +  hpd-gpios:
> > +description: used for HPD interrupt
> > +maxItems: 1
> 
> You explained in your reply to v1 review that this describes the
> interrupt generated by the ANX7625. It should be replaced by an
> interrupts property.
OK, I'll change it to interrupts property.
> 
> > +
> > +  enable-gpios:
> > +description: used for power on chip control
> > +maxItems: 1
> > +
> > +  reset-gpios:
> > +description: used for reset chip control
> > +maxItems: 1
> 
> Could you please mention the exact name of the corresponding pins on the
> chip for enable and reset ?
OK, I'll mention the exact name of the corresponding pins on the chip.
> 
> > +
> > +  port@0:
> > +type: object
> > +description:
> > +  A port node pointing to MIPI DSI host port node.
> > +
> > +  port@1:
> > +type: object
> > +description:
> > +  A port node pointing to MIPI DPI host port node.
> > +
> > +  port@2:
> > +type: object
> > +description:
> > +  A port node pointing to external connector port node.
> > +
> > +  port@3:
> > +type: object
> > +description:
> > +  A port node pointing to internal panel port node.
> > +
> > +  port@4:
> > +type: object
> > +description:
> > +  A port node pointing to normal eDP port node.
> 
> I don't think three output ports is correct. Ports 3 and 4 are really
> the same. I'm even unsure about port 2 and 3, someone with better
> knowledge of USB-C and DisplayPort would be in a better position to
> comment.
I used it to distinguish different output, port@2 used for USB Type-C
output, I need it to register external connector port notifier
interface, and I think it is OK to conbine port@3 and port@4.
> 
> > +
> 
> You're missing the #address-cells and #size-cells properties required
> for the ports. As the device is an I2C device we're lucky that the
> parent will specify compatible address and size cells numbers, but I'm
> not sure we should rely on that luck.
OK, I'll add it.
> 
> Rob, how does yaml schema handle this ?
> 
> > +required:
> > +  - compatible
> > +  - reg
> > +  - port@0 | port@1
> > +
> > +example:
> > +  - |
> > +anx_bridge: anx7625@58 {
> 
> The node name should describe the device's function. How about
> encoder@58 ?
OK, I'll change it.
> 
> > +compatible = "analogix,anx7625";
> > +reg = <0x58>;
> > +status = "okay";
> > +port@0 {
> > +  reg = <0>;
> > +  anx7625_1_in: endpoint {
> > +remote-endpoint = <_dsi_bridge_1>;
> > +  };
> > +};
> > +};
> 
> -- 
> Regards,
> 
> Laurent Pinchart
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


20-02-2019-09NL

2019-10-09 Thread Claims dept.
LOTTO NETHERLANDS!!!
WINNER!!!

We are pleased to inform you of the announcement of the winners of the Lotto 
Netherlands 
Promotion which took place on the 16th September, 2019 in the Netherlands. Your 
e-mail address 
attached to winning number 20-02-2019-09NL and lucky numbers 210-12-865-50 won 
in the first 
category of 1,500,000.00 Euros.

Email Participants from all over the world were selected through our new global 
Microsoft Email generator 
and your e-mail address come up as one of the lucky winners. To begin the 
process you are advise
to contact our claims department by email or call for the processing of your 
winning money. 

CONTACT DETAILS:

Name: Mr. James Keller
Email: claimsdirecto...@aim.com
Tel: 0031-687-482-376

Please keep your wining number 20-02-2019-09NL from the public until your 
winnings has been processed. 

Best Regards, 

Mrs. Rose Adams
International Relation officer.

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


Re: [PATCH v2 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2019-10-09 Thread Xin Ji
Hi Dan Carpenter, sorry for that, I send the wrong patch, I didn't
correctly merge the changed code. Will send the new patch based on your
new comments.

Thanks,
Xin

On Wed, Oct 09, 2019 at 02:30:32PM +0300, Dan Carpenter wrote:
> Are you sure you sent the correct patch?  This has many of the same
> style issues I mentioned in the previous email.  The error handling
> in edid_read() is wrong.  probe() will still crash if allocating the
> work queue fails.
> 
> On Wed, Oct 09, 2019 at 09:28:02AM +, Xin Ji wrote:
> > The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> > for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.
> > 
> > The ANX7625 can support both USB Type-C PD feature and MIPI DSI/DPI
> > to DP feature. This driver only enabled MIPI DSI/DPI to DP feature.
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  drivers/gpu/drm/bridge/Makefile   |2 +-
> >  drivers/gpu/drm/bridge/analogix/Kconfig   |6 +
> >  drivers/gpu/drm/bridge/analogix/Makefile  |1 +
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 2132 
> > +
> >  drivers/gpu/drm/bridge/analogix/anx7625.h |  405 ++
> >  5 files changed, 2545 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h
> > 
> > diff --git a/drivers/gpu/drm/bridge/Makefile 
> > b/drivers/gpu/drm/bridge/Makefile
> > index 4934fcf..bcd388a 100644
> > --- a/drivers/gpu/drm/bridge/Makefile
> > +++ b/drivers/gpu/drm/bridge/Makefile
> > @@ -12,8 +12,8 @@ obj-$(CONFIG_DRM_SII9234) += sii9234.o
> >  obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
> >  obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
> >  obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o
> > -obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/
> >  obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
> >  obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o
> >  obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o
> > +obj-y += analogix/
> >  obj-y += synopsys/
> > diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
> > b/drivers/gpu/drm/bridge/analogix/Kconfig
> > index e930ff9..b2f127e 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Kconfig
> > +++ b/drivers/gpu/drm/bridge/analogix/Kconfig
> > @@ -2,3 +2,9 @@
> >  config DRM_ANALOGIX_DP
> > tristate
> > depends on DRM
> > +
> > +config ANALOGIX_ANX7625
> > +   tristate "Analogix MIPI to DP interface support"
> > +   help
> > +   ANX7625 is an ultra-low power 4K mobile HD transmitter designed
> > +   for portable devices. It converts MIPI/DPI to DisplayPort1.3 4K.
> > diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
> > b/drivers/gpu/drm/bridge/analogix/Makefile
> > index fdbf3fd..8a52867 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Makefile
> > +++ b/drivers/gpu/drm/bridge/analogix/Makefile
> > @@ -1,3 +1,4 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> > +obj-$(CONFIG_ANALOGIX_ANX7625) += anx7625.o
> >  analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o
> >  obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > new file mode 100644
> > index 000..7bb4e17
> > --- /dev/null
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -0,0 +1,2132 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright(c) 2016, Analogix Semiconductor. All rights reserved.
> > + *
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#include "anx7625.h"
> > +
> > +/*
> > + * there is a sync issue while access I2C register between AP(CPU) and
> > + * internal firmware(OCM), to avoid the race condition, AP should access
> > + * the reserved slave address before slave address occurs changes.
> > + */
> > +static int i2c_access_workaround(struct anx7625_data *ctx,
> > +struct i2c_client *client)
> > +{
> > +   u8 offset;
> > +   struct device *dev = >dev;
> > +   struct i2c_client *last_client = ctx->last_client;
> > +   int ret = 0;
> > +
> > +   if (client != last_client) {
> 
> 
> Please reverse this condition.
> 
>   if (client == ctx->last_client)
>   return 0;
> 
> Get rid of the last_client variable.
> 
> 
> > +   ctx->last_client = client;
> > +
> > +   if (client == ctx->i2c.tcpc_client)
> > +   offset = RSVD_00_ADDR;
> > +   else if (client == ctx->i2c.tx_p0_client)
> > +   offset = RSVD_D1_ADDR;
> > +   else if (client == ctx->i2c.tx_p1_client)
> > +   offset = 

[PATCH] KPC2000: kpc2000_spi.c: Fix style issues (Unecessary parenthesis)

2019-10-09 Thread Chandra Annamaneni
Resolved: CHECK: Unnecessary parentheses around table[i]

Signed-off-by: Chandra Annamaneni 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 2082d86..e702ada 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -478,7 +478,7 @@ kp_spi_probe(struct platform_device *pldev)
/* register the slave boards */
 #define NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(table) \
for (i = 0 ; i < ARRAY_SIZE(table) ; i++) { \
-   spi_new_device(master, &(table[i])); \
+   spi_new_device(master, [i]); \
}
 
switch ((drvdata->card_id & 0x) >> 16) {
-- 
2.7.4

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


[PATCH] KPC2000: kpc2000_spi.c: Fix style issues (misaligned brace)

2019-10-09 Thread Chandra Annamaneni
Resolved: ERROR: else should follow close brace '}'

Signed-off-by: Chandra Annamaneni 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index ccf88b8..2082d86 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -228,8 +228,7 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct 
spi_transfer *transfer)
kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, val);
processed++;
}
-   }
-   else if (rx) {
+   } else if (rx) {
for (i = 0 ; i < c ; i++) {
char test = 0;
 
-- 
2.7.4

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


[PATCH] KPC2000: kpc2000_spi.c: Fix style issues (alignment)

2019-10-09 Thread Chandra Annamaneni
Resolved: "CHECK: Alignment should match open parenthesis" from checkpatch.pl

Signed-off-by: Chandra Annamaneni 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 0d510f0..ccf88b8 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -316,19 +316,19 @@ kp_spi_transfer_one_message(struct spi_master *master, 
struct spi_message *m)
if (transfer->speed_hz > KP_SPI_CLK ||
(len && !(rx_buf || tx_buf))) {
dev_dbg(kpspi->dev, "  transfer: %d Hz, %d %s%s, %d 
bpw\n",
-   transfer->speed_hz,
-   len,
-   tx_buf ? "tx" : "",
-   rx_buf ? "rx" : "",
-   transfer->bits_per_word);
+   transfer->speed_hz,
+   len,
+   tx_buf ? "tx" : "",
+   rx_buf ? "rx" : "",
+   transfer->bits_per_word);
dev_dbg(kpspi->dev, "  transfer -EINVAL\n");
return -EINVAL;
}
if (transfer->speed_hz &&
transfer->speed_hz < (KP_SPI_CLK >> 15)) {
dev_dbg(kpspi->dev, "speed_hz %d below minimum %d Hz\n",
-   transfer->speed_hz,
-   KP_SPI_CLK >> 15);
+   transfer->speed_hz,
+   KP_SPI_CLK >> 15);
dev_dbg(kpspi->dev, "  speed_hz -EINVAL\n");
return -EINVAL;
}
-- 
2.7.4

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


[PATCH] KPC2000: kpc2000_spi.c: Fix style issues (missing blank line)

2019-10-09 Thread Chandra Annamaneni
Resolved: "CHECK: Please use a blank line after.." from checkpatch.pl

Signed-off-by: Chandra Annamaneni 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index ef78b6d..0d510f0 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -50,6 +50,7 @@ static struct flash_platform_data p2kr0_spi0_pdata = {
.nr_parts = ARRAY_SIZE(p2kr0_spi0_parts),
.parts =p2kr0_spi0_parts,
 };
+
 static struct flash_platform_data p2kr0_spi1_pdata = {
.name = "SPI1",
.nr_parts = ARRAY_SIZE(p2kr0_spi1_parts),
-- 
2.7.4

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


[PATCH] KPC2000: kpc2000_spi.c: Fix style issues (line length)

2019-10-09 Thread Chandra Annamaneni
Resoved: "WARNING: line over 80 characters" from checkpatch.pl

Signed-off-by: Chandra Annamaneni 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 3be33c4..ef78b6d 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -30,19 +30,19 @@
 #include "kpc.h"
 
 static struct mtd_partition p2kr0_spi0_parts[] = {
-   { .name = "SLOT_0", .size = 7798784,.offset = 0,
},
-   { .name = "SLOT_1", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "SLOT_2", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "SLOT_3", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "CS0_EXTRA",  .size = MTDPART_SIZ_FULL,   .offset = 
MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_0",  .size = 7798784,  .offset = 0,},
+   { .name = "SLOT_1",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_2",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_3",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "CS0_EXTRA", .size = MTDPART_SIZ_FULL, .offset = 
MTDPART_OFS_NXTBLK},
 };
 
 static struct mtd_partition p2kr0_spi1_parts[] = {
-   { .name = "SLOT_4", .size = 7798784,.offset = 0,
},
-   { .name = "SLOT_5", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "SLOT_6", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "SLOT_7", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "CS1_EXTRA",  .size = MTDPART_SIZ_FULL,   .offset = 
MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_4",  .size = 7798784,  .offset = 0,},
+   { .name = "SLOT_5",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_6",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_7",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "CS1_EXTRA",  .size = MTDPART_SIZ_FULL, .offset = 
MTDPART_OFS_NXTBLK},
 };
 
 static struct flash_platform_data p2kr0_spi0_pdata = {
-- 
2.7.4

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


[PATCH v2] staging: qlge: correct a misspelled word

2019-10-09 Thread Jules Irenge
Fix a misspelling of "several" detected by checkpatch

Signed-off-by: Jules Irenge 
---
 drivers/staging/qlge/qlge_dbg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
index 5599525a19d5..28fc974ce982 100644
--- a/drivers/staging/qlge/qlge_dbg.c
+++ b/drivers/staging/qlge/qlge_dbg.c
@@ -354,7 +354,7 @@ static int ql_get_xgmac_regs(struct ql_adapter *qdev, u32 
*buf,
 
for (i = PAUSE_SRC_LO; i < XGMAC_REGISTER_END; i += 4, buf++) {
/* We're reading 400 xgmac registers, but we filter out
-* serveral locations that are non-responsive to reads.
+* several locations that are non-responsive to reads.
 */
if ((i == 0x0114) ||
(i == 0x0118) ||
-- 
2.21.0

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


Re: [Outreachy kernel] [PATCH] staging: qlge: correct misspelled word

2019-10-09 Thread Julia Lawall



On Wed, 9 Oct 2019, Jules Irenge wrote:

> Correct misspelled word " check

Why is there a " in the above line?

You don't need to put a newline after check.

>  issued by checkpatch.pl tool:
> "CHECK: serveral may be misspelled - perhaps several?".

It's not reall necessary to give the checkpatch message in this case,
although it is good to acknowledge checkpatch.  You could say something
like:

Fix a misspelling of "several" detected by checkpatch.

julia

> Signed-off-by: Jules Irenge 
> ---
>  drivers/staging/qlge/qlge_dbg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
> index 086f067fd899..097fab7b4287 100644
> --- a/drivers/staging/qlge/qlge_dbg.c
> +++ b/drivers/staging/qlge/qlge_dbg.c
> @@ -354,7 +354,7 @@ static int ql_get_xgmac_regs(struct ql_adapter *qdev, u32 
> *buf,
>
>   for (i = PAUSE_SRC_LO; i < XGMAC_REGISTER_END; i += 4, buf++) {
>   /* We're reading 400 xgmac registers, but we filter out
> -  * serveral locations that are non-responsive to reads.
> +  * several locations that are non-responsive to reads.
>*/
>   if ((i == 0x0114) ||
>   (i == 0x0118) ||
> --
> 2.21.0
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/20191009194115.5513-1-jbi.octave%40gmail.com.
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Outreachy kernel] [PATCH] staging: qlge: Fix multiple assignments warning by splitting the assignement into two each

2019-10-09 Thread Julia Lawall



On Wed, 9 Oct 2019, Jules Irenge wrote:

> Fix multiple assignments warning " check
>  issued by checkpatch.pl tool:
> "CHECK: multiple assignments should be avoided".
>
> Signed-off-by: Jules Irenge 
> ---
>  drivers/staging/qlge/qlge_dbg.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
> index 086f067fd899..69bd4710c5ec 100644
> --- a/drivers/staging/qlge/qlge_dbg.c
> +++ b/drivers/staging/qlge/qlge_dbg.c
> @@ -141,8 +141,10 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
>   u32 *direct_ptr, temp;
>   u32 *indirect_ptr;
>
> - xfi_direct_valid = xfi_indirect_valid = 0;
> - xaui_direct_valid = xaui_indirect_valid = 1;
> + xfi_indirect_valid = 0;
> + xfi_direct_valid = xfi_indirect_valid;
> + xaui_indirect_valid = 1;
> + xaui_direct_valid = xaui_indirect_valid

Despite checkpatch, I think that the original code was easier to
understand.

julia

>
>   /* The XAUI needs to be read out per port */
>   status = ql_read_other_func_serdes_reg(qdev,
> --
> 2.21.0
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/20191009204311.7988-1-jbi.octave%40gmail.com.
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: qlge: Fix multiple assignments warning by splitting the assignement into two each

2019-10-09 Thread Jules Irenge
Fix multiple assignments warning " check
 issued by checkpatch.pl tool:
"CHECK: multiple assignments should be avoided".

Signed-off-by: Jules Irenge 
---
 drivers/staging/qlge/qlge_dbg.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
index 086f067fd899..69bd4710c5ec 100644
--- a/drivers/staging/qlge/qlge_dbg.c
+++ b/drivers/staging/qlge/qlge_dbg.c
@@ -141,8 +141,10 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
u32 *direct_ptr, temp;
u32 *indirect_ptr;
 
-   xfi_direct_valid = xfi_indirect_valid = 0;
-   xaui_direct_valid = xaui_indirect_valid = 1;
+   xfi_indirect_valid = 0;
+   xfi_direct_valid = xfi_indirect_valid;
+   xaui_indirect_valid = 1;
+   xaui_direct_valid = xaui_indirect_valid
 
/* The XAUI needs to be read out per port */
status = ql_read_other_func_serdes_reg(qdev,
-- 
2.21.0

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


[PATCH] staging: qlge: Fix multiple assignments warning by splitting the assignement into two each

2019-10-09 Thread Jules Irenge
Fix multiple assignments warning " check
 issued by checkpatch.pl tool:
"CHECK: multiple assignments should be avoided".

Signed-off-by: Jules Irenge 
---
 drivers/staging/qlge/qlge_dbg.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
index 086f067fd899..69bd4710c5ec 100644
--- a/drivers/staging/qlge/qlge_dbg.c
+++ b/drivers/staging/qlge/qlge_dbg.c
@@ -141,8 +141,10 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
u32 *direct_ptr, temp;
u32 *indirect_ptr;
 
-   xfi_direct_valid = xfi_indirect_valid = 0;
-   xaui_direct_valid = xaui_indirect_valid = 1;
+   xfi_indirect_valid = 0;
+   xfi_direct_valid = xfi_indirect_valid;
+   xaui_indirect_valid = 1;
+   xaui_direct_valid = xaui_indirect_valid
 
/* The XAUI needs to be read out per port */
status = ql_read_other_func_serdes_reg(qdev,
-- 
2.21.0

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


[PATCH] staging: qlge: fix "alignment should match open parenthesis" checks

2019-10-09 Thread Jules Irenge
Fix "alignment should mactch open parenthesis" checks
 issued by checkpatch.pl tool:
"CHECK: Alignment should match open parenthesis".

Signed-off-by: Jules Irenge 
---
 drivers/staging/qlge/qlge_dbg.c | 127 
 1 file changed, 64 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
index 086f067fd899..c57d7e722974 100644
--- a/drivers/staging/qlge/qlge_dbg.c
+++ b/drivers/staging/qlge/qlge_dbg.c
@@ -26,7 +26,7 @@ static u32 ql_read_other_func_reg(struct ql_adapter *qdev,
 
 /* Write a NIC register from the alternate function. */
 static int ql_write_other_func_reg(struct ql_adapter *qdev,
-   u32 reg, u32 reg_val)
+  u32 reg, u32 reg_val)
 {
u32 register_to_read;
int status = 0;
@@ -41,7 +41,7 @@ static int ql_write_other_func_reg(struct ql_adapter *qdev,
 }
 
 static int ql_wait_other_func_reg_rdy(struct ql_adapter *qdev, u32 reg,
-   u32 bit, u32 err_bit)
+ u32 bit, u32 err_bit)
 {
u32 temp;
int count = 10;
@@ -61,13 +61,13 @@ static int ql_wait_other_func_reg_rdy(struct ql_adapter 
*qdev, u32 reg,
 }
 
 static int ql_read_other_func_serdes_reg(struct ql_adapter *qdev, u32 reg,
-   u32 *data)
+u32 *data)
 {
int status;
 
/* wait for reg to come ready */
status = ql_wait_other_func_reg_rdy(qdev, XG_SERDES_ADDR / 4,
-   XG_SERDES_ADDR_RDY, 0);
+   XG_SERDES_ADDR_RDY, 0);
if (status)
goto exit;
 
@@ -76,7 +76,7 @@ static int ql_read_other_func_serdes_reg(struct ql_adapter 
*qdev, u32 reg,
 
/* wait for reg to come ready */
status = ql_wait_other_func_reg_rdy(qdev, XG_SERDES_ADDR / 4,
-   XG_SERDES_ADDR_RDY, 0);
+   XG_SERDES_ADDR_RDY, 0);
if (status)
goto exit;
 
@@ -111,7 +111,7 @@ static int ql_read_serdes_reg(struct ql_adapter *qdev, u32 
reg, u32 *data)
 }
 
 static void ql_get_both_serdes(struct ql_adapter *qdev, u32 addr,
-   u32 *direct_ptr, u32 *indirect_ptr,
+  u32 *direct_ptr, u32 *indirect_ptr,
unsigned int direct_valid, unsigned int indirect_valid)
 {
unsigned int status;
@@ -133,7 +133,7 @@ static void ql_get_both_serdes(struct ql_adapter *qdev, u32 
addr,
 }
 
 static int ql_get_serdes_regs(struct ql_adapter *qdev,
-   struct ql_mpi_coredump *mpi_coredump)
+ struct ql_mpi_coredump *mpi_coredump)
 {
int status;
unsigned int xfi_direct_valid, xfi_indirect_valid, xaui_direct_valid;
@@ -146,7 +146,8 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
 
/* The XAUI needs to be read out per port */
status = ql_read_other_func_serdes_reg(qdev,
-   XG_SERDES_XAUI_HSS_PCS_START, );
+  XG_SERDES_XAUI_HSS_PCS_START,
+  );
if (status)
temp = XG_SERDES_ADDR_XAUI_PWR_DOWN;
 
@@ -203,7 +204,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
 
for (i = 0; i <= 0x00034; i += 4, direct_ptr++, indirect_ptr++)
ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
-   xaui_direct_valid, xaui_indirect_valid);
+  xaui_direct_valid, xaui_indirect_valid);
 
/* Get XAUI_HSS_PCS register block. */
if (qdev->func & 1) {
@@ -220,7 +221,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
 
for (i = 0x800; i <= 0x880; i += 4, direct_ptr++, indirect_ptr++)
ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
-   xaui_direct_valid, xaui_indirect_valid);
+  xaui_direct_valid, xaui_indirect_valid);
 
/* Get XAUI_XFI_AN register block. */
if (qdev->func & 1) {
@@ -233,7 +234,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
 
for (i = 0x1000; i <= 0x1034; i += 4, direct_ptr++, indirect_ptr++)
ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
-   xfi_direct_valid, xfi_indirect_valid);
+  xfi_direct_valid, xfi_indirect_valid);
 
/* Get XAUI_XFI_TRAIN register block. */
if (qdev->func & 1) {
@@ -248,7 +249,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
 
for (i = 0x1050; i <= 0x107c; i += 4, direct_ptr++, indirect_ptr++)

[PATCH] staging: qlge: correct misspelled word

2019-10-09 Thread Jules Irenge
Correct misspelled word " check
 issued by checkpatch.pl tool:
"CHECK: serveral may be misspelled - perhaps several?".

Signed-off-by: Jules Irenge 
---
 drivers/staging/qlge/qlge_dbg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
index 086f067fd899..097fab7b4287 100644
--- a/drivers/staging/qlge/qlge_dbg.c
+++ b/drivers/staging/qlge/qlge_dbg.c
@@ -354,7 +354,7 @@ static int ql_get_xgmac_regs(struct ql_adapter *qdev, u32 
*buf,
 
for (i = PAUSE_SRC_LO; i < XGMAC_REGISTER_END; i += 4, buf++) {
/* We're reading 400 xgmac registers, but we filter out
-* serveral locations that are non-responsive to reads.
+* several locations that are non-responsive to reads.
 */
if ((i == 0x0114) ||
(i == 0x0118) ||
-- 
2.21.0

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


[PATCH] staging: qlge: correct misspelled word

2019-10-09 Thread Jules Irenge
Correct misspelled word " check
 issued by checkpatch.pl tool:
"CHECK: serveral may be misspelled - perhaps several?".

Signed-off-by: Jules Irenge 
---
 drivers/staging/qlge/qlge_dbg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
index 086f067fd899..097fab7b4287 100644
--- a/drivers/staging/qlge/qlge_dbg.c
+++ b/drivers/staging/qlge/qlge_dbg.c
@@ -354,7 +354,7 @@ static int ql_get_xgmac_regs(struct ql_adapter *qdev, u32 
*buf,
 
for (i = PAUSE_SRC_LO; i < XGMAC_REGISTER_END; i += 4, buf++) {
/* We're reading 400 xgmac registers, but we filter out
-* serveral locations that are non-responsive to reads.
+* several locations that are non-responsive to reads.
 */
if ((i == 0x0114) ||
(i == 0x0118) ||
-- 
2.21.0

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


[PATCH] staging: qlge: fix "alignment should match open parenthesis" checks

2019-10-09 Thread Jules Irenge
Fix "alignment should mactch open parenthesis" checks
 issued by checkpatch.pl tool:
"CHECK: Alignment should match open parenthesis".

Signed-off-by: Jules Irenge 
---
 drivers/staging/qlge/qlge_dbg.c | 127 
 1 file changed, 64 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
index 086f067fd899..c57d7e722974 100644
--- a/drivers/staging/qlge/qlge_dbg.c
+++ b/drivers/staging/qlge/qlge_dbg.c
@@ -26,7 +26,7 @@ static u32 ql_read_other_func_reg(struct ql_adapter *qdev,
 
 /* Write a NIC register from the alternate function. */
 static int ql_write_other_func_reg(struct ql_adapter *qdev,
-   u32 reg, u32 reg_val)
+  u32 reg, u32 reg_val)
 {
u32 register_to_read;
int status = 0;
@@ -41,7 +41,7 @@ static int ql_write_other_func_reg(struct ql_adapter *qdev,
 }
 
 static int ql_wait_other_func_reg_rdy(struct ql_adapter *qdev, u32 reg,
-   u32 bit, u32 err_bit)
+ u32 bit, u32 err_bit)
 {
u32 temp;
int count = 10;
@@ -61,13 +61,13 @@ static int ql_wait_other_func_reg_rdy(struct ql_adapter 
*qdev, u32 reg,
 }
 
 static int ql_read_other_func_serdes_reg(struct ql_adapter *qdev, u32 reg,
-   u32 *data)
+u32 *data)
 {
int status;
 
/* wait for reg to come ready */
status = ql_wait_other_func_reg_rdy(qdev, XG_SERDES_ADDR / 4,
-   XG_SERDES_ADDR_RDY, 0);
+   XG_SERDES_ADDR_RDY, 0);
if (status)
goto exit;
 
@@ -76,7 +76,7 @@ static int ql_read_other_func_serdes_reg(struct ql_adapter 
*qdev, u32 reg,
 
/* wait for reg to come ready */
status = ql_wait_other_func_reg_rdy(qdev, XG_SERDES_ADDR / 4,
-   XG_SERDES_ADDR_RDY, 0);
+   XG_SERDES_ADDR_RDY, 0);
if (status)
goto exit;
 
@@ -111,7 +111,7 @@ static int ql_read_serdes_reg(struct ql_adapter *qdev, u32 
reg, u32 *data)
 }
 
 static void ql_get_both_serdes(struct ql_adapter *qdev, u32 addr,
-   u32 *direct_ptr, u32 *indirect_ptr,
+  u32 *direct_ptr, u32 *indirect_ptr,
unsigned int direct_valid, unsigned int indirect_valid)
 {
unsigned int status;
@@ -133,7 +133,7 @@ static void ql_get_both_serdes(struct ql_adapter *qdev, u32 
addr,
 }
 
 static int ql_get_serdes_regs(struct ql_adapter *qdev,
-   struct ql_mpi_coredump *mpi_coredump)
+ struct ql_mpi_coredump *mpi_coredump)
 {
int status;
unsigned int xfi_direct_valid, xfi_indirect_valid, xaui_direct_valid;
@@ -146,7 +146,8 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
 
/* The XAUI needs to be read out per port */
status = ql_read_other_func_serdes_reg(qdev,
-   XG_SERDES_XAUI_HSS_PCS_START, );
+  XG_SERDES_XAUI_HSS_PCS_START,
+  );
if (status)
temp = XG_SERDES_ADDR_XAUI_PWR_DOWN;
 
@@ -203,7 +204,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
 
for (i = 0; i <= 0x00034; i += 4, direct_ptr++, indirect_ptr++)
ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
-   xaui_direct_valid, xaui_indirect_valid);
+  xaui_direct_valid, xaui_indirect_valid);
 
/* Get XAUI_HSS_PCS register block. */
if (qdev->func & 1) {
@@ -220,7 +221,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
 
for (i = 0x800; i <= 0x880; i += 4, direct_ptr++, indirect_ptr++)
ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
-   xaui_direct_valid, xaui_indirect_valid);
+  xaui_direct_valid, xaui_indirect_valid);
 
/* Get XAUI_XFI_AN register block. */
if (qdev->func & 1) {
@@ -233,7 +234,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
 
for (i = 0x1000; i <= 0x1034; i += 4, direct_ptr++, indirect_ptr++)
ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr,
-   xfi_direct_valid, xfi_indirect_valid);
+  xfi_direct_valid, xfi_indirect_valid);
 
/* Get XAUI_XFI_TRAIN register block. */
if (qdev->func & 1) {
@@ -248,7 +249,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
 
for (i = 0x1050; i <= 0x107c; i += 4, direct_ptr++, indirect_ptr++)

Re: [PATCH 0/7] Fix various compilation issues with wfx driver

2019-10-09 Thread Dan Carpenter
On Wed, Oct 09, 2019 at 03:13:14PM +, Jerome Pouiller wrote:
> On Tuesday 8 October 2019 17:10:56 CEST Greg Kroah-Hartman wrote:
> > On Tue, Oct 08, 2019 at 09:42:47AM +, Jerome Pouiller wrote:
> > > From: Jérôme Pouiller 
> > >
> > > Most of problems are related to big-endian architectures.
> > 
> > kbuild still reports 2 errors with these patches applied:
> > 
> > Regressions in current branch:
> > 
> > drivers/staging/wfx/hif_tx.c:82:2-8: preceding lock on line 65
> 
> As I replied to Julia, this behavior is intended.
> 
> > drivers/staging/wfx/main.c:188:14-21: ERROR: PTR_ERR applied after 
> > initialization to constant on line 183
> 
> This is a false positive, as confirmed by Dan.
> 
> You may also notice:
> 
>   drivers/staging/wfx/scan.c:207 wfx_scan_work() warn: inconsistent returns 
> 'sem:>scan.lock'
> 
> I also consider it as a false positive.

Yeah.  I thought it might be.  The beauty of 0day bot is that normally
the warnings come really quick after the original author wrote the code
so it's fresh in their heads.  I suspected it might be a false positive
but I wasn't sure either way and I try not to spend a lot of time
reviewing those warnings.

regards,
dan carpenter

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


Re: [Outreachy kernel] [PATCH] staging: kpc2000: Remove unnecessary return variable

2019-10-09 Thread Julia Lawall



On Wed, 9 Oct 2019, Wambui Karuga wrote:

> Remove unnecessary variable `val` in kp_spi_read_reg() that only holds
> the return value from readq().
> Issue found by coccinelle using the script:
>
> @@
> local idexpression ret;
> expression e;
> @@
>
> -ret =
> +return
>  e;
> -return ret;
>
> Signed-off-by: Wambui Karuga 

Acked-by: Julia Lawall 


> ---
>  drivers/staging/kpc2000/kpc2000_spi.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
> b/drivers/staging/kpc2000/kpc2000_spi.c
> index 3be33c450cab..6ba94b0131da 100644
> --- a/drivers/staging/kpc2000/kpc2000_spi.c
> +++ b/drivers/staging/kpc2000/kpc2000_spi.c
> @@ -162,14 +162,12 @@ union kp_spi_ffctrl {
>  kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx)
>  {
>   u64 __iomem *addr = cs->base;
> - u64 val;
>
>   addr += idx;
>   if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0))
>   return cs->conf_cache;
>
> - val = readq(addr);
> - return val;
> + return readq(addr);
>  }
>
>   static inline void
> --
> 2.23.0
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/20191009170703.GA2869%40wambui.
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 1/2] dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe

2019-10-09 Thread Dan Carpenter
On Wed, Oct 09, 2019 at 04:58:12PM +0200, Alexander Gordeev wrote:
> On Wed, Oct 09, 2019 at 03:14:41PM +0300, Dan Carpenter wrote:
> > > +config AVALON_DMA_PCI_VENDOR_ID
> > > + hex "PCI vendor ID"
> > > + default "0x1172"
> > > +
> > > +config AVALON_DMA_PCI_DEVICE_ID
> > > + hex "PCI device ID"
> > > + default "0xe003"
> > 
> > This feels wrong.  Why isn't it known in advance.
> 
> Because device designers would likely use they own IDs. The ones I
> put are just defaults inherited from the (Altera) reference design.
> 
> > > + u32 *rd_flags = hw->dma_desc_table_rd.cpu_addr->flags;
> > > + u32 *wr_flags = hw->dma_desc_table_wr.cpu_addr->flags;
> > > + struct avalon_dma_desc *desc;
> > > + struct virt_dma_desc *vdesc;
> > > + bool rd_done;
> > > + bool wr_done;
> > > +
> > > + spin_lock(lock);
> > > +
> > > + rd_done = (hw->h2d_last_id < 0);
> > > + wr_done = (hw->d2h_last_id < 0);
> > > +
> > > + if (rd_done && wr_done) {
> > > + spin_unlock(lock);
> > > + return IRQ_NONE;
> > > + }
> > > +
> > > + do {
> > > + if (!rd_done && rd_flags[hw->h2d_last_id])
> > > + rd_done = true;
> > > +
> > > + if (!wr_done && wr_flags[hw->d2h_last_id])
> > > + wr_done = true;
> > > + } while (!rd_done || !wr_done);
> > 
> > This loop is very strange.  It feels like the last_id indexes needs
> > to atomic or protected from racing somehow so we don't do an out of
> > bounds read.
> 
> My bad. I should have put a comment on this. This polling comes from my
> reading of the Intel documentation:
> 
> "The MSI interrupt notifies the host when a DMA operation has completed.
> After the host receives this interrupt, it can poll the DMA read or write
> status table to determine which entry or entries have the done bit set."
> 
> "The Descriptor Controller writes a 1 to the done bit of the status DWORD
> to indicate successful completion. The Descriptor Controller also sends
> an MSI interrupt for the final descriptor. After receiving this MSI,
> host software can poll the done bit to determine status."
> 
> I sense an ambiguity above. It sounds possible an MSI interrupt could be
> delivered before corresponding done bit is set. May be imperfect wording..
> Anyway, the loop does look weird and in reality I doubt I observed the
> done bit unset even once. So I put this polling just in case.

You're missing my point.  When we set
hw->d2h_last_id = 1;
...
hw->d2h_last_id = 2;

There is a tiny moment where ->d2h_last_id is transitioning from 1 to 2
where its value is unknown.  We're in a busy loop here so we have a
decent chance of hitting that 1/1000,000th of a second.  If we happen to
hit it at exactly the right time then we're reading from a random
address and it will cause an oops.

We have to use atomic_t types or something to handle race conditions.

regards,
dan carpenter

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


[PATCH] staging: kpc2000: Remove unnecessary return variable

2019-10-09 Thread Wambui Karuga
Remove unnecessary variable `val` in kp_spi_read_reg() that only holds
the return value from readq().
Issue found by coccinelle using the script:

@@
local idexpression ret;
expression e;
@@

-ret =
+return
 e;
-return ret;

Signed-off-by: Wambui Karuga 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 3be33c450cab..6ba94b0131da 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -162,14 +162,12 @@ union kp_spi_ffctrl {
 kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx)
 {
u64 __iomem *addr = cs->base;
-   u64 val;
 
addr += idx;
if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0))
return cs->conf_cache;
 
-   val = readq(addr);
-   return val;
+   return readq(addr);
 }
 
static inline void
-- 
2.23.0

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


Re: [PATCH] binder: prevent UAF read in print_binder_transaction_log_entry()

2019-10-09 Thread Todd Kjos
On Wed, Oct 9, 2019 at 3:40 AM Christian Brauner
 wrote:
>
> On Tue, Oct 08, 2019 at 02:05:16PM -0400, Joel Fernandes wrote:
> > On Tue, Oct 08, 2019 at 03:01:59PM +0200, Christian Brauner wrote:

[...]

> >
> > One more thought, this can be made dependent on CONFIG_BINDERFS since 
> > regular
> > binder devices cannot be unregistered AFAICS and as Jann said, the problem 
> > is
> > BINDERFS specific. That way we avoid the memcpy for _every_ transaction.
> > These can be thundering when Android starts up.
>
> Unless Todd sees this as a real performance problem I'm weary to
> introduce additional checking and record a pointer for non-binderfs and
> a memcpy() for binderfs devices. :)
>

I don't see this as a real problem. In practice, memcpy will be moving
< 10 bytes. Also, by the time this code is in an android device,
CONFIG_BINDERFS will always be enabled since this is how we are
removing binder's use of debugfs. So a micro-optimization of the
!BINDERFS case will not be meaningful.

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


Re: [PATCH] binder: prevent UAF read in print_binder_transaction_log_entry()

2019-10-09 Thread Joel Fernandes
On Wed, Oct 09, 2019 at 05:10:45PM +0200, Christian Brauner wrote:
> On Wed, Oct 09, 2019 at 10:55:58AM -0400, Joel Fernandes wrote:
> > On Wed, Oct 09, 2019 at 04:29:11PM +0200, Christian Brauner wrote:
> > > On Wed, Oct 09, 2019 at 10:21:29AM -0400, Joel Fernandes wrote:
> > > > On Wed, Oct 09, 2019 at 12:40:12PM +0200, Christian Brauner wrote:
> > > > > On Tue, Oct 08, 2019 at 02:05:16PM -0400, Joel Fernandes wrote:
> > > > > > On Tue, Oct 08, 2019 at 03:01:59PM +0200, Christian Brauner wrote:
> > > > > > > When a binder transaction is initiated on a binder device coming 
> > > > > > > from a
> > > > > > > binderfs instance, a pointer to the name of the binder device is 
> > > > > > > stashed
> > > > > > > in the binder_transaction_log_entry's context_name member. Later 
> > > > > > > on it
> > > > > > > is used to print the name in 
> > > > > > > print_binder_transaction_log_entry(). By
> > > > > > > the time print_binder_transaction_log_entry() accesses 
> > > > > > > context_name
> > > > > > > binderfs_evict_inode() might have already freed the associated 
> > > > > > > memory
> > > > > > > thereby causing a UAF. Do the simple thing and prevent this by 
> > > > > > > copying
> > > > > > > the name of the binder device instead of stashing a pointer to it.
> > > > > > > 
> > > > > > > Reported-by: Jann Horn 
> > > > > > > Fixes: 03e2e07e3814 ("binder: Make transaction_log available in 
> > > > > > > binderfs")
> > > > > > > Link: 
> > > > > > > https://lore.kernel.org/r/cag48ez14q0-f8lqsvcnbyr2o6gpw8shxsm4u5jmd9mpstem...@mail.gmail.com
> > > > > > > Cc: Joel Fernandes 
> > > > > > > Cc: Todd Kjos 
> > > > > > > Cc: Hridya Valsaraju 
> > > > > > > Signed-off-by: Christian Brauner 
> > > > > > > ---
> > > > > > >  drivers/android/binder.c  | 4 +++-
> > > > > > >  drivers/android/binder_internal.h | 2 +-
> > > > > > >  2 files changed, 4 insertions(+), 2 deletions(-)
> > > > > > > 
> > > > > > > diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> > > > > > > index c0a491277aca..5b9ac2122e89 100644
> > > > > > > --- a/drivers/android/binder.c
> > > > > > > +++ b/drivers/android/binder.c
> > > > > > > @@ -57,6 +57,7 @@
> > > > > > >  #include 
> > > > > > >  #include 
> > > > > > >  #include 
> > > > > > > +#include 
> > > > > > >  #include 
> > > > > > >  #include 
> > > > > > >  #include 
> > > > > > > @@ -66,6 +67,7 @@
> > > > > > >  #include 
> > > > > > >  
> > > > > > >  #include 
> > > > > > > +#include 
> > > > > > >  
> > > > > > >  #include 
> > > > > > >  
> > > > > > > @@ -2876,7 +2878,7 @@ static void binder_transaction(struct 
> > > > > > > binder_proc *proc,
> > > > > > >   e->target_handle = tr->target.handle;
> > > > > > >   e->data_size = tr->data_size;
> > > > > > >   e->offsets_size = tr->offsets_size;
> > > > > > > - e->context_name = proc->context->name;
> > > > > > > + strscpy(e->context_name, proc->context->name, 
> > > > > > > BINDERFS_MAX_NAME);
> > > > > > 
> > > > > > Strictly speaking, proc-context->name can also be initialized for 
> > > > > > !BINDERFS
> > > > > > so the BINDERFS in the MAX_NAME macro is misleading. So probably 
> > > > > > there should
> > > > > > be a BINDER_MAX_NAME (and associated checks for whether non 
> > > > > > BINDERFS names
> > > > > > fit within the MAX.
> > > > > 
> > > > > I know but I don't think it's worth special-casing non-binderfs 
> > > > > devices.
> > > > > First, non-binderfs devices can only be created through a KCONFIG 
> > > > > option
> > > > > determined at compile time. For stock Android the names are the same 
> > > > > for
> > > > > all vendors afaik.
> > > > 
> > > > I am just talking about the name of weirdly named macro here.
> > > 
> > > You might miss context here: It's named that way because currently only
> > > binderfs binder devices are bound to that limit. That's a point I made
> > > further below in my previous mail. Non-binderfs devices are not subject
> > > to that restriction and when we tried to make them subject to the same
> > > it as rejected.
> > 
> > I know that. I am saying the memcpy is happening for regular binder devices
> > as well but the macro has BINDERFS in the name. That's all. It is not a
> > significant eye sore. But is a bit odd.
> 
> Right, and I told you that we _can't_ rename it to BINDER_MAX because
> that check only happens for binderfs devices since you were suggesting
> this. If you want to rename to get rid of the this being somehow
> apparently odd then you need to introduce that check for non-binderfs
> devices too. Or just rename the macro in a follow-up patch. I don't care.

Here in this patch we are doing mem copy for regular binder device name using
a BINDERFS macro name.

> > 
> > > 
> > > 
> > > > 
> > > > > Fifth, I already tried to push for validation of non-binderfs binder
> > > > > devices a while back when I wrote binderfs and was told that it's not
> > > > > needed. Hrydia tried the same and we decided the same thing. So you 
> > > > > get
> > > > > to 

Re: [PATCH 0/7] Fix various compilation issues with wfx driver

2019-10-09 Thread Jerome Pouiller
On Tuesday 8 October 2019 17:10:56 CEST Greg Kroah-Hartman wrote:
> On Tue, Oct 08, 2019 at 09:42:47AM +, Jerome Pouiller wrote:
> > From: Jérôme Pouiller 
> >
> > Most of problems are related to big-endian architectures.
> 
> kbuild still reports 2 errors with these patches applied:
> 
> Regressions in current branch:
> 
> drivers/staging/wfx/hif_tx.c:82:2-8: preceding lock on line 65

As I replied to Julia, this behavior is intended.

> drivers/staging/wfx/main.c:188:14-21: ERROR: PTR_ERR applied after 
> initialization to constant on line 183

This is a false positive, as confirmed by Dan.

You may also notice:

  drivers/staging/wfx/scan.c:207 wfx_scan_work() warn: inconsistent returns 
'sem:>scan.lock'

I also consider it as a false positive.

> Can you please fix those up as well?

Beside these ones, I will address the other reported problems.

-- 
Jérôme Pouiller

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


Re: [PATCH] binder: prevent UAF read in print_binder_transaction_log_entry()

2019-10-09 Thread Christian Brauner
On Wed, Oct 09, 2019 at 10:55:58AM -0400, Joel Fernandes wrote:
> On Wed, Oct 09, 2019 at 04:29:11PM +0200, Christian Brauner wrote:
> > On Wed, Oct 09, 2019 at 10:21:29AM -0400, Joel Fernandes wrote:
> > > On Wed, Oct 09, 2019 at 12:40:12PM +0200, Christian Brauner wrote:
> > > > On Tue, Oct 08, 2019 at 02:05:16PM -0400, Joel Fernandes wrote:
> > > > > On Tue, Oct 08, 2019 at 03:01:59PM +0200, Christian Brauner wrote:
> > > > > > When a binder transaction is initiated on a binder device coming 
> > > > > > from a
> > > > > > binderfs instance, a pointer to the name of the binder device is 
> > > > > > stashed
> > > > > > in the binder_transaction_log_entry's context_name member. Later on 
> > > > > > it
> > > > > > is used to print the name in print_binder_transaction_log_entry(). 
> > > > > > By
> > > > > > the time print_binder_transaction_log_entry() accesses context_name
> > > > > > binderfs_evict_inode() might have already freed the associated 
> > > > > > memory
> > > > > > thereby causing a UAF. Do the simple thing and prevent this by 
> > > > > > copying
> > > > > > the name of the binder device instead of stashing a pointer to it.
> > > > > > 
> > > > > > Reported-by: Jann Horn 
> > > > > > Fixes: 03e2e07e3814 ("binder: Make transaction_log available in 
> > > > > > binderfs")
> > > > > > Link: 
> > > > > > https://lore.kernel.org/r/cag48ez14q0-f8lqsvcnbyr2o6gpw8shxsm4u5jmd9mpstem...@mail.gmail.com
> > > > > > Cc: Joel Fernandes 
> > > > > > Cc: Todd Kjos 
> > > > > > Cc: Hridya Valsaraju 
> > > > > > Signed-off-by: Christian Brauner 
> > > > > > ---
> > > > > >  drivers/android/binder.c  | 4 +++-
> > > > > >  drivers/android/binder_internal.h | 2 +-
> > > > > >  2 files changed, 4 insertions(+), 2 deletions(-)
> > > > > > 
> > > > > > diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> > > > > > index c0a491277aca..5b9ac2122e89 100644
> > > > > > --- a/drivers/android/binder.c
> > > > > > +++ b/drivers/android/binder.c
> > > > > > @@ -57,6 +57,7 @@
> > > > > >  #include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > > +#include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > > @@ -66,6 +67,7 @@
> > > > > >  #include 
> > > > > >  
> > > > > >  #include 
> > > > > > +#include 
> > > > > >  
> > > > > >  #include 
> > > > > >  
> > > > > > @@ -2876,7 +2878,7 @@ static void binder_transaction(struct 
> > > > > > binder_proc *proc,
> > > > > > e->target_handle = tr->target.handle;
> > > > > > e->data_size = tr->data_size;
> > > > > > e->offsets_size = tr->offsets_size;
> > > > > > -   e->context_name = proc->context->name;
> > > > > > +   strscpy(e->context_name, proc->context->name, 
> > > > > > BINDERFS_MAX_NAME);
> > > > > 
> > > > > Strictly speaking, proc-context->name can also be initialized for 
> > > > > !BINDERFS
> > > > > so the BINDERFS in the MAX_NAME macro is misleading. So probably 
> > > > > there should
> > > > > be a BINDER_MAX_NAME (and associated checks for whether non BINDERFS 
> > > > > names
> > > > > fit within the MAX.
> > > > 
> > > > I know but I don't think it's worth special-casing non-binderfs devices.
> > > > First, non-binderfs devices can only be created through a KCONFIG option
> > > > determined at compile time. For stock Android the names are the same for
> > > > all vendors afaik.
> > > 
> > > I am just talking about the name of weirdly named macro here.
> > 
> > You might miss context here: It's named that way because currently only
> > binderfs binder devices are bound to that limit. That's a point I made
> > further below in my previous mail. Non-binderfs devices are not subject
> > to that restriction and when we tried to make them subject to the same
> > it as rejected.
> 
> I know that. I am saying the memcpy is happening for regular binder devices
> as well but the macro has BINDERFS in the name. That's all. It is not a
> significant eye sore. But is a bit odd.

Right, and I told you that we _can't_ rename it to BINDER_MAX because
that check only happens for binderfs devices since you were suggesting
this. If you want to rename to get rid of the this being somehow
apparently odd then you need to introduce that check for non-binderfs
devices too. Or just rename the macro in a follow-up patch. I don't care.

> 
> > 
> > 
> > > 
> > > > Fifth, I already tried to push for validation of non-binderfs binder
> > > > devices a while back when I wrote binderfs and was told that it's not
> > > > needed. Hrydia tried the same and we decided the same thing. So you get
> > > > to be the next person to send a patch. :)
> > > 
> > > I don't follow why we are talking about non-binderfs validation. I am just
> > 
> > Because above you said
> > 
> > > > > so the BINDERFS in the MAX_NAME macro is misleading. So probably 
> > > > > there should
> > > > > be a BINDER_MAX_NAME (and associated checks for whether non BINDERFS 
> > > > > names
> > > > > fit within the MAX.
> > 
> > which to me reads like 

Re: [staging:staging-testing 57/111] drivers/staging/wfx/scan.c:207 wfx_scan_work() warn: inconsistent returns 'sem:>scan.lock'.

2019-10-09 Thread Jerome Pouiller
On Wednesday 9 October 2019 09:38:31 CEST kbuild test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
> staging-testing
> head:   d49d1c76b96ebf39539e93d5ab7943a01ef70e4f
> commit: 1a61af0f8cbecd1610c6fc380d0fb00f57fd43f2 [57/111] staging: wfx: allow 
> to scan networks
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot 
> Reported-by: Dan Carpenter 
> 
> New smatch warnings:
> drivers/staging/wfx/scan.c:207 wfx_scan_work() warn: inconsistent returns 
> 'sem:>scan.lock'.
>   Locked on:   line 201
>   Unlocked on: line 145
> 
> # 
> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?id=1a61af0f8cbecd1610c6fc380d0fb00f57fd43f2
> git remote add staging 
> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
> git remote update staging
> git checkout 1a61af0f8cbecd1610c6fc380d0fb00f57fd43f2
> vim +207 drivers/staging/wfx/scan.c
> 
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  116  void wfx_scan_work(struct 
> work_struct *work)
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  117  {
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  118  struct wfx_vif *wvif 
> = container_of(work, struct wfx_vif, scan.work);
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  119  struct 
> ieee80211_channel **it;
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  120  struct 
> wfx_scan_params scan = {
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  121  
> .scan_req.scan_type.type = 0,/* Foreground */
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  122  };
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  123  struct 
> ieee80211_channel *first;
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  124  int i;
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  125
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  126  
> down(>scan.lock);
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  127  
> mutex_lock(>wdev->conf_mutex);
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  128
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  129  if (!wvif->scan.req 
> || wvif->scan.curr == wvif->scan.end) {
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  130  if 
> (wvif->scan.output_power != wvif->wdev->output_power)
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  131  
> hif_set_output_power(wvif, wvif->wdev->output_power * 10);
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  132
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  133  if 
> (wvif->scan.status < 0)
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  134  
> dev_warn(wvif->wdev->dev, "scan failed\n");
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  135  else if 
> (wvif->scan.req)
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  136  
> dev_dbg(wvif->wdev->dev, "scan completed\n");
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  137  else
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  138  
> dev_dbg(wvif->wdev->dev, "scan canceled\n");
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  139
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  140  
> wvif->scan.req = NULL;
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  141  
> wfx_tx_unlock(wvif->wdev);
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  142  
> mutex_unlock(>wdev->conf_mutex);
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  143  
> __ieee80211_scan_completed_compat(wvif->wdev->hw, wvif->scan.status ? 1 : 0);
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  144  
> up(>scan.lock);
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  145  return;
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  146  }
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  147  first = 
> *wvif->scan.curr;
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  148
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  149  for (it = 
> wvif->scan.curr + 1, i = 1;
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  150   it != 
> wvif->scan.end && i < HIF_API_MAX_NB_CHANNELS;
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  151   ++it, ++i) {
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  152  if 
> ((*it)->band != first->band)
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  153  break;
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  154  if 
> (((*it)->flags ^ first->flags) &
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  155
>   IEEE80211_CHAN_NO_IR)
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  156  break;
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  157  if 
> (!(first->flags & IEEE80211_CHAN_NO_IR) &&
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  158  
> (*it)->max_power != first->max_power)
> 1a61af0f8cbecd Jérôme Pouiller 2019-09-19  159  

Re: [staging:staging-testing 41/59] drivers/staging/wfx/main.c:47:14-21: ERROR: PTR_ERR applied after initialization to constant on line 42

2019-10-09 Thread Dan Carpenter
On Wed, Oct 09, 2019 at 02:21:47PM +, Jerome Pouiller wrote:
> On Wednesday 9 October 2019 08:51:10 CEST Rong Chen wrote:
> > On 10/7/19 4:36 PM, Jerome Pouiller wrote:
> > > On Friday 4 October 2019 12:48:32 CEST kbuild test robot wrote:
> > > [...]
> >  drivers/staging/wfx/main.c:47:14-21: ERROR: PTR_ERR applied after 
> >  initialization to constant on line 42
> > >> vim +47 drivers/staging/wfx/main.c
> > >>
> > >>  30
> > >>  31  struct gpio_desc *wfx_get_gpio(struct device *dev, int 
> > >> override, const char *label)
> > >>  32  {
> > >>  33  struct gpio_desc *ret;
> > >>  34  char label_buf[256];
> > >>  35
> > >>  36  if (override >= 0) {
> > >>  37  snprintf(label_buf, sizeof(label_buf), 
> > >> "wfx_%s", label);
> > >>  38  ret = ERR_PTR(devm_gpio_request_one(dev, 
> > >> override, GPIOF_OUT_INIT_LOW, label_buf));
> > >>  39  if (!ret)
> > >>  40  ret = gpio_to_desc(override);
> > >>  41  } else if (override == -1) {
> > >>> 42  ret = NULL;
> > >>  43  } else {
> > >>  44  ret = devm_gpiod_get(dev, label, GPIOD_OUT_LOW);
> > >>  45  }
> > >>  46  if (IS_ERR(ret) || !ret) {
> > >>> 47  if (!ret || PTR_ERR(ret) == -ENOENT)
> > >>  48  dev_warn(dev, "gpio %s is not 
> > >> defined\n", label);
> > >>  49  else
> > >>  50  dev_warn(dev, "error while requesting 
> > >> gpio %s\n", label);
> > >>  51  ret = NULL;
> > >>  52  } else {
> > >>  53  dev_dbg(dev, "using gpio %d for %s\n", 
> > >> desc_to_gpio(ret), label);
> > >>  54  }
> > >>  55  return ret;
> > >>  56  }
> > >>  57
> > > I think that this report is a false positive or I missed something?
> > >
> > Sorry for the inconvenience, but we confirmed that the error first
> > appeared since commit 0096214a59.
> 
> Hi Rong,
> 
> Err... I continue to not understand the meaning of this warning. If
> override != -1 then ret is not constant, isn't?

It's a false positive.  Those happen.  Just ignore it.

regards,
dan carpenter

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


[PATCH -next] staging: emxx_udc: use devm_platform_ioremap_resource() to simplify code

2019-10-09 Thread YueHaibing
Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing 
---
 drivers/staging/emxx_udc/emxx_udc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c 
b/drivers/staging/emxx_udc/emxx_udc.c
index 147481b..9e0c19e 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -3078,7 +3078,6 @@ static int nbu2ss_drv_probe(struct platform_device *pdev)
 {
int status = -ENODEV;
struct nbu2ss_udc   *udc;
-   struct resource *r;
int irq;
void __iomem *mmio_base;
 
@@ -3088,8 +3087,7 @@ static int nbu2ss_drv_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, udc);
 
/* require I/O memory and IRQ to be provided as resources */
-   r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   mmio_base = devm_ioremap_resource(>dev, r);
+   mmio_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(mmio_base))
return PTR_ERR(mmio_base);
 
-- 
2.7.4


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


[PATCH -next] staging: clocking-wizard: use devm_platform_ioremap_resource() to simplify code

2019-10-09 Thread YueHaibing
Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing 
---
 drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c 
b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
index 15b7a82..e52a64b 100644
--- a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
+++ b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
@@ -135,7 +135,6 @@ static int clk_wzrd_probe(struct platform_device *pdev)
unsigned long rate;
const char *clk_name;
struct clk_wzrd *clk_wzrd;
-   struct resource *mem;
struct device_node *np = pdev->dev.of_node;
 
clk_wzrd = devm_kzalloc(>dev, sizeof(*clk_wzrd), GFP_KERNEL);
@@ -143,8 +142,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
return -ENOMEM;
platform_set_drvdata(pdev, clk_wzrd);
 
-   mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   clk_wzrd->base = devm_ioremap_resource(>dev, mem);
+   clk_wzrd->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(clk_wzrd->base))
return PTR_ERR(clk_wzrd->base);
 
-- 
2.7.4


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


Re: [PATCH] binder: prevent UAF read in print_binder_transaction_log_entry()

2019-10-09 Thread Joel Fernandes
On Wed, Oct 09, 2019 at 04:29:11PM +0200, Christian Brauner wrote:
> On Wed, Oct 09, 2019 at 10:21:29AM -0400, Joel Fernandes wrote:
> > On Wed, Oct 09, 2019 at 12:40:12PM +0200, Christian Brauner wrote:
> > > On Tue, Oct 08, 2019 at 02:05:16PM -0400, Joel Fernandes wrote:
> > > > On Tue, Oct 08, 2019 at 03:01:59PM +0200, Christian Brauner wrote:
> > > > > When a binder transaction is initiated on a binder device coming from 
> > > > > a
> > > > > binderfs instance, a pointer to the name of the binder device is 
> > > > > stashed
> > > > > in the binder_transaction_log_entry's context_name member. Later on it
> > > > > is used to print the name in print_binder_transaction_log_entry(). By
> > > > > the time print_binder_transaction_log_entry() accesses context_name
> > > > > binderfs_evict_inode() might have already freed the associated memory
> > > > > thereby causing a UAF. Do the simple thing and prevent this by copying
> > > > > the name of the binder device instead of stashing a pointer to it.
> > > > > 
> > > > > Reported-by: Jann Horn 
> > > > > Fixes: 03e2e07e3814 ("binder: Make transaction_log available in 
> > > > > binderfs")
> > > > > Link: 
> > > > > https://lore.kernel.org/r/cag48ez14q0-f8lqsvcnbyr2o6gpw8shxsm4u5jmd9mpstem...@mail.gmail.com
> > > > > Cc: Joel Fernandes 
> > > > > Cc: Todd Kjos 
> > > > > Cc: Hridya Valsaraju 
> > > > > Signed-off-by: Christian Brauner 
> > > > > ---
> > > > >  drivers/android/binder.c  | 4 +++-
> > > > >  drivers/android/binder_internal.h | 2 +-
> > > > >  2 files changed, 4 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> > > > > index c0a491277aca..5b9ac2122e89 100644
> > > > > --- a/drivers/android/binder.c
> > > > > +++ b/drivers/android/binder.c
> > > > > @@ -57,6 +57,7 @@
> > > > >  #include 
> > > > >  #include 
> > > > >  #include 
> > > > > +#include 
> > > > >  #include 
> > > > >  #include 
> > > > >  #include 
> > > > > @@ -66,6 +67,7 @@
> > > > >  #include 
> > > > >  
> > > > >  #include 
> > > > > +#include 
> > > > >  
> > > > >  #include 
> > > > >  
> > > > > @@ -2876,7 +2878,7 @@ static void binder_transaction(struct 
> > > > > binder_proc *proc,
> > > > >   e->target_handle = tr->target.handle;
> > > > >   e->data_size = tr->data_size;
> > > > >   e->offsets_size = tr->offsets_size;
> > > > > - e->context_name = proc->context->name;
> > > > > + strscpy(e->context_name, proc->context->name, 
> > > > > BINDERFS_MAX_NAME);
> > > > 
> > > > Strictly speaking, proc-context->name can also be initialized for 
> > > > !BINDERFS
> > > > so the BINDERFS in the MAX_NAME macro is misleading. So probably there 
> > > > should
> > > > be a BINDER_MAX_NAME (and associated checks for whether non BINDERFS 
> > > > names
> > > > fit within the MAX.
> > > 
> > > I know but I don't think it's worth special-casing non-binderfs devices.
> > > First, non-binderfs devices can only be created through a KCONFIG option
> > > determined at compile time. For stock Android the names are the same for
> > > all vendors afaik.
> > 
> > I am just talking about the name of weirdly named macro here.
> 
> You might miss context here: It's named that way because currently only
> binderfs binder devices are bound to that limit. That's a point I made
> further below in my previous mail. Non-binderfs devices are not subject
> to that restriction and when we tried to make them subject to the same
> it as rejected.

I know that. I am saying the memcpy is happening for regular binder devices
as well but the macro has BINDERFS in the name. That's all. It is not a
significant eye sore. But is a bit odd.

> 
> 
> > 
> > > Fifth, I already tried to push for validation of non-binderfs binder
> > > devices a while back when I wrote binderfs and was told that it's not
> > > needed. Hrydia tried the same and we decided the same thing. So you get
> > > to be the next person to send a patch. :)
> > 
> > I don't follow why we are talking about non-binderfs validation. I am just
> 
> Because above you said
> 
> > > > so the BINDERFS in the MAX_NAME macro is misleading. So probably there 
> > > > should
> > > > be a BINDER_MAX_NAME (and associated checks for whether non BINDERFS 
> > > > names
> > > > fit within the MAX.
> 
> which to me reads like you want generic checks for _all_ binder devices
> not just for the ones from binderfs.

No I am not talking about the checks at all, I am talking about the unwanted
mem copy you are doing for regular binder devices now. Before binderfs this
would not have happened, but now for regular binder devices we have to do the
extra mem copies which were avoided before. That was what I was talking about.

But this discussing is getting to bike shedding at this point, and since the
overhead is likely small, I am Ok with the change (though I don't like very
much the additional memcpy and the associated space wastage in the
transaction buffer for regular binder 

Re: [PATCH v2 1/2] dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe

2019-10-09 Thread Alexander Gordeev
On Wed, Oct 09, 2019 at 03:14:41PM +0300, Dan Carpenter wrote:
> > +config AVALON_DMA_PCI_VENDOR_ID
> > +   hex "PCI vendor ID"
> > +   default "0x1172"
> > +
> > +config AVALON_DMA_PCI_DEVICE_ID
> > +   hex "PCI device ID"
> > +   default "0xe003"
> 
> This feels wrong.  Why isn't it known in advance.

Because device designers would likely use they own IDs. The ones I
put are just defaults inherited from the (Altera) reference design.

> > +   u32 *rd_flags = hw->dma_desc_table_rd.cpu_addr->flags;
> > +   u32 *wr_flags = hw->dma_desc_table_wr.cpu_addr->flags;
> > +   struct avalon_dma_desc *desc;
> > +   struct virt_dma_desc *vdesc;
> > +   bool rd_done;
> > +   bool wr_done;
> > +
> > +   spin_lock(lock);
> > +
> > +   rd_done = (hw->h2d_last_id < 0);
> > +   wr_done = (hw->d2h_last_id < 0);
> > +
> > +   if (rd_done && wr_done) {
> > +   spin_unlock(lock);
> > +   return IRQ_NONE;
> > +   }
> > +
> > +   do {
> > +   if (!rd_done && rd_flags[hw->h2d_last_id])
> > +   rd_done = true;
> > +
> > +   if (!wr_done && wr_flags[hw->d2h_last_id])
> > +   wr_done = true;
> > +   } while (!rd_done || !wr_done);
> 
> This loop is very strange.  It feels like the last_id indexes needs
> to atomic or protected from racing somehow so we don't do an out of
> bounds read.

My bad. I should have put a comment on this. This polling comes from my
reading of the Intel documentation:

"The MSI interrupt notifies the host when a DMA operation has completed.
After the host receives this interrupt, it can poll the DMA read or write
status table to determine which entry or entries have the done bit set."

"The Descriptor Controller writes a 1 to the done bit of the status DWORD
to indicate successful completion. The Descriptor Controller also sends
an MSI interrupt for the final descriptor. After receiving this MSI,
host software can poll the done bit to determine status."

I sense an ambiguity above. It sounds possible an MSI interrupt could be
delivered before corresponding done bit is set. May be imperfect wording..
Anyway, the loop does look weird and in reality I doubt I observed the
done bit unset even once. So I put this polling just in case.

> > +   struct avalon_dma_chan *chan = to_avalon_dma_chan(dma_chan);
> > +   struct avalon_dma_desc *desc;
> > +   gfp_t gfp_flags = in_interrupt() ? GFP_NOWAIT : GFP_KERNEL;
> > +   dma_addr_t dev_addr;
> > +
> > +   if (direction == DMA_MEM_TO_DEV)
> > +   dev_addr = chan->dst_addr;
> > +   else if (direction == DMA_DEV_TO_MEM)
> > +   dev_addr = chan->src_addr;
> > +   else
> > +   return NULL;
> > +
> > +   desc = kzalloc(sizeof(*desc), gfp_flags);
> 
> Everyone else does GFP_WAIT or GFP_ATOMIC.  Is GFP_KERNEL really okay?

I am not sure why not to use GFP_KERNEL from non-atomic context.
Documentation/driver-api/dmaengine/provider.rst claims always to
use GFP_NOWAIT though:

  - Any allocation you might do should be using the GFP_NOWAIT
flag, in order not to potentially sleep, but without depleting
the emergency pool either.

So probably I just should use GFP_NOWAIT.

Thanks, Dan!

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


Re: [staging:staging-testing 41/59] drivers/staging/wfx/main.c:47:14-21: ERROR: PTR_ERR applied after initialization to constant on line 42

2019-10-09 Thread Jerome Pouiller
On Wednesday 9 October 2019 08:51:10 CEST Rong Chen wrote:
> On 10/7/19 4:36 PM, Jerome Pouiller wrote:
> > On Friday 4 October 2019 12:48:32 CEST kbuild test robot wrote:
> > [...]
>  drivers/staging/wfx/main.c:47:14-21: ERROR: PTR_ERR applied after 
>  initialization to constant on line 42
> >> vim +47 drivers/staging/wfx/main.c
> >>
> >>  30
> >>  31  struct gpio_desc *wfx_get_gpio(struct device *dev, int override, 
> >> const char *label)
> >>  32  {
> >>  33  struct gpio_desc *ret;
> >>  34  char label_buf[256];
> >>  35
> >>  36  if (override >= 0) {
> >>  37  snprintf(label_buf, sizeof(label_buf), "wfx_%s", 
> >> label);
> >>  38  ret = ERR_PTR(devm_gpio_request_one(dev, 
> >> override, GPIOF_OUT_INIT_LOW, label_buf));
> >>  39  if (!ret)
> >>  40  ret = gpio_to_desc(override);
> >>  41  } else if (override == -1) {
> >>> 42  ret = NULL;
> >>  43  } else {
> >>  44  ret = devm_gpiod_get(dev, label, GPIOD_OUT_LOW);
> >>  45  }
> >>  46  if (IS_ERR(ret) || !ret) {
> >>> 47  if (!ret || PTR_ERR(ret) == -ENOENT)
> >>  48  dev_warn(dev, "gpio %s is not defined\n", 
> >> label);
> >>  49  else
> >>  50  dev_warn(dev, "error while requesting 
> >> gpio %s\n", label);
> >>  51  ret = NULL;
> >>  52  } else {
> >>  53  dev_dbg(dev, "using gpio %d for %s\n", 
> >> desc_to_gpio(ret), label);
> >>  54  }
> >>  55  return ret;
> >>  56  }
> >>  57
> > I think that this report is a false positive or I missed something?
> >
> Sorry for the inconvenience, but we confirmed that the error first
> appeared since commit 0096214a59.

Hi Rong,

Err... I continue to not understand the meaning of this warning. If
override != -1 then ret is not constant, isn't?

-- 
Jérôme Pouiller

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


Re: [PATCH v2 0/6] media: cedrus: h264: Support multi-slice frames

2019-10-09 Thread Jernej Škrabec
Dne sreda, 09. oktober 2019 ob 12:18:45 CEST je Hans Verkuil napisal(a):
> On 10/7/19 9:01 PM, Jernej Škrabec wrote:
> > Dne ponedeljek, 07. oktober 2019 ob 12:44:24 CEST je Hans Verkuil 
napisal(a):
> >> Hi Jernej,
> >> 
> >> On 9/29/19 10:00 PM, Jernej Skrabec wrote:
> >>> This series adds support for decoding multi-slice H264 frames along with
> >>> support for V4L2_DEC_CMD_FLUSH and V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF.
> >>> 
> >>> Code was tested by modified ffmpeg, which can be found here:
> >>> https://github.com/jernejsk/FFmpeg, branch mainline-test
> >>> It has to be configured with at least following options:
> >>> --enable-v4l2-request --enable-libudev --enable-libdrm
> >>> 
> >>> Samples used for testing:
> >>> http://jernej.libreelec.tv/videos/h264/BA1_FT_C.mp4
> >>> http://jernej.libreelec.tv/videos/h264/h264.mp4
> >>> 
> >>> Command line used for testing:
> >>> ffmpeg -hwaccel drm -hwaccel_device /dev/dri/card0 -i h264.mp4 -pix_fmt
> >>> bgra -f fbdev /dev/fb0
> >>> 
> >>> Please note that V4L2_DEC_CMD_FLUSH was not tested because I'm
> >>> not sure how. ffmpeg follows exactly which slice is last in frame
> >>> and sets hold flag accordingly. Improper usage of hold flag would
> >>> corrupt ffmpeg assumptions and it would probably crash. Any ideas
> >>> how to test this are welcome!
> >>> 
> >>> Thanks to Jonas for adjusting ffmpeg.
> >>> 
> >>> Please let me know what you think.
> >>> 
> >>> Best regards,
> >>> Jernej
> >>> 
> >>> Changes from v1:
> >>> - added Rb tags
> >>> - updated V4L2_DEC_CMD_FLUSH documentation
> >>> - updated first slice detection in Cedrus
> >>> - hold capture buffer flag is set according to source format
> >>> - added v4l m2m stateless_(try_)decoder_cmd ioctl helpers
> >>> 
> >>> Hans Verkuil (2):
> >>>   vb2: add V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF
> >>>   videodev2.h: add V4L2_DEC_CMD_FLUSH
> >>> 
> >>> Jernej Skrabec (4):
> >>>   media: v4l2-mem2mem: add stateless_(try_)decoder_cmd ioctl helpers
> >>>   media: cedrus: Detect first slice of a frame
> >>>   media: cedrus: h264: Support multiple slices per frame
> >>>   media: cedrus: Add support for holding capture buffer
> >>>  
> >>>  Documentation/media/uapi/v4l/buffer.rst   | 13 ++
> >>>  .../media/uapi/v4l/vidioc-decoder-cmd.rst | 10 +++-
> >>>  .../media/uapi/v4l/vidioc-reqbufs.rst |  6 +++
> >>>  .../media/videodev2.h.rst.exceptions  |  1 +
> >>>  .../media/common/videobuf2/videobuf2-v4l2.c   |  8 +++-
> >>>  drivers/media/v4l2-core/v4l2-mem2mem.c| 35 ++
> >>>  drivers/staging/media/sunxi/cedrus/cedrus.h   |  1 +
> >>>  .../staging/media/sunxi/cedrus/cedrus_dec.c   | 11 +
> >>>  .../staging/media/sunxi/cedrus/cedrus_h264.c  | 11 -
> >>>  .../staging/media/sunxi/cedrus/cedrus_hw.c|  8 ++--
> >>>  .../staging/media/sunxi/cedrus/cedrus_video.c | 14 ++
> >>>  include/media/v4l2-mem2mem.h  | 46 +++
> >>>  include/media/videobuf2-core.h|  3 ++
> >>>  include/media/videobuf2-v4l2.h|  5 ++
> >>>  include/uapi/linux/videodev2.h| 14 --
> >>>  15 files changed, 175 insertions(+), 11 deletions(-)
> >> 
> >> I didn't want to make a v3 of this series, instead I hacked this patch
> >> that
> >> will hopefully do all the locking right.
> >> 
> >> Basically I moved all the 'held' related code into v4l2-mem2mem under
> >> job_spinlock. This simplifies the driver code as well.
> >> 
> >> But this is a hack that sits on top of this series. If your ffmpeg tests
> >> are now successful, then I'll turn this into a proper series with
> >> correct documentation (a lot of the comments are now wrong with this
> >> patch, so just ignore that).
> > 
> > Thanks for looking into this! With small fix mentioned below, it works!
> > Note that both scenarios I tested (flushing during decoding and flushing
> > after decoding is finished) are focused on capture queue. In order to
> > trigger output queue flush, ffmpeg would need to queue multiple jobs and
> > call flush before they are all processed. This is not something I can do
> > at this time. Maybe Jonas can help with modifying ffmpeg appropriately.
> > However, code for case seems correct to me.
> > 
> >> Regards,
> >> 
> >>Hans
> >> 
> >> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c
> >> b/drivers/media/v4l2-core/v4l2-mem2mem.c index 2677a07e4c9b..f81a8f2465ab
> >> 100644
> >> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c
> >> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
> >> @@ -412,25 +412,24 @@ static void v4l2_m2m_cancel_job(struct v4l2_m2m_ctx
> >> *m2m_ctx) }
> >> 
> >>  }
> >> 
> >> -void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev,
> >> -   struct v4l2_m2m_ctx *m2m_ctx)
> >> +static bool _v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev,
> >> +struct v4l2_m2m_ctx *m2m_ctx)
> >> 
> >>  {
> >> 
> >> -  unsigned long flags;
> >> -
> >> -  spin_lock_irqsave(_dev->job_spinlock, flags);
> 

Re: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls

2019-10-09 Thread Dan Carpenter
On Tue, Oct 01, 2019 at 09:58:55PM +0300, Dan Carpenter wrote:
> On Tue, Oct 01, 2019 at 06:13:21PM +0300, Denis Efremov wrote:
> > Just found an official documentation to this issue:
> > https://gcc.gnu.org/gcc-4.9/porting_to.html
> > "Null pointer checks may be optimized away more aggressively
> > ...
> > The pointers passed to memmove (and similar functions in ) must 
> > be non-null
> > even when nbytes==0, so GCC can use that information to remove the check 
> > after the
> > memmove call. Calling copy(p, NULL, 0) can therefore deference a null 
> > pointer and crash."
> > 
> 
> Correct.  In glibc those functions are annotated as non-NULL.
> 
> extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
>  size_t __n) __THROW __nonnull ((1, 2));

I was wrong on this.  It's built into GCC so it doesn't matter how it's
annotated.

> 
> We aren't going to do that in the kernel.  A second difference is that
> in the kernel we use -fno-delete-null-pointer-checks so it doesn't
> delete the NULL checks.

But it's true that the kernel has -fno-delete-null-pointer-checks so I
don't think this is worth patching.

regards,
dan carpenter

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


Re: [PATCH] binder: prevent UAF read in print_binder_transaction_log_entry()

2019-10-09 Thread Christian Brauner
On Wed, Oct 09, 2019 at 10:21:29AM -0400, Joel Fernandes wrote:
> On Wed, Oct 09, 2019 at 12:40:12PM +0200, Christian Brauner wrote:
> > On Tue, Oct 08, 2019 at 02:05:16PM -0400, Joel Fernandes wrote:
> > > On Tue, Oct 08, 2019 at 03:01:59PM +0200, Christian Brauner wrote:
> > > > When a binder transaction is initiated on a binder device coming from a
> > > > binderfs instance, a pointer to the name of the binder device is stashed
> > > > in the binder_transaction_log_entry's context_name member. Later on it
> > > > is used to print the name in print_binder_transaction_log_entry(). By
> > > > the time print_binder_transaction_log_entry() accesses context_name
> > > > binderfs_evict_inode() might have already freed the associated memory
> > > > thereby causing a UAF. Do the simple thing and prevent this by copying
> > > > the name of the binder device instead of stashing a pointer to it.
> > > > 
> > > > Reported-by: Jann Horn 
> > > > Fixes: 03e2e07e3814 ("binder: Make transaction_log available in 
> > > > binderfs")
> > > > Link: 
> > > > https://lore.kernel.org/r/cag48ez14q0-f8lqsvcnbyr2o6gpw8shxsm4u5jmd9mpstem...@mail.gmail.com
> > > > Cc: Joel Fernandes 
> > > > Cc: Todd Kjos 
> > > > Cc: Hridya Valsaraju 
> > > > Signed-off-by: Christian Brauner 
> > > > ---
> > > >  drivers/android/binder.c  | 4 +++-
> > > >  drivers/android/binder_internal.h | 2 +-
> > > >  2 files changed, 4 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> > > > index c0a491277aca..5b9ac2122e89 100644
> > > > --- a/drivers/android/binder.c
> > > > +++ b/drivers/android/binder.c
> > > > @@ -57,6 +57,7 @@
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > +#include 
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > @@ -66,6 +67,7 @@
> > > >  #include 
> > > >  
> > > >  #include 
> > > > +#include 
> > > >  
> > > >  #include 
> > > >  
> > > > @@ -2876,7 +2878,7 @@ static void binder_transaction(struct binder_proc 
> > > > *proc,
> > > > e->target_handle = tr->target.handle;
> > > > e->data_size = tr->data_size;
> > > > e->offsets_size = tr->offsets_size;
> > > > -   e->context_name = proc->context->name;
> > > > +   strscpy(e->context_name, proc->context->name, 
> > > > BINDERFS_MAX_NAME);
> > > 
> > > Strictly speaking, proc-context->name can also be initialized for 
> > > !BINDERFS
> > > so the BINDERFS in the MAX_NAME macro is misleading. So probably there 
> > > should
> > > be a BINDER_MAX_NAME (and associated checks for whether non BINDERFS names
> > > fit within the MAX.
> > 
> > I know but I don't think it's worth special-casing non-binderfs devices.
> > First, non-binderfs devices can only be created through a KCONFIG option
> > determined at compile time. For stock Android the names are the same for
> > all vendors afaik.
> 
> I am just talking about the name of weirdly named macro here.

You might miss context here: It's named that way because currently only
binderfs binder devices are bound to that limit. That's a point I made
further below in my previous mail. Non-binderfs devices are not subject
to that restriction and when we tried to make them subject to the same
it as rejected.



> 
> > Fifth, I already tried to push for validation of non-binderfs binder
> > devices a while back when I wrote binderfs and was told that it's not
> > needed. Hrydia tried the same and we decided the same thing. So you get
> > to be the next person to send a patch. :)
> 
> I don't follow why we are talking about non-binderfs validation. I am just

Because above you said

> > > so the BINDERFS in the MAX_NAME macro is misleading. So probably there 
> > > should
> > > be a BINDER_MAX_NAME (and associated checks for whether non BINDERFS names
> > > fit within the MAX.

which to me reads like you want generic checks for _all_ binder devices
not just for the ones from binderfs.

(Btw, I didn't read your comments as pointing it out the patch is buggy.
I mostly wanted to provide context why we ended up with the
binderfs-specific restriction. Maybe the list sounded like a complaint
but it wasn't meant to. :))

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


Re: [PATCH] binder: prevent UAF read in print_binder_transaction_log_entry()

2019-10-09 Thread Joel Fernandes
On Wed, Oct 09, 2019 at 12:40:12PM +0200, Christian Brauner wrote:
> On Tue, Oct 08, 2019 at 02:05:16PM -0400, Joel Fernandes wrote:
> > On Tue, Oct 08, 2019 at 03:01:59PM +0200, Christian Brauner wrote:
> > > When a binder transaction is initiated on a binder device coming from a
> > > binderfs instance, a pointer to the name of the binder device is stashed
> > > in the binder_transaction_log_entry's context_name member. Later on it
> > > is used to print the name in print_binder_transaction_log_entry(). By
> > > the time print_binder_transaction_log_entry() accesses context_name
> > > binderfs_evict_inode() might have already freed the associated memory
> > > thereby causing a UAF. Do the simple thing and prevent this by copying
> > > the name of the binder device instead of stashing a pointer to it.
> > > 
> > > Reported-by: Jann Horn 
> > > Fixes: 03e2e07e3814 ("binder: Make transaction_log available in binderfs")
> > > Link: 
> > > https://lore.kernel.org/r/cag48ez14q0-f8lqsvcnbyr2o6gpw8shxsm4u5jmd9mpstem...@mail.gmail.com
> > > Cc: Joel Fernandes 
> > > Cc: Todd Kjos 
> > > Cc: Hridya Valsaraju 
> > > Signed-off-by: Christian Brauner 
> > > ---
> > >  drivers/android/binder.c  | 4 +++-
> > >  drivers/android/binder_internal.h | 2 +-
> > >  2 files changed, 4 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> > > index c0a491277aca..5b9ac2122e89 100644
> > > --- a/drivers/android/binder.c
> > > +++ b/drivers/android/binder.c
> > > @@ -57,6 +57,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -66,6 +67,7 @@
> > >  #include 
> > >  
> > >  #include 
> > > +#include 
> > >  
> > >  #include 
> > >  
> > > @@ -2876,7 +2878,7 @@ static void binder_transaction(struct binder_proc 
> > > *proc,
> > >   e->target_handle = tr->target.handle;
> > >   e->data_size = tr->data_size;
> > >   e->offsets_size = tr->offsets_size;
> > > - e->context_name = proc->context->name;
> > > + strscpy(e->context_name, proc->context->name, BINDERFS_MAX_NAME);
> > 
> > Strictly speaking, proc-context->name can also be initialized for !BINDERFS
> > so the BINDERFS in the MAX_NAME macro is misleading. So probably there 
> > should
> > be a BINDER_MAX_NAME (and associated checks for whether non BINDERFS names
> > fit within the MAX.
> 
> I know but I don't think it's worth special-casing non-binderfs devices.
> First, non-binderfs devices can only be created through a KCONFIG option
> determined at compile time. For stock Android the names are the same for
> all vendors afaik.

I am just talking about the name of weirdly named macro here.

> Second, BINDERFS_MAX_NAME is set to the maximum path name component
> length that nearly all filesystems support (256 chars). If you exceed
> that then you run afoul of a bunch of other assumptions already and will
> cause trouble.

Again, just talking about the name.

> Third, even if there is someone crazy and uses more than 256 chars for a
> non-binderfs device at KCONFIG time strscpy will do the right thing and
> truncate and you'd see a truncated binder device name. This doesn't seem
> to be a big deal for a debugfs interface.

Sure I never said the patch has a bug.

> Fourth, the check for non-binderfs devices technically has nothing to do
> with this patch. This patch should really just do the minimal thing and
> fix the UAF. Which it does.

Again, never said the patch is buggy.

> Fifth, I already tried to push for validation of non-binderfs binder
> devices a while back when I wrote binderfs and was told that it's not
> needed. Hrydia tried the same and we decided the same thing. So you get
> to be the next person to send a patch. :)

I don't follow why we are talking about non-binderfs validation. I am just
saying a memcpy of the name could have been avoided for regular binder
devices. But since Todd Acked it, I wont stand in the way..

> > One more thought, this can be made dependent on CONFIG_BINDERFS since 
> > regular
> > binder devices cannot be unregistered AFAICS and as Jann said, the problem 
> > is
> > BINDERFS specific. That way we avoid the memcpy for _every_ transaction.
> > These can be thundering when Android starts up.
> 
> Unless Todd sees this as a real performance problem I'm weary to
> introduce additional checking and record a pointer for non-binderfs and
> a memcpy() for binderfs devices. :)

Ok.

> > (I secretly wish C strings could be refcounted to avoid exactly this issue,
> > that should not be hard to develop but I am not sure if it is worth it for
> > this problem :) - For one, it will avoid having to do the strcpy for _every_
> > transaction).
> > 
> > Other than these nits, please add my tag on whichever is the final solution:
> > 
> > Reviewed-by: Joel Fernandes (Google) 
> 
> Thanks for the review, Joel. :)

My duty!! ;-)

thanks,

 - Joel

___
devel mailing list

Re: [PATCH v2 2/3] staging: wfx: Make function 'wfx_tx_queue_get' static

2019-10-09 Thread Jerome Pouiller
On Wednesday 9 October 2019 15:43:35 CEST zhengbin wrote:
> CAUTION: This email originated from outside of the organization. Do not click 
> links or open attachments unless you recognize the sender and know the 
> content is safe.
> 
> 
> Fix sparse warnings:
> 
> drivers/staging/wfx/queue.c:218:16: warning: symbol 'wfx_tx_queue_get' was 
> not declared. Should it be static?
> 
> Reported-by: Hulk Robot 
> Signed-off-by: zhengbin 
> ---
>  drivers/staging/wfx/queue.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c
> index 6f1be4f..c44ffdf 100644
> --- a/drivers/staging/wfx/queue.c
> +++ b/drivers/staging/wfx/queue.c
> @@ -215,7 +215,9 @@ void wfx_tx_queue_put(struct wfx_dev *wdev, struct 
> wfx_queue *queue, struct sk_b
> spin_unlock_bh(>queue.lock);
>  }
> 
> -struct sk_buff *wfx_tx_queue_get(struct wfx_dev *wdev, struct wfx_queue 
> *queue, u32 link_id_map)
> +static struct sk_buff *wfx_tx_queue_get(struct wfx_dev *wdev,
> +   struct wfx_queue *queue,
> +   u32 link_id_map)
>  {
> struct sk_buff *skb = NULL;
> struct sk_buff *item;
> --
> 2.7.4
> 

Reviewed-by: Jérôme Pouiller 

-- 
Jérôme Pouiller

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


Re: [PATCH v2 3/3] staging: wfx: Make some functions static in sta.c

2019-10-09 Thread Jerome Pouiller
On Wednesday 9 October 2019 15:43:35 CEST zhengbin wrote:
> Fix sparse warnings:
> 
> drivers/staging/wfx/sta.c:269:6: warning: symbol 'wfx_update_filtering_work' 
> was not declared. Should it be static?
> drivers/staging/wfx/sta.c:475:6: warning: symbol 'wfx_event_handler_work' was 
> not declared. Should it be static?
> drivers/staging/wfx/sta.c:521:6: warning: symbol 'wfx_bss_loss_work' was not 
> declared. Should it be static?
> drivers/staging/wfx/sta.c:528:6: warning: symbol 'wfx_bss_params_work' was 
> not declared. Should it be static?
> drivers/staging/wfx/sta.c:539:6: warning: symbol 
> 'wfx_set_beacon_wakeup_period_work' was not declared. Should it be static?
> drivers/staging/wfx/sta.c:732:6: warning: symbol 'wfx_unjoin_work' was not 
> declared. Should it be static?
> drivers/staging/wfx/sta.c:794:6: warning: symbol 'wfx_set_cts_work' was not 
> declared. Should it be static?
> drivers/staging/wfx/sta.c:1234:6: warning: symbol 'wfx_set_tim_work' was not 
> declared. Should it be static?
> 
> Reported-by: Hulk Robot 
> Signed-off-by: zhengbin 
> ---
>  drivers/staging/wfx/sta.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
> index 2855d14..d19bab6 100644
> --- a/drivers/staging/wfx/sta.c
> +++ b/drivers/staging/wfx/sta.c
> @@ -269,7 +269,7 @@ void wfx_update_filtering(struct wfx_vif *wvif)
> kfree(bf_tbl);
>  }
> 
> -void wfx_update_filtering_work(struct work_struct *work)
> +static void wfx_update_filtering_work(struct work_struct *work)
>  {
> struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
> update_filtering_work);
> 
> @@ -475,7 +475,7 @@ static void wfx_event_report_rssi(struct wfx_vif *wvif, 
> uint8_t raw_rcpi_rssi)
> ieee80211_cqm_rssi_notify(wvif->vif, cqm_evt, rcpi_rssi, GFP_KERNEL);
>  }
> 
> -void wfx_event_handler_work(struct work_struct *work)
> +static void wfx_event_handler_work(struct work_struct *work)
>  {
> struct wfx_vif *wvif =
> container_of(work, struct wfx_vif, event_handler_work);
> @@ -521,14 +521,14 @@ void wfx_event_handler_work(struct work_struct *work)
> __wfx_free_event_queue();
>  }
> 
> -void wfx_bss_loss_work(struct work_struct *work)
> +static void wfx_bss_loss_work(struct work_struct *work)
>  {
> struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
> bss_loss_work.work);
> 
> ieee80211_connection_loss(wvif->vif);
>  }
> 
> -void wfx_bss_params_work(struct work_struct *work)
> +static void wfx_bss_params_work(struct work_struct *work)
>  {
> struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
> bss_params_work);
> 
> @@ -539,7 +539,7 @@ void wfx_bss_params_work(struct work_struct *work)
> mutex_unlock(>wdev->conf_mutex);
>  }
> 
> -void wfx_set_beacon_wakeup_period_work(struct work_struct *work)
> +static void wfx_set_beacon_wakeup_period_work(struct work_struct *work)
>  {
> struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
> set_beacon_wakeup_period_work);
> 
> @@ -732,7 +732,7 @@ static void wfx_do_join(struct wfx_vif *wvif)
> cfg80211_put_bss(wvif->wdev->hw->wiphy, bss);
>  }
> 
> -void wfx_unjoin_work(struct work_struct *work)
> +static void wfx_unjoin_work(struct work_struct *work)
>  {
> struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
> unjoin_work);
> 
> @@ -794,7 +794,7 @@ int wfx_sta_remove(struct ieee80211_hw *hw, struct 
> ieee80211_vif *vif,
> return 0;
>  }
> 
> -void wfx_set_cts_work(struct work_struct *work)
> +static void wfx_set_cts_work(struct work_struct *work)
>  {
> struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
> set_cts_work);
> u8 erp_ie[3] = { WLAN_EID_ERP_INFO, 1, 0 };
> @@ -1234,7 +1234,7 @@ static int wfx_set_tim_impl(struct wfx_vif *wvif, bool 
> aid0_bit_set)
> return 0;
>  }
> 
> -void wfx_set_tim_work(struct work_struct *work)
> +static void wfx_set_tim_work(struct work_struct *work)
>  {
> struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
> set_tim_work);
> 
> --
> 2.7.4
> 

Reviewed-by: Jérôme Pouiller 

-- 
Jérôme Pouiller

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


Re: [PATCH v2 1/3] staging: wfx: Make function 'sram_write_dma_safe','load_firmware_secure' static

2019-10-09 Thread Jerome Pouiller
On Wednesday 9 October 2019 15:43:31 CEST zhengbin wrote:
> CAUTION: This email originated from outside of the organization. Do not click 
> links or open attachments unless you recognize the sender and know the 
> content is safe.
> 
> 
> Fix sparse warnings:
> 
> drivers/staging/wfx/fwio.c:83:5: warning: symbol 'sram_write_dma_safe' was 
> not declared. Should it be static?
> drivers/staging/wfx/fwio.c:229:5: warning: symbol 'load_firmware_secure' was 
> not declared. Should it be static?
> 
> Reported-by: Hulk Robot 
> Signed-off-by: zhengbin 
> ---
>  drivers/staging/wfx/fwio.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c
> index 8fb4a9f..6d82c62 100644
> --- a/drivers/staging/wfx/fwio.c
> +++ b/drivers/staging/wfx/fwio.c
> @@ -80,7 +80,8 @@ static const char * const fwio_error_strings[] = {
>   * NOTE: it may also be possible to use 'pages' from struct firmware and 
> avoid
>   * bounce buffer
>   */
> -int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, 
> size_t len)
> +static int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf,
> +  size_t len)
>  {
> int ret;
> const u8 *tmp;
> @@ -226,7 +227,7 @@ static void print_boot_status(struct wfx_dev *wdev)
> }
>  }
> 
> -int load_firmware_secure(struct wfx_dev *wdev)
> +static int load_firmware_secure(struct wfx_dev *wdev)
>  {
> const struct firmware *fw = NULL;
> int header_size;
> --
> 2.7.4
> 

Reviewed-by: Jérôme Pouiller 

-- 
Jérôme Pouiller

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


Re: [PATCH][next] staging: wfx: fix swapped arguments in memset call

2019-10-09 Thread Jerome Pouiller
On Wednesday 9 October 2019 11:46:08 CEST Colin King wrote:
> From: Colin Ian King 
> 
> The memset appears to have the 2nd and 3rd arguments in the wrong
> order, fix this by swapping these around into the correct order.
> 
> Addresses-Coverity: ("Memset fill truncated")
> Fixes: 4f8b7fabb15d ("staging: wfx: allow to send commands to chip")
> Signed-off-by: Colin Ian King 
> ---
>  drivers/staging/wfx/debug.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c
> index 8de16ad7c710..761ad9b4f27e 100644
> --- a/drivers/staging/wfx/debug.c
> +++ b/drivers/staging/wfx/debug.c
> @@ -226,7 +226,7 @@ static ssize_t wfx_send_hif_msg_write(struct file *file, 
> const char __user *user
> // wfx_cmd_send() chekc that reply buffer is wide enough, but do not
> // return precise length read. User have to know how many bytes should
> // be read. Filling reply buffer with a memory pattern may help user.
> -   memset(context->reply, sizeof(context->reply), 0xFF);
> +   memset(context->reply, 0xFF, sizeof(context->reply));
> request = memdup_user(user_buf, count);
> if (IS_ERR(request))
> return PTR_ERR(request);

Ouch! I realize that "-Wmemset-transposed-args" and/or "-Wmemset-elt-size"
don't catch this case.

Thank you for your attentive reading.

Reviewed-by: Jérôme Pouiller 

-- 
Jérôme Pouiller

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


Re: [PATCH v2 0/3] staging: wfx: Make some functions static

2019-10-09 Thread Dan Carpenter
Thanks!

regars,
dan carpenter

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


Re: [PATCH RFC v2 2/2] dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe test

2019-10-09 Thread Dan Carpenter
On Wed, Oct 09, 2019 at 12:12:31PM +0200, Alexander Gordeev wrote:
> diff --git a/drivers/dma/avalon-test/avalon-dev.c 
> b/drivers/dma/avalon-test/avalon-dev.c
> new file mode 100644
> index ..9e83f777f937
> --- /dev/null
> +++ b/drivers/dma/avalon-test/avalon-dev.c
> @@ -0,0 +1,65 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Avalon DMA driver
> + *
> + * Author: Alexander Gordeev 
> + */
> +#include 
> +#include 
> +#include 
> +
> +#include "avalon-dev.h"
> +#include "avalon-ioctl.h"
> +#include "avalon-mmap.h"
> +
> +const struct file_operations avalon_dev_fops = {
> + .llseek = generic_file_llseek,
> + .unlocked_ioctl = avalon_dev_ioctl,
> + .mmap   = avalon_dev_mmap,
> +};
> +
> +static struct avalon_dev avalon_dev;
> +
> +static int __init avalon_drv_init(void)
> +{
> + struct avalon_dev *adev = _dev;
> + struct dma_chan *chan;
> + dma_cap_mask_t mask;
> + int ret;
> +
> + dma_cap_zero(mask);
> + dma_cap_set(DMA_SLAVE, mask);
> +
> + chan = dma_request_channel(mask, NULL, NULL);
> + if (!chan)
> + return -ENODEV;
> +
> + adev->dma_chan  = chan;
> +
> + adev->misc_dev.minor= MISC_DYNAMIC_MINOR;
> + adev->misc_dev.name = DEVICE_NAME;
> + adev->misc_dev.nodename = DEVICE_NAME;
> + adev->misc_dev.fops = _dev_fops;
> + adev->misc_dev.mode = 0644;
> +
> + ret = misc_register(>misc_dev);
> + if (ret)
> + return ret;

dma_release_channel(chan);

Btw, I find the error labels very frustrating to read.  They all are
"come-from" style labels.

p = malloc();
if (!p)
goto malloc_failed;

That doesn't tell me anything about what the goto does.  It should be
like:

if (ret)
goto release_dma;

return 0;

release_dma:
dma_release_channel(chan);

return ret;

> +
> + return 0;
> +}
> +
> +static void __exit avalon_drv_exit(void)
> +{
> + struct avalon_dev *adev = _dev;
> +
> + misc_deregister(>misc_dev);
> + dma_release_channel(adev->dma_chan);
> +}
> +
> +module_init(avalon_drv_init);
> +module_exit(avalon_drv_exit);
> +
> +MODULE_AUTHOR("Alexander Gordeev ");
> +MODULE_DESCRIPTION("Avalon DMA control driver");
> +MODULE_LICENSE("GPL v2");
> diff --git a/drivers/dma/avalon-test/avalon-dev.h 
> b/drivers/dma/avalon-test/avalon-dev.h
> new file mode 100644
> index ..f06362ebf110
> --- /dev/null
> +++ b/drivers/dma/avalon-test/avalon-dev.h
> @@ -0,0 +1,33 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Avalon DMA driver
> + *
> + * Author: Alexander Gordeev 
> + */
> +#ifndef __AVALON_DEV_H__
> +#define __AVALON_DEV_H__
> +
> +#include 
> +#include 
> +
> +#include "../avalon/avalon-hw.h"
> +
> +#define TARGET_MEM_BASE  CONFIG_AVALON_TEST_TARGET_BASE
> +#define TARGET_MEM_SIZE  CONFIG_AVALON_TEST_TARGET_SIZE
> +
> +#define TARGET_DMA_SIZE (2 * AVALON_DMA_MAX_TANSFER_SIZE)
> +#define TARGET_DMA_SIZE_SG  TARGET_MEM_SIZE
> +
> +#define DEVICE_NAME  "avalon-dev"
> +
> +struct avalon_dev {
> + struct dma_chan *dma_chan;
> + struct miscdevice misc_dev;
> +};
> +
> +static inline struct device *chan_to_dev(struct dma_chan *chan)
> +{
> + return chan->device->dev;
> +}
> +
> +#endif
> diff --git a/drivers/dma/avalon-test/avalon-ioctl.c 
> b/drivers/dma/avalon-test/avalon-ioctl.c
> new file mode 100644
> index ..b90cdedf4400
> --- /dev/null
> +++ b/drivers/dma/avalon-test/avalon-ioctl.c
> @@ -0,0 +1,128 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Avalon DMA driver
> + *
> + * Author: Alexander Gordeev 
> + */
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include "avalon-xfer.h"
> +
> +long avalon_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> +{
> + struct avalon_dev *adev = container_of(file->private_data,
> + struct avalon_dev, misc_dev);
> + struct dma_chan *chan = adev->dma_chan;
> + struct device *dev = chan_to_dev(chan);
> + struct iovec iovec[2];
> + void __user *buf = NULL, __user *buf_rd = NULL, __user *buf_wr = NULL;
> + size_t len = 0, len_rd = 0, len_wr = 0;
> + int ret = 0;
> +
> + dev_dbg(dev, "%s(%d) { cmd %x", __FUNCTION__, __LINE__, cmd);

Use ftrace and delete this debug code.

> +
> + switch (cmd) {
> + case IOCTL_AVALON_DMA_GET_INFO: {
> + struct avalon_dma_info info = {
> + .mem_addr   = TARGET_MEM_BASE,
> + .mem_size   = TARGET_MEM_SIZE,
> + .dma_size   = TARGET_DMA_SIZE,
> + .dma_size_sg= TARGET_DMA_SIZE_SG,
> + };
> +
> + if (copy_to_user((void *)arg, , sizeof(info))) {
> + ret = -EFAULT;
> + goto done;
> + }
> +
> + goto done;
> + }
> + case 

[PATCH v2 0/3] staging: wfx: Make some functions static

2019-10-09 Thread zhengbin
v1->v2: keep the declaration style consistent within the file

zhengbin (3):
  staging: wfx: Make function
'sram_write_dma_safe','load_firmware_secure' static
  staging: wfx: Make function 'wfx_tx_queue_get' static
  staging: wfx: Make some functions static in sta.c

 drivers/staging/wfx/fwio.c  |  5 +++--
 drivers/staging/wfx/queue.c |  4 +++-
 drivers/staging/wfx/sta.c   | 16 
 3 files changed, 14 insertions(+), 11 deletions(-)

--
2.7.4

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


[PATCH v2 3/3] staging: wfx: Make some functions static in sta.c

2019-10-09 Thread zhengbin
Fix sparse warnings:

drivers/staging/wfx/sta.c:269:6: warning: symbol 'wfx_update_filtering_work' 
was not declared. Should it be static?
drivers/staging/wfx/sta.c:475:6: warning: symbol 'wfx_event_handler_work' was 
not declared. Should it be static?
drivers/staging/wfx/sta.c:521:6: warning: symbol 'wfx_bss_loss_work' was not 
declared. Should it be static?
drivers/staging/wfx/sta.c:528:6: warning: symbol 'wfx_bss_params_work' was not 
declared. Should it be static?
drivers/staging/wfx/sta.c:539:6: warning: symbol 
'wfx_set_beacon_wakeup_period_work' was not declared. Should it be static?
drivers/staging/wfx/sta.c:732:6: warning: symbol 'wfx_unjoin_work' was not 
declared. Should it be static?
drivers/staging/wfx/sta.c:794:6: warning: symbol 'wfx_set_cts_work' was not 
declared. Should it be static?
drivers/staging/wfx/sta.c:1234:6: warning: symbol 'wfx_set_tim_work' was not 
declared. Should it be static?

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/staging/wfx/sta.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 2855d14..d19bab6 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -269,7 +269,7 @@ void wfx_update_filtering(struct wfx_vif *wvif)
kfree(bf_tbl);
 }

-void wfx_update_filtering_work(struct work_struct *work)
+static void wfx_update_filtering_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
update_filtering_work);

@@ -475,7 +475,7 @@ static void wfx_event_report_rssi(struct wfx_vif *wvif, 
uint8_t raw_rcpi_rssi)
ieee80211_cqm_rssi_notify(wvif->vif, cqm_evt, rcpi_rssi, GFP_KERNEL);
 }

-void wfx_event_handler_work(struct work_struct *work)
+static void wfx_event_handler_work(struct work_struct *work)
 {
struct wfx_vif *wvif =
container_of(work, struct wfx_vif, event_handler_work);
@@ -521,14 +521,14 @@ void wfx_event_handler_work(struct work_struct *work)
__wfx_free_event_queue();
 }

-void wfx_bss_loss_work(struct work_struct *work)
+static void wfx_bss_loss_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
bss_loss_work.work);

ieee80211_connection_loss(wvif->vif);
 }

-void wfx_bss_params_work(struct work_struct *work)
+static void wfx_bss_params_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
bss_params_work);

@@ -539,7 +539,7 @@ void wfx_bss_params_work(struct work_struct *work)
mutex_unlock(>wdev->conf_mutex);
 }

-void wfx_set_beacon_wakeup_period_work(struct work_struct *work)
+static void wfx_set_beacon_wakeup_period_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
set_beacon_wakeup_period_work);

@@ -732,7 +732,7 @@ static void wfx_do_join(struct wfx_vif *wvif)
cfg80211_put_bss(wvif->wdev->hw->wiphy, bss);
 }

-void wfx_unjoin_work(struct work_struct *work)
+static void wfx_unjoin_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, unjoin_work);

@@ -794,7 +794,7 @@ int wfx_sta_remove(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
return 0;
 }

-void wfx_set_cts_work(struct work_struct *work)
+static void wfx_set_cts_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_cts_work);
u8 erp_ie[3] = { WLAN_EID_ERP_INFO, 1, 0 };
@@ -1234,7 +1234,7 @@ static int wfx_set_tim_impl(struct wfx_vif *wvif, bool 
aid0_bit_set)
return 0;
 }

-void wfx_set_tim_work(struct work_struct *work)
+static void wfx_set_tim_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_tim_work);

--
2.7.4

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


[PATCH v2 2/3] staging: wfx: Make function 'wfx_tx_queue_get' static

2019-10-09 Thread zhengbin
Fix sparse warnings:

drivers/staging/wfx/queue.c:218:16: warning: symbol 'wfx_tx_queue_get' was not 
declared. Should it be static?

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/staging/wfx/queue.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c
index 6f1be4f..c44ffdf 100644
--- a/drivers/staging/wfx/queue.c
+++ b/drivers/staging/wfx/queue.c
@@ -215,7 +215,9 @@ void wfx_tx_queue_put(struct wfx_dev *wdev, struct 
wfx_queue *queue, struct sk_b
spin_unlock_bh(>queue.lock);
 }

-struct sk_buff *wfx_tx_queue_get(struct wfx_dev *wdev, struct wfx_queue 
*queue, u32 link_id_map)
+static struct sk_buff *wfx_tx_queue_get(struct wfx_dev *wdev,
+   struct wfx_queue *queue,
+   u32 link_id_map)
 {
struct sk_buff *skb = NULL;
struct sk_buff *item;
--
2.7.4

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


[PATCH v2 1/3] staging: wfx: Make function 'sram_write_dma_safe', 'load_firmware_secure' static

2019-10-09 Thread zhengbin
Fix sparse warnings:

drivers/staging/wfx/fwio.c:83:5: warning: symbol 'sram_write_dma_safe' was not 
declared. Should it be static?
drivers/staging/wfx/fwio.c:229:5: warning: symbol 'load_firmware_secure' was 
not declared. Should it be static?

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/staging/wfx/fwio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c
index 8fb4a9f..6d82c62 100644
--- a/drivers/staging/wfx/fwio.c
+++ b/drivers/staging/wfx/fwio.c
@@ -80,7 +80,8 @@ static const char * const fwio_error_strings[] = {
  * NOTE: it may also be possible to use 'pages' from struct firmware and avoid
  * bounce buffer
  */
-int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, size_t 
len)
+static int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf,
+  size_t len)
 {
int ret;
const u8 *tmp;
@@ -226,7 +227,7 @@ static void print_boot_status(struct wfx_dev *wdev)
}
 }

-int load_firmware_secure(struct wfx_dev *wdev)
+static int load_firmware_secure(struct wfx_dev *wdev)
 {
const struct firmware *fw = NULL;
int header_size;
--
2.7.4

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


Re: [PATCH 1/3] staging: wfx: Make function 'sram_write_dma_safe', 'load_firmware_secure' static

2019-10-09 Thread Dan Carpenter
On Wed, Oct 09, 2019 at 09:03:37PM +0800, zhengbin wrote:
> -int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, 
> size_t len)
> +static int
> +sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, size_t 
> len)

Either declaration style is fine, but keep it consistent within the
file.  Here the style should be:

static int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf,
   size_t len)

regards,
dan carpenter

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


Re: [PATCH RFC v2 2/2] dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe test

2019-10-09 Thread Greg KH
On Wed, Oct 09, 2019 at 12:12:31PM +0200, Alexander Gordeev wrote:
> +config AVALON_TEST_TARGET_BASE
> + hex "Target device base address"
> + default "0x7000"
> +
> +config AVALON_TEST_TARGET_SIZE
> + hex "Target device memory size"
> + default "0x1000"

Don't put stuff like this as a configuration option, requiring the
kernel to be rebuilt.  Make it dynamic, or from device tree, but not
like this.

thanks,

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


Re: [PATCH v2 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2019-10-09 Thread Dan Carpenter
On Wed, Oct 09, 2019 at 02:30:32PM +0300, Dan Carpenter wrote:
> > +   platform = kzalloc(sizeof(*platform), GFP_KERNEL);
> > +   if (!platform) {
> > +   DRM_DEV_ERROR(dev, "failed to allocate driver data\n");
> > +   ret = -ENOMEM;
> > +   goto exit;
> 
> return -ENOMEM;
> 
> > +   }
> > +
> > +   pdata = >pdata;
> > +
> > +   /* device tree parsing function call */
> > +   ret = anx7625_parse_dt(>dev, pdata);
> > +   if (ret != 0)   /* if occurs error */
> > +   goto err0;
> 
> != 0 is double negative.  Choose better label names.  Remove the obvious
> comment.
> 
> if (ret)
>   goto free_platform;
> 
> > +
> > +   anx7625_init_gpio(platform);
> > +
> > +   /* to access global platform data */
> > +   platform->client = client;
> > +   i2c_set_clientdata(client, platform);
> > +
> > +   if (platform->pdata.extcon_supported) {
> > +   /* get extcon device from DTS */
> > +   platform->extcon = extcon_get_edev_by_phandle(>dev, 0);
> > +   if (PTR_ERR(platform->extcon) == -EPROBE_DEFER)
> > +   goto err0;
> 
> Preserve the error code.
> 
> > +   if (IS_ERR(platform->extcon)) {
> > +   DRM_DEV_ERROR(>dev,
> > + "can not get extcon device!");
> > +   goto err0;
> 
> Prerve the error code.
> 
> > +   }
> > +
> > +   ret = anx7625_extcon_notifier_init(platform);
> > +   if (ret < 0)
> > +   goto err0;
> > +   }
> > +
> > +   atomic_set(>power_status, 0);
> > +
> > +   mutex_init(>lock);
> > +
> > +   if (platform->pdata.gpio_intr_hpd) {
> > +   INIT_WORK(>work, anx7625_work_func);
> > +   platform->workqueue = create_workqueue("anx7625_work");
> > +   if (!platform->workqueue) {
> > +   DRM_DEV_ERROR(dev, "failed to create work queue\n");
> > +   ret = -ENOMEM;
> > +   goto err1;
> 
> This goto will crash.  Because you have forgotten what the most recently
> allocated resource was.  It should be "goto free_platform;" still.
> 
> > +   }
> > +
> > +   platform->pdata.hpd_irq =
> > +   gpiod_to_irq(platform->pdata.gpio_intr_hpd);
> > +   if (platform->pdata.hpd_irq < 0) {
> > +   DRM_DEV_ERROR(dev, "failed to get gpio irq\n");
> > +   goto err1;
> 
> goto free_wq;
> 
> > +   }
> > +
> > +   ret = request_threaded_irq(platform->pdata.hpd_irq,
> > +  NULL, anx7625_intr_hpd_isr,
> > +  IRQF_TRIGGER_FALLING |
> > +  IRQF_TRIGGER_RISING |
> > +  IRQF_ONESHOT,
> > +  "anx7625-hpd", platform);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "failed to request irq\n");
> > +   goto err1;
> > +   }
> > +
> > +   ret = irq_set_irq_wake(platform->pdata.hpd_irq, 1);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "Request irq for hpd");
> > +   DRM_DEV_ERROR(dev, "interrupt wake set fail\n");
> > +   goto err1;
> > +   }
> > +
> > +   ret = enable_irq_wake(platform->pdata.hpd_irq);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "Enable irq for HPD");
> > +   DRM_DEV_ERROR(dev, "interrupt wake enable fail\n");
> > +   goto err1;
> > +   }
> > +   }
> > +
> > +   if (anx7625_register_i2c_dummy_clients(platform, client) != 0) {
> 
> Preserve the error code.
> 
>   ret = anx7625_register_i2c_dummy_clients();
>   if (ret)
>   goto free_platform;
> 

I meant goto free_wq here.  That's the most recent allocation.

regards,
dan carpenter

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


Re: [PATCH v2 1/2] dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe

2019-10-09 Thread Greg KH
On Wed, Oct 09, 2019 at 12:12:30PM +0200, Alexander Gordeev wrote:
> +static int setup_dma_descs(struct dma_desc *dma_descs,
> +struct avalon_dma_desc *desc)
> +{
> + struct scatterlist *sg_stop;
> + unsigned int sg_set;
> + int ret;
> +
> + ret = setup_descs_sg(dma_descs, 0,
> +  desc->direction,
> +  desc->dev_addr,
> +  desc->sg, desc->sg_len,
> +  desc->sg_curr, desc->sg_offset,
> +  _stop, _set);
> + BUG_ON(!ret);

Yeah, a driver can crash the kernel!

:(

Never do this, always recover properly, to not do so is "lazy"
programming.

If this is something that is impossible to ever happen, then never test
for it.  But if it can happen, then properly handle the error and move
on.

Same for the other uses of BUG_ON() and WARN_ON in here.  Remember many
systems run with "panic on warn" so if a user can trigger that, then the
machine reboots, which is not good.

thanks,

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


Re: [PATCH] staging: media: Fix alignment to match open parenthesis

2019-10-09 Thread Hans Verkuil
Hi Amol,

For future reference: always include the driver name in the subject.

I've added "imx: " to the subject for you, so no need to resend, but
the driver name is important information.

Regards,

Hans

On 9/11/19 6:56 PM, Amol Grover wrote:
> CHECK: Alignment should match open parenthesis
> 
> Signed-off-by: Amol Grover 
> ---
>  drivers/staging/media/imx/imx-media-csi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx-media-csi.c 
> b/drivers/staging/media/imx/imx-media-csi.c
> index 367e39f5b382..773b3d6964cf 100644
> --- a/drivers/staging/media/imx/imx-media-csi.c
> +++ b/drivers/staging/media/imx/imx-media-csi.c
> @@ -627,8 +627,8 @@ static int csi_idmac_start(struct csi_priv *priv)
>   }
>  
>   priv->nfb4eof_irq = ipu_idmac_channel_irq(priv->ipu,
> -  priv->idmac_ch,
> -  IPU_IRQ_NFB4EOF);
> +   priv->idmac_ch,
> +   IPU_IRQ_NFB4EOF);
>   ret = devm_request_irq(priv->dev, priv->nfb4eof_irq,
>  csi_idmac_nfb4eof_interrupt, 0,
>  "imx-smfc-nfb4eof", priv);
> @@ -1472,7 +1472,7 @@ static void csi_try_fmt(struct csi_priv *priv,
>   imx_media_enum_mbus_format(, 0,
>  CS_SEL_ANY, false);
>   *cc = imx_media_find_mbus_format(code,
> - CS_SEL_ANY, false);
> +  CS_SEL_ANY, false);
>   sdformat->format.code = (*cc)->codes[0];
>   }
>  
> 

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


[PATCH 3/3] staging: wfx: Make some functions static in sta.c

2019-10-09 Thread zhengbin
Fix sparse warnings:

drivers/staging/wfx/sta.c:269:6: warning: symbol 'wfx_update_filtering_work' 
was not declared. Should it be static?
drivers/staging/wfx/sta.c:475:6: warning: symbol 'wfx_event_handler_work' was 
not declared. Should it be static?
drivers/staging/wfx/sta.c:521:6: warning: symbol 'wfx_bss_loss_work' was not 
declared. Should it be static?
drivers/staging/wfx/sta.c:528:6: warning: symbol 'wfx_bss_params_work' was not 
declared. Should it be static?
drivers/staging/wfx/sta.c:539:6: warning: symbol 
'wfx_set_beacon_wakeup_period_work' was not declared. Should it be static?
drivers/staging/wfx/sta.c:732:6: warning: symbol 'wfx_unjoin_work' was not 
declared. Should it be static?
drivers/staging/wfx/sta.c:794:6: warning: symbol 'wfx_set_cts_work' was not 
declared. Should it be static?
drivers/staging/wfx/sta.c:1234:6: warning: symbol 'wfx_set_tim_work' was not 
declared. Should it be static?

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/staging/wfx/sta.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 2855d14..d19bab6 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -269,7 +269,7 @@ void wfx_update_filtering(struct wfx_vif *wvif)
kfree(bf_tbl);
 }

-void wfx_update_filtering_work(struct work_struct *work)
+static void wfx_update_filtering_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
update_filtering_work);

@@ -475,7 +475,7 @@ static void wfx_event_report_rssi(struct wfx_vif *wvif, 
uint8_t raw_rcpi_rssi)
ieee80211_cqm_rssi_notify(wvif->vif, cqm_evt, rcpi_rssi, GFP_KERNEL);
 }

-void wfx_event_handler_work(struct work_struct *work)
+static void wfx_event_handler_work(struct work_struct *work)
 {
struct wfx_vif *wvif =
container_of(work, struct wfx_vif, event_handler_work);
@@ -521,14 +521,14 @@ void wfx_event_handler_work(struct work_struct *work)
__wfx_free_event_queue();
 }

-void wfx_bss_loss_work(struct work_struct *work)
+static void wfx_bss_loss_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
bss_loss_work.work);

ieee80211_connection_loss(wvif->vif);
 }

-void wfx_bss_params_work(struct work_struct *work)
+static void wfx_bss_params_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
bss_params_work);

@@ -539,7 +539,7 @@ void wfx_bss_params_work(struct work_struct *work)
mutex_unlock(>wdev->conf_mutex);
 }

-void wfx_set_beacon_wakeup_period_work(struct work_struct *work)
+static void wfx_set_beacon_wakeup_period_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, 
set_beacon_wakeup_period_work);

@@ -732,7 +732,7 @@ static void wfx_do_join(struct wfx_vif *wvif)
cfg80211_put_bss(wvif->wdev->hw->wiphy, bss);
 }

-void wfx_unjoin_work(struct work_struct *work)
+static void wfx_unjoin_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, unjoin_work);

@@ -794,7 +794,7 @@ int wfx_sta_remove(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
return 0;
 }

-void wfx_set_cts_work(struct work_struct *work)
+static void wfx_set_cts_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_cts_work);
u8 erp_ie[3] = { WLAN_EID_ERP_INFO, 1, 0 };
@@ -1234,7 +1234,7 @@ static int wfx_set_tim_impl(struct wfx_vif *wvif, bool 
aid0_bit_set)
return 0;
 }

-void wfx_set_tim_work(struct work_struct *work)
+static void wfx_set_tim_work(struct work_struct *work)
 {
struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_tim_work);

--
2.7.4

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


[PATCH 2/3] staging: wfx: Make function 'wfx_tx_queue_get' static

2019-10-09 Thread zhengbin
Fix sparse warnings:

drivers/staging/wfx/queue.c:218:16: warning: symbol 'wfx_tx_queue_get' was not 
declared. Should it be static?

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/staging/wfx/queue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c
index 6f1be4f..4a860227 100644
--- a/drivers/staging/wfx/queue.c
+++ b/drivers/staging/wfx/queue.c
@@ -215,7 +215,8 @@ void wfx_tx_queue_put(struct wfx_dev *wdev, struct 
wfx_queue *queue, struct sk_b
spin_unlock_bh(>queue.lock);
 }

-struct sk_buff *wfx_tx_queue_get(struct wfx_dev *wdev, struct wfx_queue 
*queue, u32 link_id_map)
+static struct sk_buff *
+wfx_tx_queue_get(struct wfx_dev *wdev, struct wfx_queue *queue, u32 
link_id_map)
 {
struct sk_buff *skb = NULL;
struct sk_buff *item;
--
2.7.4

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


[PATCH 1/3] staging: wfx: Make function 'sram_write_dma_safe', 'load_firmware_secure' static

2019-10-09 Thread zhengbin
Fix sparse warnings:

drivers/staging/wfx/fwio.c:83:5: warning: symbol 'sram_write_dma_safe' was not 
declared. Should it be static?
drivers/staging/wfx/fwio.c:229:5: warning: symbol 'load_firmware_secure' was 
not declared. Should it be static?

Reported-by: Hulk Robot 
Signed-off-by: zhengbin 
---
 drivers/staging/wfx/fwio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c
index 8fb4a9f..39e1258 100644
--- a/drivers/staging/wfx/fwio.c
+++ b/drivers/staging/wfx/fwio.c
@@ -80,7 +80,8 @@ static const char * const fwio_error_strings[] = {
  * NOTE: it may also be possible to use 'pages' from struct firmware and avoid
  * bounce buffer
  */
-int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, size_t 
len)
+static int
+sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, size_t len)
 {
int ret;
const u8 *tmp;
@@ -226,7 +227,7 @@ static void print_boot_status(struct wfx_dev *wdev)
}
 }

-int load_firmware_secure(struct wfx_dev *wdev)
+static int load_firmware_secure(struct wfx_dev *wdev)
 {
const struct firmware *fw = NULL;
int header_size;
--
2.7.4

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


[PATCH 0/3] staging: wfx: Make some functions static

2019-10-09 Thread zhengbin
zhengbin (3):
  staging: wfx: Make function
'sram_write_dma_safe','load_firmware_secure' static
  staging: wfx: Make function 'wfx_tx_queue_get' static
  staging: wfx: Make some functions static in sta.c

 drivers/staging/wfx/fwio.c  |  5 +++--
 drivers/staging/wfx/queue.c |  3 ++-
 drivers/staging/wfx/sta.c   | 16 
 3 files changed, 13 insertions(+), 11 deletions(-)

--
2.7.4

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


[PATCH 4/5] staging: rtl8723bs: Remove rtw_merge_string() function

2019-10-09 Thread Hans de Goede
The phy_Config*WithParaFile() functions were the only user of this
function.

Signed-off-by: Hans de Goede 
---
 drivers/staging/rtl8723bs/include/osdep_service_linux.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h 
b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
index c582ede1ac12..a2d9de866c4b 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
@@ -127,13 +127,6 @@ static inline void rtw_netif_stop_queue(struct net_device 
*pnetdev)
netif_tx_stop_all_queues(pnetdev);
 }
 
-static inline void rtw_merge_string(char *dst, int dst_len, char *src1, char 
*src2)
-{
-   int len = 0;
-   len += snprintf(dst+len, dst_len - len, "%s", src1);
-   len += snprintf(dst+len, dst_len - len, "%s", src2);
-}
-
 #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1)
 
 #define rtw_netdev_priv(netdev) (((struct rtw_netdev_priv_indicator 
*)netdev_priv(netdev))->priv)
-- 
2.23.0

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


[PATCH 5/5] staging: rtl8723bs: Remove File operation APIs

2019-10-09 Thread Hans de Goede
rtl8723bs had 2 private file operation helpers:

rtw_is_file_readable()
rtw_retrive_from_file()

These were only used by the removed phy_Config*WithParaFile() functions,
so they can be removed now.

Signed-off-by: Hans de Goede 
---
 .../staging/rtl8723bs/include/osdep_service.h |   4 -
 .../staging/rtl8723bs/os_dep/osdep_service.c  | 136 --
 2 files changed, 140 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h 
b/drivers/staging/rtl8723bs/include/osdep_service.h
index 81a9c19ecc6a..a40cf7b60a69 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -171,10 +171,6 @@ extern void rtw_softap_lock_suspend(void);
 extern void rtw_softap_unlock_suspend(void);
 #endif
 
-/* File operation APIs, just for linux now */
-extern int rtw_is_file_readable(char *path);
-extern int rtw_retrive_from_file(char *path, u8 *buf, u32 sz);
-
 extern void rtw_free_netdev(struct net_device * netdev);
 
 
diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c 
b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
index 25a80041ce87..f5614e56371e 100644
--- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
@@ -65,142 +65,6 @@ void _rtw_init_queue(struct __queue *pqueue)
spin_lock_init(&(pqueue->lock));
 }
 
-/*
-* Open a file with the specific @param path, @param flag, @param mode
-* @param fpp the pointer of struct file pointer to get struct file pointer 
while file opening is success
-* @param path the path of the file to open
-* @param flag file operation flags, please refer to linux document
-* @param mode please refer to linux document
-* @return Linux specific error code
-*/
-static int openFile(struct file **fpp, char *path, int flag, int mode)
-{
-   struct file *fp;
-
-   fp = filp_open(path, flag, mode);
-   if (IS_ERR(fp)) {
-   *fpp = NULL;
-   return PTR_ERR(fp);
-   }
-   else {
-   *fpp = fp;
-   return 0;
-   }
-}
-
-/*
-* Close the file with the specific @param fp
-* @param fp the pointer of struct file to close
-* @return always 0
-*/
-static int closeFile(struct file *fp)
-{
-   filp_close(fp, NULL);
-   return 0;
-}
-
-static int readFile(struct file *fp, char *buf, int len)
-{
-   int rlen = 0, sum = 0;
-
-   if (!fp->f_op || !fp->f_op->read)
-   return -EPERM;
-
-   while (sum < len) {
-   rlen = kernel_read(fp, buf + sum, len - sum, >f_pos);
-   if (rlen > 0)
-   sum += rlen;
-   else if (0 != rlen)
-   return rlen;
-   else
-   break;
-   }
-
-   return sum;
-
-}
-
-/*
-* Test if the specifi @param path is a file and readable
-* @param path the path of the file to test
-* @return Linux specific error code
-*/
-static int isFileReadable(char *path)
-{
-   struct file *fp;
-   int ret = 0;
-   char buf;
-
-   fp = filp_open(path, O_RDONLY, 0);
-   if (IS_ERR(fp))
-   return PTR_ERR(fp);
-
-   if (readFile(fp, , 1) != 1)
-   ret = -EINVAL;
-
-   filp_close(fp, NULL);
-   return ret;
-}
-
-/*
-* Open the file with @param path and retrive the file content into memory 
starting from @param buf for @param sz at most
-* @param path the path of the file to open and read
-* @param buf the starting address of the buffer to store file content
-* @param sz how many bytes to read at most
-* @return the byte we've read, or Linux specific error code
-*/
-static int retriveFromFile(char *path, u8 *buf, u32 sz)
-{
-   int ret = -1;
-   struct file *fp;
-
-   if (path && buf) {
-   ret = openFile(, path, O_RDONLY, 0);
-
-   if (ret == 0) {
-   DBG_871X("%s openFile path:%s fp =%p\n", __func__, path 
, fp);
-
-   ret = readFile(fp, buf, sz);
-   closeFile(fp);
-
-   DBG_871X("%s readFile, ret:%d\n", __func__, ret);
-
-   } else {
-   DBG_871X("%s openFile path:%s Fail, ret:%d\n", 
__func__, path, ret);
-   }
-   } else {
-   DBG_871X("%s NULL pointer\n", __func__);
-   ret =  -EINVAL;
-   }
-   return ret;
-}
-
-/*
-* Test if the specifi @param path is a file and readable
-* @param path the path of the file to test
-* @return true or false
-*/
-int rtw_is_file_readable(char *path)
-{
-   if (isFileReadable(path) == 0)
-   return true;
-   else
-   return false;
-}
-
-/*
-* Open the file with @param path and retrive the file content into memory 
starting from @param buf for @param sz at most
-* @param path the path of the file to open and read
-* @param buf the starting address of the buffer to store file content
-* @param sz how many bytes to read at most

[PATCH 2/5] staging: rtl8723bs: Remove phy_Config*WithParaFile() functions

2019-10-09 Thread Hans de Goede
These are no longer used, so remove them and also remove various
struct definitions only used by these functions.

Signed-off-by: Hans de Goede 
---
 drivers/staging/rtl8723bs/hal/hal_com.c   |1 -
 .../staging/rtl8723bs/hal/hal_com_phycfg.c| 1076 -
 .../rtl8723bs/include/hal_com_phycfg.h|   26 -
 drivers/staging/rtl8723bs/include/hal_data.h  |   21 -
 4 files changed, 1124 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c 
b/drivers/staging/rtl8723bs/hal/hal_com.c
index eddd56abbb2d..109bd85b0cd8 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com.c
@@ -30,7 +30,6 @@ void rtw_hal_data_deinit(struct adapter *padapter)
 {
if (is_primary_adapter(padapter)) { /* if (padapter->isprimary) */
if (padapter->HalData) {
-   phy_free_filebuf(padapter);
vfree(padapter->HalData);
padapter->HalData = NULL;
padapter->hal_data_sz = 0;
diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c 
b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 6539bee9b5ba..eb7de3617d83 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -2202,1079 +2202,3 @@ void Hal_ChannelPlanToRegulation(struct adapter 
*Adapter, u16 ChannelPlan)
break;
}
 }
-
-
-static char file_path_bs[PATH_MAX];
-
-#define GetLineFromBuffer(buffer)   strsep(, "\n")
-
-int phy_ConfigMACWithParaFile(struct adapter *Adapter, char *pFileName)
-{
-   struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-   int rlen = 0, rtStatus = _FAIL;
-   char *szLine, *ptmp;
-   u32 u4bRegOffset, u4bRegValue, u4bMove;
-
-   if (!(Adapter->registrypriv.load_phy_file & LOAD_MAC_PARA_FILE))
-   return rtStatus;
-
-   memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN);
-
-   if ((pHalData->mac_reg_len == 0) && !pHalData->mac_reg) {
-   rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, 
pFileName);
-
-   if (rtw_is_file_readable(file_path_bs) == true) {
-   rlen = rtw_retrive_from_file(file_path_bs, 
pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
-   if (rlen > 0) {
-   rtStatus = _SUCCESS;
-   pHalData->mac_reg = vzalloc(rlen);
-   if (pHalData->mac_reg) {
-   memcpy(pHalData->mac_reg, 
pHalData->para_file_buf, rlen);
-   pHalData->mac_reg_len = rlen;
-   } else
-   DBG_871X("%s mac_reg alloc fail !\n", 
__func__);
-   }
-   }
-   } else {
-   if ((pHalData->mac_reg_len != 0) && (pHalData->mac_reg != 
NULL)) {
-   memcpy(pHalData->para_file_buf, pHalData->mac_reg, 
pHalData->mac_reg_len);
-   rtStatus = _SUCCESS;
-   } else
-   DBG_871X("%s(): Critical Error !!!\n", __func__);
-   }
-
-   if (rtStatus == _SUCCESS) {
-   ptmp = pHalData->para_file_buf;
-   for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = 
GetLineFromBuffer(ptmp)) {
-   if (!IsCommentString(szLine)) {
-   /*  Get 1st hex value as register offset */
-   if (GetHexValueFromString(szLine, 
, )) {
-   if (u4bRegOffset == 0x) /*  Ending. 
*/
-   break;
-
-   /*  Get 2nd hex value as register 
value. */
-   szLine += u4bMove;
-   if (GetHexValueFromString(szLine, 
, ))
-   rtw_write8(Adapter, 
u4bRegOffset, (u8)u4bRegValue);
-   }
-   }
-   }
-   } else
-   DBG_871X("%s(): No File %s, Load from HWImg Array!\n", 
__func__, pFileName);
-
-   return rtStatus;
-}
-
-int phy_ConfigBBWithParaFile(
-   struct adapter *Adapter, char *pFileName, u32 ConfigType
-)
-{
-   struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-   int rlen = 0, rtStatus = _FAIL;
-   char *szLine, *ptmp;
-   u32 u4bRegOffset, u4bRegValue, u4bMove;
-   char *pBuf = NULL;
-   u32 *pBufLen = NULL;
-
-   if (!(Adapter->registrypriv.load_phy_file & LOAD_BB_PARA_FILE))
-   return rtStatus;
-
-   switch (ConfigType) {
-   case CONFIG_BB_PHY_REG:
-   pBuf = pHalData->bb_phy_reg;
-   pBufLen = >bb_phy_reg_len;
-   break;
-   case CONFIG_BB_AGC_TAB:
-   

[PATCH 1/5] staging: rtl8723bs: Remove phy_Config*With*ParaFile() calls

2019-10-09 Thread Hans de Goede
The rtl8723bs driver tries to load various parameters from disk,
circumventing the standard firmware loader mechanism and using DIY
code for this.

No devices which run the mainline kernel ship with these files and even
if these files were present then they still would not be loaded without
additional module parameters. To be precise the following 3 conditions
must all 3 be true for on disk parameters to be used:

1) The rtw_load_phy_file modparam must contain the mask for the type, this
   defaults to(LOAD_BB_PG_PARA_FILE | LOAD_RF_TXPWR_LMT_PARA_FILE) so with
   the default settings this condition is only true for:
   phy_ConfigBBWithPgParaFile()
   PHY_ConfigRFWithPowerLimitTableParaFile(); and
2) rtw_phy_file_path modparam must be set to say "/lib/firmware/"; and
3) Store a /lib/firmware/rtl8723b/XXX file in the expected format.

In practice all 3 being true never happens, so the
phy_Config*With*ParaFile() calls are nops, remove them.

The actual code implementing them will be removed in a separate patch.

Note the ODM_ConfigRFWithHeaderFile() and ODM_ConfigBBWithHeaderFile()
functions always return HAL_STATUS_SUCCESS, this patch makes use of this
to simplify the new code without the phy_Config*With*ParaFile() calls.

Signed-off-by: Hans de Goede 
---
 .../staging/rtl8723bs/hal/rtl8723b_phycfg.c   | 77 +++
 .../staging/rtl8723bs/hal/rtl8723b_rf6052.c   | 41 +-
 2 files changed, 13 insertions(+), 105 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c 
b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
index 6df2b58bdc67..cf23414d7224 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
@@ -362,24 +362,10 @@ void PHY_SetRFReg_8723B(
  */
 s32 PHY_MACConfig8723B(struct adapter *Adapter)
 {
-   int rtStatus = _SUCCESS;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-   s8 *pszMACRegFile;
-   s8 sz8723MACRegFile[] = RTL8723B_PHY_MACREG;
-
-
-   pszMACRegFile = sz8723MACRegFile;
-
-   /*  */
-   /*  Config MAC */
-   /*  */
-   rtStatus = phy_ConfigMACWithParaFile(Adapter, pszMACRegFile);
-   if (rtStatus == _FAIL) {
-   ODM_ReadAndConfig_MP_8723B_MAC_REG(>odmpriv);
-   rtStatus = _SUCCESS;
-   }
 
-   return rtStatus;
+   ODM_ReadAndConfig_MP_8723B_MAC_REG(>odmpriv);
+   return _SUCCESS;
 }
 
 /**
@@ -427,17 +413,6 @@ static void phy_InitBBRFRegisterDefinition(struct adapter 
*Adapter)
 static int phy_BB8723b_Config_ParaFile(struct adapter *Adapter)
 {
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-   int rtStatus = _SUCCESS;
-   u8 sz8723BBRegFile[] = RTL8723B_PHY_REG;
-   u8 sz8723AGCTableFile[] = RTL8723B_AGC_TAB;
-   u8 sz8723BBBRegPgFile[] = RTL8723B_PHY_REG_PG;
-   u8 sz8723BRFTxPwrLmtFile[] = RTL8723B_TXPWR_LMT;
-   u8 *pszBBRegFile = NULL, *pszAGCTableFile = NULL, *pszBBRegPgFile = 
NULL, *pszRFTxPwrLmtFile = NULL;
-
-   pszBBRegFile = sz8723BBRegFile;
-   pszAGCTableFile = sz8723AGCTableFile;
-   pszBBRegPgFile = sz8723BBBRegPgFile;
-   pszRFTxPwrLmtFile = sz8723BRFTxPwrLmtFile;
 
/*  Read Tx Power Limit File */
PHY_InitTxPowerLimit(Adapter);
@@ -445,30 +420,14 @@ static int phy_BB8723b_Config_ParaFile(struct adapter 
*Adapter)
Adapter->registrypriv.RegEnableTxPowerLimit == 1 ||
(Adapter->registrypriv.RegEnableTxPowerLimit == 2 && 
pHalData->EEPROMRegulatory == 1)
) {
-   if (PHY_ConfigRFWithPowerLimitTableParaFile(Adapter, 
pszRFTxPwrLmtFile) == _FAIL) {
-   if (HAL_STATUS_SUCCESS != 
ODM_ConfigRFWithHeaderFile(>odmpriv, CONFIG_RF_TXPWR_LMT, 
(ODM_RF_RADIO_PATH_E)0))
-   rtStatus = _FAIL;
-   }
-
-   if (rtStatus != _SUCCESS) {
-   DBG_871X("%s():Read Tx power limit fail\n", __func__);
-   goto phy_BB8190_Config_ParaFile_Fail;
-   }
+   ODM_ConfigRFWithHeaderFile(>odmpriv,
+  CONFIG_RF_TXPWR_LMT, 0);
}
 
/*  */
/*  1. Read PHY_REG.TXT BB INIT!! */
/*  */
-   if (phy_ConfigBBWithParaFile(Adapter, pszBBRegFile, CONFIG_BB_PHY_REG) 
==
-   _FAIL) {
-   if (HAL_STATUS_SUCCESS != 
ODM_ConfigBBWithHeaderFile(>odmpriv, CONFIG_BB_PHY_REG))
-   rtStatus = _FAIL;
-   }
-
-   if (rtStatus != _SUCCESS) {
-   DBG_8192C("%s():Write BB Reg Fail!!", __func__);
-   goto phy_BB8190_Config_ParaFile_Fail;
-   }
+   ODM_ConfigBBWithHeaderFile(>odmpriv, CONFIG_BB_PHY_REG);
 
/*  If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */
PHY_InitTxPowerByRate(Adapter);
@@ -476,11 +435,8 @@ static int phy_BB8723b_Config_ParaFile(struct adapter 
*Adapter)

[PATCH 3/5] staging: rtl8723bs: Remove phy_Config*WithParaFile() configuration leftovers

2019-10-09 Thread Hans de Goede
Now that the phy_Config*WithParaFile() functions have been removed nothing
is using these module-parameters and defines anymore.

Signed-off-by: Hans de Goede 
---
 drivers/staging/rtl8723bs/include/drv_types.h |  4 
 .../staging/rtl8723bs/include/rtl8723b_hal.h  | 15 --
 drivers/staging/rtl8723bs/os_dep/os_intfs.c   | 20 ---
 3 files changed, 39 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/drv_types.h 
b/drivers/staging/rtl8723bs/include/drv_types.h
index 8d7fce1e39b7..6ec9087f2eb1 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -197,9 +197,6 @@ struct registry_priv
u8 RFE_Type;
u8  check_fw_ps;
 
-   u8 load_phy_file;
-   u8 RegDecryptCustomFile;
-
 #ifdef CONFIG_MULTI_VIR_IFACES
u8 ext_iface_num;/* primary/secondary iface is excluded */
 #endif
@@ -693,7 +690,6 @@ void rtw_indicate_wx_disassoc_event(struct adapter 
*padapter);
 void indicate_wx_scan_complete_event(struct adapter *padapter);
 int rtw_change_ifname(struct adapter *padapter, const char *ifname);
 
-extern char *rtw_phy_file_path;
 extern char *rtw_initmac;
 extern int rtw_mc2u_disable;
 extern int rtw_ht_enable;
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h 
b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
index 8f00ced1c697..f36516fa84c7 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
@@ -20,21 +20,6 @@
 #include "hal_phy_reg_8723b.h"
 #include "hal_phy_cfg.h"
 
-/*  */
-/* RTL8723B From file */
-/*  */
-#define RTL8723B_FW_IMG  "rtl8723b/FW_NIC.bin"
-#define RTL8723B_FW_WW_IMG   "rtl8723b/FW_WoWLAN.bin"
-#define RTL8723B_PHY_REG "rtl8723b/PHY_REG.txt"
-#define RTL8723B_PHY_RADIO_A "rtl8723b/RadioA.txt"
-#define RTL8723B_PHY_RADIO_B "rtl8723b/RadioB.txt"
-#define RTL8723B_TXPWR_TRACK "rtl8723b/TxPowerTrack.txt"
-#define RTL8723B_AGC_TAB "rtl8723b/AGC_TAB.txt"
-#define RTL8723B_PHY_MACREG  "rtl8723b/MAC_REG.txt"
-#define RTL8723B_PHY_REG_PG  "rtl8723b/PHY_REG_PG.txt"
-#define RTL8723B_PHY_REG_MP  "rtl8723b/PHY_REG_MP.txt"
-#define RTL8723B_TXPWR_LMT   "rtl8723b/TXPWR_LMT.txt"
-
 /*  */
 /* RTL8723B From header */
 /*  */
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c 
b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 5044f7373b8b..cb4c86728d26 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -201,24 +201,6 @@ MODULE_PARM_DESC(rtw_tx_pwr_lmt_enable, "0:Disable, 
1:Enable, 2: Depend on efuse
 module_param(rtw_tx_pwr_by_rate, int, 0644);
 MODULE_PARM_DESC(rtw_tx_pwr_by_rate, "0:Disable, 1:Enable, 2: Depend on 
efuse");
 
-char *rtw_phy_file_path = "";
-module_param(rtw_phy_file_path, charp, 0644);
-MODULE_PARM_DESC(rtw_phy_file_path, "The path of phy parameter");
-/*  PHY FILE Bit Map */
-/*  BIT0 - MAC,0: non-support, 1: support */
-/*  BIT1 - BB, 0: non-support, 1: support */
-/*  BIT2 - BB_PG,  0: non-support, 1: support */
-/*  BIT3 - BB_MP,  0: non-support, 1: support */
-/*  BIT4 - RF, 0: non-support, 1: support */
-/*  BIT5 - RF_TXPWR_TRACK, 0: non-support, 1: support */
-/*  BIT6 - RF_TXPWR_LMT,   0: non-support, 1: support */
-static int rtw_load_phy_file = (BIT2 | BIT6);
-module_param(rtw_load_phy_file, int, 0644);
-MODULE_PARM_DESC(rtw_load_phy_file, "PHY File Bit Map");
-static int rtw_decrypt_phy_file;
-module_param(rtw_decrypt_phy_file, int, 0644);
-MODULE_PARM_DESC(rtw_decrypt_phy_file, "Enable Decrypt PHY File");
-
 int _netdev_open(struct net_device *pnetdev);
 int netdev_open (struct net_device *pnetdev);
 static int netdev_close (struct net_device *pnetdev);
@@ -321,8 +303,6 @@ static void loadparam(struct adapter *padapter, _nic_hdl 
pnetdev)
registry_par->bEn_RFE = 1;
registry_par->RFE_Type = 64;
 
-   registry_par->load_phy_file = (u8)rtw_load_phy_file;
-   registry_par->RegDecryptCustomFile = (u8)rtw_decrypt_phy_file;
registry_par->qos_opt_enable = (u8)rtw_qos_opt_enable;
 
registry_par->hiq_filter = (u8)rtw_hiq_filter;
-- 
2.23.0

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


Re: [PATCH v2 1/2] dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe

2019-10-09 Thread Dan Carpenter
On Wed, Oct 09, 2019 at 12:12:30PM +0200, Alexander Gordeev wrote:
> Support Avalon-MM DMA Interface for PCIe used in hard IPs for
> Intel Arria, Cyclone or Stratix FPGAs.
> 
> CC: Michael Chen 
> CC: de...@driverdev.osuosl.org
> CC: dmaeng...@vger.kernel.org
> 
> Signed-off-by: Alexander Gordeev 
> ---
>  drivers/dma/Kconfig  |   2 +
>  drivers/dma/Makefile |   1 +
>  drivers/dma/avalon/Kconfig   |  88 +++
>  drivers/dma/avalon/Makefile  |   6 +
>  drivers/dma/avalon/avalon-core.c | 432 +++
>  drivers/dma/avalon/avalon-core.h |  90 +++
>  drivers/dma/avalon/avalon-hw.c   | 212 +++
>  drivers/dma/avalon/avalon-hw.h   |  86 ++
>  drivers/dma/avalon/avalon-pci.c  | 150 +++
>  9 files changed, 1067 insertions(+)
>  create mode 100644 drivers/dma/avalon/Kconfig
>  create mode 100644 drivers/dma/avalon/Makefile
>  create mode 100644 drivers/dma/avalon/avalon-core.c
>  create mode 100644 drivers/dma/avalon/avalon-core.h
>  create mode 100644 drivers/dma/avalon/avalon-hw.c
>  create mode 100644 drivers/dma/avalon/avalon-hw.h
>  create mode 100644 drivers/dma/avalon/avalon-pci.c
> 
> diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
> index 7af874b69ffb..f6f43480a4a4 100644
> --- a/drivers/dma/Kconfig
> +++ b/drivers/dma/Kconfig
> @@ -669,6 +669,8 @@ source "drivers/dma/sh/Kconfig"
>  
>  source "drivers/dma/ti/Kconfig"
>  
> +source "drivers/dma/avalon/Kconfig"
> +
>  # clients
>  comment "DMA Clients"
>   depends on DMA_ENGINE
> diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
> index f5ce8665e944..fd7e11417b73 100644
> --- a/drivers/dma/Makefile
> +++ b/drivers/dma/Makefile
> @@ -75,6 +75,7 @@ obj-$(CONFIG_UNIPHIER_MDMAC) += uniphier-mdmac.o
>  obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
>  obj-$(CONFIG_ZX_DMA) += zx_dma.o
>  obj-$(CONFIG_ST_FDMA) += st_fdma.o
> +obj-$(CONFIG_AVALON_DMA) += avalon/
>  
>  obj-y += mediatek/
>  obj-y += qcom/
> diff --git a/drivers/dma/avalon/Kconfig b/drivers/dma/avalon/Kconfig
> new file mode 100644
> index ..09e0773fcdb2
> --- /dev/null
> +++ b/drivers/dma/avalon/Kconfig
> @@ -0,0 +1,88 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Avalon DMA engine
> +#
> +# Author: Alexander Gordeev 
> +#
> +config AVALON_DMA
> + tristate "Intel Avalon-MM DMA Interface for PCIe"
> + depends on PCI
> + select DMA_ENGINE
> + select DMA_VIRTUAL_CHANNELS
> + help
> +   This selects a driver for Avalon-MM DMA Interface for PCIe
> +   hard IP block used in Intel Arria, Cyclone or Stratix FPGAs.
> +
> +if AVALON_DMA
> +
> +config AVALON_DMA_MASK_WIDTH
> + int "Avalon DMA streaming and coherent bitmask width"
> + range 0 64
> + default 64
> + help
> +   Width of bitmask for streaming and coherent DMA operations
> +
> +config AVALON_DMA_CTRL_BASE
> + hex "Avalon DMA controllers base"
> + default "0x"
> +
> +config AVALON_DMA_RD_EP_DST_LO
> + hex "Avalon DMA read controller base low"
> + default "0x8000"
> + help
> +   Specifies the lower 32-bits of the base address of the read
> +   status and descriptor table in the Root Complex memory.
> +
> +config AVALON_DMA_RD_EP_DST_HI
> + hex "Avalon DMA read controller base high"
> + default "0x"
> + help
> +   Specifies the upper 32-bits of the base address of the read
> +   status and descriptor table in the Root Complex memory.
> +
> +config AVALON_DMA_WR_EP_DST_LO
> + hex "Avalon DMA write controller base low"
> + default "0x80002000"
> + help
> +   Specifies the lower 32-bits of the base address of the write
> +   status and descriptor table in the Root Complex memory.
> +
> +config AVALON_DMA_WR_EP_DST_HI
> + hex "Avalon DMA write controller base high"
> + default "0x"
> + help
> +   Specifies the upper 32-bits of the base address of the write
> +   status and descriptor table in the Root Complex memory.
> +
> +config AVALON_DMA_PCI_VENDOR_ID
> + hex "PCI vendor ID"
> + default "0x1172"
> +
> +config AVALON_DMA_PCI_DEVICE_ID
> + hex "PCI device ID"
> + default "0xe003"

This feels wrong.  Why isn't it known in advance.

> +
> +config AVALON_DMA_PCI_BAR
> + int "PCI device BAR the Avalon DMA controller is mapped to"
> + range 0 5
> + default 0
> + help
> +   Number of PCI BAR the DMA controller is mapped to
> +
> +config AVALON_DMA_PCI_MSI_COUNT_ORDER
> + int "Count of MSIs the PCI device provides (order)"
> + range 0 5
> + default 5
> + help
> +   Number of vectors the PCI device uses in multiple MSI mode.
> +   This number is provided as the power of two.
> +
> +config AVALON_DMA_PCI_MSI_VECTOR
> + int "Vector number the DMA controller is mapped to"
> + range 0 31
> + default 0
> + help
> +   Number of MSI vector the DMA controller is mapped to in
> +   multiple MSI mode.
> +
> +endif
> 

Re: [PATCH v2 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding

2019-10-09 Thread Laurent Pinchart
Hi Xin Ji,

Thank you for the patch.

On Wed, Oct 09, 2019 at 09:27:07AM +, Xin Ji wrote:
> The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> for portable device. It converts MIPI to DisplayPort 1.3 4K.
> 
> You can add support to your board with binding.
> 
> Example:
>   anx_bridge: anx7625@58 {
>   compatible = "analogix,anx7625";
>   reg = <0x58>;
>   enable-gpios = < 45 GPIO_ACTIVE_LOW>;
>   reset-gpios = < 73 GPIO_ACTIVE_LOW>;
>   status = "okay";
>   port@0 {
>   reg = <0>;
>   anx7625_1_in: endpoint {
>   remote-endpoint = <_dsi_bridge_1>;
>   };
>   };
>   };
> 
> Signed-off-by: Xin Ji 
> ---
>  .../bindings/display/bridge/anx7625.yaml   | 79 
> ++
>  1 file changed, 79 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> 
> diff --git a/Documentation/devicetree/bindings/display/bridge/anx7625.yaml 
> b/Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> new file mode 100644
> index 000..0ef6271
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> @@ -0,0 +1,79 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +# Copyright 2019 Analogix Semiconductor, Inc.
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/display/bridge/anx7625.yaml#;
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#;
> +
> +title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
> +
> +maintainers:
> +  - Xin Ji 
> +
> +description: |
> +  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
> +  designed for portable devices.
> +
> +properties:
> +  compatible:
> +items:
> +  - const: analogix,anx7625
> +
> +  reg:
> +maxItems: 1
> +
> +  hpd-gpios:
> +description: used for HPD interrupt
> +maxItems: 1

You explained in your reply to v1 review that this describes the
interrupt generated by the ANX7625. It should be replaced by an
interrupts property.

> +
> +  enable-gpios:
> +description: used for power on chip control
> +maxItems: 1
> +
> +  reset-gpios:
> +description: used for reset chip control
> +maxItems: 1

Could you please mention the exact name of the corresponding pins on the
chip for enable and reset ?

> +
> +  port@0:
> +type: object
> +description:
> +  A port node pointing to MIPI DSI host port node.
> +
> +  port@1:
> +type: object
> +description:
> +  A port node pointing to MIPI DPI host port node.
> +
> +  port@2:
> +type: object
> +description:
> +  A port node pointing to external connector port node.
> +
> +  port@3:
> +type: object
> +description:
> +  A port node pointing to internal panel port node.
> +
> +  port@4:
> +type: object
> +description:
> +  A port node pointing to normal eDP port node.

I don't think three output ports is correct. Ports 3 and 4 are really
the same. I'm even unsure about port 2 and 3, someone with better
knowledge of USB-C and DisplayPort would be in a better position to
comment.

> +

You're missing the #address-cells and #size-cells properties required
for the ports. As the device is an I2C device we're lucky that the
parent will specify compatible address and size cells numbers, but I'm
not sure we should rely on that luck.

Rob, how does yaml schema handle this ?

> +required:
> +  - compatible
> +  - reg
> +  - port@0 | port@1
> +
> +example:
> +  - |
> +anx_bridge: anx7625@58 {

The node name should describe the device's function. How about
encoder@58 ?

> +compatible = "analogix,anx7625";
> +reg = <0x58>;
> +status = "okay";
> +port@0 {
> +  reg = <0>;
> +  anx7625_1_in: endpoint {
> +remote-endpoint = <_dsi_bridge_1>;
> +  };
> +};
> +};

-- 
Regards,

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


Re: [PATCH v2 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2019-10-09 Thread Dan Carpenter
Are you sure you sent the correct patch?  This has many of the same
style issues I mentioned in the previous email.  The error handling
in edid_read() is wrong.  probe() will still crash if allocating the
work queue fails.

On Wed, Oct 09, 2019 at 09:28:02AM +, Xin Ji wrote:
> The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.
> 
> The ANX7625 can support both USB Type-C PD feature and MIPI DSI/DPI
> to DP feature. This driver only enabled MIPI DSI/DPI to DP feature.
> 
> Signed-off-by: Xin Ji 
> ---
>  drivers/gpu/drm/bridge/Makefile   |2 +-
>  drivers/gpu/drm/bridge/analogix/Kconfig   |6 +
>  drivers/gpu/drm/bridge/analogix/Makefile  |1 +
>  drivers/gpu/drm/bridge/analogix/anx7625.c | 2132 
> +
>  drivers/gpu/drm/bridge/analogix/anx7625.h |  405 ++
>  5 files changed, 2545 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
>  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h
> 
> diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
> index 4934fcf..bcd388a 100644
> --- a/drivers/gpu/drm/bridge/Makefile
> +++ b/drivers/gpu/drm/bridge/Makefile
> @@ -12,8 +12,8 @@ obj-$(CONFIG_DRM_SII9234) += sii9234.o
>  obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
>  obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
>  obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o
> -obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/
>  obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
>  obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o
>  obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o
> +obj-y += analogix/
>  obj-y += synopsys/
> diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
> b/drivers/gpu/drm/bridge/analogix/Kconfig
> index e930ff9..b2f127e 100644
> --- a/drivers/gpu/drm/bridge/analogix/Kconfig
> +++ b/drivers/gpu/drm/bridge/analogix/Kconfig
> @@ -2,3 +2,9 @@
>  config DRM_ANALOGIX_DP
>   tristate
>   depends on DRM
> +
> +config ANALOGIX_ANX7625
> + tristate "Analogix MIPI to DP interface support"
> + help
> + ANX7625 is an ultra-low power 4K mobile HD transmitter designed
> + for portable devices. It converts MIPI/DPI to DisplayPort1.3 4K.
> diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
> b/drivers/gpu/drm/bridge/analogix/Makefile
> index fdbf3fd..8a52867 100644
> --- a/drivers/gpu/drm/bridge/analogix/Makefile
> +++ b/drivers/gpu/drm/bridge/analogix/Makefile
> @@ -1,3 +1,4 @@
>  # SPDX-License-Identifier: GPL-2.0-only
> +obj-$(CONFIG_ANALOGIX_ANX7625) += anx7625.o
>  analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o
>  obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> b/drivers/gpu/drm/bridge/analogix/anx7625.c
> new file mode 100644
> index 000..7bb4e17
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -0,0 +1,2132 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright(c) 2016, Analogix Semiconductor. All rights reserved.
> + *
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include "anx7625.h"
> +
> +/*
> + * there is a sync issue while access I2C register between AP(CPU) and
> + * internal firmware(OCM), to avoid the race condition, AP should access
> + * the reserved slave address before slave address occurs changes.
> + */
> +static int i2c_access_workaround(struct anx7625_data *ctx,
> +  struct i2c_client *client)
> +{
> + u8 offset;
> + struct device *dev = >dev;
> + struct i2c_client *last_client = ctx->last_client;
> + int ret = 0;
> +
> + if (client != last_client) {


Please reverse this condition.

if (client == ctx->last_client)
return 0;

Get rid of the last_client variable.


> + ctx->last_client = client;
> +
> + if (client == ctx->i2c.tcpc_client)
> + offset = RSVD_00_ADDR;
> + else if (client == ctx->i2c.tx_p0_client)
> + offset = RSVD_D1_ADDR;
> + else if (client == ctx->i2c.tx_p1_client)
> + offset = RSVD_60_ADDR;
> + else if (client == ctx->i2c.rx_p0_client)
> + offset = RSVD_39_ADDR;
> + else if (client == ctx->i2c.rx_p1_client)
> + offset = RSVD_7F_ADDR;
> + else
> + offset = RSVD_00_ADDR;
> +
> + ret = i2c_smbus_write_byte_data(client, offset, 0x00);
> + if (ret < 0)
> + DRM_DEV_ERROR(dev,
> +   

Re: [Outreachy kernel] [PATCH] staging: rtl8712: Add comment to lock declaration

2019-10-09 Thread Jules Irenge




On Mon, 7 Oct 2019, Julia Lawall wrote:




On Mon, 7 Oct 2019, Jules Irenge wrote:


Add comment to spinlock declaration to fix warning issued by checkpatch.pl
"CHECK: spinlock_t definition without comment".


Since it is not apparent from the shown code, it would be helpful to
describe what evidence you used to choose this comment.

thanks,
julia



Thanks for your feedback, I will leave as it is following the advice of 
one of the maintainer. I thought a general term of protecting interrupt 
might be appropriate.


Kind regards
Jules



Signed-off-by: Jules Irenge 
---
 drivers/staging/rtl8712/drv_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/drv_types.h 
b/drivers/staging/rtl8712/drv_types.h
index 0c4325073c63..960d8709aada 100644
--- a/drivers/staging/rtl8712/drv_types.h
+++ b/drivers/staging/rtl8712/drv_types.h
@@ -160,7 +160,7 @@ struct _adapter {
int pid; /*process id from UI*/
struct work_struct wk_filter_rx_ff0;
u8 blnEnableRxFF0Filter;
-   spinlock_t lock_rx_ff0_filter;
+   spinlock_t lock_rx_ff0_filter; /*spinlock to protect interrupt request*/
const struct firmware *fw;
struct usb_interface *pusb_intf;
struct mutex mutex_start;
--
2.21.0

--
You received this message because you are subscribed to the Google Groups 
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to outreachy-kernel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/outreachy-kernel/20191007205248.24466-1-jbi.octave%40gmail.com.



--
You received this message because you are subscribed to the Google Groups 
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to outreachy-kernel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1910072254290.2578%40hadrien.


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


Re: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls

2019-10-09 Thread Denis Efremov
Hi,

On 09.10.2019 12:35, Hans de Goede wrote:
> Hi Denis,
> 
> On 30-09-2019 13:01, Denis Efremov wrote:
>> memcpy() in phy_ConfigBBWithParaFile() and PHY_ConfigRFWithParaFile() is
>> called with "src == NULL && len == 0". This is an undefined behavior.
>> Moreover this if pre-condition "pBufLen && (*pBufLen == 0) && !pBuf"
>> is constantly false because it is a nested if in the else brach, i.e.,
>> "if (cond) { ... } else { if (cond) {...} }". This patch alters the
>> if condition to check "pBufLen && pBuf" pointers are not NULL.
>>
>> Cc: Greg Kroah-Hartman 
>> Cc: Hans de Goede 
>> Cc: Bastien Nocera 
>> Cc: Larry Finger 
>> Cc: Jes Sorensen 
>> Cc: sta...@vger.kernel.org
>> Signed-off-by: Denis Efremov 
>> ---
>> Not tested. I don't have the hardware. The fix is based on my guess.
> 
> Thsnk you for your patch.
> 
> So I've been doing some digging and this code normally never executes.
> 
> For this to execute the user would need to change the rtw_load_phy_file module
> param from its default of 0x44 (LOAD_BB_PG_PARA_FILE | 
> LOAD_RF_TXPWR_LMT_PARA_FILE)
> to something which includes 0x02 (LOAD_BB_PARA_FILE) as mask.
> 
> And even with that param set for this code to actually do something /
> for pBuf to ever not be NULL the following conditions would have to
> be true:
> 
> 1) Set the rtw_load_phy_file module param from its default of
>    0x44 (LOAD_BB_PG_PARA_FILE | LOAD_RF_TXPWR_LMT_PARA_FILE) to something
>    which includes 0x02 as mask; and
> 2) Set rtw_phy_file_path module parameter to say "/lib/firmware/"; and
> 3) Store a /lib/firmware/rtl8723b/PHY_REG.txt file in the expected format.
> 
> So I've come to the conclusion that all the phy_Config*WithParaFile functions
> (and a bunch of stuff they use) can be removed.
> 
> I will prepare and submit a patch for this.
> 

Thank you for perfect investigation! I can only agree with you, because this
code is buggy. It looks like no one faced this bug previously and the code
can be safely removed.

Best Regards,
Denis

> 
>>
>>   drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c 
>> b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
>> index 6539bee9b5ba..0902dc3c1825 100644
>> --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
>> +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
>> @@ -2320,7 +2320,7 @@ int phy_ConfigBBWithParaFile(
>>   }
>>   }
>>   } else {
>> -    if (pBufLen && (*pBufLen == 0) && !pBuf) {
>> +    if (pBufLen && pBuf) {
>>   memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
>>   rtStatus = _SUCCESS;
>>   } else
>> @@ -2752,7 +2752,7 @@ int PHY_ConfigRFWithParaFile(
>>   }
>>   }
>>   } else {
>> -    if (pBufLen && (*pBufLen == 0) && !pBuf) {
>> +    if (pBufLen && pBuf) {
>>   memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
>>   rtStatus = _SUCCESS;
>>   } else
>>
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] binder: prevent UAF read in print_binder_transaction_log_entry()

2019-10-09 Thread Christian Brauner
On Tue, Oct 08, 2019 at 02:05:16PM -0400, Joel Fernandes wrote:
> On Tue, Oct 08, 2019 at 03:01:59PM +0200, Christian Brauner wrote:
> > When a binder transaction is initiated on a binder device coming from a
> > binderfs instance, a pointer to the name of the binder device is stashed
> > in the binder_transaction_log_entry's context_name member. Later on it
> > is used to print the name in print_binder_transaction_log_entry(). By
> > the time print_binder_transaction_log_entry() accesses context_name
> > binderfs_evict_inode() might have already freed the associated memory
> > thereby causing a UAF. Do the simple thing and prevent this by copying
> > the name of the binder device instead of stashing a pointer to it.
> > 
> > Reported-by: Jann Horn 
> > Fixes: 03e2e07e3814 ("binder: Make transaction_log available in binderfs")
> > Link: 
> > https://lore.kernel.org/r/cag48ez14q0-f8lqsvcnbyr2o6gpw8shxsm4u5jmd9mpstem...@mail.gmail.com
> > Cc: Joel Fernandes 
> > Cc: Todd Kjos 
> > Cc: Hridya Valsaraju 
> > Signed-off-by: Christian Brauner 
> > ---
> >  drivers/android/binder.c  | 4 +++-
> >  drivers/android/binder_internal.h | 2 +-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> > index c0a491277aca..5b9ac2122e89 100644
> > --- a/drivers/android/binder.c
> > +++ b/drivers/android/binder.c
> > @@ -57,6 +57,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -66,6 +67,7 @@
> >  #include 
> >  
> >  #include 
> > +#include 
> >  
> >  #include 
> >  
> > @@ -2876,7 +2878,7 @@ static void binder_transaction(struct binder_proc 
> > *proc,
> > e->target_handle = tr->target.handle;
> > e->data_size = tr->data_size;
> > e->offsets_size = tr->offsets_size;
> > -   e->context_name = proc->context->name;
> > +   strscpy(e->context_name, proc->context->name, BINDERFS_MAX_NAME);
> 
> Strictly speaking, proc-context->name can also be initialized for !BINDERFS
> so the BINDERFS in the MAX_NAME macro is misleading. So probably there should
> be a BINDER_MAX_NAME (and associated checks for whether non BINDERFS names
> fit within the MAX.

I know but I don't think it's worth special-casing non-binderfs devices.
First, non-binderfs devices can only be created through a KCONFIG option
determined at compile time. For stock Android the names are the same for
all vendors afaik.
Second, BINDERFS_MAX_NAME is set to the maximum path name component
length that nearly all filesystems support (256 chars). If you exceed
that then you run afoul of a bunch of other assumptions already and will
cause trouble.
Third, even if there is someone crazy and uses more than 256 chars for a
non-binderfs device at KCONFIG time strscpy will do the right thing and
truncate and you'd see a truncated binder device name. This doesn't seem
to be a big deal for a debugfs interface.
Fourth, the check for non-binderfs devices technically has nothing to do
with this patch. This patch should really just do the minimal thing and
fix the UAF. Which it does.
Fifth, I already tried to push for validation of non-binderfs binder
devices a while back when I wrote binderfs and was told that it's not
needed. Hrydia tried the same and we decided the same thing. So you get
to be the next person to send a patch. :)

> 
> > if (reply) {
> 
> > binder_inner_proc_lock(proc);
> > diff --git a/drivers/android/binder_internal.h 
> > b/drivers/android/binder_internal.h
> > index bd47f7f72075..ae991097d14d 100644
> > --- a/drivers/android/binder_internal.h
> > +++ b/drivers/android/binder_internal.h
> > @@ -130,7 +130,7 @@ struct binder_transaction_log_entry {
> > int return_error_line;
> > uint32_t return_error;
> > uint32_t return_error_param;
> > -   const char *context_name;
> > +   char context_name[BINDERFS_MAX_NAME + 1];
> 
> Same comment here, context_name can be used for non-BINDERFS transactions as
> well such as default binder devices.

See above.

> 
> One more thought, this can be made dependent on CONFIG_BINDERFS since regular
> binder devices cannot be unregistered AFAICS and as Jann said, the problem is
> BINDERFS specific. That way we avoid the memcpy for _every_ transaction.
> These can be thundering when Android starts up.

Unless Todd sees this as a real performance problem I'm weary to
introduce additional checking and record a pointer for non-binderfs and
a memcpy() for binderfs devices. :)

> 
> (I secretly wish C strings could be refcounted to avoid exactly this issue,
> that should not be hard to develop but I am not sure if it is worth it for
> this problem :) - For one, it will avoid having to do the strcpy for _every_
> transaction).
> 
> Other than these nits, please add my tag on whichever is the final solution:
> 
> Reviewed-by: Joel Fernandes (Google) 

Thanks for the review, Joel. :)
Christian
___
devel mailing 

[staging:staging-testing 57/111] drivers/staging/wfx/scan.c:207 wfx_scan_work() warn: inconsistent returns 'sem:>scan.lock'.

2019-10-09 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
staging-testing
head:   d49d1c76b96ebf39539e93d5ab7943a01ef70e4f
commit: 1a61af0f8cbecd1610c6fc380d0fb00f57fd43f2 [57/111] staging: wfx: allow 
to scan networks

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 
Reported-by: Dan Carpenter 

New smatch warnings:
drivers/staging/wfx/scan.c:207 wfx_scan_work() warn: inconsistent returns 
'sem:>scan.lock'.
  Locked on:   line 201
  Unlocked on: line 145

# 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?id=1a61af0f8cbecd1610c6fc380d0fb00f57fd43f2
git remote add staging 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
git remote update staging
git checkout 1a61af0f8cbecd1610c6fc380d0fb00f57fd43f2
vim +207 drivers/staging/wfx/scan.c

1a61af0f8cbecd Jérôme Pouiller 2019-09-19  116  void wfx_scan_work(struct 
work_struct *work)
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  117  {
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  118  struct wfx_vif *wvif = 
container_of(work, struct wfx_vif, scan.work);
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  119  struct 
ieee80211_channel **it;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  120  struct wfx_scan_params 
scan = {
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  121  
.scan_req.scan_type.type = 0,/* Foreground */
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  122  };
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  123  struct 
ieee80211_channel *first;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  124  int i;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  125  
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  126  down(>scan.lock);
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  127  
mutex_lock(>wdev->conf_mutex);
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  128  
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  129  if (!wvif->scan.req || 
wvif->scan.curr == wvif->scan.end) {
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  130  if 
(wvif->scan.output_power != wvif->wdev->output_power)
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  131  
hif_set_output_power(wvif, wvif->wdev->output_power * 10);
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  132  
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  133  if 
(wvif->scan.status < 0)
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  134  
dev_warn(wvif->wdev->dev, "scan failed\n");
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  135  else if 
(wvif->scan.req)
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  136  
dev_dbg(wvif->wdev->dev, "scan completed\n");
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  137  else
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  138  
dev_dbg(wvif->wdev->dev, "scan canceled\n");
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  139  
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  140  wvif->scan.req 
= NULL;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  141  
wfx_tx_unlock(wvif->wdev);
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  142  
mutex_unlock(>wdev->conf_mutex);
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  143  
__ieee80211_scan_completed_compat(wvif->wdev->hw, wvif->scan.status ? 1 : 0);
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  144  
up(>scan.lock);
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  145  return;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  146  }
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  147  first = 
*wvif->scan.curr;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  148  
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  149  for (it = 
wvif->scan.curr + 1, i = 1;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  150   it != 
wvif->scan.end && i < HIF_API_MAX_NB_CHANNELS;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  151   ++it, ++i) {
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  152  if ((*it)->band 
!= first->band)
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  153  break;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  154  if 
(((*it)->flags ^ first->flags) &
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  155  
IEEE80211_CHAN_NO_IR)
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  156  break;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  157  if 
(!(first->flags & IEEE80211_CHAN_NO_IR) &&
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  158  
(*it)->max_power != first->max_power)
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  159  break;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  160  }
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  161  scan.scan_req.band = 
first->band;
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  162  
1a61af0f8cbecd Jérôme Pouiller 2019-09-19  163   

Re: [PATCH v2 0/6] media: cedrus: h264: Support multi-slice frames

2019-10-09 Thread Hans Verkuil
On 10/7/19 9:01 PM, Jernej Škrabec wrote:
> Dne ponedeljek, 07. oktober 2019 ob 12:44:24 CEST je Hans Verkuil napisal(a):
>> Hi Jernej,
>>
>> On 9/29/19 10:00 PM, Jernej Skrabec wrote:
>>> This series adds support for decoding multi-slice H264 frames along with
>>> support for V4L2_DEC_CMD_FLUSH and V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF.
>>>
>>> Code was tested by modified ffmpeg, which can be found here:
>>> https://github.com/jernejsk/FFmpeg, branch mainline-test
>>> It has to be configured with at least following options:
>>> --enable-v4l2-request --enable-libudev --enable-libdrm
>>>
>>> Samples used for testing:
>>> http://jernej.libreelec.tv/videos/h264/BA1_FT_C.mp4
>>> http://jernej.libreelec.tv/videos/h264/h264.mp4
>>>
>>> Command line used for testing:
>>> ffmpeg -hwaccel drm -hwaccel_device /dev/dri/card0 -i h264.mp4 -pix_fmt
>>> bgra -f fbdev /dev/fb0
>>>
>>> Please note that V4L2_DEC_CMD_FLUSH was not tested because I'm
>>> not sure how. ffmpeg follows exactly which slice is last in frame
>>> and sets hold flag accordingly. Improper usage of hold flag would
>>> corrupt ffmpeg assumptions and it would probably crash. Any ideas
>>> how to test this are welcome!
>>>
>>> Thanks to Jonas for adjusting ffmpeg.
>>>
>>> Please let me know what you think.
>>>
>>> Best regards,
>>> Jernej
>>>
>>> Changes from v1:
>>> - added Rb tags
>>> - updated V4L2_DEC_CMD_FLUSH documentation
>>> - updated first slice detection in Cedrus
>>> - hold capture buffer flag is set according to source format
>>> - added v4l m2m stateless_(try_)decoder_cmd ioctl helpers
>>>
>>> Hans Verkuil (2):
>>>   vb2: add V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF
>>>   videodev2.h: add V4L2_DEC_CMD_FLUSH
>>>
>>> Jernej Skrabec (4):
>>>   media: v4l2-mem2mem: add stateless_(try_)decoder_cmd ioctl helpers
>>>   media: cedrus: Detect first slice of a frame
>>>   media: cedrus: h264: Support multiple slices per frame
>>>   media: cedrus: Add support for holding capture buffer
>>>  
>>>  Documentation/media/uapi/v4l/buffer.rst   | 13 ++
>>>  .../media/uapi/v4l/vidioc-decoder-cmd.rst | 10 +++-
>>>  .../media/uapi/v4l/vidioc-reqbufs.rst |  6 +++
>>>  .../media/videodev2.h.rst.exceptions  |  1 +
>>>  .../media/common/videobuf2/videobuf2-v4l2.c   |  8 +++-
>>>  drivers/media/v4l2-core/v4l2-mem2mem.c| 35 ++
>>>  drivers/staging/media/sunxi/cedrus/cedrus.h   |  1 +
>>>  .../staging/media/sunxi/cedrus/cedrus_dec.c   | 11 +
>>>  .../staging/media/sunxi/cedrus/cedrus_h264.c  | 11 -
>>>  .../staging/media/sunxi/cedrus/cedrus_hw.c|  8 ++--
>>>  .../staging/media/sunxi/cedrus/cedrus_video.c | 14 ++
>>>  include/media/v4l2-mem2mem.h  | 46 +++
>>>  include/media/videobuf2-core.h|  3 ++
>>>  include/media/videobuf2-v4l2.h|  5 ++
>>>  include/uapi/linux/videodev2.h| 14 --
>>>  15 files changed, 175 insertions(+), 11 deletions(-)
>>
>> I didn't want to make a v3 of this series, instead I hacked this patch that
>> will hopefully do all the locking right.
>>
>> Basically I moved all the 'held' related code into v4l2-mem2mem under
>> job_spinlock. This simplifies the driver code as well.
>>
>> But this is a hack that sits on top of this series. If your ffmpeg tests are
>> now successful, then I'll turn this into a proper series with correct
>> documentation (a lot of the comments are now wrong with this patch, so just
>> ignore that).
> 
> Thanks for looking into this! With small fix mentioned below, it works! Note 
> that both scenarios I tested (flushing during decoding and flushing after 
> decoding is finished) are focused on capture queue. In order to trigger 
> output 
> queue flush, ffmpeg would need to queue multiple jobs and call flush before 
> they 
> are all processed. This is not something I can do at this time. Maybe Jonas 
> can help with modifying ffmpeg appropriately. However, code for case seems 
> correct to me.
> 
>>
>> Regards,
>>
>>  Hans
>>
>> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c
>> b/drivers/media/v4l2-core/v4l2-mem2mem.c index 2677a07e4c9b..f81a8f2465ab
>> 100644
>> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c
>> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
>> @@ -412,25 +412,24 @@ static void v4l2_m2m_cancel_job(struct v4l2_m2m_ctx
>> *m2m_ctx) }
>>  }
>>
>> -void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev,
>> - struct v4l2_m2m_ctx *m2m_ctx)
>> +static bool _v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev,
>> +  struct v4l2_m2m_ctx *m2m_ctx)
>>  {
>> -unsigned long flags;
>> -
>> -spin_lock_irqsave(_dev->job_spinlock, flags);
>>  if (!m2m_dev->curr_ctx || m2m_dev->curr_ctx != m2m_ctx) {
>> -spin_unlock_irqrestore(_dev->job_spinlock, flags);
>>  dprintk("Called by an instance not currently 
> running\n");
>> -return;
>> +return false;
>>  }
>>
>>  

Re: [PATCH RFC 0/2] staging: Support Avalon-MM DMA Interface for PCIe

2019-10-09 Thread Alexander Gordeev
On Thu, Sep 19, 2019 at 01:37:08PM +0200, Greg KH wrote:
> Why is this being submitted for drivers/staging/ and not the "real" part
> of the kernel tree?

Hi Greg!

I sent v2 of the patchset, but it does not need to be part of the
staging tree. I CC-ed de...@driverdev.osuosl.org for reference.

Thanks!

> All staging code must have a TODO file listing what needs to be done in
> order to get it out of staging, and be self-contained (i.e. no files
> include/linux/)
> 
> Please fix that up when resending this series.
> 
> thanks,
> 
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RFC v2 2/2] dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe test

2019-10-09 Thread Alexander Gordeev
This is sample implementation of a driver that uses "avalon-dma"
driver interface to perform data transfers between on-chip and
system memory in devices using Avalon-MM DMA Interface for PCIe
design. Companion user-level tool could be found at
https://github.com/a-gordeev/avalon-tool.git

CC: Michael Chen 
CC: de...@driverdev.osuosl.org
CC: dmaeng...@vger.kernel.org

Signed-off-by: Alexander Gordeev 
---
 drivers/dma/Kconfig |   1 +
 drivers/dma/Makefile|   1 +
 drivers/dma/avalon-test/Kconfig |  23 +
 drivers/dma/avalon-test/Makefile|  14 +
 drivers/dma/avalon-test/avalon-dev.c|  65 +++
 drivers/dma/avalon-test/avalon-dev.h|  33 ++
 drivers/dma/avalon-test/avalon-ioctl.c  | 128 +
 drivers/dma/avalon-test/avalon-ioctl.h  |  12 +
 drivers/dma/avalon-test/avalon-mmap.c   |  93 
 drivers/dma/avalon-test/avalon-mmap.h   |  12 +
 drivers/dma/avalon-test/avalon-sg-buf.c | 132 +
 drivers/dma/avalon-test/avalon-sg-buf.h |  26 +
 drivers/dma/avalon-test/avalon-util.c   |  54 ++
 drivers/dma/avalon-test/avalon-util.h   |  12 +
 drivers/dma/avalon-test/avalon-xfer.c   | 697 
 drivers/dma/avalon-test/avalon-xfer.h   |  28 +
 include/uapi/linux/avalon-ioctl.h   |  32 ++
 17 files changed, 1363 insertions(+)
 create mode 100644 drivers/dma/avalon-test/Kconfig
 create mode 100644 drivers/dma/avalon-test/Makefile
 create mode 100644 drivers/dma/avalon-test/avalon-dev.c
 create mode 100644 drivers/dma/avalon-test/avalon-dev.h
 create mode 100644 drivers/dma/avalon-test/avalon-ioctl.c
 create mode 100644 drivers/dma/avalon-test/avalon-ioctl.h
 create mode 100644 drivers/dma/avalon-test/avalon-mmap.c
 create mode 100644 drivers/dma/avalon-test/avalon-mmap.h
 create mode 100644 drivers/dma/avalon-test/avalon-sg-buf.c
 create mode 100644 drivers/dma/avalon-test/avalon-sg-buf.h
 create mode 100644 drivers/dma/avalon-test/avalon-util.c
 create mode 100644 drivers/dma/avalon-test/avalon-util.h
 create mode 100644 drivers/dma/avalon-test/avalon-xfer.c
 create mode 100644 drivers/dma/avalon-test/avalon-xfer.h
 create mode 100644 include/uapi/linux/avalon-ioctl.h

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index f6f43480a4a4..4b3c6a6baf4c 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -670,6 +670,7 @@ source "drivers/dma/sh/Kconfig"
 source "drivers/dma/ti/Kconfig"
 
 source "drivers/dma/avalon/Kconfig"
+source "drivers/dma/avalon-test/Kconfig"
 
 # clients
 comment "DMA Clients"
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index fd7e11417b73..eb3ee7f6cac6 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx_dma.o
 obj-$(CONFIG_ST_FDMA) += st_fdma.o
 obj-$(CONFIG_AVALON_DMA) += avalon/
+obj-$(CONFIG_AVALON_TEST) += avalon-test/
 
 obj-y += mediatek/
 obj-y += qcom/
diff --git a/drivers/dma/avalon-test/Kconfig b/drivers/dma/avalon-test/Kconfig
new file mode 100644
index ..021c28fe77a6
--- /dev/null
+++ b/drivers/dma/avalon-test/Kconfig
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Avalon DMA engine
+#
+# Author: Alexander Gordeev 
+#
+config AVALON_TEST
+   select AVALON_DMA
+   tristate "Intel Avalon-MM DMA Interface for PCIe test driver"
+   help
+ This selects a test driver for Avalon-MM DMA Interface for PCI
+
+if AVALON_TEST
+
+config AVALON_TEST_TARGET_BASE
+   hex "Target device base address"
+   default "0x7000"
+
+config AVALON_TEST_TARGET_SIZE
+   hex "Target device memory size"
+   default "0x1000"
+
+endif
diff --git a/drivers/dma/avalon-test/Makefile b/drivers/dma/avalon-test/Makefile
new file mode 100644
index ..63351c52478a
--- /dev/null
+++ b/drivers/dma/avalon-test/Makefile
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Avalon DMA driver
+#
+# Author: Alexander Gordeev 
+#
+obj-$(CONFIG_AVALON_TEST)  += avalon-test.o
+
+avalon-test-objs :=avalon-dev.o \
+   avalon-ioctl.o \
+   avalon-mmap.o \
+   avalon-sg-buf.o \
+   avalon-xfer.o \
+   avalon-util.o
diff --git a/drivers/dma/avalon-test/avalon-dev.c 
b/drivers/dma/avalon-test/avalon-dev.c
new file mode 100644
index ..9e83f777f937
--- /dev/null
+++ b/drivers/dma/avalon-test/avalon-dev.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Avalon DMA driver
+ *
+ * Author: Alexander Gordeev 
+ */
+#include 
+#include 
+#include 
+
+#include "avalon-dev.h"
+#include "avalon-ioctl.h"
+#include "avalon-mmap.h"
+
+const struct file_operations avalon_dev_fops = {
+   .llseek = generic_file_llseek,
+   .unlocked_ioctl = avalon_dev_ioctl,
+   .mmap   = avalon_dev_mmap,
+};
+
+static struct avalon_dev avalon_dev;
+
+static int __init avalon_drv_init(void)
+{
+   struct avalon_dev *adev = _dev;

[PATCH v2 1/2] dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe

2019-10-09 Thread Alexander Gordeev
Support Avalon-MM DMA Interface for PCIe used in hard IPs for
Intel Arria, Cyclone or Stratix FPGAs.

CC: Michael Chen 
CC: de...@driverdev.osuosl.org
CC: dmaeng...@vger.kernel.org

Signed-off-by: Alexander Gordeev 
---
 drivers/dma/Kconfig  |   2 +
 drivers/dma/Makefile |   1 +
 drivers/dma/avalon/Kconfig   |  88 +++
 drivers/dma/avalon/Makefile  |   6 +
 drivers/dma/avalon/avalon-core.c | 432 +++
 drivers/dma/avalon/avalon-core.h |  90 +++
 drivers/dma/avalon/avalon-hw.c   | 212 +++
 drivers/dma/avalon/avalon-hw.h   |  86 ++
 drivers/dma/avalon/avalon-pci.c  | 150 +++
 9 files changed, 1067 insertions(+)
 create mode 100644 drivers/dma/avalon/Kconfig
 create mode 100644 drivers/dma/avalon/Makefile
 create mode 100644 drivers/dma/avalon/avalon-core.c
 create mode 100644 drivers/dma/avalon/avalon-core.h
 create mode 100644 drivers/dma/avalon/avalon-hw.c
 create mode 100644 drivers/dma/avalon/avalon-hw.h
 create mode 100644 drivers/dma/avalon/avalon-pci.c

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 7af874b69ffb..f6f43480a4a4 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -669,6 +669,8 @@ source "drivers/dma/sh/Kconfig"
 
 source "drivers/dma/ti/Kconfig"
 
+source "drivers/dma/avalon/Kconfig"
+
 # clients
 comment "DMA Clients"
depends on DMA_ENGINE
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index f5ce8665e944..fd7e11417b73 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -75,6 +75,7 @@ obj-$(CONFIG_UNIPHIER_MDMAC) += uniphier-mdmac.o
 obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx_dma.o
 obj-$(CONFIG_ST_FDMA) += st_fdma.o
+obj-$(CONFIG_AVALON_DMA) += avalon/
 
 obj-y += mediatek/
 obj-y += qcom/
diff --git a/drivers/dma/avalon/Kconfig b/drivers/dma/avalon/Kconfig
new file mode 100644
index ..09e0773fcdb2
--- /dev/null
+++ b/drivers/dma/avalon/Kconfig
@@ -0,0 +1,88 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Avalon DMA engine
+#
+# Author: Alexander Gordeev 
+#
+config AVALON_DMA
+   tristate "Intel Avalon-MM DMA Interface for PCIe"
+   depends on PCI
+   select DMA_ENGINE
+   select DMA_VIRTUAL_CHANNELS
+   help
+ This selects a driver for Avalon-MM DMA Interface for PCIe
+ hard IP block used in Intel Arria, Cyclone or Stratix FPGAs.
+
+if AVALON_DMA
+
+config AVALON_DMA_MASK_WIDTH
+   int "Avalon DMA streaming and coherent bitmask width"
+   range 0 64
+   default 64
+   help
+ Width of bitmask for streaming and coherent DMA operations
+
+config AVALON_DMA_CTRL_BASE
+   hex "Avalon DMA controllers base"
+   default "0x"
+
+config AVALON_DMA_RD_EP_DST_LO
+   hex "Avalon DMA read controller base low"
+   default "0x8000"
+   help
+ Specifies the lower 32-bits of the base address of the read
+ status and descriptor table in the Root Complex memory.
+
+config AVALON_DMA_RD_EP_DST_HI
+   hex "Avalon DMA read controller base high"
+   default "0x"
+   help
+ Specifies the upper 32-bits of the base address of the read
+ status and descriptor table in the Root Complex memory.
+
+config AVALON_DMA_WR_EP_DST_LO
+   hex "Avalon DMA write controller base low"
+   default "0x80002000"
+   help
+ Specifies the lower 32-bits of the base address of the write
+ status and descriptor table in the Root Complex memory.
+
+config AVALON_DMA_WR_EP_DST_HI
+   hex "Avalon DMA write controller base high"
+   default "0x"
+   help
+ Specifies the upper 32-bits of the base address of the write
+ status and descriptor table in the Root Complex memory.
+
+config AVALON_DMA_PCI_VENDOR_ID
+   hex "PCI vendor ID"
+   default "0x1172"
+
+config AVALON_DMA_PCI_DEVICE_ID
+   hex "PCI device ID"
+   default "0xe003"
+
+config AVALON_DMA_PCI_BAR
+   int "PCI device BAR the Avalon DMA controller is mapped to"
+   range 0 5
+   default 0
+   help
+ Number of PCI BAR the DMA controller is mapped to
+
+config AVALON_DMA_PCI_MSI_COUNT_ORDER
+   int "Count of MSIs the PCI device provides (order)"
+   range 0 5
+   default 5
+   help
+ Number of vectors the PCI device uses in multiple MSI mode.
+ This number is provided as the power of two.
+
+config AVALON_DMA_PCI_MSI_VECTOR
+   int "Vector number the DMA controller is mapped to"
+   range 0 31
+   default 0
+   help
+ Number of MSI vector the DMA controller is mapped to in
+ multiple MSI mode.
+
+endif
diff --git a/drivers/dma/avalon/Makefile b/drivers/dma/avalon/Makefile
new file mode 100644
index ..4b5278d12f86
--- /dev/null
+++ b/drivers/dma/avalon/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_AVALON_DMA)   += avalon-dma.o
+
+avalon-dma-objs

[PATCH v2 0/2] dmaengine: avalon: Support Avalon-MM DMA Interface for PCIe

2019-10-09 Thread Alexander Gordeev
This series is against v5.4-rc2

Changes since v1:
- "avalon-dma" converted to "dmaengine" model;
- "avalon-drv" renamed to "avalon-test";

The Avalon-MM DMA Interface for PCIe is a design used in hard IPs for
Intel Arria, Cyclone or Stratix FPGAs. It transfers data between on-chip
memory and system memory.

Patch 1. This patch introduces "avalon-dma" driver that conforms to
"dmaengine" model.

Patch 2. The existing "dmatest" is not meant for DMA_SLAVE type of
transfers needed by "avalon-dma". Instead, custom "avalon-test" driver
was used to debug and stress "avalon-dma". If it could be useful for a
wider audience, I can make it optional part of "avalon-dma" sources or
leave it as separate driver. Marking patch 2 as RFC for now.

Testing was done using a custom FPGA build with Arria 10 FPGA streaming
data to target device RAM:

  +--++--++--++--+
  | Nios CPU |<-->|   RAM|<-->|  Avalon  |<-PCIe->| Host CPU |
  +--++--++--++--+

The RAM was examined for data integrity by examining RAM contents
from host CPU (indirectly - checking data DMAed to the system) and
from Nios CPU that has direct access to the device RAM. A companion
tool using "avalon-test" driver was used to DMA files to the device:
https://github.com/a-gordeev/avalon-tool.git

CC: Michael Chen 
CC: de...@driverdev.osuosl.org
CC: dmaeng...@vger.kernel.org

Alexander Gordeev (2):
  dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe
  dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe test

 drivers/dma/Kconfig |   3 +
 drivers/dma/Makefile|   2 +
 drivers/dma/avalon-test/Kconfig |  23 +
 drivers/dma/avalon-test/Makefile|  14 +
 drivers/dma/avalon-test/avalon-dev.c|  65 +++
 drivers/dma/avalon-test/avalon-dev.h|  33 ++
 drivers/dma/avalon-test/avalon-ioctl.c  | 128 +
 drivers/dma/avalon-test/avalon-ioctl.h  |  12 +
 drivers/dma/avalon-test/avalon-mmap.c   |  93 
 drivers/dma/avalon-test/avalon-mmap.h   |  12 +
 drivers/dma/avalon-test/avalon-sg-buf.c | 132 +
 drivers/dma/avalon-test/avalon-sg-buf.h |  26 +
 drivers/dma/avalon-test/avalon-util.c   |  54 ++
 drivers/dma/avalon-test/avalon-util.h   |  12 +
 drivers/dma/avalon-test/avalon-xfer.c   | 697 
 drivers/dma/avalon-test/avalon-xfer.h   |  28 +
 drivers/dma/avalon/Kconfig  |  88 +++
 drivers/dma/avalon/Makefile |   6 +
 drivers/dma/avalon/avalon-core.c| 432 +++
 drivers/dma/avalon/avalon-core.h|  90 +++
 drivers/dma/avalon/avalon-hw.c  | 212 +++
 drivers/dma/avalon/avalon-hw.h  |  86 +++
 drivers/dma/avalon/avalon-pci.c | 150 +
 include/uapi/linux/avalon-ioctl.h   |  32 ++
 24 files changed, 2430 insertions(+)
 create mode 100644 drivers/dma/avalon-test/Kconfig
 create mode 100644 drivers/dma/avalon-test/Makefile
 create mode 100644 drivers/dma/avalon-test/avalon-dev.c
 create mode 100644 drivers/dma/avalon-test/avalon-dev.h
 create mode 100644 drivers/dma/avalon-test/avalon-ioctl.c
 create mode 100644 drivers/dma/avalon-test/avalon-ioctl.h
 create mode 100644 drivers/dma/avalon-test/avalon-mmap.c
 create mode 100644 drivers/dma/avalon-test/avalon-mmap.h
 create mode 100644 drivers/dma/avalon-test/avalon-sg-buf.c
 create mode 100644 drivers/dma/avalon-test/avalon-sg-buf.h
 create mode 100644 drivers/dma/avalon-test/avalon-util.c
 create mode 100644 drivers/dma/avalon-test/avalon-util.h
 create mode 100644 drivers/dma/avalon-test/avalon-xfer.c
 create mode 100644 drivers/dma/avalon-test/avalon-xfer.h
 create mode 100644 drivers/dma/avalon/Kconfig
 create mode 100644 drivers/dma/avalon/Makefile
 create mode 100644 drivers/dma/avalon/avalon-core.c
 create mode 100644 drivers/dma/avalon/avalon-core.h
 create mode 100644 drivers/dma/avalon/avalon-hw.c
 create mode 100644 drivers/dma/avalon/avalon-hw.h
 create mode 100644 drivers/dma/avalon/avalon-pci.c
 create mode 100644 include/uapi/linux/avalon-ioctl.h

-- 
2.23.0

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


Apply For Financial investment at a lower rate 2%

2019-10-09 Thread Nadia Artha Dewi
-- 
Hello,

We are private lenders based in UK.
Do you need a loan (credit) as soon as possible. Are you in search of
money to solve your personal needs or finance your business venture,
then get Your desired loan today! Consult us at Sunrise Funding Ltd.

* We offer personal loan & huge capital loan at 2% interest rate to
the general public both locally and internationally.
* Credit amount range from $5,000.00 -- $500,000.00 and above.
* Special $10,000,000.00 Loan offer for huge project also available.
* Loan period of 6 months -- 10 years.
* Loan is granted 24 hours after approval and accredited, directly in
hand or bank account.

Please note that you are advised to contact us for more details via
the following e-mail address below;

EMAIL : sunrisefundinglt...@gmail.com
FIRM : Sunrise Funding Ltd UK.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: wfx: fix swapped arguments in memset call

2019-10-09 Thread Colin King
From: Colin Ian King 

The memset appears to have the 2nd and 3rd arguments in the wrong
order, fix this by swapping these around into the correct order.

Addresses-Coverity: ("Memset fill truncated")
Fixes: 4f8b7fabb15d ("staging: wfx: allow to send commands to chip")
Signed-off-by: Colin Ian King 
---
 drivers/staging/wfx/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c
index 8de16ad7c710..761ad9b4f27e 100644
--- a/drivers/staging/wfx/debug.c
+++ b/drivers/staging/wfx/debug.c
@@ -226,7 +226,7 @@ static ssize_t wfx_send_hif_msg_write(struct file *file, 
const char __user *user
// wfx_cmd_send() chekc that reply buffer is wide enough, but do not
// return precise length read. User have to know how many bytes should
// be read. Filling reply buffer with a memory pattern may help user.
-   memset(context->reply, sizeof(context->reply), 0xFF);
+   memset(context->reply, 0xFF, sizeof(context->reply));
request = memdup_user(user_buf, count);
if (IS_ERR(request))
return PTR_ERR(request);
-- 
2.20.1

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


[PATCH v2 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2019-10-09 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.

The ANX7625 can support both USB Type-C PD feature and MIPI DSI/DPI
to DP feature. This driver only enabled MIPI DSI/DPI to DP feature.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/Makefile   |2 +-
 drivers/gpu/drm/bridge/analogix/Kconfig   |6 +
 drivers/gpu/drm/bridge/analogix/Makefile  |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c | 2132 +
 drivers/gpu/drm/bridge/analogix/anx7625.h |  405 ++
 5 files changed, 2545 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index 4934fcf..bcd388a 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -12,8 +12,8 @@ obj-$(CONFIG_DRM_SII9234) += sii9234.o
 obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o
-obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/
 obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
 obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o
 obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o
+obj-y += analogix/
 obj-y += synopsys/
diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
b/drivers/gpu/drm/bridge/analogix/Kconfig
index e930ff9..b2f127e 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -2,3 +2,9 @@
 config DRM_ANALOGIX_DP
tristate
depends on DRM
+
+config ANALOGIX_ANX7625
+   tristate "Analogix MIPI to DP interface support"
+   help
+   ANX7625 is an ultra-low power 4K mobile HD transmitter designed
+   for portable devices. It converts MIPI/DPI to DisplayPort1.3 4K.
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
b/drivers/gpu/drm/bridge/analogix/Makefile
index fdbf3fd..8a52867 100644
--- a/drivers/gpu/drm/bridge/analogix/Makefile
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_ANALOGIX_ANX7625) += anx7625.o
 analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
new file mode 100644
index 000..7bb4e17
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -0,0 +1,2132 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright(c) 2016, Analogix Semiconductor. All rights reserved.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "anx7625.h"
+
+/*
+ * there is a sync issue while access I2C register between AP(CPU) and
+ * internal firmware(OCM), to avoid the race condition, AP should access
+ * the reserved slave address before slave address occurs changes.
+ */
+static int i2c_access_workaround(struct anx7625_data *ctx,
+struct i2c_client *client)
+{
+   u8 offset;
+   struct device *dev = >dev;
+   struct i2c_client *last_client = ctx->last_client;
+   int ret = 0;
+
+   if (client != last_client) {
+   ctx->last_client = client;
+
+   if (client == ctx->i2c.tcpc_client)
+   offset = RSVD_00_ADDR;
+   else if (client == ctx->i2c.tx_p0_client)
+   offset = RSVD_D1_ADDR;
+   else if (client == ctx->i2c.tx_p1_client)
+   offset = RSVD_60_ADDR;
+   else if (client == ctx->i2c.rx_p0_client)
+   offset = RSVD_39_ADDR;
+   else if (client == ctx->i2c.rx_p1_client)
+   offset = RSVD_7F_ADDR;
+   else
+   offset = RSVD_00_ADDR;
+
+   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev,
+ "failed to access i2c id=%x\n:%x",
+ client->addr, offset);
+   }
+
+   return ret;
+}
+
+static int anx7625_reg_read(struct anx7625_data *ctx,
+   struct i2c_client *client, u8 reg_addr)
+{
+   int ret;
+   struct device *dev = >dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_byte_data(client, reg_addr);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c failed id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_block_read(struct 

[PATCH v2 0/2] Add initial support for slimport anx7625

2019-10-09 Thread Xin Ji
Hi all,

The following series add initial support for the Slimport ANX7625 transmitter, a
ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable device.

This is the initial version, any mistakes, please let me know, I will fix it in
the next series.

Thanks,
Xin


Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding
  drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

 .../bindings/display/bridge/anx7625.yaml   |   79 +
 drivers/gpu/drm/bridge/Makefile|2 +-
 drivers/gpu/drm/bridge/analogix/Kconfig|6 +
 drivers/gpu/drm/bridge/analogix/Makefile   |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 2132 
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  405 
 6 files changed, 2624 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/anx7625.yaml
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

-- 
2.7.4

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


[PATCH v2 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding

2019-10-09 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI to DisplayPort 1.3 4K.

You can add support to your board with binding.

Example:
anx_bridge: anx7625@58 {
compatible = "analogix,anx7625";
reg = <0x58>;
enable-gpios = < 45 GPIO_ACTIVE_LOW>;
reset-gpios = < 73 GPIO_ACTIVE_LOW>;
status = "okay";
port@0 {
reg = <0>;
anx7625_1_in: endpoint {
remote-endpoint = <_dsi_bridge_1>;
};
};
};

Signed-off-by: Xin Ji 
---
 .../bindings/display/bridge/anx7625.yaml   | 79 ++
 1 file changed, 79 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/anx7625.yaml

diff --git a/Documentation/devicetree/bindings/display/bridge/anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/anx7625.yaml
new file mode 100644
index 000..0ef6271
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/anx7625.yaml
@@ -0,0 +1,79 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Analogix Semiconductor, Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/bridge/anx7625.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
+
+maintainers:
+  - Xin Ji 
+
+description: |
+  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
+  designed for portable devices.
+
+properties:
+  compatible:
+items:
+  - const: analogix,anx7625
+
+  reg:
+maxItems: 1
+
+  hpd-gpios:
+description: used for HPD interrupt
+maxItems: 1
+
+  enable-gpios:
+description: used for power on chip control
+maxItems: 1
+
+  reset-gpios:
+description: used for reset chip control
+maxItems: 1
+
+  port@0:
+type: object
+description:
+  A port node pointing to MIPI DSI host port node.
+
+  port@1:
+type: object
+description:
+  A port node pointing to MIPI DPI host port node.
+
+  port@2:
+type: object
+description:
+  A port node pointing to external connector port node.
+
+  port@3:
+type: object
+description:
+  A port node pointing to internal panel port node.
+
+  port@4:
+type: object
+description:
+  A port node pointing to normal eDP port node.
+
+required:
+  - compatible
+  - reg
+  - port@0 | port@1
+
+example:
+  - |
+anx_bridge: anx7625@58 {
+compatible = "analogix,anx7625";
+reg = <0x58>;
+status = "okay";
+port@0 {
+  reg = <0>;
+  anx7625_1_in: endpoint {
+remote-endpoint = <_dsi_bridge_1>;
+  };
+};
+};
-- 
2.7.4

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


Re: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls

2019-10-09 Thread Hans de Goede

Hi Denis,

On 30-09-2019 13:01, Denis Efremov wrote:

memcpy() in phy_ConfigBBWithParaFile() and PHY_ConfigRFWithParaFile() is
called with "src == NULL && len == 0". This is an undefined behavior.
Moreover this if pre-condition "pBufLen && (*pBufLen == 0) && !pBuf"
is constantly false because it is a nested if in the else brach, i.e.,
"if (cond) { ... } else { if (cond) {...} }". This patch alters the
if condition to check "pBufLen && pBuf" pointers are not NULL.

Cc: Greg Kroah-Hartman 
Cc: Hans de Goede 
Cc: Bastien Nocera 
Cc: Larry Finger 
Cc: Jes Sorensen 
Cc: sta...@vger.kernel.org
Signed-off-by: Denis Efremov 
---
Not tested. I don't have the hardware. The fix is based on my guess.


Thsnk you for your patch.

So I've been doing some digging and this code normally never executes.

For this to execute the user would need to change the rtw_load_phy_file module
param from its default of 0x44 (LOAD_BB_PG_PARA_FILE | 
LOAD_RF_TXPWR_LMT_PARA_FILE)
to something which includes 0x02 (LOAD_BB_PARA_FILE) as mask.

And even with that param set for this code to actually do something /
for pBuf to ever not be NULL the following conditions would have to
be true:

1) Set the rtw_load_phy_file module param from its default of
   0x44 (LOAD_BB_PG_PARA_FILE | LOAD_RF_TXPWR_LMT_PARA_FILE) to something
   which includes 0x02 as mask; and
2) Set rtw_phy_file_path module parameter to say "/lib/firmware/"; and
3) Store a /lib/firmware/rtl8723b/PHY_REG.txt file in the expected format.

So I've come to the conclusion that all the phy_Config*WithParaFile functions
(and a bunch of stuff they use) can be removed.

I will prepare and submit a patch for this.

Regards,

Hans





  drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c 
b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 6539bee9b5ba..0902dc3c1825 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -2320,7 +2320,7 @@ int phy_ConfigBBWithParaFile(
}
}
} else {
-   if (pBufLen && (*pBufLen == 0) && !pBuf) {
+   if (pBufLen && pBuf) {
memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
rtStatus = _SUCCESS;
} else
@@ -2752,7 +2752,7 @@ int PHY_ConfigRFWithParaFile(
}
}
} else {
-   if (pBufLen && (*pBufLen == 0) && !pBuf) {
+   if (pBufLen && pBuf) {
memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
rtStatus = _SUCCESS;
} else



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


[staging:staging-testing 55/111] drivers/staging/wfx/wfx.h:91 wdev_to_wvif() warn: potential spectre issue 'wdev->vif' [r] (local cap)

2019-10-09 Thread Dan Carpenter
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
staging-testing
head:   d49d1c76b96ebf39539e93d5ab7943a01ef70e4f
commit: 9bca45f3d6924f19f29c0d019e961af3f41bdc9e [55/111] staging: wfx: allow 
to send 802.11 frames

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 
Reported-by: Dan Carpenter 

New smatch warnings:
drivers/staging/wfx/wfx.h:91 wdev_to_wvif() warn: potential spectre issue 
'wdev->vif' [r] (local cap)
drivers/staging/wfx/data_tx.c:479 wfx_tx_get_raw_link_id() warn: signedness bug 
returning '(-2)'

# 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?id=9bca45f3d6924f19f29c0d019e961af3f41bdc9e
git remote add staging 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
git remote update staging
git checkout 9bca45f3d6924f19f29c0d019e961af3f41bdc9e
vim +91 drivers/staging/wfx/wfx.h

e16e7f0716a6ba Jérôme Pouiller 2019-09-19  80  
f4a71ba8753d94 Jérôme Pouiller 2019-09-19  81  static inline struct wfx_vif 
*wdev_to_wvif(struct wfx_dev *wdev, int vif_id)
f4a71ba8753d94 Jérôme Pouiller 2019-09-19  82  {
f4a71ba8753d94 Jérôme Pouiller 2019-09-19  83   if (vif_id >= 
ARRAY_SIZE(wdev->vif)) {
f4a71ba8753d94 Jérôme Pouiller 2019-09-19  84   dev_dbg(wdev->dev, 
"requesting non-existent vif: %d\n", vif_id);
f4a71ba8753d94 Jérôme Pouiller 2019-09-19  85   return NULL;
f4a71ba8753d94 Jérôme Pouiller 2019-09-19  86   }

vaf_id = array_index_nospec(wdev->vif, ARRAY_SIZE(wdev->vif)); ?

f4a71ba8753d94 Jérôme Pouiller 2019-09-19  87   if (!wdev->vif[vif_id]) {
f4a71ba8753d94 Jérôme Pouiller 2019-09-19  88   dev_dbg(wdev->dev, 
"requesting non-allocated vif: %d\n", vif_id);
f4a71ba8753d94 Jérôme Pouiller 2019-09-19  89   return NULL;
f4a71ba8753d94 Jérôme Pouiller 2019-09-19  90   }
f4a71ba8753d94 Jérôme Pouiller 2019-09-19 @91   return (struct wfx_vif *) 
wdev->vif[vif_id]->drv_priv;
f4a71ba8753d94 Jérôme Pouiller 2019-09-19  92  }

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] KPC2000: kpc2000_spi.c: Fix alignment and style problems.

2019-10-09 Thread Dan Carpenter
On Tue, Oct 08, 2019 at 08:50:39PM -0700, Chandra Annamaneni wrote:
> diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
> b/drivers/staging/kpc2000/kpc2000_spi.c
> index 3be33c4..a20f2d7 100644
> --- a/drivers/staging/kpc2000/kpc2000_spi.c
> +++ b/drivers/staging/kpc2000/kpc2000_spi.c
> @@ -30,19 +30,27 @@
>  #include "kpc.h"
>  
>  static struct mtd_partition p2kr0_spi0_parts[] = {
> - { .name = "SLOT_0", .size = 7798784,.offset = 0,
> },
> - { .name = "SLOT_1", .size = 7798784,.offset = 
> MTDPART_OFS_NXTBLK},
> - { .name = "SLOT_2", .size = 7798784,.offset = 
> MTDPART_OFS_NXTBLK},
> - { .name = "SLOT_3", .size = 7798784,.offset = 
> MTDPART_OFS_NXTBLK},
> - { .name = "CS0_EXTRA",  .size = MTDPART_SIZ_FULL,   .offset = 
> MTDPART_OFS_NXTBLK},
> + { .name = "SLOT_0", .size = 7798784,.offset = 0,},
> + { .name = "SLOT_1", .size = 7798784,.offset =
> +  MTDPART_OFS_NXTBLK},

This looks worse than the original code...  :(  You could maybe make it
a little bit tighter if you used space characters.

{ .name = "SLOT_0",.size = 7798784,  .offset = 0,   
 },
{ .name = "SLOT_1",.size = 7798784,  .offset = 
MTDPART_OFS_NXTBLK},
{ .name = "SLOT_2",.size = 7798784,  .offset = 
MTDPART_OFS_NXTBLK},
{ .name = "SLOT_3",.size = 7798784,  .offset = 
MTDPART_OFS_NXTBLK},
{ .name = "CS0_EXTRA", .size = MTDPART_SIZ_FULL, .offset = 
MTDPART_OFS_NXTBLK},

It still goes over 80 characters, but that's okay.  Or we could just
leave the original code as is.

[ snip ]

>  static struct flash_platform_data p2kr0_spi1_pdata = {
>   .name = "SPI1",
>   .nr_parts = ARRAY_SIZE(p2kr0_spi1_parts),
> @@ -165,7 +174,7 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int 
> idx)
>   u64 val;
>  
>   addr += idx;
> - if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0))
> + if (idx == KP_SPI_REG_CONFIG && cs->conf_cache >= 0)

I like these changes but Greg doesn't.  So don't bother with this one.

>   return cs->conf_cache;
>  
>   val = readq(addr);

The rest of the changes are fine.  Split them into multiple patches and
resend.

regards,
dan carpenter

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


Re: [PATCH v3] staging: vc04_services: Avoid NULL comparison

2019-10-09 Thread Dan Carpenter
On Tue, Oct 08, 2019 at 07:44:15PM -0700, Nachammai Karuppiah wrote:
> Remove NULL comparison. Issue found using checkpatch.pl
> 
> Signed-off-by: Nachammai Karuppiah 
> 
> ---
> 
> Changes in V2
>- Remove all NULL comparisons in vc04_services/interface directory.
> ---
> 
> changes in V3
>- Fixed warnings. Reported-by: kbuild test robot 
> ---
> 
> Signed-off-by: Nachammai Karuppiah 
> ---
>  .../interface/vchiq_arm/vchiq_2835_arm.c   |  4 ++--


Only one --- cut off line is needed.  You have two Signed-of-by lines
as well.  It should just be:

Remove NULL comparison. Issue found using checkpatch.pl

Signed-off-by: Nachammai Karuppiah 
---
Changes in V2
   - Remove all NULL comparisons in vc04_services/interface directory.
changes in V3
   - Fixed warnings. Reported-by: kbuild test robot 

  .../interface/vchiq_arm/vchiq_2835_arm.c   |  4 ++--

But this doesn't affect the final patch, and we can see all the
information so it's fine.  No need to resend.

Reviewed-by: Dan Carpenter 

regards,
dan carpenter

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


Re: [PATCH] KPC2000: kpc2000_spi.c: Fix alignment and style problems.

2019-10-09 Thread Greg KH
On Tue, Oct 08, 2019 at 08:50:39PM -0700, Chandra Annamaneni wrote:
>   Fixed alignment and style issues raised by checkpatch.pl

Why is this padded?

Also, you need to break this up into "one logical change per patch",
you can't "fix all style issues" at once, sorry.

Please fix this up and send it as a patch series.

thanks,

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


Re: [staging:staging-testing 41/59] drivers/staging/wfx/main.c:47:14-21: ERROR: PTR_ERR applied after initialization to constant on line 42

2019-10-09 Thread Rong Chen




On 10/7/19 4:36 PM, Jerome Pouiller wrote:

On Friday 4 October 2019 12:48:32 CEST kbuild test robot wrote:
[...]

drivers/staging/wfx/main.c:47:14-21: ERROR: PTR_ERR applied after 
initialization to constant on line 42

vim +47 drivers/staging/wfx/main.c

 30
 31  struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const 
char *label)
 32  {
 33  struct gpio_desc *ret;
 34  char label_buf[256];
 35
 36  if (override >= 0) {
 37  snprintf(label_buf, sizeof(label_buf), "wfx_%s", 
label);
 38  ret = ERR_PTR(devm_gpio_request_one(dev, override, 
GPIOF_OUT_INIT_LOW, label_buf));
 39  if (!ret)
 40  ret = gpio_to_desc(override);
 41  } else if (override == -1) {
   > 42  ret = NULL;
 43  } else {
 44  ret = devm_gpiod_get(dev, label, GPIOD_OUT_LOW);
 45  }
 46  if (IS_ERR(ret) || !ret) {
   > 47  if (!ret || PTR_ERR(ret) == -ENOENT)
 48  dev_warn(dev, "gpio %s is not defined\n", 
label);
 49  else
 50  dev_warn(dev, "error while requesting gpio 
%s\n", label);
 51  ret = NULL;
 52  } else {
 53  dev_dbg(dev, "using gpio %d for %s\n", 
desc_to_gpio(ret), label);
 54  }
 55  return ret;
 56  }
 57

I think that this report is a false positive or I missed something?



Hi,

Sorry for the inconvenience, but we confirmed that the error first 
appeared since commit 0096214a59.


Best Regards,
Rong Chen

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