netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC net-next] generate boilerplate impls such as devlink_resource_register()
@ 2024-07-03 10:13 Przemek Kitszel
  2024-07-04  0:51 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Przemek Kitszel @ 2024-07-03 10:13 UTC (permalink / raw)
  To: Jakub Kicinski, Jiri Pirko; +Cc: netdev@vger.kernel.org

Hi,

I have and idea that boilerplate devlink_ wrappers over devl_ functions
could be generated via short script, with the handcrafted .c code as the
only input. Take for example the following [one line] added to 
devlink/resource.c would replace the whole definition and kdoc, which 
would be placed in the generated file in about the same form as the
current code. This will be applied to all suitable functions of course.

The script will be short, but not so trivial to write it without prior
RFC. For those wondering if I don't have better things to do: yes, but
I have also some awk-time that will not be otherwise spend on more 
serious stuff anyway :)

[one line]
DEVLINK_GEN_SYMBOL_GPL(devlink_resource_register);

[removed part below]

/**
  *	devlink_resource_register - devlink resource register
  *
  *	@devlink: devlink
  *	@resource_name: resource's name
  *	@resource_size: resource's size
  *	@resource_id: resource's id
  *	@parent_resource_id: resource's parent id
  *	@size_params: size parameters
  *
  *	Generic resources should reuse the same names across drivers.
  *	Please see the generic resources list at:
  *	Documentation/networking/devlink/devlink-resource.rst
  *
  *	Context: Takes and release devlink->lock <mutex>.
  */
int devlink_resource_register(struct devlink *devlink,
			      const char *resource_name,
			      u64 resource_size,
			      u64 resource_id,
			      u64 parent_resource_id,
			      const struct devlink_resource_size_params *size_params)
{
	int err;

	devl_lock(devlink);
	err = devl_resource_register(devlink, resource_name, resource_size,
				     resource_id, parent_resource_id, size_params);
	devl_unlock(devlink);
	return err;
}
EXPORT_SYMBOL_GPL(devlink_resource_register);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-04  7:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-03 10:13 [RFC net-next] generate boilerplate impls such as devlink_resource_register() Przemek Kitszel
2024-07-04  0:51 ` Jakub Kicinski
2024-07-04  7:23   ` Przemek Kitszel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).