From patchwork Sun Jun 25 16:28:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13292066 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35A2FC001B3 for ; Sun, 25 Jun 2023 16:29:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbjFYQ3n (ORCPT ); Sun, 25 Jun 2023 12:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbjFYQ3e (ORCPT ); Sun, 25 Jun 2023 12:29:34 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C6D426A0 for ; Sun, 25 Jun 2023 09:29:09 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-98dfb3f9af6so224224166b.2 for ; Sun, 25 Jun 2023 09:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687710527; x=1690302527; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S/rzC2uY92Y7QjHEbrLYHKQpIVmtiRBB2yJYhOpPt9Y=; b=kWNVgHVXaDznJi3aUv40cg0WDHjPqeQbE7ooAhNpc2QVWxrle12iAqj9L+h1TWwXDk dtkI3ow6FX5XwNM2MAed6C8itsSEWMtYnbIJocwNd873waZ/vDuEnPIfCTdcgUwZM7Cl O+qvTaWV3lFRymsHglHnxKJhxBytkBk83943nXaapTsWi20aON/w+L1Wl0hcPzvfFXhD /OlecmPqtoZ9NICiamf4EhZWcMr7NqgEDXVoHqOWJu+xyh0hI2gSKxXB4uOnWywbCveZ D/XizEWkdsh50oE8aorQCbqCr6iWPg//rU0BnBlaG1jXMHaEztkDAJJylN6+CM+8AZYV /ZwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687710527; x=1690302527; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S/rzC2uY92Y7QjHEbrLYHKQpIVmtiRBB2yJYhOpPt9Y=; b=VeeoAfRZxjL01FImV69Jdd2GnIrpGUb9U7rfrzMpwOVw+bvi9bOApcqHlPavcS71tk ZJJsNB51NGPkKSEfDJQJJa/Y8MQYw80qGLd8rIf6uVe8th2LOSZ3jkvtqX+5APU6i2Yt RoATBmqHyJMttEKIJhohmuy6dozEx4iwH18T8J1Pq6K0uxHajKT4pqxnU3Wz4m7pOcTR RdIjjFw2/iuSTt8aNcv9FfwBb6InrpEq9gfy9U1fhowBYwBQO8Y8nsF3ktqhuMLLHpjr io/U9ggvZk6QkF4tf7R3ZHU+zPAVnoawYitGXhwk7BrFCs0IrgGVyflt/Msa+p8yQrq3 fk3Q== X-Gm-Message-State: AC+VfDzY9YfUaoouYZu7QuTZ1divboYtjJ7W+rQ4vok7YDpAF4QLeRKb kzkPDX52XWWMws6RR4QUbTltKA== X-Google-Smtp-Source: ACHHUZ4BOguJGgvQUdBr/7tJsm58YGWNa+vqxnxV1YpaTPhoPeHr/NE4gBjdMj0HYjBTCHK6qE943g== X-Received: by 2002:a17:907:d0f:b0:94e:4489:f24d with SMTP id gn15-20020a1709070d0f00b0094e4489f24dmr26387029ejc.61.1687710526920; Sun, 25 Jun 2023 09:28:46 -0700 (PDT) Received: from krzk-bin.. ([178.197.219.26]) by smtp.gmail.com with ESMTPSA id ec10-20020a170906b6ca00b00982be08a9besm2277731ejb.172.2023.06.25.09.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 09:28:46 -0700 (PDT) From: Krzysztof Kozlowski To: Dmitry Torokhov , Hans de Goede , Linus Walleij , Bastien Nocera , Sangwon Jee , Eugen Hristev , =?utf-8?q?Mika_Penttil=C3=A4?= , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Cc: Andi Shyti , Andy Shevchenko , Krzysztof Kozlowski , Andy Shevchenko Subject: [PATCH v4 13/24] Input: goodix - Simplify with dev_err_probe() Date: Sun, 25 Jun 2023 18:28:06 +0200 Message-Id: <20230625162817.100397-14-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230625162817.100397-1-krzysztof.kozlowski@linaro.org> References: <20230625162817.100397-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Hans de Goede Reviewed-by: Andy Shevchenko --- drivers/input/touchscreen/goodix.c | 40 ++++++++---------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index f5aa240739f9..85d4249f1065 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -935,7 +935,6 @@ static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts) */ static int goodix_get_gpio_config(struct goodix_ts_data *ts) { - int error; struct device *dev; struct gpio_desc *gpiod; bool added_acpi_mappings = false; @@ -951,33 +950,20 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts) ts->gpiod_rst_flags = GPIOD_IN; ts->avdd28 = devm_regulator_get(dev, "AVDD28"); - if (IS_ERR(ts->avdd28)) { - error = PTR_ERR(ts->avdd28); - if (error != -EPROBE_DEFER) - dev_err(dev, - "Failed to get AVDD28 regulator: %d\n", error); - return error; - } + if (IS_ERR(ts->avdd28)) + return dev_err_probe(dev, PTR_ERR(ts->avdd28), "Failed to get AVDD28 regulator\n"); ts->vddio = devm_regulator_get(dev, "VDDIO"); - if (IS_ERR(ts->vddio)) { - error = PTR_ERR(ts->vddio); - if (error != -EPROBE_DEFER) - dev_err(dev, - "Failed to get VDDIO regulator: %d\n", error); - return error; - } + if (IS_ERR(ts->vddio)) + return dev_err_probe(dev, PTR_ERR(ts->vddio), "Failed to get VDDIO regulator\n"); retry_get_irq_gpio: /* Get the interrupt GPIO pin number */ gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN); - if (IS_ERR(gpiod)) { - error = PTR_ERR(gpiod); - if (error != -EPROBE_DEFER) - dev_err(dev, "Failed to get %s GPIO: %d\n", - GOODIX_GPIO_INT_NAME, error); - return error; - } + if (IS_ERR(gpiod)) + return dev_err_probe(dev, PTR_ERR(gpiod), "Failed to get %s GPIO\n", + GOODIX_GPIO_INT_NAME); + if (!gpiod && has_acpi_companion(dev) && !added_acpi_mappings) { added_acpi_mappings = true; if (goodix_add_acpi_gpio_mappings(ts) == 0) @@ -988,13 +974,9 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts) /* Get the reset line GPIO pin number */ gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, ts->gpiod_rst_flags); - if (IS_ERR(gpiod)) { - error = PTR_ERR(gpiod); - if (error != -EPROBE_DEFER) - dev_err(dev, "Failed to get %s GPIO: %d\n", - GOODIX_GPIO_RST_NAME, error); - return error; - } + if (IS_ERR(gpiod)) + return dev_err_probe(dev, PTR_ERR(gpiod), "Failed to get %s GPIO\n", + GOODIX_GPIO_RST_NAME); ts->gpiod_rst = gpiod;