From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17919C433E0 for ; Mon, 18 May 2020 15:01:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E08A920756 for ; Mon, 18 May 2020 15:01:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="b1KoRPzh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728162AbgERPBB (ORCPT ); Mon, 18 May 2020 11:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727954AbgERPBB (ORCPT ); Mon, 18 May 2020 11:01:01 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEAF2C061A0C for ; Mon, 18 May 2020 08:01:00 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id m12so9632820wmc.0 for ; Mon, 18 May 2020 08:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8++mCf4jSObKvczsPrCihMEuKhSX0mbSobsPe+OlqoE=; b=b1KoRPzh9KeASUfJshq63jbOp9jg3g/1rpHNd1w/o+KQuz4BhUdHMX05yfqVsWYET4 HWW1Mpp4YrWFk67arh4A2bp+D+x9YrUAJr/tgsIAjZJUb6vepsGF6L3fMH55zsUrFIJJ 0mSRpAxHlAsHOcYM7awxP5nAJX3vNXuaewFgbEE/Hvb/P6FI263krXKqG4gsb/p58602 4K8Vm/tZRVERoDDdHDD4wyRS1FQHHf2xLhg532Qj8v0QFQpgmlSBqNl6gRqp2Yf+6yyv 4yJ79yABAK+WKH83YZfPZ9vmS3WqBCP17g2A7bVa+J/erzwnI8YSkmsnjUUgCuiCKS2S jqLQ== 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; bh=8++mCf4jSObKvczsPrCihMEuKhSX0mbSobsPe+OlqoE=; b=B9qZ5N0nViom2XsWpYMTjX70K11rYYcW6sR/OGohaWY2A0qALWhEnhlb1ZWa/DdtKZ LMZU0EyAZ9LKp732+yNWt7UymbOlhfCj+qEJQx4zl2ROr9xepR3LaU5KGmZFeFtQ5PHN 8NuaGQpKgsyLd7NRL1dMoph+08HFJ8VJdZr7XuBhfVawpgunUJ2F0VF1OXQRYZUX+ByA ezofPPymc7uesF3xPtxvCu1t+Cwth0ymbgoK9cbvhT4Z0OurUuQ769J4hQx0MAmSKwjl ML0Y5SFRMxatE5boAUtbGcpOYiQIRorMV4Tzn8eNm4pkMDhJIig/XwEzQ04syKa/3QwI uNIA== X-Gm-Message-State: AOAM533ZrE9zOWqhpAY4J3LuTlwH9U8UIFw9j6Mj6/KfF9IWVDEmTLO0 lMfW9/tMcS9soCApfv8s8NlVBg== X-Google-Smtp-Source: ABdhPJwVYyW+g2DU5vF2SFs8kROpaXsS+0st9Moezr7mqbpA2jZeUyxRLI/bkAyeZ7mLDzH+DnX7+w== X-Received: by 2002:a1c:770e:: with SMTP id t14mr20423003wmi.86.1589814058651; Mon, 18 May 2020 08:00:58 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id j2sm16678993wrp.47.2020.05.18.08.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 08:00:57 -0700 (PDT) Date: Mon, 18 May 2020 16:00:55 +0100 From: Daniel Thompson To: Sam Ravnborg Cc: dri-devel@lists.freedesktop.org, Jingoo Han , Lee Jones , Peter Ujfalusi , Tomi Valkeinen , Andy Gross , Bartlomiej Zolnierkiewicz , Bjorn Andersson , Daniel Vetter , David Airlie , Douglas Anderson , Jani Nikula , Jonathan Corbet , Linus Walleij , linux-arm-msm@vger.kernel.org, linux-pwm@vger.kernel.org, Maarten Lankhorst , Maxime Ripard , Michael Hennerich , patches@opensource.cirrus.com, Russell King , Support Opensource , Thierry Reding , Thomas Zimmermann , Uwe Kleine-Konig Subject: Re: [PATCH v2 03/16] backlight: add backlight_is_blank() Message-ID: <20200518150055.2vaaoucf4nodwoz5@holly.lan> References: <20200517190139.740249-1-sam@ravnborg.org> <20200517190139.740249-4-sam@ravnborg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200517190139.740249-4-sam@ravnborg.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Sun, May 17, 2020 at 09:01:26PM +0200, Sam Ravnborg wrote: > The backlight support has two properties that express the state: > - power > - state > > It is un-documented and easy to get wrong. > Add backlight_is_blank() helper to make it simpler for drivers > to get the check of the state correct. > > A lot of drivers also includes checks for fb_blank. > This check is redundant when the state is checked > and thus not needed in this helper function. > But added anyway to avoid introducing subtle bug > due to the creative use in some drivers. > > Rolling out this helper to all relevant backlight drivers > will eliminate almost all accesses to fb_blank. > > v2: > - Added fb_blank condition (Daniel) > > Signed-off-by: Sam Ravnborg > Cc: Daniel Vetter > Cc: Lee Jones > Cc: Daniel Thompson > Cc: Jingoo Han Reviewed-by: Daniel Thompson > --- > include/linux/backlight.h | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/include/linux/backlight.h b/include/linux/backlight.h > index c7d6b2e8c3b5..a0a083b35c47 100644 > --- a/include/linux/backlight.h > +++ b/include/linux/backlight.h > @@ -175,6 +175,25 @@ static inline void backlight_put(struct backlight_device *bd) > put_device(&bd->dev); > } > > +/** > + * backlight_is_blank - Return true if display is expected to be blank > + * @bd: the backlight device > + * > + * Display is expected to be blank if any of these is true:: > + * > + * 1) if power in not UNBLANK > + * 2) if fb_blank is not UNBLANK > + * 3) if state indicate BLANK or SUSPENDED > + * > + * Returns true if display is expected to be blank, false otherwise. > + */ > +static inline bool backlight_is_blank(struct backlight_device *bd) > +{ > + return bd->props.power != FB_BLANK_UNBLANK || > + bd->props.fb_blank != FB_BLANK_UNBLANK || > + bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK); > +} > + > extern struct backlight_device *backlight_device_register(const char *name, > struct device *dev, void *devdata, const struct backlight_ops *ops, > const struct backlight_properties *props); > -- > 2.25.1 >