mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
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@tremplin-utc.net> Cc: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/2025021028-shortcake-stained-b0a8@gregkh Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
72239a78f9
commit
3b18ccb547
2 changed files with 12 additions and 18 deletions
|
@ -14,7 +14,6 @@
|
||||||
#include <linux/dmi.h>
|
#include <linux/dmi.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/platform_device.h>
|
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
@ -230,7 +229,7 @@ static int lis3lv02d_get_pwron_wait(struct lis3lv02d *lis3)
|
||||||
return 0;
|
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;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,7 +693,7 @@ int lis3lv02d_joystick_enable(struct lis3lv02d *lis3)
|
||||||
input_dev->phys = DRIVER_NAME "/input0";
|
input_dev->phys = DRIVER_NAME "/input0";
|
||||||
input_dev->id.bustype = BUS_HOST;
|
input_dev->id.bustype = BUS_HOST;
|
||||||
input_dev->id.vendor = 0;
|
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->open = lis3lv02d_joystick_open;
|
||||||
input_dev->close = lis3lv02d_joystick_close;
|
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,
|
static DEVICE_ATTR(rate, S_IRUGO | S_IWUSR, lis3lv02d_rate_show,
|
||||||
lis3lv02d_rate_set);
|
lis3lv02d_rate_set);
|
||||||
|
|
||||||
static struct attribute *lis3lv02d_attributes[] = {
|
static struct attribute *lis3lv02d_attrs[] = {
|
||||||
&dev_attr_selftest.attr,
|
&dev_attr_selftest.attr,
|
||||||
&dev_attr_position.attr,
|
&dev_attr_position.attr,
|
||||||
&dev_attr_rate.attr,
|
&dev_attr_rate.attr,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
ATTRIBUTE_GROUPS(lis3lv02d);
|
||||||
static const struct attribute_group lis3lv02d_attribute_group = {
|
|
||||||
.attrs = lis3lv02d_attributes
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static int lis3lv02d_add_fs(struct lis3lv02d *lis3)
|
static int lis3lv02d_add_fs(struct lis3lv02d *lis3)
|
||||||
{
|
{
|
||||||
lis3->pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
|
lis3->fdev = faux_device_create_with_groups(DRIVER_NAME, NULL, NULL, lis3lv02d_groups);
|
||||||
if (IS_ERR(lis3->pdev))
|
if (!lis3->fdev)
|
||||||
return PTR_ERR(lis3->pdev);
|
return -ENODEV;
|
||||||
|
|
||||||
platform_set_drvdata(lis3->pdev, lis3);
|
faux_device_set_drvdata(lis3->fdev, lis3);
|
||||||
return sysfs_create_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lis3lv02d_remove_fs(struct lis3lv02d *lis3)
|
void lis3lv02d_remove_fs(struct lis3lv02d *lis3)
|
||||||
{
|
{
|
||||||
sysfs_remove_group(&lis3->pdev->dev.kobj, &lis3lv02d_attribute_group);
|
faux_device_destroy(lis3->fdev);
|
||||||
platform_device_unregister(lis3->pdev);
|
|
||||||
if (lis3->pm_dev) {
|
if (lis3->pm_dev) {
|
||||||
/* Barrier after the sysfs remove */
|
/* Barrier after the sysfs remove */
|
||||||
pm_runtime_barrier(lis3->pm_dev);
|
pm_runtime_barrier(lis3->pm_dev);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* Copyright (C) 2007-2008 Yan Burman
|
* Copyright (C) 2007-2008 Yan Burman
|
||||||
* Copyright (C) 2008-2009 Eric Piel
|
* Copyright (C) 2008-2009 Eric Piel
|
||||||
*/
|
*/
|
||||||
#include <linux/platform_device.h>
|
#include <linux/device/faux.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <linux/regulator/consumer.h>
|
#include <linux/regulator/consumer.h>
|
||||||
#include <linux/miscdevice.h>
|
#include <linux/miscdevice.h>
|
||||||
|
@ -282,7 +282,7 @@ struct lis3lv02d {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct input_dev *idev; /* input device */
|
struct input_dev *idev; /* input device */
|
||||||
struct platform_device *pdev; /* platform device */
|
struct faux_device *fdev; /* faux device */
|
||||||
struct regulator_bulk_data regulators[2];
|
struct regulator_bulk_data regulators[2];
|
||||||
atomic_t count; /* interrupt count after last read */
|
atomic_t count; /* interrupt count after last read */
|
||||||
union axis_conversion ac; /* hw -> logical axis */
|
union axis_conversion ac; /* hw -> logical axis */
|
||||||
|
|
Loading…
Add table
Reference in a new issue