From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751293AbdBDS1i (ORCPT ); Sat, 4 Feb 2017 13:27:38 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35250 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751203AbdBDS1h (ORCPT ); Sat, 4 Feb 2017 13:27:37 -0500 Date: Sat, 4 Feb 2017 10:27:33 -0800 From: Dmitry Torokhov To: Mark Brown Cc: Liam Girdwood , linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/5] regulator: core: simplify _regulator_get() Message-ID: <20170204182733.GD12980@dtor-ws> References: <20170203215604.23285-1-dmitry.torokhov@gmail.com> <20170203215604.23285-4-dmitry.torokhov@gmail.com> <20170204103458.vqqhpqhwjwkiizxo@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170204103458.vqqhpqhwjwkiizxo@sirena.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 04, 2017 at 11:34:58AM +0100, Mark Brown wrote: > On Fri, Feb 03, 2017 at 01:56:03PM -0800, Dmitry Torokhov wrote: > > The code in _regulator_get() got a bit confusing over time, with control > > flow jumping to a label from couple of places. Let's untangle it a bit. > > This is quite hard to review without a concrete description of what the > changes actually are... > > > Signed-off-by: Dmitry Torokhov > > --- > > drivers/regulator/core.c | 66 +++++++++++++++++++++++++----------------------- > > 1 file changed, 34 insertions(+), 32 deletions(-) > > ...it's a fairly large change in core code which is as you say a little > complicated. OK, so the change is twofold: 1. We make handling of missing supplies and substituting them with dummy regulators more explicit: - check if we not have full constraints and refuse considering dummy regulators with appropriate message - use "switch (get_type)" to handle different types of request explicit as well. "Normal" requests will get dummies, exclusive will not and will notify user about that; optional will fail silently. 2. We will not be jumping to a label normal in the middle of the function but instead have proper conditional flow. I believe jumps should be reserved for error handling, breaking from inner loop, or restarting a loop, but not for implementing normal conditional flow. Do you need me to put this into commit description or this is sufficient? Thanks. -- Dmitry