lkml.org 
[lkml]   [2016]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] cocci: Find i2c drivers with an of_device table that isn't exported
    Date
    This script will then add the MODULE_DEVICE_TABLE(of, ...) to correctly export
    the device tree table

    Usage: spatch --sp-file scripts/coccinelle/i2c/i2c_table_missing_export.cocci . --in-place
    ---

    Javier,

    I've been working on scripts to automate some of the conversion processes
    involved in this DT_I2C project.

    This one adds missing exports for i2c device tables.

    Feel free to use it if it helps.

    I have another one which searches for drivers which have both an I2C device table, and an OF device table,
    and a probe function which does not use the second parameter.

    It then performs the conversion to the probe_new() and removes the I2C device table.

    Should help with the bulk of the conversion

    --
    Kieran

    .../coccinelle/i2c/of_table_missing_export.cocci | 34 ++++++++++++++++++++++
    1 file changed, 34 insertions(+)
    create mode 100644 scripts/coccinelle/i2c/of_table_missing_export.cocci

    diff --git a/scripts/coccinelle/i2c/of_table_missing_export.cocci b/scripts/coccinelle/i2c/of_table_missing_export.cocci
    new file mode 100644
    index 000000000000..5d1950fdf8a3
    --- /dev/null
    +++ b/scripts/coccinelle/i2c/of_table_missing_export.cocci
    @@ -0,0 +1,34 @@
    +// Look for I2C drivers without an exported of_device_id table
    +//
    +
    +// C1 : Identify the i2c_device_id array
    +
    +@ i2c_dev_id @
    +identifier arr;
    +@@
    +struct i2c_device_id arr[] = { ... };
    +
    +// C2 : For now, we only want to match on I2C drivers
    +
    +@ dev_id depends on i2c_dev_id @
    +identifier arr;
    +@@
    +struct of_device_id arr[] = { ... };
    +
    +// C2 : Check if we already export the MODULE_DEVICE_TABLE
    +
    +@ of_dev_table depends on dev_id @
    +declarer name MODULE_DEVICE_TABLE;
    +identifier of;
    +identifier dev_id.arr;
    +@@
    + MODULE_DEVICE_TABLE(of, arr);
    +
    +
    +// A1: Export it!
    +
    +@ add_mod_dev_table depends on !of_dev_table @
    +identifier dev_id.arr;
    +@@
    +struct of_device_id arr[] = { ... };
    ++ MODULE_DEVICE_TABLE(of, arr);
    --
    2.5.0
    \
     
     \ /
      Last update: 2016-05-10 17:01    [W:4.128 / U:0.240 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site