Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp38413pxb; Wed, 14 Apr 2021 08:56:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+Xq0v2qWyvX4wvr/iCuWLyvGnto4OxkyRs06X7EccQCXYA0fhw2ACxTv6TFMP++cc5QO6 X-Received: by 2002:a05:6402:84b:: with SMTP id b11mr41544150edz.56.1618415763938; Wed, 14 Apr 2021 08:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618415763; cv=none; d=google.com; s=arc-20160816; b=OHqw/zqF0YPHQfiEYAaM78YGDKALvcplOTVclrMQjQsm7t/1Hyhs18pUcTLD+cQwaJ JSunQ9GI9IZSKusWnRaIBlho7F8rDgujfjqtSD+FVUlni6+sC9HvGOSYkPR2MRUdRW2k 61PyBLW4s0GmreQ/iJeJyJH/CPfMpoZzMgChKIWyN23EP9RX3hGExB1vohhEBkqFQdlq DcLHmazJQUqZf+CcGy8oiiunqNgy99RdIIp2MYD1TT6SqxiyAeqRizz/E8gKe+rusLf1 RmXT0DtPqmj4Q7m9Dle+FY6cpd///bdYK/If2HTnAO8rHC4iV/QdCZMe5lwVLwhqjs+q KecA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=h2glotSQNv6sLqKL+wvYFAeO5knjRBKMj7UoWHlfyWc=; b=nM9LeYgbEwXx2ShzwIzP1/C+f7AvHOXRWPHw7Kmmk04ge9YdeTQBGwzEEvSBEarIll L+d9IaOHgldLTf39eflqLc21ZXpG5nRbElIOKA35Js14P/NG7UUeRgTBqNDuojSZc1PG 4Xz4YOf9M00XRiaa34DnuxChl/yQxErMm29UHKuKexrtchPo39NjSbf8ql+ZfF453d1B X5DtMM76BR3J4g0IwIpF3JE2szc00BhiNU1q+8p9w2nYIwXJGPbbufh3VXW2UESKTqJK QR9aGFLSjZG38kEiEKgCjLVb2+7On+kAgDdrbUIb8O6OiqYGEfDCzua2YN0kfB0IZZBY EByg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NtVk7QEN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id q11si9402143eju.518.2021.04.14.08.55.36; Wed, 14 Apr 2021 08:56:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NtVk7QEN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1351111AbhDNNI2 (ORCPT + 99 others); Wed, 14 Apr 2021 09:08:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232933AbhDNNIX (ORCPT ); Wed, 14 Apr 2021 09:08:23 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1E66C061574; Wed, 14 Apr 2021 06:08:01 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id e14so31270288ejz.11; Wed, 14 Apr 2021 06:08:01 -0700 (PDT) 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=h2glotSQNv6sLqKL+wvYFAeO5knjRBKMj7UoWHlfyWc=; b=NtVk7QEN72VW9Nscr50h789KhTGxyVxK88UL1mfIGSrZ6YHIDLY2H+ylqi3osFVyL5 HdBrkG/DVuG0makrWXeAABIUSdOrKrS2Ngx4ruxgT3O6zBYPigaZgic5pQEs1ickxZx/ L+VKsO5+iGHne/kDMz/9wgOs8JcXqLSuEJOEZLPrTmunvdVDSTi4y5WDOmKBQvzBfXVv SkNJqNEzo6ObWXYlKWybUFh9SvSS9hNHeLJwEwxN62e0PyvGw9U8rvOVrpWBVbTSmwgP We6KZRaSD7fRkiOMiKDulLy4CPV4d3TmkZMNK+86RDSJ8mXZatcMKDiEVK3noGQ1GR7P BKzQ== 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=h2glotSQNv6sLqKL+wvYFAeO5knjRBKMj7UoWHlfyWc=; b=sq3Us2gbG9popFIXlh7G5juItENdUSoATFjAjjuoSKPmL7+o6tI6aF/c4af+udz/zl qr1o2MLVlzv2x5AtsLqupmPi+YLGWMiLTrkhhZUvfAHh7rcx/4HT+3XXjMtVRM1gsBth XtYPlNSu8bZB9bU1yV7Iu2YcaDEuLasNjsA8sgNi9PkDFYonu2VAKKo0o0J5nw59XW1U dUJaLZxHoxolRTNcEslYLiaSH+d3lTSJ775M00nLsM4+HRrCgIUSeE6fLNXBB/vJui8B wQXEDZn5FE0bwpS/QC3ft3AbGSY/0C7KCc7hN2qtJyhSDqmV+Is9O6QJMmyj5QnCrX7J MzUQ== X-Gm-Message-State: AOAM533nsGaUhkoqYkhbsB08FHzc80YxYOI8GVOxp0+409lsiTO8Ydcs H6+rYCiNkWKOgVwVoSoyw7NUQUPeLfpzRi5XzTdzvWkTX8J7FQ== X-Received: by 2002:a17:906:44b:: with SMTP id e11mr30154715eja.551.1618405680381; Wed, 14 Apr 2021 06:08:00 -0700 (PDT) MIME-Version: 1.0 References: <20210412132619.7896-1-aford173@gmail.com> <20210412132619.7896-2-aford173@gmail.com> In-Reply-To: From: Adam Ford Date: Wed, 14 Apr 2021 08:07:49 -0500 Message-ID: Subject: Re: [PATCH V4 2/2] net: ethernet: ravb: Enable optional refclk To: Geert Uytterhoeven Cc: netdev , Adam Ford-BE , Sergei Shtylyov , "David S. Miller" , Jakub Kicinski , Rob Herring , Linux-Renesas , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 13, 2021 at 2:33 AM Geert Uytterhoeven wrote: > > Hi Adam, > > On Mon, Apr 12, 2021 at 3:27 PM Adam Ford wrote: > > For devices that use a programmable clock for the AVB reference clock, > > the driver may need to enable them. Add code to find the optional clock > > and enable it when available. > > > > Signed-off-by: Adam Ford > > Reviewed-by: Andrew Lunn > > > > --- > > V4: Eliminate the NULL check when disabling refclk, and add a line > > to disable the refclk if there is a failure after it's been > > initialized. > > Thanks for the update! > > > --- a/drivers/net/ethernet/renesas/ravb_main.c > > +++ b/drivers/net/ethernet/renesas/ravb_main.c > > @@ -2148,6 +2148,13 @@ static int ravb_probe(struct platform_device *pdev) > > goto out_release; > > } > > > > + priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk"); > > + if (IS_ERR(priv->refclk)) { > > + error = PTR_ERR(priv->refclk); > > + goto out_release; > > Note that this will call clk_disable_unprepare() in case of failure, which is > fine, as that function is a no-op in case of a failed clock. Geert, A bot reported that if I jump to out_release may try to free a clock if some instances where priv isn't defined. Currently, the priv->clk isn't freed either. I have heard some back-and-forth discussions in other threads on whether or not devm functions auto free or not. I'm fine with sending a V5 to make the free for the refclock happen only when the priv has successfully initialized. Should I also add one for freeing priv->clk and change all the other goto out_release commands to point to this new section? I am thinking it would like something like: free_refclk: clk_disable_unprepare(priv->refclk); free_clk; clk_disable_unprepare(priv->clk); out_release: free_netdev(ndev); .... adam > > > + } > > + clk_prepare_enable(priv->refclk); > > + > > ndev->max_mtu = 2048 - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); > > ndev->min_mtu = ETH_MIN_MTU; > > > > @@ -2244,6 +2251,7 @@ static int ravb_probe(struct platform_device *pdev) > > if (chip_id != RCAR_GEN2) > > ravb_ptp_stop(ndev); > > out_release: > > + clk_disable_unprepare(priv->refclk); > > free_netdev(ndev); > > > > pm_runtime_put(&pdev->dev); > > Reviewed-by: Geert Uytterhoeven > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds