From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04A113FC2 for ; Sun, 29 Aug 2021 23:18:28 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id v20-20020a1cf714000000b002e71f4d2026so10462000wmh.1 for ; Sun, 29 Aug 2021 16:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philpotter-co-uk.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rtP9/zqwMm5tTi+7Rao14dM7+IS9AMZy0vyNq2TuYYg=; b=i82vexUq47GpjKiBP1yTgSBfqEswshCxCsLfDix784nRKpCiGif/YqkuNI5Dn6TBOM x1HsTZjZlptPJu/37VbeZ5Ht7WYhRLHEsBt6eSIxbeDpxkmpVEP9JcBTmwqnNJxcsf9s 3B2jCu0NpADQpZApfW/VVAPiQgwrEdI4GSNBw2dlXIsbzT5IMbZjhDaNt/C/MRXPrITr thyEOBxlT1h9AqM8aoTBMpSQWqXHZC/tuoZjbPCwxaLGZM4bfAA4BkN/gCJ9Qm3szVrn WL/EIKeOZol7V8p0SY1n3FSen5G4SsDMn1lo37LwbDVG2EGdnudsGV+Zg5WlKAs6Dyrp 6GEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rtP9/zqwMm5tTi+7Rao14dM7+IS9AMZy0vyNq2TuYYg=; b=Qd/LxUDZlHHx+igICHhsY0xfbJSDdQ3AqpQ3t4Gc7XTyhWph3LvR/stG+tU5CTQvAA KWtozlGLKHnjkyICEeTvopKqAXBpOabEOPYr/dfRIPY4mg60br+YFJDAQmeocujIrYKS wY6wzigu4lOk2q65ZBbfxIb6/wI46P8Eb6PbBOefSvjeC3LDSU8h4TxX9Znj2nLtCWy2 XHOhpfmHVD7irT4hkendv6FYgPQqbZkFkx3iGwbdIexTCTPrS7l+UKL9M9PO06bJTBKa GJ5ddYwGHg8BOZFPaBOvSsmyEx+PRIQK1bWk5ahS0g392iCmzc5py5w1EilYfMEJyGpu W/CA== X-Gm-Message-State: AOAM532DHiR/KvdgDcQFdzN33/j0MsjFQ/KyOO5n0FLOrsMqmzsheQUO jX91R4OHnX18NI1XAGv7rLvyJQ== X-Google-Smtp-Source: ABdhPJwtPAQZpsaldUXKdEeFQGoUq30/MRNwOnkvqhrgAZdCqeCG1vfVgjMn/HMiUMkaJIOPyOnlng== X-Received: by 2002:a7b:c0c7:: with SMTP id s7mr18747339wmh.66.1630279107175; Sun, 29 Aug 2021 16:18:27 -0700 (PDT) Received: from equinox (2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.1.e.e.d.f.d.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:dfde:e1a0::2]) by smtp.gmail.com with ESMTPSA id y11sm16515082wru.0.2021.08.29.16.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Aug 2021 16:18:26 -0700 (PDT) Date: Mon, 30 Aug 2021 00:18:24 +0100 From: Phillip Potter To: Pavel Skripkin Cc: gregkh@linuxfoundation.org, straube.linux@gmail.com, fmdefrancesco@gmail.com, Larry.Finger@lwfinger.net, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] staging: r8188eu: simplify c2h_evt_hdl function Message-ID: References: <20210828212453.898-1-phil@philpotter.co.uk> <20210828212453.898-3-phil@philpotter.co.uk> <19b08be7-964e-fdbc-93c8-825ad41e1ade@gmail.com> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19b08be7-964e-fdbc-93c8-825ad41e1ade@gmail.com> On Sun, Aug 29, 2021 at 02:54:14PM +0300, Pavel Skripkin wrote: > On 8/29/21 12:24 AM, Phillip Potter wrote: > > Simplify c2h_evt_hdl function by removing majority of its code. The > > function always returns _FAIL anyway, due to the wrapper function it > > calls always returning _FAIL. For this reason, it is better to just > > return _FAIL directly. > > > > Leave the call to c2h_evt_read in place, as without it, event handling > > semantics of the driver would be changed, despite nothing actually being > > done with the event. > > > > Signed-off-by: Phillip Potter > > --- > > drivers/staging/r8188eu/core/rtw_cmd.c | 21 +++------------------ > > 1 file changed, 3 insertions(+), 18 deletions(-) > > > > diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c > > index ce73ac7cf973..b520c6b43c03 100644 > > --- a/drivers/staging/r8188eu/core/rtw_cmd.c > > +++ b/drivers/staging/r8188eu/core/rtw_cmd.c > > @@ -1854,27 +1854,12 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt) > > static s32 c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter) > > { > > - s32 ret = _FAIL; > > u8 buf[16]; > > - if (!c2h_evt) { > > - /* No c2h event in cmd_obj, read c2h event before handling*/ > > - if (c2h_evt_read(adapter, buf) == _SUCCESS) { > > - c2h_evt = (struct c2h_evt_hdr *)buf; > > + if (!c2h_evt) > > + c2h_evt_read(adapter, buf); > > - if (filter && !filter(c2h_evt->id)) > > - goto exit; > > - > > - ret = rtw_hal_c2h_handler(adapter, c2h_evt); > > - } > > - } else { > > - if (filter && !filter(c2h_evt->id)) > > - goto exit; > > - > > - ret = rtw_hal_c2h_handler(adapter, c2h_evt); > > - } > > -exit: > > - return ret; > > + return _FAIL; > > > Hi, Phillip! > > > Do we really need to return _FAIL every time? The only one caller of > c2h_evt_hdl() does not rely on it's return value. Shouldn't we make this > function return void to simplify the code? Dear Pavel, Thanks for the review. Good point on the return type, I'll publish a v2 series. > > > BTW, this function does nothing now, as I understand. It reads to local > buffer and returns. I think, it can be removed > > > > > } > > static void c2h_wk_callback(struct work_struct *work) > > Not sure if you're referring to c2h_wk_callback or c2h_evt_hdl, but either way, they both call (indirectly or otherwise) c2h_evt_read and c2h_evt_clear as well as rtw_c2h_wk_cmd in the case of c2h_wk_callback. To just delete them wholesale therefore would be unsafe I think, due to the effect on event semantics. Certainly, it is possible to handle this c2h stuff by just reading from register and ignoring though - another series is a better place for that though I think. Admittedly, I may be talking nonsense here :-) Regards, Phil