From patchwork Fri Aug 16 12:30:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 819879 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (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 3C77019A281 for ; Fri, 16 Aug 2024 12:30:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811434; cv=none; b=ugUvNA0ajC99u03x30LoIdGb3M1VXtHDU5HBLl3PA0IqrDsBa6fPSIgh6u2mUQF09lbXDozLSCrGwrBb9dpXrSJLhi/Fp6E13VkLGR+7YLKCRsdC2U0jPqyRIzr0nxfNPQ4XJj7l2p3mihSe2+2eXXyXiKvSV3T+gl/65BmEM3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811434; c=relaxed/simple; bh=568YwfJwS19eXY00SNElYpfCguoOx4QLLp+DlESW9is=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bJ9eY4YG06avX+ZWEycyEnuZ7y8evubyymrwPRH2voOJzVM9rxHAyjKvLVPUTD7dRVyS7FWaA8mv9KNw0C7854AnAP6c7an6aIqwaHhO7pCjmslHYo6LhBh96/pDpok5CP2RfdTB+UR8MWgzswYwA+/biD0Ni08JxjCcslQIIgU= 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=HT0b2Ao3; arc=none smtp.client-ip=209.85.160.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HT0b2Ao3" Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-45006bcb482so10299501cf.3 for ; Fri, 16 Aug 2024 05:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811432; x=1724416232; 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=S9+z6gpUkXqdscNtaq7xrhbv4UjN8Jhn3DWImgjgzCA=; b=HT0b2Ao3kkXG2qbVTWRBT065VwQi+FYTkWzxGX+HzM5WVkryR0kUtnmjlVZiHZ59AI C6jDOjCZ+VcFml0EvzQWbcwG7L6vg0gA3BbJ7yV1+BZ3FWMz0cl+Bz/Bm3UGeqrbHC1I u4XAskt6hUlwjHHJGqFsLxsrrtBlQUx5DiW2A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811432; x=1724416232; 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=S9+z6gpUkXqdscNtaq7xrhbv4UjN8Jhn3DWImgjgzCA=; b=T+cpuStgzgVh9Ph5Khj8wO8CQyRednaFMH4Q0dQxEdp7Xfdl2X7t4tKqrwTvxkCtQj lDf8sN6yHqV3kXQaLLVfMahAOugxZCg6VFxrRdMtvtlFOg88swqymlZwzP6JyKvgWIj4 gAJQUTTAxIC0V0oQgEMe6UmRpSosxkgKtEE6XifC+uDk43RQaUk1oMNlbGcTb0xvPcRM 456ktyJ5Nd/TZ0wMNF4VGB8eqjtgttZ9QfE4b3AIM6WrZ4UU+HvtxI1rq/KEl+/2E/q0 T5l+mJ1gF+FYOKK3184OZhtAXyVq3O/xanaTtEC6pEGGV48bsF6vKK58XOP9qGdbPgpv QOCw== X-Gm-Message-State: AOJu0YyS1J356Lzba6PItI+VgS8aoMp+OGoVPI8XQqYhiKaXby1+kLlm ogsGzZv+eoNV4TWCEIVXFMGuoYnfoqjDYeYAtmjY1WKE/IQQYBi+MbPyJ84bJA== X-Google-Smtp-Source: AGHT+IG1ysskNar2G6UxqNwrChFpnXW+yrLaTjloZETNU435Cn2/Ocy8z8Un46AKaDseQscvtgw8oQ== X-Received: by 2002:a05:622a:1f17:b0:44f:e753:c541 with SMTP id d75a77b69052e-453742fa038mr32797401cf.37.1723811431966; Fri, 16 Aug 2024 05:30:31 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd9e39sm15853051cf.2.2024.08.16.05.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:30:31 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 16 Aug 2024 12:30:29 +0000 Subject: [PATCH v3 1/3] media: drivers/media/dvb-core: Split dvb_frontend_open() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-coccinelle-followup-v3-1-79fbc2742fa8@chromium.org> References: <20240816-coccinelle-followup-v3-0-79fbc2742fa8@chromium.org> In-Reply-To: <20240816-coccinelle-followup-v3-0-79fbc2742fa8@chromium.org> To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Ricardo Ribalda X-Mailer: b4 0.13.0 Move the actual opening to its own function. Not intended code change. This is a preparation for the next patch. Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-core/dvb_frontend.c | 148 ++++++++++++++++++---------------- 1 file changed, 80 insertions(+), 68 deletions(-) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 4f78f30b3646..26d1e8cd2108 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -2760,77 +2760,25 @@ static __poll_t dvb_frontend_poll(struct file *file, struct poll_table_struct *w return 0; } -static int dvb_frontend_open(struct inode *inode, struct file *file) +static int __dvb_frontend_open(struct inode *inode, struct file *file) { struct dvb_device *dvbdev = file->private_data; struct dvb_frontend *fe = dvbdev->priv; struct dvb_frontend_private *fepriv = fe->frontend_priv; - struct dvb_adapter *adapter = fe->dvb; int ret; - dev_dbg(fe->dvb->device, "%s:\n", __func__); - if (fe->exit == DVB_FE_DEVICE_REMOVED) - return -ENODEV; - - if (adapter->mfe_shared == 2) { - mutex_lock(&adapter->mfe_lock); - if ((file->f_flags & O_ACCMODE) != O_RDONLY) { - if (adapter->mfe_dvbdev && - !adapter->mfe_dvbdev->writers) { - mutex_unlock(&adapter->mfe_lock); - return -EBUSY; - } - adapter->mfe_dvbdev = dvbdev; - } - } else if (adapter->mfe_shared) { - mutex_lock(&adapter->mfe_lock); - - if (!adapter->mfe_dvbdev) - adapter->mfe_dvbdev = dvbdev; - - else if (adapter->mfe_dvbdev != dvbdev) { - struct dvb_device - *mfedev = adapter->mfe_dvbdev; - struct dvb_frontend - *mfe = mfedev->priv; - struct dvb_frontend_private - *mfepriv = mfe->frontend_priv; - int mferetry = (dvb_mfe_wait_time << 1); - - mutex_unlock(&adapter->mfe_lock); - while (mferetry-- && (mfedev->users != -1 || - mfepriv->thread)) { - if (msleep_interruptible(500)) { - if (signal_pending(current)) - return -EINTR; - } - } - - mutex_lock(&adapter->mfe_lock); - if (adapter->mfe_dvbdev != dvbdev) { - mfedev = adapter->mfe_dvbdev; - mfe = mfedev->priv; - mfepriv = mfe->frontend_priv; - if (mfedev->users != -1 || - mfepriv->thread) { - mutex_unlock(&adapter->mfe_lock); - return -EBUSY; - } - adapter->mfe_dvbdev = dvbdev; - } - } - } - if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) { if ((ret = fe->ops.ts_bus_ctrl(fe, 1)) < 0) - goto err0; - - /* If we took control of the bus, we need to force - reinitialization. This is because many ts_bus_ctrl() - functions strobe the RESET pin on the demod, and if the - frontend thread already exists then the dvb_init() routine - won't get called (which is what usually does initial - register configuration). */ + return ret; + + /* + * If we took control of the bus, we need to force + * reinitialization. This is because many ts_bus_ctrl() + * functions strobe the RESET pin on the demod, and if the + * frontend thread already exists then the dvb_init() routine + * won't get called (which is what usually does initial + * register configuration). + */ fepriv->reinitialise = 1; } @@ -2871,8 +2819,6 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) dvb_frontend_get(fe); - if (adapter->mfe_shared) - mutex_unlock(&adapter->mfe_lock); return ret; err3: @@ -2891,9 +2837,75 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) err1: if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) fe->ops.ts_bus_ctrl(fe, 0); -err0: - if (adapter->mfe_shared) - mutex_unlock(&adapter->mfe_lock); + + return ret; +} + +static int dvb_frontend_open(struct inode *inode, struct file *file) +{ + struct dvb_device *dvbdev = file->private_data; + struct dvb_frontend *fe = dvbdev->priv; + struct dvb_adapter *adapter = fe->dvb; + int ret; + + dev_dbg(fe->dvb->device, "%s:\n", __func__); + if (fe->exit == DVB_FE_DEVICE_REMOVED) + return -ENODEV; + + if (!adapter->mfe_shared) + return __dvb_frontend_open(inode, file); + + if (adapter->mfe_shared == 2) { + mutex_lock(&adapter->mfe_lock); + if ((file->f_flags & O_ACCMODE) != O_RDONLY) { + if (adapter->mfe_dvbdev && + !adapter->mfe_dvbdev->writers) { + mutex_unlock(&adapter->mfe_lock); + return -EBUSY; + } + adapter->mfe_dvbdev = dvbdev; + } + } else { + mutex_lock(&adapter->mfe_lock); + + if (!adapter->mfe_dvbdev) { + adapter->mfe_dvbdev = dvbdev; + } else if (adapter->mfe_dvbdev != dvbdev) { + struct dvb_device + *mfedev = adapter->mfe_dvbdev; + struct dvb_frontend + *mfe = mfedev->priv; + struct dvb_frontend_private + *mfepriv = mfe->frontend_priv; + int mferetry = (dvb_mfe_wait_time << 1); + + mutex_unlock(&adapter->mfe_lock); + while (mferetry-- && (mfedev->users != -1 || + mfepriv->thread)) { + if (msleep_interruptible(500)) { + if (signal_pending(current)) + return -EINTR; + } + } + + mutex_lock(&adapter->mfe_lock); + if (adapter->mfe_dvbdev != dvbdev) { + mfedev = adapter->mfe_dvbdev; + mfe = mfedev->priv; + mfepriv = mfe->frontend_priv; + if (mfedev->users != -1 || + mfepriv->thread) { + mutex_unlock(&adapter->mfe_lock); + return -EBUSY; + } + adapter->mfe_dvbdev = dvbdev; + } + } + } + + ret = __dvb_frontend_open(inode, file); + mutex_unlock(&adapter->mfe_lock); + return ret; } From patchwork Fri Aug 16 12:30:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 820125 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 C67061AE050 for ; Fri, 16 Aug 2024 12:30:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811435; cv=none; b=JkZ1eIGexZBYw9qRoDigZCoPsb9m1C0de0Zb9W57Og4sJeg23rj6u56pB0ng8P1vcBr2N+vnV2VmLkPL3FhXlMDqbyrwfXBwwtj6hwa8k04AZ3jJFNBETPVw4DqjFz9WpbIiuT8abUB6SSCm7EXwhjR/pGNZ4hH93XKDya4K6pE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811435; c=relaxed/simple; bh=AZKrq35caHyUC1AOx2BHGxje6p+Qp28K1jvfGAPDILk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lhd32vJva8UOboHqA3tkO4J0HdlBxo5mYO/Ee/D/Qmr2bKPlBzG4PAsrM+o7r5VMxwOkxCu2E6EhH3EfWQBjZyrNvv5IPXdT/S0NqtG7U0tqr3LozHOEUfK2E/gyotgsgumJQ/lxYas+IlAr07M1wXtxoKyl4mm5RACjMlQBs44= 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=nxtqWHW+; arc=none smtp.client-ip=209.85.167.174 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="nxtqWHW+" Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3db1e4219f8so1134694b6e.3 for ; Fri, 16 Aug 2024 05:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811433; x=1724416233; 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=9/QU+rV1Nd5TU+U1vgju3PydQyZ7PV27wGq420iJA4U=; b=nxtqWHW+NdFExhTogcJpuiRR5ruNEwhEz37Ks31wkc/EUTuKY2FXbrDhTbtbesj9KF Sm3UZLFA4/FAMHEiP/fuB/bUTZUij9CQehcSlJHlEcUtoQloIokp6PYmrMERt7l6ouDK QXNwmbtoWry3B/jC7wzIc+czsYDQH6JMwBoRs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811433; x=1724416233; 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=9/QU+rV1Nd5TU+U1vgju3PydQyZ7PV27wGq420iJA4U=; b=Lp/CLmFY2zSQDzuEDRwU0kVyQ8EdAadChX+TGiaGXBrv5Lfjm3fGJOVKZU+vMAhcIP GR26YGVBm5OoKNyuNeJw8reF7wPSfwOjE20hffjK4r5GOIXC2iGoDIL+1/pkxMbkdVbb ey5DHFz1DGqGtu5qG+g5tk/HzMkB2wHfOPl8f41T2HxhTBtDf1o3e5BvJ3B9iZOPQlbb A5og81nD4ynBPPekGyL9ebSzkESbn/vbmescNEQFFRAcZpWznHIyAXuHAYD8pXCiZaF6 SdldfKmRN67IrivCs/NVfqAooZbL/olDgjAc9YfTBmzlQzdmDfnDLJIFP5hiRcPGxBeS hqhg== X-Gm-Message-State: AOJu0YxyWl+q0JrkqG80DvRbhD3mTA2hg1/sukmqUI+pEEB51+Dssr/l iwP+KufzbLkjA8wUwr2NVXowDW+BVg0qrcORaonH1XCstLcoK+QZ5A2BcMTE4g== X-Google-Smtp-Source: AGHT+IHjyuDdk6080uZHYBYL0mtSfgS+GpjPjfdGO3VjFw+1uuHfaAIvPhfZJz4zvTAfrCYH0dFSAw== X-Received: by 2002:a05:6808:d50:b0:3db:37ff:42b2 with SMTP id 5614622812f47-3dd3ae3881amr2338824b6e.45.1723811432555; Fri, 16 Aug 2024 05:30:32 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd9e39sm15853051cf.2.2024.08.16.05.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:30:32 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 16 Aug 2024 12:30:30 +0000 Subject: [PATCH v3 2/3] media: drivers/media/dvb-core: Refactor dvb_frontend_open locking Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-coccinelle-followup-v3-2-79fbc2742fa8@chromium.org> References: <20240816-coccinelle-followup-v3-0-79fbc2742fa8@chromium.org> In-Reply-To: <20240816-coccinelle-followup-v3-0-79fbc2742fa8@chromium.org> To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Ricardo Ribalda X-Mailer: b4 0.13.0 Split out the wait function, and introduce some new toys: guard and lockdep. This fixes the following cocci warnings: drivers/media/dvb-core/dvb_frontend.c:2897:1-7: preceding lock on line 2776 drivers/media/dvb-core/dvb_frontend.c:2897:1-7: preceding lock on line 2786 drivers/media/dvb-core/dvb_frontend.c:2897:1-7: preceding lock on line 2809 Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-core/dvb_frontend.c | 58 ++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 26d1e8cd2108..16d21ec6ff35 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -2841,6 +2842,34 @@ static int __dvb_frontend_open(struct inode *inode, struct file *file) return ret; } +static int wait_dvb_frontend(struct dvb_adapter *adapter, + struct dvb_device *mfedev) +{ + struct dvb_frontend *mfe = mfedev->priv; + struct dvb_frontend_private *mfepriv = mfe->frontend_priv; + int mferetry = (dvb_mfe_wait_time << 1); + int ret = 0; + + lockdep_assert_held(&adapter->mfe_lock); + + if (mfedev->users == -1 && !mfepriv->thread) + return 0; + + mutex_unlock(&adapter->mfe_lock); + + while (mferetry-- && (mfedev->users != -1 || mfepriv->thread)) { + if (msleep_interruptible(500)) + if (signal_pending(current)) { + ret = -EINTR; + break; + } + } + + mutex_lock(&adapter->mfe_lock); + + return ret; +} + static int dvb_frontend_open(struct inode *inode, struct file *file) { struct dvb_device *dvbdev = file->private_data; @@ -2855,19 +2884,16 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) if (!adapter->mfe_shared) return __dvb_frontend_open(inode, file); + guard(mutex)(&adapter->mfe_lock); + if (adapter->mfe_shared == 2) { - mutex_lock(&adapter->mfe_lock); if ((file->f_flags & O_ACCMODE) != O_RDONLY) { if (adapter->mfe_dvbdev && - !adapter->mfe_dvbdev->writers) { - mutex_unlock(&adapter->mfe_lock); + !adapter->mfe_dvbdev->writers) return -EBUSY; - } adapter->mfe_dvbdev = dvbdev; } } else { - mutex_lock(&adapter->mfe_lock); - if (!adapter->mfe_dvbdev) { adapter->mfe_dvbdev = dvbdev; } else if (adapter->mfe_dvbdev != dvbdev) { @@ -2877,34 +2903,24 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) *mfe = mfedev->priv; struct dvb_frontend_private *mfepriv = mfe->frontend_priv; - int mferetry = (dvb_mfe_wait_time << 1); - - mutex_unlock(&adapter->mfe_lock); - while (mferetry-- && (mfedev->users != -1 || - mfepriv->thread)) { - if (msleep_interruptible(500)) { - if (signal_pending(current)) - return -EINTR; - } - } - mutex_lock(&adapter->mfe_lock); + ret = wait_dvb_frontend(adapter, mfedev); + if (ret) + return ret; + if (adapter->mfe_dvbdev != dvbdev) { mfedev = adapter->mfe_dvbdev; mfe = mfedev->priv; mfepriv = mfe->frontend_priv; if (mfedev->users != -1 || - mfepriv->thread) { - mutex_unlock(&adapter->mfe_lock); + mfepriv->thread) return -EBUSY; - } adapter->mfe_dvbdev = dvbdev; } } } ret = __dvb_frontend_open(inode, file); - mutex_unlock(&adapter->mfe_lock); return ret; } From patchwork Fri Aug 16 12:30:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 819878 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 54AD91AE87B for ; Fri, 16 Aug 2024 12:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811435; cv=none; b=CfZ/GeJefkSlDCrQfRZAvgRtT0ivUMaTC4tYxBaKVsu/hTN17EFDYkiuelamkLjjr8sVV9XqUvVaLWtdOR+7xugWoFNWo37rGil6cfbU+eAat278F3zrVhoAkIWTDPBlIGZt0V8aRPmYT14Cthhsn/mh7FULzcgTAV4B8jt8QVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811435; c=relaxed/simple; bh=AN2zkbqD250EjGBEmwuzJlE8f9nO0nY/af0JFueOjQI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QeMybI5OjF8r1MsLQQYhCVh5t2Ra6s1FQ/puOGMrFEqBLq+inYC4+/INUBBv5H1Kw/hwcpYvoxABwczZlpEzH25v1hVl4Ym2gD3HYtElo7Hqe1yD1x2rHwclhyv0cAv0KQTXhLe4bpfuFRct06YxRz6SShF6fycjcG3n5l/HyfM= 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=dpF4LyFB; arc=none smtp.client-ip=209.85.160.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="dpF4LyFB" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-44ff99fcd42so10821421cf.0 for ; Fri, 16 Aug 2024 05:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811433; x=1724416233; 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=s0nrBOsUAqUgapKq+R34S7oSUAMCsQPiLYdOB0fBvGY=; b=dpF4LyFByvsA4sBvf6xOcUq9BpW5B7BT3TTHaXWX2SQNvq3vU45R5VLRinRWtt03CI Hizt6+FWPAPpVgxCgWSpEeBJKLzBBarSKmT32AQXKXAsisfDl4nkHoB5HBnHgunoUa56 NNcK3h3/9IJU2gruXljdIieKAS3+BN2Ox3gDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811433; x=1724416233; 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=s0nrBOsUAqUgapKq+R34S7oSUAMCsQPiLYdOB0fBvGY=; b=GvYwUf5EuH6soRNrSFz5DTf6FTJnaHzJCWAYM0HTaQgDCe+BYGlaTr9uS8U4GCRczY 3fvo8iiTSiZntu9m890N89t4wYnFHhiIGWMi4gxJ6DFdTx45xxI5AX3FThU3wI6w5HCJ gN/DHxcL2js2bbnacHWkJiTKPrRR8LeVHlHUdy5ENVMsgU63gggGTufacRK8nsBQvnQl Ize+ogkYgWwwJXg56tIsdJyBxNO4GExEponxZEw3kdB1ea9tGxcTr/vsb7BWzO3JZ/xD pMephs24qYWErIblNmWR9Npcs4hpxiVCE746NtaOe/+Z/SY2wvcKHmK5G/Ws7YbTgwFs ASNA== X-Gm-Message-State: AOJu0YxDdxc7XHtIscYpKOCVqdTOoMtmy6B03KfOMWXioPGxAZdHT7nJ lR6MKbUEcPPDadZmgeIdXBa6zqfFik5+IxvpS6lErZbirqF8Iw9Q8NDVp9r+qA== X-Google-Smtp-Source: AGHT+IGQPFo/pK6ONr5jhdyaMMEVlTHiYM6Dy3SXIYXya/U1WD7/VoBzANNiaowrEjln8pWihHYKBg== X-Received: by 2002:a05:622a:1c19:b0:44f:feef:efe1 with SMTP id d75a77b69052e-453743a947fmr24457181cf.54.1723811433219; Fri, 16 Aug 2024 05:30:33 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd9e39sm15853051cf.2.2024.08.16.05.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:30:32 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 16 Aug 2024 12:30:31 +0000 Subject: [PATCH v3 3/3] media: drivers/media/dvb-core: CodoStyle for dvb_frontend_open() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-coccinelle-followup-v3-3-79fbc2742fa8@chromium.org> References: <20240816-coccinelle-followup-v3-0-79fbc2742fa8@chromium.org> In-Reply-To: <20240816-coccinelle-followup-v3-0-79fbc2742fa8@chromium.org> To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Ricardo Ribalda X-Mailer: b4 0.13.0 We can rearrange a bit the function to reduce the indentation levels. No functional change added to this patch. Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-core/dvb_frontend.c | 49 ++++++++++++++++------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 16d21ec6ff35..f714fc432dea 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -2875,7 +2875,6 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) struct dvb_device *dvbdev = file->private_data; struct dvb_frontend *fe = dvbdev->priv; struct dvb_adapter *adapter = fe->dvb; - int ret; dev_dbg(fe->dvb->device, "%s:\n", __func__); if (fe->exit == DVB_FE_DEVICE_REMOVED) @@ -2893,36 +2892,32 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) return -EBUSY; adapter->mfe_dvbdev = dvbdev; } - } else { - if (!adapter->mfe_dvbdev) { + return __dvb_frontend_open(inode, file); + } + + if (!adapter->mfe_dvbdev) { + adapter->mfe_dvbdev = dvbdev; + } else if (adapter->mfe_dvbdev != dvbdev) { + struct dvb_device *mfedev = adapter->mfe_dvbdev; + struct dvb_frontend *mfe = mfedev->priv; + struct dvb_frontend_private *mfepriv = mfe->frontend_priv; + int ret; + + ret = wait_dvb_frontend(adapter, mfedev); + if (ret) + return ret; + + if (adapter->mfe_dvbdev != dvbdev) { + mfedev = adapter->mfe_dvbdev; + mfe = mfedev->priv; + mfepriv = mfe->frontend_priv; + if (mfedev->users != -1 || mfepriv->thread) + return -EBUSY; adapter->mfe_dvbdev = dvbdev; - } else if (adapter->mfe_dvbdev != dvbdev) { - struct dvb_device - *mfedev = adapter->mfe_dvbdev; - struct dvb_frontend - *mfe = mfedev->priv; - struct dvb_frontend_private - *mfepriv = mfe->frontend_priv; - - ret = wait_dvb_frontend(adapter, mfedev); - if (ret) - return ret; - - if (adapter->mfe_dvbdev != dvbdev) { - mfedev = adapter->mfe_dvbdev; - mfe = mfedev->priv; - mfepriv = mfe->frontend_priv; - if (mfedev->users != -1 || - mfepriv->thread) - return -EBUSY; - adapter->mfe_dvbdev = dvbdev; - } } } - ret = __dvb_frontend_open(inode, file); - - return ret; + return __dvb_frontend_open(inode, file); } static int dvb_frontend_release(struct inode *inode, struct file *file)