Skip to content

Commit 3b18ccb

Browse files
committed
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 <[email protected]> Cc: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/2025021028-shortcake-stained-b0a8@gregkh Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 72239a7 commit 3b18ccb

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

drivers/misc/lis3lv02d/lis3lv02d.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <linux/dmi.h>
1515
#include <linux/module.h>
1616
#include <linux/types.h>
17-
#include <linux/platform_device.h>
1817
#include <linux/interrupt.h>
1918
#include <linux/input.h>
2019
#include <linux/delay.h>
@@ -230,7 +229,7 @@ static int lis3lv02d_get_pwron_wait(struct lis3lv02d *lis3)
230229
return 0;
231230
}
232231

233-
dev_err(&lis3->pdev->dev, "Error unknown odrs-index: %d\n", odr_idx);
232+
dev_err(&lis3->fdev->dev, "Error unknown odrs-index: %d\n", odr_idx);
234233
return -ENXIO;
235234
}
236235

@@ -694,7 +693,7 @@ int lis3lv02d_joystick_enable(struct lis3lv02d *lis3)
694693
input_dev->phys = DRIVER_NAME "/input0";
695694
input_dev->id.bustype = BUS_HOST;
696695
input_dev->id.vendor = 0;
697-
input_dev->dev.parent = &lis3->pdev->dev;
696+
input_dev->dev.parent = &lis3->fdev->dev;
698697

699698
input_dev->open = lis3lv02d_joystick_open;
700699
input_dev->close = lis3lv02d_joystick_close;
@@ -855,32 +854,27 @@ static DEVICE_ATTR(position, S_IRUGO, lis3lv02d_position_show, NULL);
855854
static DEVICE_ATTR(rate, S_IRUGO | S_IWUSR, lis3lv02d_rate_show,
856855
lis3lv02d_rate_set);
857856

858-
static struct attribute *lis3lv02d_attributes[] = {
857+
static struct attribute *lis3lv02d_attrs[] = {
859858
&dev_attr_selftest.attr,
860859
&dev_attr_position.attr,
861860
&dev_attr_rate.attr,
862861
NULL
863862
};
864-
865-
static const struct attribute_group lis3lv02d_attribute_group = {
866-
.attrs = lis3lv02d_attributes
867-
};
868-
863+
ATTRIBUTE_GROUPS(lis3lv02d);
869864

870865
static int lis3lv02d_add_fs(struct lis3lv02d *lis3)
871866
{
872-
lis3->pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
873-
if (IS_ERR(lis3->pdev))
874-
return PTR_ERR(lis3->pdev);
867+
lis3->fdev = faux_device_create_with_groups(DRIVER_NAME, NULL, NULL, lis3lv02d_groups);
868+
if (!lis3->fdev)
869+
return -ENODEV;
875870

876-
platform_set_drvdata(lis3->pdev, lis3);
877-
return sysfs_create_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group);
871+
faux_device_set_drvdata(lis3->fdev, lis3);
872+
return 0;
878873
}
879874

880875
void lis3lv02d_remove_fs(struct lis3lv02d *lis3)
881876
{
882-
sysfs_remove_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group);
883-
platform_device_unregister(lis3->pdev);
877+
faux_device_destroy(lis3->fdev);
884878
if (lis3->pm_dev) {
885879
/* Barrier after the sysfs remove */
886880
pm_runtime_barrier(lis3->pm_dev);

drivers/misc/lis3lv02d/lis3lv02d.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Copyright (C) 2007-2008 Yan Burman
66
* Copyright (C) 2008-2009 Eric Piel
77
*/
8-
#include <linux/platform_device.h>
8+
#include <linux/device/faux.h>
99
#include <linux/input.h>
1010
#include <linux/regulator/consumer.h>
1111
#include <linux/miscdevice.h>
@@ -282,7 +282,7 @@ struct lis3lv02d {
282282
*/
283283

284284
struct input_dev *idev; /* input device */
285-
struct platform_device *pdev; /* platform device */
285+
struct faux_device *fdev; /* faux device */
286286
struct regulator_bulk_data regulators[2];
287287
atomic_t count; /* interrupt count after last read */
288288
union axis_conversion ac; /* hw -> logical axis */

0 commit comments

Comments
 (0)