public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Giedrius Statkevičius" <giedrius.statkevicius@gmail.com>
To: lidza.louina@gmail.com, markh@compro.net
Cc: gregkh@linuxfoundation.org,
	driverdev-devel@linuxdriverproject.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	"Giedrius Statkevičius" <giedrius.statkevicius@gmail.com>
Subject: [PATCH v2 1/2 RESEND] staging: dgnc: remove dead code in dgnc_tty_write()
Date: Fri, 10 Apr 2015 17:48:54 +0300	[thread overview]
Message-ID: <1428677335-6853-1-git-send-email-giedrius.statkevicius@gmail.com> (raw)

Remove the dead code protected by in_user in dgnc_tty_write() because it is set
to 0 and never changed to 1 thus the code in ifs never gets executed.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
---
v2: Just remove the dead code protected by in_user and join the first and third
patches.

 drivers/staging/dgnc/dgnc_tty.c | 45 +----------------------------------------
 1 file changed, 1 insertion(+), 44 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index ce4187f..cf2eb21 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -42,16 +42,11 @@
 #include "dgnc_sysfs.h"
 #include "dgnc_utils.h"
 
-#define init_MUTEX(sem)	 sema_init(sem, 1)
-#define DECLARE_MUTEX(name)     \
-	struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-
 /*
  * internal variables
  */
 static struct dgnc_board	*dgnc_BoardsByMajor[256];
 static unsigned char		*dgnc_TmpWriteBuf;
-static DECLARE_MUTEX(dgnc_TmpWriteSem);
 
 /*
  * Default transparent print information.
@@ -1705,7 +1700,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
 	ushort tail;
 	ushort tmask;
 	uint remain;
-	int from_user = 0;
 
 	if (tty == NULL || dgnc_TmpWriteBuf == NULL)
 		return 0;
@@ -1785,38 +1779,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
 	if (count <= 0)
 		goto exit_retry;
 
-	if (from_user) {
-
-		count = min(count, WRITEBUFLEN);
-
-		spin_unlock_irqrestore(&ch->ch_lock, flags);
-
-		/*
-		 * If data is coming from user space, copy it into a temporary
-		 * buffer so we don't get swapped out while doing the copy to
-		 * the board.
-		 */
-		/* we're allowed to block if it's from_user */
-		if (down_interruptible(&dgnc_TmpWriteSem))
-			return -EINTR;
-
-		/*
-		 * copy_from_user() returns the number
-		 * of bytes that could *NOT* be copied.
-		 */
-		count -= copy_from_user(dgnc_TmpWriteBuf, (const unsigned char __user *) buf, count);
-
-		if (!count) {
-			up(&dgnc_TmpWriteSem);
-			return -EFAULT;
-		}
-
-		spin_lock_irqsave(&ch->ch_lock, flags);
-
-		buf = dgnc_TmpWriteBuf;
-
-	}
-
 	n = count;
 
 	/*
@@ -1853,12 +1815,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
 		ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps;
 	}
 
-	if (from_user) {
-		spin_unlock_irqrestore(&ch->ch_lock, flags);
-		up(&dgnc_TmpWriteSem);
-	} else {
-		spin_unlock_irqrestore(&ch->ch_lock, flags);
-	}
+	spin_unlock_irqrestore(&ch->ch_lock, flags);
 
 	if (count) {
 		/*
-- 
2.3.5


             reply	other threads:[~2015-04-10 14:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-10 14:48 Giedrius Statkevičius [this message]
2015-04-10 14:48 ` [PATCH v2 2/2 RESEND] staging: dgnc: remove redundant check Giedrius Statkevičius
2015-04-11  4:51 ` [PATCH v2 1/2 RESEND] staging: dgnc: remove dead code in dgnc_tty_write() Sudip Mukherjee
2015-04-11 12:20   ` Giedrius Statkevičius
2015-04-11 12:59     ` Sudip Mukherjee
2015-05-03 18:49 ` Greg KH

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=1428677335-6853-1-git-send-email-giedrius.statkevicius@gmail.com \
    --to=giedrius.statkevicius@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lidza.louina@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markh@compro.net \
    /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