]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/i2c: tda998x: register bridge outside of component helper
authorRussell King <rmk+kernel@armlinux.org.uk>
Thu, 2 Aug 2018 09:25:19 +0000 (10:25 +0100)
committerRussell King <rmk+kernel@armlinux.org.uk>
Tue, 7 Aug 2018 09:32:03 +0000 (10:32 +0100)
Register the bridge outside of the component helper as we have
drivers that wish to use the tda998x without its encoder.

Tested-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
drivers/gpu/drm/i2c/tda998x_drv.c

index f486d85ac5759ce4061a7bc1ef982bff15981f15..a7a4307f7fcb41fc86554127a6333ff6e21e7322 100644 (file)
@@ -1904,18 +1904,8 @@ err_encoder:
 static int tda998x_bind(struct device *dev, struct device *master, void *data)
 {
        struct drm_device *drm = data;
-       int ret;
-
-       ret = tda998x_create(dev);
-       if (ret)
-               return ret;
 
-       ret = tda998x_encoder_init(dev, drm);
-       if (ret) {
-               tda998x_destroy(dev);
-               return ret;
-       }
-       return 0;
+       return tda998x_encoder_init(dev, drm);
 }
 
 static void tda998x_unbind(struct device *dev, struct device *master,
@@ -1924,7 +1914,6 @@ static void tda998x_unbind(struct device *dev, struct device *master,
        struct tda998x_priv *priv = dev_get_drvdata(dev);
 
        drm_encoder_cleanup(&priv->encoder);
-       tda998x_destroy(dev);
 }
 
 static const struct component_ops tda998x_ops = {
@@ -1935,16 +1924,27 @@ static const struct component_ops tda998x_ops = {
 static int
 tda998x_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
+       int ret;
+
        if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
                dev_warn(&client->dev, "adapter does not support I2C\n");
                return -EIO;
        }
-       return component_add(&client->dev, &tda998x_ops);
+
+       ret = tda998x_create(&client->dev);
+       if (ret)
+               return ret;
+
+       ret = component_add(&client->dev, &tda998x_ops);
+       if (ret)
+               tda998x_destroy(&client->dev);
+       return ret;
 }
 
 static int tda998x_remove(struct i2c_client *client)
 {
        component_del(&client->dev, &tda998x_ops);
+       tda998x_destroy(&client->dev);
        return 0;
 }