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.8 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,URIBL_BLOCKED autolearn=unavailable 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 9C092C433E2 for ; Thu, 14 May 2020 19:41:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79529206DC for ; Thu, 14 May 2020 19:41:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="iiMsiC+m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728334AbgENTlW (ORCPT ); Thu, 14 May 2020 15:41:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728187AbgENTlW (ORCPT ); Thu, 14 May 2020 15:41:22 -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 DC9CDC061A0C for ; Thu, 14 May 2020 12:41:20 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id u188so151630wmu.1 for ; Thu, 14 May 2020 12:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=NFCWAEu05B4EVTuscfDYGoNeadlz+Kx9w9Y5eJvPttc=; b=iiMsiC+mv/wgW8vole6F8NN4cEtIXPvO0pSRH18Z9qVdXjuaSJnnDp9RkqXhzJ+Qt3 2EhRuywExWkh2CmcncaOfPNzSP4bIY/pKSEdh/sRcGiInH8zjYAIpRs7Y3injlZP7Ndx hV83PYAdgnTRVurii3t5KVdNlPKufu+e1UoR4= 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=NFCWAEu05B4EVTuscfDYGoNeadlz+Kx9w9Y5eJvPttc=; b=bezNFoULORJ+3OBoeSuLl34e/e00lUfn95lbQwgedyJkN/IGkojOiY1h9SMWF6l/T6 f7e0aS+jbsA4IftdGpdrUBztNtkJiDMftBllJj3tHA8IJzqlAJMf1LlUT8QShiltSO1J lCEt4NccyUPvElM+lTkGiwK/h3Glii9dYoUgqwGlsQh//mdMtA2PPZ/b30WG8LKMcHQF hZca7TkwavWWB300j5gInSNs5HuPOSdPbjwGxDbB7axXtzb1EJ0H3tuh4NYNmcclRQ/p 4wdDoGy/BOoSFeZ7YpjO2jnWU+F6Un68Cuht3Mt7RqfYfFG6Cien2oy+g0tEryaBrw/c mfnw== X-Gm-Message-State: AOAM530GSS8hwPVBOY1kf35sqdMKHia4IuqlBQSegqP44ek0xggCt6sC QjsXRj1GWiySNsseuOkYu5KcmA== X-Google-Smtp-Source: ABdhPJwFpfjqo8vtjxSzoQQvQrMS4vYTIbF1RS6H6blsGaggnazJUNp8mnWAkPEh3BAF2LXxL3D5Zw== X-Received: by 2002:a1c:5985:: with SMTP id n127mr9963996wmb.64.1589485279605; Thu, 14 May 2020 12:41:19 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id c125sm125672wma.23.2020.05.14.12.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2020 12:41:18 -0700 (PDT) Date: Thu, 14 May 2020 21:41:16 +0200 From: Daniel Vetter To: Sam Ravnborg Cc: dri-devel@lists.freedesktop.org, Jingoo Han , Lee Jones , Daniel Thompson , Allison Randal , Andy Gross , Bartlomiej Zolnierkiewicz , Bjorn Andersson , Daniel Vetter , David Airlie , Douglas Anderson , Enrico Weigelt , Jani Nikula , Jonathan Corbet , Jyri Sarha , Kate Stewart , Kefeng Wang , Laurent Pinchart , 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 Gleixner , Thomas Zimmermann , Tomi Valkeinen , Uwe Kleine Konig , Zheng Bin Subject: Re: [PATCH v1 08/18] backlight: add backlight_is_blank() Message-ID: <20200514194116.GB206103@phenom.ffwll.local> References: <20200514191001.457441-1-sam@ravnborg.org> <20200514191001.457441-9-sam@ravnborg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200514191001.457441-9-sam@ravnborg.org> X-Operating-System: Linux phenom 5.6.0-1-amd64 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Thu, May 14, 2020 at 09:09:51PM +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 > as thus not needed in this helper function. > Rolling out this helper to all relevant backlight drivers > will eliminate almost all accesses to fb_blank. > > Signed-off-by: Sam Ravnborg > Cc: Lee Jones > Cc: Daniel Thompson > Cc: Jingoo Han > --- > include/linux/backlight.h | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/include/linux/backlight.h b/include/linux/backlight.h > index b7839ea9d00a..e67e926de1e2 100644 > --- a/include/linux/backlight.h > +++ b/include/linux/backlight.h > @@ -165,6 +165,23 @@ static inline int backlight_disable(struct backlight_device *bd) > return backlight_update_status(bd); > } > > +/** > + * 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 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.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK); This definition here doesn't match backlight_enabled/disable() functions we added. I think to avoid lots of pondering and surprises we should try to make sure these are all matching, so that once we rolled them out everywhere, we can just replace the complicated state with one flag. -Daniel > +} > + > 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 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch