Skip to contentSkip to conversation

staging: dgap: removes redundant null check and change paramter for dgap_tty_digigeta()

PATCH In review Daeseok Youn 1 participant 1 message Jul 11, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 5/9 staging: dgap: removes redundant null check and change paramter for dgap_tty_digigeta()

Null checks in dgap_tty_digigeta() are already done by dgap_tty_ioctl() and change "tty" as a paramter of this function to "ch" and "un".

---
 drivers/staging/dgap/dgap.c |   23 +++++------------------
 1 files changed, 5 insertions(+), 18 deletions(-)
drivers/staging/dgap/dgap.c +5 -18
index 160a960..7ebbf50 100644
@@ -86,8 +86,8 @@ static int dgap_block_til_ready(struct tty_struct *tty, struct file *file,
 				struct channel_t *ch);
 static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
 				unsigned long arg);
-static int dgap_tty_digigeta(struct tty_struct *tty,
-				struct digi_t __user *retinfo);
+static int dgap_tty_digigeta(struct channel_t *ch, struct un_t *un,
+			     struct digi_t __user *retinfo);
 static int dgap_tty_digiseta(struct channel_t *ch, struct board_t *bd,
 			     struct un_t *un, struct digi_t __user *new_info);
 static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo);
@@ -3189,28 +3189,15 @@ static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command,
  *
  *
  */
-static int dgap_tty_digigeta(struct tty_struct *tty,
-				struct digi_t __user *retinfo)
+static int dgap_tty_digigeta(struct channel_t *ch, struct un_t *un,
+			     struct digi_t __user *retinfo)
 {
-	struct channel_t *ch;
-	struct un_t *un;
 	struct digi_t tmp;
 	ulong lock_flags;
 
 	if (!retinfo)
 		return -EFAULT;
 
-	if (!tty || tty->magic != TTY_MAGIC)
-		return -EFAULT;
-
-	un = tty->driver_data;
-	if (!un || un->magic != DGAP_UNIT_MAGIC)
-		return -EFAULT;
-
-	ch = un->un_ch;
-	if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
-		return -EFAULT;
-
 	memset(&tmp, 0, sizeof(tmp));
 
 	spin_lock_irqsave(&ch->ch_lock, lock_flags);
@@ -4060,7 +4047,7 @@ static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
 		/* get information for ditty */
 		spin_unlock_irqrestore(&ch->ch_lock, lock_flags2);
 		spin_unlock_irqrestore(&bd->bd_lock, lock_flags);
-		return dgap_tty_digigeta(tty, uarg);
+		return dgap_tty_digigeta(ch, un, uarg);
 
 	case DIGI_SETAW:
 	case DIGI_SETAF:
Signature · 1 line
1.7.1