Skip to contentSkip to conversation

staging: unisys: remove unused variables

PATCH Superseded Sudip Mukherjee 2 participants 5 messages Mar 12, 2015 – Mar 17, 2015 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 staging: unisys: remove unused variables

these variable were being assigned some values but never reused.

---
 drivers/staging/unisys/virthba/virthba.c | 18 ++++++------------
 drivers/staging/unisys/virtpci/virtpci.c | 22 +++++++---------------
 2 files changed, 13 insertions(+), 27 deletions(-)
drivers/staging/unisys/virthba/virthba.c +6 -12
index e5b0dd8..655db2f 100644
@@ -333,16 +333,14 @@ static inline void
 send_disk_add_remove(struct diskaddremove *dar)
 {
 	struct scsi_device *sdev;
-	int error;
 
 	sdev = scsi_device_lookup(dar->shost, dar->channel, dar->id, dar->lun);
 	if (sdev) {
 		if (!(dar->add))
 			scsi_remove_device(sdev);
 	} else if (dar->add) {
-		error =
-		    scsi_add_device(dar->shost, dar->channel, dar->id,
-				    dar->lun);
+		scsi_add_device(dar->shost, dar->channel, dar->id,
+				dar->lun);
 	}
 	kfree(dar);
 }
@@ -401,7 +399,6 @@ virthba_isr(int irq, void *dev_id)
 	struct channel_header __iomem *channel_header;
 	struct signal_queue_header __iomem *pqhdr;
 	u64 mask;
-	unsigned long long rc1;
 
 	if (virthbainfo == NULL)
 		return IRQ_NONE;
@@ -414,7 +411,8 @@ virthba_isr(int irq, void *dev_id)
 		0)) {
 		virthbainfo->interrupts_disabled++;
 		mask = ~ULTRA_CHANNEL_ENABLE_INTS;
-		rc1 = uisqueue_interlocked_and(virthbainfo->flags_addr, mask);
+		uisqueue_interlocked_and(virthbainfo->flags_addr,
+					 mask);
 	}
 	if (spar_signalqueue_empty(channel_header, IOCHAN_FROM_IOPART)) {
 		virthbainfo->interrupts_notme++;
@@ -807,7 +805,6 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
 {
 	struct scsi_device *scsidev = scsicmd->device;
 	int insert_location;
-	unsigned char op;
 	unsigned char *cdb = scsicmd->cmnd;
 	struct Scsi_Host *scsihost = scsidev->host;
 	struct uiscmdrsp *cmdrsp;
@@ -890,7 +887,6 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
 		cmdrsp->scsi.guest_phys_entries = scsi_sg_count(scsicmd);
 	}
 
-	op = cdb[0];
 	i = uisqueue_put_cmdrsp_with_lock_client(virthbainfo->chinfo.queueinfo,
 						 cmdrsp, IOCHAN_TO_IOPART,
 						 &virthbainfo->chinfo.
@@ -984,11 +980,9 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
 {
 	struct virtdisk_info *vdisk;
 	struct scsi_device *scsidev;
-	struct sense_data *sd;
 
 	scsidev = scsicmd->device;
 	memcpy(scsicmd->sense_buffer, cmdrsp->scsi.sensebuf, MAX_SENSE_SIZE);
-	sd = (struct sense_data *)scsicmd->sense_buffer;
 
 	/* Do not log errors for disk-not-present inquiries */
 	if ((cmdrsp->scsi.cmnd[0] == INQUIRY) &&
@@ -1178,7 +1172,6 @@ process_incoming_rsps(void *v)
 	struct uiscmdrsp *cmdrsp = NULL;
 	const int SZ = sizeof(struct uiscmdrsp);
 	u64 mask;
-	unsigned long long rc1;
 
 	UIS_DAEMONIZE("vhba_incoming");
 	/* alloc once and reuse */
@@ -1197,7 +1190,8 @@ process_incoming_rsps(void *v)
 		atomic_set(&virthbainfo->interrupt_rcvd, 0);
 		/* drain queue */
 		drain_queue(virthbainfo, dc, cmdrsp);
-		rc1 = uisqueue_interlocked_or(virthbainfo->flags_addr, mask);
+		uisqueue_interlocked_or(virthbainfo->flags_addr,
+					mask);
 	}
 
 	kfree(cmdrsp);
drivers/staging/unisys/virtpci/virtpci.c +7 -15
index 43b5736..e0d38d5 100644
@@ -546,7 +546,6 @@ static void delete_all(void)
 static int delete_all_virt(enum virtpci_dev_type devtype,
 			   struct del_vbus_guestpart *delparams)
 {
-	int i;
 	unsigned char busid[BUS_ID_SIZE];
 	struct device *vbus;
 
@@ -561,7 +560,7 @@ static int delete_all_virt(enum virtpci_dev_type devtype,
 		return 0;
 
 	/* delete all vhbas/vnics */
-	i = virtpci_device_del(vbus, devtype, NULL, NULL);
+	virtpci_device_del(vbus, devtype, NULL, NULL);
 	return 1;
 }
 
@@ -797,7 +796,6 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
 	struct virtpci_dev *tmpvpcidev = NULL, *prev;
 	unsigned long flags;
 	int ret;
-	struct spar_io_channel_protocol __iomem *io_chan = NULL;
 	struct device *dev;
 
 	POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
@@ -831,10 +829,6 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
 	virtpcidev->queueinfo.chan = addparams->chanptr;
 	virtpcidev->queueinfo.send_int_if_needed = NULL;
 
-	/* Set up safe queue... */
-	io_chan = (struct spar_io_channel_protocol __iomem *)
-		virtpcidev->queueinfo.chan;
-
 	virtpcidev->intr = addparams->intr;
 
 	/* initialize stuff in the device portion of the struct */
@@ -946,7 +940,7 @@ static int virtpci_device_serverdown(struct device *parentbus,
 {
 	int pausethisone = 0;
 	bool found = false;
-	struct virtpci_dev *tmpvpcidev, *prevvpcidev;
+	struct virtpci_dev *tmpvpcidev;
 	struct virtpci_driver *vpcidriver;
 	unsigned long flags;
 	int rc = 0;
@@ -957,9 +951,8 @@ static int virtpci_device_serverdown(struct device *parentbus,
 	/* find the vhba or vnic in virtpci device list */
 	write_lock_irqsave(&vpcidev_list_lock, flags);
 
-	for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL;
-	     (tmpvpcidev && !found);
-	     prevvpcidev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) {
+	for (tmpvpcidev = vpcidev_list_head; (tmpvpcidev && !found);
+	     tmpvpcidev = tmpvpcidev->next) {
 		if (tmpvpcidev->devtype != devtype)
 			continue;
 
@@ -1000,7 +993,7 @@ static int virtpci_device_serverup(struct device *parentbus,
 {
 	int resumethisone = 0;
 	bool found = false;
-	struct virtpci_dev *tmpvpcidev, *prevvpcidev;
+	struct virtpci_dev *tmpvpcidev;
 	struct virtpci_driver *vpcidriver;
 	unsigned long flags;
 	int rc = 0;
@@ -1012,9 +1005,8 @@ static int virtpci_device_serverup(struct device *parentbus,
 	/* find the vhba or vnic in virtpci device list */
 	write_lock_irqsave(&vpcidev_list_lock, flags);
 
-	for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL;
-	     (tmpvpcidev && !found);
-	     prevvpcidev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) {
+	for (tmpvpcidev = vpcidev_list_head; (tmpvpcidev && !found);
+	     tmpvpcidev = tmpvpcidev->next) {
 		if (tmpvpcidev->devtype != devtype)
 			continue;
 
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/2 staging: unisys: remove comparison

the macro comparison is always true as MAJOR is defined as unsiged int.

---
 drivers/staging/unisys/visorchipset/file.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/unisys/visorchipset/file.c +2 -4
index 9ca7f1e..a1e8e79 100644
@@ -82,10 +82,8 @@ visorchipset_file_cleanup(void)
 		cdev_del(&file_cdev);
 	file_cdev.ops = NULL;
 	if (registered) {
-		if (MAJOR(majordev) >= 0) {
-			unregister_chrdev_region(majordev, 1);
-			majordev = MKDEV(0, 0);
-		}
+		unregister_chrdev_region(majordev, 1);
+		majordev = MKDEV(0, 0);
 		registered = FALSE;
 	}
 }
Signature · 1 line
1.8.1.2
#2 lore raw

Re: [PATCH 2/2] staging: unisys: remove comparison

Quoted 13 lines · Sudip Mukherjee

the macro comparison is always true as MAJOR is defined as unsiged int.

---
 drivers/staging/unisys/visorchipset/file.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/unisys/visorchipset/file.c +0 -0
index 9ca7f1e..a1e8e79 100644

drivers/staging/unisys/visorchipset/file.c visorchipset_file_cleanup(void) · line 86

Quoted 9 lines
drivers/staging/unisys/visorchipset/file.c +2 -4
@@ -82,10 +82,8 @@ visorchipset_file_cleanup(void)
 		cdev_del(&file_cdev);
 	file_cdev.ops = NULL;
 	if (registered) {
-		if (MAJOR(majordev) >= 0) {
-			unregister_chrdev_region(majordev, 1);
-			majordev = MKDEV(0, 0);
-		}
+		unregister_chrdev_region(majordev, 1);
+		majordev = MKDEV(0, 0);

If this is really true, then why is someone trying to assign -1 to majordev at the top of the file? :)

I suggest you fix this up properly, not by papering over the bug.

thanks,

greg k-h

#3 lore raw
In reply to Sudip Mukherjee
Quoted 18 lines · Sudip Mukherjee

these variable were being assigned some values but never reused.

---
 drivers/staging/unisys/virthba/virthba.c | 18 ++++++------------
 drivers/staging/unisys/virtpci/virtpci.c | 22 +++++++---------------
 2 files changed, 13 insertions(+), 27 deletions(-)
drivers/staging/unisys/virthba/virthba.c +0 -1
index e5b0dd8..655db2f 100644
@@ -333,16 +333,14 @@ static inline void
 send_disk_add_remove(struct diskaddremove *dar)
 {
 	struct scsi_device *sdev;
-	int error;
 

drivers/staging/unisys/virthba/virthba.c static inline void · line 343

Quoted 10 lines
drivers/staging/unisys/virthba/virthba.c +2 -3
 	sdev = scsi_device_lookup(dar->shost, dar->channel, dar->id, dar->lun);
 	if (sdev) {
 		if (!(dar->add))
 			scsi_remove_device(sdev);
 	} else if (dar->add) {
-		error =
-		    scsi_add_device(dar->shost, dar->channel, dar->id,
-				    dar->lun);
+		scsi_add_device(dar->shost, dar->channel, dar->id,
+				dar->lun);

This should be properly checked, not ignored.

#4 lore raw
Quoted 19 lines · Greg Kroah-Hartman
Quoted 18 lines · Sudip Mukherjee

these variable were being assigned some values but never reused.

---
 drivers/staging/unisys/virthba/virthba.c | 18 ++++++------------
 drivers/staging/unisys/virtpci/virtpci.c | 22 +++++++---------------
 2 files changed, 13 insertions(+), 27 deletions(-)
drivers/staging/unisys/virthba/virthba.c +0 -1
index e5b0dd8..655db2f 100644
@@ -333,16 +333,14 @@ static inline void
 send_disk_add_remove(struct diskaddremove *dar)
 {
 	struct scsi_device *sdev;
-	int error;
 
Quoted 12 lines

drivers/staging/unisys/virthba/virthba.c static inline void · line 343

Quoted 10 lines
drivers/staging/unisys/virthba/virthba.c +2 -3
 	sdev = scsi_device_lookup(dar->shost, dar->channel, dar->id, dar->lun);
 	if (sdev) {
 		if (!(dar->add))
 			scsi_remove_device(sdev);
 	} else if (dar->add) {
-		error =
-		    scsi_add_device(dar->shost, dar->channel, dar->id,
-				    dar->lun);
+		scsi_add_device(dar->shost, dar->channel, dar->id,
+				dar->lun);

This should be properly checked, not ignored.

i have a total newbie question on this one and I am hoping to get some pointer or some advise on it.
this send_disk_add_remove() is being called from do_disk_add_remove() which is a function called from a workqueue. so how do i return error codes fom here?

regards
sudip