From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90FDFC2B9F4 for ; Fri, 25 Jun 2021 07:38:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74E4F613FA for ; Fri, 25 Jun 2021 07:38:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230003AbhFYHkw (ORCPT ); Fri, 25 Jun 2021 03:40:52 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:34700 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbhFYHkt (ORCPT ); Fri, 25 Jun 2021 03:40:49 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 3B2F721C01; Fri, 25 Jun 2021 07:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1624606708; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nnuofijrl6RYEFo+SFPGi5DMa5lFhRBvWdO4DS6T/+U=; b=vEuo9NsyGr+cpk9/T9Oi+8amIT5p6qH1c8/d+FX686CYu0U//vzniKvYnHilyV8Id69HOj hg5Q8ux54N44TOI55Z5LGIpYvMovuz7RlKMKqR5KgvT4Tn5zLWMfvZv7/CGQak42rrqLFP X6OOzpIQrThIzWsL9FGN5HwvTYVdxHk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1624606708; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nnuofijrl6RYEFo+SFPGi5DMa5lFhRBvWdO4DS6T/+U=; b=WTKkbJVi6TeYOQSW2lEK8FsvSkE2tasxsltYBEAL13LnawAU2wmKPEGGb26GdUsVKe9UvI /LDYfu8+WMBiLbDw== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 02865A3BB4; Fri, 25 Jun 2021 07:38:27 +0000 (UTC) Date: Fri, 25 Jun 2021 09:38:27 +0200 Message-ID: From: Takashi Iwai To: Christophe JAILLET Cc: clemens@ladisch.de, o-takashi@sakamocchi.jp, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] ALSA: firewire-lib: Fix 'amdtp_domain_start()' when no AMDTP_OUT_STREAM stream is found In-Reply-To: <9c9a53a4905984a570ba5672cbab84f2027dedc1.1624560484.git.christophe.jaillet@wanadoo.fr> References: <9c9a53a4905984a570ba5672cbab84f2027dedc1.1624560484.git.christophe.jaillet@wanadoo.fr> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: kernel-janitors@vger.kernel.org On Thu, 24 Jun 2021 20:49:36 +0200, Christophe JAILLET wrote: > > The intent here is to return an error code if we don't find what we are > looking for in the 'list_for_each_entry()' loop. > > 's' is not NULL if the list is empty or if we scan the complete list. > Introduce a new 'found' variable to handle such cases. > > Fixes: 60dd49298ec5 ("ALSA: firewire-lib: handle several AMDTP streams in callback handler of IRQ target") > Signed-off-by: Christophe JAILLET Applied now. Thanks. Takashi > --- > We could test with" if (list_entry_is_head(s, &d->streams, list))" > instead, but I find it much less readable. > --- > sound/firewire/amdtp-stream.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c > index aad9778d1c4d..9be2260e4ca2 100644 > --- a/sound/firewire/amdtp-stream.c > +++ b/sound/firewire/amdtp-stream.c > @@ -1943,6 +1943,7 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int tx_init_skip_cycles, > unsigned int events_per_period = d->events_per_period; > unsigned int queue_size; > struct amdtp_stream *s; > + bool found = false; > int err; > > if (replay_seq) { > @@ -1955,10 +1956,12 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int tx_init_skip_cycles, > > // Select an IT context as IRQ target. > list_for_each_entry(s, &d->streams, list) { > - if (s->direction == AMDTP_OUT_STREAM) > + if (s->direction == AMDTP_OUT_STREAM) { > + found = true; > break; > + } > } > - if (!s) > + if (!found) > return -ENXIO; > d->irq_target = s; > > -- > 2.30.2 >