From nobody Thu Dec 18 01:49:24 2025 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46F8F1E4106 for ; Tue, 11 Feb 2025 09:30:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739266260; cv=none; b=lthCuh7udBtwLczsX0U7NFNHRzj1ROV/qpAK7G4y+Njbbfrocs+zd0+6MWk0uuIvYlfn63P3TRlnjshBcmLzpzes5Q1mzQuPmFL9h73/0MGKDPpiK22aT5N7CIZpE2gfQPIA/nt6KTlVP3XiaZtuJz1it2V4jnMP/po1pa8nh6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739266260; c=relaxed/simple; bh=yHR7fmZ2/v4fPjI6lJk75oX1K0Ixzxl2HWQK1pCqNbs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Rqo9ZaP1YMeLLph2BdFt+yCvJizyySP4G8kUTmEqWmyaFi88WD5zi8wQjom/YZAjstyukywKPFluNIHKiHOswtrN+v/zTYb/MIVnSEk6MMOgy4c5EY0Rmvi0tW7WTu9T93u3t993zVxdJZlcMDqTtAxEKuvoX1S+39lCirCkM7c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=bnRyVbHw; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bnRyVbHw" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4394a823036so12592035e9.0 for ; Tue, 11 Feb 2025 01:30:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739266256; x=1739871056; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yExLMLYCeWgfPAg8dv/C3ycaxjv+o/aMZg2SZJq4U/c=; b=bnRyVbHwVOkTyOrrx9/86MX5gbpUdsS9WoXKWqV9O/Jri40ReZkIRcFB/gjHCTqRXU N8ptfmyJpUj9gWAD1bgBeHS9MEajbnlvGs+Vdeh84pcj05O6+f5jUfPlHCbbqKMXW1+Q ophOz8b8A5Xc7RspEG3y5B501fuyExfxMY75F2fbSpJ4KywgqCt2IR23NB+VvmNcGCoc w5vx5buNW86efpohEJYm/XqA5U1Rx4aeRhv9+nrTO4GKK9GfEyl8+z8AVuKgKlx0lLhJ n9VR8vaYIH798CEEgFrGCRX0NyC4CVGSaHzfCFO0PrFOmmBUcEQx56yf0jt9Zn9tKQAe msCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739266256; x=1739871056; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yExLMLYCeWgfPAg8dv/C3ycaxjv+o/aMZg2SZJq4U/c=; b=Ga+HST6qdRNI4FJWx3tv/XdLVWoxs/DdxEvhdjYUBAPPehUHNLDjNc3qnSoVFw4NSI l9wOUkPyYsXEaO9CRH7l8MvyAfx/i95gg8QGM8mhw7ZsMSCKRQQ4d/12kbAeih4cdn63 be/s4UER+tjpl84xWQl8+BihGdoADg0t8nJ2mH6K2Z/VEIEXki9b/4i5r43QfQ4MiMFO We3T/orDM7b8qOpg+csxxxPiTR5sky41SeNEiTEeHkGCX40YLkrmaal3AOB19pSJLqZY 0WegIJSTIDgU0zqApejkTtqXabFHLXlveV/+8+ZStOncIW975OdH2t5u9nVbOQSN9jey H6mg== X-Forwarded-Encrypted: i=1; AJvYcCUhVzGT28PaQ25r6732SRkAocmO8OvL0ouLxlHUO5CYD8C+kbgnVEAn3iQ/Y8Ulj8V/Cn/2Qxt+Rxjytg4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1wOgxpZZ58hCUdyh5OmaE+ndCDpj2YsILbAidqJyxnUobb+oz TbWMRr6jHKHGcpuDF0roAOdo5J+jL16pA1tIlB9h5zdrCjsxtZM5Zq3DbnjCiak= X-Gm-Gg: ASbGnct5XThjjN3D5dt3o820ELWpvyOViOknqVEFUyJUWdSq/fCZruLGCfL9convTaw YQ4b+ZAx9UZY3EXMIfQYBvKMslH2nsJPKdJDNRa+b+d6E48UBERsa5L1cfQVn2XGKYNxhFbvn0r +1EwGHSi2hRg2mYMEMuwemufRIC1I5xSDugs8CjXI1IvFp66bOIFUNGHyBnkDy0k9Tq0mZ7j5TE RvdkQbYrsUAkvFeOVWsCefhI1ZN0sxfD4aGVkTU4uMXWC+juoWdiQYz4pQ3sYqV8uFDtDXFtc0K Tt+TmWuFatjBzdUMT+rCj1B5KZ9KuEMsq4IvwuR4uG/hjmK0RcTq3fxM59KJsWuESd7nui8= X-Google-Smtp-Source: AGHT+IGnPHCTuUJLNxNW+8FrO/x/ilNOPLhSCK9CbmM8yRSZ+1JxBJpmZu1Hul9+oawgshMY1YBAVA== X-Received: by 2002:a5d:47a6:0:b0:38d:d6cc:a6e1 with SMTP id ffacd0b85a97d-38dd6ccae82mr9537099f8f.28.1739266256526; Tue, 11 Feb 2025 01:30:56 -0800 (PST) Received: from ta2.c.googlers.com (169.178.77.34.bc.googleusercontent.com. [34.77.178.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dc672b55bsm12591296f8f.79.2025.02.11.01.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 01:30:55 -0800 (PST) From: Tudor Ambarus Date: Tue, 11 Feb 2025 09:30:53 +0000 Subject: [PATCH 1/2] mtd: spi-nor: sort headers alphabetically Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250211-spi-nor-guard-mutex-v1-1-05ed77a484d9@linaro.org> References: <20250211-spi-nor-guard-mutex-v1-0-05ed77a484d9@linaro.org> In-Reply-To: <20250211-spi-nor-guard-mutex-v1-0-05ed77a484d9@linaro.org> To: Pratyush Yadav , Michael Walle , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Tudor Ambarus X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739266254; l=819; i=tudor.ambarus@linaro.org; s=20241212; h=from:subject:message-id; bh=yHR7fmZ2/v4fPjI6lJk75oX1K0Ixzxl2HWQK1pCqNbs=; b=jRD2FuvxlKXrQY2PB6zLOHVnD7bkUrVQk6+dxMacV2L7fyr3pJ5CDh56ppe6qZw39nYoSxGuU B/oagtN2SJQBw2LdBeBzYRUbvHEw7kAGJ1smKNeFa9YSax+xqeXCFKp X-Developer-Key: i=tudor.ambarus@linaro.org; a=ed25519; pk=uQzE0NXo3dIjeowMTOPCpIiPHEz12IA/MbyzrZVh9WI= Sorting headers alphabetically helps locating duplicates, and makes it easier to figure out where to insert new headers. Signed-off-by: Tudor Ambarus Reviewed-by: Pratyush Yadav --- drivers/mtd/spi-nor/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 19eb98bd6821..1bb4a500be6e 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -7,10 +7,10 @@ * Copyright (C) 2014, Freescale Semiconductor, Inc. */ =20 -#include -#include #include #include +#include +#include #include #include #include --=20 2.48.1.502.g6dc24dfdaf-goog From nobody Thu Dec 18 01:49:24 2025 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A57961F03F2 for ; Tue, 11 Feb 2025 09:30:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739266261; cv=none; b=bIvacFZRzkxF6x+UpcMLa9OEeV+77C/mrq1Oa5Hr1NWhdaIulwfWX7GvVWu4JbrNVT4MnkHmENSlmMRJe+EaeoH0mc5y+4CLWuvSmTUE+R2cWBKAiTK+zTLePwmEFaglkE/bOZUq7yq+WixFLpnksszn0Y4M5pQGwvuhiGffot0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739266261; c=relaxed/simple; bh=A/I48PbBb5I5iIc6Shl7ozap+VkugdClZDkBLg/W4xs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UgzIn6CDDaiHFcUXVLUgn/hb3ODUiI1Tk6cLQjfy+vJz8DkH8vHQnOI0vdhCQeF5bGlaScfOO8qsb56QGxBd4eAhc6BzcRKFU/I65Ym3Rdoq3mrTXVQ3nb8i48jl78Y74YRetoRoF4Uqf2wyOxwYEjZwJtaUA4lM7W+P+UW83ts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=maZWnNaa; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="maZWnNaa" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-38dc5b8ed86so2249004f8f.1 for ; Tue, 11 Feb 2025 01:30:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739266258; x=1739871058; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8GF075tACuMVMVh8PNKT0nRFACsnr6kvsDOiw0epdSs=; b=maZWnNaaEaLZshsyOEyl9lTSgdoaKdOWmW9cZIB1VNcPq4qWtFmwwLocWEuIbYufdB NZ0MgxaeLYfhJSn2OuENObg68VAandSxjvb38OcS/iZKEpSXXfkiK959ntgpYTPIKq6s rxEDwkWOCj+wjm9MRx4o0C5wIFrnrC7Qoc4bU179D37xOiL3CgNeY3pEKQgaca6ZSVDZ p/o6ENiOcVgz+zQ3/hxLuWY9IpFrFE7ZnBnEK1IuQwWkQAtOKzUaSlyjWFJgxr988+0a vmRTIWgFbQwD0azCgxsSk4xnKtiVqrG/0/M59nF4TKL1baTQb8WApiReue7IyH7f96rO ejUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739266258; x=1739871058; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8GF075tACuMVMVh8PNKT0nRFACsnr6kvsDOiw0epdSs=; b=lyLFIexNRNYlVrizIMqR9Xb0+5EnHtiD6IN6XWlgFYCfI4pxaj5P1TYsEZJ4ZAPxsB CgGTy5qzmK5IBbyTvcEVYdlUAvHCgYhogQIbvSnfaqgtfrGVPLfVp6BSes4T1ck6eQO5 Zh+KSLwXdKfd6ICx8ncSsXf47u3aDc9bflVAblIRI7KhA8WWWzKIe5V0Xo9KpeWucWlY f6dqGvZU9vYOeHZyNYmiwc0DmR2mMPegSx8LD9FJGN471WiHiCgxskpOFDw59tDEqSUr EknWU9LQid4F8bjpnglLXwayqgbqxz++/slwW2NPf+gRj50Wrvzc7dhbvncwS2qyUgIM oDPg== X-Forwarded-Encrypted: i=1; AJvYcCWpjRtQ3eR80MRcLRbO9GGyFTaLrukAgWegpcz++wLEvdiror3ngiqdBBi5e4EXdr8NKP5veEZK/I/MIVg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3BQAx2Axyj2eOMZI5R9hc/Us3adRy7B0XT2cDGjEJlv14bOHX vzf2Ua+BjoicLZxh0xygYSOYnn1HCoVspAN+zKQ15PwQrh0ycPJOGuP4EvQvi4E= X-Gm-Gg: ASbGncu5Mn+B5BxHj+lT97jNZzJT2wIRJw8gjmeLlJP1evnYDGIYSgYy//CxOxwu4Gu 1BdJWJxXdt6LI9j1xv5EGQz0YfnoHIRcnhbd9d6zbiT+v7Ymv4pCfU12f+uMfQ9fw7AlBgBCzWy t+VZNzfXwqHBiH8feFGDOsb6x3DipalcGVBBxAd/TX0sh6mmruZdwuVd1OHVU6a/KqBS6acmSEd brXO0FPdQ/wTRXl2ycDy0XDmK/zBpCuSUqhQt3NC3rkamXDlgwfh+b3KwceTgX6+LiElPvLsAB+ zYSixcmSYKxEamSo+l5y9HZpu2Al9318ax4n91Pi5Sy+4I4pmbJ96yhyRZqUgf3goQnFiOw= X-Google-Smtp-Source: AGHT+IFiydCLeAvyEeW/5ArSvXalUmxlAwauB30Q787ws04Fjnw5BBYoJGg7Bc0g2UUutEuxX4DAng== X-Received: by 2002:a05:6000:1887:b0:38c:5fbf:10d6 with SMTP id ffacd0b85a97d-38de416d65dmr2356745f8f.7.1739266257863; Tue, 11 Feb 2025 01:30:57 -0800 (PST) Received: from ta2.c.googlers.com (169.178.77.34.bc.googleusercontent.com. [34.77.178.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dc672b55bsm12591296f8f.79.2025.02.11.01.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 01:30:56 -0800 (PST) From: Tudor Ambarus Date: Tue, 11 Feb 2025 09:30:54 +0000 Subject: [PATCH 2/2] mtd: spi-nor: use scope-based mutex cleanup helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250211-spi-nor-guard-mutex-v1-2-05ed77a484d9@linaro.org> References: <20250211-spi-nor-guard-mutex-v1-0-05ed77a484d9@linaro.org> In-Reply-To: <20250211-spi-nor-guard-mutex-v1-0-05ed77a484d9@linaro.org> To: Pratyush Yadav , Michael Walle , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Tudor Ambarus X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739266254; l=6004; i=tudor.ambarus@linaro.org; s=20241212; h=from:subject:message-id; bh=A/I48PbBb5I5iIc6Shl7ozap+VkugdClZDkBLg/W4xs=; b=M8SYru7/AL6WclLtCUHLw2NOZOMXHyS08tR6ubyxEcEb+BuFrMRefWlULpzaP4icIWZlwbluz Z0nLiWyXXYAAfj2CzZNJEmKOJEt+NYyUUIHjJluJ3o+nPlpEuQBlDMX X-Developer-Key: i=tudor.ambarus@linaro.org; a=ed25519; pk=uQzE0NXo3dIjeowMTOPCpIiPHEz12IA/MbyzrZVh9WI= Use scope-based mutex clenup helpers, it reduces the code size. Signed-off-by: Tudor Ambarus Reviewed-by: Pratyush Yadav --- drivers/mtd/spi-nor/core.c | 71 ++++++++++++++----------------------------= ---- 1 file changed, 22 insertions(+), 49 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 1bb4a500be6e..c9b970f35c6b 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -7,6 +7,7 @@ * Copyright (C) 2014, Freescale Semiconductor, Inc. */ =20 +#include #include #include #include @@ -639,32 +640,26 @@ static bool spi_nor_use_parallel_locking(struct spi_n= or *nor) static int spi_nor_rww_start_rdst(struct spi_nor *nor) { struct spi_nor_rww *rww =3D &nor->rww; - int ret =3D -EAGAIN; =20 - mutex_lock(&nor->lock); + guard(mutex)(&nor->lock); =20 if (rww->ongoing_io || rww->ongoing_rd) - goto busy; + return -EAGAIN; =20 rww->ongoing_io =3D true; rww->ongoing_rd =3D true; - ret =3D 0; =20 -busy: - mutex_unlock(&nor->lock); - return ret; + return 0; } =20 static void spi_nor_rww_end_rdst(struct spi_nor *nor) { struct spi_nor_rww *rww =3D &nor->rww; =20 - mutex_lock(&nor->lock); + guard(mutex)(&nor->lock); =20 rww->ongoing_io =3D false; rww->ongoing_rd =3D false; - - mutex_unlock(&nor->lock); } =20 static int spi_nor_lock_rdst(struct spi_nor *nor) @@ -1212,26 +1207,21 @@ static void spi_nor_offset_to_banks(u64 bank_size, = loff_t start, size_t len, static bool spi_nor_rww_start_io(struct spi_nor *nor) { struct spi_nor_rww *rww =3D &nor->rww; - bool start =3D false; =20 - mutex_lock(&nor->lock); + guard(mutex)(&nor->lock); =20 if (rww->ongoing_io) - goto busy; + return false; =20 rww->ongoing_io =3D true; - start =3D true; =20 -busy: - mutex_unlock(&nor->lock); - return start; + return true; } =20 static void spi_nor_rww_end_io(struct spi_nor *nor) { - mutex_lock(&nor->lock); + guard(mutex)(&nor->lock); nor->rww.ongoing_io =3D false; - mutex_unlock(&nor->lock); } =20 static int spi_nor_lock_device(struct spi_nor *nor) @@ -1254,32 +1244,27 @@ static void spi_nor_unlock_device(struct spi_nor *n= or) static bool spi_nor_rww_start_exclusive(struct spi_nor *nor) { struct spi_nor_rww *rww =3D &nor->rww; - bool start =3D false; =20 mutex_lock(&nor->lock); =20 if (rww->ongoing_io || rww->ongoing_rd || rww->ongoing_pe) - goto busy; + return false; =20 rww->ongoing_io =3D true; rww->ongoing_rd =3D true; rww->ongoing_pe =3D true; - start =3D true; =20 -busy: - mutex_unlock(&nor->lock); - return start; + return true; } =20 static void spi_nor_rww_end_exclusive(struct spi_nor *nor) { struct spi_nor_rww *rww =3D &nor->rww; =20 - mutex_lock(&nor->lock); + guard(mutex)(&nor->lock); rww->ongoing_io =3D false; rww->ongoing_rd =3D false; rww->ongoing_pe =3D false; - mutex_unlock(&nor->lock); } =20 int spi_nor_prep_and_lock(struct spi_nor *nor) @@ -1316,30 +1301,26 @@ static bool spi_nor_rww_start_pe(struct spi_nor *no= r, loff_t start, size_t len) { struct spi_nor_rww *rww =3D &nor->rww; unsigned int used_banks =3D 0; - bool started =3D false; u8 first, last; int bank; =20 - mutex_lock(&nor->lock); + guard(mutex)(&nor->lock); =20 if (rww->ongoing_io || rww->ongoing_rd || rww->ongoing_pe) - goto busy; + return false; =20 spi_nor_offset_to_banks(nor->params->bank_size, start, len, &first, &last= ); for (bank =3D first; bank <=3D last; bank++) { if (rww->used_banks & BIT(bank)) - goto busy; + return false; =20 used_banks |=3D BIT(bank); } =20 rww->used_banks |=3D used_banks; rww->ongoing_pe =3D true; - started =3D true; =20 -busy: - mutex_unlock(&nor->lock); - return started; + return true; } =20 static void spi_nor_rww_end_pe(struct spi_nor *nor, loff_t start, size_t l= en) @@ -1348,15 +1329,13 @@ static void spi_nor_rww_end_pe(struct spi_nor *nor,= loff_t start, size_t len) u8 first, last; int bank; =20 - mutex_lock(&nor->lock); + guard(mutex)(&nor->lock); =20 spi_nor_offset_to_banks(nor->params->bank_size, start, len, &first, &last= ); for (bank =3D first; bank <=3D last; bank++) rww->used_banks &=3D ~BIT(bank); =20 rww->ongoing_pe =3D false; - - mutex_unlock(&nor->lock); } =20 static int spi_nor_prep_and_lock_pe(struct spi_nor *nor, loff_t start, siz= e_t len) @@ -1393,19 +1372,18 @@ static bool spi_nor_rww_start_rd(struct spi_nor *no= r, loff_t start, size_t len) { struct spi_nor_rww *rww =3D &nor->rww; unsigned int used_banks =3D 0; - bool started =3D false; u8 first, last; int bank; =20 - mutex_lock(&nor->lock); + guard(mutex)(&nor->lock); =20 if (rww->ongoing_io || rww->ongoing_rd) - goto busy; + return false; =20 spi_nor_offset_to_banks(nor->params->bank_size, start, len, &first, &last= ); for (bank =3D first; bank <=3D last; bank++) { if (rww->used_banks & BIT(bank)) - goto busy; + return false; =20 used_banks |=3D BIT(bank); } @@ -1413,11 +1391,8 @@ static bool spi_nor_rww_start_rd(struct spi_nor *nor= , loff_t start, size_t len) rww->used_banks |=3D used_banks; rww->ongoing_io =3D true; rww->ongoing_rd =3D true; - started =3D true; =20 -busy: - mutex_unlock(&nor->lock); - return started; + return true; } =20 static void spi_nor_rww_end_rd(struct spi_nor *nor, loff_t start, size_t l= en) @@ -1426,7 +1401,7 @@ static void spi_nor_rww_end_rd(struct spi_nor *nor, l= off_t start, size_t len) u8 first, last; int bank; =20 - mutex_lock(&nor->lock); + guard(mutex)(&nor->lock); =20 spi_nor_offset_to_banks(nor->params->bank_size, start, len, &first, &last= ); for (bank =3D first; bank <=3D last; bank++) @@ -1434,8 +1409,6 @@ static void spi_nor_rww_end_rd(struct spi_nor *nor, l= off_t start, size_t len) =20 rww->ongoing_io =3D false; rww->ongoing_rd =3D false; - - mutex_unlock(&nor->lock); } =20 static int spi_nor_prep_and_lock_rd(struct spi_nor *nor, loff_t start, siz= e_t len) --=20 2.48.1.502.g6dc24dfdaf-goog