[RFC][PATCH 2/4 v3] usb: host: ohci-platform: BUG_ON() to WARN_ON() on probe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We should avoid using BUG_ON() in drivers.
This patch switch to use WARN_ON() from BUG_ON(),
and avoid NULL pointer access by new macro.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
---
v2 -> v3

 - BUG_ON -> WARN_ON

 drivers/usb/host/ohci-platform.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 670c705..d2893e6 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -16,6 +16,8 @@
 #include <linux/platform_device.h>
 #include <linux/usb/ohci_pdriver.h>
 
+#define ohci_pdata_get(pdata, x) ((pdata) ? (pdata)->x : 0)
+
 static int ohci_platform_reset(struct usb_hcd *hcd)
 {
 	struct platform_device *pdev = to_platform_device(hcd->self.controller);
@@ -23,11 +25,11 @@ static int ohci_platform_reset(struct usb_hcd *hcd)
 	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
 	int err;
 
-	if (pdata->big_endian_desc)
+	if (ohci_pdata_get(pdata, big_endian_desc))
 		ohci->flags |= OHCI_QUIRK_BE_DESC;
-	if (pdata->big_endian_mmio)
+	if (ohci_pdata_get(pdata, big_endian_mmio))
 		ohci->flags |= OHCI_QUIRK_BE_MMIO;
-	if (pdata->no_big_frame_no)
+	if (ohci_pdata_get(pdata, no_big_frame_no))
 		ohci->flags |= OHCI_QUIRK_FRAME_NO;
 
 	ohci_hcd_init(ohci);
@@ -86,7 +88,7 @@ static int __devinit ohci_platform_probe(struct platform_device *dev)
 	int irq;
 	int err = -ENOMEM;
 
-	BUG_ON(!dev->dev.platform_data);
+	WARN_ON(!dev->dev.platform_data);
 
 	if (usb_disabled())
 		return -ENODEV;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux