public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: rmk+kernel@armlinux•org.uk (Russell King)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v2 5/7] drm/i2c: tda998x: allocate tda998x_priv inside tda998x_create()
Date: Mon, 30 Jul 2018 17:42:26 +0100	[thread overview]
Message-ID: <E1fkBFa-00048z-Rr@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20180730164137.GD17271@n2100.armlinux.org.uk>

Move the tda998x_priv allocation inside tda998x_create() and simplify
the tda998x_create()'s arguments.  Pass the same to tda998x_destroy().

Signed-off-by: Russell King <rmk+kernel@armlinux•org.uk>
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index 1ea62052f3e0..476161967742 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1567,8 +1567,10 @@ static const struct drm_bridge_funcs tda998x_bridge_funcs = {
 	.enable = tda998x_bridge_enable,
 };
 
-static void tda998x_destroy(struct tda998x_priv *priv)
+static void tda998x_destroy(struct device *dev)
 {
+	struct tda998x_priv *priv = dev_get_drvdata(dev);
+
 	drm_bridge_remove(&priv->bridge);
 
 	/* disable all IRQs and free the IRQ handler */
@@ -1653,13 +1655,21 @@ static void tda998x_set_config(struct tda998x_priv *priv,
 	priv->audio_params = p->audio_params;
 }
 
-static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
+static int tda998x_create(struct device *dev)
 {
+	struct i2c_client *client = to_i2c_client(dev);
 	struct device_node *np = client->dev.of_node;
 	struct i2c_board_info cec_info;
+	struct tda998x_priv *priv;
 	u32 video;
 	int rev_lo, rev_hi, ret;
 
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	dev_set_drvdata(dev, priv);
+
 	mutex_init(&priv->mutex);	/* protect the page access */
 	mutex_init(&priv->audio_mutex); /* protect access from audio thread */
 	mutex_init(&priv->edid_mutex);
@@ -1832,7 +1842,7 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
 	return 0;
 
 fail:
-	tda998x_destroy(priv);
+	tda998x_destroy(dev);
 err_irq:
 	return ret;
 }
@@ -1884,24 +1894,16 @@ static int tda998x_encoder_init(struct device *dev, struct drm_device *drm)
 
 static int tda998x_bind(struct device *dev, struct device *master, void *data)
 {
-	struct i2c_client *client = to_i2c_client(dev);
 	struct drm_device *drm = data;
-	struct tda998x_priv *priv;
 	int ret;
 
-	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	dev_set_drvdata(dev, priv);
-
-	ret = tda998x_create(client, priv);
+	ret = tda998x_create(dev);
 	if (ret)
 		return ret;
 
 	ret = tda998x_encoder_init(dev, drm);
 	if (ret) {
-		tda998x_destroy(priv);
+		tda998x_destroy(dev);
 		return ret;
 	}
 	return 0;
@@ -1913,7 +1915,7 @@ 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(priv);
+	tda998x_destroy(dev);
 }
 
 static const struct component_ops tda998x_ops = {
-- 
2.7.4

  parent reply	other threads:[~2018-07-30 16:42 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-30 16:41 [PATCH v2 0/7] tda998x: allow use with bridge based devices Russell King - ARM Linux
2018-07-30 16:42 ` [PATCH v2 1/7] drm/i2c: tda998x: find the drm_device via the drm_connector Russell King
2018-07-30 16:42 ` [PATCH v2 2/7] drm/i2c: tda998x: split tda998x_encoder_dpms into enable/disable Russell King
2018-07-31  5:46   ` Peter Rosin
2018-07-30 16:42 ` [PATCH v2 3/7] drm/i2c: tda998x: move tda998x_set_config() into tda998x_create() Russell King
2018-07-30 16:42 ` [PATCH v2 4/7] drm/i2c: tda998x: convert to bridge driver Russell King
2018-07-31  7:37   ` Peter Rosin
2018-08-08 19:09   ` Sean Paul
2018-08-08 22:15     ` Russell King - ARM Linux
2018-08-10 16:11       ` Sean Paul
2018-08-10 16:50         ` Russell King - ARM Linux
2018-08-10 17:02           ` Sean Paul
2018-08-10 17:16             ` Russell King - ARM Linux
2018-08-14 10:42               ` Daniel Vetter
2018-08-14 10:48                 ` Russell King - ARM Linux
2018-08-14 11:11                   ` Daniel Vetter
2018-08-27 16:15   ` Andrzej Hajda
2018-08-27 17:59     ` Russell King - ARM Linux
2018-08-28  7:31       ` Andrzej Hajda
2018-07-30 16:42 ` Russell King [this message]
2018-07-30 16:42 ` [PATCH v2 6/7] drm/i2c: tda998x: cleanup from previous changes Russell King
2018-07-30 16:42 ` [PATCH v2 7/7] drm/i2c: tda998x: register bridge outside of component helper Russell King
2018-08-27 16:19   ` Andrzej Hajda
2018-07-31  5:44 ` [PATCH v2 0/7] tda998x: allow use with bridge based devices Peter Rosin
2018-07-31  7:41   ` Russell King - ARM Linux
2018-07-31  7:53     ` Peter Rosin
2018-07-31  9:23       ` Russell King - ARM Linux
2018-07-31  9:26         ` [PATCH 1/4] drm/i2c: tda998x: move mode_valid() to bridge Russell King
2018-08-27 16:24           ` Andrzej Hajda
2018-07-31  9:26         ` [PATCH 2/4] drm/i2c: tda998x: get rid of private fill_modes function Russell King
2018-07-31  9:26         ` [PATCH 3/4] drm/i2c: tda998x: correct PLL divider calculation Russell King
2018-07-31  9:26         ` [PATCH 4/4] drm/i2c: tda998x: add support for pixel repeated modes Russell King
2018-07-31  9:42           ` Russell King - ARM Linux
2018-07-31 10:43         ` [PATCH v2 0/7] tda998x: allow use with bridge based devices Peter Rosin
2018-07-31 11:15           ` Russell King - ARM Linux
2018-08-01  9:01             ` Peter Rosin
2018-08-01  9:35               ` Russell King - ARM Linux
2018-08-02  6:06                 ` Peter Rosin
2018-11-12 16:50                   ` Peter Rosin
2018-11-12 17:00                     ` Russell King - ARM Linux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1fkBFa-00048z-Rr@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux$(echo .)org.uk \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox