netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: irda: resolve sparse errors due to implicit pci_power_t casts
@ 2017-10-05 23:38 Matthew Giassa
  2017-10-18 14:12 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Giassa @ 2017-10-05 23:38 UTC (permalink / raw)
  To: gregkh, samuel
  Cc: davem, stephen, khoroshilov, georgiana.chelu93, johannes.berg,
	netdev, devel, linux-kernel, matthew

Explicitly casting pci_power_t types to resolve sparse warnings (shown
below).

Also fixing a related logging bug where pci_power_t is cast to unsigned
(can be negative, i.e. PCI_POWER_ERROR).

Original sparse report:

drivers/staging/irda/drivers//vlsi_ir.c:170:51: warning: cast from
restricted pci_power_t
drivers/staging/irda/drivers//vlsi_ir.c:1726:39: warning: restricted
pci_power_t degrades to integer
drivers/staging/irda/drivers//vlsi_ir.c:1728:45: warning: incorrect type
in assignment (different base types)
drivers/staging/irda/drivers//vlsi_ir.c:1728:45:    expected restricted
pci_power_t [usertype] current_state
drivers/staging/irda/drivers//vlsi_ir.c:1728:45:    got int [signed]
[usertype] event
drivers/staging/irda/drivers//vlsi_ir.c:1748:29: warning: incorrect type
in assignment (different base types)
drivers/staging/irda/drivers//vlsi_ir.c:1748:29:    expected restricted
pci_power_t [usertype] current_state
drivers/staging/irda/drivers//vlsi_ir.c:1748:29:    got int [signed]
[usertype] event

Warnings no longer present.

Signed-off-by: Matthew Giassa <matthew@giassa.net>
---
 drivers/staging/irda/drivers/vlsi_ir.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/irda/drivers/vlsi_ir.c b/drivers/staging/irda/drivers/vlsi_ir.c
index 3dff3c5..20ce4d8 100644
--- a/drivers/staging/irda/drivers/vlsi_ir.c
+++ b/drivers/staging/irda/drivers/vlsi_ir.c
@@ -167,7 +167,8 @@ static void vlsi_proc_pdev(struct seq_file *seq, struct pci_dev *pdev)
 
 	seq_printf(seq, "\n%s (vid/did: [%04x:%04x])\n",
 		   pci_name(pdev), (int)pdev->vendor, (int)pdev->device);
-	seq_printf(seq, "pci-power-state: %u\n", (unsigned) pdev->current_state);
+	seq_printf(seq, "pci-power-state: %d\n",
+		   (int __force)pdev->current_state);
 	seq_printf(seq, "resources: irq=%u / io=0x%04x / dma_mask=0x%016Lx\n",
 		   pdev->irq, (unsigned)pci_resource_start(pdev, 0), (unsigned long long)pdev->dma_mask);
 	seq_puts(seq, "hw registers: ");
@@ -1723,9 +1724,10 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
 	idev = netdev_priv(ndev);
 	mutex_lock(&idev->mtx);
 	if (pdev->current_state != 0) {			/* already suspended */
-		if (state.event > pdev->current_state) {	/* simply go deeper */
+		/* simply go deeper */
+		if (state.event > (int __force)pdev->current_state) {
 			pci_set_power_state(pdev, pci_choose_state(pdev, state));
-			pdev->current_state = state.event;
+			pdev->current_state = (pci_power_t __force)state.event;
 		}
 		else
 			net_err_ratelimited("%s - %s: invalid suspend request %u -> %u\n",
@@ -1745,7 +1747,7 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
 	}
 
 	pci_set_power_state(pdev, pci_choose_state(pdev, state));
-	pdev->current_state = state.event;
+	pdev->current_state = (pci_power_t __force)state.event;
 	idev->resume_ok = 1;
 	mutex_unlock(&idev->mtx);
 	return 0;
-- 
2.7.4

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

end of thread, other threads:[~2017-10-18 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-05 23:38 [PATCH] staging: irda: resolve sparse errors due to implicit pci_power_t casts Matthew Giassa
2017-10-18 14:12 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).