Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933499AbeAKNE3 (ORCPT + 1 other); Thu, 11 Jan 2018 08:04:29 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:45623 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752978AbeAKNE2 (ORCPT ); Thu, 11 Jan 2018 08:04:28 -0500 From: Laurent Pinchart To: Maxime Ripard Cc: Daniel Vetter , Jani Nikula , Sean Paul , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mark Brown Subject: Re: [PATCH] drm/panel: lvds: Handle the optional regulator case properly Date: Thu, 11 Jan 2018 15:05:01 +0200 Message-ID: <1944741.zEkzsdPTSS@avalon> Organization: Ideas on Board Oy In-Reply-To: <20180110155941.16109-1-maxime.ripard@free-electrons.com> References: <20180110155941.16109-1-maxime.ripard@free-electrons.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Hi Maxime, (CC'ing Mark Brown) Thank you for the patch. On Wednesday, 10 January 2018 17:59:41 EET Maxime Ripard wrote: > The devm_regulator_get_optional function, unlike it was assumed in the > commit a1c55bccf600 ("drm/panel: lvds: Add support for the power-supply > property"), is actually returning an error pointer with -ENODEV instead of > NULL when there's no regulator to find. > > Make sure we handle that case properly. > > Fixes: a1c55bccf600 ("drm/panel: lvds: Add support for the power-supply > property") Signed-off-by: Maxime Ripard > --- > drivers/gpu/drm/panel/panel-lvds.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/panel/panel-lvds.c > b/drivers/gpu/drm/panel/panel-lvds.c index 57e38a9e7ab4..9f46e7095c0e > 100644 > --- a/drivers/gpu/drm/panel/panel-lvds.c > +++ b/drivers/gpu/drm/panel/panel-lvds.c > @@ -215,8 +215,13 @@ static int panel_lvds_probe(struct platform_device > *pdev) lvds->supply = devm_regulator_get_optional(lvds->dev, "power"); > if (IS_ERR(lvds->supply)) { > ret = PTR_ERR(lvds->supply); > - dev_err(lvds->dev, "failed to request regulator: %d\n", ret); > - return ret; > + > + if (ret != -ENODEV) { > + dev_err(lvds->dev, "failed to request regulator: %d\n", ret); > + return ret; I wouldn't print an error message if ret == -EPROBE_DEFER. > + } else { > + lvds->supply = NULL; > + } > } How about lvds->supply = devm_regulator_get_optional(lvds->dev, "power"); if (IS_ERR(lvds->supply)) { ret = PTR_ERR(lvds->supply); if (ret != -ENODEV) { if (ret == -EPROBE_DEFER) dev_err(lvds->dev, "failed to request regulator: %d\n", ret); return ret; } lvds->supply = NULL; } My preference, however, would be for devm_regulator_get_optional() to return NULL when no regulator is present. The current implementation returns -ENODEV in multiple cases, making it impossible to properly discriminate between having no regulator and not being able to get the regulator due to an error. Mark, what do you think about this ? > /* Get GPIOs and backlight controller. */ -- Regards, Laurent Pinchart