Unnecessary code cleanup patches
Subsystems (4)
v2 cover Unnecessary code cleanup patches
Changes since v1:
- suggested by Andy Shevchenko
* Patch for drivers/staging/media/av7110/sp8870.c and drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c is split into two different patches in the patchset for use by the different driver maintainers.
* Added subject title for each of the separated patch
* Patch 1: Removed unnecessary curly braces {} initially inserted
* Patch 2: Unnecessary {} was also removed from v1
Abraham Samuel Adekunle (3):
staging: media: Remove duplicate NULL tests on a value in pci
staging: media: Remove duplicated NULL tests on a value in av7110
staging: rtl8723bs: Prevent duplicate NULL tests on a value
.../media/atomisp/pci/atomisp_gmin_platform.c | 2 +- drivers/staging/media/av7110/sp8870.c | 10 ++-- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/core/rtw_xmit.c | 56 +++++++++---------- 4 files changed, 33 insertions(+), 37 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/3 staging: media: Remove duplicate NULL tests on a value in pci
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
--- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1 -1
@@ -1292,7 +1292,7 @@ static int gmin_get_config_dsm_var(struct device *dev,* if it founds something different than string, letting it * to fall back to the old code. */ -if (cur && cur->type !=ACPI_TYPE_STRING ) { +if (cur->type !=ACPI_TYPE_STRING ) {dev_info (dev,"found non-string _DSM entry for '%s'\n" , var);ACPI_FREE (obj);return -EINVAL ;
Signature · 1 line
2.34.1
PATCH v2 2/3 staging: media: Remove duplicated NULL tests on a value in av7110
In reply to Abraham Samuel AdekunleWhen a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
--- drivers/staging/media/av7110/sp8870.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/media/av7110/sp8870.c +4 -6
@@ -508,12 +508,10 @@ static int sp8870_set_frontend(struct dvb_frontend *fe) }if (debug) { -if (valid) { -if (trials >1 ) { -pr_info ("%s(): firmware lockup!!!\n" , __func__); -pr_info ("%s(): recovered after %i trial(s))\n" , __func__, trials -1 ); - lockups++; - } +if (trials >1 ) { +pr_info ("%s(): firmware lockup!!!\n" , __func__); +pr_info ("%s(): recovered after %i trial(s))\n" , __func__, trials -1 ); + lockups++; } switches++;pr_info ("%s(): switches = %i lockups = %i\n" , __func__, switches, lockups);
Signature · 1 line
2.34.1
PATCH v2 3/3 staging: rtl8723bs: Prevent duplicate NULL tests on a value
In reply to Abraham Samuel AdekunleWhen a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/core/rtw_xmit.c | 56 +++++++++---------- 2 files changed, 28 insertions(+), 30 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1 -1
@@ -1323,7 +1323,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)spin_unlock_bh (&pstapriv->asoc_list_lock);/* now the station is qualified to join our BSS... */ -if (pstat && (pstat->state &WIFI_FW_ASSOC_SUCCESS ) && (status ==WLAN_STATUS_SUCCESS )) { +if ((pstat->state &WIFI_FW_ASSOC_SUCCESS ) && (status ==WLAN_STATUS_SUCCESS )) {/* 1 bss_cap_update & sta_info_update */ bss_cap_update_on_sta_join (padapter, pstat);sta_info_update (padapter, pstat);
drivers/staging/rtl8723bs/core/rtw_xmit.c +27 -29
62 lines not on this page · raw message
Signature · 1 line
2.34.1
Andy Shevchenko
maintainerRe: [PATCH v2 1/3] staging: media: Remove duplicate NULL tests on a value in pci
In reply to Abraham Samuel AdekunleQuoted 8 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
Missing period. And Subject should be as simple as
"media: atomisp: Remove ..."
...
Please, send this patch separately from the others.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andy Shevchenko
maintainerRe: [PATCH v2 2/3] staging: media: Remove duplicated NULL tests on a value in av7110
In reply to Abraham Samuel AdekunleQuoted 8 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
Missing period. And Subject should be like
"media: sp8870: Remove ..."
When in doubt, run
$ git log --oneline --no-merges -- $YOUR_FILE_OR_FILES
and look at the result. Use common sense and age and frequency of appearance for possible variants. The more recent and more often wins.
...
Code wise the change looks good now.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andy Shevchenko
maintainerRe: [PATCH v2 3/3] staging: rtl8723bs: Prevent duplicate NULL tests on a value
In reply to Abraham Samuel AdekunleQuoted 8 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
Missing period.
...
Quoted 13 lines
drivers/staging/rtl8723bs/core/rtw_xmit.c +13
-0+ psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; + psta->sta_xmitpriv.txseq_tid[pattrib->priority] &=0xFFF ; + pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; + +SetSeqNum (hdr, pattrib->seqnum); + +/* check if enable ampdu */ +if (pattrib->ht_en && psta->htpriv.ampdu_enable) +if (psta->htpriv.agg_enable_bitmap &BIT (pattrib->priority)) + pattrib->ampdu_en = true; + +/* re-check if enable ampdu by BA_starting_seqctrl */ +if (pattrib->ampdu_en == true) {
drivers/staging/rtl8723bs/core/rtw_xmit.c s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr · line 965
Quoted 10 lines
drivers/staging/rtl8723bs/core/rtw_xmit.c +9
-0+u16 tx_seq; + + tx_seq = psta->BA_starting_seqctrl[pattrib->priority &0x0f ]; + +/* check BA_starting_seqctrl */ +if (SN_LESS (pattrib->seqnum, tx_seq)) { + pattrib->ampdu_en = false;/* AGG BK */ + }else if (SN_EQUAL (pattrib->seqnum, tx_seq)) { + psta->BA_starting_seqctrl[pattrib->priority &0x0f ] = (tx_seq+1 )&0xfff ;
While at it, make this more readable:
psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq + 1) & 0xfff;
drivers/staging/rtl8723bs/core/rtw_xmit.c s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr · line 969
Quoted 4 lines
drivers/staging/rtl8723bs/core/rtw_xmit.c +3
-0+ pattrib->ampdu_en = true;/* AGG EN */ + }else { + psta->BA_starting_seqctrl[pattrib->priority &0x0f ] = (pattrib->seqnum+1 )&0xfff ;
Ditto.
Also consider to use module operator as it shows the exact amount of the records we support in the circular buffer.
psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum + 1) % 4096;
Since it's power-of-two denominator, it will be optimised by the compiler to the same code as it's now.
Quoted 2 lines
(quoted diff) +1
-0+ pattrib->ampdu_en = true;/* AGG EN */ }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Greg KH
maintainerRe: [PATCH v2 1/3] staging: media: Remove duplicate NULL tests on a value in pci
In reply to Abraham Samuel AdekunleQuoted 4 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Quoted 8 lines
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
Signed-off-by Abraham Samuel Adekunle <[email protected]>--- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +-
I can't take any drivers/staging/media/ changes for outreachy applications, sorry. That should have been in the instructions somewhere.
thanks,
greg k-h
Re: [PATCH v2 1/3] staging: media: Remove duplicate NULL tests on a value in pci
Hi,
Quoted 10 lines · Greg KH
Quoted 9 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
Quoted 7 lines
Quoted 3 lines
Signed-off-by Abraham Samuel Adekunle <[email protected]>--- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +-I can't take any
drivers/staging/media/changes for outreachy applications, sorry. That should have been in the instructions somewhere.
I don't know if this helps wrt outreachy but I can pick up this atomisp (and I plan to do so).
Regards,
Hans
Re: [PATCH v2 1/3] staging: media: Remove duplicate NULL tests on a value in pci
In reply to Andy ShevchenkoQuoted 13 lines · Andy Shevchenko
Quoted 8 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
Missing period. And Subject should be as simple as
Quoted 7 lines
"media: atomisp: Remove ..."
...
Please, send this patch separately from the others.
--
Thank you very much for your review
Unfortunately I have been told I cannot work on the media driver as an outreachy applicant.
I do appreciate your apparent reviews.
I will Cc your email when I apply your review to my rtl8723bs driver patch of the patchset.
Thanks
Adekunle
Re: [PATCH v2 3/3] staging: rtl8723bs: Prevent duplicate NULL tests on a value
In reply to Andy ShevchenkoQuoted 6 lines · Andy Shevchenko
Quoted 4 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Quoted 6 lines
Quoted 4 lines
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
Missing period.
Noted.
...
Quoted 15 lines
Quoted 1 line
+ psta->BA_starting_seqctrl[pattrib->priority &
0x0f] = (tx_seq+1)&0xfff;While at it, make this more readable:
psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq + 1) & 0xfff;drivers/staging/rtl8723bs/core/rtw_xmit.c s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr · line 969
Quoted 4 lines
drivers/staging/rtl8723bs/core/rtw_xmit.c +3
-0+ pattrib->ampdu_en = true;/* AGG EN */ + }else { + psta->BA_starting_seqctrl[pattrib->priority &0x0f ] = (pattrib->seqnum+1 )&0xfff ;Ditto.
Quoted 13 lines
Also consider to use module operator as it shows the exact amount of the records we support in the circular buffer.
psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum + 1) % 4096;Since it's power-of-two denominator, it will be optimised by the compiler to the same code as it's now.
Quoted 2 lines
+
pattrib->ampdu_en= true;/* AGG EN */}
Thank you very much for the review
I will send an updated Patchset
Adekunle
Re: [PATCH v2 1/3] staging: media: Remove duplicate NULL tests on a value in pci
In reply to Abraham Samuel AdekunleHi,
Quoted 10 lines · Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a second NULL test on the same value in another expression is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that has previously been NULL tested.
Found by Coccinelle
Signed-off-by Abraham Samuel Adekunle <[email protected]>
Thank you for your patch.
I have merged this in my media-atomisp branch:
https://git.kernel.org/pub/scm/linux/kernel/git/hansg/linux.git/log/?h=media-atomisp
And this patch will be included in my next pull-request to Mauro (to media subsystem maintainer)
Regards,
Hans
Quoted 17 lines
--- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1
-1@@ -1292,7 +1292,7 @@ static int gmin_get_config_dsm_var(struct device *dev,* if it founds something different than string, letting it * to fall back to the old code. */ -if (cur && cur->type !=ACPI_TYPE_STRING ) { +if (cur->type !=ACPI_TYPE_STRING ) {dev_info (dev,"found non-string _DSM entry for '%s'\n" , var);ACPI_FREE (obj);return -EINVAL ;