Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3500049pxf; Mon, 22 Mar 2021 07:52:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjX5RNR08dToixlf2RjiAw+n9xPbutW+faR4YskhZsJnf2D1hEZxquOrxXAG3HoAx8i+Xr X-Received: by 2002:aa7:db0c:: with SMTP id t12mr25715737eds.34.1616424735677; Mon, 22 Mar 2021 07:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616424735; cv=none; d=google.com; s=arc-20160816; b=Rw/smrM/l8hFmUdnH3E2A9R7x3LKWJ0p3onifYFJT1owOp9GzXKJDtdJABdg/2YGfQ eWX50z7AUB22rvtoMZcIBKVdIg8aNjWFwfwGA1Xro92D1Mmox8JNsdh4iy0Dr84CaKg9 FmdgbmJmpEMDLWql2+951898+M5db1dTVw9m0q3BJbXVbKgvC5fYnLbm/kJ3Vd2hxoig At/8I8rbhI3iIf+dYhAKrvrrydtia/5Xzoktk/3/rEV9as9eQvM1760fYUu4yUbcuVCb zpDpWPM+15t/7Krq1G/6C1FzVREwMMurMiUbKF/n8GpfoZ661Aqwg3bMvY9f+ULMqW3e IoCA== 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=n10YTl8yDHfoLk7Eb0QFT+Ylko/1K3gSQHGE1LQuwm4=; b=nN3Ep1u25puVVEk8lCo7x9o+L4OaZ5LVOqLYYWc3NdjZM/WH2W1fOPjrfcoK3Hnt+0 Xa9pQKsfClS1cBXYX50Av1IwP8MAIvPF7F2S8WEAjeQWlXuG+AyXEzprNe9OGRv6p0n6 YV9rfo1f4wve4Ygqna/sKQvyEqsrbHIDPlTRDdSCUrC3jIl2uQjrwrXW5HdIxDS3rOMY 3sguLwYq5qbw2TDHQmz+EORHTyLS0bb9D8Md2HMF1iE7/GxM9RcEFVCvLoe7rb15iG3K wg5KdASvzcOPed0IvX7dD2icEAbxuT73aIfqiyz+0jjvioxrMcnA6Yi1kyt9nPtwvKSL dHGA== 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 38si11912297edr.200.2021.03.22.07.51.53; Mon, 22 Mar 2021 07:52:15 -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 S231458AbhCVOum (ORCPT + 99 others); Mon, 22 Mar 2021 10:50:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbhCVOtC (ORCPT ); Mon, 22 Mar 2021 10:49:02 -0400 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDF74C0613AE for ; Mon, 22 Mar 2021 07:48:55 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed20:250b:f16c:c5e2:505d]) by albert.telenet-ops.be with bizsmtp id jSot2401Q2HDxaV06Sot8G; Mon, 22 Mar 2021 15:48:53 +0100 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 1lOLrR-009ZWQ-1j; Mon, 22 Mar 2021 15:48:53 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1lOLrP-004T6e-TA; Mon, 22 Mar 2021 15:48:51 +0100 From: Geert Uytterhoeven To: Robin van der Gracht , Rob Herring , Miguel Ojeda , Paul Burton , Greg Kroah-Hartman Cc: devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 14/17] auxdisplay: ht16k33: Extract ht16k33_brightness_set() Date: Mon, 22 Mar 2021 15:48:45 +0100 Message-Id: <20210322144848.1065067-15-geert@linux-m68k.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210322144848.1065067-1-geert@linux-m68k.org> References: <20210322144848.1065067-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 --- 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 91b039702270ab10..7c34b7a7879deb1a 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