Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3491265pxb; Mon, 4 Apr 2022 18:41:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw49YBYXVjbLaX1N1sctrjMcu3bAj5xPsoaxqnk1ADNM3KU+fdMHKuNaP+CwavE92HyXhPB X-Received: by 2002:a17:903:246:b0:153:857c:a1f6 with SMTP id j6-20020a170903024600b00153857ca1f6mr897612plh.153.1649122871733; Mon, 04 Apr 2022 18:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649122871; cv=none; d=google.com; s=arc-20160816; b=fmvTV4cYAXKEiBgwtgUriPHL9/rq88qFnTuqVyje+V8ffRtcV77sRnp7xlcRcrkmv0 KW+qGCkFHGyWJIoBZrwlESiuLflRm4mE2GgmVFPJFVft9s67NUFx4JOBTJpR3b47J0SO Kmaca7azQDLe8n706yUxGdn5FIp4a/T9oRUq+X7UHQ5Xz4yAdBXT3kJ3yVObtZsfQf6M RTpWFmyQQ2q5x1lc5Qxm+TYBth1j0zBWrz2+bMRVX1Qt0V646emfsQVjdOOd9JwHA1fO oe3xQRmVRKs10xO0xTXSv8CzviQW4QK+aI97rw29NBEgLcgWpji/805TYj84juEFqzYe Dj5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Gwff2ScMyduRFsgNLSOrbaYErL2LHR4WqzSPtFakqCI=; b=gEUVPDTgvIeDn0tyVXDl5TO473ss4XX8cntxoYZ+2w5nbl30eSFwh4/RIG0wjVvMtG IJn8THR8BmxuWVy0gdbvoLiSVn/tN/AX/M4tnfBK3rnsEE5oMATwa/J9yb8ufovk7akF hyccBdu8ayT5UsAkZA50lVhA2va6xWH0I/THsAkOD4tmDpmdC3uMeE6mKidSW/rtx1au nZ0+9koYtwmnvwttYS/yIaQNNkKf/G1v7zG/Uuid1bSEcz7ZCNSqylkV5N5xvq04w74n a4qUSXBhITvfTnZjoWjyFYe0k87zOVnkXNqIQqHMEmMDAo58bpwPBnYGdGeF9Oo0I6Ka M1JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=E4dRxHk3; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 67-20020a630846000000b003816043ee71si12581510pgi.102.2022.04.04.18.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:41:11 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=E4dRxHk3; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C15FD269A53; Mon, 4 Apr 2022 17:36:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242755AbiCaXJG (ORCPT + 99 others); Thu, 31 Mar 2022 19:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242262AbiCaXJF (ORCPT ); Thu, 31 Mar 2022 19:09:05 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6F05241A13; Thu, 31 Mar 2022 16:07:17 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id g22so1018459edz.2; Thu, 31 Mar 2022 16:07:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Gwff2ScMyduRFsgNLSOrbaYErL2LHR4WqzSPtFakqCI=; b=E4dRxHk3X5Xz6uhDp52u6jrJvE/XjTHOkNGNPYHzoNyNyghBE6nTVogfQ8NX+WJRF+ t250rCKrgxpbGxzg+KY3hCGGnyGjZW2o0WU8L5QRafo1cSwGkkZG2NmusPL+7kFSM836 8mgGNyoSS3NL003Il3/2o6f6brvr7F5JEWStaxaRFe/ZPx1dPwTy/JQiJAQutw9xJoYp EBB5mHEYQvZ6GtHlE1eU3j7oIMutmWsUCelULppAPxeHaaErMOhmabxp1MtFlGFzehh9 akogZ7C7SNqduYGp7+ECJcENz8e8I/rXSycU1PohiljVQPp/hwv8AKQelfnjOx5bKHdb Vk8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Gwff2ScMyduRFsgNLSOrbaYErL2LHR4WqzSPtFakqCI=; b=D2DHqVMHqq3oWjQCXrFjey82bZusKAc4DjlO3+tgUBZm+vN8qRwHnh4qZXg4kCodVL VpNrV+QpDcRCtFW3F0+GZZwJYBAg0d449cnCwcYXmjESQN0qs1Gx3P6wj+1iKxPXgqm7 3AOwh49tND5PdJjOKYQSQhFz5OnyY+JUhc3vf4OdOXYNLxxS+BHYB3KrXOzE0wU49IIv PqmGCGdCUUPtzzlhl1XN1YHtGy6VcFez+jCWMWDvoRnFDXEyD7WUlMbMKVX6l8DDWqJt FUUlCWwVDvBrFgKxpNzRWJifJbhkUvtR7QgX05HxCq3XtySo3vgL1Vh5qX4+kPgtYc6H bPRw== X-Gm-Message-State: AOAM530cTS2cv+ksk1hmeIBLGtdb6yRvwrk8gKocb9sy1vpdyJiG/qbC 4Azle9G1l7/mWbH9l4j/ujo= X-Received: by 2002:a05:6402:2219:b0:418:ed4e:f999 with SMTP id cq25-20020a056402221900b00418ed4ef999mr18450252edb.121.1648768036169; Thu, 31 Mar 2022 16:07:16 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id p12-20020a17090635cc00b006e055c9c91esm297131ejb.101.2022.03.31.16.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 16:07:15 -0700 (PDT) From: Jakob Koschel To: Jonathan Cameron Cc: Lars-Peter Clausen , Dan Carpenter , Jakob Koschel , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH 1/3] iio: buffer: remove usage of list iterator variable for list_for_each_entry_continue_reverse() Date: Fri, 1 Apr 2022 01:06:30 +0200 Message-Id: <20220331230632.957634-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to limit the scope of the list iterator variable to the list traversal loop, use a dedicated pointer to iterate through the list [1]. Since that variable should not be used past the loop iteration, a separate variable is used to 'remember the current location within the loop'. To either continue iterating from that position or start a new iteration (if the previous iteration was complete) list_prepare_entry() is used. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- drivers/iio/industrialio-buffer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 208b5193c621..151a77c2affd 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -1059,7 +1059,7 @@ static int iio_enable_buffers(struct iio_dev *indio_dev, struct iio_device_config *config) { struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); - struct iio_buffer *buffer; + struct iio_buffer *buffer, *tmp = NULL; int ret; indio_dev->active_scan_mask = config->scan_mask; @@ -1097,8 +1097,10 @@ static int iio_enable_buffers(struct iio_dev *indio_dev, list_for_each_entry(buffer, &iio_dev_opaque->buffer_list, buffer_list) { ret = iio_buffer_enable(buffer, indio_dev); - if (ret) + if (ret) { + tmp = buffer; goto err_disable_buffers; + } } if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) { @@ -1125,6 +1127,7 @@ static int iio_enable_buffers(struct iio_dev *indio_dev, indio_dev->pollfunc); } err_disable_buffers: + buffer = list_prepare_entry(tmp, &iio_dev_opaque->buffer_list, buffer_list); list_for_each_entry_continue_reverse(buffer, &iio_dev_opaque->buffer_list, buffer_list) iio_buffer_disable(buffer, indio_dev); base-commit: f82da161ea75dc4db21b2499e4b1facd36dab275 -- 2.25.1