mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: LABBE Corentin <clabbe.montjoie@gmail.com>,
	mark.a.allyn@intel.com, jayant.mangalampalli@intel.com
Cc: gregkh@linuxfoundation.org, monamagarwal123@gmail.com,
	paul.gortmaker@windriver.com, jg1.han@samsung.com,
	paulmck@linux.vnet.ibm.com, valentina.manea.m@gmail.com,
	jack@suse.cz, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] staging: sep: No else is necessary after a break (reported by checkpatch)
Date: Sat, 19 Jul 2014 11:00:28 -0700	[thread overview]
Message-ID: <1405792828.14358.110.camel@joe-AO725> (raw)
In-Reply-To: <1405791282-28023-3-git-send-email-clabbe.montjoie@gmail.com>

(Adding Mark Allyn and Jayant Mangalampalli)

Is this still project still active?

On Sat, 2014-07-19 at 19:34 +0200, LABBE Corentin wrote:
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> ---
>  drivers/staging/sep/sep_main.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c
> index 177e4b9..1580d95f 100644
> --- a/drivers/staging/sep/sep_main.c
> +++ b/drivers/staging/sep/sep_main.c
> @@ -2881,12 +2881,11 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
>  				if (is_kva) {
>  					error = -ENODEV;
>  					break;
> -				} else {
> -					error_temp = copy_to_user(
> +				}
> +				error_temp = copy_to_user(
>  						(void __user *)tail_pt,
>  						dcb_table_ptr->tail_data,
>  						dcb_table_ptr->tail_data_size);
> -				}
>  				if (error_temp) {
>  					/* Release the DMA resource */
>  					error = -EFAULT;

It'd be probably be better to rewrite the code to unindent
a level by using continue.  Something like below:

btw:

the is_kva test looks very odd and should probably be
moved outside the loop.

pt_hold should probably be void * not unsigned long
as it loses high order bits on x86-32.

definition:
	aligned_u64 out_vr_tail_pt;
use:
+			pt_hold = (unsigned long)dcb_table_ptr->
+				out_vr_tail_pt;

---
 drivers/staging/sep/sep_main.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c
index 75ca15e..24b4a54 100644
--- a/drivers/staging/sep/sep_main.c
+++ b/drivers/staging/sep/sep_main.c
@@ -2871,26 +2871,23 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
 		 * Go over each DCB and see if
 		 * tail pointer must be updated
 		 */
-		for (i = 0; i < (*dma_ctx)->nr_dcb_creat;
-		     i++, dcb_table_ptr++) {
-			if (dcb_table_ptr->out_vr_tail_pt) {
-				pt_hold = (unsigned long)dcb_table_ptr->
-					out_vr_tail_pt;
-				tail_pt = (void *)pt_hold;
-				if (is_kva) {
-					error = -ENODEV;
-					break;
-				} else {
-					error_temp = copy_to_user(
-						(void __user *)tail_pt,
-						dcb_table_ptr->tail_data,
-						dcb_table_ptr->tail_data_size);
-				}
-				if (error_temp) {
-					/* Release the DMA resource */
-					error = -EFAULT;
-					break;
-				}
+		for (i = 0; i < (*dma_ctx)->nr_dcb_creat; i++, dcb_table_ptr++) {
+			if (!dcb_table_ptr->out_vr_tail_pt)
+				continue;
+			pt_hold = (unsigned long)dcb_table_ptr->
+				out_vr_tail_pt;
+			tail_pt = (void *)pt_hold;
+			if (is_kva) {
+				error = -ENODEV;
+				break;
+			}
+			error_temp = copy_to_user((void __user *)tail_pt,
+						  dcb_table_ptr->tail_data,
+						  dcb_table_ptr->tail_data_size);
+			if (error_temp) {
+				/* Release the DMA resource */
+				error = -EFAULT;
+				break;
 			}
 		}
 	}



  reply	other threads:[~2014-07-19 18:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-19 17:34 [PATCH] staging: sep: Fix issues reported by checkpatch LABBE Corentin
2014-07-19 17:34 ` [PATCH 1/4] staging: sep: Solves some problems " LABBE Corentin
2014-07-21 19:19   ` Greg KH
2014-07-19 17:34 ` [PATCH 2/4] staging: sep: No else is necessary after a break (reported by checkpatch) LABBE Corentin
2014-07-19 18:00   ` Joe Perches [this message]
2014-07-20  6:39     ` Corentin LABBE
2014-07-19 17:34 ` [PATCH 3/4] staging: sep: Fix misceanellous problems reported by checkpatch LABBE Corentin
2014-07-19 17:34 ` [PATCH 4/4] staging: sep: Fix blank lines issue " LABBE Corentin

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=1405792828.14358.110.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=clabbe.montjoie@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=jayant.mangalampalli@intel.com \
    --cc=jg1.han@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.a.allyn@intel.com \
    --cc=monamagarwal123@gmail.com \
    --cc=paul.gortmaker@windriver.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=valentina.manea.m@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

all inboxes | Powered by JetHome®