diff mbox series

[v2,1/2] include: linux: siox: more for declaring siox drivers

Message ID 1560854427-27537-2-git-send-email-info@metux.net
State New
Headers show
Series [v2,1/2] include: linux: siox: more for declaring siox drivers | expand

Commit Message

Enrico Weigelt, metux IT consult June 18, 2019, 10:40 a.m. UTC
From: Enrico Weigelt <info@metux.net>

Add more helper macros for trivial driver init cases, similar to the
already existing module_platform_driver() or module_i2c_driver().

This helps to reduce driver init boilerplate.

Signed-off-by: Enrico Weigelt <info@metux.net>
---
 include/linux/siox.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Uwe Kleine-König June 18, 2019, 4:17 p.m. UTC | #1
Hello,

Cc: += Thorsten Scherer

On Tue, Jun 18, 2019 at 12:40:26PM +0200, Enrico Weigelt, metux IT consult wrote:
> From: Enrico Weigelt <info@metux.net>
> 
> Add more helper macros for trivial driver init cases, similar to the
> already existing module_platform_driver() or module_i2c_driver().
> 
> This helps to reduce driver init boilerplate.
> 
> Signed-off-by: Enrico Weigelt <info@metux.net>

I like the change. Just noticed that the Subject line is a bit strange
though. if "more for" is proper English then it's news to me. I'd write:

	siox: add helper macro to simplify driver registration

> ---
>  include/linux/siox.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/linux/siox.h b/include/linux/siox.h
> index d79624e..d53b2b2 100644
> --- a/include/linux/siox.h
> +++ b/include/linux/siox.h
> @@ -75,3 +75,12 @@ static inline void siox_driver_unregister(struct siox_driver *sdriver)
>  {
>  	return driver_unregister(&sdriver->driver);
>  }
> +
> +/* module_siox_driver() - Helper macro for drivers that don't do

I'd prefer /* on a separate line as documented in
Documentation/process/coding-style.rst (for non-net code).

> + * anything special in module init/exit.  This eliminates a lot of
> + * boilerplate.  Each module may only use this macro once, and
> + * calling it replaces module_init() and module_exit()
> + */
> +#define module_siox_driver(__siox_driver) \
> +	module_driver(__siox_driver, siox_driver_register, \
> +			siox_driver_unregister)
> -- 

Sorry I didn't notice these two things in the first round already.

Best regards
Uwe
Enrico Weigelt, metux IT consult June 24, 2019, 5:33 a.m. UTC | #2
On 18.06.19 18:17, Uwe Kleine-König wrote:

Hi,

> I like the change. Just noticed that the Subject line is a bit strange> though. if "more for" is proper English then it's news to me. I'd
write:> > 	siox: add helper macro to simplify driver registration
Good point, seems I've must have been totally under-coffeined, and
some words on nasty phone interrupts :o

I'll fix that.

<snip>

>> diff --git a/include/linux/siox.h b/include/linux/siox.h>> index d79624e..d53b2b2 100644>> --- a/include/linux/siox.h>> +++
b/include/linux/siox.h>> @@ -75,3 +75,12 @@ static inline void
siox_driver_unregister(struct siox_driver *sdriver)>>  {>>  	return
driver_unregister(&sdriver->driver);>>  }>> +>> +/* module_siox_driver()
- Helper macro for drivers that don't do> > I'd prefer /* on a separate
line as documented in> Documentation/process/coding-style.rst (for
non-net code).
Done.

Do we have a tool to check for that ? checkpatch doesn't seem to care
about it.

>> + * anything special in module init/exit.  This eliminates a lot of>> + * boilerplate.  Each module may only use this macro once, and>> + *
calling it replaces module_init() and module_exit()>> + */>> +#define
module_siox_driver(__siox_driver) \>> +	module_driver(__siox_driver,
siox_driver_register, \>> +			siox_driver_unregister)>> -- > > Sorry I
didn't notice these two things in the first round already.
No problem, that's why we have multiple rounds :)


I'll send v3 in a few minutes ...


--mtx
diff mbox series

Patch

diff --git a/include/linux/siox.h b/include/linux/siox.h
index d79624e..d53b2b2 100644
--- a/include/linux/siox.h
+++ b/include/linux/siox.h
@@ -75,3 +75,12 @@  static inline void siox_driver_unregister(struct siox_driver *sdriver)
 {
 	return driver_unregister(&sdriver->driver);
 }
+
+/* module_siox_driver() - Helper macro for drivers that don't do
+ * anything special in module init/exit.  This eliminates a lot of
+ * boilerplate.  Each module may only use this macro once, and
+ * calling it replaces module_init() and module_exit()
+ */
+#define module_siox_driver(__siox_driver) \
+	module_driver(__siox_driver, siox_driver_register, \
+			siox_driver_unregister)