Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2666146rdb; Mon, 4 Dec 2023 04:23:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVMBiVqmgwSxRJncsTu9AO+0eQQMxcuqDp9QhvxXt4oy5oV24q5mcOn38R0Ix/I7/EjAGL X-Received: by 2002:a05:6358:9106:b0:170:2cff:b57e with SMTP id q6-20020a056358910600b001702cffb57emr2106096rwq.28.1701692609817; Mon, 04 Dec 2023 04:23:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701692609; cv=none; d=google.com; s=arc-20160816; b=x+8INF8xqoSe8nMpMRKfuY9dxEIkzEscyN3T+f4TUfK3gkyOC8K4iYvz4hZsMOeY5m xrY8Yo25W5dHxggWrE5THaf1ZVwGG/oh+2ODIZKfjz0iexiPpOUn2ATnseL3Gl/fr9h+ fk6pk4UbKlG6OoP/dySQL9+MfblXvFJiqZCnpGnGEAMnfbt7uI4Tpl5HcrHn1kOSNLap RIdW2twxefYki0UMbY6lQ6jVy316B/FLzPYxg7FXhMBafrLoBoNj7EbCLLzFo0TmuyQN naFCk4AVzSwzl6GsVEGypGqaVXGhOWufer1wGDXqo3yBq9cfm/+acZZ56hsLhiHOJtq1 S2YA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=BULq1Q3RTJt4AtA3FAi8zSXugrw22FQu2FsKwBdAGII=; fh=zTMCn1ZD7i21SpaVENoR10gnESfmUYFhexKu2tybiYQ=; b=gxBGr6oCdyC2m0mDa62QaDpxUz1OaQLov8eOEH8yz4kfyDBnZIceM/WywskvlyVw/n 7/Gxs4yTeQcp0XvAyCpQH5k6xyX+RrFU6AIGNNx/aDGoEOpn5EMEavCzmQICdTikyw4N wkIzUm9xWwxPwmQhIXeWfTbA5lJFqUFI9Y/8uMnyvTw65PZFQgD3rQP5CGLNXhZVR1vL dsAcZvIygOKyQxOc1iU4CGvL4nFXMJi6yyfP286Y20yATv5iUcY0BRqdGkhc2F8cLhSB 8Pqa3b88jwb7H0xrgb1r6JB/Dsg76JJsyz2ltH0I4/bW75C5t+cnd11yEOtIsQLJVbWa 3pLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F0RqIcPP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id cn11-20020a056a020a8b00b005ac8d44bad4si2581829pgb.592.2023.12.04.04.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 04:23:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F0RqIcPP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 293CC80A733F; Mon, 4 Dec 2023 04:23:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233157AbjLDMXM (ORCPT + 99 others); Mon, 4 Dec 2023 07:23:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233128AbjLDMXL (ORCPT ); Mon, 4 Dec 2023 07:23:11 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6EC2100 for ; Mon, 4 Dec 2023 04:23:17 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 251FAC433C8; Mon, 4 Dec 2023 12:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701692597; bh=VoegbZtlGEE+YOCixMcNCzHVYsgNLyvCC0B36pZHRl4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=F0RqIcPPKLUl064QkUhYGTS9EllbUb9s6eU+USIgBLOvyxCtNRBIbTV5bYKdX+52W kV6+xp4A4VeL9nN8uI8oobmhex+sWPpciLjJ9tXFIYbroCUkzIeQ+kro1KPTRF5IR+ 6d7SFCVZSSPiUGcCx3awIbGpFF5Tj7f72+vbArRj2K90M/nudyszGg4lOF15EAXCnj xAqOkrMrx4ErtkEvdTwr1Ge2duUNPsUK7bSlp6qj3IpL84Or3pDZpyFeld9jniqJ4q GWqpOB9i4UDFmJ/LfyGCTYiopptkhOuasnoSibCk8lPop7Pic/DV510ylmbDaPWYCH ob+qIrUbla9Vw== Date: Mon, 4 Dec 2023 12:23:09 +0000 From: Jonathan Cameron To: Marcus Folkesson Cc: Kent Gustavsson , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] iio: adc: mcp3911: simplify code with guard macro Message-ID: <20231204122309.4b1b6de7@jic23-huawei> In-Reply-To: <20231127-mcp3911-guard-v2-1-9462630dca1e@gmail.com> References: <20231127-mcp3911-guard-v2-1-9462630dca1e@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 04:23:27 -0800 (PST) On Mon, 27 Nov 2023 08:38:22 +0100 Marcus Folkesson wrote: > Use the guard(mutex) macro for handle mutex lock/unlocks. > > Signed-off-by: Marcus Folkesson Oddly this doesn't apply. Also some comments inline. > --- > Changes in v2: > - Return directly instead of goto label > - Link to v1: https://lore.kernel.org/r/20231125-mcp3911-guard-v1-1-2748d16a3f3f@gmail.com > --- > drivers/iio/adc/mcp3911.c | 27 ++++++++++----------------- > 1 file changed, 10 insertions(+), 17 deletions(-) > > diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c > index 974c5bd923a6..30836725ef9a 100644 > --- a/drivers/iio/adc/mcp3911.c > +++ b/drivers/iio/adc/mcp3911.c > @@ -7,6 +7,7 @@ > */ > #include > #include > +#include > #include > #include > #include > @@ -168,13 +169,13 @@ static int mcp3911_read_raw(struct iio_dev *indio_dev, > struct mcp3911 *adc = iio_priv(indio_dev); > int ret = -EINVAL; > > - mutex_lock(&adc->lock); > + guard(mutex)(&adc->lock); > switch (mask) { > case IIO_CHAN_INFO_RAW: > ret = mcp3911_read(adc, > MCP3911_CHANNEL(channel->channel), val, 3); > if (ret) > - goto out; > + return ret; > > *val = sign_extend32(*val, 23); This should go further. Return early in the good paths as well return IIO_VAL_INT; a few lines later than this.