Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp33885pxb; Thu, 30 Sep 2021 00:00:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfifz+SwyMwLT+cDo0U/8zCsjmfGQcGDtEslrZQOXZ6dUGyagZxwg3pYeKulhOedG62ouk X-Received: by 2002:a17:90a:c695:: with SMTP id n21mr4761582pjt.183.1632985250702; Thu, 30 Sep 2021 00:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632985250; cv=none; d=google.com; s=arc-20160816; b=dpBacJU8hIL359OhrZoQwzU0OdAXwx0XtGudFum3dIHL2aOMZm6fPqtsFiby+z3UFc sDiaFLHIxi5o4LgNpkjTBEHhcrp7Oxqrn1nBzGxkGB+npe9LFCN58RqzMBIyAMX0yhAw oHzuGlqS4/5FOAKeudXp79qjVcCMZ6wVdtYVu0uWMNphya2jra62nfIq9jQNQjCNpyzP 2xDn0WRMDg1jt/ojazk8b/+vI6rjIipLdamXtV19et92qk0K+YqIXqn36riuks814Ea+ LOX5tuFurODGXVtGwYzg4LmJoWu+bAucS97bMK5ITRVcFkObIqMMyACCcT+a+sHYX2MN P56A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :message-id:user-agent:references:in-reply-to:reply-to:subject:cc:to :from:date:mime-version; bh=HZh+JkdvIltm0qtiEp2NzOXLYk3NzYkQWrobjPHoRnM=; b=xj8evTLuAQOdgQJ6qGxaH0VRxzePZspmWSFU2zPVmXmTZtO3U9N14ezoPzZxpTlxLb 1u4ks6NAkDwtRciHF5/nELM0SZfpDGf0ncGvGkZCh3o9mLgMiak1drc93XcgiYpJSpDs HTvfXHOCczkrH2fktSYCpfBOi5LgCnlameXi9D13fLVUdXNNUMWE0Ew0oC+cPTsPBh4n gHNUIVnq8Q6lgIHKWfEkf08T3AZUhUV9x8yqZwsFXRt/as1O/NQk8NukIymzIcyYDNPh Zr6XIf/BTRR3i/vwuhI9wbmM1/9nKyGT+df8fTu6ceGh73H8GKCQqoD1A9yfgPZVFQ2N 56QQ== 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 a5si2558830pgw.365.2021.09.30.00.00.37; Thu, 30 Sep 2021 00:00:50 -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 S1348444AbhI3HAX (ORCPT + 99 others); Thu, 30 Sep 2021 03:00:23 -0400 Received: from protonic.xs4all.nl ([83.163.252.89]:41812 "EHLO protonic.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231938AbhI3HAW (ORCPT ); Thu, 30 Sep 2021 03:00:22 -0400 Received: from fiber.protonic.nl (edge2.prtnl [192.168.1.170]) by sparta.prtnl (Postfix) with ESMTP id 6EDA744A024E; Thu, 30 Sep 2021 08:58:38 +0200 (CEST) MIME-Version: 1.0 Date: Thu, 30 Sep 2021 08:58:38 +0200 From: Robin van der Gracht To: Geert Uytterhoeven Cc: Miguel Ojeda , Rob Herring , Paul Burton , Greg Kroah-Hartman , Pavel Machek , Marek Behun , devicetree@vger.kernel.org, linux-leds@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 15/19] auxdisplay: ht16k33: Extract ht16k33_brightness_set() Reply-To: robin@protonic.nl In-Reply-To: <20210914143835.511051-16-geert@linux-m68k.org> References: <20210914143835.511051-1-geert@linux-m68k.org> <20210914143835.511051-16-geert@linux-m68k.org> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <39669058fbcac7d5612066e4f8146956@protonic.nl> X-Sender: robin@protonic.nl Organization: Protonic Holland Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reviewed-by: Robin van der Gracht On 2021-09-14 16:38, Geert Uytterhoeven wrote: > Extract brightness handling into a helper function, so it can be called > from multiple places. > > Signed-off-by: Geert Uytterhoeven > --- > v6: > - No changes, > > v5: > - No changes, > > v4: > - No changes, > > v3: > - Use "err" instead of "error" to be consistent with existing driver > naming style, > > 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..928ac9722c142855 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 err; > + > + if (brightness == 0) > + return ht16k33_display_off(priv); > + > + err = ht16k33_display_on(priv); > + if (err) > + return err; > + > + 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) Met vriendelijke groet, Robin van der Gracht -- Protonic Holland Factorij 36 1689AL Zwaag +31 (0)229 212928 https://www.protonic.nl