Skip to content

Commit 508ccdf

Browse files
rafaeljwalexandrebelloni
authored andcommitted
rtc: cmos: Call cmos_wake_setup() from cmos_do_probe()
Notice that cmos_wake_setup() is the only user of acpi_rtc_info and it can operate on the cmos_rtc variable directly, so it need not set the platform_data pointer before cmos_do_probe() is called. Instead, it can be called by cmos_do_probe() in the case when the platform_data pointer is not set to implement the default behavior (which is to use the FADT information as long as ACPI support is enabled). Modify the code accordingly. While at it, drop a comment that doesn't really match the code it is supposed to be describing. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Zhang Rui <[email protected]> Tested-by: Zhang Rui <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/4803444.31r3eYUQgx@kreacher Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 60da738 commit 508ccdf

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

drivers/rtc/rtc-cmos.c

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@ static irqreturn_t cmos_interrupt(int irq, void *p)
744744
return IRQ_NONE;
745745
}
746746

747+
static void cmos_wake_setup(struct device *dev);
748+
747749
#ifdef CONFIG_PNP
748750
#define INITSECTION
749751

@@ -827,19 +829,27 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
827829
if (info->address_space)
828830
address_space = info->address_space;
829831

830-
if (info->rtc_day_alarm && info->rtc_day_alarm < 128)
831-
cmos_rtc.day_alrm = info->rtc_day_alarm;
832-
if (info->rtc_mon_alarm && info->rtc_mon_alarm < 128)
833-
cmos_rtc.mon_alrm = info->rtc_mon_alarm;
834-
if (info->rtc_century && info->rtc_century < 128)
835-
cmos_rtc.century = info->rtc_century;
832+
cmos_rtc.day_alrm = info->rtc_day_alarm;
833+
cmos_rtc.mon_alrm = info->rtc_mon_alarm;
834+
cmos_rtc.century = info->rtc_century;
836835

837836
if (info->wake_on && info->wake_off) {
838837
cmos_rtc.wake_on = info->wake_on;
839838
cmos_rtc.wake_off = info->wake_off;
840839
}
840+
} else {
841+
cmos_wake_setup(dev);
841842
}
842843

844+
if (cmos_rtc.day_alrm >= 128)
845+
cmos_rtc.day_alrm = 0;
846+
847+
if (cmos_rtc.mon_alrm >= 128)
848+
cmos_rtc.mon_alrm = 0;
849+
850+
if (cmos_rtc.century >= 128)
851+
cmos_rtc.century = 0;
852+
843853
cmos_rtc.dev = dev;
844854
dev_set_drvdata(dev, &cmos_rtc);
845855

@@ -1275,40 +1285,30 @@ static void use_acpi_alarm_quirks(void)
12751285
static inline void use_acpi_alarm_quirks(void) { }
12761286
#endif
12771287

1278-
/* Every ACPI platform has a mc146818 compatible "cmos rtc". Here we find
1279-
* its device node and pass extra config data. This helps its driver use
1280-
* capabilities that the now-obsolete mc146818 didn't have, and informs it
1281-
* that this board's RTC is wakeup-capable (per ACPI spec).
1282-
*/
1283-
static struct cmos_rtc_board_info acpi_rtc_info;
1284-
12851288
static void cmos_wake_setup(struct device *dev)
12861289
{
12871290
if (acpi_disabled)
12881291
return;
12891292

12901293
use_acpi_alarm_quirks();
12911294

1292-
acpi_rtc_info.wake_on = rtc_wake_on;
1293-
acpi_rtc_info.wake_off = rtc_wake_off;
1295+
cmos_rtc.wake_on = rtc_wake_on;
1296+
cmos_rtc.wake_off = rtc_wake_off;
12941297

1295-
/* workaround bug in some ACPI tables */
1298+
/* ACPI tables bug workaround. */
12961299
if (acpi_gbl_FADT.month_alarm && !acpi_gbl_FADT.day_alarm) {
12971300
dev_dbg(dev, "bogus FADT month_alarm (%d)\n",
12981301
acpi_gbl_FADT.month_alarm);
12991302
acpi_gbl_FADT.month_alarm = 0;
13001303
}
13011304

1302-
acpi_rtc_info.rtc_day_alarm = acpi_gbl_FADT.day_alarm;
1303-
acpi_rtc_info.rtc_mon_alarm = acpi_gbl_FADT.month_alarm;
1304-
acpi_rtc_info.rtc_century = acpi_gbl_FADT.century;
1305+
cmos_rtc.day_alrm = acpi_gbl_FADT.day_alarm;
1306+
cmos_rtc.mon_alrm = acpi_gbl_FADT.month_alarm;
1307+
cmos_rtc.century = acpi_gbl_FADT.century;
13051308

1306-
/* NOTE: S4_RTC_WAKE is NOT currently useful to Linux */
13071309
if (acpi_gbl_FADT.flags & ACPI_FADT_S4_RTC_WAKE)
13081310
dev_info(dev, "RTC can wake from S4\n");
13091311

1310-
dev->platform_data = &acpi_rtc_info;
1311-
13121312
/* RTC always wakes from S1/S2/S3, and often S4/STD */
13131313
device_init_wakeup(dev, 1);
13141314
}
@@ -1359,8 +1359,6 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
13591359
{
13601360
int irq, ret;
13611361

1362-
cmos_wake_setup(&pnp->dev);
1363-
13641362
if (pnp_port_start(pnp, 0) == 0x70 && !pnp_irq_valid(pnp, 0)) {
13651363
irq = 0;
13661364
#ifdef CONFIG_X86
@@ -1468,7 +1466,6 @@ static int __init cmos_platform_probe(struct platform_device *pdev)
14681466
int irq, ret;
14691467

14701468
cmos_of_init(pdev);
1471-
cmos_wake_setup(&pdev->dev);
14721469

14731470
if (RTC_IOMAPPED)
14741471
resource = platform_get_resource(pdev, IORESOURCE_IO, 0);

0 commit comments

Comments
 (0)