lkml.org 
[lkml]   [2014]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch v9 2/3] usb: dwc3: Add Qualcomm DWC3 glue layer driver
Hi,

On Sat, Sep 13, 2014 at 01:55:50AM +0530, Pramod Gurav wrote:
> >>> + qdwc = devm_kzalloc(&pdev->dev, sizeof(*qdwc), GFP_KERNEL);
> >>> + if (!qdwc)
> >>> + return -ENOMEM;
> >>> +
> >>> + platform_set_drvdata(pdev, qdwc);
> >>> +
> >>> + qdwc->dev = &pdev->dev;
> >>> +
> >>> + qdwc->core_clk = devm_clk_get(qdwc->dev, "core");
> >>> + if (IS_ERR(qdwc->core_clk)) {
> >>> + dev_err(qdwc->dev, "failed to get core clock\n");
> >>> + return PTR_ERR(qdwc->core_clk);
> >>> + }
> >>> +
> >>> + qdwc->iface_clk = devm_clk_get(qdwc->dev, "iface");
> >>> + if (IS_ERR(qdwc->iface_clk)) {
> >>> + dev_dbg(qdwc->dev, "failed to get optional iface clock\n");
> >>> + qdwc->iface_clk = NULL;
> >>> + }
> >>> +
> >>> + qdwc->sleep_clk = devm_clk_get(qdwc->dev, "sleep");
> >>> + if (IS_ERR(qdwc->sleep_clk)) {
> >>> + dev_dbg(qdwc->dev, "failed to get optional sleep clock\n");
> >>> + qdwc->sleep_clk = NULL;
> >>> + }
> >>> +
> >>> + ret = clk_prepare_enable(qdwc->core_clk);
> >>> + if (ret) {
> >>> + dev_err(qdwc->dev, "failed to enable core clock\n");
> >>> + goto err_core;
> >>> + }
> >>> +
> >>> + ret = clk_prepare_enable(qdwc->iface_clk);
> >>>
> >> Should not we check if qdwc->iface_clk is valid?
> >
> > read the sources luke.
> Now I read that its initialized to NULL in fail case but should we call
> prepare_enable at all if its NULL?

now read the source of clk_enable() and clk_prepare() ;-) NULL is a
valid clock, it just returns 0. This is better than sprinkling IS_ERR()
all over the place.

--
balbi
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2014-09-12 23:01    [W:0.108 / U:0.856 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site