Hi Damien, A few nits and stuff:
Firstly, you must include a better subject line. E.g. [PATCH] sunxi: w1: Fix module unloading On Mon, May 5, 2014 at 8:17 AM, Damien Nicolet <zar...@gmail.com> wrote: > It is now possible to unload the module And a better description. E.g. Fix static platform_device causing module unloading to fail. > Signed-off-by: Damien Nicolet <zar...@gmail.com> > --- > drivers/w1/w1_sunxi.c | 55 > ++++++++++++++++++++++++++++++++++--------------- > 1 file changed, 38 insertions(+), 17 deletions(-) > > diff --git a/drivers/w1/w1_sunxi.c b/drivers/w1/w1_sunxi.c > index de24f06..e811cfe 100644 > --- a/drivers/w1/w1_sunxi.c > +++ b/drivers/w1/w1_sunxi.c > @@ -9,35 +9,56 @@ static int gpio = -1; > module_param(gpio, int, 0444); > MODULE_PARM_DESC(gpio, "w1 gpio pin number"); > > -static struct w1_gpio_platform_data w1_gpio_pdata = { > - .pin = -1, > - .is_open_drain = 0, > -}; > - > -static struct platform_device w1_device = { > - .name = "w1-gpio", > - .id = -1, > - .dev.platform_data = &w1_gpio_pdata, > -}; > +static struct platform_device *w1_device; > > static int __init w1_sunxi_init(void) > { > - int ret; > - if (!gpio_is_valid(gpio)) { > + int ret = 0; > + struct w1_gpio_platform_data w1_gpio_pdata = { > + .pin = gpio, > + .is_open_drain = 0, > + }; > + > + if (!gpio_is_valid(w1_gpio_pdata.pin)) { > ret = > script_parser_fetch("w1_para", "gpio", &gpio, > sizeof(int)); > if (ret || !gpio_is_valid(gpio)) { > - pr_err("invalid gpio pin : %d\n", gpio); > - return -EINVAL; > + pr_err("invalid gpio pin in fex configuration : %d\n", > + gpio); > + ret = -EINVAL; > + goto err0; Drop the err0 label as it's simpler to just write "return -EINVAL" here. > } > + w1_gpio_pdata.pin = gpio; > } > - w1_gpio_pdata.pin = gpio; > - return platform_device_register(&w1_device); > + > + w1_device = platform_device_alloc("w1-gpio", 0); > + if (!w1_device) { > + ret = -ENOMEM; > + goto err0; Drop the err0 label as it's shorter to just write "return -ENOMEM" (and drop the braces) here. > + } > + > + ret = > + platform_device_add_data(w1_device, &w1_gpio_pdata, > + sizeof(struct w1_gpio_platform_data)); > + if (ret) > + goto err1; > + > + ret = platform_device_add(w1_device); > + if (ret) > + goto err1; > + > + return 0; > + > +err1: > + platform_device_put(w1_device); > + > +err0: > + return ret; > } > > static void __exit w1_sunxi_exit(void) > { > - platform_device_unregister(&w1_device); > + platform_device_unregister(w1_device); > } > > module_init(w1_sunxi_init); Thanks, -- Julian Calaby Email: julian.cal...@gmail.com Profile: http://www.google.com/profiles/julian.calaby/ .Plan: http://sites.google.com/site/juliancalaby/ -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.