mirror of
https://github.com/torvalds/linux.git
synced 2024-11-12 23:23:03 +00:00
rtc: class: make rtc_class constant
Since commit 43a7206b09
("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the rtc_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240305-class_cleanup-abelloni-v1-1-944c026137c8@marliere.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
32a6be0858
commit
6b6ca09611
@ -21,7 +21,6 @@
|
|||||||
#include "rtc-core.h"
|
#include "rtc-core.h"
|
||||||
|
|
||||||
static DEFINE_IDA(rtc_ida);
|
static DEFINE_IDA(rtc_ida);
|
||||||
struct class *rtc_class;
|
|
||||||
|
|
||||||
static void rtc_device_release(struct device *dev)
|
static void rtc_device_release(struct device *dev)
|
||||||
{
|
{
|
||||||
@ -199,6 +198,11 @@ static SIMPLE_DEV_PM_OPS(rtc_class_dev_pm_ops, rtc_suspend, rtc_resume);
|
|||||||
#define RTC_CLASS_DEV_PM_OPS NULL
|
#define RTC_CLASS_DEV_PM_OPS NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const struct class rtc_class = {
|
||||||
|
.name = "rtc",
|
||||||
|
.pm = RTC_CLASS_DEV_PM_OPS,
|
||||||
|
};
|
||||||
|
|
||||||
/* Ensure the caller will set the id before releasing the device */
|
/* Ensure the caller will set the id before releasing the device */
|
||||||
static struct rtc_device *rtc_allocate_device(void)
|
static struct rtc_device *rtc_allocate_device(void)
|
||||||
{
|
{
|
||||||
@ -220,7 +224,7 @@ static struct rtc_device *rtc_allocate_device(void)
|
|||||||
|
|
||||||
rtc->irq_freq = 1;
|
rtc->irq_freq = 1;
|
||||||
rtc->max_user_freq = 64;
|
rtc->max_user_freq = 64;
|
||||||
rtc->dev.class = rtc_class;
|
rtc->dev.class = &rtc_class;
|
||||||
rtc->dev.groups = rtc_get_dev_attribute_groups();
|
rtc->dev.groups = rtc_get_dev_attribute_groups();
|
||||||
rtc->dev.release = rtc_device_release;
|
rtc->dev.release = rtc_device_release;
|
||||||
|
|
||||||
@ -475,13 +479,14 @@ EXPORT_SYMBOL_GPL(devm_rtc_device_register);
|
|||||||
|
|
||||||
static int __init rtc_init(void)
|
static int __init rtc_init(void)
|
||||||
{
|
{
|
||||||
rtc_class = class_create("rtc");
|
int err;
|
||||||
if (IS_ERR(rtc_class)) {
|
|
||||||
pr_err("couldn't create class\n");
|
err = class_register(&rtc_class);
|
||||||
return PTR_ERR(rtc_class);
|
if (err)
|
||||||
}
|
return err;
|
||||||
rtc_class->pm = RTC_CLASS_DEV_PM_OPS;
|
|
||||||
rtc_dev_init();
|
rtc_dev_init();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
subsys_initcall(rtc_init);
|
subsys_initcall(rtc_init);
|
||||||
|
@ -696,7 +696,7 @@ struct rtc_device *rtc_class_open(const char *name)
|
|||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct rtc_device *rtc = NULL;
|
struct rtc_device *rtc = NULL;
|
||||||
|
|
||||||
dev = class_find_device_by_name(rtc_class, name);
|
dev = class_find_device_by_name(&rtc_class, name);
|
||||||
if (dev)
|
if (dev)
|
||||||
rtc = to_rtc_device(dev);
|
rtc = to_rtc_device(dev);
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ static inline time64_t rtc_tm_sub(struct rtc_time *lhs, struct rtc_time *rhs)
|
|||||||
#include <linux/timerqueue.h>
|
#include <linux/timerqueue.h>
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
|
|
||||||
extern struct class *rtc_class;
|
extern const struct class rtc_class;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For these RTC methods the device parameter is the physical device
|
* For these RTC methods the device parameter is the physical device
|
||||||
|
@ -201,7 +201,7 @@ static int __init test_suspend(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* RTCs have initialized by now too ... can we use one? */
|
/* RTCs have initialized by now too ... can we use one? */
|
||||||
dev = class_find_device(rtc_class, NULL, NULL, has_wakealarm);
|
dev = class_find_device(&rtc_class, NULL, NULL, has_wakealarm);
|
||||||
if (dev) {
|
if (dev) {
|
||||||
rtc = rtc_class_open(dev_name(dev));
|
rtc = rtc_class_open(dev_name(dev));
|
||||||
put_device(dev);
|
put_device(dev);
|
||||||
|
@ -134,7 +134,7 @@ static struct class_interface alarmtimer_rtc_interface = {
|
|||||||
|
|
||||||
static int alarmtimer_rtc_interface_setup(void)
|
static int alarmtimer_rtc_interface_setup(void)
|
||||||
{
|
{
|
||||||
alarmtimer_rtc_interface.class = rtc_class;
|
alarmtimer_rtc_interface.class = &rtc_class;
|
||||||
return class_interface_register(&alarmtimer_rtc_interface);
|
return class_interface_register(&alarmtimer_rtc_interface);
|
||||||
}
|
}
|
||||||
static void alarmtimer_rtc_interface_remove(void)
|
static void alarmtimer_rtc_interface_remove(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user