[02/12] pata_parport: Introduce module_pata_parport_driver macro
Commit Message
Introduce module_pata_parport_driver macro and use it in protocol
drivers to reduce boilerplate code. Remove paride_(un)register
compatibility defines.
Signed-off-by: Ondrej Zary <linux@zary.sk>
---
drivers/ata/pata_parport/aten.c | 13 +------------
drivers/ata/pata_parport/bpck.c | 13 +------------
drivers/ata/pata_parport/bpck6.c | 17 +----------------
drivers/ata/pata_parport/comm.c | 13 +------------
drivers/ata/pata_parport/dstr.c | 13 +------------
drivers/ata/pata_parport/epat.c | 4 ++--
drivers/ata/pata_parport/epia.c | 13 +------------
drivers/ata/pata_parport/fit2.c | 13 +------------
drivers/ata/pata_parport/fit3.c | 13 +------------
drivers/ata/pata_parport/friq.c | 13 +------------
drivers/ata/pata_parport/frpw.c | 13 +------------
drivers/ata/pata_parport/kbic.c | 10 +++++-----
drivers/ata/pata_parport/ktti.c | 13 +------------
drivers/ata/pata_parport/on20.c | 13 +------------
drivers/ata/pata_parport/on26.c | 13 +------------
include/linux/pata_parport.h | 14 +++++++++++---
16 files changed, 31 insertions(+), 170 deletions(-)
Comments
On 2/11/23 5:42 PM, Ondrej Zary wrote:
> Introduce module_pata_parport_driver macro and use it in protocol
> drivers to reduce boilerplate code. Remove paride_(un)register
> compatibility defines.
>
> Signed-off-by: Ondrej Zary <linux@zary.sk>
[...]
> diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c
> index d897e2a28efe..3c358e66db25 100644
> --- a/drivers/ata/pata_parport/bpck6.c
> +++ b/drivers/ata/pata_parport/bpck6.c
> @@ -245,23 +245,8 @@ static struct pi_protocol bpck6 = {
> .release_proto = bpck6_release_proto,
> };
>
> -static int __init bpck6_init(void)
> -{
> - printk(KERN_INFO "bpck6: BACKPACK Protocol Driver V"BACKPACK_VERSION"\n");
> - printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n");
> - if(verbose)
> - printk(KERN_DEBUG "bpck6: verbose debug enabled.\n");
Hm, perhaps should've been removed in a separate patch?
[...]
> diff --git a/drivers/ata/pata_parport/epat.c b/drivers/ata/pata_parport/epat.c
> index 6ce2dee7657f..eb72bcd0c8da 100644
> --- a/drivers/ata/pata_parport/epat.c
> +++ b/drivers/ata/pata_parport/epat.c
> @@ -327,12 +327,12 @@ static int __init epat_init(void)
> #ifdef CONFIG_PARIDE_EPATC8
Hm, this is now called PATA_PARPORT_EPATC8, no?
> epatc8 = 1;
Seems like a dead code?
> #endif
[...]
MBR, Sergey
On Sunday 12 February 2023 13:19:28 Sergey Shtylyov wrote:
> On 2/11/23 5:42 PM, Ondrej Zary wrote:
>
> > Introduce module_pata_parport_driver macro and use it in protocol
> > drivers to reduce boilerplate code. Remove paride_(un)register
> > compatibility defines.
> >
> > Signed-off-by: Ondrej Zary <linux@zary.sk>
> [...]
>
> > diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c
> > index d897e2a28efe..3c358e66db25 100644
> > --- a/drivers/ata/pata_parport/bpck6.c
> > +++ b/drivers/ata/pata_parport/bpck6.c
> > @@ -245,23 +245,8 @@ static struct pi_protocol bpck6 = {
> > .release_proto = bpck6_release_proto,
> > };
> >
> > -static int __init bpck6_init(void)
> > -{
> > - printk(KERN_INFO "bpck6: BACKPACK Protocol Driver V"BACKPACK_VERSION"\n");
> > - printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n");
> > - if(verbose)
> > - printk(KERN_DEBUG "bpck6: verbose debug enabled.\n");
>
> Hm, perhaps should've been removed in a separate patch?
>
> [...]
> > diff --git a/drivers/ata/pata_parport/epat.c b/drivers/ata/pata_parport/epat.c
> > index 6ce2dee7657f..eb72bcd0c8da 100644
> > --- a/drivers/ata/pata_parport/epat.c
> > +++ b/drivers/ata/pata_parport/epat.c
> > @@ -327,12 +327,12 @@ static int __init epat_init(void)
> > #ifdef CONFIG_PARIDE_EPATC8
>
> Hm, this is now called PATA_PARPORT_EPATC8, no?
Yes, it's a bug. This compile-time option should go away completely.
> > epatc8 = 1;
>
> Seems like a dead code?
>
> > #endif
> [...]
>
> MBR, Sergey
>
@@ -147,16 +147,5 @@ static struct pi_protocol aten = {
.log_adapter = aten_log_adapter,
};
-static int __init aten_init(void)
-{
- return paride_register(&aten);
-}
-
-static void __exit aten_exit(void)
-{
- paride_unregister( &aten );
-}
-
MODULE_LICENSE("GPL");
-module_init(aten_init)
-module_exit(aten_exit)
+module_pata_parport_driver(aten);
@@ -462,16 +462,5 @@ static struct pi_protocol bpck = {
.log_adapter = bpck_log_adapter,
};
-static int __init bpck_init(void)
-{
- return paride_register(&bpck);
-}
-
-static void __exit bpck_exit(void)
-{
- paride_unregister(&bpck);
-}
-
MODULE_LICENSE("GPL");
-module_init(bpck_init)
-module_exit(bpck_exit)
+module_pata_parport_driver(bpck);
@@ -245,23 +245,8 @@ static struct pi_protocol bpck6 = {
.release_proto = bpck6_release_proto,
};
-static int __init bpck6_init(void)
-{
- printk(KERN_INFO "bpck6: BACKPACK Protocol Driver V"BACKPACK_VERSION"\n");
- printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n");
- if(verbose)
- printk(KERN_DEBUG "bpck6: verbose debug enabled.\n");
- return paride_register(&bpck6);
-}
-
-static void __exit bpck6_exit(void)
-{
- paride_unregister(&bpck6);
-}
-
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Micro Solutions Inc.");
MODULE_DESCRIPTION("BACKPACK Protocol module, compatible with PARIDE");
module_param(verbose, bool, 0644);
-module_init(bpck6_init)
-module_exit(bpck6_exit)
+module_pata_parport_driver(bpck6);
@@ -206,16 +206,5 @@ static struct pi_protocol comm = {
.log_adapter = comm_log_adapter,
};
-static int __init comm_init(void)
-{
- return paride_register(&comm);
-}
-
-static void __exit comm_exit(void)
-{
- paride_unregister(&comm);
-}
-
MODULE_LICENSE("GPL");
-module_init(comm_init)
-module_exit(comm_exit)
+module_pata_parport_driver(comm);
@@ -218,16 +218,5 @@ static struct pi_protocol dstr = {
.log_adapter = dstr_log_adapter,
};
-static int __init dstr_init(void)
-{
- return paride_register(&dstr);
-}
-
-static void __exit dstr_exit(void)
-{
- paride_unregister(&dstr);
-}
-
MODULE_LICENSE("GPL");
-module_init(dstr_init)
-module_exit(dstr_exit)
+module_pata_parport_driver(dstr);
@@ -327,12 +327,12 @@ static int __init epat_init(void)
#ifdef CONFIG_PARIDE_EPATC8
epatc8 = 1;
#endif
- return paride_register(&epat);
+ return pata_parport_register_driver(&epat);
}
static void __exit epat_exit(void)
{
- paride_unregister(&epat);
+ pata_parport_unregister_driver(&epat);
}
MODULE_LICENSE("GPL");
@@ -301,16 +301,5 @@ static struct pi_protocol epia = {
.log_adapter = epia_log_adapter,
};
-static int __init epia_init(void)
-{
- return paride_register(&epia);
-}
-
-static void __exit epia_exit(void)
-{
- paride_unregister(&epia);
-}
-
MODULE_LICENSE("GPL");
-module_init(epia_init)
-module_exit(epia_exit)
+module_pata_parport_driver(epia);
@@ -136,16 +136,5 @@ static struct pi_protocol fit2 = {
.log_adapter = fit2_log_adapter,
};
-static int __init fit2_init(void)
-{
- return paride_register(&fit2);
-}
-
-static void __exit fit2_exit(void)
-{
- paride_unregister(&fit2);
-}
-
MODULE_LICENSE("GPL");
-module_init(fit2_init)
-module_exit(fit2_exit)
+module_pata_parport_driver(fit2);
@@ -196,16 +196,5 @@ static struct pi_protocol fit3 = {
.log_adapter = fit3_log_adapter,
};
-static int __init fit3_init(void)
-{
- return paride_register(&fit3);
-}
-
-static void __exit fit3_exit(void)
-{
- paride_unregister(&fit3);
-}
-
MODULE_LICENSE("GPL");
-module_init(fit3_init)
-module_exit(fit3_exit)
+module_pata_parport_driver(fit3);
@@ -261,16 +261,5 @@ static struct pi_protocol friq = {
.release_proto = friq_release_proto,
};
-static int __init friq_init(void)
-{
- return paride_register(&friq);
-}
-
-static void __exit friq_exit(void)
-{
- paride_unregister(&friq);
-}
-
MODULE_LICENSE("GPL");
-module_init(friq_init)
-module_exit(friq_exit)
+module_pata_parport_driver(friq);
@@ -298,16 +298,5 @@ static struct pi_protocol frpw = {
.log_adapter = frpw_log_adapter,
};
-static int __init frpw_init(void)
-{
- return paride_register(&frpw);
-}
-
-static void __exit frpw_exit(void)
-{
- paride_unregister(&frpw);
-}
-
MODULE_LICENSE("GPL");
-module_init(frpw_init)
-module_exit(frpw_exit)
+module_pata_parport_driver(frpw);
@@ -288,19 +288,19 @@ static int __init kbic_init(void)
{
int rv;
- rv = paride_register(&k951);
+ rv = pata_parport_register_driver(&k951);
if (rv < 0)
return rv;
- rv = paride_register(&k971);
+ rv = pata_parport_register_driver(&k971);
if (rv < 0)
- paride_unregister(&k951);
+ pata_parport_unregister_driver(&k951);
return rv;
}
static void __exit kbic_exit(void)
{
- paride_unregister(&k951);
- paride_unregister(&k971);
+ pata_parport_unregister_driver(&k951);
+ pata_parport_unregister_driver(&k971);
}
MODULE_LICENSE("GPL");
@@ -113,16 +113,5 @@ static struct pi_protocol ktti = {
.log_adapter = ktti_log_adapter,
};
-static int __init ktti_init(void)
-{
- return paride_register(&ktti);
-}
-
-static void __exit ktti_exit(void)
-{
- paride_unregister(&ktti);
-}
-
MODULE_LICENSE("GPL");
-module_init(ktti_init)
-module_exit(ktti_exit)
+module_pata_parport_driver(ktti);
@@ -138,16 +138,5 @@ static struct pi_protocol on20 = {
.log_adapter = on20_log_adapter,
};
-static int __init on20_init(void)
-{
- return paride_register(&on20);
-}
-
-static void __exit on20_exit(void)
-{
- paride_unregister(&on20);
-}
-
MODULE_LICENSE("GPL");
-module_init(on20_init)
-module_exit(on20_exit)
+module_pata_parport_driver(on20);
@@ -304,16 +304,5 @@ static struct pi_protocol on26 = {
.log_adapter = on26_log_adapter,
};
-static int __init on26_init(void)
-{
- return paride_register(&on26);
-}
-
-static void __exit on26_exit(void)
-{
- paride_unregister(&on26);
-}
-
MODULE_LICENSE("GPL");
-module_init(on26_init)
-module_exit(on26_exit)
+module_pata_parport_driver(on26);
@@ -87,8 +87,16 @@ struct pi_protocol {
int pata_parport_register_driver(struct pi_protocol *pr);
void pata_parport_unregister_driver(struct pi_protocol *pr);
-/* defines for old paride protocol modules */
-#define paride_register pata_parport_register_driver
-#define paride_unregister pata_parport_unregister_driver
+
+/**
+ * module_pata_parport_driver() - Helper macro for registering a pata_parport driver
+ * @__pi_protocol: pi_protocol struct
+ *
+ * Helper macro for pata_parport drivers which do not 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_pata_parport_driver(__pi_protocol) \
+ module_driver(__pi_protocol, pata_parport_register_driver, pata_parport_unregister_driver)
#endif /* LINUX_PATA_PARPORT_H */