Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1855865ybi; Sat, 13 Jul 2019 01:52:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5QJKejG1l+33jVwALDIRNxxwNMC2a4QQq1D9RCB7EBIJfjX5Y6izGox4vZpbLCGhrHKSN X-Received: by 2002:a17:902:7083:: with SMTP id z3mr16820896plk.278.1563007936502; Sat, 13 Jul 2019 01:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563007936; cv=none; d=google.com; s=arc-20160816; b=yJIv2pFlWsM/G3CWbHHxk2nlRJyydijsllayGj0BpdRurzgf57IUyA8iOALpQvVcFG 0MFwNu2HGXOUimlD8xaIZm431+/5jUkpx1xD8nfXemlhtEUZKp3URg9WoDURbfkIAUYa 53iipcXqg3YEKx8jIyq2zNNx2knPF+2Yko8HjFa29VMp/zMOPhlUdtX4PKY89sI0VbM+ wJgYObCG6XtQIAK/PIZREr27res3VdlUs8t7fzjEyjhGD8arC6qGVpXpwSzrwRQ3Ie8A c66dXDTG9zhPHjJYoLrRqwm9j3mRV3R05j+1Bw3d/J+JRuOFtvH9Xf9FwiRJUd3WeQ7l /ZNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=utzqHI/cp2sxXHHGSJtE6rG6UN4H5LVvwlzG1e0NnIk=; b=nhv4I4I2lmRXsd4MrZ06UcnRd/V/4khZkaJ1IYGXWXxsHgHqbeETDSHrdn2nc1wcTl EnvIhbIxnrnrGkNYAOOF7assF+XQieOH6HU1PEYbzt01LtHb6wJMzygIClptq9EjZUUe NLlaXS+YGh7yeRqsQuUv+j3k4nyoD3BEcPAwr+metHhOSniG/EDG08/qk87BIOE6aFBF xOn8/UoqkOVPnoEHIXt48Z30scp+raN1nnXJJFEtTZ7Y7TfVc2H3FAaASnB4PzkhsmFp 0Bw2To1pwo0IocbqEPPFdW0exwXVBV2oCOgdilJmEQsV3dtBu29Rd00H4CCwUTzZOD4J x/vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E3e+fGOf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12si10399107pla.363.2019.07.13.01.52.00; Sat, 13 Jul 2019 01:52:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E3e+fGOf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727418AbfGMIvV (ORCPT + 99 others); Sat, 13 Jul 2019 04:51:21 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38638 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbfGMIvV (ORCPT ); Sat, 13 Jul 2019 04:51:21 -0400 Received: by mail-pf1-f196.google.com with SMTP id y15so5342292pfn.5; Sat, 13 Jul 2019 01:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=utzqHI/cp2sxXHHGSJtE6rG6UN4H5LVvwlzG1e0NnIk=; b=E3e+fGOf5WzyVMJK1i+OYcPdsS2KXoHwHWjszu7ucgYn0PRi/OMCFTFabGi6a23ahM PzJRp4d3fKtQZWmA1FRDZ7dESPYI59Fv82teDcusq5D5zVPMzm3RzILxuGk9RSddhqqd kqY90nA/Au2rXE7lL4S0XAnId+95PJw21xznabcrNbEL3Lptz3/JZOj6xT0AD/z15qyY TVj+Ni4tNQi2f4w3qFX1VLJcDotf0qeE7sXT8oW3IVqAWOOV3d2RATUIgy3i3WeCoZc3 wJrfWW3kJ7czhNCdvGeEvttjkBxCBdgsRGcdkMAtAOWDQf/aJQ5aG3ynuJHzg4nJasaQ fs4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=utzqHI/cp2sxXHHGSJtE6rG6UN4H5LVvwlzG1e0NnIk=; b=jkwkPv5U6ONRl04KPMk11B/dTm12Ah2CY8X+WUPJSwIfxswqnAh3BtWLoaVCClWknE Cz3+//rrBVJVH1n9dQ5O12tUEpdZzK4aAyqnX9ryLqAhqcuRin/sxSqQWzGjhR2TZEtQ vyMIn9btZs0SfvpBlJNLFeKr/PIChoYRtnEI8dT7SAZ9tFMk3Ymrr5B0OZQxtKE9r7qR mms5Zl8Bf//213I0wiRR0x6g6pYsDAqEVsFwEGsjw9Xktt5AksPb6bnUxptnupKguHd7 FlckpNNXbHJpAXWP/gX5XJYEdAIPWldp5l3V0riMLqQPpwrDfwl/ZhXVPcVDbhDrMNdW hwfg== X-Gm-Message-State: APjAAAWy6v/bLnvCln3LAX8NAccgJP7RNPLlLrYs2vL16g6hgSSMrTmk rlv+2qxUrw8/QuF+7kk90rJL/CO4epQ= X-Received: by 2002:a17:90a:26ef:: with SMTP id m102mr16955113pje.50.1563007880477; Sat, 13 Jul 2019 01:51:20 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id a21sm13724324pfi.27.2019.07.13.01.51.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 13 Jul 2019 01:51:20 -0700 (PDT) Date: Sat, 13 Jul 2019 01:51:18 -0700 From: Dmitry Torokhov To: Fuqian Huang Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 08/14] Input: elan_i2c - Replace devm_add_action() followed by failure action with devm_add_action_or_reset() Message-ID: <20190713085118.GB103820@dtor-ws> References: <20190708123332.11989-1-huangfq.daxian@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190708123332.11989-1-huangfq.daxian@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 08, 2019 at 08:33:32PM +0800, Fuqian Huang wrote: > devm_add_action_or_reset() is introduced as a helper function which > internally calls devm_add_action(). If devm_add_action() fails > then it will execute the action mentioned and return the error code. > This reduce source code size (avoid writing the action twice) > and reduce the likelyhood of bugs. > > Signed-off-by: Fuqian Huang > --- > drivers/input/mouse/elan_i2c_core.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c > index 420efaab3860..a8d4f3bd09bf 100644 > --- a/drivers/input/mouse/elan_i2c_core.c > +++ b/drivers/input/mouse/elan_i2c_core.c > @@ -1234,9 +1234,8 @@ static int elan_probe(struct i2c_client *client, > return error; > } > > - error = devm_add_action(dev, elan_remove_sysfs_groups, data); > + error = devm_add_action_or_reset(dev, elan_remove_sysfs_groups, data); Actually, the driver should use devm_device_add_groups() and then we do not need custom cleanup action, I posted a patch for that. > if (error) { > - elan_remove_sysfs_groups(data); > dev_err(dev, "Failed to add sysfs cleanup action: %d\n", > error); > return error; > -- > 2.11.0 > Thanks. -- Dmitry