summaryrefslogtreecommitdiff
path: root/drivers/base/platform-msi.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2021-12-11 01:18:58 +0300
committerThomas Gleixner <tglx@linutronix.de>2021-12-17 00:16:38 +0300
commit077aeadb6cacdee79acff3deb1b31581584fdb9c (patch)
treec41f68c7a26722023123b6c96034917b3e56c8ab /drivers/base/platform-msi.c
parent93296cd1325d1d9afede60202d8833011c9001f2 (diff)
downloadlinux-077aeadb6cacdee79acff3deb1b31581584fdb9c.tar.xz
platform-msi: Allocate MSI device data on first use
Allocate the MSI device data on first invocation of the allocation function for platform MSI private data. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Nishanth Menon <nm@ti.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20211210221813.805529729@linutronix.de
Diffstat (limited to 'drivers/base/platform-msi.c')
-rw-r--r--drivers/base/platform-msi.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c
index f1f0876510a4..3da2688c96ef 100644
--- a/drivers/base/platform-msi.c
+++ b/drivers/base/platform-msi.c
@@ -204,6 +204,8 @@ platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec,
irq_write_msi_msg_t write_msi_msg)
{
struct platform_msi_priv_data *datap;
+ int err;
+
/*
* Limit the number of interrupts to 2048 per device. Should we
* need to bump this up, DEV_ID_SHIFT should be adjusted
@@ -218,6 +220,10 @@ platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec,
return ERR_PTR(-EINVAL);
}
+ err = msi_setup_device_data(dev);
+ if (err)
+ return ERR_PTR(err);
+
/* Already had a helping of MSI? Greed... */
if (!list_empty(dev_to_msi_list(dev)))
return ERR_PTR(-EBUSY);
@@ -229,7 +235,7 @@ platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec,
datap->devid = ida_simple_get(&platform_msi_devid_ida,
0, 1 << DEV_ID_SHIFT, GFP_KERNEL);
if (datap->devid < 0) {
- int err = datap->devid;
+ err = datap->devid;
kfree(datap);
return ERR_PTR(err);
}