Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp79074lqp; Fri, 12 Apr 2024 10:58:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJ8EK8UMLWilNizzzoJrqzzK7pXUj4o6pYyMOS/QiP1HPkvvyQSGnt3cHY6yw5q/Jp/Gf/v6Gjah4tm68RViMQNiEMlIVhIZFJI7CJiw== X-Google-Smtp-Source: AGHT+IHOqvqLZBCMkKRDs92/kufMuGCXXVr5CPRVrunAAxRYR4hPN92zKzA2bzHJYWBE0jvcUs3K X-Received: by 2002:a17:90b:1b47:b0:2a2:70c6:970c with SMTP id nv7-20020a17090b1b4700b002a270c6970cmr3349550pjb.11.1712944680492; Fri, 12 Apr 2024 10:58:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712944680; cv=pass; d=google.com; s=arc-20160816; b=N5imM7SlV/eZY0tvH+E5hZqYOLdgN/bDz4tOxuKH1YaZk9ZAyLlumHG0hgxIgHcI4w zP87CMnEok75HGYsi99afzcNIjog3rZ+8jjYUHdKnwGyRNl6sKBiK3kTtPTpZHxv9bIc laO0Tb6eGh+dZLj28m0Q/aUxQa4CM6OaHG1UWRd/0h0xMaMAfdoxxohpli4SoocPNVha Ab+3zVlChu9LiwZle1r/hYemTMa7n3y0zdJt4qoiGSZzsuWtjS9KlrMOpHygnaYRBDbT 1ig5uCP7i9FVWcQ+V+hH8oPFonucXtISGTq+tnl5KlRdhqEYisM7odCCAtwak80P4POh 8oRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Uvy8VXgFPjhSVW+3XOJxGKLHEL3KF/CQaJ2rJamkFj0=; fh=MjtdR5ZM51PywmjDM3JDNqGHDTXUTkNuptb8U3Hy+TQ=; b=RFWT/34nQiXFGZJqtbTBPXsyVQS8T81v97vPQ03oezn/xtQqIsotHrGU9rkcij1XDh rICjJZqzOQpmGC5+PdmdeQwRNq34+MOmBiZIZnH7S+EqFc6nhNenjnH21kA67rSGsU2a bUrmAAya91DZ3W5PFN0ewprcOEAbwfYvgtoVDmiAToaGwHPBlJUs1JVoPKilANeFSKyw QfXYZw7JHnJkAQizKHPExCeBatrZxM/WV1MiAL7UaxJmxc6V20ogtO2rvcl4HaNt7Kc1 r2jmgP0CGOLZmN5YR0l+8WnNIufEeRxcVQ/oHgRUvjlBEeII8BclXD0XnlPdOnDhAsAf 9pSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="RNadb4L/"; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-143153-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143153-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z7-20020a17090ad78700b002a653975332si3530852pju.111.2024.04.12.10.58.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 10:58:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143153-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="RNadb4L/"; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-143153-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143153-linux.lists.archive=gmail.com@vger.kernel.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8DCF9287C50 for ; Fri, 12 Apr 2024 17:46:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 699E414E2EF; Fri, 12 Apr 2024 17:46:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RNadb4L/" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EA8384A35; Fri, 12 Apr 2024 17:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712943995; cv=none; b=FbFi2j7d8GkOD5Pxy3q0K/KQh+u98nLwqevPQBCnPzTpv4Q/XOPAkITYEzK/u/oQ9Zh3V5jXdim+4u0PuQH2IVSL9vqbwj2zthww9rO4n/a3087W5G8BF03B8Vt+IcXt760FdP3dvDGjVRv73h3wkgZNwrM7AB+goAL9gBIKntc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712943995; c=relaxed/simple; bh=yk3dJwZYho2TmdvCH1G6eTKYmUXBHIbNMDu93HdHWE0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hBpNIbVv+zM/wpZNHC0MvIrQrZR4Fnre6FW7m/e10mdCuibGs5ChXnCn51zCoZ7qNzAeD6O5jaWwNS0+HwDfBy7V4TW2FPZo+DS+LH1vxGcZs5GVRAtM2EK17Ea9WI8RsCS4rlQfMw3vTx+kx2nIdT2UtA3sbDBfaEdeVYeqUrw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=RNadb4L/; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from pendragon.ideasonboard.com (85-76-65-73-nat.elisa-mobile.fi [85.76.65.73]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6627B8E1; Fri, 12 Apr 2024 19:45:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712943948; bh=yk3dJwZYho2TmdvCH1G6eTKYmUXBHIbNMDu93HdHWE0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RNadb4L/SonvbAnjPwqdbHUP6X9zsaOqS4dyvqX3J+kWjmJ32wsCBYgr7n2Oo9HJc 0jH8zUEBeWANuuAPR1gdwl4rUBSbL0od6/yyS47GvpRme2JDC8PosJeddMf+VpoMCH O/ShOX6bJbTIG15SPTQi6t3MBaYB9zenWXd8qpqE= Date: Fri, 12 Apr 2024 20:46:21 +0300 From: Laurent Pinchart To: Sakari Ailus Cc: linux-media@vger.kernel.org, tomi.valkeinen@ideasonboard.com, Hans de Goede , Mauro Carvalho Chehab , Hans Verkuil , Umang Jain , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/1] media: v4l: Don't turn on privacy LED if streamon fails Message-ID: <20240412174621.GA5444@pendragon.ideasonboard.com> References: <20240410114712.661186-1-sakari.ailus@linux.intel.com> 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-Disposition: inline In-Reply-To: <20240410114712.661186-1-sakari.ailus@linux.intel.com> Hi Sakari, Thank you for the patch. On Wed, Apr 10, 2024 at 02:47:12PM +0300, Sakari Ailus wrote: > Turn on the privacy LED only if streamon succeeds. This can be done after > enabling streaming on the sensor. > > Fixes: b6e10ff6c23d ("media: v4l2-core: Make the v4l2-core code enable/disable the privacy LED if present") > Signed-off-by: Sakari Ailus > --- > drivers/media/v4l2-core/v4l2-subdev.c | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c > index 4c6198c48dd6..012b757eac9f 100644 > --- a/drivers/media/v4l2-core/v4l2-subdev.c > +++ b/drivers/media/v4l2-core/v4l2-subdev.c > @@ -412,15 +412,6 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable) > if (WARN_ON(!!sd->enabled_streams == !!enable)) > return 0; > > -#if IS_REACHABLE(CONFIG_LEDS_CLASS) > - if (!IS_ERR_OR_NULL(sd->privacy_led)) { > - if (enable) > - led_set_brightness(sd->privacy_led, > - sd->privacy_led->max_brightness); > - else > - led_set_brightness(sd->privacy_led, 0); > - } > -#endif > ret = sd->ops->video->s_stream(sd, enable); > > if (!enable && ret < 0) { > @@ -428,9 +419,20 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable) > ret = 0; > } > > - if (!ret) > + if (!ret) { > sd->enabled_streams = enable ? BIT(0) : 0; > > +#if IS_REACHABLE(CONFIG_LEDS_CLASS) > + if (!IS_ERR_OR_NULL(sd->privacy_led)) { > + if (enable) > + led_set_brightness(sd->privacy_led, > + sd->privacy_led->max_brightness); > + else > + led_set_brightness(sd->privacy_led, 0); > + } > +#endif This means that the LED will be turned slightly after the camera is enabled. I don't think it's an issue in practice. Another possibly more important concern is that we should maybe check the return value of led_set_brightness(), and fail .s_stream() when we can't enable the privacy LED at stream on time. In that case, it would be best to keep turning the privacy LED on before calling .s_stream(). It should still be turned off only after calling .s_stream() though. > + } > + > return ret; > } > -- Regards, Laurent Pinchart