Subject: Re: therm_pm72 units, interface

From: Michel Dänzer <[email-masked]>
Date: Mon, 05 Aug 2013 11:13:13 +0200

On Sam, 2013-08-03 at 07:02 +1000, Benjamin Herrenschmidt wrote:
> On Fri, 2013-08-02 at 18:52 +0200, Michel Dänzer wrote:
> 
> > Thanks for the suggestion. The same windfarm modules were loaded in both
> > cases, but i2c_powermac wasn't loaded with the newer kernels. Loading it
> > manually fixes the problem.
> > 
> > How is i2c_powermac supposed to get loaded with current kernels?
> 
> It's a platform driver, but it's missing a module device-table
> 
> Can you try this completely untested patch ?
> 
> diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
> index 8dc90da..5af5153 100644
> --- a/drivers/i2c/busses/i2c-powermac.c
> +++ b/drivers/i2c/busses/i2c-powermac.c
> @@ -458,9 +458,15 @@ static int i2c_powermac_probe(struct platform_device *dev)
>  	return rc;
>  }
>  
> +static const struct platform_device_id i2c_powermac_id = {
> +	.name = "i2c-powermac"
> +};
> +MODULE_DEVICE_TABLE(platform, i2c_powermac_id);
> +
>  static struct platform_driver i2c_powermac_driver = {
>  	.probe = i2c_powermac_probe,
>  	.remove = i2c_powermac_remove,
> +	.id_table = *i2c_powermac_id,

This fails to build:

  CC [M]  drivers/i2c/busses/i2c-powermac.o
drivers/i2c/busses/i2c-powermac.c:469:14: error: invalid type argument of unary ‘*’ (have ‘const struct platform_device_id’)
make[1]: *** [drivers/i2c/busses/i2c-powermac.o] Error 1

The version below builds, but the module still doesn't get loaded
automagically (unless I'm missing some command I need to run between
copying the new module to /lib/modules/$(uname -r)/ and rebooting?).

Looking at other drivers in drivers/i2c/busses/, maybe
i2c_powermac_driver.driver needs an of_match_table entry?

diff --git a/drivers/i2c/busses/i2c-powermac.c
b/drivers/i2c/busses/i2c-powermac.c
index 8dc90da..74066fc 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -458,9 +458,19 @@ static int i2c_powermac_probe(struct
platform_device *dev)
        return rc;
 }

+static const struct platform_device_id i2c_powermac_id[] = {
+       {
+               .name = "i2c-powermac"
+       }, {
+               /* sentinel */
+       }
+};
+MODULE_DEVICE_TABLE(platform, i2c_powermac_id);
+
 static struct platform_driver i2c_powermac_driver = {
        .probe = i2c_powermac_probe,
        .remove = i2c_powermac_remove,
+       .id_table = i2c_powermac_id,
        .driver = {
                .name = "i2c-powermac",
                .bus = &platform_bus_type,
@@ -468,5 +478,3 @@ static struct platform_driver i2c_powermac_driver =
{
 };

 module_platform_driver(i2c_powermac_driver);
-
-MODULE_ALIAS("platform:i2c-powermac");

-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer