Skip to content

Commit a2f9fbc

Browse files
committed
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 <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9dfa374 commit a2f9fbc

File tree

7 files changed

+105
-120
lines changed

7 files changed

+105
-120
lines changed
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
obj-$(CONFIG_INTEL_SKL_INT3472) += intel_skl_int3472.o
2-
intel_skl_int3472-y := intel_skl_int3472_common.o \
3-
intel_skl_int3472_discrete.o \
4-
intel_skl_int3472_tps68470.o \
5-
intel_skl_int3472_clk_and_regulator.o
1+
obj-$(CONFIG_INTEL_SKL_INT3472) += intel_skl_int3472_discrete.o \
2+
intel_skl_int3472_tps68470.o
3+
intel_skl_int3472_discrete-y := discrete.o clk_and_regulator.o common.o
4+
intel_skl_int3472_tps68470-y := tps68470.o common.o

drivers/platform/x86/intel/int3472/intel_skl_int3472_clk_and_regulator.c renamed to drivers/platform/x86/intel/int3472/clk_and_regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <linux/regulator/driver.h>
1010
#include <linux/slab.h>
1111

12-
#include "intel_skl_int3472_common.h"
12+
#include "common.h"
1313

1414
/*
1515
* The regulators have to have .ops to be valid, but the only ops we actually
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Author: Dan Scally <[email protected]> */
3+
4+
#include <linux/acpi.h>
5+
#include <linux/slab.h>
6+
7+
#include "common.h"
8+
9+
union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev, char *id)
10+
{
11+
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
12+
acpi_handle handle = adev->handle;
13+
union acpi_object *obj;
14+
acpi_status status;
15+
16+
status = acpi_evaluate_object(handle, id, NULL, &buffer);
17+
if (ACPI_FAILURE(status))
18+
return ERR_PTR(-ENODEV);
19+
20+
obj = buffer.pointer;
21+
if (!obj)
22+
return ERR_PTR(-ENODEV);
23+
24+
if (obj->type != ACPI_TYPE_BUFFER) {
25+
acpi_handle_err(handle, "%s object is not an ACPI buffer\n", id);
26+
kfree(obj);
27+
return ERR_PTR(-EINVAL);
28+
}
29+
30+
return obj;
31+
}
32+
33+
int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb)
34+
{
35+
union acpi_object *obj;
36+
int ret;
37+
38+
obj = skl_int3472_get_acpi_buffer(adev, "CLDB");
39+
if (IS_ERR(obj))
40+
return PTR_ERR(obj);
41+
42+
if (obj->buffer.length > sizeof(*cldb)) {
43+
acpi_handle_err(adev->handle, "The CLDB buffer is too large\n");
44+
ret = -EINVAL;
45+
goto out_free_obj;
46+
}
47+
48+
memcpy(cldb, obj->buffer.pointer, obj->buffer.length);
49+
ret = 0;
50+
51+
out_free_obj:
52+
kfree(obj);
53+
return ret;
54+
}

drivers/platform/x86/intel/int3472/intel_skl_int3472_common.h renamed to drivers/platform/x86/intel/int3472/common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ struct int3472_discrete_device {
105105
struct gpiod_lookup_table gpios;
106106
};
107107

108-
int skl_int3472_discrete_probe(struct platform_device *pdev);
109-
int skl_int3472_discrete_remove(struct platform_device *pdev);
110-
int skl_int3472_tps68470_probe(struct i2c_client *client);
111108
union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev,
112109
char *id);
113110
int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb);

drivers/platform/x86/intel/int3472/intel_skl_int3472_discrete.c renamed to drivers/platform/x86/intel/int3472/discrete.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <linux/platform_device.h>
1515
#include <linux/uuid.h>
1616

17-
#include "intel_skl_int3472_common.h"
17+
#include "common.h"
1818

1919
/*
2020
* 79234640-9e10-4fea-a5c1-b5aa8b19756f
@@ -332,7 +332,9 @@ static int skl_int3472_parse_crs(struct int3472_discrete_device *int3472)
332332
return 0;
333333
}
334334

335-
int skl_int3472_discrete_probe(struct platform_device *pdev)
335+
static int skl_int3472_discrete_remove(struct platform_device *pdev);
336+
337+
static int skl_int3472_discrete_probe(struct platform_device *pdev)
336338
{
337339
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
338340
struct int3472_discrete_device *int3472;
@@ -395,7 +397,7 @@ int skl_int3472_discrete_probe(struct platform_device *pdev)
395397
return ret;
396398
}
397399

398-
int skl_int3472_discrete_remove(struct platform_device *pdev)
400+
static int skl_int3472_discrete_remove(struct platform_device *pdev)
399401
{
400402
struct int3472_discrete_device *int3472 = platform_get_drvdata(pdev);
401403

@@ -411,3 +413,23 @@ int skl_int3472_discrete_remove(struct platform_device *pdev)
411413

412414
return 0;
413415
}
416+
417+
static const struct acpi_device_id int3472_device_id[] = {
418+
{ "INT3472", 0 },
419+
{ }
420+
};
421+
MODULE_DEVICE_TABLE(acpi, int3472_device_id);
422+
423+
static struct platform_driver int3472_discrete = {
424+
.driver = {
425+
.name = "int3472-discrete",
426+
.acpi_match_table = int3472_device_id,
427+
},
428+
.probe = skl_int3472_discrete_probe,
429+
.remove = skl_int3472_discrete_remove,
430+
};
431+
module_platform_driver(int3472_discrete);
432+
433+
MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI Discrete Device Driver");
434+
MODULE_AUTHOR("Daniel Scally <[email protected]>");
435+
MODULE_LICENSE("GPL v2");

drivers/platform/x86/intel/int3472/intel_skl_int3472_common.c

Lines changed: 0 additions & 106 deletions
This file was deleted.

drivers/platform/x86/intel/int3472/intel_skl_int3472_tps68470.c renamed to drivers/platform/x86/intel/int3472/tps68470.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <linux/platform_device.h>
88
#include <linux/regmap.h>
99

10-
#include "intel_skl_int3472_common.h"
10+
#include "common.h"
1111

1212
#define DESIGNED_FOR_CHROMEOS 1
1313
#define DESIGNED_FOR_WINDOWS 2
@@ -95,7 +95,7 @@ static int skl_int3472_tps68470_calc_type(struct acpi_device *adev)
9595
return DESIGNED_FOR_WINDOWS;
9696
}
9797

98-
int skl_int3472_tps68470_probe(struct i2c_client *client)
98+
static int skl_int3472_tps68470_probe(struct i2c_client *client)
9999
{
100100
struct acpi_device *adev = ACPI_COMPANION(&client->dev);
101101
struct regmap *regmap;
@@ -135,3 +135,22 @@ int skl_int3472_tps68470_probe(struct i2c_client *client)
135135

136136
return ret;
137137
}
138+
139+
static const struct acpi_device_id int3472_device_id[] = {
140+
{ "INT3472", 0 },
141+
{ }
142+
};
143+
MODULE_DEVICE_TABLE(acpi, int3472_device_id);
144+
145+
static struct i2c_driver int3472_tps68470 = {
146+
.driver = {
147+
.name = "int3472-tps68470",
148+
.acpi_match_table = int3472_device_id,
149+
},
150+
.probe_new = skl_int3472_tps68470_probe,
151+
};
152+
module_i2c_driver(int3472_tps68470);
153+
154+
MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI TPS68470 Device Driver");
155+
MODULE_AUTHOR("Daniel Scally <[email protected]>");
156+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)