diff mbox series

[v2,06/26] driver core: fw_devlink: Introduce fw_devlink_set_device()

Message ID 20250507071315.394857-7-herve.codina@bootlin.com
State New
Headers show
Series lan966x pci device: Add support for SFPs | expand

Commit Message

Herve Codina May 7, 2025, 7:12 a.m. UTC
Setting fwnode->dev is specific to fw_devlink.

In order to avoid having a direct 'fwnode->dev = dev;' in several
place in the kernel, introduce fw_devlink_set_device() helper to perform
this operation.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 include/linux/fwnode.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Herve Codina May 19, 2025, 2:27 p.m. UTC | #1
Hi Andy,

On Wed, 7 May 2025 18:02:40 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Wed, May 07, 2025 at 09:12:48AM +0200, Herve Codina wrote:
> > Setting fwnode->dev is specific to fw_devlink.
> > 
> > In order to avoid having a direct 'fwnode->dev = dev;' in several
> > place in the kernel, introduce fw_devlink_set_device() helper to perform
> > this operation.  
> 
> Makes sense, can you also mark that field as __private? So sparse can catch
> the abusers up.
> 

I didn't know about __private tag and related ACCESS_PRIVATE().
Indeed, It makes perfect sense.

I will add it in next iteration.

Thanks for pointing out.

Best regards,
Hervé
diff mbox series

Patch

diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index af76de93bee2..9fc4427b1004 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -226,4 +226,10 @@  void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode);
 void fw_devlink_refresh_fwnode(struct fwnode_handle *fwnode);
 bool fw_devlink_is_strict(void);
 
+static inline void fw_devlink_set_device(struct fwnode_handle *fwnode,
+					 struct device *dev)
+{
+	fwnode->dev = dev;
+}
+
 #endif