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 E11FFC433E0 for ; Thu, 14 May 2020 20:03:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC1722065C for ; Thu, 14 May 2020 20:03:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="VAIiWBZd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729102AbgENUDz (ORCPT ); Thu, 14 May 2020 16:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729103AbgENUDz (ORCPT ); Thu, 14 May 2020 16:03:55 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C00FC061A0E for ; Thu, 14 May 2020 13:03:54 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id u188so266948wmu.1 for ; Thu, 14 May 2020 13:03:54 -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=0T9FZKzhaNIAyAMhurXfRjBv09XxUrY4eeMiZKg77EU=; b=VAIiWBZd2orVmWNlsBdww0kQaG/rvtc7vet7nyyZlSVy3XFuYBQVE80Glibbmi1Q/H P7xZZPm/sIwfTWY1GifVPJ6d0KCv5ZLDS22MX0SAdwHCH6ahi3ME03a3kF/lqQvAxdpl XDNuG1qZ6i5qtfURURGheV0H/P+nYP3ryGwSk= 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=0T9FZKzhaNIAyAMhurXfRjBv09XxUrY4eeMiZKg77EU=; b=Vzg5mL3wwgLF92sX83JfeYsYTqbN0oGqHaEEIN1VKD5HqgMmnNLPVMxwTVT48+Cr1P bFJnhLAW37WDMXymSx8RRONxEDbjm02e0WGxwii7tSHPGsgb9QoXgaeF+eXKepeQiV1C zsEgIOY2EJj4b1IbKEiBybSXoQTXM5Osmirkq1n5cfe03bzJmGm6hNTO+axMygE3V7en +IxND6gHVBMu51gI8HDkYkKLaYa2AOwtb02tG+J9WMY9HjMjQOm0wUD5G+KeuO4xxzrn FWGh3NXcktUpmUDfV4caXOxK//gUK861DjFZhRLG61T7ftZdhNnVLVSln84Tu6T35eXO /iNw== X-Gm-Message-State: AOAM532yccdNEBMu5djtV4VqzRtNVsDxtxAIgDvLwASrIQEDEgYYWDmY hN545fKycPAdMQIJLPJfgOLNSg== X-Google-Smtp-Source: ABdhPJyYd+AOcu5tx+w8CHn4dey+W+3+gPxvcA9FEiyAuntQNRmQiufc1W5mxesih8+QEvnI7mVCfQ== X-Received: by 2002:a1c:c309:: with SMTP id t9mr14300wmf.113.1589486633043; Thu, 14 May 2020 13:03:53 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id q14sm18882wrc.66.2020.05.14.13.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2020 13:03:52 -0700 (PDT) Date: Thu, 14 May 2020 22:03:49 +0200 From: Daniel Vetter To: Sam Ravnborg Cc: Daniel Vetter , Kate Stewart , Kefeng Wang , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, Bjorn Andersson , Thierry Reding , Laurent Pinchart , Lee Jones , Daniel Thompson , Jonathan Corbet , Tomi Valkeinen , Russell King , Andy Gross , Uwe Kleine Konig , linux-pwm@vger.kernel.org, Michael Hennerich , Bartlomiej Zolnierkiewicz , Jani Nikula , linux-arm-msm@vger.kernel.org, Jyri Sarha , Thomas Gleixner , Allison Randal , Support Opensource , Jingoo Han , Douglas Anderson , Zheng Bin , Thomas Zimmermann , patches@opensource.cirrus.com, Enrico Weigelt Subject: Re: [PATCH v1 08/18] backlight: add backlight_is_blank() Message-ID: <20200514200349.GD206103@phenom.ffwll.local> References: <20200514191001.457441-1-sam@ravnborg.org> <20200514191001.457441-9-sam@ravnborg.org> <20200514194116.GB206103@phenom.ffwll.local> <20200514194646.GA460099@ravnborg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200514194646.GA460099@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:46:46PM +0200, Sam Ravnborg wrote: > Hi Daniel. > > On Thu, May 14, 2020 at 09:41:16PM +0200, Daniel Vetter wrote: > > 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. > > Will add it in v2. When all user of fb_blank is dropped we can > safely remove it then. > And as you said on irc, the risk of introducing regressions is lower > as we see some creative uses in the drivers today. > I already did some kind of audit - but I may have missed something. btw one pattern I've seen in a few places with a few greps I've just done is maybe worth putting into a helper too: backlight_force_enable(bl) { if (bl->brightness == 0) bl->brightness = bl->max_brightness; backlight_enable(backlight); } Just in case you run out of ideas anytime soon :-) Cheers, Daniel > > Sam > > > > > > +} > > > + > > > 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 > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch