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 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 34205D43377 for ; Thu, 7 Nov 2024 16:27:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D47D110E883; Thu, 7 Nov 2024 16:27:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="sgq9DuN9"; dkim-atps=neutral Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB61610E883; Thu, 7 Nov 2024 16:27:10 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id E2BFAA41F1A; Thu, 7 Nov 2024 16:25:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B3AFC4CECC; Thu, 7 Nov 2024 16:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730996829; bh=RaF/yzDkwC/xI3JHS3wDYezLNgto4gJR15z4QCLcIec=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=sgq9DuN999fo+gF31O1Sog3B6QwMV6OvcPe7VPqi8sJ1TCzU/W1Ez/tliuLSn6HZv H6WJr617Z9ho3vOtVhPzMb0TyqS+gb2SI7mq/C0wytQj+BYrK8SHegywRApVWEjefm VrP+Uq41/kYqyiwmALEKXPYG2sF+9dXoP558MEULT3X9CJ2qlfOgYo5XQQ/akQ/Li+ 8PC//m2NPppcQqPE5AwaE9VZUm8GEStHJrNdsbBXQj3zX2/Uw70Eqzdl18ZXk0ykpu Nv3hNeVLx2kThS8Iy5jvLz2TwdYaK/p8look0JzKdaIO94mqldL4oshBd2UJ53q8QV LBGXXQk7Ujmww== Date: Thu, 7 Nov 2024 10:27:07 -0600 From: Bjorn Helgaas To: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Bjorn Helgaas , Srinivas Kandagatla , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Alex Deucher , Christian =?utf-8?B?S8O2bmln?= , Xinhui Pan , David Airlie , Simona Vetter , Dennis Dalessandro , Jason Gunthorpe , Leon Romanovsky , Tudor Ambarus , Pratyush Yadav , Michael Walle , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Naveen Krishna Chatradhi , Carlos Bilbao , Hans de Goede , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , "David E. Box" , "James E.J. Bottomley" , "Martin K. Petersen" , Richard Henderson , Matt Turner , Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Logan Gunthorpe , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Dan Williams , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-cxl@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-mtd@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org Subject: Re: [PATCH v2 03/10] PCI/sysfs: Calculate bin_attribute size through bin_size() Message-ID: <20241107162707.GA1618544@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20241103-sysfs-const-bin_attr-v2-3-71110628844c@weissschuh.net> X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" On Sun, Nov 03, 2024 at 05:03:32PM +0000, Thomas Weißschuh wrote: > Stop abusing the is_bin_visible() callback to calculate the attribute > size. Instead use the new, dedicated bin_size() one. > > Signed-off-by: Thomas Weißschuh Acked-by: Bjorn Helgaas Thanks for doing this! > --- > drivers/pci/pci-sysfs.c | 28 ++++++++++++++++------------ > 1 file changed, 16 insertions(+), 12 deletions(-) > > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > index 5d0f4db1cab78674c5e5906f321bf7a57b742983..040f01b2b999175e8d98b05851edc078bbabbe0d 100644 > --- a/drivers/pci/pci-sysfs.c > +++ b/drivers/pci/pci-sysfs.c > @@ -818,21 +818,20 @@ static struct bin_attribute *pci_dev_config_attrs[] = { > NULL, > }; > > -static umode_t pci_dev_config_attr_is_visible(struct kobject *kobj, > - struct bin_attribute *a, int n) > +static size_t pci_dev_config_attr_bin_size(struct kobject *kobj, > + const struct bin_attribute *a, > + int n) > { > struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); > > - a->size = PCI_CFG_SPACE_SIZE; > if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) > - a->size = PCI_CFG_SPACE_EXP_SIZE; > - > - return a->attr.mode; > + return PCI_CFG_SPACE_EXP_SIZE; > + return PCI_CFG_SPACE_SIZE; > } > > static const struct attribute_group pci_dev_config_attr_group = { > .bin_attrs = pci_dev_config_attrs, > - .is_bin_visible = pci_dev_config_attr_is_visible, > + .bin_size = pci_dev_config_attr_bin_size, > }; > > /* > @@ -1330,21 +1329,26 @@ static umode_t pci_dev_rom_attr_is_visible(struct kobject *kobj, > struct bin_attribute *a, int n) > { > struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); > - size_t rom_size; > > /* If the device has a ROM, try to expose it in sysfs. */ > - rom_size = pci_resource_len(pdev, PCI_ROM_RESOURCE); > - if (!rom_size) > + if (!pci_resource_end(pdev, PCI_ROM_RESOURCE)) > return 0; > > - a->size = rom_size; > - > return a->attr.mode; > } > > +static size_t pci_dev_rom_attr_bin_size(struct kobject *kobj, > + const struct bin_attribute *a, int n) > +{ > + struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); > + > + return pci_resource_len(pdev, PCI_ROM_RESOURCE); > +} > + > static const struct attribute_group pci_dev_rom_attr_group = { > .bin_attrs = pci_dev_rom_attrs, > .is_bin_visible = pci_dev_rom_attr_is_visible, > + .bin_size = pci_dev_rom_attr_bin_size, > }; > > static ssize_t reset_store(struct device *dev, struct device_attribute *attr, > > -- > 2.47.0 >