linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Tomer Samara <tomersamara98@gmail.com>, gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rts5208: clear alignment style issues
Date: Sat, 01 Aug 2020 18:44:37 -0700	[thread overview]
Message-ID: <f8dd21b5000d4def1de9e79f32433f22da5b33d7.camel@perches.com> (raw)
In-Reply-To: <20200801210056.GA305272@tsnow>

On Sun, 2020-08-02 at 00:00 +0300, Tomer Samara wrote:
>   Clear checkpatch alignment style issues in rtsx_transport.c.
>   CHECK: Alignment should match open parenthesis
[]
> diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
[]
> @@ -678,7 +678,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,
>  
>  	/* Wait for TRANS_OK_INT */
>  	timeleft = wait_for_completion_interruptible_timeout(&trans_done,
> -			msecs_to_jiffies(timeout));
> +							     msecs_to_jiffies(timeout));
>  	if (timeleft <= 0) {
>  		dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
>  			__func__, __LINE__);

Always try to improve the code rather than just
shut up checkpatch warnings.

Perhaps it's more sensible to centralize the uses of
wait_for_completion_interruptible_timeout.

Something like:
---
 drivers/staging/rts5208/rtsx_transport.c | 36 +++++++++++++-------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 5f1eefe80f1e..269ff1be7cba 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -222,12 +222,18 @@ void rtsx_send_cmd_no_wait(struct rtsx_chip *chip)
 	rtsx_writel(chip, RTSX_HCBCTLR, val);
 }
 
+static inline bool rtsx_wait(struct completion *comp, int timeout)
+{
+	unsigned long t = msecs_to_jiffies(timeout);
+
+	return wait_for_completion_interruptible_timeout(comp, t) > 0;
+}
+
 int rtsx_send_cmd(struct rtsx_chip *chip, u8 card, int timeout)
 {
 	struct rtsx_dev *rtsx = chip->rtsx;
 	struct completion trans_done;
 	u32 val = BIT(31);
-	long timeleft;
 	int err = 0;
 
 	if (card == SD_CARD)
@@ -257,9 +263,8 @@ int rtsx_send_cmd(struct rtsx_chip *chip, u8 card, int timeout)
 	spin_unlock_irq(&rtsx->reg_lock);
 
 	/* Wait for TRANS_OK_INT */
-	timeleft = wait_for_completion_interruptible_timeout(
-		&trans_done, msecs_to_jiffies(timeout));
-	if (timeleft <= 0) {
+
+	if (!rtsx_wait(&trans_done, timeout)) {
 		dev_dbg(rtsx_dev(chip), "chip->int_reg = 0x%x\n",
 			chip->int_reg);
 		err = -ETIMEDOUT;
@@ -322,7 +327,6 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,
 	u8 dir;
 	int sg_cnt, i, resid;
 	int err = 0;
-	long timeleft;
 	struct scatterlist *sg_ptr;
 	u32 val = TRIG_DMA;
 
@@ -419,9 +423,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,
 
 	spin_unlock_irq(&rtsx->reg_lock);
 
-	timeleft = wait_for_completion_interruptible_timeout(
-		&trans_done, msecs_to_jiffies(timeout));
-	if (timeleft <= 0) {
+	if (!rtsx_wait(&trans_done, timeout)) {
 		dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
 			__func__, __LINE__);
 		dev_dbg(rtsx_dev(chip), "chip->int_reg = 0x%x\n",
@@ -443,9 +445,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,
 	if (rtsx->trans_result == TRANS_NOT_READY) {
 		init_completion(&trans_done);
 		spin_unlock_irq(&rtsx->reg_lock);
-		timeleft = wait_for_completion_interruptible_timeout(
-			&trans_done, msecs_to_jiffies(timeout));
-		if (timeleft <= 0) {
+		if (!rtsx_wait(&trans_done, timeout)) {
 			dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
 				__func__, __LINE__);
 			dev_dbg(rtsx_dev(chip), "chip->int_reg = 0x%x\n",
@@ -486,7 +486,6 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,
 	u8 dir;
 	int buf_cnt, i;
 	int err = 0;
-	long timeleft;
 	struct scatterlist *sg_ptr;
 
 	if (!sg || (num_sg <= 0))
@@ -563,9 +562,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,
 
 		spin_unlock_irq(&rtsx->reg_lock);
 
-		timeleft = wait_for_completion_interruptible_timeout(
-			&trans_done, msecs_to_jiffies(timeout));
-		if (timeleft <= 0) {
+		if (!rtsx_wait(&trans_done, timeout)) {
 			dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
 				__func__, __LINE__);
 			dev_dbg(rtsx_dev(chip), "chip->int_reg = 0x%x\n",
@@ -590,9 +587,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,
 	if (rtsx->trans_result == TRANS_NOT_READY) {
 		init_completion(&trans_done);
 		spin_unlock_irq(&rtsx->reg_lock);
-		timeleft = wait_for_completion_interruptible_timeout(
-			&trans_done, msecs_to_jiffies(timeout));
-		if (timeleft <= 0) {
+		if (!rtsx_wait(&trans_done, timeout)) {
 			dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
 				__func__, __LINE__);
 			dev_dbg(rtsx_dev(chip), "chip->int_reg = 0x%x\n",
@@ -633,7 +628,6 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,
 	u8 dir;
 	int err = 0;
 	u32 val = BIT(31);
-	long timeleft;
 
 	if (!buf || (len <= 0))
 		return -EIO;
@@ -677,9 +671,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,
 	spin_unlock_irq(&rtsx->reg_lock);
 
 	/* Wait for TRANS_OK_INT */
-	timeleft = wait_for_completion_interruptible_timeout(&trans_done,
-			msecs_to_jiffies(timeout));
-	if (timeleft <= 0) {
+	if (!rtsx_wait(&trans_done, timeout)) {
 		dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n",
 			__func__, __LINE__);
 		dev_dbg(rtsx_dev(chip), "chip->int_reg = 0x%x\n",



      reply	other threads:[~2020-08-02  1:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-01 21:00 [PATCH] staging: rts5208: clear alignment style issues Tomer Samara
2020-08-02  1:44 ` Joe Perches [this message]

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=f8dd21b5000d4def1de9e79f32433f22da5b33d7.camel@perches.com \
    --to=joe@perches.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tomersamara98@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).