* [PATCH 1/2] staging: dgnc: remove dead code in dgnc_tty_write()
@ 2015-04-05 23:16 Giedrius Statkevicius
2015-04-05 23:16 ` [PATCH 2/2] staging: dgnc: remove redundant check Giedrius Statkevicius
2015-04-05 23:28 ` [PATCH 1/2] staging: dgnc: remove dead code in dgnc_tty_write() Giedrius Statkevičius
0 siblings, 2 replies; 4+ messages in thread
From: Giedrius Statkevicius @ 2015-04-05 23:16 UTC (permalink / raw)
To: lidza.louina, markh
Cc: gregkh, driverdev-devel, devel, linux-kernel, Giedrius Statkevičius
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
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/2] staging: dgnc: remove redundant check
2015-04-05 23:16 [PATCH 1/2] staging: dgnc: remove dead code in dgnc_tty_write() Giedrius Statkevicius
@ 2015-04-05 23:16 ` Giedrius Statkevicius
2015-04-05 23:28 ` [PATCH 1/2] staging: dgnc: remove dead code in dgnc_tty_write() Giedrius Statkevičius
1 sibling, 0 replies; 4+ messages in thread
From: Giedrius Statkevicius @ 2015-04-05 23:16 UTC (permalink / raw)
To: lidza.louina, markh
Cc: gregkh, driverdev-devel, devel, linux-kernel, Giedrius Statkevičius
count doesn't get changed in between identical checks in dgnc_tty_write() so
remove the second check
Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
---
v2: no change
drivers/staging/dgnc/dgnc_tty.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index cf2eb21..61d5a8e 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1773,12 +1773,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
ch->ch_flags &= ~CH_PRON;
}
- /*
- * If there is nothing left to copy, or I can't handle any more data, leave.
- */
- if (count <= 0)
- goto exit_retry;
-
n = count;
/*
--
2.3.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] staging: dgnc: remove dead code in dgnc_tty_write()
2015-04-05 23:16 [PATCH 1/2] staging: dgnc: remove dead code in dgnc_tty_write() Giedrius Statkevicius
2015-04-05 23:16 ` [PATCH 2/2] staging: dgnc: remove redundant check Giedrius Statkevicius
@ 2015-04-05 23:28 ` Giedrius Statkevičius
2015-04-10 13:24 ` Greg KH
1 sibling, 1 reply; 4+ messages in thread
From: Giedrius Statkevičius @ 2015-04-05 23:28 UTC (permalink / raw)
To: Giedrius Statkevicius
Cc: lidza.louina, markh, gregkh, driverdev-devel, devel, linux-kernel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 2916 bytes --]
Forgot to put "v2" in the title. Should I resend? Sorry for the confusion. Still
making some patch submitting mistakes from time to time. :(
On Mon, 6 Apr 2015, Giedrius Statkevicius 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.
>
> 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
>
>
Su pagarba / Regards,
Giedrius
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-10 13:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-05 23:16 [PATCH 1/2] staging: dgnc: remove dead code in dgnc_tty_write() Giedrius Statkevicius
2015-04-05 23:16 ` [PATCH 2/2] staging: dgnc: remove redundant check Giedrius Statkevicius
2015-04-05 23:28 ` [PATCH 1/2] staging: dgnc: remove dead code in dgnc_tty_write() Giedrius Statkevičius
2015-04-10 13:24 ` Greg KH
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®