Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1028572rdh; Mon, 25 Sep 2023 00:30:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTfYj99hk2vT+bjJ59nABCp9jw5pVqhAILJnYj4ff02lfbHdLqSdbNjLJvjVAcXMHeJ868 X-Received: by 2002:a17:902:e808:b0:1b8:2ba0:c9a8 with SMTP id u8-20020a170902e80800b001b82ba0c9a8mr7820398plg.2.1695627005855; Mon, 25 Sep 2023 00:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695627005; cv=none; d=google.com; s=arc-20160816; b=sWqXVw9JoclGYT7I32UbMI1iTp/jsD2d+4Xx4tZlkY/o6C9V/Q+JYDJaoaeV7OOdy9 muxS6dF68q1/U2CsNxTi28w1avqBlVsf7v9xch9C5RnaSJFeqAeXbHFIra92GF7GeW/a /zouDnimQAHVCP6cI2oFZFNK2FB4uCvVv4kzU80HUO1B126seyX0Yon/qMBlYTN9MmD1 Z/NkeWsfwysnP5S6c7wD+Mfu4ZC0eefUFWfffdjhtd1f/FAeAUauwwQvFUxTZUaXu31U drk4W5At6/T2/h+cOpq/19LtL31jKnlhbU55g8vRnVfWR5JV0G6hFESsUTxnTlmeMv5S KUww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=plUDobdC2yIkn4RdkX7ayJLMVvFN5Q4UcwR3TZWeUwA=; fh=Y0PYaS9nrWl0DO0oYFMJ52zh3BA45I2L3hpwaCfZfdc=; b=Ady23WD3xZZrNH4dQepmUiAq7tcA3Rt9/lSqvk63hnFMjspi24gxiexJB6YLIq9IwJ Zbr6DWqc/fyqzREyVZ9EjDF3sjPIrstq47vuvCbPgwOrH4aN4T2SqzPN6i3Fq4PTfTFp z8l0MSJHFjqyndT8v9S5AehXPdrpIjkVPDqPJ9p4S9utEUER0SIdUtxTiCiKTeCSmb22 vivIaVlBzO+LJLw302uAw22QCVxutStUekR+7+ZAKa3na1hCA5j3Rzd19JmxWhL7xo0Z 0xpGfsIU/jV2C1pn7cJGQiAAq5v+JpmO/JGVLDid0ou7lpbEhSjSumXNDymuRUpaaSwt koaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id m1-20020a170902db0100b001c61923a58esi1876123plx.137.2023.09.25.00.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 00:30:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C65F180408C8; Mon, 25 Sep 2023 00:11:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232437AbjIYHLE (ORCPT + 99 others); Mon, 25 Sep 2023 03:11:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232426AbjIYHLB (ORCPT ); Mon, 25 Sep 2023 03:11:01 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B26C9B8; Mon, 25 Sep 2023 00:10:54 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12C41C433C7; Mon, 25 Sep 2023 07:10:51 +0000 (UTC) Message-ID: <936acf18-b961-40e3-b68b-f1c679961d67@xs4all.nl> Date: Mon, 25 Sep 2023 09:10:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 11/17] media: qcom: camss: Allow clocks vfeN vfe_liteN or vfe_lite Content-Language: en-US, nl To: Bryan O'Donoghue , rfoss@kernel.org, todor.too@gmail.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mchehab@kernel.org, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, andrey.konovalov@linaro.org Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230911131411.196033-1-bryan.odonoghue@linaro.org> <20230911131411.196033-12-bryan.odonoghue@linaro.org> From: Hans Verkuil In-Reply-To: <20230911131411.196033-12-bryan.odonoghue@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 25 Sep 2023 00:11:08 -0700 (PDT) On 11/09/2023 15:14, Bryan O'Donoghue wrote: > The number of Video Front End - VFE or Image Front End - IFE supported > with new SoCs can vary both for the full and lite cases. > > For example sdm845 has one vfe_lite and two vfe interfaces with the vfe > clock called simply "vfe_lite" with no integer postfix. sc8280xp has four > vfe and four vfe lite blocks. > > At the moment we declare vfe_lite0 and vfe_lite1 for sm8250 but never set > those clocks because we don't match the strings. > > We need to support the following clock name formats > > - vfeN > - vfe_liteN > - vfe_lite > > with N being any reasonably sized integer. > > There are two sites in this code which need to do the same thing, > constructing and matching strings with the pattern above, so encapsulate > the logic in one function. > > Signed-off-by: Bryan O'Donoghue > --- > drivers/media/platform/qcom/camss/camss-vfe.c | 22 ++++++++++++++----- > 1 file changed, 16 insertions(+), 6 deletions(-) > > diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c > index db8f68819ded9..f3cf387e4907e 100644 > --- a/drivers/media/platform/qcom/camss/camss-vfe.c > +++ b/drivers/media/platform/qcom/camss/camss-vfe.c > @@ -431,6 +431,20 @@ void vfe_isr_reset_ack(struct vfe_device *vfe) > complete(&vfe->reset_complete); > } > > +static int vfe_match_clock_names(struct vfe_device *vfe, > + struct camss_clock *clock) > +{ > + char vfe_name[6]; /* vfeXX\0 */ > + char vfe_lite_name[11]; /* vfe_liteXX\0 */ > + > + snprintf(vfe_name, sizeof(vfe_name), "vfe%d", vfe->id); > + snprintf(vfe_lite_name, sizeof(vfe_lite_name), "vfe_lite%d", vfe->id); > + > + return (!strcmp(clock->name, vfe_name) || > + !strcmp(clock->name, vfe_lite_name) || > + !strcmp(clock->name, "vfe_lite")); > +} I'm getting this compiler warning: drivers/media/platform/qcom/camss/camss-vfe.c: In function 'vfe_match_clock_names': drivers/media/platform/qcom/camss/camss-vfe.c:483:52: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=] 483 | snprintf(vfe_name, sizeof(vfe_name), "vfe%d", vfe->id); | ^ Since vfe->id is a u8 I would just increase both the vfe_name and vfe_lite_name sizes by 1. Regards, Hans > + > /* > * vfe_set_clock_rates - Calculate and set clock rates on VFE module > * @vfe: VFE device > @@ -454,9 +468,7 @@ static int vfe_set_clock_rates(struct vfe_device *vfe) > for (i = 0; i < vfe->nclocks; i++) { > struct camss_clock *clock = &vfe->clock[i]; > > - if (!strcmp(clock->name, "vfe0") || > - !strcmp(clock->name, "vfe1") || > - !strcmp(clock->name, "vfe_lite")) { > + if (vfe_match_clock_names(vfe, clock)) { > u64 min_rate = 0; > long rate; > > @@ -537,9 +549,7 @@ static int vfe_check_clock_rates(struct vfe_device *vfe) > for (i = 0; i < vfe->nclocks; i++) { > struct camss_clock *clock = &vfe->clock[i]; > > - if (!strcmp(clock->name, "vfe0") || > - !strcmp(clock->name, "vfe1") || > - !strcmp(clock->name, "vfe_lite")) { > + if (vfe_match_clock_names(vfe, clock)) { > u64 min_rate = 0; > unsigned long rate; >