Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1120521pxv; Fri, 25 Jun 2021 06:02:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycarhZ0s8hykqhAKV792uWQ5M0tQ94jUYbs12D4EmkaVRlXMYyNwPkhzXW6Tou1wX5bBWJ X-Received: by 2002:a5d:4dc8:: with SMTP id f8mr11042901wru.168.1624626139915; Fri, 25 Jun 2021 06:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624626139; cv=none; d=google.com; s=arc-20160816; b=LI8syUZiPIsa2LBK2Txj12aVRJVIf+CmjXZtq81RKL6/oCHAZYz9EztPIlzi0oicpC XUQ4V6BJJvRjnr4Lv1Zby/Q6OoZbGdctZuVOyBe8TPzoUkyLStPOG4XJ94kudgJpKd6f 8+DEGFAVmlV5O7kjSkOgV74ORjwQ86n3AQicmXBqRSRxHKp48+wNCVPTo92cy2oB6qoJ 8TC1+XFzQKPz4pIF/QNSHBSJSMZjVbYV1fMLCbiN6tNMnI7c1Q6X5yAKbndsSLvE+D3W dyRLvJY4wIEAOnuy+g6aoiQStlB8mO/CqpmRRXx3L1aONzenBSw+9VvhTxH8GX6VhyuP YhzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=p0Oxl/n4XcBm0ffpHApP2Dqd+45vAEmsOQDlbHddon4=; b=MMKOwW60CeaiXRlSk4789d5zY/xOLWsn+TpImFD2STAHwBDu8Vzgfy3URRXay/QC8g fA9YAkeAQ01+4JniDuork8Mo+r4udx0PxUwPp+GGeJQYDmNzC+kWuZF4aQduDvvVBu70 AEytku9rvI9gBpBeUh1xOd/xK+MVae3FeovxpLnVKpEvWrsC67b4Z9tExv6dbnjxXpE7 uu4x7Es/53ay5hqya5QGQtyTV9gRPkoGfV9tJjZ1XgcZyVOUtrvqoXArfJdx1ccorDOB WDrWLaC6qTIKwIsOr2ih4LRLOnqGXKN4YEjTV/E4QxQ3ZZJqfUJdZBPsmCQTepA0HZS3 Bxpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e18si6029284edr.336.2021.06.25.06.01.56; Fri, 25 Jun 2021 06:02:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231709AbhFYNCZ (ORCPT + 99 others); Fri, 25 Jun 2021 09:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231659AbhFYNBv (ORCPT ); Fri, 25 Jun 2021 09:01:51 -0400 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00FD2C061153 for ; Fri, 25 Jun 2021 05:59:17 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed20:1476:ce84:e216:add8]) by laurent.telenet-ops.be with bizsmtp id MQzD2500v2B1U9901QzDBq; Fri, 25 Jun 2021 14:59:14 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lwlQO-003TMX-UH; Fri, 25 Jun 2021 14:59:12 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1lwlQN-004sRa-PZ; Fri, 25 Jun 2021 14:59:11 +0200 From: Geert Uytterhoeven To: Robin van der Gracht , Rob Herring , Miguel Ojeda , Paul Burton , Greg Kroah-Hartman , Pavel Machek Cc: devicetree@vger.kernel.org, linux-leds@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 15/18] auxdisplay: ht16k33: Extract ht16k33_brightness_set() Date: Fri, 25 Jun 2021 14:58:59 +0200 Message-Id: <20210625125902.1162428-16-geert@linux-m68k.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210625125902.1162428-1-geert@linux-m68k.org> References: <20210625125902.1162428-1-geert@linux-m68k.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extract brightness handling into a helper function, so it can be called from multiple places. Signed-off-by: Geert Uytterhoeven --- v2: - No changes. --- drivers/auxdisplay/ht16k33.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index c7a3a0e1fbb5d03e..ed5aab2627e028ed 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -113,6 +113,22 @@ static int ht16k33_display_off(struct ht16k33_priv *priv) return i2c_smbus_write_byte(priv->client, REG_DISPLAY_SETUP); } +static int ht16k33_brightness_set(struct ht16k33_priv *priv, + unsigned int brightness) +{ + int error; + + if (brightness == 0) + return ht16k33_display_off(priv); + + error = ht16k33_display_on(priv); + if (error) + return error; + + return i2c_smbus_write_byte(priv->client, + REG_BRIGHTNESS | (brightness - 1)); +} + static void ht16k33_fb_queue(struct ht16k33_priv *priv) { struct ht16k33_fbdev *fbdev = &priv->fbdev; @@ -197,13 +213,10 @@ static int ht16k33_bl_update_status(struct backlight_device *bl) if (bl->props.power != FB_BLANK_UNBLANK || bl->props.fb_blank != FB_BLANK_UNBLANK || - bl->props.state & BL_CORE_FBBLANK || brightness == 0) { - return ht16k33_display_off(priv); - } + bl->props.state & BL_CORE_FBBLANK) + brightness = 0; - ht16k33_display_on(priv); - return i2c_smbus_write_byte(priv->client, - REG_BRIGHTNESS | (brightness - 1)); + return ht16k33_brightness_set(priv, brightness); } static int ht16k33_bl_check_fb(struct backlight_device *bl, struct fb_info *fi) -- 2.25.1