mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 06:01:57 +00:00
platform/x86: int3472: Split into 2 drivers
The intel_skl_int3472.ko module contains 2 separate drivers, the int3472_discrete platform driver and the int3472_tps68470 I2C-driver. These 2 drivers contain very little shared code, only skl_int3472_get_acpi_buffer() and skl_int3472_fill_cldb() are shared. Split the module into 2 drivers, linking the little shared code directly into both. This will allow us to add soft-module dependencies for the tps68470 clk, gpio and regulator drivers to the new intel_skl_int3472_tps68470.ko to help with probe ordering issues without causing these modules to get loaded on boards which only use the int3472_discrete platform driver. While at it also rename the .c and .h files to remove the cumbersome intel_skl_int3472_ prefix. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20211203102857.44539-8-hdegoede@redhat.com
This commit is contained in:
parent
9dfa374cc6
commit
a2f9fbc247
@ -1,5 +1,4 @@
|
||||
obj-$(CONFIG_INTEL_SKL_INT3472) += intel_skl_int3472.o
|
||||
intel_skl_int3472-y := intel_skl_int3472_common.o \
|
||||
intel_skl_int3472_discrete.o \
|
||||
intel_skl_int3472_tps68470.o \
|
||||
intel_skl_int3472_clk_and_regulator.o
|
||||
obj-$(CONFIG_INTEL_SKL_INT3472) += 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 common.o
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <linux/regulator/driver.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "intel_skl_int3472_common.h"
|
||||
#include "common.h"
|
||||
|
||||
/*
|
||||
* The regulators have to have .ops to be valid, but the only ops we actually
|
54
drivers/platform/x86/intel/int3472/common.c
Normal file
54
drivers/platform/x86/intel/int3472/common.c
Normal file
@ -0,0 +1,54 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Author: Dan Scally <djrscally@gmail.com> */
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev, char *id)
|
||||
{
|
||||
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||
acpi_handle handle = adev->handle;
|
||||
union acpi_object *obj;
|
||||
acpi_status status;
|
||||
|
||||
status = acpi_evaluate_object(handle, id, NULL, &buffer);
|
||||
if (ACPI_FAILURE(status))
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
obj = buffer.pointer;
|
||||
if (!obj)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
if (obj->type != ACPI_TYPE_BUFFER) {
|
||||
acpi_handle_err(handle, "%s object is not an ACPI buffer\n", id);
|
||||
kfree(obj);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb)
|
||||
{
|
||||
union acpi_object *obj;
|
||||
int ret;
|
||||
|
||||
obj = skl_int3472_get_acpi_buffer(adev, "CLDB");
|
||||
if (IS_ERR(obj))
|
||||
return PTR_ERR(obj);
|
||||
|
||||
if (obj->buffer.length > sizeof(*cldb)) {
|
||||
acpi_handle_err(adev->handle, "The CLDB buffer is too large\n");
|
||||
ret = -EINVAL;
|
||||
goto out_free_obj;
|
||||
}
|
||||
|
||||
memcpy(cldb, obj->buffer.pointer, obj->buffer.length);
|
||||
ret = 0;
|
||||
|
||||
out_free_obj:
|
||||
kfree(obj);
|
||||
return ret;
|
||||
}
|
@ -105,9 +105,6 @@ struct int3472_discrete_device {
|
||||
struct gpiod_lookup_table gpios;
|
||||
};
|
||||
|
||||
int skl_int3472_discrete_probe(struct platform_device *pdev);
|
||||
int skl_int3472_discrete_remove(struct platform_device *pdev);
|
||||
int skl_int3472_tps68470_probe(struct i2c_client *client);
|
||||
union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
|
||||
char *id);
|
||||
int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);
|
@ -14,7 +14,7 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/uuid.h>
|
||||
|
||||
#include "intel_skl_int3472_common.h"
|
||||
#include "common.h"
|
||||
|
||||
/*
|
||||
* 79234640-9e10-4fea-a5c1-b5aa8b19756f
|
||||
@ -332,7 +332,9 @@ static int skl_int3472_parse_crs(struct int3472_discrete_device *int3472)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int skl_int3472_discrete_probe(struct platform_device *pdev)
|
||||
static int skl_int3472_discrete_remove(struct platform_device *pdev);
|
||||
|
||||
static int skl_int3472_discrete_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
|
||||
struct int3472_discrete_device *int3472;
|
||||
@ -395,7 +397,7 @@ err_put_sensor:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int skl_int3472_discrete_remove(struct platform_device *pdev)
|
||||
static int skl_int3472_discrete_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct int3472_discrete_device *int3472 = platform_get_drvdata(pdev);
|
||||
|
||||
@ -411,3 +413,23 @@ int skl_int3472_discrete_remove(struct platform_device *pdev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct acpi_device_id int3472_device_id[] = {
|
||||
{ "INT3472", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, int3472_device_id);
|
||||
|
||||
static struct platform_driver int3472_discrete = {
|
||||
.driver = {
|
||||
.name = "int3472-discrete",
|
||||
.acpi_match_table = int3472_device_id,
|
||||
},
|
||||
.probe = skl_int3472_discrete_probe,
|
||||
.remove = skl_int3472_discrete_remove,
|
||||
};
|
||||
module_platform_driver(int3472_discrete);
|
||||
|
||||
MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI Discrete Device Driver");
|
||||
MODULE_AUTHOR("Daniel Scally <djrscally@gmail.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
@ -1,106 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Author: Dan Scally <djrscally@gmail.com> */
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "intel_skl_int3472_common.h"
|
||||
|
||||
union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev, char *id)
|
||||
{
|
||||
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||
acpi_handle handle = adev->handle;
|
||||
union acpi_object *obj;
|
||||
acpi_status status;
|
||||
|
||||
status = acpi_evaluate_object(handle, id, NULL, &buffer);
|
||||
if (ACPI_FAILURE(status))
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
obj = buffer.pointer;
|
||||
if (!obj)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
if (obj->type != ACPI_TYPE_BUFFER) {
|
||||
acpi_handle_err(handle, "%s object is not an ACPI buffer\n", id);
|
||||
kfree(obj);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb)
|
||||
{
|
||||
union acpi_object *obj;
|
||||
int ret;
|
||||
|
||||
obj = skl_int3472_get_acpi_buffer(adev, "CLDB");
|
||||
if (IS_ERR(obj))
|
||||
return PTR_ERR(obj);
|
||||
|
||||
if (obj->buffer.length > sizeof(*cldb)) {
|
||||
acpi_handle_err(adev->handle, "The CLDB buffer is too large\n");
|
||||
ret = -EINVAL;
|
||||
goto out_free_obj;
|
||||
}
|
||||
|
||||
memcpy(cldb, obj->buffer.pointer, obj->buffer.length);
|
||||
ret = 0;
|
||||
|
||||
out_free_obj:
|
||||
kfree(obj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct acpi_device_id int3472_device_id[] = {
|
||||
{ "INT3472", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, int3472_device_id);
|
||||
|
||||
static struct platform_driver int3472_discrete = {
|
||||
.driver = {
|
||||
.name = "int3472-discrete",
|
||||
.acpi_match_table = int3472_device_id,
|
||||
},
|
||||
.probe = skl_int3472_discrete_probe,
|
||||
.remove = skl_int3472_discrete_remove,
|
||||
};
|
||||
|
||||
static struct i2c_driver int3472_tps68470 = {
|
||||
.driver = {
|
||||
.name = "int3472-tps68470",
|
||||
.acpi_match_table = int3472_device_id,
|
||||
},
|
||||
.probe_new = skl_int3472_tps68470_probe,
|
||||
};
|
||||
|
||||
static int skl_int3472_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = platform_driver_register(&int3472_discrete);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = i2c_register_driver(THIS_MODULE, &int3472_tps68470);
|
||||
if (ret)
|
||||
platform_driver_unregister(&int3472_discrete);
|
||||
|
||||
return ret;
|
||||
}
|
||||
module_init(skl_int3472_init);
|
||||
|
||||
static void skl_int3472_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&int3472_discrete);
|
||||
i2c_del_driver(&int3472_tps68470);
|
||||
}
|
||||
module_exit(skl_int3472_exit);
|
||||
|
||||
MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI Device Driver");
|
||||
MODULE_AUTHOR("Daniel Scally <djrscally@gmail.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
@ -7,7 +7,7 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/regmap.h>
|
||||
|
||||
#include "intel_skl_int3472_common.h"
|
||||
#include "common.h"
|
||||
|
||||
#define DESIGNED_FOR_CHROMEOS 1
|
||||
#define DESIGNED_FOR_WINDOWS 2
|
||||
@ -95,7 +95,7 @@ static int skl_int3472_tps68470_calc_type(struct acpi_device *adev)
|
||||
return DESIGNED_FOR_WINDOWS;
|
||||
}
|
||||
|
||||
int skl_int3472_tps68470_probe(struct i2c_client *client)
|
||||
static int skl_int3472_tps68470_probe(struct i2c_client *client)
|
||||
{
|
||||
struct acpi_device *adev = ACPI_COMPANION(&client->dev);
|
||||
struct regmap *regmap;
|
||||
@ -135,3 +135,22 @@ int skl_int3472_tps68470_probe(struct i2c_client *client)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct acpi_device_id int3472_device_id[] = {
|
||||
{ "INT3472", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, int3472_device_id);
|
||||
|
||||
static struct i2c_driver int3472_tps68470 = {
|
||||
.driver = {
|
||||
.name = "int3472-tps68470",
|
||||
.acpi_match_table = int3472_device_id,
|
||||
},
|
||||
.probe_new = skl_int3472_tps68470_probe,
|
||||
};
|
||||
module_i2c_driver(int3472_tps68470);
|
||||
|
||||
MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI TPS68470 Device Driver");
|
||||
MODULE_AUTHOR("Daniel Scally <djrscally@gmail.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
Loading…
Reference in New Issue
Block a user