Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp22032rdb; Thu, 21 Dec 2023 01:22:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IH44uF0C7oRHMqyjYWnq63XcgXAHHcoVfBwyYRd32prcZpKl3961RVAlhAe8pDa/35G1Ova X-Received: by 2002:a50:d7dd:0:b0:552:574a:5390 with SMTP id m29-20020a50d7dd000000b00552574a5390mr391066edj.15.1703150561869; Thu, 21 Dec 2023 01:22:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703150561; cv=none; d=google.com; s=arc-20160816; b=fYEbv5SQ68uslBMqYkxr6l6rp3xycO44GazkPtAEqxLGDFxZ8DE6I00EqxEEMUQHaR 3C7VLzb33OQfkVlL68159UKgDr3m0b6W0ya1qsAcoE8MZiDZDH3P095aXrq0zd2S7VfY yIlJ1xZUpPrFP+ggOYnvAnCeu27Cnmfdtu6DMt4Tr0GjT3n+fuXS0vPGxp3K2LRwi/L8 V1GlSKwFgT7M8g7y5tzTEoNzl7EglFslRE75ShOW/deGHBHYS7qRszJS8MXhAReFcTsU RRqLt9pfi3Ley1/o9IroWG0/XBGvOUyKIuZZQipNsSh45+04RAWuhMeYfW4p/Vf/KnWF uuTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ChggBcLmx6xwxdONtamQnLuhemi42z+fo6lA2pWbhwU=; fh=AYNOcKQpfKo7XCf16ytU2gysaFjK84VU+UDjj32Jzyw=; b=K90cNmExn7ZkK3sOiZkQDCcqEpiuWA/DAlrPXSGdECvsjkFLrs2TZnI/h5gGnuShdn 0NjOC3K3JBb9srrGpJ6MchtEsq/100pxgj1j6gwRZnkiQLxyEWDdl2t2oxonotKiRtSK W628CARuHN97lfNlY/sXzEi2aE6OQPp3ibgEYb9KJK19eCzbap6e2W72WlZh1TwcCbqy 2iqN/yUyFYl65w3C+1Ehfu4joCyXNrrTaRTw1F5nK3YwwnsIZ7/0oDCmffD8XompD7Cg 2T8HS8ki21KjC0MK/ABiEo1jx9C+Djgj67ftmBLtxGMpT7ZJr6ITpcNDzEBpYllWA5N6 HutA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=HQsCbD6e; spf=pass (google.com: domain of linux-kernel+bounces-8092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8092-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id er15-20020a056402448f00b00552bc255913si696672edb.279.2023.12.21.01.22.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:22:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=HQsCbD6e; spf=pass (google.com: domain of linux-kernel+bounces-8092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8092-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9EB2E1F2412B for ; Thu, 21 Dec 2023 09:22:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5374748CC6; Thu, 21 Dec 2023 09:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="HQsCbD6e" X-Original-To: linux-kernel@vger.kernel.org Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1120142057; Thu, 21 Dec 2023 09:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=ChggBcLmx6xwxdONtamQnLuhemi42z+fo6lA2pWbhwU=; b=HQsCbD6eY5xpXuXZGUXu93WyEe nOyyL37w1Bep+gwZr3pQn4nY6yLqcGcVt2/ot24rvwDI0W1nyIuWB8OQjXvQ9j0fjr6eGQ/apIKk9 0SpolhYokHIzP8K8Nh8QqsbPAmZV2GV4Q9o1SZjW7Hz4OiSyf+UYz55x6+AlH6w08F4A=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1rGF10-003UXK-3p; Thu, 21 Dec 2023 10:06:50 +0100 Date: Thu, 21 Dec 2023 10:06:50 +0100 From: Andrew Lunn To: Jernej Skrabec Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, wens@csie.org, samuel@sholland.org, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Corentin Labbe Subject: Re: [PATCH v5 1/3] phy: handle optional regulator for PHY Message-ID: References: <20231220203537.83479-1-jernej.skrabec@gmail.com> <20231220203537.83479-2-jernej.skrabec@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231220203537.83479-2-jernej.skrabec@gmail.com> > +static int > +fwnode_regulator_get_bulk_enabled(struct device *dev, > + struct fwnode_handle *fwnode, > + struct regulator_bulk_data **consumers) > +{ > + struct device_node *np; > + int ret, reg_cnt; > + > + np = to_of_node(fwnode); > + if (!np) > + return 0; > + > + reg_cnt = of_regulator_bulk_get_all(dev, np, consumers); > + if (reg_cnt < 0) { > + ret = reg_cnt; > + goto clean_consumers; > + } > + > + if (reg_cnt == 0) > + return 0; I've not used regulators much, but i think you can combine these two into one. Its guaranteed *consumer is NULL if reg_cnt == 0. And kfree() is happy with a NULL pointer. > + > + ret = regulator_bulk_enable(reg_cnt, *consumers); > + if (ret) > + goto clean_consumers; I would expect this to be part of mdio_device_reset(), same as the GPIO, and reset controller, but first obviously. And parsing DT should happen in a similar place to parsing the reset GPIO and reset controller. Andrew