Skip to content

Commit 871db98

Browse files
committed
platform/x86: dell-smo8800: Convert to be a platform driver
JIRA: https://issues.redhat.com/browse/RHEL-47426 Conflicts: RHEL dae377d removed the 'return 0' statement in smo8800_remove but it needs to be restored in order for this commit to compile. commit bc6b8d7 Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: Tue Aug 3 22:40:39 2021 +0300 platform/x86: dell-smo8800: Convert to be a platform driver ACPI core in conjunction with platform driver core provides an infrastructure to enumerate ACPI devices. Use it in order to remove a lot of boilerplate code. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Pali Rohár <pali@kernel.org> Tested-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/20210803194039.35083-1-andriy.shevchenko@linux.intel.com Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent 5417834 commit 871db98

File tree

2 files changed

+21
-56
lines changed

2 files changed

+21
-56
lines changed

drivers/platform/x86/dell/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ config DELL_SMBIOS_SMM
140140
config DELL_SMO8800
141141
tristate "Dell Latitude freefall driver (ACPI SMO88XX)"
142142
default m
143-
depends on ACPI
143+
depends on ACPI || COMPILE_TEST
144144
help
145145
Say Y here if you want to support SMO88XX freefall devices
146146
on Dell Latitude laptops.

drivers/platform/x86/dell/dell-smo8800.c

Lines changed: 20 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010

1111
#define DRIVER_NAME "smo8800"
1212

13-
#include <linux/kernel.h>
14-
#include <linux/module.h>
15-
#include <linux/acpi.h>
13+
#include <linux/fs.h>
1614
#include <linux/interrupt.h>
15+
#include <linux/kernel.h>
1716
#include <linux/miscdevice.h>
17+
#include <linux/mod_devicetable.h>
18+
#include <linux/module.h>
19+
#include <linux/platform_device.h>
1820
#include <linux/uaccess.h>
19-
#include <linux/fs.h>
2021

2122
struct smo8800_device {
2223
u32 irq; /* acpi device irq */
@@ -44,37 +45,6 @@ static irqreturn_t smo8800_interrupt_thread(int irq, void *data)
4445
return IRQ_HANDLED;
4546
}
4647

47-
static acpi_status smo8800_get_resource(struct acpi_resource *resource,
48-
void *context)
49-
{
50-
struct acpi_resource_extended_irq *irq;
51-
52-
if (resource->type != ACPI_RESOURCE_TYPE_EXTENDED_IRQ)
53-
return AE_OK;
54-
55-
irq = &resource->data.extended_irq;
56-
if (!irq || !irq->interrupt_count)
57-
return AE_OK;
58-
59-
*((u32 *)context) = irq->interrupts[0];
60-
return AE_CTRL_TERMINATE;
61-
}
62-
63-
static u32 smo8800_get_irq(struct acpi_device *device)
64-
{
65-
u32 irq = 0;
66-
acpi_status status;
67-
68-
status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
69-
smo8800_get_resource, &irq);
70-
if (ACPI_FAILURE(status)) {
71-
dev_err(&device->dev, "acpi_walk_resources failed\n");
72-
return 0;
73-
}
74-
75-
return irq;
76-
}
77-
7848
static ssize_t smo8800_misc_read(struct file *file, char __user *buf,
7949
size_t count, loff_t *pos)
8050
{
@@ -136,7 +106,7 @@ static const struct file_operations smo8800_misc_fops = {
136106
.release = smo8800_misc_release,
137107
};
138108

139-
static int smo8800_add(struct acpi_device *device)
109+
static int smo8800_probe(struct platform_device *device)
140110
{
141111
int err;
142112
struct smo8800_device *smo8800;
@@ -160,14 +130,12 @@ static int smo8800_add(struct acpi_device *device)
160130
return err;
161131
}
162132

163-
device->driver_data = smo8800;
133+
platform_set_drvdata(device, smo8800);
164134

165-
smo8800->irq = smo8800_get_irq(device);
166-
if (!smo8800->irq) {
167-
dev_err(&device->dev, "failed to obtain IRQ\n");
168-
err = -EINVAL;
135+
err = platform_get_irq(device, 0);
136+
if (err < 0)
169137
goto error;
170-
}
138+
smo8800->irq = err;
171139

172140
err = request_threaded_irq(smo8800->irq, smo8800_interrupt_quick,
173141
smo8800_interrupt_thread,
@@ -189,13 +157,14 @@ static int smo8800_add(struct acpi_device *device)
189157
return err;
190158
}
191159

192-
static void smo8800_remove(struct acpi_device *device)
160+
static int smo8800_remove(struct platform_device *device)
193161
{
194-
struct smo8800_device *smo8800 = device->driver_data;
162+
struct smo8800_device *smo8800 = platform_get_drvdata(device);
195163

196164
free_irq(smo8800->irq, smo8800);
197165
misc_deregister(&smo8800->miscdev);
198166
dev_dbg(&device->dev, "device /dev/freefall unregistered\n");
167+
return 0;
199168
}
200169

201170
/* NOTE: Keep this list in sync with drivers/i2c/busses/i2c-i801.c */
@@ -210,21 +179,17 @@ static const struct acpi_device_id smo8800_ids[] = {
210179
{ "SMO8831", 0 },
211180
{ "", 0 },
212181
};
213-
214182
MODULE_DEVICE_TABLE(acpi, smo8800_ids);
215183

216-
static struct acpi_driver smo8800_driver = {
217-
.name = DRIVER_NAME,
218-
.class = "Latitude",
219-
.ids = smo8800_ids,
220-
.ops = {
221-
.add = smo8800_add,
222-
.remove = smo8800_remove,
184+
static struct platform_driver smo8800_driver = {
185+
.probe = smo8800_probe,
186+
.remove = smo8800_remove,
187+
.driver = {
188+
.name = DRIVER_NAME,
189+
.acpi_match_table = smo8800_ids,
223190
},
224-
.owner = THIS_MODULE,
225191
};
226-
227-
module_acpi_driver(smo8800_driver);
192+
module_platform_driver(smo8800_driver);
228193

229194
MODULE_DESCRIPTION("Dell Latitude freefall driver (ACPI SMO88XX)");
230195
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)