Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1402567pxj; Fri, 21 May 2021 13:23:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfHrEz4ODxU8yw7Mf03jdpRVaiBLuB7gkWuOprJpx3l4Tl97mKmXOM1WjHQ86T9wGljUxE X-Received: by 2002:a92:c52d:: with SMTP id m13mr532422ili.191.1621628595033; Fri, 21 May 2021 13:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621628595; cv=none; d=google.com; s=arc-20160816; b=dRGMtk2gbPsny3ypy6DewhvnXLxMYOvnyjsAZmb7l+q3B1ZS1IN0yH+g1EWbhbK//m cD4ep4wRAoz66rdCT5Hqw0IY2CJRWY5J/MHCb4FLdF10o6o7W4WOx0WZi72nAVpQFzvy xSfizK19xXwuPcNcTDsimIHXFLdXAaS2rnQC4QweTUK4hD+eZg+GZkclbTGH4XGtUdB4 PHIhoJ4qxtoZ1W6SUyo4m1O1/pTdwALhz0nSob7ymtGoFuN/HwoZFlSxn74rUdg7V5LM xhI/+LYPWv7xnt2HUwsan18JQ2WIYAsc85E3khUZ1+FGAtkB3qiUyq4D+gVZjGT+K0eB Fcvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=1dOqFSSZPpQ9Fgo3UhWdWkVJF/jVeCSjCFheVI4a2ik=; b=Qs3Ctv7+KxkIvhBS6XP2cs86ET7EZxvEAE3pKfIa3I0F3PSiTmq1rLDEUlVb++jJhM ms1+1IfVmcDUQzMeY/GM1ytFvt8ZIc2HOGFojS5k79OY2nebrGdxWeo6iLAe/nlfWOpC 5gfWvPCPIyamTdhAbJ6ru+SgJVuWmNN9qbRt40edX7AZSb/gLdvXB7FpOvHj+CxjYSfz 0sDzSmIETl2YMK4ZJguInpA0claKYGi8LaI4BkhYZpZ8ISFys/27TBXZdxoMEhhEhMP+ j28lrnbpOVcNKfH/qKiSIjtPFwQVGyRq/0sYQv7Q8p7SIY6Xfha8QhsHzttGSzCefRNC vuRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=RoTVA2Ng; 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 e25si6127523iol.49.2021.05.21.13.23.02; Fri, 21 May 2021 13:23:15 -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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=RoTVA2Ng; 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 S235810AbhEUQh1 (ORCPT + 99 others); Fri, 21 May 2021 12:37:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236590AbhEUQh0 (ORCPT ); Fri, 21 May 2021 12:37:26 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17648C0613CE for ; Fri, 21 May 2021 09:36:02 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id d14so20330918ybe.3 for ; Fri, 21 May 2021 09:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1dOqFSSZPpQ9Fgo3UhWdWkVJF/jVeCSjCFheVI4a2ik=; b=RoTVA2NgHUbxRJhBJ/luJ49b3as6mCmRsiOebUYm7u0Af1Dv4jYhCFuxRUolVEHw5k Rh/Hm5ZrO40SNvD0NOyzH7CNaLyrCAjFz1XR+jT5yQajxGx61DlJIX3hlc1Kjl/Vduw8 zSM2qx65ETxEx6K6IrATwctFyiuiB7zv5ZHqvrdCPjYLG/cVnHMbCFi/wW59xMkp3P18 kcfDMAF7VXuyXLUOE4e5E76wvPsWKP2M+YVKBX0mr5GwHoFdQRJ+FPfMc700uBzIK+Bd F/MvTVIke6bfpVCwcMli5uF5HEY99M7WI09Ov33IjJztIYA4lH6ke2vhSvJUBIlEkrWg wm3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1dOqFSSZPpQ9Fgo3UhWdWkVJF/jVeCSjCFheVI4a2ik=; b=ZSAbVeSPBA6DE+l019QkiYoyJTeKd+6m+8AhVfeLadGy9loW8Y84S8nPz/3cwH6we0 VGE0bY6hhJlIAYw1VrI7/0YYDcNtVaOkRUmJON0j0mpak5qzMSlY35aUDL5ecns/zI5p qmobPqhSeLAA/gwsBqDnB/C7pmpXafcuRZ7ibusmuxhdiD9/HV7admuVJyQyV/0uCVoL MfqAZ5/SrKzIDsM+e5/m1kYaSmNXdv1yCf7q3EjWTGn1d+5rjjjRCaJm/2k4+FoOoqqb +L4F10jcZ6t/VwrSHtmdu+TRnJuk9wc7VKBv1dYoLzBOPzwWqMaNwyWR10hOXuDf2h6f ULTw== X-Gm-Message-State: AOAM533mSF+B28D0n9f4rRPewsm4/xoB/bUL794FmDJzliavGJqvKlBk c3YrskibFHmeJz2YUT9QMWQ+GQYkvv/nDP/FLBRWCA== X-Received: by 2002:a25:287:: with SMTP id 129mr16144124ybc.312.1621614961384; Fri, 21 May 2021 09:36:01 -0700 (PDT) MIME-Version: 1.0 References: <12bb40f022be0378ed493e7ad33122b0@walle.cc> <87a6ooh46s.fsf@miraculix.mork.no> In-Reply-To: From: Bartosz Golaszewski Date: Fri, 21 May 2021 18:35:50 +0200 Message-ID: Subject: Re: [PATCH v2 2/3] gpio: gpio-regmap: Use devm_add_action() To: "Vaittinen, Matti" Cc: "michael@walle.cc" , "bjorn@mork.no" , linux-power , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linus.walleij@linaro.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 21, 2021 at 12:31 PM Vaittinen, Matti wrote: > > > On Fri, 2021-05-21 at 10:38 +0200, Bj=C3=B8rn Mork wrote: > > Michael Walle writes: > > > > > Am 2021-05-21 08:28, schrieb Matti Vaittinen: > > > > Slightly simplify the devm_gpio_regmap_register() by using the > > > > devm_add_action(). > > > > > > Hm, nice, but what bothers me a bit is that no other subsystem > > > does it that way, eg. hwmon/hwmon.c or watchdog/watchdog_core.c. > > > They also store just one pointer, thus could be simplified in the > > > same way. What I don't know is if devm_add_action() was intended > > > to be used this way. So I can't say much for this patch ;) > > > > There are some examples. Like: > > > > int devm_i2c_add_adapter(struct device *dev, struct i2c_adapter > > *adapter) > > { > > int ret; > > > > ret =3D i2c_add_adapter(adapter); > > if (ret) > > return ret; > > > > return devm_add_action_or_reset(dev, devm_i2c_del_adapter, > > adapter); > > } > > > > > > You should probably use the devm_add_action_or_reset() wrapper here > > too, > > catching the unlikely devm_add_action() alloc failure. > > > > I was thinking of it but as the gpio registration succeeded I was > thinking that we could go on with it - (which means we can proceed but > the gpio is never released.) > > I am not sure how much difference it makes in the case of small alloc > failure ;) > > But as it seems I am in any case re-spinning this I can change this to > the devm_add_action_or_reset() and fail the gpio_regmap registration if > alloc fails. > > Best Regards > Matti Vaittinen Hi Matti, Please use the reset variant. We always want to roll-back the changes done in a function before the failure and propagate the error code. Bart