Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp7989822ybc; Fri, 29 Nov 2019 04:09:48 -0800 (PST) X-Google-Smtp-Source: APXvYqzpB8tEhoqrL9a7OmecuYIy2MZPHWPeLfa9j9tW/Q9sAzNH1fr/9fTXroI2deTx79S3BRie X-Received: by 2002:a2e:9ec3:: with SMTP id h3mr38214990ljk.203.1575029388695; Fri, 29 Nov 2019 04:09:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575029388; cv=none; d=google.com; s=arc-20160816; b=duusgZYkpkwiq6hgaq0TGZmdje8nL049q4CkpopjxHqZS8rbLPv7er1N/R4QaDDCwB T6TtfPdJ98I0R7eUObb9Spt/hY1RbPLSolYAV9Sr04PktCzDu6iJG/D03hNuvJX+IoR5 uoErJer6joO6WMMW31w7X41aH3T67d8ey1eQ8bzEpZl7bPhz/Zia0Dy8JAmo6qyipfBt K7yF165zSwyKzBrzFQCa/9QjEakcWnJa77j73Wsz0abuMuNmMOZbHzkuJ1FpKNOEsAXz WqMpsQVMnF6iuecwCdHkAbICZQA94T+j7fplpBjtIRkM404mcRikqV0OJ9f31SamPMeB CjEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pYh4OF7fVecpJQShy7dlLTgKEjADRLBZ2wMKeIZnp+c=; b=SSNTyWp1V6D42YwF5lYWnr8QLuJDoYXfS3zzvdBUaipK9nSG1TkJ+12qnoA+Vq5jOx cp9Wh3C/mQYMGvHygZ45h+pcEwVtOByTtkmXNNwRVN/fI2DM9wUVWpPUJKcL1enVcsOn xgAAYR3Y7aRip8q9Xe04ltTczqZHMkXCKxeeecyuCddNGJ1QpPd/GDg70/nU9bJyRQ8S XL+ixtbJv4/slDJz718SJvOx1z/2PDZmXDovqSwLbBiG24+8Z1at0hx5AzBLjMjJZ5yS NuFJS/AzgOJH+a7lnSbItJRSjrsr3Nq5lY3ZM/1rrlt63+m5bGIHuzcdaarP0Swex9Q4 qZjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sLGJCHQh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id la9si14446080ejb.122.2019.11.29.04.09.24; Fri, 29 Nov 2019 04:09:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sLGJCHQh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbfK2MIM (ORCPT + 99 others); Fri, 29 Nov 2019 07:08:12 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:35882 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbfK2MIM (ORCPT ); Fri, 29 Nov 2019 07:08:12 -0500 Received: by mail-ed1-f67.google.com with SMTP id j17so9183467edp.3; Fri, 29 Nov 2019 04:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pYh4OF7fVecpJQShy7dlLTgKEjADRLBZ2wMKeIZnp+c=; b=sLGJCHQh1Ii00vfaWvxz8zLwdfABNxTItE+up4RY4ik3cKyLshn4OlAOTXbemurpTg S8xxiFrVKISJPTDbFVqFgE8KyiCPlEFXizAzNK7lrtxtOFyAmG+9OfLl2erO0zijnBCo 5zWqTsJiz4sOzngC0wSe18Lzn/HMBG+V+c9Sr9b8ZPlIgExtaSxbdw+jcgEAVzwT3tFO +bW1uMMRWrHEg4sBhJ582rYkW0GyDfXn0FWn0H2bQseX79SXZbxMe9ZlA+s5mW5EkgUv 2iyToHoCYRW8uUHFUgRdyR4QBo14hjtJcEbiKDT4i96Y2WIFflnPzYLFwsMad6VsWwdJ 94YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pYh4OF7fVecpJQShy7dlLTgKEjADRLBZ2wMKeIZnp+c=; b=fodT1VWHIoAPtAajtEte6OFnuTXhWwZ0SOarQ5TUYnJFby+hNZMyiBSnVpu811g1l1 OQjUGr6vedqEe9TnNwmgwO5+dxPcrbvO7RljqF51BFlfiMfUQ17GsjXGKTX3TA08m4Oj eTIFmu7DlXg0spwbELiziQ02g2/ovOhYQZKcsTV0RTjGoYOV8ExBwJ9qs4hwM+RK/I+r HWFZJeV41YLakxhNBVZTs80z+FlKb8280St8iJkqL0kv9DLT4g2ObTNejkvQSX3QyOiR VLFJZCXujgL84LaP8qFpl+uZ59Ze90IkdL4M7tF8tKMuJA3yAI39QTbQ5bfLhIuj80vN SQuw== X-Gm-Message-State: APjAAAUactJQSRuiZoBE9TGGo80B9hiJ3KnHC2T28Ld7J4Ccaz5RW+Ig oATkbVu8U4DypkzC+dG3PnWidL58g/yqoCEGmZ8= X-Received: by 2002:a17:907:2099:: with SMTP id pv25mr40555706ejb.144.1575029289991; Fri, 29 Nov 2019 04:08:09 -0800 (PST) MIME-Version: 1.0 References: <20191128074505.GC1781@kadam> In-Reply-To: <20191128074505.GC1781@kadam> From: Shubhrajyoti Datta Date: Fri, 29 Nov 2019 17:37:57 +0530 Message-ID: Subject: Re: [PATCH v3 08/10] clk: clock-wizard: Make the output names unique To: Dan Carpenter Cc: linux-clk@vger.kernel.org, linux-kernel , devel@driverdev.osuosl.org, Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Stephen Boyd , Greg Kroah-Hartman , Mike Turquette , Shubhrajyoti Datta , Rob Herring , =?UTF-8?Q?S=C3=B6ren_Brinkmann?= Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 28, 2019 at 1:15 PM Dan Carpenter wrote: > > On Thu, Nov 28, 2019 at 12:06:15PM +0530, shubhrajyoti.datta@gmail.com wrote: > > From: Shubhrajyoti Datta > > > > Incase there are more than one instance of the clocking wizard. > > And if the output name given is the same then the probe fails. > > Fix the same by appending the device name to the output name to > > make it unique. > > > > Signed-off-by: Shubhrajyoti Datta > > --- > > drivers/clk/clk-xlnx-clock-wizard.c | 13 ++++++++----- > > 1 file changed, 8 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/clk/clk-xlnx-clock-wizard.c b/drivers/clk/clk-xlnx-clock-wizard.c > > index 75ea745..9993543 100644 > > --- a/drivers/clk/clk-xlnx-clock-wizard.c > > +++ b/drivers/clk/clk-xlnx-clock-wizard.c > > @@ -555,6 +555,9 @@ static int clk_wzrd_probe(struct platform_device *pdev) > > ret = -ENOMEM; > > goto err_disable_clk; > > } > > + outputs = of_property_count_strings(np, "clock-output-names"); > > + if (outputs == 1) > > + flags = CLK_SET_RATE_PARENT; > > clk_wzrd->clks_internal[wzrd_clk_mul] = clk_register_fixed_factor > > (&pdev->dev, clk_name, > > __clk_get_name(clk_wzrd->clk_in1), > > @@ -566,9 +569,6 @@ static int clk_wzrd_probe(struct platform_device *pdev) > > goto err_disable_clk; > > } > > > > - outputs = of_property_count_strings(np, "clock-output-names"); > > - if (outputs == 1) > > - flags = CLK_SET_RATE_PARENT; > > clk_name = kasprintf(GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev)); > > if (!clk_name) { > > ret = -ENOMEM; > > @@ -591,6 +591,7 @@ static int clk_wzrd_probe(struct platform_device *pdev) > > /* register div per output */ > > for (i = outputs - 1; i >= 0 ; i--) { > > const char *clkout_name; > > + const char *clkout_name_wiz; > > > > if (of_property_read_string_index(np, "clock-output-names", i, > > &clkout_name)) { > > @@ -599,9 +600,11 @@ static int clk_wzrd_probe(struct platform_device *pdev) > > ret = -EINVAL; > > goto err_rm_int_clks; > > } > > + clkout_name_wiz = kasprintf(GFP_KERNEL, "%s_%s", > > + dev_name(&pdev->dev), clkout_name); > > If this kasprintf() crashes then clk_wzrd_register_divf() will fail. > But that was a headache to review. Just add a check for NULL. We need > a kfree() as well. > > One alternative would be to just declare a buffer on the stack and use > snprintf(). We don't need to keep the name around after the call to > clk_wzrd_register_divf(). Will fix in next version. > > regards, > dan carpenter >