public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: "Giedrius Statkevičius" <giedrius.statkevicius@gmail.com>
Cc: lidza.louina@gmail.com, markh@compro.net,
	gregkh@linuxfoundation.org,
	driverdev-devel@linuxdriverproject.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2 RESEND] staging: dgnc: remove dead code in dgnc_tty_write()
Date: Sat, 11 Apr 2015 10:21:44 +0530	[thread overview]
Message-ID: <20150411045144.GA3496@sudip-PC> (raw)
In-Reply-To: <1428677335-6853-1-git-send-email-giedrius.statkevicius@gmail.com>

On Fri, Apr 10, 2015 at 05:48:54PM +0300, Giedrius Statkevičius wrote:
> 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.
dgnc_tty_write() is being called by dgnc_tty_put_char() and it is also
the write callback function of struct tty_operations, so I think the
correct fix will be to use from_user and make it 0 when
dgnc_tty_put_char() calls this function else make it 1 to inform the
function that the data wil be coming from the userspace. Maybe some
thing like this:

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index ce4187f..96eaf5b 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1682,10 +1682,15 @@ static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c)
 	/*
 	 * Simply call tty_write.
 	 */
-	dgnc_tty_write(tty, &c, 1);
+	__dgnc_tty_write(tty, &c, 1, 0);
 	return 1;
 }
 
+static int dgnc_tty_write(struct tty_struct *tty,
+		const unsigned char *buf, int count)
+{
+	__dgnc_tty_write(tty, buf, count, 1);
+}
 
 /*
  * dgnc_tty_write()
@@ -1693,8 +1698,8 @@ static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c)
  * Take data from the user or kernel and send it out to the FEP.
  * In here exists all the Transparent Print magic as well.
  */
-static int dgnc_tty_write(struct tty_struct *tty,
-		const unsigned char *buf, int count)
+static int __dgnc_tty_write(struct tty_struct *tty,
+		const unsigned char *buf, int count, int from_user)
 {
 	struct channel_t *ch = NULL;
 	struct un_t *un = NULL;
@@ -1705,7 +1710,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;


regards
sudip

  parent reply	other threads:[~2015-04-11  4:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-10 14:48 [PATCH v2 1/2 RESEND] staging: dgnc: remove dead code in dgnc_tty_write() Giedrius Statkevičius
2015-04-10 14:48 ` [PATCH v2 2/2 RESEND] staging: dgnc: remove redundant check Giedrius Statkevičius
2015-04-11  4:51 ` Sudip Mukherjee [this message]
2015-04-11 12:20   ` [PATCH v2 1/2 RESEND] staging: dgnc: remove dead code in dgnc_tty_write() 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=20150411045144.GA3496@sudip-PC \
    --to=sudipm.mukherjee@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=giedrius.statkevicius@gmail.com \
    --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