drivers: misc: therm_est: Add of_match_table
Jinyoung Park [Thu, 2 May 2013 11:56:05 +0000 (20:56 +0900)]
Added of_match_table in the driver structure.
If there is therm_est binding data in device tree, we don't need to add
platform_device_register() for therm_est device in board file.

Bug 1240803

Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/224875
(cherry picked from commit 71deb2ba7174b010c63155a47c54de9a9ea7f7d7)

Change-Id: Ia85a74d3c7b69c3bd4be7859ec8daa8d09d0a4e1
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/353278
Reviewed-by: Harry Hong <hhong@nvidia.com>
Tested-by: Harry Hong <hhong@nvidia.com>

drivers/misc/therm_est.c

index 5918d24..c775646 100644 (file)
@@ -846,13 +846,12 @@ static int __parse_dt_timer_trip(struct device_node *np,
 static struct therm_est_data *therm_est_get_pdata(struct device *dev)
 {
        struct therm_est_data *data;
-       struct device_node *np;
+       struct device_node *np = dev->of_node;
        struct device_node *ch;
        u32 val;
        int i, j, k, l;
        int ret;
 
-       np = of_find_compatible_node(NULL, NULL, "nvidia,therm-est");
        if (!np)
                return dev->platform_data;
 
@@ -1064,10 +1063,19 @@ static void __devexit therm_est_shutdown(struct platform_device *pdev)
        therm_est_remove(pdev);
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id therm_est_dt_match[] = {
+       { .compatible = "nvidia,therm-est" },
+       { },
+};
+MODULE_DEVICE_TABLE(of, therm_est_dt_match);
+#endif
+
 static struct platform_driver therm_est_driver = {
        .driver = {
                .owner = THIS_MODULE,
                .name  = "therm_est",
+               .of_match_table = of_match_ptr(therm_est_dt_match),
        },
        .probe  = therm_est_probe,
        .remove = __devexit_p(therm_est_remove),