From d8c1fa4af0f311363d9f9cf1014b11d31a99ff10 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 22 May 2010 10:22:00 +0200 Subject: ieee1394: video1394: Use memdup_user ...when user data is immediately copied into the allocated region. Signed-off-by: Julia Lawall Signed-off-by: Stefan Richter (changelog) --- drivers/ieee1394/video1394.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers/ieee1394') diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index a42bd6893bcf9..a77483befcdac 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c @@ -1045,14 +1045,9 @@ static long video1394_ioctl(struct file *file, if (get_user(qv, &p->packet_sizes)) return -EFAULT; - psizes = kmalloc(buf_size, GFP_KERNEL); - if (!psizes) - return -ENOMEM; - - if (copy_from_user(psizes, qv, buf_size)) { - kfree(psizes); - return -EFAULT; - } + psizes = memdup_user(qv, buf_size); + if (IS_ERR(psizes)) + return PTR_ERR(psizes); } spin_lock_irqsave(&d->lock,flags); -- cgit 1.2.3-korg From 5030c807907ae90ad21e9220c1a9d592558deba2 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Tue, 15 Jun 2010 02:00:11 +0200 Subject: ieee1394: remove unused variables which caused gcc 4.6 to warn about variable 'XYZ' set but not used. sbp2.c, unit_characteristics: The underlying problem which was spotted here --- an incomplete implementation --- is already 50% fixed in drivers/firewire/sbp2.c which observes mgt_ORB_timeout but not yet ORB_size. raw1394.c, length_conflict; dv1394.c, ts_off: Impossible to tell why these variables are there. We can safely remove them though because we don't need a compiler warning to realize that we are dealing with (at least stylistically) flawed code here. dv1394.c, packet_time: This was used in debug macro that is only compiled in with DV1394_DEBUG_LEVEL >= 2 defined at compile-time. Just drop it since nobody debugs dv1394 anymore. Avoids noise in regular kernel builds. dv1394.c, ohci; eth1394.c, priv: These variables clearly can go away. Somebody wanted to use them but then didn't (or not anymore). Note, all of this code is considered to be at its end of life and is thus not really meant to receive janitorial updates anymore. But if we can easily remove noisy warnings from kernel builds, we should. Reported-by: Justin P. Mattock Signed-off-by: Stefan Richter --- drivers/ieee1394/dv1394.c | 14 ++------------ drivers/ieee1394/eth1394.c | 3 --- drivers/ieee1394/raw1394.c | 3 +-- drivers/ieee1394/sbp2.c | 11 ++++------- 4 files changed, 7 insertions(+), 24 deletions(-) (limited to 'drivers/ieee1394') diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index adaefabc40e96..f8fcbd048447b 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c @@ -610,7 +610,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame) } else { u32 transmit_sec, transmit_cyc; - u32 ts_cyc, ts_off; + u32 ts_cyc; /* DMA is stopped, so this is the very first frame */ video->active_frame = this_frame; @@ -636,7 +636,6 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame) transmit_sec += transmit_cyc/8000; transmit_cyc %= 8000; - ts_off = ct_off; ts_cyc = transmit_cyc + 3; ts_cyc %= 8000; @@ -2004,7 +2003,7 @@ static void ir_tasklet_func(unsigned long data) int sof=0; /* start-of-frame flag */ struct frame *f; - u16 packet_length, packet_time; + u16 packet_length; int i, dbc=0; struct DMA_descriptor_block *block = NULL; u16 xferstatus; @@ -2024,11 +2023,6 @@ static void ir_tasklet_func(unsigned long data) sizeof(struct packet)); packet_length = le16_to_cpu(p->data_length); - packet_time = le16_to_cpu(p->timestamp); - - irq_printk("received packet %02d, timestamp=%04x, length=%04x, sof=%02x%02x\n", video->current_packet, - packet_time, packet_length, - p->data[0], p->data[1]); /* get the descriptor based on packet_buffer cursor */ f = video->frames[video->current_packet / MAX_PACKETS]; @@ -2320,7 +2314,6 @@ static void dv1394_add_host(struct hpsb_host *host) static void dv1394_host_reset(struct hpsb_host *host) { - struct ti_ohci *ohci; struct video_card *video = NULL, *tmp_vid; unsigned long flags; @@ -2328,9 +2321,6 @@ static void dv1394_host_reset(struct hpsb_host *host) if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME)) return; - ohci = (struct ti_ohci *)host->hostdata; - - /* find the corresponding video_cards */ spin_lock_irqsave(&dv1394_cards_lock, flags); list_for_each_entry(tmp_vid, &dv1394_cards, list) { diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index a4e9dcb6d4a9a..bc289e367e30e 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c @@ -1258,7 +1258,6 @@ static void ether1394_iso(struct hpsb_iso *iso) char *buf; struct eth1394_host_info *hi; struct net_device *dev; - struct eth1394_priv *priv; unsigned int len; u32 specifier_id; u16 source_id; @@ -1288,8 +1287,6 @@ static void ether1394_iso(struct hpsb_iso *iso) (be32_to_cpu(data[1]) & 0xff000000) >> 24; source_id = be32_to_cpu(data[0]) >> 16; - priv = netdev_priv(dev); - if (info->channel != (iso->host->csr.broadcast_channel & 0x3f) || specifier_id != ETHER1394_GASP_SPECIFIER_ID) { /* This packet is not for us */ diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index b563d5e9fa2e5..2c417ae7622b5 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c @@ -1015,7 +1015,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid, struct arm_addr *arm_addr = NULL; struct arm_request *arm_req = NULL; struct arm_response *arm_resp = NULL; - int found = 0, size = 0, rcode = -1, length_conflict = 0; + int found = 0, size = 0, rcode = -1; struct arm_request_response *arm_req_resp = NULL; DBGMSG("arm_write called by node: %X " @@ -1054,7 +1054,6 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid, } if (arm_addr->rec_length < length) { DBGMSG("arm_write blocklength too big -> rcode_data_error"); - length_conflict = 1; rcode = RCODE_DATA_ERROR; /* hardware error, data is unavailable */ } if (rcode == -1) { diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index f199896c41135..d3a136c70c48a 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -1351,12 +1351,11 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu, struct csr1212_keyval *kv; struct csr1212_dentry *dentry; u64 management_agent_addr; - u32 unit_characteristics, firmware_revision, model; + u32 firmware_revision, model; unsigned workarounds; int i; management_agent_addr = 0; - unit_characteristics = 0; firmware_revision = SBP2_ROM_VALUE_MISSING; model = ud->flags & UNIT_DIRECTORY_MODEL_ID ? ud->model_id : SBP2_ROM_VALUE_MISSING; @@ -1373,17 +1372,15 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu, lu->lun = ORB_SET_LUN(kv->value.immediate); break; - case SBP2_UNIT_CHARACTERISTICS_KEY: - /* FIXME: This is ignored so far. - * See SBP-2 clause 7.4.8. */ - unit_characteristics = kv->value.immediate; - break; case SBP2_FIRMWARE_REVISION_KEY: firmware_revision = kv->value.immediate; break; default: + /* FIXME: Check for SBP2_UNIT_CHARACTERISTICS_KEY + * mgt_ORB_timeout and ORB_size, SBP-2 clause 7.4.8. */ + /* FIXME: Check for SBP2_DEVICE_TYPE_AND_LUN_KEY. * Its "ordered" bit has consequences for command ORB * list handling. See SBP-2 clauses 4.6, 7.4.11, 10.2 */ -- cgit 1.2.3-korg From 80792d182e43bee89fce509e64fdea27e600530f Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 12 Jul 2010 13:50:00 -0700 Subject: ieee1394: Remove unnecessary casts of private_data Signed-off-by: Joe Perches Signed-off-by: Stefan Richter --- drivers/ieee1394/dv1394.c | 4 ++-- drivers/ieee1394/raw1394.c | 4 ++-- drivers/ieee1394/video1394.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/ieee1394') diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index f8fcbd048447b..c5a031b79d036 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c @@ -172,7 +172,7 @@ static DEFINE_SPINLOCK(dv1394_cards_lock); static inline struct video_card* file_to_video_card(struct file *file) { - return (struct video_card*) file->private_data; + return file->private_data; } /*** FRAME METHODS *********************************************************/ @@ -1783,7 +1783,7 @@ static int dv1394_open(struct inode *inode, struct file *file) struct video_card *video = NULL; if (file->private_data) { - video = (struct video_card*) file->private_data; + video = file->private_data; } else { /* look up the card by ID */ diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index 2c417ae7622b5..f3401427404cc 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c @@ -440,7 +440,7 @@ static struct pending_request *next_complete_req(struct file_info *fi) static ssize_t raw1394_read(struct file *file, char __user * buffer, size_t count, loff_t * offset_is_ignored) { - struct file_info *fi = (struct file_info *)file->private_data; + struct file_info *fi = file->private_data; struct pending_request *req; ssize_t ret; @@ -2244,7 +2244,7 @@ static int state_connected(struct file_info *fi, struct pending_request *req) static ssize_t raw1394_write(struct file *file, const char __user * buffer, size_t count, loff_t * offset_is_ignored) { - struct file_info *fi = (struct file_info *)file->private_data; + struct file_info *fi = file->private_data; struct pending_request *req; ssize_t retval = -EBADFD; diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index a77483befcdac..5c74f796d7f1f 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c @@ -720,7 +720,7 @@ static inline unsigned video1394_buffer_state(struct dma_iso_ctx *d, static long video1394_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - struct file_ctx *ctx = (struct file_ctx *)file->private_data; + struct file_ctx *ctx = file->private_data; struct ti_ohci *ohci = ctx->ohci; unsigned long flags; void __user *argp = (void __user *)arg; @@ -1172,7 +1172,7 @@ static long video1394_ioctl(struct file *file, static int video1394_mmap(struct file *file, struct vm_area_struct *vma) { - struct file_ctx *ctx = (struct file_ctx *)file->private_data; + struct file_ctx *ctx = file->private_data; if (ctx->current_ctx == NULL) { PRINT(KERN_ERR, ctx->ohci->host->id, @@ -1239,7 +1239,7 @@ static int video1394_open(struct inode *inode, struct file *file) static int video1394_release(struct inode *inode, struct file *file) { - struct file_ctx *ctx = (struct file_ctx *)file->private_data; + struct file_ctx *ctx = file->private_data; struct ti_ohci *ohci = ctx->ohci; struct list_head *lh, *next; u64 mask; -- cgit 1.2.3-korg