From nobody Thu Apr 2 20:26:38 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 8B3CB3A7836 for ; Thu, 26 Mar 2026 21:35:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774560910; cv=none; b=HWTEgaRPB7O82hC9sN3YfXwm0kl93FpQH3MqnfGTjVAd8lOIfIYtTI9c9ktYjjhj3bvaMiM3WPEGAlp6IHmzpUNyWj/moW7RgsmR5jZW60KoqQ34YLiJLQUsXuwLI2O1I6/haTQQYwVX+mjtoKLKcYq8kwDZrUbKH2n9x3uoyyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774560910; c=relaxed/simple; bh=CtnwhLDLOxjCXa3BzzxQo5WlhQ17lqydy/Bm6LiQsfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uej02+koEE4OpwB7TuHFx9OOKBif5YMjz52FtDFDu08JRFwWjkiy4I2HNEh/uKP5V+DakFrHQIOi0Ly1YTNo5+lG1+bEVecQ7aPQ6f/cs8/E2m4NRiDXS382jh6NzL2WjFQuFDQO8fDqCMBXnz+PF0/RwamGrCp4vqdkkPmJcX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GzjeVxOw; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GzjeVxOw" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-48704db565eso20820745e9.1 for ; Thu, 26 Mar 2026 14:35:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774560907; x=1775165707; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iVJ/09f+kraUH4FlZGqso9M+eYHC0bMs9ktLcorknuk=; b=GzjeVxOw7tVqok0inhuAyktYGIpLr+DP8o8IKCMu7vtQRWMgoA1hnmCJf5TMU0fwbZ wzWuqeySBaJ1MU9kfPFA9o0YIfoSWndIBYd9fL0XNd6AfJdecm+88kI/cmm7mJRi0MN1 nngY5b3S66SMN7kRha4JlgLBkELkQw/l+XfFGuocXwiiwh6VJ5LLbvYdTSPxG/fmRilb YWiplU7t/5Aq/VoI5Ue5iTCcPJxHkL4GQ5dssVWl6g+0ezML5ydzE07F90Xs7RAQiHdG tftYhIrAQEFWDRe0uLVhwa3XhhN52bKn9/U1a6/m+1xYVmaQe1WRxEJcMGOSniELp3hN A7Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774560907; x=1775165707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iVJ/09f+kraUH4FlZGqso9M+eYHC0bMs9ktLcorknuk=; b=HMZExl72Zd6pOuo0vYdMXI1gt4yVrv2Kxftzik1ekTIAmNMUzpcP3L6gdKwankb5OS JqO4OCKiAEZg2ntq4bDyePs4A1YiBTENGcaQqG2VGBQanm6uSXLcfsjmbGFtg9WXHr1G KniicWAN5RMysR9yrvzJCr+Qo5K4XtO6RefJ1T1nZifGL06ZFcNORWn5Mr6taC94HX0Z oLwVY+iUSErApxQge7XIu7aYODqLRYj2Iou6FhQJlaW8BMjtXOqzWjJuSrYk57/Wj3mh JIFaDRg1SSt3V4aw/1x27NKGV9m25E4IEqF/IXDQ61VXAgoxsJh5p3mVltPYqF1fAm7J S5Pg== X-Forwarded-Encrypted: i=1; AJvYcCVRrcfnTJl3ILzu60FojKVQTfKTSS2XTJ5yAKIoJm9P7uj9z5nf85m/JpQ5KFIcDMIFHZoKjOc/iwDivKs=@vger.kernel.org X-Gm-Message-State: AOJu0YyMBa1oQjpYjBfDeVNarx8ZsXgCScbIZcQsAJj/9WfMX5l5djsm 4tg2XuEu4zBYDpfs1YEtgWzqsqRN4SAB5/x8Mlf0UjkM4ondc/txBC4A X-Gm-Gg: ATEYQzzC8ZS6vGsWGTrkBLMqnVEB264Wxi07lCmnDkUDqx69H1oR5LFIjguOcZZ0i9+ v+7IMuPa1+8APMzNrtnoorPlZJiNb8cLW69auzoYym7GPOCqKHqSdnMlRAao6WVcVwnhoJx/4KS 8gnsN97bjyEnwqOgRQ/J01eYFrDOHCEYwGmC84/PJDyMViVCl3ITHdF2MU1mRvRryeolLLZzzMc l3dEvZep04eRfZQOJvORTMtfaC7BkETj5Imt9XPYhNtik/BM3DLgMd4mjSG40ek+6I3tbcC52aY aqWShFTxTc4RtGvxYtRsQfxoYR1uN58SpoCUZsoH1XZeRm2ER7BuMLYIUDSpJL2yYWREtwEkt0f qB5k9/cBjrmPIQnJlUDKgA3aNBQZ7vxwWTvlPvFrb1mV82tyHkmt7tmzyKxKe9AzmF/Nv49zZLO QuqnF0cUzRY938oYWKsNw4tyytUwt3yKgXjXsnZuS4PaPOtg== X-Received: by 2002:a05:600c:c168:b0:485:35a4:939f with SMTP id 5b1f17b1804b1-48727eddeacmr3457045e9.28.1774560906791; Thu, 26 Mar 2026 14:35:06 -0700 (PDT) Received: from localhost.localdomain ([2a00:f41:1855:4ab5:5c9b:17ff:fe26:9b2c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48722c7cec3sm51106825e9.6.2026.03.26.14.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 14:35:06 -0700 (PDT) From: "Jose A. Perez de Azpillaga" To: linux-staging@lists.linux.dev Cc: Andy Shevchenko , Hans de Goede , Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Kees Cook , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v2 2/3] staging: media: atomisp: extract ISP2401 cleanup into helper function Date: Thu, 26 Mar 2026 22:34:08 +0100 Message-ID: <20260326213442.876745-3-azpijr@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260326213442.876745-1-azpijr@gmail.com> References: <20260326213442.876745-1-azpijr@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To reduce indentation and improve the readability of ia_css_stream_destroy(), extract the ISP2401-specific cleanup block into a new static helper function, ia_css_stream_destroy_isp2401(). Signed-off-by: Jose A. Perez de Azpillaga --- drivers/staging/media/atomisp/pci/sh_css.c | 89 +++++++++++----------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/m= edia/atomisp/pci/sh_css.c index 8d8b82dc59f1..0e848758723f 100644 --- a/drivers/staging/media/atomisp/pci/sh_css.c +++ b/drivers/staging/media/atomisp/pci/sh_css.c @@ -8189,10 +8189,53 @@ ia_css_stream_create(const struct ia_css_stream_con= fig *stream_config, return err; } =20 +static void ia_css_stream_destroy_isp2401(struct ia_css_stream *stream) +{ + int i, j; + + for (i =3D 0; i < stream->num_pipes; i++) { + struct ia_css_pipe *entry =3D stream->pipes[i]; + unsigned int sp_thread_id; + struct sh_css_sp_pipeline_terminal *terminal; + + assert(entry); + if (entry) { + if (!ia_css_pipeline_get_sp_thread_id( + ia_css_pipe_get_pipe_num(entry), &sp_thread_id)) + return; + + terminal =3D &sh_css_sp_group.pipe_io[sp_thread_id].input; + + for (j =3D 0; j < IA_CSS_STREAM_MAX_ISYS_STREAM_PER_CH; j++) { + ia_css_isys_stream_h isys_stream =3D + &terminal->context.virtual_input_system_stream[j]; + if (stream->config.isys_config[j].valid && isys_stream->valid) + ia_css_isys_stream_destroy(isys_stream); + } + } + } + + if (stream->config.mode =3D=3D IA_CSS_INPUT_MODE_BUFFERED_SENSOR) { + for (i =3D 0; i < stream->num_pipes; i++) { + struct ia_css_pipe *entry =3D stream->pipes[i]; + /* + * free any mipi frames that are remaining: + * some test stream create-destroy cycles do + * not generate output frames + * and the mipi buffer is not freed in the + * deque function + */ + if (entry) + free_mipi_frames(entry); + } + } + stream_unregister_with_csi_rx(stream); +} + int ia_css_stream_destroy(struct ia_css_stream *stream) { - int i, j; + int i; int err =3D 0; =20 IA_CSS_ENTER_PRIVATE("stream =3D %p", stream); @@ -8206,48 +8249,8 @@ ia_css_stream_destroy(struct ia_css_stream *stream) =20 if ((stream->last_pipe) && ia_css_pipeline_is_mapped(stream->last_pipe->pipe_num)) { - if (IS_ISP2401) { - for (i =3D 0; i < stream->num_pipes; i++) { - struct ia_css_pipe *entry =3D stream->pipes[i]; - unsigned int sp_thread_id; - struct sh_css_sp_pipeline_terminal *sp_pipeline_input_terminal; - - assert(entry); - if (entry) { - /* get the SP thread id */ - if (!ia_css_pipeline_get_sp_thread_id( - ia_css_pipe_get_pipe_num(entry), &sp_thread_id)) - return -EINVAL; - - /* get the target input terminal */ - sp_pipeline_input_terminal =3D - &sh_css_sp_group.pipe_io[sp_thread_id].input; - - for (j =3D 0; j < IA_CSS_STREAM_MAX_ISYS_STREAM_PER_CH; j++) { - ia_css_isys_stream_h isys_stream =3D - &sp_pipeline_input_terminal->context.virtual_input_system_stream[j]; - if (stream->config.isys_config[j].valid && isys_stream->valid) - ia_css_isys_stream_destroy(isys_stream); - } - } - } - - if (stream->config.mode =3D=3D IA_CSS_INPUT_MODE_BUFFERED_SENSOR) { - for (i =3D 0; i < stream->num_pipes; i++) { - struct ia_css_pipe *entry =3D stream->pipes[i]; - /* - * free any mipi frames that are remaining: - * some test stream create-destroy cycles do - * not generate output frames - * and the mipi buffer is not freed in the - * deque function - */ - if (entry) - free_mipi_frames(entry); - } - } - stream_unregister_with_csi_rx(stream); - } + if (IS_ISP2401) + ia_css_stream_destroy_isp2401(stream); =20 for (i =3D 0; i < stream->num_pipes; i++) { struct ia_css_pipe *curr_pipe =3D stream->pipes[i]; --=20 2.53.0