From mboxrd@z Thu Jan 1 00:00:00 1970 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 29F2A17C98; Mon, 25 Mar 2024 12:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370339; cv=none; b=ZNJyhp2WT9qJkfNViP/IqydcXIZ9m1vleVGLW7KNYV809rj8N0wZ1nQ6uh9qCxKGVa4c5LDOW9zXoHNgNcWpltHym+kO3mPoq69URHNoBQyiu9moEX7YK8ytTkjRl5CbH5B3BFb8SA3bRbD6Ah/WjAQT0lRWvLM2qizBk9H6Pvk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370339; c=relaxed/simple; bh=95OfuHhtUR61PCdLT913r4p58jGY4g4ttdpsQZMIHKE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eeNcAgp5PLkSy/LFAP6gCKouRzNFPEJfUaq6i0cY/DiuI3uT3HKAljumb4rbnoR7AkeeCsdgP3I9yirEU+cswfJvsFpxnWYkzQrMGO/w14eU9Wsp0iLI+ZDIl3sj4+M9IAzf/HXbu+rfOxFKQ/cuAj716pQ+zeVg9YsaxgMHxiI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=0RqbUNoE; arc=none smtp.client-ip=156.67.10.101 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="0RqbUNoE" 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=OgU9ATmRZP6L3LpzuzX003fhjH7k0Ift0+MTIYapSoA=; b=0RqbUNoEE8/paq5vSzmjLbsA0Y sOt8eUVaYwOPNeHqtcx3KhS/x2x6blQy1CxPXXwerD+QVRpCR2vY1bl2ErUJo0rDFAKujo3WNBq8L tPTw/n0r3KsZNg36bUs3LCOML00kYdGPmsFxOIgWZikBEOgNmLUX5enm+rsx75xmJs9Q=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1rojb8-00B9Nd-5b; Mon, 25 Mar 2024 13:38:42 +0100 Date: Mon, 25 Mar 2024 13:38:42 +0100 From: Andrew Lunn To: Luiz Angelo Daros de Luca Cc: Linus Walleij , Alvin =?utf-8?Q?=C5=A0ipraga?= , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 4/4] net: dsa: realtek: add LED drivers for rtl8366rb Message-ID: <9ca3fc83-ef54-4080-bd77-b0f09eefc952@lunn.ch> References: <20240310-realtek-led-v1-0-4d9813ce938e@gmail.com> <20240310-realtek-led-v1-4-4d9813ce938e@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: > static int rtl8366rb_setup(struct dsa_switch *ds) > { > (...) > if (priv->leds_disabled) { if (!priv->leds_disable) return; Saves you one level of indentation. or static int rtl8366rb_setup_all_off(foo *priv) { > /* Turn everything off */ > regmap_update_bits(priv->map, > RTL8366RB_INTERRUPT_CONTROL_REG, > RTL8366RB_P4_RGMII_LED, > 0); > > for (i = 0; i < RTL8366RB_NUM_LEDGROUPS; i++) { > ret = rb8366rb_set_ledgroup_mode(priv, i, > RTL8366RB_LEDGROUP_OFF); > if (ret) > return ret; > } > } > } This is what i meant by small helpers. And the function names replaces the need for the comment. This is part of the thinking behind the coding style. Function names can replace comments. And the higher level functions becomes easier to follow because you don't need to dig into the details to understand: if (priv->leds_disabled) rtl8366rb_setup_all_off(priv); Andrew