From nobody Wed Sep 17 05:51:34 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4381EC4332F for ; Fri, 23 Dec 2022 05:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230108AbiLWF4s (ORCPT ); Fri, 23 Dec 2022 00:56:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbiLWF4p (ORCPT ); Fri, 23 Dec 2022 00:56:45 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FECA62EF for ; Thu, 22 Dec 2022 21:56:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671774960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xglbcwBtHUzE7Svvg1D0riaViqFayLrBuEpuMnhx0Os=; b=XdlTGVxW+l+jL/D5wFjjOyPKjiDzBnMDQ4RD7MfGP4ixcGKkoLfRvW+YhAI+SKo/p/8jyl VMND92Ecptunn1uVnaSWxL1T2MyueHpZjSmd/PXt/niysZu4J0rbdi9wd2Ltt20J0lCyJr shj61LOKCJGA1X1HfDYtrZV/zvasjZU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-153-9wZ9O01HPuOwAkPNvArVfw-1; Fri, 23 Dec 2022 00:55:57 -0500 X-MC-Unique: 9wZ9O01HPuOwAkPNvArVfw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C2C1518811F4; Fri, 23 Dec 2022 05:55:56 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-204.pek2.redhat.com [10.72.12.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30D0D40C2064; Fri, 23 Dec 2022 05:55:53 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com Cc: sgarzare@redhat.com, eperezma@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 1/4] vdpa_sim: switch to use __vdpa_alloc_device() Date: Fri, 23 Dec 2022 13:55:45 +0800 Message-Id: <20221223055548.27810-2-jasowang@redhat.com> In-Reply-To: <20221223055548.27810-1-jasowang@redhat.com> References: <20221223055548.27810-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows us to control the allocation size of the structure. Reviewed-by: Stefano Garzarella Acked-by: Eugenio P=C3=A9rez Signed-off-by: Jason Wang --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_= sim.c index cb88891b44a8..118dbc8e5d67 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -249,6 +249,7 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr = *dev_attr, const struct vdpa_dev_set_config *config) { const struct vdpa_config_ops *ops; + struct vdpa_device *vdpa; struct vdpasim *vdpasim; struct device *dev; int i, ret =3D -ENOMEM; @@ -266,14 +267,16 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_att= r *dev_attr, else ops =3D &vdpasim_config_ops; =20 - vdpasim =3D vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, - dev_attr->ngroups, dev_attr->nas, - dev_attr->name, false); - if (IS_ERR(vdpasim)) { - ret =3D PTR_ERR(vdpasim); + vdpa =3D __vdpa_alloc_device(NULL, ops, + dev_attr->ngroups, dev_attr->nas, + sizeof(struct vdpasim), + dev_attr->name, false); + if (IS_ERR(vdpa)) { + ret =3D PTR_ERR(vdpa); goto err_alloc; } =20 + vdpasim =3D vdpa_to_sim(vdpa); vdpasim->dev_attr =3D *dev_attr; INIT_WORK(&vdpasim->work, dev_attr->work_fn); spin_lock_init(&vdpasim->lock); --=20 2.25.1