Re: [PATCH 1/2] usb: r8a66597-udc: fix for udc-newstyle

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

 



Hi,

On Mon, Oct 31, 2011 at 04:01:29PM +0900, Yoshihiro Shimoda wrote:
> The udc-newstyle needs device_register in probe() of platform_device.
> If it doesn't call, kernel panic happens in the sysfs_create_dir() when
> we run modprobe a gadget driver.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>
> ---
>  drivers/usb/gadget/r8a66597-udc.c |   28 +++++++++-------------------
>  1 files changed, 9 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
> index 68a826a..44c3e5e 100644
> --- a/drivers/usb/gadget/r8a66597-udc.c
> +++ b/drivers/usb/gadget/r8a66597-udc.c
> @@ -1742,7 +1742,6 @@ static int r8a66597_start(struct usb_gadget *gadget,
>  		struct usb_gadget_driver *driver)
>  {
>  	struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget);
> -	int retval;
> 
>  	if (!driver
>  			|| driver->speed != USB_SPEED_HIGH
> @@ -1752,16 +1751,7 @@ static int r8a66597_start(struct usb_gadget *gadget,
>  		return -ENODEV;
> 
>  	/* hook up the driver */
> -	driver->driver.bus = NULL;
>  	r8a66597->driver = driver;
> -	r8a66597->gadget.dev.driver = &driver->driver;
> -
> -	retval = device_add(&r8a66597->gadget.dev);
> -	if (retval) {
> -		dev_err(r8a66597_to_dev(r8a66597), "device_add error (%d)\n",
> -			retval);
> -		goto error;
> -	}
> 
>  	init_controller(r8a66597);
>  	r8a66597_bset(r8a66597, VBSE, INTENB0);
> @@ -1775,12 +1765,6 @@ static int r8a66597_start(struct usb_gadget *gadget,
>  	}
> 
>  	return 0;
> -
> -error:
> -	r8a66597->driver = NULL;
> -	r8a66597->gadget.dev.driver = NULL;
> -
> -	return retval;
>  }
> 
>  static int r8a66597_stop(struct usb_gadget *gadget,
> @@ -1794,7 +1778,6 @@ static int r8a66597_stop(struct usb_gadget *gadget,
>  	disable_controller(r8a66597);
>  	spin_unlock_irqrestore(&r8a66597->lock, flags);
> 
> -	device_del(&r8a66597->gadget.dev);
>  	r8a66597->driver = NULL;
>  	return 0;
>  }
> @@ -1845,6 +1828,7 @@ static int __exit r8a66597_remove(struct platform_device *pdev)
>  		clk_put(r8a66597->clk);
>  	}
>  #endif
> +	device_unregister(&r8a66597->gadget.dev);
>  	kfree(r8a66597);
>  	return 0;
>  }
> @@ -1924,13 +1908,17 @@ static int __init r8a66597_probe(struct platform_device *pdev)
>  	r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW;
> 
>  	r8a66597->gadget.ops = &r8a66597_gadget_ops;
> -	device_initialize(&r8a66597->gadget.dev);
>  	dev_set_name(&r8a66597->gadget.dev, "gadget");
>  	r8a66597->gadget.is_dualspeed = 1;
>  	r8a66597->gadget.dev.parent = &pdev->dev;
>  	r8a66597->gadget.dev.dma_mask = pdev->dev.dma_mask;
>  	r8a66597->gadget.dev.release = pdev->dev.release;
>  	r8a66597->gadget.name = udc_name;
> +	ret = device_register(&r8a66597->gadget.dev);
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "device_register failed\n");
> +		goto clean_up;
> +	}
> 
>  	init_timer(&r8a66597->timer);
>  	r8a66597->timer.function = r8a66597_timer;
> @@ -1945,7 +1933,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
>  			dev_err(&pdev->dev, "cannot get clock \"%s\"\n",
>  				clk_name);
>  			ret = PTR_ERR(r8a66597->clk);
> -			goto clean_up;
> +			goto clean_up_dev;
>  		}
>  		clk_enable(r8a66597->clk);
>  	}
> @@ -2015,6 +2003,8 @@ clean_up2:
>  		clk_put(r8a66597->clk);
>  	}
>  #endif
> +clean_up_dev:
> +	device_unregister(&r8a66597->gadget.dev);

this adds a compile warning:

drivers/usb/gadget/r8a66597-udc.c: In function ‘r8a66597_probe’:
drivers/usb/gadget/r8a66597-udc.c:2006:1: warning: label ‘clean_up_dev’ defined but not used [-Wunused-label]

please check if below is acceptable:

diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
index 44c3e5e..38f9988 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -2002,8 +2002,8 @@ clean_up2:
 		clk_disable(r8a66597->clk);
 		clk_put(r8a66597->clk);
 	}
-#endif
 clean_up_dev:
+#endif
 	device_unregister(&r8a66597->gadget.dev);
 clean_up:
 	if (r8a66597) {

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux