Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp875601rdb; Fri, 26 Jan 2024 13:39:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdOVaT/0uYyn533ivl2pHXp0diXjlkjiwi/XTfvgiu/VwFiExjgPKaC09GNXligEkYk3HG X-Received: by 2002:a05:6358:7247:b0:176:5459:a9c7 with SMTP id i7-20020a056358724700b001765459a9c7mr404469rwa.28.1706305183582; Fri, 26 Jan 2024 13:39:43 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p29-20020a63741d000000b005d48e659692si1646769pgc.753.2024.01.26.13.39.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 13:39:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40684-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=Y3aGxsmI; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-40684-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 25BFC286EDA for ; Fri, 26 Jan 2024 21:39:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 141A4250E2; Fri, 26 Jan 2024 21:39:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y3aGxsmI" Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93E9724A02; Fri, 26 Jan 2024 21:39:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706305173; cv=none; b=T4xSW2qvTf/3Y5SXfR+15va5K2jMlT6whyliMdGmtUAdfeY1ITdunW0UvpJuwwLPDIbEttqgLOlqmWDnJCw5AZ1hJ3fa/Gpq2E4m1JfWJsPSpatmbaUU+LjEy/m9JhN58KAF8O0fBA5ywBZikDXfFTWT3A513ODeNfHQZNDk3+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706305173; c=relaxed/simple; bh=aYWtVCS6UzhbIOesoYUujKfoyGoA1lZ5lx3aq+McpdY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=D/cdEHDvEpUhMCZB0PBaiINxDzj5cT0Sq3bVk/qcI5+Ke9IA58Bqq1ct2V83kpP9oPm5Ty+tVC38QKT6GjyJc8UZdn5E/n29NY+xyEDMWLs651vEU7XAmQPJb0Dpc438D+yyum+rQWdcBmHYMrUxR2Z6o2RWwGgcv83+1hPdGdw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y3aGxsmI; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-40ee705e9bfso10821985e9.0; Fri, 26 Jan 2024 13:39:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706305170; x=1706909970; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GnBIN51Yx/Gln0h3onAB09YxTVH+h1KGIKBHmAivbD8=; b=Y3aGxsmIm8WawNZ/2Xw6aU0JLcXIMNKVjPp0oBi1iwnUbjVpBqDyRkJ7d/NmriWw5R 7qFiaW3HqsPxT184DaNP2dib9Yy5fKVN/6QJ2x9Rw2I4VGvr2eURxz133GOCpe8O/HIS OW1AFChcMh4k44r+vOQ4kguCA2MoL6jYR28UOA8EBPa6pWvUUTU9NX1vN5mbHrE8jQZP leNyypuCyxHdvzsW12FQvZ7OZmuaQPJGAg/Fyi4EZihHscldF6l0ZsxV+RtvHyPEJhaK AWUhoE4bfc6pKsLKL2Jar7XJSKL5SUK2+RzkZRjesakXVtaIN5hEeqwko23qnzfhHId+ 9G+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706305170; x=1706909970; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GnBIN51Yx/Gln0h3onAB09YxTVH+h1KGIKBHmAivbD8=; b=ZBor17dcDpBbugXi5Wv/cLXYLXNgvtjJP4cWWOLXysa+n0FrmrsLNdTF70xCEyJXY6 iXBAFeWwTioiccVnLhURiqqY6HirflTra06S+uA9f3VWIZh8lPl5UF91wqIRgTc0+WMb cWflfEQuryuSrC0E8jb9/tbNSvKEF6lF8nZ3HJpklz8Q5swjlI6gMtxHXhIH84FOL8O6 15uI6lpu7Tls2m+MqULFbrfUunNRtepvk4UZ9muLpUeF1zeNBGSRoIHDAMPVBDMlvf5Q FKWSJNEIy7LeEAGMh1rn1a6/sSl8AZuhRmslENxN1pviYnlKN6vlybJdopYClYQCMPp2 xyDw== X-Gm-Message-State: AOJu0YxoGwrZbOt2HHChaJstHUFZPcbV6Ymw3e4bAzO+2KBb2BDwbhN2 3COrS6sRJt5Nzc56ELg7Gx+NHLw/gEmxHtDazKuYQ5jVuSOzhZGd3A6YL6B9Y5v74QydfdlolDx telqwEgbmjEfOJFZMJwOyKhmJPzA= X-Received: by 2002:a05:600c:5123:b0:40d:8c4d:c0b3 with SMTP id o35-20020a05600c512300b0040d8c4dc0b3mr293884wms.94.1706305169591; Fri, 26 Jan 2024 13:39:29 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> <20240102-j7200-pcie-s2r-v2-6-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-6-8e4f7d228ec2@bootlin.com> From: Andy Shevchenko Date: Fri, 26 Jan 2024 23:38:53 +0200 Message-ID: Subject: Re: [PATCH v2 06/15] phy: ti: phy-j721e-wiz: make wiz_clock_init callable multiple times To: Thomas Richard Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 26, 2024 at 4:37=E2=80=AFPM Thomas Richard wrote: > > For suspend and resume support, wiz_clock_init needs to be called multipl= e wiz_clock_init() > times. > > Add a parameter to wiz_clock_init to be able to skip clocks registration. Ditto. ..to skip the registration of the clocks. .. > -static int wiz_clock_init(struct wiz *wiz, struct device_node *node) > +static int wiz_clock_init(struct wiz *wiz, struct device_node *node, boo= l probe) So, why not refactor this to two functions first? .. > + clk =3D devm_clk_get(dev, "core_ref_clk"); > + if (IS_ERR(clk)) { > + dev_err(dev, "core_ref_clk clock not found\n"); > + ret =3D PTR_ERR(clk); > + return ret; This is wrong and has to be fixed in the original code. The correct approach is to use `return dev_err_probe(...)` or open code it, but since we have a helper, open coding is highly discouraged. > + } .. > + if (wiz->data->pma_cmn_refclk1_int_mode) { > + clk =3D devm_clk_get(dev, "core_ref1_clk"); > + if (IS_ERR(clk)) { > + dev_err(dev, "core_ref1_clk clock not fou= nd\n"); > + ret =3D PTR_ERR(clk); > + return ret; Ditto. > + } .. > + clk =3D devm_clk_get(dev, "ext_ref_clk"); > + if (IS_ERR(clk)) { > + dev_err(dev, "ext_ref_clk clock not found\n"); > + ret =3D PTR_ERR(clk); > + return ret; Ditto. > + } .. > + /* What follows is about registering clocks. */ > + if (!probe) > + return 0; Just refactor properly, no need to have this ugly mix of devm_*() for probe stage, parameter and HW related things. --=20 With Best Regards, Andy Shevchenko