[PATCH 11/18] platform/x86: int3472: fix object shared between several modules

From: Alexander Lobakin
Date: Sat Nov 19 2022 - 18:08:42 EST


common.o is linked to both intel_skl_int3472_{discrete,tps68470}:

> scripts/Makefile.build:252: ./drivers/platform/x86/intel/int3472/Makefile:
> common.o is added to multiple modules: intel_skl_int3472_discrete
> intel_skl_int3472_tps68470

Although both drivers share one Kconfig option
(CONFIG_INTEL_SKL_INT3472), it's better to not link one object file
into several modules (and/or vmlinux).
Under certain circumstances, such can lead to the situation fixed by
commit 637a642f5ca5 ("zstd: Fixing mixed module-builtin objects").

Introduce the new module, intel_skl_int3472_common, to provide the
functions from common.o to both discrete and tps68470 drivers. This
adds only 3 exports and doesn't provide any changes to the actual
code.

Fixes: a2f9fbc247ee ("platform/x86: int3472: Split into 2 drivers")
Suggested-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
Signed-off-by: Alexander Lobakin <alobakin@xxxxx>
---
drivers/platform/x86/intel/int3472/Makefile | 8 +++++---
drivers/platform/x86/intel/int3472/common.c | 8 ++++++++
drivers/platform/x86/intel/int3472/discrete.c | 2 ++
drivers/platform/x86/intel/int3472/tps68470.c | 2 ++
4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/intel/int3472/Makefile b/drivers/platform/x86/intel/int3472/Makefile
index cfec7784c5c9..53cc0e7db749 100644
--- a/drivers/platform/x86/intel/int3472/Makefile
+++ b/drivers/platform/x86/intel/int3472/Makefile
@@ -1,4 +1,6 @@
-obj-$(CONFIG_INTEL_SKL_INT3472) += intel_skl_int3472_discrete.o \
+obj-$(CONFIG_INTEL_SKL_INT3472) += intel_skl_int3472_common.o \
+ intel_skl_int3472_discrete.o \
intel_skl_int3472_tps68470.o
-intel_skl_int3472_discrete-y := discrete.o clk_and_regulator.o common.o
-intel_skl_int3472_tps68470-y := tps68470.o tps68470_board_data.o common.o
+intel_skl_int3472_common-y := common.o
+intel_skl_int3472_discrete-y := discrete.o clk_and_regulator.o
+intel_skl_int3472_tps68470-y := tps68470.o tps68470_board_data.o
diff --git a/drivers/platform/x86/intel/int3472/common.c b/drivers/platform/x86/intel/int3472/common.c
index 9db2bb0bbba4..bd573ff46610 100644
--- a/drivers/platform/x86/intel/int3472/common.c
+++ b/drivers/platform/x86/intel/int3472/common.c
@@ -2,6 +2,7 @@
/* Author: Dan Scally <djrscally@xxxxxxxxx> */

#include <linux/acpi.h>
+#include <linux/module.h>
#include <linux/slab.h>

#include "common.h"
@@ -29,6 +30,7 @@ union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev, char *i

return obj;
}
+EXPORT_SYMBOL_NS_GPL(skl_int3472_get_acpi_buffer, INTEL_SKL_INT3472);

int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb)
{
@@ -52,6 +54,7 @@ int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb)
kfree(obj);
return ret;
}
+EXPORT_SYMBOL_NS_GPL(skl_int3472_fill_cldb, INTEL_SKL_INT3472);

/* sensor_adev_ret may be NULL, name_ret must not be NULL */
int skl_int3472_get_sensor_adev_and_name(struct device *dev,
@@ -80,3 +83,8 @@ int skl_int3472_get_sensor_adev_and_name(struct device *dev,

return ret;
}
+EXPORT_SYMBOL_NS_GPL(skl_int3472_get_sensor_adev_and_name, INTEL_SKL_INT3472);
+
+MODULE_DESCRIPTION("Intel SkyLake INT3472 Common Module");
+MODULE_AUTHOR("Daniel Scally <djrscally@xxxxxxxxx>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index 974a132db651..a1f3b593cea6 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -414,6 +414,8 @@ static struct platform_driver int3472_discrete = {
};
module_platform_driver(int3472_discrete);

+MODULE_IMPORT_NS(INTEL_SKL_INT3472);
+
MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI Discrete Device Driver");
MODULE_AUTHOR("Daniel Scally <djrscally@xxxxxxxxx>");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/platform/x86/intel/int3472/tps68470.c b/drivers/platform/x86/intel/int3472/tps68470.c
index 5b8d1a9620a5..3c983aa7731f 100644
--- a/drivers/platform/x86/intel/int3472/tps68470.c
+++ b/drivers/platform/x86/intel/int3472/tps68470.c
@@ -255,6 +255,8 @@ static struct i2c_driver int3472_tps68470 = {
};
module_i2c_driver(int3472_tps68470);

+MODULE_IMPORT_NS(INTEL_SKL_INT3472);
+
MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI TPS68470 Device Driver");
MODULE_AUTHOR("Daniel Scally <djrscally@xxxxxxxxx>");
MODULE_LICENSE("GPL v2");
--
2.38.1