From patchwork Wed Jan 13 18:20:31 2021 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: 12017501 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.8 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 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 C7F8BC433E0 for ; Wed, 13 Jan 2021 18:21:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 803D723436 for ; Wed, 13 Jan 2021 18:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727809AbhAMSVS (ORCPT ); Wed, 13 Jan 2021 13:21:18 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:60222 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726429AbhAMSVS (ORCPT ); Wed, 13 Jan 2021 13:21:18 -0500 Date: Wed, 13 Jan 2021 18:20:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1610562035; bh=p/RmxgzjPFuwTZGWTX148bvreK8r1y3X6OlrhmokIi0=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=xhBlPL//BBdCYdMcdIMa/zwjxMEbGsBl7A/UCzwQz7f5uMLvF+3dIDWBcsx9cMDBB dU6nVte7354JbhmNLAmEvclzrmzbf/ChL47Y4NcSx02Fhi5Moc4QfdsYByLGi4h+sn 2t9GoAkitvitCMPboK4o7pxbRazlup/aanql/VD4= 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 v2 02/24] platform/x86: ideapad-laptop: use appropriately typed variable to store the return value of ACPI methods Message-ID: <20210113182016.166049-3-pobrn@protonmail.com> In-Reply-To: <20210113182016.166049-1-pobrn@protonmail.com> References: <20210113182016.166049-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 Reviewed-by: Hans de Goede diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index c96fd60ec7d2..fbaf8d3f4792 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -977,6 +977,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) @@ -1031,22 +1032,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;