diff options
Diffstat (limited to 'net/irda')
-rw-r--r-- | net/irda/af_irda.c | 48 | ||||
-rw-r--r-- | net/irda/ircomm/ircomm_tty.c | 2 | ||||
-rw-r--r-- | net/irda/ircomm/ircomm_tty_ioctl.c | 107 | ||||
-rw-r--r-- | net/irda/irlap_frame.c | 24 | ||||
-rw-r--r-- | net/irda/irnet/irnet_irda.c | 2 |
5 files changed, 25 insertions, 158 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 8d77ad5cadaf..2e6990f8b80b 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c @@ -1901,16 +1901,10 @@ static int irda_setsockopt(struct socket *sock, int level, int optname, goto out; } - ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); - if (ias_opt == NULL) { - err = -ENOMEM; - goto out; - } - /* Copy query to the driver. */ - if (copy_from_user(ias_opt, optval, optlen)) { - kfree(ias_opt); - err = -EFAULT; + ias_opt = memdup_user(optval, optlen); + if (IS_ERR(ias_opt)) { + err = PTR_ERR(ias_opt); goto out; } @@ -2032,16 +2026,10 @@ static int irda_setsockopt(struct socket *sock, int level, int optname, goto out; } - ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); - if (ias_opt == NULL) { - err = -ENOMEM; - goto out; - } - /* Copy query to the driver. */ - if (copy_from_user(ias_opt, optval, optlen)) { - kfree(ias_opt); - err = -EFAULT; + ias_opt = memdup_user(optval, optlen); + if (IS_ERR(ias_opt)) { + err = PTR_ERR(ias_opt); goto out; } @@ -2317,16 +2305,10 @@ bed: goto out; } - ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); - if (ias_opt == NULL) { - err = -ENOMEM; - goto out; - } - /* Copy query to the driver. */ - if (copy_from_user(ias_opt, optval, len)) { - kfree(ias_opt); - err = -EFAULT; + ias_opt = memdup_user(optval, len); + if (IS_ERR(ias_opt)) { + err = PTR_ERR(ias_opt); goto out; } @@ -2381,16 +2363,10 @@ bed: goto out; } - ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); - if (ias_opt == NULL) { - err = -ENOMEM; - goto out; - } - /* Copy query to the driver. */ - if (copy_from_user(ias_opt, optval, len)) { - kfree(ias_opt); - err = -EFAULT; + ias_opt = memdup_user(optval, len); + if (IS_ERR(ias_opt)) { + err = PTR_ERR(ias_opt); goto out; } diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index f6061c4bb0a8..ec157c3419b5 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c @@ -690,7 +690,7 @@ static int ircomm_tty_write(struct tty_struct *tty, } /* Copy data */ - memcpy(skb_put(skb,size), buf + len, size); + skb_put_data(skb, buf + len, size); count -= size; len += size; diff --git a/net/irda/ircomm/ircomm_tty_ioctl.c b/net/irda/ircomm/ircomm_tty_ioctl.c index f18070118d05..171c3dee760e 100644 --- a/net/irda/ircomm/ircomm_tty_ioctl.c +++ b/net/irda/ircomm/ircomm_tty_ioctl.c @@ -97,33 +97,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self, self->settings.flow_control &= ~IRCOMM_RTS_CTS_IN; } tty_port_set_check_carrier(&self->port, ~cflag & CLOCAL); -#if 0 - /* - * Set up parity check flag - */ - - if (I_INPCK(self->tty)) - driver->read_status_mask |= LSR_FE | LSR_PE; - if (I_BRKINT(driver->tty) || I_PARMRK(driver->tty)) - driver->read_status_mask |= LSR_BI; - - /* - * Characters to ignore - */ - driver->ignore_status_mask = 0; - if (I_IGNPAR(driver->tty)) - driver->ignore_status_mask |= LSR_PE | LSR_FE; - - if (I_IGNBRK(self->tty)) { - self->ignore_status_mask |= LSR_BI; - /* - * If we're ignore parity and break indicators, ignore - * overruns too. (For real raw support). - */ - if (I_IGNPAR(self->tty)) - self->ignore_status_mask |= LSR_OE; - } -#endif + self->settings.data_format = cval; ircomm_param_request(self, IRCOMM_DATA_FORMAT, FALSE); @@ -271,67 +245,6 @@ static int ircomm_tty_get_serial_info(struct ircomm_tty_cb *self, static int ircomm_tty_set_serial_info(struct ircomm_tty_cb *self, struct serial_struct __user *new_info) { -#if 0 - struct serial_struct new_serial; - struct ircomm_tty_cb old_state, *state; - - if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) - return -EFAULT; - - - state = self - old_state = *self; - - if (!capable(CAP_SYS_ADMIN)) { - if ((new_serial.baud_base != state->settings.data_rate) || - (new_serial.close_delay != state->close_delay) || - ((new_serial.flags & ~ASYNC_USR_MASK) != - (self->flags & ~ASYNC_USR_MASK))) - return -EPERM; - state->flags = ((state->flags & ~ASYNC_USR_MASK) | - (new_serial.flags & ASYNC_USR_MASK)); - self->flags = ((self->flags & ~ASYNC_USR_MASK) | - (new_serial.flags & ASYNC_USR_MASK)); - /* self->custom_divisor = new_serial.custom_divisor; */ - goto check_and_exit; - } - - /* - * OK, past this point, all the error checking has been done. - * At this point, we start making changes..... - */ - - if (self->settings.data_rate != new_serial.baud_base) { - self->settings.data_rate = new_serial.baud_base; - ircomm_param_request(self, IRCOMM_DATA_RATE, TRUE); - } - - self->close_delay = new_serial.close_delay * HZ/100; - self->closing_wait = new_serial.closing_wait * HZ/100; - /* self->custom_divisor = new_serial.custom_divisor; */ - - self->flags = ((self->flags & ~ASYNC_FLAGS) | - (new_serial.flags & ASYNC_FLAGS)); - self->tty->low_latency = (self->flags & ASYNC_LOW_LATENCY) ? 1 : 0; - - check_and_exit: - - if (tty_port_initialized(self)) { - if (((old_state.flags & ASYNC_SPD_MASK) != - (self->flags & ASYNC_SPD_MASK)) || - (old_driver.custom_divisor != driver->custom_divisor)) { - if ((driver->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) - driver->tty->alt_speed = 57600; - if ((driver->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) - driver->tty->alt_speed = 115200; - if ((driver->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) - driver->tty->alt_speed = 230400; - if ((driver->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) - driver->tty->alt_speed = 460800; - ircomm_tty_change_speed(driver); - } - } -#endif return 0; } @@ -367,24 +280,6 @@ int ircomm_tty_ioctl(struct tty_struct *tty, case TIOCGICOUNT: pr_debug("%s(), TIOCGICOUNT not impl!\n", __func__); -#if 0 - save_flags(flags); cli(); - cnow = driver->icount; - restore_flags(flags); - p_cuser = (struct serial_icounter_struct __user *) arg; - if (put_user(cnow.cts, &p_cuser->cts) || - put_user(cnow.dsr, &p_cuser->dsr) || - put_user(cnow.rng, &p_cuser->rng) || - put_user(cnow.dcd, &p_cuser->dcd) || - put_user(cnow.rx, &p_cuser->rx) || - put_user(cnow.tx, &p_cuser->tx) || - put_user(cnow.frame, &p_cuser->frame) || - put_user(cnow.overrun, &p_cuser->overrun) || - put_user(cnow.parity, &p_cuser->parity) || - put_user(cnow.brk, &p_cuser->brk) || - put_user(cnow.buf_overrun, &p_cuser->buf_overrun)) - return -EFAULT; -#endif return 0; default: ret = -ENOIOCTLCMD; /* ioctls which we must ignore */ diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c index b936b1251a66..debda3de4726 100644 --- a/net/irda/irlap_frame.c +++ b/net/irda/irlap_frame.c @@ -133,7 +133,7 @@ void irlap_send_snrm_frame(struct irlap_cb *self, struct qos_info *qos) if (!tx_skb) return; - frame = (struct snrm_frame *) skb_put(tx_skb, 2); + frame = skb_put(tx_skb, 2); /* Insert connection address field */ if (qos) @@ -228,7 +228,7 @@ void irlap_send_ua_response_frame(struct irlap_cb *self, struct qos_info *qos) if (!tx_skb) return; - frame = (struct ua_frame *) skb_put(tx_skb, 10); + frame = skb_put(tx_skb, 10); /* Build UA response */ frame->caddr = self->caddr; @@ -268,7 +268,7 @@ void irlap_send_dm_frame( struct irlap_cb *self) if (!tx_skb) return; - frame = (struct dm_frame *)skb_put(tx_skb, 2); + frame = skb_put(tx_skb, 2); if (self->state == LAP_NDM) frame->caddr = CBROADCAST; @@ -298,7 +298,7 @@ void irlap_send_disc_frame(struct irlap_cb *self) if (!tx_skb) return; - frame = (struct disc_frame *)skb_put(tx_skb, 2); + frame = skb_put(tx_skb, 2); frame->caddr = self->caddr | CMD_FRAME; frame->control = DISC_CMD | PF_BIT; @@ -392,8 +392,7 @@ void irlap_send_discovery_xid_frame(struct irlap_cb *self, int S, __u8 s, info[0] = discovery->data.charset; len = IRDA_MIN(discovery->name_len, skb_tailroom(tx_skb)); - info = skb_put(tx_skb, len); - memcpy(info, discovery->data.info, len); + skb_put_data(tx_skb, discovery->data.info, len); } irlap_queue_xmit(self, tx_skb); } @@ -588,7 +587,7 @@ void irlap_send_rr_frame(struct irlap_cb *self, int command) if (!tx_skb) return; - frame = (struct rr_frame *)skb_put(tx_skb, 2); + frame = skb_put(tx_skb, 2); frame->caddr = self->caddr; frame->caddr |= (command) ? CMD_FRAME : 0; @@ -613,7 +612,7 @@ void irlap_send_rd_frame(struct irlap_cb *self) if (!tx_skb) return; - frame = (struct rd_frame *)skb_put(tx_skb, 2); + frame = skb_put(tx_skb, 2); frame->caddr = self->caddr; frame->control = RD_RSP | PF_BIT; @@ -1195,7 +1194,6 @@ void irlap_send_test_frame(struct irlap_cb *self, __u8 caddr, __u32 daddr, { struct sk_buff *tx_skb; struct test_frame *frame; - __u8 *info; tx_skb = alloc_skb(cmd->len + sizeof(struct test_frame), GFP_ATOMIC); if (!tx_skb) @@ -1203,21 +1201,19 @@ void irlap_send_test_frame(struct irlap_cb *self, __u8 caddr, __u32 daddr, /* Broadcast frames must include saddr and daddr fields */ if (caddr == CBROADCAST) { - frame = (struct test_frame *) - skb_put(tx_skb, sizeof(struct test_frame)); + frame = skb_put(tx_skb, sizeof(struct test_frame)); /* Insert the swapped addresses */ frame->saddr = cpu_to_le32(self->saddr); frame->daddr = cpu_to_le32(daddr); } else - frame = (struct test_frame *) skb_put(tx_skb, LAP_ADDR_HEADER + LAP_CTRL_HEADER); + frame = skb_put(tx_skb, LAP_ADDR_HEADER + LAP_CTRL_HEADER); frame->caddr = caddr; frame->control = TEST_RSP | PF_BIT; /* Copy info */ - info = skb_put(tx_skb, cmd->len); - memcpy(info, cmd->data, cmd->len); + skb_put_data(tx_skb, cmd->data, cmd->len); /* Return to sender */ irlap_wait_min_turn_around(self, &self->qos_tx); diff --git a/net/irda/irnet/irnet_irda.c b/net/irda/irnet/irnet_irda.c index 7f17a8020e8a..e390bceeb2f8 100644 --- a/net/irda/irnet/irnet_irda.c +++ b/net/irda/irnet/irnet_irda.c @@ -1065,7 +1065,7 @@ irnet_data_indication(void * instance, if(p[0] & 1) { /* protocol is compressed */ - skb_push(skb, 1)[0] = 0; + *(u8 *)skb_push(skb, 1) = 0; } else if(skb->len < 2) |