From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9FB0C433DB for ; Mon, 15 Mar 2021 08:46:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E50164EB7 for ; Mon, 15 Mar 2021 08:46:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229520AbhCOIqC (ORCPT ); Mon, 15 Mar 2021 04:46:02 -0400 Received: from verein.lst.de ([213.95.11.211]:52910 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbhCOIpg (ORCPT ); Mon, 15 Mar 2021 04:45:36 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id B02B468C4E; Mon, 15 Mar 2021 09:45:34 +0100 (CET) Date: Mon, 15 Mar 2021 09:45:34 +0100 From: Christoph Hellwig To: Jason Gunthorpe Cc: Cornelia Huck , kvm@vger.kernel.org, Alex Williamson , "Raj, Ashok" , Dan Williams , Daniel Vetter , Christoph Hellwig , Leon Romanovsky , Max Gurtovoy , Tarun Gupta Subject: Re: [PATCH v2 07/14] vfio/pci: Move VGA and VF initialization to functions Message-ID: <20210315084534.GC29269@lst.de> References: <0-v2-20d933792272+4ff-vfio1_jgg@nvidia.com> <7-v2-20d933792272+4ff-vfio1_jgg@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7-v2-20d933792272+4ff-vfio1_jgg@nvidia.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org > +static int vfio_pci_vf_init(struct vfio_pci_device *vdev) > +{ > + struct pci_dev *pdev = vdev->pdev; > + int ret; > + > + if (!pdev->is_physfn) > + return 0; > + > + vdev->vf_token = kzalloc(sizeof(*vdev->vf_token), GFP_KERNEL); > + if (!vdev->vf_token) > + return -ENOMEM; > +static void vfio_pci_vf_uninit(struct vfio_pci_device *vdev) > +{ > + if (!vdev->vf_token) > + return; I'd really prefer to keep these checks in the callers, as it makes the intent of the code much more clear. Same for the VGA side. But in general I like these helpers.