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=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 A77C1C433E0 for ; Tue, 7 Jul 2020 05:42:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EF8C20758 for ; Tue, 7 Jul 2020 05:42:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="aTHuMDpS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727936AbgGGFmV (ORCPT ); Tue, 7 Jul 2020 01:42:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbgGGFmV (ORCPT ); Tue, 7 Jul 2020 01:42:21 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CA97C061755 for ; Mon, 6 Jul 2020 22:42:21 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id 17so45038009wmo.1 for ; Mon, 06 Jul 2020 22:42:21 -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=WHUZR2EXdhW5czPcHt04KOGgCe/6SbN/TGw1pfVyle4=; b=aTHuMDpSIuntpboIlpD3+77prmvJYYBBCxxD8NinelcUFG+j+dj3KN9GoisfRWfdS5 8DT2xsmwMpRRwEGaZffv128mMoXufFWvGv/mGoFtuO8pHa5b2EaJRMF60gQCwpnnCuqf wX8vfS3h5dhWybSyzG9dP/DbtH+U1M75DY9HY= 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=WHUZR2EXdhW5czPcHt04KOGgCe/6SbN/TGw1pfVyle4=; b=d6YgKGcdgNLGAWyCuk5k6jKOYAG+3UzyzG08sYdv7RmQNFtwMDVQ3wMIn5X40Xfll4 fQWdlF6mU/olo69MtFNCg3UE/8kge39GcBPWi1qEi0c+RpcNTMshnq+deUkYTUld4iyj N3mvvKtKoRU8tIdkTZSWbN+KhmPI/elD4PTpi0I/PQ2+qwWH1apvcKstbZKpbIf0RJjQ g7Km6Vk9hGdZoEYn49ovzvyCkFy1xMQFEiCx5hMDX4nOt3wJu1gk0FIZmeish4RCKTpY U8tZBW40fzz8OKmUNjHgdP7EbK6Y+NrtVqhYvEvN+qhg74Oe09M5ap6/TcHnMzOQq3E/ pB3Q== X-Gm-Message-State: AOAM532esTCdUoDyspjuysLb7gAbKx2yZKFcTCSCxarBq2KlFQiz311u SF7aH/fxewHT0N0qkVcdNGeJBw== X-Google-Smtp-Source: ABdhPJxkzyQbd3f6f/x660/A1DZO543mIEmlw2oJzEFOVcvYB/zIx1BH7NEm8rYT7UByGGvzuOEFfw== X-Received: by 2002:a1c:3954:: with SMTP id g81mr2297120wma.73.1594100539918; Mon, 06 Jul 2020 22:42:19 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id 65sm2051126wma.48.2020.07.06.22.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 22:42:19 -0700 (PDT) Date: Tue, 7 Jul 2020 07:42:16 +0200 From: Daniel Vetter To: Sam Ravnborg Cc: dri-devel@lists.freedesktop.org, Jingoo Han , Lee Jones , Daniel Thompson , Andy Gross , Bartlomiej Zolnierkiewicz , Bjorn Andersson , Daniel Vetter , David Airlie , Emil Velikov , Jonathan Corbet , linux-arm-msm@vger.kernel.org, linux-pwm@vger.kernel.org, Maarten Lankhorst , Maxime Ripard , Michael Hennerich , patches@opensource.cirrus.com, Support Opensource , Thierry Reding , Thomas Zimmermann , Uwe Kleine-Konig , Peter Ujfalusi , Tomi Valkeinen Subject: Re: [PATCH v4 02/20] backlight: add backlight_is_blank() Message-ID: <20200707054216.GE3278063@phenom.ffwll.local> References: <20200703184546.144664-1-sam@ravnborg.org> <20200703184546.144664-3-sam@ravnborg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200703184546.144664-3-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 Fri, Jul 03, 2020 at 08:45:28PM +0200, Sam Ravnborg wrote: > The backlight support has two properties that express the state: > - power > - state Tiny nit, but please add "fb_blank" here too, commit message doesn't match the code anymore. With that: Reviewed-by: Daniel Vetter > > 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 bugs > due to the creative use of fb_blank in some drivers. > Introducing this helper will for some drivers results in > added support for fb_blank. This will be a change in > functionality, which will improve the backlight driver. > > Rolling out this helper to all relevant backlight drivers > will eliminate almost all accesses to fb_blank. > > v4: > - struct backlight_device * is now const > > v3: > - Clarified that the fb_blank support in > backlight_is_blank() may result in functionality > changes for the users (Emil) > > v2: > - Added fb_blank condition (Daniel) > > Signed-off-by: Sam Ravnborg > Reviewed-by: Daniel Thompson > Reviewed-by: Peter Ujfalusi > Reviewed-by: Emil Velikov > Cc: Emil Velikov > Cc: Daniel Vetter > Cc: Lee Jones > Cc: Daniel Thompson > Cc: Jingoo Han > --- > include/linux/backlight.h | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/include/linux/backlight.h b/include/linux/backlight.h > index 56e4580d4f55..56e51ebab740 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(const 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 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch