All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: 'Martin Kaiser' <martin@kaiser.cx>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Larry Finger <Larry.Finger@lwfinger.net>,
	Phillip Potter <phil@philpotter.co.uk>,
	Michael Straube <straube.linux@gmail.com>,
	"linux-staging@lists.linux.dev" <linux-staging@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging: r8188eu: remove local BIT macro
Date: Mon, 21 Mar 2022 12:06:48 +0300	[thread overview]
Message-ID: <20220321090648.GH3293@kadam> (raw)
In-Reply-To: <ac3343ea279b4d048d77b3cf2724bcbe@AcuMS.aculab.com>

On Sat, Mar 19, 2022 at 10:35:58PM +0000, David Laight wrote:
> OTOH this code is a big pile of poo.
> Abstraction functions gone mad.

Yeah.

I wrote an email similar to yours and I even wrote some sample code.
But then I deleted it because I don't pay Martin anything so I'm just
grateful for what he sends and can't reasonably ask for more.

This code constantly amazes me with how many abstractions there are.
Martin keeps deleting them, and I think he's going to run out but so
far that hasn't happened.

Anyway here is the diff just for laughs since you brought it up.  Not
something that's necessarry and definitely not a priority.

I don't really like enable/disable functions that do opposite things
depending on if true/false is passed as a parameter.  They're normally
more readable split apart.

Ideally there would be adapter_to_pdbm() and adapter_to_podm() helper
functions.

diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c
index 665b077190bc..d973cf341031 100644
--- a/drivers/staging/r8188eu/core/rtw_wlan_util.c
+++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c
@@ -276,12 +276,23 @@ void Restore_DM_Func_Flag(struct adapter *padapter)
 	SetHwReg8188EU(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag));
 }
 
+void enable_dm_func(struct adapter *padapter, u32 mode)
+ {
+	struct dm_pri *pdmpriv = adapter_to_pdbm(padapter);
+	struct odm_dm_struct *podmpriv = adapter_to_pod(padapter);
+
+	if (mode == DYNAMIC_ALL_FUNC_ENABLE) {
+		podmpriv->SupportAbility = pdmpriv->InitODMFlag;
+	} else {
+		podmpriv->SupportAbility |= mode;
+	}
+}
+
+void disable_dm_func(struct adapter *padapter, u32 mode)
+{
+	struct odm_dm_struct *podmpriv = adapter_to_pod(padapter);
+
+	podmpriv->SupportAbility &= mode;
+ }

regards,
dan carpenter


  reply	other threads:[~2022-03-21  9:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-19 18:03 [PATCH] staging: r8188eu: remove local BIT macro Martin Kaiser
2022-03-19 22:35 ` David Laight
2022-03-21  9:06   ` Dan Carpenter [this message]
2022-03-21  9:14     ` David Laight
2022-03-21  9:34   ` Martin Kaiser
2022-03-21  8:15 ` Dan Carpenter
2022-03-21  9:04   ` David Laight
2022-03-21  9:07     ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220321090648.GH3293@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=Larry.Finger@lwfinger.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=martin@kaiser.cx \
    --cc=phil@philpotter.co.uk \
    --cc=straube.linux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.