Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3499422pxf; Mon, 22 Mar 2021 07:51:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmaYJvi2MxiHavMqeCD4hVNLL+87RqDq/t4HwPFLmilVzsjS36X2IEzI/bj6vi0ukv8qvT X-Received: by 2002:a05:6402:27d4:: with SMTP id c20mr26463698ede.271.1616424671591; Mon, 22 Mar 2021 07:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616424671; cv=none; d=google.com; s=arc-20160816; b=kzyu6ZfknhUN8XgkcRdtR/TW7HgX7OV4dDls1QrfSaPbgt1YnpAJ0yfBbvK5rsp8qP CzwhHX8MRJpP0CxZN0r/n+aogsfwjCAFSn8KOoNHH63gx91f8/aVXG+Z1G/6TPAPzPJX W9UdTrcs7WarxfKkRM7/0fs76VjiEhbxJtP8y8fS+IABF+LY/f8q8ijg6vNQCxGBpHl7 H8DNj3/krvaVcGZuwcdT/JlF/Qzk871XIhiKmIgJw0wVDhV0VTTvBH2d1S65zR5g9bC8 goUYKoQ8E6MKi03bKoJx1lVauJ1vG3AM+BAVru6sCxXN3B+bGSUW+Wi6WaQsrR4/w7Yy 5tvg== 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=Wk5E2WQ/frNt3b3VIIJE7+CGKk2NIR+uIisMIY1iRWc=; b=P1pPtIJNnzUY0EgF9oPeazBEYE18wp5K7YvpMW4AkOcA4kgRK7kv6kqu58R13dzw6H 3D/1NJSpLxcDySExQcETsDP0Vt5cWgl0goF1bi4lK9xyudFOS4AWydBKfLQ3Dy4Zca+g 3Q8L2jQEqtlymwu9l+TqciWw9S1k+xnG2uGbl5QGnLfu1F3eiqGLfsGAgDll+dzbQpXD ranazPRkC9LkN8PGX6wk21rQipl/jMJMEYlh6nS9XAtp+3oqPE1tjqtDCxFN8J0s3Jkb AR0/vDAaVDMfYDd8B56UR79WckdRN0xgCS/NTlhKGolbkWDbZp8HCiJz17ZMuHKt7uhy vOAg== 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 co21si11570117edb.513.2021.03.22.07.50.48; Mon, 22 Mar 2021 07:51:11 -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 S230051AbhCVOty (ORCPT + 99 others); Mon, 22 Mar 2021 10:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbhCVOs6 (ORCPT ); Mon, 22 Mar 2021 10:48:58 -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 A5C22C0613EE for ; Mon, 22 Mar 2021 07:48:54 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed20:250b:f16c:c5e2:505d]) by albert.telenet-ops.be with bizsmtp id jSot2400i2HDxaV06Sot7m; 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 1lOLrQ-009ZWR-Na; Mon, 22 Mar 2021 15:48:52 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1lOLrP-004T6j-UD; 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 15/17] auxdisplay: ht16k33: Extract frame buffer probing Date: Mon, 22 Mar 2021 15:48:46 +0100 Message-Id: <20210322144848.1065067-16-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 all frame buffer (including backlight) probing into ht16k33_fbdev_probe(). Call ht16k33_fbdev_probe() after ht16k33_keypad_probe(), as the latter does not need any manual cleanup in the probe error path. Signed-off-by: Geert Uytterhoeven --- drivers/auxdisplay/ht16k33.c | 96 ++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index 7c34b7a7879deb1a..11d86960fbc5d8c1 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -394,33 +394,15 @@ static int ht16k33_keypad_probe(struct i2c_client *client, return input_register_device(keypad->dev); } -static int ht16k33_probe(struct i2c_client *client) +static int ht16k33_fbdev_probe(struct i2c_client *client, + struct ht16k33_priv *priv, uint32_t brightness) { - int err; - uint32_t dft_brightness; - struct backlight_device *bl; - struct backlight_properties bl_props; - struct ht16k33_priv *priv; - struct ht16k33_fbdev *fbdev; struct device *dev = &client->dev; + struct ht16k33_fbdev *fbdev = &priv->fbdev; struct device_node *node = dev->of_node; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - dev_err(dev, "i2c_check_functionality error\n"); - return -EIO; - } - - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->client = client; - i2c_set_clientdata(client, priv); - fbdev = &priv->fbdev; - - err = ht16k33_initialize(priv); - if (err) - return err; + struct backlight_properties bl_props; + struct backlight_device *bl; + int err; /* Framebuffer (2 bytes per column) */ BUILD_BUG_ON(PAGE_SIZE < HT16K33_FB_SIZE); @@ -462,13 +444,6 @@ static int ht16k33_probe(struct i2c_client *client) if (err) goto err_fbdev_info; - /* Keypad */ - if (client->irq > 0) { - err = ht16k33_keypad_probe(client, &priv->keypad); - if (err) - goto err_fbdev_unregister; - } - /* Backlight */ memset(&bl_props, 0, sizeof(struct backlight_properties)); bl_props.type = BACKLIGHT_RAW; @@ -482,18 +457,7 @@ static int ht16k33_probe(struct i2c_client *client) goto err_fbdev_unregister; } - err = of_property_read_u32(node, "default-brightness-level", - &dft_brightness); - if (err) { - dft_brightness = MAX_BRIGHTNESS; - } else if (dft_brightness > MAX_BRIGHTNESS) { - dev_warn(dev, - "invalid default brightness level: %u, using %u\n", - dft_brightness, MAX_BRIGHTNESS); - dft_brightness = MAX_BRIGHTNESS; - } - - bl->props.brightness = dft_brightness; + bl->props.brightness = brightness; ht16k33_bl_update_status(bl); ht16k33_fb_queue(priv); @@ -509,6 +473,52 @@ static int ht16k33_probe(struct i2c_client *client) return err; } +static int ht16k33_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct device_node *node = dev->of_node; + struct ht16k33_priv *priv; + uint32_t dft_brightness; + int err; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + dev_err(dev, "i2c_check_functionality error\n"); + return -EIO; + } + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->client = client; + i2c_set_clientdata(client, priv); + + err = ht16k33_initialize(priv); + if (err) + return err; + + err = of_property_read_u32(node, "default-brightness-level", + &dft_brightness); + if (err) { + dft_brightness = MAX_BRIGHTNESS; + } else if (dft_brightness > MAX_BRIGHTNESS) { + dev_warn(dev, + "invalid default brightness level: %u, using %u\n", + dft_brightness, MAX_BRIGHTNESS); + dft_brightness = MAX_BRIGHTNESS; + } + + /* Keypad */ + if (client->irq > 0) { + err = ht16k33_keypad_probe(client, &priv->keypad); + if (err) + return err; + } + + /* Frame Buffer Display */ + return ht16k33_fbdev_probe(client, priv, dft_brightness); +} + static int ht16k33_remove(struct i2c_client *client) { struct ht16k33_priv *priv = i2c_get_clientdata(client); -- 2.25.1