public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] PCI: switchtec: Trivial cleanups
@ 2022-12-15 18:21 Bjorn Helgaas
  2022-12-15 18:21 ` [PATCH 1/2] PCI: switchtec: Simplify switchtec_dma_mrpc_isr() Bjorn Helgaas
  2022-12-15 18:21 ` [PATCH 2/2] PCI: switchtec: Remove useless assignments in switchtec_dev_read() Bjorn Helgaas
  0 siblings, 2 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2022-12-15 18:21 UTC (permalink / raw)
  To: Kurt Schwemmer, Logan Gunthorpe; +Cc: linux-pci, linux-kernel, Bjorn Helgaas

From: Bjorn Helgaas <bhelgaas@google.com>

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(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] PCI: switchtec: Simplify switchtec_dma_mrpc_isr()
  2022-12-15 18:21 [PATCH 0/2] PCI: switchtec: Trivial cleanups Bjorn Helgaas
@ 2022-12-15 18:21 ` Bjorn Helgaas
  2022-12-15 18:26   ` Logan Gunthorpe
  2022-12-15 18:21 ` [PATCH 2/2] PCI: switchtec: Remove useless assignments in switchtec_dev_read() Bjorn Helgaas
  1 sibling, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2022-12-15 18:21 UTC (permalink / raw)
  To: Kurt Schwemmer, Logan Gunthorpe; +Cc: linux-pci, linux-kernel, Bjorn Helgaas

From: Bjorn Helgaas <bhelgaas@google.com>

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

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/switch/switchtec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index 75be4fe22509..d7ae84070e29 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] PCI: switchtec: Remove useless assignments in switchtec_dev_read()
  2022-12-15 18:21 [PATCH 0/2] PCI: switchtec: Trivial cleanups Bjorn Helgaas
  2022-12-15 18:21 ` [PATCH 1/2] PCI: switchtec: Simplify switchtec_dma_mrpc_isr() Bjorn Helgaas
@ 2022-12-15 18:21 ` Bjorn Helgaas
  2022-12-15 18:34   ` Logan Gunthorpe
  1 sibling, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2022-12-15 18:21 UTC (permalink / raw)
  To: Kurt Schwemmer, Logan Gunthorpe; +Cc: linux-pci, linux-kernel, Bjorn Helgaas

From: Bjorn Helgaas <bhelgaas@google.com>

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.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/switch/switchtec.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index d7ae84070e29..c04c7ee35184 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -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);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] PCI: switchtec: Simplify switchtec_dma_mrpc_isr()
  2022-12-15 18:21 ` [PATCH 1/2] PCI: switchtec: Simplify switchtec_dma_mrpc_isr() Bjorn Helgaas
@ 2022-12-15 18:26   ` Logan Gunthorpe
  0 siblings, 0 replies; 6+ messages in thread
From: Logan Gunthorpe @ 2022-12-15 18:26 UTC (permalink / raw)
  To: Bjorn Helgaas, Kurt Schwemmer; +Cc: linux-pci, linux-kernel, Bjorn Helgaas



On 2022-12-15 11:21, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
> 
> The "ret" variable in switchtec_dma_mrpc_isr() is superfluous.  Remove it
> and just return the value.  No functional change intended.
> 
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

Thanks,

Logan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] PCI: switchtec: Remove useless assignments in switchtec_dev_read()
  2022-12-15 18:21 ` [PATCH 2/2] PCI: switchtec: Remove useless assignments in switchtec_dev_read() Bjorn Helgaas
@ 2022-12-15 18:34   ` Logan Gunthorpe
  2022-12-15 19:07     ` Bjorn Helgaas
  0 siblings, 1 reply; 6+ messages in thread
From: Logan Gunthorpe @ 2022-12-15 18:34 UTC (permalink / raw)
  To: Bjorn Helgaas, Kurt Schwemmer; +Cc: linux-pci, linux-kernel, Bjorn Helgaas



On 2022-12-15 11:21, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
> 
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] PCI: switchtec: Remove useless assignments in switchtec_dev_read()
  2022-12-15 18:34   ` Logan Gunthorpe
@ 2022-12-15 19:07     ` Bjorn Helgaas
  0 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2022-12-15 19:07 UTC (permalink / raw)
  To: Logan Gunthorpe; +Cc: Kurt Schwemmer, linux-pci, linux-kernel, Bjorn Helgaas

On Thu, Dec 15, 2022 at 11:34:06AM -0700, Logan Gunthorpe wrote:
> On 2022-12-15 11:21, Bjorn Helgaas wrote:
> > From: Bjorn Helgaas <bhelgaas@google.com>
> > 
> > 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-15 19:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-15 18:21 [PATCH 0/2] PCI: switchtec: Trivial cleanups Bjorn Helgaas
2022-12-15 18:21 ` [PATCH 1/2] PCI: switchtec: Simplify switchtec_dma_mrpc_isr() Bjorn Helgaas
2022-12-15 18:26   ` Logan Gunthorpe
2022-12-15 18:21 ` [PATCH 2/2] PCI: switchtec: Remove useless assignments in switchtec_dev_read() Bjorn Helgaas
2022-12-15 18:34   ` Logan Gunthorpe
2022-12-15 19:07     ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox