Skip to contentSkip to conversation

Introduce builtin_platform_driver for non modules

GIT PULL Paul Gortmaker 3 participants 6 messages Jul 1, 2015

lore
Share & tools
lore
#0 lore raw

We see an increasing number of non-modular drivers using modular_driver() type register functions. There are several downsides to letting this continue unchecked:

1) The code can appear modular to a reader of the code, and they won't know if the code really is modular without checking the Makefile and Kconfig to see if compilation is governed by a bool or tristate.
2) Coders of drivers may be tempted to code up an __exit function that is never used, just in order to satisfy the required three args of the modular registration function.
3) Non-modular code ends up including the <module.h> which increases CPP overhead that they don't need.
4) It hinders us from performing better separation of the module init code and the generic init code.

So here we introduce similar macros for builtin drivers. Then we convert builtin drivers (controlled by a bool Kconfig) by making the following type of mapping:

module_platform_driver() ---> builtin_platform_driver()
module_platform_driver_probe() ---> builtin_platform_driver_probe().

The set of drivers that are converted here are just the ones that showed up as relying on an implicit include of <module.h> during a pending header cleanup. So we convert them here vs. adding an include of <module.h> to non-modular code to avoid compile fails. Additonal conversions can be done asynchronously at any time.

Once again, an unused module_exit function that is removed here appears in the diffstat as an outlier wrt. all the other changes.

Original posting:
"Introduce builtin_driver and use it for non-modular code"
https://lkml.kernel.org/r/[email protected]

Thanks,
Paul.
---

The following changes since commit 0f57d86787d8b1076ea8f9cbdddda2a46d534a27:

Linux 4.1-rc8 (2015-06-14 15:51:10 -1000)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git tags/module-builtin_driver-v4.1-rc8

for you to fetch changes up to 77459a0feca4ae8757a905fd1791f039479e8e1e:

drivers/clk: convert sunxi/clk-mod0.c to use builtin_platform_driver (2015-06-16 14:12:39 -0400)

----------------------------------------------------------------
Replace module_platform_driver with builtin_platform driver in non modules.

----------------------------------------------------------------
Paul Gortmaker (8):
platform_device: better support builtin boilerplate avoidance drivers/platform: Convert non-modular pdev_bus to use builtin_platform_driver drivers/cpuidle: Convert non-modular drivers to use builtin_platform_driver drivers/cpufreq: Convert non-modular s5pv210-cpufreq.c to use builtin_platform_driver drivers/soc: Convert non-modular tegra/pmc to use builtin_platform_driver drivers/soc: Convert non-modular soc-realview to use builtin_platform_driver drivers/power: Convert non-modular syscon-reboot to use builtin_platform_driver drivers/clk: convert sunxi/clk-mod0.c to use builtin_platform_driver

 drivers/clk/sunxi/clk-mod0.c         |  2 +-
 drivers/cpufreq/s5pv210-cpufreq.c    |  2 +-
 drivers/cpuidle/cpuidle-at91.c       |  3 +--
 drivers/cpuidle/cpuidle-calxeda.c    |  3 +--
 drivers/cpuidle/cpuidle-zynq.c       |  3 +--
 drivers/platform/goldfish/pdev_bus.c | 12 +-----------
 drivers/power/reset/syscon-reboot.c  |  2 +-
 drivers/soc/tegra/pmc.c              |  2 +-
 drivers/soc/versatile/soc-realview.c |  2 +-
 include/linux/device.h               | 22 ++++++++++++++++++++++
 include/linux/platform_device.h      | 23 +++++++++++++++++++++++
 11 files changed, 54 insertions(+), 22 deletions(-)
#1 lore raw
Quoted 44 lines · Paul Gortmaker

We see an increasing number of non-modular drivers using modular_driver() type register functions. There are several downsides to letting this continue unchecked:

1) The code can appear modular to a reader of the code, and they won't know if the code really is modular without checking the Makefile and Kconfig to see if compilation is governed by a bool or tristate.
2) Coders of drivers may be tempted to code up an __exit function that is never used, just in order to satisfy the required three args of the modular registration function.
3) Non-modular code ends up including the <module.h> which increases CPP overhead that they don't need.
4) It hinders us from performing better separation of the module init code and the generic init code.

So here we introduce similar macros for builtin drivers. Then we convert builtin drivers (controlled by a bool Kconfig) by making the following type of mapping:

module_platform_driver() ---> builtin_platform_driver()
module_platform_driver_probe() ---> builtin_platform_driver_probe().

The set of drivers that are converted here are just the ones that showed up as relying on an implicit include of <module.h> during a pending header cleanup. So we convert them here vs. adding an include of <module.h> to non-modular code to avoid compile fails. Additonal conversions can be done asynchronously at any time.

Once again, an unused module_exit function that is removed here appears in the diffstat as an outlier wrt. all the other changes.

Original posting:
"Introduce builtin_driver and use it for non-modular code"
https://lkml.kernel.org/r/[email protected]

Thanks,
Paul.
---

The following changes since commit 0f57d86787d8b1076ea8f9cbdddda2a46d534a27:

Linux 4.1-rc8 (2015-06-14 15:51:10 -1000)

Quoted 7 lines

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git tags/module-builtin_driver-v4.1-rc8

for you to fetch changes up to 77459a0feca4ae8757a905fd1791f039479e8e1e:

drivers/clk: convert sunxi/clk-mod0.c to use builtin_platform_driver (2015-06-16 14:12:39 -0400)

Was this ever in linux-next? I saw you post this once, don't recall any real discussion about it. Ideally some subsystem people would ack it...

thanks,

greg k-h

#2 lore raw

Hi Greg,

Quoted 7 lines · On Tue, 30 Jun 2015 18:24:58 -0700 Greg KH <[email protected]> wrote:
Quoted 7 lines

The following changes since commit 0f57d86787d8b1076ea8f9cbdddda2a46d534a27:

Linux 4.1-rc8 (2015-06-14 15:51:10 -1000)

are available in the git repository at:

Quoted 7 lines
Quoted 5 lines

git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git tags/module-builtin_driver-v4.1-rc8

for you to fetch changes up to 77459a0feca4ae8757a905fd1791f039479e8e1e:

drivers/clk: convert sunxi/clk-mod0.c to use builtin_platform_driver (2015-06-16 14:12:39 -0400)

Was this ever in linux-next?

Yes, since next-20150617.

Quoted 1 line

Ideally some subsystem people would ack it...

Most of the patches have at least one Ack

Signature · 2 lines
Cheers,
Stephen Rothwell                    [email protected]
#3 lore raw
Quoted 12 lines · Stephen Rothwell

Hi Greg,

Quoted 9 lines · On Tue, 30 Jun 2015 18:24:58 -0700 Greg KH <[email protected]> wrote:
Quoted 9 lines

The following changes since commit 0f57d86787d8b1076ea8f9cbdddda2a46d534a27:

Linux 4.1-rc8 (2015-06-14 15:51:10 -1000)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git tags/module-builtin_driver-v4.1-rc8

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

for you to fetch changes up to 77459a0feca4ae8757a905fd1791f039479e8e1e:

drivers/clk: convert sunxi/clk-mod0.c to use builtin_platform_driver (2015-06-16 14:12:39 -0400)

Was this ever in linux-next?

Yes, since next-20150617.

Ah good, missed that, sorry.

Quoted 3 lines
Quoted 1 line

Ideally some subsystem people would ack it...

Most of the patches have at least one Ack

Ok, I was looking at the one that touched the driver core :)

Anyway, this is fine with me, sorry for the noise.

greg k-h

#4 lore raw
In reply to Greg KH

[Re: [GIT PULL] Introduce builtin_platform_driver for non modules] On 30/06/2015 (Tue 18:24) Greg KH wrote:

[...]

Quoted 7 lines
Quoted 7 lines

The following changes since commit 0f57d86787d8b1076ea8f9cbdddda2a46d534a27:

Linux 4.1-rc8 (2015-06-14 15:51:10 -1000)

are available in the git repository at:

Quoted 7 lines
Quoted 5 lines

git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git tags/module-builtin_driver-v4.1-rc8

for you to fetch changes up to 77459a0feca4ae8757a905fd1791f039479e8e1e:

drivers/clk: convert sunxi/clk-mod0.c to use builtin_platform_driver (2015-06-16 14:12:39 -0400)

Was this ever in linux-next?

It was added to linux-next a month ago, and all the commits and their baseline have been unchanged for the last two weeks (the date Stephen indicated) as that was when the last Acks etc stopped trickling in.

I've also been proactively monitoring linux-next looking for any merge issues, which is why I sent you the (now mainline) commits fc368ea1ea00c and 5a6a7cd05c039 -- in both commits I mentioned how we'd like to change to use this very infrastructure here, once it is present in tree.

Quoted 1 line

I saw you post this once, don't recall any real discussion about it.

I thought the lack of discussion wasn't surprising, given that it was a mundane and trivial extension of the modular ones to a non-modular use case, and the ugly alternative is to let everyone open code their own :(

That said, it was posted with a sensible Cc list and it also did get wider opportunity for possible discussion if needed, thanks to LWN:

	https://lwn.net/Articles/643854/

The only other thread of discussion I can think of was where another subsystem maintainer looped me into the review of a new driver, because they were looking forward to having this in tree, due to the additional clarity it would add between modular and non modular code:

	https://lkml.kernel.org/r/[email protected]
Quoted 1 line

Ideally some subsystem people would ack it...

Yes a good many of the deployment patches themselves are Ack'd. For the core macro introduction itself, you were Cc'd on it [and the 0/7 intro].

Given my above mentioned commits that you'd read and merged that mentioned this, I didn't want to burn karma nagging you for an explicit ack for this one basic commit itself, given how busy you are with stable, staging, etc. But I did explicitly put you on the Cc for this pull figuring it would be an opportunity to keep you in the loop and provide a last chance opportunity for a "No, don't do this because..."

If I have to burn karma nagging you about something, I'd rather it be something more important, like adding this (unrelated) clk_add_alias fix to staging -- since its absence has been breaking powerpc, s390, parisc, cris, ... etc. builds in linux-next for quite some time now. :)

	https://lkml.org/lkml/2015/6/25/365

Thanks,
Paul.
--

Quoted 4 lines

thanks,

greg k-h

#5 lore raw
Quoted 49 lines · Paul Gortmaker

[Re: [GIT PULL] Introduce builtin_platform_driver for non modules] On 30/06/2015 (Tue 18:24) Greg KH wrote:

[...]

Quoted 7 lines
Quoted 7 lines

The following changes since commit 0f57d86787d8b1076ea8f9cbdddda2a46d534a27:

Linux 4.1-rc8 (2015-06-14 15:51:10 -1000)

are available in the git repository at:

Quoted 7 lines
Quoted 5 lines

git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git tags/module-builtin_driver-v4.1-rc8

for you to fetch changes up to 77459a0feca4ae8757a905fd1791f039479e8e1e:

drivers/clk: convert sunxi/clk-mod0.c to use builtin_platform_driver (2015-06-16 14:12:39 -0400)

Was this ever in linux-next?

It was added to linux-next a month ago, and all the commits and their baseline have been unchanged for the last two weeks (the date Stephen indicated) as that was when the last Acks etc stopped trickling in.

I've also been proactively monitoring linux-next looking for any merge issues, which is why I sent you the (now mainline) commits fc368ea1ea00c and 5a6a7cd05c039 -- in both commits I mentioned how we'd like to change to use this very infrastructure here, once it is present in tree.

Quoted 1 line

I saw you post this once, don't recall any real discussion about it.

I thought the lack of discussion wasn't surprising, given that it was a mundane and trivial extension of the modular ones to a non-modular use case, and the ugly alternative is to let everyone open code their own :(

That said, it was posted with a sensible Cc list and it also did get wider opportunity for possible discussion if needed, thanks to LWN:

	https://lwn.net/Articles/643854/

The only other thread of discussion I can think of was where another subsystem maintainer looped me into the review of a new driver, because they were looking forward to having this in tree, due to the additional clarity it would add between modular and non modular code:

	https://lkml.kernel.org/r/[email protected]
Quoted 1 line

Ideally some subsystem people would ack it...

Yes a good many of the deployment patches themselves are Ack'd. For the core macro introduction itself, you were Cc'd on it [and the 0/7 intro].

Quoted 6 lines

Given my above mentioned commits that you'd read and merged that mentioned this, I didn't want to burn karma nagging you for an explicit ack for this one basic commit itself, given how busy you are with stable, staging, etc. But I did explicitly put you on the Cc for this pull figuring it would be an opportunity to keep you in the loop and provide a last chance opportunity for a "No, don't do this because..."

Fair enough, thanks for that, I don't have any objections to this pull request.

Quoted 6 lines

If I have to burn karma nagging you about something, I'd rather it be something more important, like adding this (unrelated) clk_add_alias fix to staging -- since its absence has been breaking powerpc, s390, parisc, cris, ... etc. builds in linux-next for quite some time now. :)

	https://lkml.org/lkml/2015/6/25/365

Heh, it's not nagging, I'll queue that up after 4.2-rc1 is out, along with other fixes.

thanks,

greg k-h