[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025020625-uncrown-equation-ceb5@gregkh>
Date: Thu, 6 Feb 2025 18:38:20 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org,
"Rafael J. Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>,
Lyude Paul <lyude@...hat.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Alexander Lobakin <aleksander.lobakin@...el.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Liam Girdwood <lgirdwood@...il.com>,
Lukas Wunner <lukas@...ner.de>,
Mark Brown <broonie@...nel.org>,
MaĆra Canal <mairacanal@...eup.net>,
Robin Murphy <robin.murphy@....com>,
Simona Vetter <simona.vetter@...ll.ch>,
Zijun Hu <quic_zijuhu@...cinc.com>,
linux-usb@...r.kernel.org,
rust-for-linux@...r.kernel.org,
Eric Piel <eric.piel@...mplin-utc.net>,
Arnd Bergmann <arnd@...db.de>
Subject: [PATCH v3 6/8] misc: lis3lv02d: convert to use faux_device
The lis3lv02d driver does not need to create a platform device, it only
did so because it was simple to do that in order to get a place in sysfs
to hang some device-specific attributes. Change it over to use the faux
device instead as this is NOT a real platform device, and it makes the
code even smaller than before.
Cc: Eric Piel <eric.piel@...mplin-utc.net>
Cc: Arnd Bergmann <arnd@...db.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
v3: new patch in the series. For an example of the api working, does
not have to be merged at this time, but I can take it if the
maintainers give an ack.
drivers/misc/lis3lv02d/lis3lv02d.c | 26 ++++++++++----------------
drivers/misc/lis3lv02d/lis3lv02d.h | 4 ++--
2 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
index 4233dc4cc7d6..3db54b6673c9 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
@@ -14,7 +14,6 @@
#include <linux/dmi.h>
#include <linux/module.h>
#include <linux/types.h>
-#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/input.h>
#include <linux/delay.h>
@@ -230,7 +229,7 @@ static int lis3lv02d_get_pwron_wait(struct lis3lv02d *lis3)
return 0;
}
- dev_err(&lis3->pdev->dev, "Error unknown odrs-index: %d\n", odr_idx);
+ dev_err(&lis3->fdev->dev, "Error unknown odrs-index: %d\n", odr_idx);
return -ENXIO;
}
@@ -694,7 +693,7 @@ int lis3lv02d_joystick_enable(struct lis3lv02d *lis3)
input_dev->phys = DRIVER_NAME "/input0";
input_dev->id.bustype = BUS_HOST;
input_dev->id.vendor = 0;
- input_dev->dev.parent = &lis3->pdev->dev;
+ input_dev->dev.parent = &lis3->fdev->dev;
input_dev->open = lis3lv02d_joystick_open;
input_dev->close = lis3lv02d_joystick_close;
@@ -855,32 +854,27 @@ static DEVICE_ATTR(position, S_IRUGO, lis3lv02d_position_show, NULL);
static DEVICE_ATTR(rate, S_IRUGO | S_IWUSR, lis3lv02d_rate_show,
lis3lv02d_rate_set);
-static struct attribute *lis3lv02d_attributes[] = {
+static struct attribute *lis3lv02d_attrs[] = {
&dev_attr_selftest.attr,
&dev_attr_position.attr,
&dev_attr_rate.attr,
NULL
};
-
-static const struct attribute_group lis3lv02d_attribute_group = {
- .attrs = lis3lv02d_attributes
-};
-
+ATTRIBUTE_GROUPS(lis3lv02d);
static int lis3lv02d_add_fs(struct lis3lv02d *lis3)
{
- lis3->pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
- if (IS_ERR(lis3->pdev))
- return PTR_ERR(lis3->pdev);
+ lis3->fdev = faux_device_create_with_groups(DRIVER_NAME, NULL, lis3lv02d_groups);
+ if (!lis3->fdev)
+ return -ENODEV;
- platform_set_drvdata(lis3->pdev, lis3);
- return sysfs_create_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group);
+ faux_device_set_drvdata(lis3->fdev, lis3);
+ return 0;
}
void lis3lv02d_remove_fs(struct lis3lv02d *lis3)
{
- sysfs_remove_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group);
- platform_device_unregister(lis3->pdev);
+ faux_device_destroy(lis3->fdev);
if (lis3->pm_dev) {
/* Barrier after the sysfs remove */
pm_runtime_barrier(lis3->pm_dev);
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
index 195bd2fd2eb5..989a49e57554 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.h
+++ b/drivers/misc/lis3lv02d/lis3lv02d.h
@@ -5,7 +5,7 @@
* Copyright (C) 2007-2008 Yan Burman
* Copyright (C) 2008-2009 Eric Piel
*/
-#include <linux/platform_device.h>
+#include <linux/device/faux.h>
#include <linux/input.h>
#include <linux/regulator/consumer.h>
#include <linux/miscdevice.h>
@@ -282,7 +282,7 @@ struct lis3lv02d {
*/
struct input_dev *idev; /* input device */
- struct platform_device *pdev; /* platform device */
+ struct faux_device *fdev; /* faux device */
struct regulator_bulk_data regulators[2];
atomic_t count; /* interrupt count after last read */
union axis_conversion ac; /* hw -> logical axis */
--
2.48.1
Powered by blists - more mailing lists