Skip to contentSkip to conversation

PCI: switchtec: Trivial cleanups

PATCH Superseded Bjorn Helgaas 2 participants 6 messages Dec 15, 2022

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover PCI: switchtec: Trivial cleanups

From: Bjorn Helgaas <[email protected]>

Simplify switchtec_dma_mrpc_isr() slightly and remove some unused assignments in switchtec_dev_read().

It's possible you want a different fix for the latter, e.g., actually returning the error values that are currently assigned but then ignored.

Bjorn Helgaas (2):
PCI: switchtec: Simplify switchtec_dma_mrpc_isr()
PCI: switchtec: Remove useless assignments in switchtec_dev_read()

 drivers/pci/switch/switchtec.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 PCI: switchtec: Simplify switchtec_dma_mrpc_isr()

From: Bjorn Helgaas <[email protected]>

The "ret" variable in switchtec_dma_mrpc_isr() is superfluous. Remove it and just return the value. No functional change intended.

---
 drivers/pci/switch/switchtec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pci/switch/switchtec.c +1 -3
index 75be4fe22509..d7ae84070e29 100644
@@ -1480,15 +1480,13 @@ static irqreturn_t switchtec_event_isr(int irq, void *dev)
 static irqreturn_t switchtec_dma_mrpc_isr(int irq, void *dev)
 {
 	struct switchtec_dev *stdev = dev;
-	irqreturn_t ret = IRQ_NONE;
 
 	iowrite32(SWITCHTEC_EVENT_CLEAR |
 		  SWITCHTEC_EVENT_EN_IRQ,
 		  &stdev->mmio_part_cfg->mrpc_comp_hdr);
 	schedule_work(&stdev->mrpc_work);
 
-	ret = IRQ_HANDLED;
-	return ret;
+	return IRQ_HANDLED;
 }
 
 static int switchtec_init_isr(struct switchtec_dev *stdev)
Signature · 1 line
2.25.1
#3 lore raw

PATCH 2/2 PCI: switchtec: Remove useless assignments in switchtec_dev_read()

In reply to Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Some switchtec_dev_read() error cases assign to "rc", then branch to "out". But the code at "out" never uses "rc". Drop the useless assignments. No functional change intended.

---
 drivers/pci/switch/switchtec.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/pci/switch/switchtec.c +2 -6
index d7ae84070e29..c04c7ee35184 100644
@@ -605,18 +605,14 @@ static ssize_t switchtec_dev_read(struct file *filp, char __user *data,
 
 	rc = copy_to_user(data, &stuser->return_code,
 			  sizeof(stuser->return_code));
-	if (rc) {
-		rc = -EFAULT;
+	if (rc)
 		goto out;
-	}
 
 	data += sizeof(stuser->return_code);
 	rc = copy_to_user(data, &stuser->data,
 			  size - sizeof(stuser->return_code));
-	if (rc) {
-		rc = -EFAULT;
+	if (rc)
 		goto out;
-	}
 
 	stuser_set_state(stuser, MRPC_IDLE);
 
Signature · 1 line
2.25.1
maintainer
#4 lore raw

Re: [PATCH 2/2] PCI: switchtec: Remove useless assignments in switchtec_dev_read()

Quoted 5 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Some switchtec_dev_read() error cases assign to "rc", then branch to "out". But the code at "out" never uses "rc". Drop the useless assignments. No functional change intended.

Ah, hmm, yes. I think if copy_to_user() fails, the function should probably return -EFAULT. So perhaps an unlock and specific return as is done in previous conditions in the same function?

Thanks,

Logan

#5 lore raw

Re: [PATCH 2/2] PCI: switchtec: Remove useless assignments in switchtec_dev_read()

Quoted 10 lines · Logan Gunthorpe
Quoted 5 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Some switchtec_dev_read() error cases assign to "rc", then branch to "out". But the code at "out" never uses "rc". Drop the useless assignments. No functional change intended.

Ah, hmm, yes. I think if copy_to_user() fails, the function should probably return -EFAULT. So perhaps an unlock and specific return as is done in previous conditions in the same function?

Sure, I'll post a v2 that does that.