All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen-Yu Tsai <wens@csie.org>
To: Maxime Ripard <maxime.ripard@free-electrons.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>
Cc: Chen-Yu Tsai <wens@csie.org>,
	linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Vishnu Patekar <vishnupatekar0510@gmail.com>,
	linux-sunxi@googlegroups.com
Subject: [PATCH RFC 04/11] clk: sunxi: factors: Add unregister function
Date: Mon, 25 Jan 2016 21:15:40 +0800	[thread overview]
Message-ID: <1453727747-23307-5-git-send-email-wens@csie.org> (raw)
In-Reply-To: <1453727747-23307-1-git-send-email-wens@csie.org>

sunxi's factors clk did not have an unregister function. This means
multiple structs were leaked whenever a factors clk was unregistered.

Add an unregister function for it. Also keep pointers to the mux and
gate structs so they can be freed.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/clk/sunxi/clk-factors.c | 24 ++++++++++++++++++++++++
 drivers/clk/sunxi/clk-factors.h |  5 +++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 1de57c22a358..b464ca4a232e 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -202,6 +202,8 @@ struct clk *sunxi_factors_register(struct device_node *node,
 		if (!gate)
 			goto err_gate;
 
+		factors->gate = gate;
+
 		/* set up gate properties */
 		gate->reg = reg;
 		gate->bit_idx = data->enable;
@@ -215,6 +217,8 @@ struct clk *sunxi_factors_register(struct device_node *node,
 		if (!mux)
 			goto err_mux;
 
+		factors->mux = mux;
+
 		/* set up gate properties */
 		mux->reg = reg;
 		mux->shift = data->mux;
@@ -254,3 +258,23 @@ err_gate:
 err_factors:
 	return NULL;
 }
+
+void sunxi_factors_unregister(struct device_node *node, struct clk *clk)
+{
+	struct clk_hw *hw = __clk_get_hw(clk);
+	struct clk_factors *factors;
+	const char *name;
+
+	if (!hw)
+		return;
+
+	factors = to_clk_factors(hw);
+	name = clk_hw_get_name(hw);
+
+	/* No unregister call for clkdev_* */
+	of_clk_del_provider(node);
+	clk_unregister_composite(clk);
+	kfree(factors->mux);
+	kfree(factors->gate);
+	kfree(factors);
+}
diff --git a/drivers/clk/sunxi/clk-factors.h b/drivers/clk/sunxi/clk-factors.h
index 060319be2b99..7ea1379a7cda 100644
--- a/drivers/clk/sunxi/clk-factors.h
+++ b/drivers/clk/sunxi/clk-factors.h
@@ -34,6 +34,9 @@ struct clk_factors {
 	const struct clk_factors_config *config;
 	void (*get_factors) (u32 *rate, u32 parent, u8 *n, u8 *k, u8 *m, u8 *p);
 	spinlock_t *lock;
+	/* for cleanup */
+	struct clk_mux *mux;
+	struct clk_gate *gate;
 };
 
 struct clk *sunxi_factors_register(struct device_node *node,
@@ -41,4 +44,6 @@ struct clk *sunxi_factors_register(struct device_node *node,
 				   spinlock_t *lock,
 				   void __iomem *reg);
 
+void sunxi_factors_unregister(struct device_node *node, struct clk *clk);
+
 #endif
-- 
2.7.0

WARNING: multiple messages have this Message-ID (diff)
From: wens@csie.org (Chen-Yu Tsai)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC 04/11] clk: sunxi: factors: Add unregister function
Date: Mon, 25 Jan 2016 21:15:40 +0800	[thread overview]
Message-ID: <1453727747-23307-5-git-send-email-wens@csie.org> (raw)
In-Reply-To: <1453727747-23307-1-git-send-email-wens@csie.org>

sunxi's factors clk did not have an unregister function. This means
multiple structs were leaked whenever a factors clk was unregistered.

Add an unregister function for it. Also keep pointers to the mux and
gate structs so they can be freed.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/clk/sunxi/clk-factors.c | 24 ++++++++++++++++++++++++
 drivers/clk/sunxi/clk-factors.h |  5 +++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 1de57c22a358..b464ca4a232e 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -202,6 +202,8 @@ struct clk *sunxi_factors_register(struct device_node *node,
 		if (!gate)
 			goto err_gate;
 
+		factors->gate = gate;
+
 		/* set up gate properties */
 		gate->reg = reg;
 		gate->bit_idx = data->enable;
@@ -215,6 +217,8 @@ struct clk *sunxi_factors_register(struct device_node *node,
 		if (!mux)
 			goto err_mux;
 
+		factors->mux = mux;
+
 		/* set up gate properties */
 		mux->reg = reg;
 		mux->shift = data->mux;
@@ -254,3 +258,23 @@ err_gate:
 err_factors:
 	return NULL;
 }
+
+void sunxi_factors_unregister(struct device_node *node, struct clk *clk)
+{
+	struct clk_hw *hw = __clk_get_hw(clk);
+	struct clk_factors *factors;
+	const char *name;
+
+	if (!hw)
+		return;
+
+	factors = to_clk_factors(hw);
+	name = clk_hw_get_name(hw);
+
+	/* No unregister call for clkdev_* */
+	of_clk_del_provider(node);
+	clk_unregister_composite(clk);
+	kfree(factors->mux);
+	kfree(factors->gate);
+	kfree(factors);
+}
diff --git a/drivers/clk/sunxi/clk-factors.h b/drivers/clk/sunxi/clk-factors.h
index 060319be2b99..7ea1379a7cda 100644
--- a/drivers/clk/sunxi/clk-factors.h
+++ b/drivers/clk/sunxi/clk-factors.h
@@ -34,6 +34,9 @@ struct clk_factors {
 	const struct clk_factors_config *config;
 	void (*get_factors) (u32 *rate, u32 parent, u8 *n, u8 *k, u8 *m, u8 *p);
 	spinlock_t *lock;
+	/* for cleanup */
+	struct clk_mux *mux;
+	struct clk_gate *gate;
 };
 
 struct clk *sunxi_factors_register(struct device_node *node,
@@ -41,4 +44,6 @@ struct clk *sunxi_factors_register(struct device_node *node,
 				   spinlock_t *lock,
 				   void __iomem *reg);
 
+void sunxi_factors_unregister(struct device_node *node, struct clk *clk);
+
 #endif
-- 
2.7.0

  parent reply	other threads:[~2016-01-25 13:16 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-25 13:15 [PATCH RFC 00/11] clk: sunxi: factors clk clean up and refactor Chen-Yu Tsai
2016-01-25 13:15 ` Chen-Yu Tsai
2016-01-25 13:15 ` [PATCH RFC 01/11] clk: composite: Add unregister function Chen-Yu Tsai
2016-01-25 13:15   ` Chen-Yu Tsai
2016-01-25 13:15 ` [PATCH RFC 02/11] clk: sunxi: factors: Make struct clk_factors_config table const Chen-Yu Tsai
2016-01-25 13:15   ` Chen-Yu Tsai
2016-01-27 15:50   ` Maxime Ripard
2016-01-27 15:50     ` Maxime Ripard
2016-01-25 13:15 ` [PATCH RFC 03/11] clk: sunxi: factors: Add clk cleanup in sunxi_factors_register() error path Chen-Yu Tsai
2016-01-25 13:15   ` Chen-Yu Tsai
2016-01-27 15:51   ` Maxime Ripard
2016-01-27 15:51     ` Maxime Ripard
2016-01-25 13:15 ` Chen-Yu Tsai [this message]
2016-01-25 13:15   ` [PATCH RFC 04/11] clk: sunxi: factors: Add unregister function Chen-Yu Tsai
2016-01-27 15:52   ` Maxime Ripard
2016-01-27 15:52     ` Maxime Ripard
2016-01-27 18:08     ` Maxime Ripard
2016-01-27 18:08       ` Maxime Ripard
2016-01-25 13:15 ` [PATCH RFC 05/11] clk: sunxi: unmap registers in sunxi_factors_clk_setup if register call fails Chen-Yu Tsai
2016-01-25 13:15   ` Chen-Yu Tsai
2016-01-27 15:52   ` Maxime Ripard
2016-01-27 15:52     ` Maxime Ripard
2016-01-25 13:15 ` [PATCH RFC 06/11] clk: sunxi: factors: Consolidate get_factors parameters into a struct Chen-Yu Tsai
2016-01-25 13:15   ` Chen-Yu Tsai
2016-01-27 17:29   ` Maxime Ripard
2016-01-27 17:29     ` Maxime Ripard
2016-01-25 13:15 ` [PATCH RFC 07/11] clk: sunxi: factors: Support custom formulas Chen-Yu Tsai
2016-01-25 13:15   ` Chen-Yu Tsai
2016-01-27 17:32   ` Maxime Ripard
2016-01-27 17:32     ` Maxime Ripard
2016-01-25 13:15 ` [PATCH RFC 08/11] clk: sunxi: factors: Drop round_rate from clk ops Chen-Yu Tsai
2016-01-25 13:15   ` Chen-Yu Tsai
2016-01-27 17:33   ` Maxime Ripard
2016-01-27 17:33     ` Maxime Ripard
2016-01-25 13:15 ` [PATCH RFC 09/11] clk: sunxi: rewrite sun6i-a31-ahb1-clk using factors clk with custom recalc Chen-Yu Tsai
2016-01-25 13:15   ` Chen-Yu Tsai
2016-01-27 17:41   ` Maxime Ripard
2016-01-27 17:41     ` Maxime Ripard
2016-01-25 13:15 ` [PATCH RFC 10/11] clk: sunxi: rewrite sun6i-ar100 using factors clk Chen-Yu Tsai
2016-01-25 13:15   ` Chen-Yu Tsai
2016-01-27 17:47   ` Maxime Ripard
2016-01-27 17:47     ` Maxime Ripard
2016-01-31 16:59   ` Paul Gortmaker
2016-01-31 16:59     ` Paul Gortmaker
2016-01-31 16:59     ` Paul Gortmaker
2016-02-05 13:03     ` Chen-Yu Tsai
2016-02-05 13:03       ` Chen-Yu Tsai
2016-02-02 15:55   ` [PATCH] clk: sunxi: don't mark sun6i_ar100_data __initconst Arnd Bergmann
2016-02-02 15:55     ` Arnd Bergmann
2016-02-02 17:33     ` Maxime Ripard
2016-02-02 17:33       ` Maxime Ripard
2016-01-25 13:15 ` [PATCH RFC 11/11] clk: sunxi: rewrite sun8i-a23-mbus-clk using the simpler composite clk Chen-Yu Tsai
2016-01-25 13:15   ` Chen-Yu Tsai
2016-01-27 17:49   ` Maxime Ripard
2016-01-27 17:49     ` Maxime Ripard
2016-01-28  2:41     ` Chen-Yu Tsai
2016-01-28  2:41       ` Chen-Yu Tsai
2016-02-01 20:24       ` Maxime Ripard
2016-02-01 20:24         ` Maxime Ripard
2016-01-27 19:13 ` [PATCH RFC 00/11] clk: sunxi: factors clk clean up and refactor Maxime Ripard
2016-01-27 19:13   ` Maxime Ripard

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=1453727747-23307-5-git-send-email-wens@csie.org \
    --to=wens@csie.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    --cc=vishnupatekar0510@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.