Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fpga: dfl: drop unneeded get_device() and put_device() of feature device

The feature device data was originally stored as platform data, hence
the memory allocation was tied to the lifetime of the feature device.
Now that the feature device data is tied to the lifetime of the DFL PCIe
FPGA device instead, get_device() and put_device() are no longer needed.

Signed-off-by: Peter Colberg <peter.colberg@intel.com>
Reviewed-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Reviewed-by: Basheer Ahmed Muddebihal <basheer.ahmed.muddebihal@linux.intel.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20241120011035.230574-18-peter.colberg@intel.com
Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>

authored by

Peter Colberg and committed by
Xu Yilun
ff1f06b6 57146d94

+5 -18
-2
drivers/fpga/dfl-fme-br.c
··· 85 85 86 86 fpga_bridge_unregister(br); 87 87 88 - if (priv->port_fdata) 89 - put_device(&priv->port_fdata->dev->dev); 90 88 if (priv->port_ops) 91 89 dfl_fpga_port_ops_put(priv->port_ops); 92 90 }
+5 -11
drivers/fpga/dfl.c
··· 734 734 { 735 735 mutex_lock(&cdev->lock); 736 736 list_add(&fdata->node, &cdev->port_dev_list); 737 - get_device(&fdata->dev->dev); 738 737 mutex_unlock(&cdev->lock); 739 738 } 740 739 ··· 1644 1645 platform_device_put(port_dev); 1645 1646 1646 1647 list_del(&fdata->node); 1647 - put_device(&port_dev->dev); 1648 1648 } 1649 1649 mutex_unlock(&cdev->lock); 1650 1650 ··· 1675 1677 struct dfl_feature_dev_data *fdata; 1676 1678 1677 1679 list_for_each_entry(fdata, &cdev->port_dev_list, node) { 1678 - if (match(fdata, data) && get_device(&fdata->dev->dev)) 1680 + if (match(fdata, data)) 1679 1681 return fdata; 1680 1682 } 1681 1683 ··· 1726 1728 1727 1729 if (!device_is_registered(&fdata->dev->dev)) { 1728 1730 ret = -EBUSY; 1729 - goto put_dev_exit; 1731 + goto unlock_exit; 1730 1732 } 1731 1733 1732 1734 mutex_lock(&fdata->lock); 1733 1735 ret = dfl_feature_dev_use_begin(fdata, true); 1734 1736 mutex_unlock(&fdata->lock); 1735 1737 if (ret) 1736 - goto put_dev_exit; 1738 + goto unlock_exit; 1737 1739 1738 1740 platform_device_del(fdata->dev); 1739 1741 cdev->released_port_num++; 1740 - put_dev_exit: 1741 - put_device(&fdata->dev->dev); 1742 1742 unlock_exit: 1743 1743 mutex_unlock(&cdev->lock); 1744 1744 return ret; ··· 1767 1771 1768 1772 if (device_is_registered(&fdata->dev->dev)) { 1769 1773 ret = -EBUSY; 1770 - goto put_dev_exit; 1774 + goto unlock_exit; 1771 1775 } 1772 1776 1773 1777 ret = platform_device_add(fdata->dev); 1774 1778 if (ret) 1775 - goto put_dev_exit; 1779 + goto unlock_exit; 1776 1780 1777 1781 mutex_lock(&fdata->lock); 1778 1782 dfl_feature_dev_use_end(fdata); 1779 1783 mutex_unlock(&fdata->lock); 1780 1784 1781 1785 cdev->released_port_num--; 1782 - put_dev_exit: 1783 - put_device(&fdata->dev->dev); 1784 1786 unlock_exit: 1785 1787 mutex_unlock(&cdev->lock); 1786 1788 return ret;
-5
drivers/fpga/dfl.h
··· 551 551 dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_info *info); 552 552 void dfl_fpga_feature_devs_remove(struct dfl_fpga_cdev *cdev); 553 553 554 - /* 555 - * need to drop the device reference with put_device() after use port platform 556 - * device returned by __dfl_fpga_cdev_find_port and dfl_fpga_cdev_find_port 557 - * functions. 558 - */ 559 554 struct dfl_feature_dev_data * 560 555 __dfl_fpga_cdev_find_port_data(struct dfl_fpga_cdev *cdev, void *data, 561 556 int (*match)(struct dfl_feature_dev_data *, void *));