From patchwork Thu Aug 27 18:58:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 11741323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C70B739 for ; Thu, 27 Aug 2020 18:58:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 043B922BEA for ; Thu, 27 Aug 2020 18:58:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598554732; bh=BwfgtYwfZRXQcOsZb1hJsrMr/vfMEucNWSrgiCt3KzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Tj3+7E3QSwQC/PF0/vgC3iBIzjAk2cjkW4+DWTEm0SzTwcG56+orwd9XH2f/fc9nT oafcfUso4CFhyzDU89u3K2lL1nHDhQwbGbpYi0QyaPoxB1vUcQVjCz6UCTQyN5vD39 CPvygEzIzj/KqsDmurU0ip/sHiojQmF+DiAsBvvk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727834AbgH0S6v (ORCPT ); Thu, 27 Aug 2020 14:58:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:48694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbgH0S6t (ORCPT ); Thu, 27 Aug 2020 14:58:49 -0400 Received: from localhost.localdomain (unknown [194.230.155.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EEA4922BEA; Thu, 27 Aug 2020 18:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598554728; bh=BwfgtYwfZRXQcOsZb1hJsrMr/vfMEucNWSrgiCt3KzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vVr5/MCQlD3GDecFebJAnOHVmPlCdu8HYSjZdSYUNlbbvD2mlXpHmalyLwX+/8MeG mocsbKQXRz+eUYyafKgIQs4wlUIohOO+X2wpQEEgX9pDFlmljRiPnLnPoTf6tsUPqK GJBL2iWYUyz/aY9Q68jfRgHe+FVl2CH7g/suW5hY= From: Krzysztof Kozlowski To: Linus Walleij , Bartosz Golaszewski , Dmitry Torokhov , Hans de Goede , Bastien Nocera , Sangwon Jee , Eugen Hristev , Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org, clang-built-linux@googlegroups.com Cc: Krzysztof Kozlowski Subject: [PATCH v3 02/27] Input: gpio-vibra - Simplify with dev_err_probe() Date: Thu, 27 Aug 2020 20:58:04 +0200 Message-Id: <20200827185829.30096-3-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200827185829.30096-1-krzk@kernel.org> References: <20200827185829.30096-1-krzk@kernel.org> Sender: platform-driver-x86-owner@vger.kernel.org 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 --- Changes since v1: 1. Remove unneeded PTR_ERR_OR_ZERO, as pointed by Andy. --- drivers/input/misc/gpio-vibra.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/input/misc/gpio-vibra.c b/drivers/input/misc/gpio-vibra.c index f79f75595dd7..13c69f173620 100644 --- a/drivers/input/misc/gpio-vibra.c +++ b/drivers/input/misc/gpio-vibra.c @@ -113,22 +113,14 @@ static int gpio_vibrator_probe(struct platform_device *pdev) return -ENOMEM; vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc"); - err = PTR_ERR_OR_ZERO(vibrator->vcc); - if (err) { - if (err != -EPROBE_DEFER) - dev_err(&pdev->dev, "Failed to request regulator: %d\n", - err); - return err; - } + if (IS_ERR(vibrator->vcc)) + return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->vcc), + "Failed to request regulator\n"); vibrator->gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW); - err = PTR_ERR_OR_ZERO(vibrator->gpio); - if (err) { - if (err != -EPROBE_DEFER) - dev_err(&pdev->dev, "Failed to request main gpio: %d\n", - err); - return err; - } + if (IS_ERR(vibrator->gpio)) + return dev_err_probe(&pdev->dev, PTR_ERR(vibrator->gpio), + "Failed to request main gpio\n"); INIT_WORK(&vibrator->play_work, gpio_vibrator_play_work);