From nobody Fri Apr 17 08:43:51 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.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 9F20C36F41A for ; Mon, 23 Feb 2026 20:00:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771876850; cv=none; b=QcAoI6uMEvCfHm9BISPVCgWoCjkOXAQb+lNKtBHf0ak/9TBP7KwYnZBMYIsUBpGdsz18ZHog+8oXoEDFcLBSn7BGncRYISG1cbX3fZe4USyVeK6R+9zqjNuvPzS63S354jj9/0ZJGwWOwFc5r6U/L3VdOjEWetKMdl1DAcI07LA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771876850; c=relaxed/simple; bh=PKmdU+qG447jbsphDFAhQkfsaIYc6767WVx1E78yQA4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TVOyCA9ovNPQoL+HyyOcB4FxZEU5pwXFala7iroSDmgywNKBuOv/b5NVgm/rR/2tZADAVOgzITKJeHx509TJvUtvewHKCQvT7gla1/6Byb9GbF0ULpGB8OaIRSeoqkxN5JUSrVAFkeE3AqCG9h+t/lECd1b+UpHVWnW1RRrpNQw= 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=j+Iqd/Us; arc=none smtp.client-ip=209.85.221.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="j+Iqd/Us" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-43626796202so4052279f8f.3 for ; Mon, 23 Feb 2026 12:00:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771876848; x=1772481648; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yv125EGKHRfysJ3X3Lulm/FjdhCw6fk0IxMK5xEGXqs=; b=j+Iqd/UsvQ/MZBNEbtw/ktVUtv0W7LIPz9TjElHVVv1o8QYLZzK90QsDkzJAoe9R0V crxPu9Py7iEJqkXN+7mKOEV9+HyxJKhVPk+8pxxADxz591A5nNQwWLZouSnOE3WxzV4o 3qSgXv9AeJFMGOw8OOymau1H4Y8kxvXD0m4gHpSV90/TMWnxfVS9Xxe1KX3X9tpGptoM LWybT4Kyg+am1SGPiUEbezo7iCMZme8rYBhIm9SqTAPItNenBw4J3M5HRI8gI5hC58aJ fJECa770ch16hkNxQ8D7JW03j+Zq46JT9rwJwU7Qu0ppexWz8Dl0LsWEPWQrI00zQQ/x f+IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771876848; x=1772481648; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yv125EGKHRfysJ3X3Lulm/FjdhCw6fk0IxMK5xEGXqs=; b=YS5gVrR6gec/IM3z75XF0FaG5B1FoYlDvN1pCdMqoZIMg12/t9p4lmbObJRjn/dDmg WPlOUVWhOE4f/nRhg/vg5waXEdbrZEBGDGS8bisVAInW3fuP1+8jTn4ugs2YjsnjGAHd 1pcJCyjKOpn7ES43F9xTi6B+au0F5ZzvsVDjbqjdY541e82S+ss62ZyFutdhaRhDSHz8 TjFbZKyRSuyIqSDdlLgE0HRAE6OevPDxBSRLheqrrafbkSjMW2Ti0nVAHHUGgQTRzTiB tSxGJVYaeii+65n16imVI1w0bplqe5V3396Jpg0dgl4iL7qSKuiHj/ZrLQ93rGwl4BWn GShA== X-Forwarded-Encrypted: i=1; AJvYcCWOnqtyOJBQzvtJOkqHeXHiyJRjFJgioTgYTSkB4go1jWcoQViWMsaAcZYQHXQx9dnSMMX6mHHFdrsSDws=@vger.kernel.org X-Gm-Message-State: AOJu0YzWGQyFsXqrcXW761nZHugv8I48vhbydR/vNNJikaxV5ENmusOJ CZnf9BWhXxIVoEOR9rw51Qu4NQquiKIxp9TG+57gmAbnv6a0qo0Ffro7 X-Gm-Gg: ATEYQzxZEyPeF0QS3cbn/tjdHUW0WKoY8ARV5LWgCN8dra8g+zLLC4e6tLvUPWQhdXa aJtDMYCxTxsZZ4eCHNwBbP5y+knI/Y4kwVOMAT0Yt8IXQ57jgGjx6CRXE4gUxeywXl5v0E3Kvk3 80EBcbzknomAEBfM34bHt4WeMZMlv/RUcoVyIJ5e6d3QAAnmLnBNd7AjE76pBE6YweZ8GTct7VI 5Nln9FOJVA0hCyMNrGzyFbptmEzAvxCzm5YG5iaFd3Nx+n6tnGFz6ANjQD9ZByGt3OqQ7Gs7awB 8z2bVyynu5ukMV50XvTS30U1l2Q80fpf5fxlGLlJla1lg1NrYUQ4DuH77u+Kdvd95B8ko6Ujxzk 0viGlsDdfp4aWkYfOS5JjJMcVZZa2usW+pmwGMARXpmycpwxmyFk2lA9w2GMcBvOn8zHCv+gdaM OiytjAB4b+PBrLcHP7NZV2swoNZTH5hoF4IR8/kjw= X-Received: by 2002:a05:6000:1a8a:b0:436:3563:499c with SMTP id ffacd0b85a97d-4396f14c9bfmr15966473f8f.8.1771876847774; Mon, 23 Feb 2026 12:00:47 -0800 (PST) Received: from localhost.localdomain ([83.231.69.9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43970c00e8bsm17975577f8f.15.2026.02.23.12.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 12:00:45 -0800 (PST) From: "Jose A. Perez de Azpillaga" To: vaibhav.sr@gmail.com, mgreer@animalcreek.com Cc: johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] staging: greybus: move topology allocation to codec probe Date: Mon, 23 Feb 2026 20:59:35 +0100 Message-ID: <20260223195939.71151-1-azpijr@gmail.com> X-Mailer: git-send-email 2.53.0 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" The FIXME in gb_audio_probe noted that memory allocation for the topology should happen within the codec driver rather than the greybus helper. Move the size-check and kzalloc from audio_gb.c to audio_module.c and update the function signature of gb_audio_gb_get_topology to accept the pointer. This clarifies ownership of the allocated memory. Signed-off-by: Jose A. Perez de Azpillaga --- drivers/staging/greybus/audio_gb.c | 33 +++----------------------- drivers/staging/greybus/audio_module.c | 29 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/drivers/staging/greybus/audio_gb.c b/drivers/staging/greybus/a= udio_gb.c index 9d8994fdb41a..4037b3bf1e9f 100644 --- a/drivers/staging/greybus/audio_gb.c +++ b/drivers/staging/greybus/audio_gb.c @@ -8,38 +8,11 @@ #include #include "audio_codec.h" -/* TODO: Split into separate calls */ int gb_audio_gb_get_topology(struct gb_connection *connection, - struct gb_audio_topology **topology) + struct gb_audio_topology *topology) { - struct gb_audio_get_topology_size_response size_resp; - struct gb_audio_topology *topo; - u16 size; - int ret; - - ret =3D gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE, - NULL, 0, &size_resp, sizeof(size_resp)); - if (ret) - return ret; - - size =3D le16_to_cpu(size_resp.size); - if (size < sizeof(*topo)) - return -ENODATA; - - topo =3D kzalloc(size, GFP_KERNEL); - if (!topo) - return -ENOMEM; - - ret =3D gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY, NULL, 0, - topo, size); - if (ret) { - kfree(topo); - return ret; - } - - *topology =3D topo; - - return 0; + return gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY, + NULL, 0, topology, le16_to_cpu(topology->size)); } EXPORT_SYMBOL_GPL(gb_audio_gb_get_topology); diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greyb= us/audio_module.c index 12c376c477b3..8efb720c3f30 100644 --- a/drivers/staging/greybus/audio_module.c +++ b/drivers/staging/greybus/audio_module.c @@ -240,6 +240,8 @@ static int gb_audio_probe(struct gb_bundle *bundle, struct gbaudio_data_connection *dai, *_dai; int ret, i; struct gb_audio_topology *topology; + struct gb_audio_get_topology_size_response size_resp; + u16 size; /* There should be at least one Management and one Data cport */ if (bundle->num_cports < 2) @@ -304,13 +306,30 @@ static int gb_audio_probe(struct gb_bundle *bundle, } gbmodule->dev_id =3D gbmodule->mgmt_connection->intf->interface_id; - /* - * FIXME: malloc for topology happens via audio_gb driver - * should be done within codec driver itself - */ - ret =3D gb_audio_gb_get_topology(gbmodule->mgmt_connection, &topology); + ret =3D gb_operation_sync(gbmodule->mgmt_connection, + GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE, NULL, 0, + &size_resp, sizeof(size_resp)); + if (ret) + goto disable_connection; + + size =3D le16_to_cpu(size_resp.size); + if (size < sizeof(*topology)) { + ret =3D -ENODATA; + goto disable_connection; + } + + topology =3D kzalloc(size, GFP_KERNEL); + if (!topology) { + ret =3D -ENOMEM; + goto disable_connection; + } + + topology->size =3D cpu_to_le16(size); + + ret =3D gb_audio_gb_get_topology(gbmodule->mgmt_connection, topology); if (ret) { dev_err(dev, "%d:Error while fetching topology\n", ret); + kfree(topology); goto disable_connection; } -- 2.53.0