From patchwork Wed Dec 16 01:39:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 11976115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35146C2BB48 for ; Wed, 16 Dec 2020 01:39:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E85B623109 for ; Wed, 16 Dec 2020 01:39:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725275AbgLPBjz (ORCPT ); Tue, 15 Dec 2020 20:39:55 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:32023 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725550AbgLPBjz (ORCPT ); Tue, 15 Dec 2020 20:39:55 -0500 Date: Wed, 16 Dec 2020 01:39:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1608082753; bh=sEEwi4cgN99o5qj+ZeyAM9IlOacYuj+VTMwAtdAanac=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=Su1NWBwCh6pHu5zezjIP7lDKPW5M4JKOJ98Mzws+y6L2hxOz/I2AjGLMoaPNiVymA UBbawcPMVkDQEFfzPsMdjJx2YDKggS/DHIQPocKVBVXzQN+OoRL+012tMPK8bbuKVt KpXyg5kzP3cPNtS83x/w7T/5sC8xOTc2OASv7d0M= To: platform-driver-x86@vger.kernel.org, Hans de Goede , Mark Gross , Ike Panhc From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH 02/24] platform/x86: ideapad-laptop: use appropriately typed variable to store the return value of ACPI methods Message-ID: <20201216013857.360987-3-pobrn@protonmail.com> In-Reply-To: <20201216013857.360987-1-pobrn@protonmail.com> References: <20201216013857.360987-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Use a variable with type `acpi_status` to store the return value of ACPI methods instead of a plain `int`. And use ACPI_{SUCCESS,FAILURE} macros where possible instead of direct comparison. Signed-off-by: Barnabás Pőcze diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 9ed5bd8d955b..8b86e5547b59 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -971,6 +971,7 @@ static int ideapad_acpi_add(struct platform_device *pdev) int cfg; struct ideapad_private *priv; struct acpi_device *adev; + acpi_status acpi_err; ret = acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev); if (ret) @@ -1018,22 +1019,26 @@ static int ideapad_acpi_add(struct platform_device *pdev) if (ret && ret != -ENODEV) goto backlight_failed; } - ret = acpi_install_notify_handler(adev->handle, - ACPI_DEVICE_NOTIFY, ideapad_acpi_notify, priv); - if (ret) + acpi_err = acpi_install_notify_handler(adev->handle, + ACPI_DEVICE_NOTIFY, ideapad_acpi_notify, priv); + if (ACPI_FAILURE(acpi_err)) { + ret = -EIO; goto notification_failed; + } #if IS_ENABLED(CONFIG_ACPI_WMI) for (i = 0; i < ARRAY_SIZE(ideapad_wmi_fnesc_events); i++) { - ret = wmi_install_notify_handler(ideapad_wmi_fnesc_events[i], - ideapad_wmi_notify, priv); - if (ret == AE_OK) { + acpi_err = wmi_install_notify_handler(ideapad_wmi_fnesc_events[i], + ideapad_wmi_notify, priv); + if (ACPI_SUCCESS(acpi_err)) { priv->fnesc_guid = ideapad_wmi_fnesc_events[i]; break; } } - if (ret != AE_OK && ret != AE_NOT_EXIST) + if (ACPI_FAILURE(acpi_err) && acpi_err != AE_NOT_EXIST) { + ret = -EIO; goto notification_failed_wmi; + } #endif return 0;