Path: csiph.com!aioe.org!bofh.it!news.nic.it!robomod From: Dmitry Torokhov Newsgroups: linux.kernel Subject: Re: [PATCH 4/5] regulator: core: simplify _regulator_get() Date: Sat, 04 Feb 2017 19:30:01 +0100 Message-ID: References: Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GqPFDSSDfYjqgBy06a9jU1CAMYKPgwkT6mXPirzTbYA=; b=rEnKk4caBgdxi3y0UHT7pjVABBlNjBTlJav8hD8JUHlD0yc8Udazr7mZM2KGiH087O xLZVcJnRtULaWyQpN2gkQt2+koZ7d6eFFPM0A0lTPJUrG6kEnYAca25sRa/ISl2LrKYy LdGz4y5bmEdmycl3G3pmUR8wKqL23wlZn+zWpMK6EMWFNByXfegWPqCV/5uPxtI0CZT0 aAn4PZfEkIq5kX60RqDeB9pC844yFYWd8lBxjhDl0064Le3h4oQI/fIbs4yCyFSymaXF hySdaDZ0JGVGY13iqdb6EJzYirwMvuH3jgvEc8icX0KgR3BOLZWJcLPRpoVaUmQYa8dM 9f0A== X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GqPFDSSDfYjqgBy06a9jU1CAMYKPgwkT6mXPirzTbYA=; b=oMA2wf9BQLDM9CoktRnD3TR0LAH5fAb9xhlGKp3Ms4IdPgjxO9gHo9gMqbKNu5Tjjm z/akliqNMpWrlRGsBVDe8EthFOV+nXlBjfan5OHhti3Ut/eJenlIJabR6YteWqpu0oq1 lkaA+P9Nq4HbBQSqUd4fXN5DWb9Lp0bJ3Yoxcdc+ZpTIJtILXFfv+AMPWG+9QGWKAU7k /m9iozDhS8g+5xjj1ERCSdDpdI9rPxYelKTUDA+P0QPzQvT5N5iVbXptgzfsQZFz0jfW vAnim6kL17Q+xPzwwY6vfXSKObxVlfX41bvYvtIiGJxba+kKklzrEr4EGUmdsxR8XE8L 8nDA== X-Gm-Message-State: AIkVDXINy3qH3UtWvAr9+7ABwZSWj1XWBBry30DHRoz3HspKfSl46hroxGNXf+chUHHbdg== X-Received: by 10.99.226.83 with SMTP id y19mr4014363pgj.34.1486232856475; Sat, 04 Feb 2017 10:27:36 -0800 (PST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 40 Organization: linux.* mail to news gateway X-Original-Cc: Liam Girdwood , linux-kernel@vger.kernel.org X-Original-Date: Sat, 4 Feb 2017 10:27:33 -0800 X-Original-Message-ID: <20170204182733.GD12980@dtor-ws> X-Original-References: <20170203215604.23285-1-dmitry.torokhov@gmail.com> <20170203215604.23285-4-dmitry.torokhov@gmail.com> <20170204103458.vqqhpqhwjwkiizxo@sirena.org.uk> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1573728 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