fpga: dfl: make init callback optional
authorWu Hao <hao.wu@intel.com>
Mon, 12 Aug 2019 02:49:56 +0000 (10:49 +0800)
committerMoritz Fischer <mdf@kernel.org>
Wed, 4 Sep 2019 02:35:40 +0000 (19:35 -0700)
This patch makes init callback of sub features optional. With
this change, people don't need to prepare any empty init callback.

Signed-off-by: Wu Hao <hao.wu@intel.com>
Acked-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
drivers/fpga/dfl.c

index c0512af..96a2b82 100644 (file)
@@ -271,11 +271,13 @@ static int dfl_feature_instance_init(struct platform_device *pdev,
                                     struct dfl_feature *feature,
                                     struct dfl_feature_driver *drv)
 {
-       int ret;
+       int ret = 0;
 
-       ret = drv->ops->init(pdev, feature);
-       if (ret)
-               return ret;
+       if (drv->ops->init) {
+               ret = drv->ops->init(pdev, feature);
+               if (ret)
+                       return ret;
+       }
 
        feature->ops = drv->ops;