Re: [RFC][PATCH 1/4 v3] usb: host: ehci-platform: BUG_ON() to WARN_ON() on probe

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


On Sun, Aug 05, 2012 at 06:51:34PM -0700, kuninori.morimoto.gx@xxxxxxxxxxx wrote:
> 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/ehci-platform.c |   18 ++++++++++--------
>  1 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
> index 4b1d896..db27dfe 100644
> --- a/drivers/usb/host/ehci-platform.c
> +++ b/drivers/usb/host/ehci-platform.c
> @@ -21,6 +21,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/usb/ehci_pdriver.h>
>  
> +#define ehci_pdata_get(pdata, x) ((pdata) ? (pdata)->x : 0)
> +

FWIW, I think that an inline function would be a slight improvement over
a macro here.  Likewise for the 2nd patch of this series.

>  static int ehci_platform_reset(struct usb_hcd *hcd)
>  {
>  	struct platform_device *pdev = to_platform_device(hcd->self.controller);
> @@ -28,19 +30,19 @@ static int ehci_platform_reset(struct usb_hcd *hcd)
>  	struct ehci_hcd *ehci = hcd_to_ehci(hcd);
>  	int retval;
>  
> -	hcd->has_tt = pdata->has_tt;
> -	ehci->has_synopsys_hc_bug = pdata->has_synopsys_hc_bug;
> -	ehci->big_endian_desc = pdata->big_endian_desc;
> -	ehci->big_endian_mmio = pdata->big_endian_mmio;
> +	hcd->has_tt = ehci_pdata_get(pdata, has_tt);
> +	ehci->has_synopsys_hc_bug = ehci_pdata_get(pdata, has_synopsys_hc_bug);
> +	ehci->big_endian_desc = ehci_pdata_get(pdata, big_endian_desc);
> +	ehci->big_endian_mmio = ehci_pdata_get(pdata, big_endian_mmio);
>  
> -	ehci->caps = hcd->regs + pdata->caps_offset;
> +	ehci->caps = hcd->regs + ehci_pdata_get(pdata, caps_offset);
>  	retval = ehci_setup(hcd);
>  	if (retval)
>  		return retval;
>  
> -	if (pdata->port_power_on)
> +	if (ehci_pdata_get(pdata, port_power_on))
>  		ehci_port_power(ehci, 1);
> -	if (pdata->port_power_off)
> +	if (ehci_pdata_get(pdata, port_power_off))
>  		ehci_port_power(ehci, 0);
>  
>  	return 0;
> @@ -85,7 +87,7 @@ static int __devinit ehci_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


B and H Foto and Electronics Corp.

[Linux Media]     [Video for Linux]     [Linux Input]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Free Online Dating]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]     [More Archives]

Add to Google Powered by Linux