Re: [PATCH v2 2/2] staging: rtl8723bs: Initializing variables at declaration
Erick Karanja <[email protected]> Thu, 10 Apr 2025 08:39:47 +0300
| Newsgroups | dev.linux.lists.outreachy,dev.linux.lists.linux-staging,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2025-04-09 at 11:41 -0400, Julia Lawall wrote: >=20 >=20 > On Wed, 9 Apr 2025, Erick Karanja wrote: >=20 > > Make the code more readable by moving trivial > > initializations up with the declarations instead > > of wasting a line on that. > >=20 > > Signed-off-by: Erick Karanja <[email protected]> > > --- > > =C2=A0.../staging/rtl8723bs/hal/rtl8723bs_xmit.c=C2=A0=C2=A0=C2=A0 | 39= ++++++--------- > > ---- > > =C2=A01 file changed, 11 insertions(+), 28 deletions(-) > >=20 > > diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c > > b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c > > index 5dc1c12fe03e..d134d185bfae 100644 > > --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c > > +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c > > @@ -120,13 +120,10 @@ static s32 rtl8723_dequeue_writeport(struct > > adapter *padapter) > > =C2=A0 */ > > =C2=A0s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter) > > =C2=A0{ > > - struct xmit_priv *pxmitpriv; > > + struct xmit_priv *pxmitpriv =3D &padapter->xmitpriv; > > =C2=A0 u8 queue_empty, queue_pending; > > =C2=A0 s32 ret; > >=20 > > - > > - pxmitpriv =3D &padapter->xmitpriv; > > - > > =C2=A0 if (wait_for_completion_interruptible(&pxmitpriv- > > >xmit_comp)) { > > =C2=A0 netdev_emerg(padapter->pnetdev, > > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 "%s: down SdioXmitBufSema fail!\n", > > __func__); > > @@ -242,8 +239,7 @@ static s32 xmit_xmitframes(struct adapter > > *padapter, struct xmit_priv *pxmitpriv > > =C2=A0 /* pxmitbuf- > > >priv_data will be NULL, and will crash here */ > > =C2=A0 if (pxmitbuf->len > > > 0 && > > =C2=A0 =C2=A0=C2=A0=C2=A0 pxmitbuf- > > >priv_data) { > > - struct > > xmit_frame *pframe; > > - pframe =3D > > (struct xmit_frame *)pxmitbuf->priv_data; > > + struct > > xmit_frame *pframe =3D (struct xmit_frame *)pxmitbuf->priv_data; >=20 > I'm not sure that it's worth making this change here given that it > makes > the line even longer. Hello Julia. I will make the necessary changes. Thank you. >=20 > > =C2=A0 pframe- > > >agg_num =3D k; > > =C2=A0 pxmitbuf- > > >agg_num =3D k; > > =C2=A0 rtl8723b_u > > pdate_txdesc(pframe, pframe->buf_addr); > > @@ -326,8 +322,7 @@ static s32 xmit_xmitframes(struct adapter > > *padapter, struct xmit_priv *pxmitpriv > > =C2=A0 /*=C2=A0 dump xmit_buf to hw tx fifo */ > > =C2=A0 if (pxmitbuf) { > > =C2=A0 if (pxmitbuf->len > 0) { > > - struct xmit_frame *pframe; > > - pframe =3D (struct xmit_frame > > *)pxmitbuf->priv_data; > > + struct xmit_frame *pframe =3D > > (struct xmit_frame *)pxmitbuf->priv_data; >=20 > This also makes a long line. >=20 > > =C2=A0 pframe->agg_num =3D k; > > =C2=A0 pxmitbuf->agg_num =3D k; > > =C2=A0 rtl8723b_update_txdesc(pframe, > > pframe->buf_addr); > > @@ -357,12 +352,9 @@ static s32 xmit_xmitframes(struct adapter > > *padapter, struct xmit_priv *pxmitpriv > > =C2=A0 */ > > =C2=A0static s32 rtl8723bs_xmit_handler(struct adapter *padapter) > > =C2=A0{ > > - struct xmit_priv *pxmitpriv; > > + struct xmit_priv *pxmitpriv =3D &padapter->xmitpriv; > > =C2=A0 s32 ret; > >=20 > > - > > - pxmitpriv =3D &padapter->xmitpriv; > > - > > =C2=A0 if (wait_for_completion_interruptible(&pxmitpriv- > > >SdioXmitStart)) { > > =C2=A0 netdev_emerg(padapter->pnetdev, "%s: SdioXmitStart > > fail!\n", > > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 __func__); > > @@ -408,13 +400,9 @@ static s32 rtl8723bs_xmit_handler(struct > > adapter *padapter) > >=20 > > =C2=A0int rtl8723bs_xmit_thread(void *context) > > =C2=A0{ > > - s32 ret; > > - struct adapter *padapter; > > - struct xmit_priv *pxmitpriv; > > - > > - ret =3D _SUCCESS; > > - padapter =3D context; > > - pxmitpriv =3D &padapter->xmitpriv; > > + s32 ret =3D _SUCCESS; > > + struct adapter *padapter =3D context; > > + struct xmit_priv *pxmitpriv =3D &padapter->xmitpriv; > >=20 > > =C2=A0 allow_signal(SIGTERM); > >=20 > > @@ -435,16 +423,13 @@ s32 rtl8723bs_mgnt_xmit( > > =C2=A0) > > =C2=A0{ > > =C2=A0 s32 ret =3D _SUCCESS; > > - struct pkt_attrib *pattrib; > > - struct xmit_buf *pxmitbuf; > > + struct pkt_attrib *pattrib =3D &pmgntframe->attrib; > > + struct xmit_buf *pxmitbuf =3D pmgntframe->pxmitbuf; > > =C2=A0 struct xmit_priv *pxmitpriv =3D &padapter->xmitpriv; > > =C2=A0 struct dvobj_priv *pdvobjpriv =3D > > adapter_to_dvobj(padapter); > > =C2=A0 u8 *pframe =3D (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; > > =C2=A0 u8 txdesc_size =3D TXDESC_SIZE; > >=20 > > - pattrib =3D &pmgntframe->attrib; > > - pxmitbuf =3D pmgntframe->pxmitbuf; > > - > > =C2=A0 rtl8723b_update_txdesc(pmgntframe, pmgntframe->buf_addr); > >=20 > > =C2=A0 pxmitbuf->len =3D txdesc_size + pattrib->last_txcmdsz; > > @@ -557,15 +542,13 @@ s32 rtl8723bs_init_xmit_priv(struct adapter > > *padapter) > >=20 > > =C2=A0void rtl8723bs_free_xmit_priv(struct adapter *padapter) > > =C2=A0{ > > - struct xmit_priv *pxmitpriv; > > + struct xmit_priv *pxmitpriv =3D &padapter->xmitpriv; > > =C2=A0 struct xmit_buf *pxmitbuf; > > - struct __queue *pqueue; > > + struct __queue *pqueue =3D &pxmitpriv- > > >pending_xmitbuf_queue; > > =C2=A0 struct list_head *plist, *phead; > > =C2=A0 struct list_head tmplist; > >=20 > >=20 > > - pxmitpriv =3D &padapter->xmitpriv; > > - pqueue =3D &pxmitpriv->pending_xmitbuf_queue; > > =C2=A0 phead =3D get_list_head(pqueue); > > =C2=A0 INIT_LIST_HEAD(&tmplist); > >=20 > > -- > > 2.43.0 > >=20 > >=20 > >=20