Skip to content

Commit 72239a7

Browse files
committed
tlclk: convert to use faux_device
The tlclk 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: Mark Gross <markgross@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/2025021028-askew-smashing-4ff9@gregkh Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent dcd2a9a commit 72239a7

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

drivers/char/tlclk.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include <linux/sysfs.h>
4343
#include <linux/device.h>
4444
#include <linux/miscdevice.h>
45-
#include <linux/platform_device.h>
45+
#include <linux/device/faux.h>
4646
#include <asm/io.h> /* inb/outb */
4747
#include <linux/uaccess.h>
4848

@@ -742,7 +742,7 @@ static ssize_t store_reset (struct device *d,
742742

743743
static DEVICE_ATTR(reset, (S_IWUSR|S_IWGRP), NULL, store_reset);
744744

745-
static struct attribute *tlclk_sysfs_entries[] = {
745+
static struct attribute *tlclk_attrs[] = {
746746
&dev_attr_current_ref.attr,
747747
&dev_attr_telclock_version.attr,
748748
&dev_attr_alarms.attr,
@@ -766,13 +766,9 @@ static struct attribute *tlclk_sysfs_entries[] = {
766766
&dev_attr_reset.attr,
767767
NULL
768768
};
769+
ATTRIBUTE_GROUPS(tlclk);
769770

770-
static const struct attribute_group tlclk_attribute_group = {
771-
.name = NULL, /* put in device directory */
772-
.attrs = tlclk_sysfs_entries,
773-
};
774-
775-
static struct platform_device *tlclk_device;
771+
static struct faux_device *tlclk_device;
776772

777773
static int __init tlclk_init(void)
778774
{
@@ -817,24 +813,13 @@ static int __init tlclk_init(void)
817813
goto out3;
818814
}
819815

820-
tlclk_device = platform_device_register_simple("telco_clock",
821-
-1, NULL, 0);
822-
if (IS_ERR(tlclk_device)) {
823-
printk(KERN_ERR "tlclk: platform_device_register failed.\n");
824-
ret = PTR_ERR(tlclk_device);
816+
tlclk_device = faux_device_create_with_groups("telco_clock", NULL, NULL, tlclk_groups);
817+
if (!tlclk_device) {
818+
ret = -ENODEV;
825819
goto out4;
826820
}
827821

828-
ret = sysfs_create_group(&tlclk_device->dev.kobj,
829-
&tlclk_attribute_group);
830-
if (ret) {
831-
printk(KERN_ERR "tlclk: failed to create sysfs device attributes.\n");
832-
goto out5;
833-
}
834-
835822
return 0;
836-
out5:
837-
platform_device_unregister(tlclk_device);
838823
out4:
839824
misc_deregister(&tlclk_miscdev);
840825
out3:
@@ -848,8 +833,7 @@ static int __init tlclk_init(void)
848833

849834
static void __exit tlclk_cleanup(void)
850835
{
851-
sysfs_remove_group(&tlclk_device->dev.kobj, &tlclk_attribute_group);
852-
platform_device_unregister(tlclk_device);
836+
faux_device_destroy(tlclk_device);
853837
misc_deregister(&tlclk_miscdev);
854838
unregister_chrdev(tlclk_major, "telco_clock");
855839

0 commit comments

Comments
 (0)