[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1449787914-10434-1-git-send-email-balbi@ti.com>
Date: Thu, 10 Dec 2015 16:51:54 -0600
From: Felipe Balbi <balbi@...com>
To: Jiri Kosina <trivial@...nel.org>
CC: Greg KH <gregkh@...uxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Felipe Balbi <balbi@...com>
Subject: [PATCH] treewide: let dev_WARN() accept a condition
WARN() accepts a condition, so it's only fair that
dev_WARN() accepts one too.
Signed-off-by: Felipe Balbi <balbi@...com>
---
drivers/base/core.c | 2 +-
drivers/dma/dw/core.c | 6 ++-
drivers/dma/ioat/init.c | 2 +-
drivers/media/platform/exynos4-is/fimc-is.c | 6 +--
drivers/media/platform/exynos4-is/mipi-csis.c | 2 +-
drivers/pci/host/pci-mvebu.c | 6 +--
drivers/phy/phy-core.c | 4 +-
drivers/regulator/pbias-regulator.c | 2 +-
drivers/scsi/ufs/ufshcd.c | 6 +--
drivers/thunderbolt/ctl.c | 2 +-
drivers/thunderbolt/nhi.c | 74 ++++++++++++---------------
drivers/thunderbolt/path.c | 2 +-
drivers/thunderbolt/tb.h | 2 +-
drivers/usb/core/urb.c | 8 +--
drivers/usb/dwc3/dwc3-omap.c | 4 +-
drivers/usb/dwc3/ep0.c | 5 +-
drivers/usb/dwc3/gadget.c | 2 +-
drivers/usb/host/uhci-q.c | 20 ++++----
include/linux/device.h | 5 +-
19 files changed, 76 insertions(+), 84 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index b7d56c5ea3c6..df20db26702b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2155,7 +2155,7 @@ create_syslog_header(const struct device *dev, char *hdr, size_t hdrlen)
return pos;
overflow:
- dev_WARN(dev, "device/subsystem name too long");
+ dev_WARN(dev, true, "device/subsystem name too long");
return 0;
}
diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 7067b6ddc1db..baebab587de4 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -506,8 +506,10 @@ static void dwc_handle_error(struct dw_dma *dw, struct dw_dma_chan *dwc)
* controller flagged an error instead of scribbling over
* random memory locations.
*/
- dev_WARN(chan2dev(&dwc->chan), "Bad descriptor submitted for DMA!\n"
- " cookie: %d\n", bad_desc->txd.cookie);
+ dev_WARN(chan2dev(&dwc->chan), true,
+ "Bad descriptor submitted for DMA!\n cookie: %d\n",
+ bad_desc->txd.cookie);
+
dwc_dump_lli(dwc, &bad_desc->lli);
list_for_each_entry(child, &bad_desc->tx_list, desc_node)
dwc_dump_lli(dwc, &child->lli);
diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
index 4ef0c5e07912..b49b2944e38d 100644
--- a/drivers/dma/ioat/init.c
+++ b/drivers/dma/ioat/init.c
@@ -741,7 +741,7 @@ static int ioat_alloc_chan_resources(struct dma_chan *c)
chanerr = readl(ioat_chan->reg_base + IOAT_CHANERR_OFFSET);
- dev_WARN(to_dev(ioat_chan),
+ dev_WARN(to_dev(ioat_chan), true,
"failed to start channel chanerr: %#x\n", chanerr);
ioat_free_chan_resources(c);
return -EFAULT;
diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 49658ca39e51..2ff56995f436 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -297,10 +297,10 @@ int fimc_is_wait_event(struct fimc_is *is, unsigned long bit,
int ret = wait_event_timeout(is->irq_queue,
!state ^ test_bit(bit, &is->state),
timeout);
- if (ret == 0) {
- dev_WARN(&is->pdev->dev, "%s() timed out\n", __func__);
+
+ if (dev_WARN(&is->pdev->dev, ret == 0, "%s() timed out\n", __func__))
return -ETIME;
- }
+
return 0;
}
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index 4b85105dc159..67ca6b2dbf06 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -838,7 +838,7 @@ static int s5pcsis_probe(struct platform_device *pdev)
ret = clk_set_rate(state->clock[CSIS_CLK_MUX],
state->clk_frequency);
else
- dev_WARN(dev, "No clock frequency specified!\n");
+ dev_WARN(dev, true, "No clock frequency specified!\n");
if (ret < 0)
goto e_clkput;
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 53b79c5f0559..8cb32229a52c 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -397,11 +397,9 @@ static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
return;
}
- if (!mvebu_has_ioport(port)) {
- dev_WARN(&port->pcie->pdev->dev,
- "Attempt to set IO when IO is disabled\n");
+ if (dev_WARN(&port->pcie->pdev->dev, !mvebu_has_ioport(port),
+ "Attempt to set IO when IO is disabled\n"))
return;
- }
/*
* We read the PCI-to-PCI bridge emulated registers, and
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index fc48fac003a6..6a4c85f49e88 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -500,10 +500,8 @@ struct phy *phy_get(struct device *dev, const char *string)
int index = 0;
struct phy *phy;
- if (string == NULL) {
- dev_WARN(dev, "missing string\n");
+ if (dev_WARN(dev, string == NULL, "missing string\n"))
return ERR_PTR(-EINVAL);
- }
if (dev->of_node) {
index = of_property_match_string(dev->of_node, "phy-names",
diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
index f9d74d63be7c..bdb0f1470365 100644
--- a/drivers/regulator/pbias-regulator.c
+++ b/drivers/regulator/pbias-regulator.c
@@ -177,7 +177,7 @@ static int pbias_regulator_probe(struct platform_device *pdev)
return -EINVAL;
offset = res->start;
- dev_WARN(&pdev->dev,
+ dev_WARN(&pdev->dev, true,
"using legacy dt data for pbias offset\n");
}
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 85cd2564c157..f6e74028d71c 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3751,9 +3751,9 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id,
if (!err) {
dev_err(hba->dev, "%s: task management cmd 0x%.2x timed-out\n",
__func__, tm_function);
- if (ufshcd_clear_tm_cmd(hba, free_slot))
- dev_WARN(hba->dev, "%s: unable clear tm cmd (slot %d) after timeout\n",
- __func__, free_slot);
+ dev_WARN(hba->dev, ufshcd_clear_tm_cmd(hba, free_slot),
+ "%s: unable clear tm cmd (slot %d) after timeout\n",
+ __func__, free_slot);
err = -ETIMEDOUT;
} else {
err = ufshcd_task_req_compl(hba, free_slot, tm_response);
diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
index 799634b382c6..3f91132d5b66 100644
--- a/drivers/thunderbolt/ctl.c
+++ b/drivers/thunderbolt/ctl.c
@@ -41,7 +41,7 @@ struct tb_ctl {
#define tb_ctl_WARN(ctl, format, arg...) \
- dev_WARN(&(ctl)->nhi->pdev->dev, format, ## arg)
+ dev_WARN(&(ctl)->nhi->pdev->dev, true, format, ## arg)
#define tb_ctl_err(ctl, format, arg...) \
dev_err(&(ctl)->nhi->pdev->dev, format, ## arg)
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index 20a41f7de76f..3f8d6cecbcea 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -51,11 +51,10 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
"%s interrupt at register %#x bit %d (%#x -> %#x)\n",
active ? "enabling" : "disabling", reg, bit, old, new);
- if (new == old)
- dev_WARN(&ring->nhi->pdev->dev,
- "interrupt for %s %d is already %s\n",
- RING_TYPE(ring), ring->hop,
- active ? "enabled" : "disabled");
+ dev_WARN(&ring->nhi->pdev->dev, new == old,
+ "interrupt for %s %d is already %s\n",
+ RING_TYPE(ring), ring->hop,
+ active ? "enabled" : "disabled");
iowrite32(new, ring->nhi->iobase + reg);
}
@@ -189,11 +188,10 @@ static void ring_work(struct work_struct *work)
frame->eof = ring->descriptors[ring->tail].eof;
frame->sof = ring->descriptors[ring->tail].sof;
frame->flags = ring->descriptors[ring->tail].flags;
- if (frame->sof != 0)
- dev_WARN(&ring->nhi->pdev->dev,
- "%s %d got unexpected SOF: %#x\n",
- RING_TYPE(ring), ring->hop,
- frame->sof);
+ dev_WARN(&ring->nhi->pdev->dev, frame->sof != 0,
+ "%s %d got unexpected SOF: %#x\n",
+ RING_TYPE(ring), ring->hop,
+ frame->sof);
/*
* known flags:
* raw not enabled, interupt not set: 0x2=0010
@@ -201,11 +199,10 @@ static void ring_work(struct work_struct *work)
* raw not enabled: 0xb=1011
* partial frame (>MAX_FRAME_SIZE): 0xe=1110
*/
- if (frame->flags != 0xa)
- dev_WARN(&ring->nhi->pdev->dev,
- "%s %d got unexpected flags: %#x\n",
- RING_TYPE(ring), ring->hop,
- frame->flags);
+ dev_WARN(&ring->nhi->pdev->dev, frame->flags != 0xa,
+ "%s %d got unexpected flags: %#x\n",
+ RING_TYPE(ring), ring->hop,
+ frame->flags);
}
ring->tail = (ring->tail + 1) % ring->size;
}
@@ -246,17 +243,17 @@ static struct tb_ring *ring_alloc(struct tb_nhi *nhi, u32 hop, int size,
transmit ? "TX" : "RX", hop, size);
mutex_lock(&nhi->lock);
- if (hop >= nhi->hop_count) {
- dev_WARN(&nhi->pdev->dev, "invalid hop: %d\n", hop);
+ if (dev_WARN(&nhi->pdev->dev, hop >= nhi->hop_count,
+ "invalid hop: %d\n", hop))
goto err;
- }
- if (transmit && nhi->tx_rings[hop]) {
- dev_WARN(&nhi->pdev->dev, "TX hop %d already allocated\n", hop);
+
+ if (dev_WARN(&nhi->pdev->dev, transmit && nhi->tx_rings[hop],
+ "TX hop %d already allocated\n", hop))
goto err;
- } else if (!transmit && nhi->rx_rings[hop]) {
- dev_WARN(&nhi->pdev->dev, "RX hop %d already allocated\n", hop);
+ else if (dev_WARN(&nhi->pdev->dev, !transmit && nhi->rx_rings[hop],
+ "RX hop %d already allocated\n", hop))
goto err;
- }
+
ring = kzalloc(sizeof(*ring), GFP_KERNEL);
if (!ring)
goto err;
@@ -313,10 +310,10 @@ void ring_start(struct tb_ring *ring)
{
mutex_lock(&ring->nhi->lock);
mutex_lock(&ring->lock);
- if (ring->running) {
- dev_WARN(&ring->nhi->pdev->dev, "ring already started\n");
+ if (dev_WARN(&ring->nhi->pdev->dev, ring->running,
+ "ring already started\n"))
goto err;
- }
+
dev_info(&ring->nhi->pdev->dev, "starting %s %d\n",
RING_TYPE(ring), ring->hop);
@@ -359,11 +356,11 @@ void ring_stop(struct tb_ring *ring)
mutex_lock(&ring->lock);
dev_info(&ring->nhi->pdev->dev, "stopping %s %d\n",
RING_TYPE(ring), ring->hop);
- if (!ring->running) {
- dev_WARN(&ring->nhi->pdev->dev, "%s %d already stopped\n",
- RING_TYPE(ring), ring->hop);
+ if (dev_WARN(&ring->nhi->pdev->dev, !ring->running,
+ "%s %d already stopped\n",
+ RING_TYPE(ring), ring->hop))
goto err;
- }
+
ring_interrupt_active(ring, false);
ring_iowrite32options(ring, 0, 0);
@@ -407,11 +404,8 @@ void ring_free(struct tb_ring *ring)
else
ring->nhi->rx_rings[ring->hop] = NULL;
- if (ring->running) {
- dev_WARN(&ring->nhi->pdev->dev, "%s %d still running\n",
- RING_TYPE(ring), ring->hop);
- }
-
+ dev_WARN(&ring->nhi->pdev->dev, ring->running,
+ "%s %d still running\n", RING_TYPE(ring), ring->hop);
dma_free_coherent(&ring->nhi->pdev->dev,
ring->size * sizeof(*ring->descriptors),
ring->descriptors, ring->descriptors_dma);
@@ -515,12 +509,10 @@ static void nhi_shutdown(struct tb_nhi *nhi)
dev_info(&nhi->pdev->dev, "shutdown\n");
for (i = 0; i < nhi->hop_count; i++) {
- if (nhi->tx_rings[i])
- dev_WARN(&nhi->pdev->dev,
- "TX ring %d is still active\n", i);
- if (nhi->rx_rings[i])
- dev_WARN(&nhi->pdev->dev,
- "RX ring %d is still active\n", i);
+ dev_WARN(&nhi->pdev->dev, nhi->tx_rings[i],
+ "TX ring %d is still active\n", i);
+ dev_WARN(&nhi->pdev->dev, nhi->rx_rings[i],
+ "RX ring %d is still active\n", i);
}
nhi_disable_interrupts(nhi);
/*
diff --git a/drivers/thunderbolt/path.c b/drivers/thunderbolt/path.c
index 9562cd026dc0..39eebaac05f2 100644
--- a/drivers/thunderbolt/path.c
+++ b/drivers/thunderbolt/path.c
@@ -53,7 +53,7 @@ struct tb_path *tb_path_alloc(struct tb *tb, int num_hops)
void tb_path_free(struct tb_path *path)
{
if (path->activated) {
- tb_WARN(path->tb, "trying to free an activated path\n")
+ tb_WARN(path->tb, "trying to free an activated path\n");
return;
}
kfree(path->hops);
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 8b0d7cf2b6d6..5735242912f1 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -186,7 +186,7 @@ static inline int tb_port_write(struct tb_port *port, void *buffer,
}
#define tb_err(tb, fmt, arg...) dev_err(&(tb)->nhi->pdev->dev, fmt, ## arg)
-#define tb_WARN(tb, fmt, arg...) dev_WARN(&(tb)->nhi->pdev->dev, fmt, ## arg)
+#define tb_WARN(tb, fmt, arg...) dev_WARN(&(tb)->nhi->pdev->dev, true, fmt, ## arg)
#define tb_warn(tb, fmt, arg...) dev_warn(&(tb)->nhi->pdev->dev, fmt, ## arg)
#define tb_info(tb, fmt, arg...) dev_info(&(tb)->nhi->pdev->dev, fmt, ## arg)
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 3d274778caaf..f33b6e02b9fd 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -444,8 +444,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
*/
/* Check that the pipe's type matches the endpoint's type */
- if (usb_pipetype(urb->pipe) != pipetypes[xfertype])
- dev_WARN(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n",
+ dev_WARN(&dev->dev, usb_pipetype(urb->pipe) != pipetypes[xfertype],
+ "BOGUS urb xfer, pipe %x != type %x\n",
usb_pipetype(urb->pipe), pipetypes[xfertype]);
/* Check against a simple/standard policy */
@@ -471,8 +471,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
allowed &= urb->transfer_flags;
/* warn if submitter gave bogus flags */
- if (allowed != urb->transfer_flags)
- dev_WARN(&dev->dev, "BOGUS urb flags, %x --> %x\n",
+ dev_WARN(&dev->dev, allowed != urb->transfer_flags,
+ "BOGUS urb flags, %x --> %x\n",
urb->transfer_flags, allowed);
/*
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 22e9606d8e08..cf5694137480 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -266,7 +266,7 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
break;
default:
- dev_WARN(omap->dev, "invalid state\n");
+ dev_WARN(omap->dev, true, "invalid state\n");
}
}
@@ -398,7 +398,7 @@ static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap)
reg &= ~USBOTGSS_UTMI_OTG_CTRL_SW_MODE;
break;
default:
- dev_WARN(omap->dev, "UNKNOWN utmi mode %d\n", utmi_mode);
+ dev_WARN(omap->dev, true, "UNKNOWN utmi mode %d\n", utmi_mode);
}
dwc3_omap_write_utmi_ctrl(omap, reg);
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 5320e939e090..01d2d1bf28d8 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -140,10 +140,9 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
direction = !!(dep->flags & DWC3_EP0_DIR_IN);
- if (dwc->ep0state != EP0_DATA_PHASE) {
- dev_WARN(dwc->dev, "Unexpected pending request\n");
+ if (dev_WARN(dwc->dev, dwc->ep0state != EP0_DATA_PHASE,
+ "Unexpected pending request\n"))
return 0;
- }
__dwc3_ep0_do_control_data(dwc, dwc->eps[direction], req);
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index e24a01cc98df..beca407b7eb2 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2572,7 +2572,7 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,
dwc3_trace(trace_dwc3_gadget, "Overflow");
break;
default:
- dev_WARN(dwc->dev, "UNKNOWN IRQ %d\n", event->type);
+ dev_WARN(dwc->dev, true, "UNKNOWN IRQ %d\n", event->type);
}
}
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index da6f56d996ce..0d55e94e1246 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -123,10 +123,11 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci)
static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td)
{
- if (!list_empty(&td->list))
- dev_WARN(uhci_dev(uhci), "td %p still in list!\n", td);
- if (!list_empty(&td->fl_list))
- dev_WARN(uhci_dev(uhci), "td %p still in fl_list!\n", td);
+ dev_WARN(uhci_dev(uhci), !list_empty(&td->list),
+ "td %p still in list!\n", td);
+
+ dev_WARN(uhci_dev(uhci), !list_empty(&td->fl_list),
+ "td %p still in fl_list!\n", td);
dma_pool_free(uhci->td_pool, td, td->dma_handle);
}
@@ -293,8 +294,9 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci,
static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
{
WARN_ON(qh->state != QH_STATE_IDLE && qh->udev);
- if (!list_empty(&qh->queue))
- dev_WARN(uhci_dev(uhci), "qh %p list not empty!\n", qh);
+
+ dev_WARN(uhci_dev(uhci), !list_empty(&qh->queue),
+ "qh %p list not empty!\n", qh);
list_del(&qh->node);
if (qh->udev) {
@@ -743,9 +745,9 @@ static void uhci_free_urb_priv(struct uhci_hcd *uhci,
{
struct uhci_td *td, *tmp;
- if (!list_empty(&urbp->node))
- dev_WARN(uhci_dev(uhci), "urb %p still on QH's list!\n",
- urbp->urb);
+ dev_WARN(uhci_dev(uhci), !list_empty(&urbp->node),
+ "urb %p still on QH's list!\n",
+ urbp->urb);
list_for_each_entry_safe(td, tmp, &urbp->td_list, list) {
uhci_remove_td_from_urbp(td);
diff --git a/include/linux/device.h b/include/linux/device.h
index b8f411b57dcb..46eca8c83e8b 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1288,8 +1288,9 @@ do { \
* dev_WARN*() acts like dev_printk(), but with the key difference of
* using WARN/WARN_ONCE to include file/line information and a backtrace.
*/
-#define dev_WARN(dev, format, arg...) \
- WARN(1, "%s %s: " format, dev_driver_string(dev), dev_name(dev), ## arg);
+#define dev_WARN(dev, condition, format, arg...) \
+ WARN(condition, "%s %s: " format, \
+ dev_driver_string(dev), dev_name(dev), ## arg)
#define dev_WARN_ONCE(dev, condition, format, arg...) \
WARN_ONCE(condition, "%s %s: " format, \
--
2.6.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists