diff mbox series

[rfc,v1,1/1] platform/x86: intel: Add 'intel' prefix to the modules automatically

Message ID 20241011172531.3407093-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Changes Requested, archived
Headers show
Series [rfc,v1,1/1] platform/x86: intel: Add 'intel' prefix to the modules automatically | expand

Commit Message

Andy Shevchenko Oct. 11, 2024, 5:24 p.m. UTC
Rework Makefile to add 'intel' prefix to the modules automatically.
This removes a lot of boilerplate code in it and also makes robust
against mistypos in the prefix.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---

Send as RFC because TBH I rather want to have something like this to be
available on the level of Kbuild for any of the subdirectories in
question. Also I haven't done any comprehensive build tests on this,
let's see what CIs think about this...

 drivers/platform/x86/intel/Makefile           | 68 ++++++++-----------
 .../intel/{intel_plr_tpmi.c => plr_tpmi.c}    |  0
 2 files changed, 29 insertions(+), 39 deletions(-)
 rename drivers/platform/x86/intel/{intel_plr_tpmi.c => plr_tpmi.c} (100%)

Comments

Andy Shevchenko Oct. 11, 2024, 5:41 p.m. UTC | #1
On Fri, Oct 11, 2024 at 08:24:09PM +0300, Andy Shevchenko wrote:
> Rework Makefile to add 'intel' prefix to the modules automatically.
> This removes a lot of boilerplate code in it and also makes robust
> against mistypos in the prefix.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> 
> Send as RFC because TBH I rather want to have something like this to be
> available on the level of Kbuild for any of the subdirectories in
> question. Also I haven't done any comprehensive build tests on this,
> let's see what CIs think about this...

(FWIW, I already fixed a few mistakes locally)

To elaborate more, what I want to achieve.

Assume we have

	obj-$(OPTION) = bar/

in the Kconfig and let's say bar/ contains

	obj-$(X) += zx.o
	obj-$(Y) += zy.o

What I want is to have something like

	bar-prefix = baz
	prefixed-obj-$(OPTION) = bar/

that results *automatically* _if_ I wrote originally something like

	baz-zx-y := zx.o
	obj-$(X) += baz-zx.o
	baz-zy-y := zy.o
	obj-$(Y) += baz-zy.o

without actually modifying the Makefile in bar/.
Ilpo Järvinen Oct. 15, 2024, 9:05 a.m. UTC | #2
On Fri, 11 Oct 2024, Andy Shevchenko wrote:

> Rework Makefile to add 'intel' prefix to the modules automatically.
> This removes a lot of boilerplate code in it and also makes robust
> against mistypos in the prefix.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> 
> Send as RFC because TBH I rather want to have something like this to be
> available on the level of Kbuild for any of the subdirectories in
> question. Also I haven't done any comprehensive build tests on this,
> let's see what CIs think about this...

It feels useful to have this automatically available for the folder one 
level towards root... (perhaps two levels).

But you didn't include kbuild ML (now added).

>  drivers/platform/x86/intel/Makefile           | 68 ++++++++-----------
>  .../intel/{intel_plr_tpmi.c => plr_tpmi.c}    |  0
>  2 files changed, 29 insertions(+), 39 deletions(-)
>  rename drivers/platform/x86/intel/{intel_plr_tpmi.c => plr_tpmi.c} (100%)
> 
> diff --git a/drivers/platform/x86/intel/Makefile b/drivers/platform/x86/intel/Makefile
> index 74db065c82d6..21e9e21e0142 100644
> --- a/drivers/platform/x86/intel/Makefile
> +++ b/drivers/platform/x86/intel/Makefile
> @@ -17,50 +17,40 @@ obj-$(CONFIG_INTEL_UNCORE_FREQ_CONTROL)	+= uncore-frequency/
>  
>  
>  # Intel input drivers
> -intel-hid-y				:= hid.o
> -obj-$(CONFIG_INTEL_HID_EVENT)		+= intel-hid.o
> -intel-vbtn-y				:= vbtn.o
> -obj-$(CONFIG_INTEL_VBTN)		+= intel-vbtn.o
> +intel-target-$(CONFIG_INTEL_HID_EVENT)		+= hid.o
> +intel-target-$(CONFIG_INTEL_VBTN)		+= vbtn.o
>  
>  # Intel miscellaneous drivers
> -obj-$(CONFIG_INTEL_ISHTP_ECLITE)	+= ishtp_eclite.o
> -intel_int0002_vgpio-y			:= int0002_vgpio.o
> -obj-$(CONFIG_INTEL_INT0002_VGPIO)	+= intel_int0002_vgpio.o
> -intel_oaktrail-y			:= oaktrail.o
> -obj-$(CONFIG_INTEL_OAKTRAIL)		+= intel_oaktrail.o
> -intel_sdsi-y				:= sdsi.o
> -obj-$(CONFIG_INTEL_SDSI)		+= intel_sdsi.o
> -intel_vsec-y				:= vsec.o
> -obj-$(CONFIG_INTEL_VSEC)		+= intel_vsec.o
> +intel-target-$(CONFIG_INTEL_ISHTP_ECLITE)	+= ishtp_eclite.o
> +
> +intel-target-$(CONFIG_INTEL_INT0002_VGPIO)	+= int0002_vgpio.o
> +intel-target-$(CONFIG_INTEL_OAKTRAIL)		+= oaktrail.o
> +intel-target-$(CONFIG_INTEL_SDSI)		+= sdsi.o
> +intel-target-$(CONFIG_INTEL_VSEC)		+= vsec.o
>  
>  # Intel PMIC / PMC / P-Unit drivers
> -intel_bxtwc_tmu-y			:= bxtwc_tmu.o
> -obj-$(CONFIG_INTEL_BXTWC_PMIC_TMU)	+= intel_bxtwc_tmu.o
> -intel_crystal_cove_charger-y		:= crystal_cove_charger.o
> -obj-$(CONFIG_X86_ANDROID_TABLETS)	+= intel_crystal_cove_charger.o
> -intel_bytcrc_pwrsrc-y			:= bytcrc_pwrsrc.o
> -obj-$(CONFIG_INTEL_BYTCRC_PWRSRC)	+= intel_bytcrc_pwrsrc.o
> -intel_chtdc_ti_pwrbtn-y			:= chtdc_ti_pwrbtn.o
> -obj-$(CONFIG_INTEL_CHTDC_TI_PWRBTN)	+= intel_chtdc_ti_pwrbtn.o
> -intel_chtwc_int33fe-y			:= chtwc_int33fe.o
> -obj-$(CONFIG_INTEL_CHTWC_INT33FE)	+= intel_chtwc_int33fe.o
> -intel_mrfld_pwrbtn-y			:= mrfld_pwrbtn.o
> -obj-$(CONFIG_INTEL_MRFLD_PWRBTN)	+= intel_mrfld_pwrbtn.o
> -intel_punit_ipc-y			:= punit_ipc.o
> -obj-$(CONFIG_INTEL_PUNIT_IPC)		+= intel_punit_ipc.o
> +intel-target-$(CONFIG_INTEL_BXTWC_PMIC_TMU)	+= bxtwc_tmu.o
> +intel-target-$(CONFIG_X86_ANDROID_TABLETS)	+= crystal_cove_charger.o
> +intel-target-$(CONFIG_INTEL_BYTCRC_PWRSRC)	+= bytcrc_pwrsrc.o
> +intel-target-$(CONFIG_INTEL_CHTDC_TI_PWRBTN)	+= chtdc_ti_pwrbtn.o
> +intel-target-$(CONFIG_INTEL_CHTWC_INT33FE)	+= chtwc_int33fe.o
> +intel-target-$(CONFIG_INTEL_MRFLD_PWRBTN)	+= mrfld_pwrbtn.o
> +intel-target-$(CONFIG_INTEL_PUNIT_IPC)		+= punit_ipc.o
>  
>  # TPMI drivers
> -intel_vsec_tpmi-y			:= tpmi.o
> -obj-$(CONFIG_INTEL_TPMI)		+= intel_vsec_tpmi.o
> -obj-$(CONFIG_INTEL_PLR_TPMI)		+= intel_plr_tpmi.o
> -
> -intel_tpmi_power_domains-y		:= tpmi_power_domains.o
> -obj-$(CONFIG_INTEL_TPMI_POWER_DOMAINS)	+= intel_tpmi_power_domains.o
> +intel-target-$(CONFIG_INTEL_TPMI)		+= vsec_tpmi.o
> +intel-target-$(CONFIG_INTEL_PLR_TPMI)		+= plr_tpmi.o
> +intel-target-$(CONFIG_INTEL_TPMI_POWER_DOMAINS)	+= tpmi_power_domains.o
>  
>  # Intel Uncore drivers
> -intel-rst-y				:= rst.o
> -obj-$(CONFIG_INTEL_RST)			+= intel-rst.o
> -intel-smartconnect-y			:= smartconnect.o
> -obj-$(CONFIG_INTEL_SMARTCONNECT)	+= intel-smartconnect.o
> -intel_turbo_max_3-y			:= turbo_max_3.o
> -obj-$(CONFIG_INTEL_TURBO_MAX_3)		+= intel_turbo_max_3.o
> +intel-target-$(CONFIG_INTEL_RST)		+= rst.o
> +intel-target-$(CONFIG_INTEL_SMARTCONNECT)	+= smartconnect.o
> +intel-target-$(CONFIG_INTEL_TURBO_MAX_3)	+= turbo_max_3.o
> +
> +define INTEL_OBJ_TARGET
> +intel-$(1)-y := $(1).o
> +obj-$(2) += intel-$(1).o
> +endef
> +
> +$(foreach target-y, $(basename $(intel-target-m)), $(eval $(call INTEL_OBJ_TARGET,$(target-y),y)))
> +$(foreach target-m, $(basename $(intel-target-m)), $(eval $(call INTEL_OBJ_TARGET,$(target-m),m)))
> diff --git a/drivers/platform/x86/intel/intel_plr_tpmi.c b/drivers/platform/x86/intel/plr_tpmi.c
> similarity index 100%
> rename from drivers/platform/x86/intel/intel_plr_tpmi.c
> rename to drivers/platform/x86/intel/plr_tpmi.c

Why call these intel-target-*, wouldn't intel-obj-* be more consistent?
Andy Shevchenko Oct. 15, 2024, 11:01 a.m. UTC | #3
On Tue, Oct 15, 2024 at 12:05:45PM +0300, Ilpo Järvinen wrote:
> On Fri, 11 Oct 2024, Andy Shevchenko wrote:
> 
> > Rework Makefile to add 'intel' prefix to the modules automatically.
> > This removes a lot of boilerplate code in it and also makes robust
> > against mistypos in the prefix.

...

> > Send as RFC because TBH I rather want to have something like this to be
> > available on the level of Kbuild for any of the subdirectories in
> > question. Also I haven't done any comprehensive build tests on this,
> > let's see what CIs think about this...
> 
> It feels useful to have this automatically available for the folder one 
> level towards root... (perhaps two levels).

Yeah, ideally for a few levels of folders, but at least one would be useful
to start with.

> But you didn't include kbuild ML (now added).

I'll do it in v2.

...

> Why call these intel-target-*, wouldn't intel-obj-* be more consistent?

The (potential) problem with obj as it may collide with the standard way of
collecting objects under meta one (which will become a real module). I haven't
tested that but I believe that putting anything to FOO-obj-y/m is a carefully
placed minefield, if not now, then later. That said, I would avoid using obj
there.
diff mbox series

Patch

diff --git a/drivers/platform/x86/intel/Makefile b/drivers/platform/x86/intel/Makefile
index 74db065c82d6..21e9e21e0142 100644
--- a/drivers/platform/x86/intel/Makefile
+++ b/drivers/platform/x86/intel/Makefile
@@ -17,50 +17,40 @@  obj-$(CONFIG_INTEL_UNCORE_FREQ_CONTROL)	+= uncore-frequency/
 
 
 # Intel input drivers
-intel-hid-y				:= hid.o
-obj-$(CONFIG_INTEL_HID_EVENT)		+= intel-hid.o
-intel-vbtn-y				:= vbtn.o
-obj-$(CONFIG_INTEL_VBTN)		+= intel-vbtn.o
+intel-target-$(CONFIG_INTEL_HID_EVENT)		+= hid.o
+intel-target-$(CONFIG_INTEL_VBTN)		+= vbtn.o
 
 # Intel miscellaneous drivers
-obj-$(CONFIG_INTEL_ISHTP_ECLITE)	+= ishtp_eclite.o
-intel_int0002_vgpio-y			:= int0002_vgpio.o
-obj-$(CONFIG_INTEL_INT0002_VGPIO)	+= intel_int0002_vgpio.o
-intel_oaktrail-y			:= oaktrail.o
-obj-$(CONFIG_INTEL_OAKTRAIL)		+= intel_oaktrail.o
-intel_sdsi-y				:= sdsi.o
-obj-$(CONFIG_INTEL_SDSI)		+= intel_sdsi.o
-intel_vsec-y				:= vsec.o
-obj-$(CONFIG_INTEL_VSEC)		+= intel_vsec.o
+intel-target-$(CONFIG_INTEL_ISHTP_ECLITE)	+= ishtp_eclite.o
+
+intel-target-$(CONFIG_INTEL_INT0002_VGPIO)	+= int0002_vgpio.o
+intel-target-$(CONFIG_INTEL_OAKTRAIL)		+= oaktrail.o
+intel-target-$(CONFIG_INTEL_SDSI)		+= sdsi.o
+intel-target-$(CONFIG_INTEL_VSEC)		+= vsec.o
 
 # Intel PMIC / PMC / P-Unit drivers
-intel_bxtwc_tmu-y			:= bxtwc_tmu.o
-obj-$(CONFIG_INTEL_BXTWC_PMIC_TMU)	+= intel_bxtwc_tmu.o
-intel_crystal_cove_charger-y		:= crystal_cove_charger.o
-obj-$(CONFIG_X86_ANDROID_TABLETS)	+= intel_crystal_cove_charger.o
-intel_bytcrc_pwrsrc-y			:= bytcrc_pwrsrc.o
-obj-$(CONFIG_INTEL_BYTCRC_PWRSRC)	+= intel_bytcrc_pwrsrc.o
-intel_chtdc_ti_pwrbtn-y			:= chtdc_ti_pwrbtn.o
-obj-$(CONFIG_INTEL_CHTDC_TI_PWRBTN)	+= intel_chtdc_ti_pwrbtn.o
-intel_chtwc_int33fe-y			:= chtwc_int33fe.o
-obj-$(CONFIG_INTEL_CHTWC_INT33FE)	+= intel_chtwc_int33fe.o
-intel_mrfld_pwrbtn-y			:= mrfld_pwrbtn.o
-obj-$(CONFIG_INTEL_MRFLD_PWRBTN)	+= intel_mrfld_pwrbtn.o
-intel_punit_ipc-y			:= punit_ipc.o
-obj-$(CONFIG_INTEL_PUNIT_IPC)		+= intel_punit_ipc.o
+intel-target-$(CONFIG_INTEL_BXTWC_PMIC_TMU)	+= bxtwc_tmu.o
+intel-target-$(CONFIG_X86_ANDROID_TABLETS)	+= crystal_cove_charger.o
+intel-target-$(CONFIG_INTEL_BYTCRC_PWRSRC)	+= bytcrc_pwrsrc.o
+intel-target-$(CONFIG_INTEL_CHTDC_TI_PWRBTN)	+= chtdc_ti_pwrbtn.o
+intel-target-$(CONFIG_INTEL_CHTWC_INT33FE)	+= chtwc_int33fe.o
+intel-target-$(CONFIG_INTEL_MRFLD_PWRBTN)	+= mrfld_pwrbtn.o
+intel-target-$(CONFIG_INTEL_PUNIT_IPC)		+= punit_ipc.o
 
 # TPMI drivers
-intel_vsec_tpmi-y			:= tpmi.o
-obj-$(CONFIG_INTEL_TPMI)		+= intel_vsec_tpmi.o
-obj-$(CONFIG_INTEL_PLR_TPMI)		+= intel_plr_tpmi.o
-
-intel_tpmi_power_domains-y		:= tpmi_power_domains.o
-obj-$(CONFIG_INTEL_TPMI_POWER_DOMAINS)	+= intel_tpmi_power_domains.o
+intel-target-$(CONFIG_INTEL_TPMI)		+= vsec_tpmi.o
+intel-target-$(CONFIG_INTEL_PLR_TPMI)		+= plr_tpmi.o
+intel-target-$(CONFIG_INTEL_TPMI_POWER_DOMAINS)	+= tpmi_power_domains.o
 
 # Intel Uncore drivers
-intel-rst-y				:= rst.o
-obj-$(CONFIG_INTEL_RST)			+= intel-rst.o
-intel-smartconnect-y			:= smartconnect.o
-obj-$(CONFIG_INTEL_SMARTCONNECT)	+= intel-smartconnect.o
-intel_turbo_max_3-y			:= turbo_max_3.o
-obj-$(CONFIG_INTEL_TURBO_MAX_3)		+= intel_turbo_max_3.o
+intel-target-$(CONFIG_INTEL_RST)		+= rst.o
+intel-target-$(CONFIG_INTEL_SMARTCONNECT)	+= smartconnect.o
+intel-target-$(CONFIG_INTEL_TURBO_MAX_3)	+= turbo_max_3.o
+
+define INTEL_OBJ_TARGET
+intel-$(1)-y := $(1).o
+obj-$(2) += intel-$(1).o
+endef
+
+$(foreach target-y, $(basename $(intel-target-m)), $(eval $(call INTEL_OBJ_TARGET,$(target-y),y)))
+$(foreach target-m, $(basename $(intel-target-m)), $(eval $(call INTEL_OBJ_TARGET,$(target-m),m)))
diff --git a/drivers/platform/x86/intel/intel_plr_tpmi.c b/drivers/platform/x86/intel/plr_tpmi.c
similarity index 100%
rename from drivers/platform/x86/intel/intel_plr_tpmi.c
rename to drivers/platform/x86/intel/plr_tpmi.c