From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 217C04A2607 for ; Mon, 31 Aug 2026 18:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788200360; cv=none; b=Z714M9tcZHjsdAx1osWazSEO+RJlT7hYH73Ero/qvFDKB83HrY+vClNCSkB7Cd9JBrDYejr5Our80wL9Uwpfo43GcBbatZtmwo/XoCLdcViB/2CBaTpGr65/vqfToCIsFajcfP0hidgO6w1cF+J8FIOEMQ7pr2jx+lRqki7U7IE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788200360; c=relaxed/simple; bh=FztbYciuUu/xBl4EtmM8UJG3T8usV0MXM/d6deYWyo0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mVXqE61ND4eXqx0M1HQD7pY3xFHCfK7Ah4OFv5kbebdvRVeoCHF2FbrWFbPUkNhfhbpYQtC+jbMC9GSLukcJtuY7gqxsc3UcCpGmkhvaPdY6ED/UrHywAlzsdolrzOu578dH0WJneiDgahb8B7fmBQ3m5UqrnHkKr7gPUgrBprw= 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=rM1HRszv; arc=none smtp.client-ip=209.85.128.43 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="rM1HRszv" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4957eefd361so41845e9.1 for ; Mon, 31 Aug 2026 11:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788200357; x=1788805157; 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:content-type; bh=fsl1K9EFVIiMJCG+9Qgue9j3QGOqyAit8togwWpGNDY=; b=rM1HRszvxblm7QOtDWz4Xeqi7ZKigWiihmbhVoCxGq8NdxgqdZjjAOAob+NrZ40UTy czCuZG+Wac0wvTfHBuHfPCevY6d9tlRR8s+uvMXgCKGfNVRlQZQ92POoC6hNJNGjE77F UK9BSv8CTrOkgTMdmKT/+RZhzgKv/FZ+CpMFx3eMx0AsVjK9VnIoJJ/Vy1sVrlLf0rt+ jJInhcnWMLo8/f3mrpvfZNCZgo0f6almUfLRQB2KlTW2yinLRpVaT69bSxTM+Nf8alf1 KjWkHbbtPErMLIycC/Qt+bYORIdldolrdw0/dB0LiUxZnOTmlst/l7hbCuYVjR5Ng5RM LLSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788200357; x=1788805157; 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:content-type; bh=fsl1K9EFVIiMJCG+9Qgue9j3QGOqyAit8togwWpGNDY=; b=Bu7v7pYhDih1UiH/vEmvdu+fx/ooDuJDSY23g3VyjJiubT0a5jKq93o3k5UVQsV+9n Z+3k6HufShsOeNGglet3rbDJlO8dunUy1j3l4ZTH2h/ERt4e6OVdrceHZHkO13JNjVyo j4tAwRU0OspBNYyZ/uMSPNY1uvdvNdmn9Or/88sk4Nk6KOwqCwig4neoyv5IX+qWeQxx 8/uRAxhBDRNeDUT7y+ofOeNGE3p4QPzsYcduBLCaSfqLnXB4GvKG6U0eBWGzfFg7jBgz F93D50LDW/8gqGvfVbBCbT35+qfxc3CzMP7SLKjMx3LSg9WK9JhFAr7jzAqFHlyOD6V7 5QbQ== X-Forwarded-Encrypted: i=1; AHgh+RoJAmr3m1xvM4bxwz7Pqn757+cGviMB/ajjaPHYmb/fQJYl991cdrgFxxSttTJw8T945a0XFyrvahZ2ew==@vger.kernel.org X-Gm-Message-State: AFuF++mS/NVAp++2scLNRNj6AfUQqPI1WJ7gJ/n721qkZWeN6fZB1I0m gMM38eCrnQCMTFRzgeMV5COMZQBM4E/4tZkvSgv8s781J+8R+UeLalKj X-Gm-Gg: AR+sD11JHkTEzsjwrTe4l5HR+l2iAU0uNSN8aBg6bX4pZcFdY4RKUy1QTqwp8b1/vN0 Sn3hefxfBGyCuYFmGJu9slJpZ7CASs+dVUqQRvbsunWhuHAT7N900bAuGR0jCOKQd1QfrHzyOgV MV30AgZBHk8kgv2Db90PbfZ+Tt8AIS+vK2ykro98Dsv4n4BZ56oTjCP2i2/1rur+rAXJBys1k1e 8lygL5Y5wFE1DDU9+sCs9o26bGEVV/V4YiGOuwgn7CnV8CJMBdMGUevxnrkFo+N6Mpdev9/S5KK zswisGXqzPrLWHt3bpKUlG+rIdW0lZKn4Cq84jCSkAZB2zAndCl6AXzbfyOOEPD+FNg7Yi4YTmR ZH8DLe4d9yqnRB7alixTHBC+MhJH48fovNmUVKKf0perXdbkmYjZGE1vSsgYK3zfTeZZ5ejoMll kX57XULh7k0P/Aneg9b6DKzC8VZuJFlAokYPuEdDQ8kZ3xaXrc++aMJSvFbjtUUGuJkcRlWF6g1 9VhMdT1Cxsg X-Received: by 2002:a05:600c:4e86:b0:499:db6d:bc97 with SMTP id 5b1f17b1804b1-49b91bd43a7mr385786455e9.0.1788200357210; Mon, 31 Aug 2026 11:19:17 -0700 (PDT) Received: from localhost.localdomain ([2001:b07:5d3a:fe75:a74b:bc2a:bdfb:30ff]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cdce3e4e7sm9041965e9.9.2026.08.31.11.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 11:19:16 -0700 (PDT) From: Fernando Rimoli To: Sakari Ailus , Daniel Scally , linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Arsalan Naeem , Jakob Berg Jespersen , linux-kernel@vger.kernel.org, Fernando Rimoli Subject: [PATCH v4 4/6] media: ipu-bridge: Assign endpoint property indices dynamically Date: Mon, 31 Aug 2026 20:18:56 +0200 Message-ID: <20260831181858.325109-5-fernandorimoli11@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260831181858.325109-1-fernandorimoli11@gmail.com> References: <20260720163819.104130-1-fernandorimoli11@gmail.com> <20260831181858.325109-1-fernandorimoli11@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The endpoint property array is populated with hardcoded indices, so a property that is only set conditionally has to be placed at a fixed slot. As the array is NULL-terminated, such a property is silently dropped when an earlier optional slot is left empty: "link-frequencies" is skipped for configs with nr_link_freqs == 0, which would truncate the array before anything following it. Name the endpoint property slots in an enum, size the array accordingly and assign the indices through a bounds-checked running index, as done for the MIPI DisCo for Imaging properties in mipi-disco-img.c. No functional change intended: the same properties are set in the same order. Signed-off-by: Fernando Rimoli --- drivers/media/pci/intel/ipu-bridge.c | 27 ++++++++++++++------------- include/media/ipu-bridge.h | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c index 131c70844..cd3c36d44 100644 --- a/drivers/media/pci/intel/ipu-bridge.c +++ b/drivers/media/pci/intel/ipu-bridge.c @@ -449,6 +449,7 @@ static void ipu_bridge_create_fwnode_properties( struct ipu_bridge *bridge, const struct ipu_sensor_config *cfg) { + unsigned int i = IPU_SENSOR_EP_BUS_TYPE; struct ipu_property_names *names = &sensor->prop_names; struct software_node *nodes = sensor->swnodes; @@ -508,21 +509,21 @@ static void ipu_bridge_create_fwnode_properties( PROPERTY_ENTRY_REF_ARRAY("lens-focus", sensor->vcm_ref); } - sensor->ep_properties[0] = PROPERTY_ENTRY_U32( - sensor->prop_names.bus_type, - V4L2_FWNODE_BUS_TYPE_CSI2_DPHY); - sensor->ep_properties[1] = PROPERTY_ENTRY_U32_ARRAY_LEN( - sensor->prop_names.data_lanes, - bridge->data_lanes, sensor->lanes); - sensor->ep_properties[2] = PROPERTY_ENTRY_REF_ARRAY( - sensor->prop_names.remote_endpoint, - sensor->local_ref); + sensor->ep_properties[IPU_NEXT_EP_PROPERTY(i, NUM_OF)] = + PROPERTY_ENTRY_U32(names->bus_type, + V4L2_FWNODE_BUS_TYPE_CSI2_DPHY); + sensor->ep_properties[IPU_NEXT_EP_PROPERTY(i, NUM_OF)] = + PROPERTY_ENTRY_U32_ARRAY_LEN(names->data_lanes, + bridge->data_lanes, sensor->lanes); + sensor->ep_properties[IPU_NEXT_EP_PROPERTY(i, NUM_OF)] = + PROPERTY_ENTRY_REF_ARRAY(names->remote_endpoint, + sensor->local_ref); if (cfg->nr_link_freqs > 0) - sensor->ep_properties[3] = PROPERTY_ENTRY_U64_ARRAY_LEN( - sensor->prop_names.link_frequencies, - cfg->link_freqs, - cfg->nr_link_freqs); + sensor->ep_properties[IPU_NEXT_EP_PROPERTY(i, NUM_OF)] = + PROPERTY_ENTRY_U64_ARRAY_LEN(names->link_frequencies, + cfg->link_freqs, + cfg->nr_link_freqs); sensor->ipu_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN( sensor->prop_names.data_lanes, diff --git a/include/media/ipu-bridge.h b/include/media/ipu-bridge.h index 16fac7654..61e10cef1 100644 --- a/include/media/ipu-bridge.h +++ b/include/media/ipu-bridge.h @@ -64,6 +64,23 @@ enum ipu_sensor_swnodes { SWNODE_COUNT }; +enum ipu_sensor_ep_props { + IPU_SENSOR_EP_BUS_TYPE, + IPU_SENSOR_EP_DATA_LANES, + IPU_SENSOR_EP_REMOTE_EP, + IPU_SENSOR_EP_LINK_FREQUENCIES, + IPU_SENSOR_EP_NUM_OF, + IPU_SENSOR_EP_NUM_ENTRIES +}; + +/* + * Get the index of the next endpoint property in the property array, with a + * given maximum value. + */ +#define IPU_NEXT_EP_PROPERTY(index, max) \ + (WARN_ON((index) > IPU_SENSOR_EP_##max) ? \ + IPU_SENSOR_EP_##max : (index)++) + /* Data representation as it is in ACPI SSDB buffer */ struct ipu_sensor_ssdb { u8 version; @@ -141,7 +158,7 @@ struct ipu_sensor { const char *vcm_type; struct ipu_property_names prop_names; - struct property_entry ep_properties[5]; + struct property_entry ep_properties[IPU_SENSOR_EP_NUM_ENTRIES]; struct property_entry dev_properties[5]; struct property_entry ipu_properties[3]; struct property_entry ivsc_properties[1]; -- 2.43.0