Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp143757lqh; Mon, 6 May 2024 14:11:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVI4Q9jUZC3WmNT5ccoGurpjckEhfEvoXBU45PzRAZ1V5flQQPyoP8IcS17zK0AAedtsN1d7Jn14CncU3nPvpP+vSnhNF+J3tcbNjXivQ== X-Google-Smtp-Source: AGHT+IEkjSNADWXx/kTzDgehw2RDnxxPE9Kxx4y9qx34fH6SVaLvo7Rqj+dJ9VQGc4uklE+hVKyq X-Received: by 2002:ad4:5c68:0:b0:6a0:5ad6:54f4 with SMTP id i8-20020ad45c68000000b006a05ad654f4mr16017128qvh.33.1715029870622; Mon, 06 May 2024 14:11:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715029870; cv=pass; d=google.com; s=arc-20160816; b=yXq0N93tWiLNzinu0R10K3d8HIju/FAYuhnFI5uOUL7CnGeIC0/vV9vs5yIx0MXKsi 7idOAExq3tl9/SZuI4vPGORi8kYnP1wa4xsX+co1oEZZFpqjGkS4QwEDuIHVIvsXt1/O X2oocKXyz18+oCzjAeK2aXMjvIg7c9Qel64iBxe4BQv+gEtfq/uQOtU4+KrBLeABVdxu wiNc1hfUmTpT2LriY2fmZ0xxFH/ZMswfN+R2ylk2bGrK2sn4Yd2p+ALD8FuzjOK2zQgk 7RKdbLuUu3MlQ3howRny+Stxvui7FY/bgPi/c+5YV0lxca1s8Dplm7jwQmoD04Pn87qC LjGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=OkJF7t/M3Ojeyh5RuyGpe29BYnbPsSXvxhXAxpUcSgA=; fh=9d9hWtqB3O1vacV/IcpQ960DopHIJXS/XWfkGJolJdc=; b=XruJ45nnCZ6Va8teEez4Bf2oj1wGV/Dc68nmz0zDfhX9Lt1vOM2sIY4izoINepj78u i4FSGbbT1ULG7V5wgt0bi5wQTLT/KLir6zlNDVnEU6hbuSDXezg9q1TCtDcPhnivGOoY AYy8z1KT4UUUDMH8kGScQfbMHBhVDKMPKDgaJG5WWDGkIlQ0KtyyssF0UzDS1XajdNRZ 5SccSQaYAB98JPXY6vWeT/x/XcjrcApu5y0HiyTF1M4S686vgKGs8nZ6S3e/hyqB59VB ZWYAVNfPmNgtaGFPcy9FLS0lJu4tQAhLtms7XuPNdVVYmpz6zUofMTrmCQAn8m2C+z6g qOZw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XwKYLAWH; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-170424-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170424-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 14-20020a05621420ce00b0069936512817si10014202qve.157.2024.05.06.14.11.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 14:11:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170424-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XwKYLAWH; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-170424-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170424-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 571F81C21007 for ; Mon, 6 May 2024 21:11:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6374C15D5C7; Mon, 6 May 2024 21:10:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XwKYLAWH" Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 11F1215B988 for ; Mon, 6 May 2024 21:10:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715029833; cv=none; b=ZdHl2UfxvPS8lUGQaAhnwbQ3wthteMhyS/Sjnt9GQvQE8Y6njv/90yy9nB1NADQnEqUjM+kZ5832bPEDkVUbb2DBIyKM7tk0iF+pc3VgcBJeiG1gxo/Z6qYaQGjRe/ZZ4KP//M9APtDYPkBZ37MwOa0oz9PtoKf6zLcnr22wto8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715029833; c=relaxed/simple; bh=13OxCCXFD0dQ5I30NApvqTwlwhaZmASYM9bf5Kr18JA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zm7wcSShJYGG7/QfMGDiBlV30vxAiu5FBZwmHU1wdes9H7wsstYVuL37If4jnVohtIyjqZSA1yJXKBnBtHUtGYZH/O6P95tE0leaq3sCf5gMns1ghRVdkKIdz46sYyl/zch7E/fjYjtgTaLooAX9Mvsw83+Sl7lMH/jGlGIdmdg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=XwKYLAWH; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7928c54e945so208432485a.2 for ; Mon, 06 May 2024 14:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1715029831; x=1715634631; 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=OkJF7t/M3Ojeyh5RuyGpe29BYnbPsSXvxhXAxpUcSgA=; b=XwKYLAWHKeesNbtDBek7g9IS4gFMiv9eI9W2VBr5egHx5PloHV7HSKt4OlzddnYsH+ QBZeHbgd3jXjI7ickZ4evj85OGAlPcfdzHoNL7sBJoAjJ4SBBGUpEK7BMIMjZrP1A7Gd x8GnPM9FZaD0w/uVfEWgbMbcgZvuNDCI25M8M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715029831; x=1715634631; 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=OkJF7t/M3Ojeyh5RuyGpe29BYnbPsSXvxhXAxpUcSgA=; b=KHzCNV1T4oXmxB7eqshGftd+8MhSa12vF2fU1XsKC/txWYiaQgKh/wocstd8gXFZ+7 hSvVWcQOEzel49gz4ceMxGn/Kvd0W4mqsYPxJmxnc3D+jjoJ9mAEAeRittCmDB/HlSiB J79fWHVAiqaCaFwEZwZ7nJR8PcYIYFo3KWT4NojCM2YcGi1goLxCkjSOia0bxpVWnRkJ gaHmDcw2qO3S7ydZnRCwlTYG4pxcH9VsxBeghOtPMBz+o+ki5GHaoG+Gmr4LxSih3GA/ X2BxgeLgwASvVDo68hEIXpsjYfh+musMlj41eFt8TRrRNsSLY8TnGf/PgIRrhM6FH/76 mm5A== X-Forwarded-Encrypted: i=1; AJvYcCWGEMmitOWeVkO5Smm/huzSKJvxvrrzvf1ze+yrFGrh5ocv6ej0slHgQQ/aw1H0sy77DJmLEn2eKInUZWeEV7RXqkPRKOB1GJ5y3yDo X-Gm-Message-State: AOJu0YwdCHaDpWykeZxH2wYkxZdUx7L2CAfyR1PXcJYEolskgBOXr2eP CsH520O2Fb7HP/S9qnGRenAAbwGwVp6A1MBNthFytoYAmRmUHNlrnY0iDcS32w== X-Received: by 2002:a05:620a:2481:b0:792:8c4c:375c with SMTP id i1-20020a05620a248100b007928c4c375cmr9980404qkn.11.1715029830998; Mon, 06 May 2024 14:10:30 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id pa20-20020a05620a831400b0078f13e59dc9sm4224921qkn.102.2024.05.06.14.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 14:10:30 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 06 May 2024 21:10:28 +0000 Subject: [PATCH 3/5] media: dvb-frontends/stv090x: Refactor tuner_i2c_lock 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: 7bit Message-Id: <20240506-cocci-locks-v1-3-a67952fe5d19@chromium.org> References: <20240506-cocci-locks-v1-0-a67952fe5d19@chromium.org> In-Reply-To: <20240506-cocci-locks-v1-0-a67952fe5d19@chromium.org> To: Andy Walls , Mauro Carvalho Chehab , Sean Young , Jarod Wilson Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 Move the lock logic to it's own function. There is less code duplication and cocci is much happier. Fix the following cocci warning: drivers/media/dvb-frontends/stv090x.c:799:1-7: preceding lock on line 768 Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/stv090x.c | 37 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c index cc45139057ba..3b02d504941f 100644 --- a/drivers/media/dvb-frontends/stv090x.c +++ b/drivers/media/dvb-frontends/stv090x.c @@ -748,6 +748,22 @@ static int stv090x_write_reg(struct stv090x_state *state, unsigned int reg, u8 d return stv090x_write_regs(state, reg, &tmp, 1); } +static inline void stv090x_tuner_i2c_lock(struct stv090x_state *state) +{ + if (state->config->tuner_i2c_lock) + state->config->tuner_i2c_lock(&state->frontend, 1); + else + mutex_lock(&state->internal->tuner_lock); +} + +static inline void stv090x_tuner_i2c_unlock(struct stv090x_state *state) +{ + if (state->config->tuner_i2c_lock) + state->config->tuner_i2c_lock(&state->frontend, 0); + else + mutex_unlock(&state->internal->tuner_lock); +} + static int stv090x_i2c_gate_ctrl(struct stv090x_state *state, int enable) { u32 reg; @@ -761,12 +777,8 @@ static int stv090x_i2c_gate_ctrl(struct stv090x_state *state, int enable) * In case of any error, the lock is unlocked and exit within the * relevant operations themselves. */ - if (enable) { - if (state->config->tuner_i2c_lock) - state->config->tuner_i2c_lock(&state->frontend, 1); - else - mutex_lock(&state->internal->tuner_lock); - } + if (enable) + stv090x_tuner_i2c_lock(state); reg = STV090x_READ_DEMOD(state, I2CRPT); if (enable) { @@ -782,20 +794,13 @@ static int stv090x_i2c_gate_ctrl(struct stv090x_state *state, int enable) goto err; } - if (!enable) { - if (state->config->tuner_i2c_lock) - state->config->tuner_i2c_lock(&state->frontend, 0); - else - mutex_unlock(&state->internal->tuner_lock); - } + if (!enable) + stv090x_tuner_i2c_unlock(state); return 0; err: dprintk(FE_ERROR, 1, "I/O error"); - if (state->config->tuner_i2c_lock) - state->config->tuner_i2c_lock(&state->frontend, 0); - else - mutex_unlock(&state->internal->tuner_lock); + stv090x_tuner_i2c_unlock(state); return -1; } -- 2.45.0.rc1.225.g2a3ae87e7f-goog