Skip to content

Commit b14b77b

Browse files
committed
ACPI: TAD: Split three functions to untangle runtime PM handling
Move the core functionality of acpi_tad_get_real_time(), acpi_tad_wake_set(), and acpi_tad_wake_read() into separate functions called __acpi_tad_get_real_time(), __acpi_tad_wake_set(), and __acpi_tad_wake_read(), respectively, which can be called from code blocks following a single runtime resume of the device. This will facilitate adding alarm support to the RTC class device interface of the driver going forward. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://patch.msgid.link/23076728.EfDdHjke4D@rafael.j.wysocki
1 parent f706a63 commit b14b77b

1 file changed

Lines changed: 40 additions & 17 deletions

File tree

drivers/acpi/acpi_tad.c

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,10 @@ static int acpi_tad_evaluate_grt(struct device *dev, struct acpi_tad_rt *rt)
151151
return ret;
152152
}
153153

154-
static int acpi_tad_get_real_time(struct device *dev, struct acpi_tad_rt *rt)
154+
static int __acpi_tad_get_real_time(struct device *dev, struct acpi_tad_rt *rt)
155155
{
156156
int ret;
157157

158-
PM_RUNTIME_ACQUIRE(dev, pm);
159-
if (PM_RUNTIME_ACQUIRE_ERR(&pm))
160-
return -ENXIO;
161-
162158
ret = acpi_tad_evaluate_grt(dev, rt);
163159
if (ret)
164160
return ret;
@@ -169,6 +165,15 @@ static int acpi_tad_get_real_time(struct device *dev, struct acpi_tad_rt *rt)
169165
return 0;
170166
}
171167

168+
static int acpi_tad_get_real_time(struct device *dev, struct acpi_tad_rt *rt)
169+
{
170+
PM_RUNTIME_ACQUIRE(dev, pm);
171+
if (PM_RUNTIME_ACQUIRE_ERR(&pm))
172+
return -ENXIO;
173+
174+
return __acpi_tad_get_real_time(dev, rt);
175+
}
176+
172177
/* sysfs interface */
173178

174179
static char *acpi_tad_rt_next_field(char *s, int *val)
@@ -268,8 +273,8 @@ static ssize_t time_show(struct device *dev, struct device_attribute *attr,
268273

269274
static DEVICE_ATTR_RW(time);
270275

271-
static int acpi_tad_wake_set(struct device *dev, char *method, u32 timer_id,
272-
u32 value)
276+
static int __acpi_tad_wake_set(struct device *dev, char *method, u32 timer_id,
277+
u32 value)
273278
{
274279
acpi_handle handle = ACPI_HANDLE(dev);
275280
union acpi_object args[] = {
@@ -286,17 +291,23 @@ static int acpi_tad_wake_set(struct device *dev, char *method, u32 timer_id,
286291
args[0].integer.value = timer_id;
287292
args[1].integer.value = value;
288293

289-
PM_RUNTIME_ACQUIRE(dev, pm);
290-
if (PM_RUNTIME_ACQUIRE_ERR(&pm))
291-
return -ENXIO;
292-
293294
status = acpi_evaluate_integer(handle, method, &arg_list, &retval);
294295
if (ACPI_FAILURE(status) || retval)
295296
return -EIO;
296297

297298
return 0;
298299
}
299300

301+
static int acpi_tad_wake_set(struct device *dev, char *method, u32 timer_id,
302+
u32 value)
303+
{
304+
PM_RUNTIME_ACQUIRE(dev, pm);
305+
if (PM_RUNTIME_ACQUIRE_ERR(&pm))
306+
return -ENXIO;
307+
308+
return __acpi_tad_wake_set(dev, method, timer_id, value);
309+
}
310+
300311
static int acpi_tad_wake_write(struct device *dev, const char *buf, char *method,
301312
u32 timer_id, const char *specval)
302313
{
@@ -317,8 +328,8 @@ static int acpi_tad_wake_write(struct device *dev, const char *buf, char *method
317328
return acpi_tad_wake_set(dev, method, timer_id, value);
318329
}
319330

320-
static ssize_t acpi_tad_wake_read(struct device *dev, char *buf, char *method,
321-
u32 timer_id, const char *specval)
331+
static int __acpi_tad_wake_read(struct device *dev, char *method, u32 timer_id,
332+
unsigned long long *retval)
322333
{
323334
acpi_handle handle = ACPI_HANDLE(dev);
324335
union acpi_object args[] = {
@@ -328,18 +339,30 @@ static ssize_t acpi_tad_wake_read(struct device *dev, char *buf, char *method,
328339
.pointer = args,
329340
.count = ARRAY_SIZE(args),
330341
};
331-
unsigned long long retval;
332342
acpi_status status;
333343

334344
args[0].integer.value = timer_id;
335345

346+
status = acpi_evaluate_integer(handle, method, &arg_list, retval);
347+
if (ACPI_FAILURE(status))
348+
return -EIO;
349+
350+
return 0;
351+
}
352+
353+
static ssize_t acpi_tad_wake_read(struct device *dev, char *buf, char *method,
354+
u32 timer_id, const char *specval)
355+
{
356+
unsigned long long retval;
357+
int ret;
358+
336359
PM_RUNTIME_ACQUIRE(dev, pm);
337360
if (PM_RUNTIME_ACQUIRE_ERR(&pm))
338361
return -ENXIO;
339362

340-
status = acpi_evaluate_integer(handle, method, &arg_list, &retval);
341-
if (ACPI_FAILURE(status))
342-
return -EIO;
363+
ret = __acpi_tad_wake_read(dev, method, timer_id, &retval);
364+
if (ret)
365+
return ret;
343366

344367
if ((u32)retval == ACPI_TAD_WAKE_DISABLED)
345368
return sprintf(buf, "%s\n", specval);

0 commit comments

Comments
 (0)