lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AC9522804BA5F115+20250815013658.GB1129045@nic-Precision-5820-Tower>
Date: Fri, 15 Aug 2025 09:36:58 +0800
From: Yibo Dong <dong100@...se.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: Vadim Fedorenko <vadim.fedorenko@...ux.dev>, andrew+netdev@...n.ch,
	davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
	pabeni@...hat.com, horms@...nel.org, corbet@....net,
	gur.stavi@...wei.com, maddy@...ux.ibm.com, mpe@...erman.id.au,
	danishanwar@...com, lee@...ger.us, gongfan1@...wei.com,
	lorenzo@...nel.org, geert+renesas@...der.be,
	Parthiban.Veerasooran@...rochip.com, lukas.bulwahn@...hat.com,
	alexanderduyck@...com, richardcochran@...il.com,
	netdev@...r.kernel.org, linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 4/5] net: rnpgbe: Add basic mbx_fw support

On Fri, Aug 15, 2025 at 02:04:57AM +0200, Andrew Lunn wrote:
> > If it is more cleaner bellow?
> > 
> > static int mucse_fw_send_cmd_wait(struct mucse_hw *hw,
> >                                   struct mbx_fw_cmd_req *req,
> >                                   struct mbx_fw_cmd_reply *reply)
> > {
> >         int len = le16_to_cpu(req->datalen) + MBX_REQ_HDR_LEN;
> >         int retry_cnt = 3;
> >         int err;
> > 
> >         err = mutex_lock_interruptible(&hw->mbx.lock);
> >         if (err)
> >                 return err;
> >         err = hw->mbx.ops->write_posted(hw, (u32 *)req,
> >                                         L_WD(len));
> >         if (err)
> >                 goto quit;
> >         do {
> >                 err = hw->mbx.ops->read_posted(hw, (u32 *)reply,
> >                                                L_WD(sizeof(*reply)));
> >                 if (err)
> >                         goto quit;
> >         } while (--retry_cnt >= 0 && reply->opcode != req->opcode);
> > 
> >         mutex_unlock(&hw->mbx.lock);
> >         if (retry_cnt < 0)
> >                 return -ETIMEDOUT;
> >         if (reply->error_code)
> >                 return -EIO;
> >         return 0;
> > quit:
> >         mutex_unlock(&hw->mbx.lock);
> >         return err;
> > }
> 
> You might want a read a few other drivers in mailine. Look at the
> naming. I doubt you will find many using "quit" for a label. "out" or
> "unlock" is more popular.
> 
> When it comes to locks, it is better to have one lock statement and
> one unlock statement. It then becomes easy to see all paths lead to
> the unlock.
> 
> 	Andrew
> 

Got it, I will change label 'quit' to 'out'.
And I will try to keep 'one lock statement and one unlock statement'
principle in mind.

Thanks for your feedback.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ