Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp201797pxb; Fri, 15 Oct 2021 03:55:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJws1yORTMIww/hVx2XoLJSbb/OMVadcevcZisIu27aXrpgylwVYnLULS0PhxtdJCtmuYswu X-Received: by 2002:a17:90a:ac03:: with SMTP id o3mr12937098pjq.130.1634295314200; Fri, 15 Oct 2021 03:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634295314; cv=none; d=google.com; s=arc-20160816; b=LCsai7X3XImGw06K8Sz89eyIr+rm/DjOvB/+3EpIwXswkmvuZkFgxYoaIDjdAK5yKR CX88RwdyjPKgHByX9ECxsYlUCh6VRm3Cc/gEgKnIuqbwE0fSCejdVhOn2HWja+NIptoR eBCmGHfcBP9HruxHEsTKNbbO7eCpA5NLRHjdA9o19hvIgTlCK/wsglAMTfYxOJknt5Td nGa2ACUhEnkojfzWB5a1CGdsk+ewv/NfVRoQca84aBV2qmZmn42OSbcxs6IrsAXI/t5W 9l2MzMPiUwesX28YG1Jr+M8sFwjRDzJbPRJrUBadIMqmbhZFfxVRB4E/TMxje0NOXLwf trSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=D9iYedh4eX9SnwmBHfnTvY1So2AkybRePWaYfCfRUwI=; b=e7pgiZzmAI50nTmYkRF98yGelgA+NIe347I+9Ve2v8ZNMNu4csk4M4rgE0z0b28DAx uwtt66sp1IlbGEoreLj4GVatS08+rkj955eBWWWqtJK+ZG9u6yJxERiS/KUipAumj0mW fwUvoiANt5NywEEeoviAcfPoWZGk/GwMEFaGYadO+ORFHRvbUuhwItHgJFFkj1brejal BZVPjMXiVOdjGCItpV9xY9iTDqHrF9oXfQuw2i3UQO5+e5xjPFXUTtV6h2uozSHPw3dl WJKpfvjDyYtV4oAYYK4vlzYLmh8NazUDtJkqeP7m+xGWNw12EAvr9rZJXdLqNgNE3dxW 2zpg== 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 ob13si9053947pjb.78.2021.10.15.03.55.01; Fri, 15 Oct 2021 03:55:14 -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 S235009AbhJOCap (ORCPT + 99 others); Thu, 14 Oct 2021 22:30:45 -0400 Received: from mx22.baidu.com ([220.181.50.185]:51886 "EHLO baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234986AbhJOCao (ORCPT ); Thu, 14 Oct 2021 22:30:44 -0400 Received: from BC-Mail-Ex26.internal.baidu.com (unknown [172.31.51.20]) by Forcepoint Email with ESMTPS id C5B1299473A1198EF05A; Fri, 15 Oct 2021 10:28:32 +0800 (CST) Received: from BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) by BC-Mail-Ex26.internal.baidu.com (172.31.51.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 15 Oct 2021 10:28:32 +0800 Received: from LAPTOP-UKSR4ENP.internal.baidu.com (172.31.63.8) by BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Fri, 15 Oct 2021 10:28:31 +0800 From: Cai Huoqing To: , CC: , , , , , , , Subject: [PATCH v2 2/2] HID: wacom: Make use of the helper function devm_add_action_or_reset() Date: Fri, 15 Oct 2021 10:28:03 +0800 Message-ID: <20211015022803.3827-2-caihuoqing@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211015022803.3827-1-caihuoqing@baidu.com> References: <20211015022803.3827-1-caihuoqing@baidu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.31.63.8] X-ClientProxiedBy: BC-Mail-Ex31.internal.baidu.com (172.31.51.25) To BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The helper function devm_add_action_or_reset() will internally call devm_add_action(), and if devm_add_action() fails then it will execute the action mentioned and return the error code. So use devm_add_action_or_reset() instead of devm_add_action() to simplify the error handling, reduce the code. Signed-off-by: Cai Huoqing --- v1->v2: *Sort to patch series with [PATCH v2 1/2] from Jason drivers/hid/wacom_sys.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 62f50e4b837d..2717d39600b4 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -894,11 +894,9 @@ static int wacom_add_shared_data(struct hid_device *hdev) wacom_wac->shared = &data->shared; - retval = devm_add_action(&hdev->dev, wacom_remove_shared_data, wacom); - if (retval) { - wacom_remove_shared_data(wacom); + retval = devm_add_action_or_reset(&hdev->dev, wacom_remove_shared_data, wacom); + if (retval) return retval; - } if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) wacom_wac->shared->touch = hdev; -- 2.25.1