From: mturquette@linaro.org (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 08/35] clk: ti: fix ti_clk_get_reg_addr error handling
Date: Fri, 06 Mar 2015 11:18:21 -0800 [thread overview]
Message-ID: <20150306191821.11109.2610@quantum> (raw)
In-Reply-To: <1424891085-10392-9-git-send-email-t-kristo@ti.com>
Quoting Tero Kristo (2015-02-25 11:04:18)
> There is a case where NULL can be a valid return value for
> ti_clk_get_reg_addr, specifically the case where both the provider index
> and register offsets are zero. In this case, the current error checking
> against a NULL pointer will fail. Thus, change the API to return a
> ERR_PTR value in an error case, and change all the users of this API to
> check against IS_ERR instead.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> Cc: Michael Turquette <mturquette@linaro.org>
Looks good to me.
Regards,
Mike
> ---
> drivers/clk/ti/apll.c | 5 +++--
> drivers/clk/ti/autoidle.c | 2 +-
> drivers/clk/ti/clk.c | 7 ++++---
> drivers/clk/ti/divider.c | 4 ++--
> drivers/clk/ti/dpll.c | 6 +++---
> drivers/clk/ti/gate.c | 4 ++--
> drivers/clk/ti/interface.c | 2 +-
> drivers/clk/ti/mux.c | 4 ++--
> 8 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/clk/ti/apll.c b/drivers/clk/ti/apll.c
> index 72d9727..49baf38 100644
> --- a/drivers/clk/ti/apll.c
> +++ b/drivers/clk/ti/apll.c
> @@ -203,7 +203,7 @@ static void __init of_dra7_apll_setup(struct device_node *node)
> ad->control_reg = ti_clk_get_reg_addr(node, 0);
> ad->idlest_reg = ti_clk_get_reg_addr(node, 1);
>
> - if (!ad->control_reg || !ad->idlest_reg)
> + if (IS_ERR(ad->control_reg) || IS_ERR(ad->idlest_reg))
> goto cleanup;
>
> ad->idlest_mask = 0x1;
> @@ -384,7 +384,8 @@ static void __init of_omap2_apll_setup(struct device_node *node)
> ad->autoidle_reg = ti_clk_get_reg_addr(node, 1);
> ad->idlest_reg = ti_clk_get_reg_addr(node, 2);
>
> - if (!ad->control_reg || !ad->autoidle_reg || !ad->idlest_reg)
> + if (IS_ERR(ad->control_reg) || IS_ERR(ad->autoidle_reg) ||
> + IS_ERR(ad->idlest_reg))
> goto cleanup;
>
> clk = clk_register(NULL, &clk_hw->hw);
> diff --git a/drivers/clk/ti/autoidle.c b/drivers/clk/ti/autoidle.c
> index 8912ff8..e75c64c 100644
> --- a/drivers/clk/ti/autoidle.c
> +++ b/drivers/clk/ti/autoidle.c
> @@ -119,7 +119,7 @@ int __init of_ti_clk_autoidle_setup(struct device_node *node)
> clk->name = node->name;
> clk->reg = ti_clk_get_reg_addr(node, 0);
>
> - if (!clk->reg) {
> + if (IS_ERR(clk->reg)) {
> kfree(clk);
> return -EINVAL;
> }
> diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
> index e22b956..0ebe5c5 100644
> --- a/drivers/clk/ti/clk.c
> +++ b/drivers/clk/ti/clk.c
> @@ -103,7 +103,8 @@ int __init ti_clk_retry_init(struct device_node *node, struct clk_hw *hw,
> * @index: register index from the clock node
> *
> * Builds clock register address from device tree information. This
> - * is a struct of type clk_omap_reg.
> + * is a struct of type clk_omap_reg. Returns a pointer to the register
> + * address, or a pointer error value in failure.
> */
> void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index)
> {
> @@ -121,14 +122,14 @@ void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index)
>
> if (i == CLK_MAX_MEMMAPS) {
> pr_err("clk-provider not found for %s!\n", node->name);
> - return NULL;
> + return ERR_PTR(-ENOENT);
> }
>
> reg->index = i;
>
> if (of_property_read_u32_index(node, "reg", index, &val)) {
> pr_err("%s must have reg[%d]!\n", node->name, index);
> - return NULL;
> + return ERR_PTR(-EINVAL);
> }
>
> reg->offset = val;
> diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c
> index 6211893..ff5f117 100644
> --- a/drivers/clk/ti/divider.c
> +++ b/drivers/clk/ti/divider.c
> @@ -530,8 +530,8 @@ static int __init ti_clk_divider_populate(struct device_node *node,
> u32 val;
>
> *reg = ti_clk_get_reg_addr(node, 0);
> - if (!*reg)
> - return -EINVAL;
> + if (IS_ERR(*reg))
> + return PTR_ERR(*reg);
>
> if (!of_property_read_u32(node, "ti,bit-shift", &val))
> *shift = val;
> diff --git a/drivers/clk/ti/dpll.c b/drivers/clk/ti/dpll.c
> index 81dc469..11478a5 100644
> --- a/drivers/clk/ti/dpll.c
> +++ b/drivers/clk/ti/dpll.c
> @@ -390,18 +390,18 @@ static void __init of_ti_dpll_setup(struct device_node *node,
> #endif
> } else {
> dd->idlest_reg = ti_clk_get_reg_addr(node, 1);
> - if (!dd->idlest_reg)
> + if (IS_ERR(dd->idlest_reg))
> goto cleanup;
>
> dd->mult_div1_reg = ti_clk_get_reg_addr(node, 2);
> }
>
> - if (!dd->control_reg || !dd->mult_div1_reg)
> + if (IS_ERR(dd->control_reg) || IS_ERR(dd->mult_div1_reg))
> goto cleanup;
>
> if (dd->autoidle_mask) {
> dd->autoidle_reg = ti_clk_get_reg_addr(node, 3);
> - if (!dd->autoidle_reg)
> + if (IS_ERR(dd->autoidle_reg))
> goto cleanup;
> }
>
> diff --git a/drivers/clk/ti/gate.c b/drivers/clk/ti/gate.c
> index d493307..0c6fdfc 100644
> --- a/drivers/clk/ti/gate.c
> +++ b/drivers/clk/ti/gate.c
> @@ -225,7 +225,7 @@ static void __init _of_ti_gate_clk_setup(struct device_node *node,
>
> if (ops != &omap_gate_clkdm_clk_ops) {
> reg = ti_clk_get_reg_addr(node, 0);
> - if (!reg)
> + if (IS_ERR(reg))
> return;
>
> if (!of_property_read_u32(node, "ti,bit-shift", &val))
> @@ -264,7 +264,7 @@ _of_ti_composite_gate_clk_setup(struct device_node *node,
> return;
>
> gate->enable_reg = ti_clk_get_reg_addr(node, 0);
> - if (!gate->enable_reg)
> + if (IS_ERR(gate->enable_reg))
> goto cleanup;
>
> of_property_read_u32(node, "ti,bit-shift", &val);
> diff --git a/drivers/clk/ti/interface.c b/drivers/clk/ti/interface.c
> index 265d91f..c76230d 100644
> --- a/drivers/clk/ti/interface.c
> +++ b/drivers/clk/ti/interface.c
> @@ -111,7 +111,7 @@ static void __init _of_ti_interface_clk_setup(struct device_node *node,
> u32 val;
>
> reg = ti_clk_get_reg_addr(node, 0);
> - if (!reg)
> + if (IS_ERR(reg))
> return;
>
> if (!of_property_read_u32(node, "ti,bit-shift", &val))
> diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c
> index 728e253..5cdeed5 100644
> --- a/drivers/clk/ti/mux.c
> +++ b/drivers/clk/ti/mux.c
> @@ -210,7 +210,7 @@ static void of_mux_clk_setup(struct device_node *node)
>
> reg = ti_clk_get_reg_addr(node, 0);
>
> - if (!reg)
> + if (IS_ERR(reg))
> goto cleanup;
>
> of_property_read_u32(node, "ti,bit-shift", &shift);
> @@ -283,7 +283,7 @@ static void __init of_ti_composite_mux_clk_setup(struct device_node *node)
>
> mux->reg = ti_clk_get_reg_addr(node, 0);
>
> - if (!mux->reg)
> + if (IS_ERR(mux->reg))
> goto cleanup;
>
> if (!of_property_read_u32(node, "ti,bit-shift", &val))
> --
> 1.7.9.5
>
next prev parent reply other threads:[~2015-03-06 19:18 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-25 19:04 [PATCHv3 00/35] ARM: OMAP2+: PRCM / SCM cleanups against 4.0-rc1 Tero Kristo
2015-02-25 19:04 ` [PATCHv3 01/35] ARM: OMAP2+: PRCM: rename of_prcm_init to omap_prcm_init Tero Kristo
2015-02-25 19:04 ` [PATCHv3 02/35] ARM: OMAP3: PRM: invert the wkst_mask for the prm_clear_mod_irqs Tero Kristo
2015-02-25 19:04 ` [PATCHv3 03/35] ARM: OMAP2+: PRM: add generic API for clear_mod_irqs Tero Kristo
2015-02-25 19:08 ` Felipe Balbi
2015-02-25 19:04 ` [PATCHv3 04/35] ARM: OMAP3+: PRM: add common APIs for prm_vp_check/clear_txdone Tero Kristo
2015-02-25 19:09 ` Felipe Balbi
2015-02-25 19:44 ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 05/35] ARM: OMAP4+: PRM: move omap_prm_base_init under OMAP4 PRM driver Tero Kristo
2015-02-25 19:04 ` [PATCHv3 06/35] ARM: OMAP4+: CM: move omap_cm_base_init under OMAP4 CM driver Tero Kristo
2015-02-25 19:04 ` [PATCHv3 07/35] ARM: OMAP4: PRM: move omap4xxx_prm_init earlier in init order Tero Kristo
2015-02-25 19:04 ` [PATCHv3 08/35] clk: ti: fix ti_clk_get_reg_addr error handling Tero Kristo
2015-03-06 19:18 ` Mike Turquette [this message]
2015-03-17 18:38 ` Tony Lindgren
2015-03-18 7:06 ` Tero Kristo
2015-03-18 17:02 ` Tony Lindgren
2015-03-19 7:14 ` Tero Kristo
2015-03-20 7:00 ` Tero Kristo
2015-02-25 19:04 ` [PATCHv3 09/35] Documentation: DT: document PRCM compatible strings for dm81x SoCs Tero Kristo
2015-02-25 19:04 ` [PATCHv3 10/35] ARM: OMAP2+: PRCM: add support for static clock memmap indices Tero Kristo
2015-02-25 19:04 ` [PATCHv3 11/35] ARM: OMAP2+: clock: move clock provider infrastructure to clock driver Tero Kristo
2015-02-25 19:04 ` [PATCHv3 12/35] ARM: OMAP2+: PRCM: split PRCM module init to their own driver files Tero Kristo
2015-02-25 19:04 ` [PATCHv3 13/35] ARM: OMAP2+: CM: determine CM base address from device tree Tero Kristo
2015-02-25 19:04 ` [PATCHv3 14/35] ARM: OMAP2+: PRM: determine PRM " Tero Kristo
2015-02-25 19:04 ` [PATCHv3 15/35] ARM: OMAP2+: control: determine control module base address from DT Tero Kristo
2015-02-25 19:04 ` [PATCHv3 16/35] ARM: OMAP2+: PRM: move SoC specific init calls within a generic API Tero Kristo
2015-02-25 19:04 ` [PATCHv3 17/35] ARM: OMAP4+: PRM: determine prm_device_inst based on DT compatibility Tero Kristo
2015-02-25 19:04 ` [PATCHv3 18/35] ARM: OMAP2+: CM: move SoC specific init calls within a generic API Tero Kristo
2015-02-25 19:04 ` [PATCHv3 19/35] ARM: OMAP4+: PRM: setup prm_features from the PRM init time flags Tero Kristo
2015-02-25 19:04 ` [PATCHv3 20/35] ARM: OMAP4+: PRM: get rid of cpu_is_omap44xx calls from interrupt init Tero Kristo
2015-02-25 19:04 ` [PATCHv3 21/35] ARM: OMAP2+: clock: add low-level support for regmap Tero Kristo
2015-02-25 19:04 ` [PATCHv3 22/35] ARM: OMAP2+: control: remove API for getting control module base address Tero Kristo
2015-02-25 19:04 ` [PATCHv3 23/35] ARM: OMAP2+: id: cache omap_type value Tero Kristo
2015-02-25 19:04 ` [PATCHv3 24/35] ARM: OMAP2+: control: add syscon support for register accesses Tero Kristo
2015-02-25 19:04 ` [PATCHv3 25/35] ARM: dts: omap24xx: merge control module features under scrm node Tero Kristo
2015-02-25 19:04 ` [PATCHv3 26/35] ARM: dts: omap3: " Tero Kristo
2015-02-25 19:04 ` [PATCHv3 27/35] ARM: dts: am33xx: " Tero Kristo
2015-02-25 19:04 ` [PATCHv3 28/35] ARM: dts: am43xx-epos-evm: fix pinmux node layout Tero Kristo
2015-02-25 19:04 ` [PATCHv3 29/35] ARM: dts: am4372: merge control module features under scrm node Tero Kristo
2015-02-25 19:04 ` [PATCHv3 30/35] ARM: dts: omap4: add system control module node Tero Kristo
2015-02-25 19:04 ` [PATCHv3 31/35] ARM: OMAP4: display: convert display to use syscon for dsi muxing Tero Kristo
2015-02-25 19:04 ` [PATCHv3 32/35] ARM: OMAP4+: control: remove support for legacy pad read/write Tero Kristo
2015-02-25 19:04 ` [PATCHv3 33/35] ARM: dts: omap5: add system control module node Tero Kristo
2015-02-25 19:04 ` [PATCHv3 34/35] ARM: dts: dra7: " Tero Kristo
2015-03-11 17:17 ` Tony Lindgren
2015-03-11 19:08 ` Tero Kristo
2015-03-11 19:26 ` Tony Lindgren
2015-03-11 19:57 ` Tero Kristo
2015-03-11 21:00 ` Tony Lindgren
2015-02-25 19:04 ` [PATCHv3 35/35] ARM: OMAP4+: control: add support for initializing control module via DT Tero Kristo
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=20150306191821.11109.2610@quantum \
--to=mturquette@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).