* [PATCH 1/2] rtc: fix module reference count in rtc-proc
@ 2015-11-07 4:00 Geliang Tang
2015-11-07 4:00 ` [PATCH 2/2] rtc: efi: add efi_procfs in efi_rtc_ops Geliang Tang
2015-11-30 19:03 ` [PATCH 1/2] rtc: fix module reference count in rtc-proc Alexandre Belloni
0 siblings, 2 replies; 4+ messages in thread
From: Geliang Tang @ 2015-11-07 4:00 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni; +Cc: Geliang Tang, rtc-linux, linux-kernel
rtc-proc.c is not built as a module. Thus, rather than dealing with
THIS_MODULE's reference count, we should deal with rtc->owner's
reference count.
Signed-off-by: Geliang Tang <geliangtang@163.com>
---
drivers/rtc/rtc-proc.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index ffa69e1..31e7e23 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -112,19 +112,21 @@ static int rtc_proc_open(struct inode *inode, struct file *file)
int ret;
struct rtc_device *rtc = PDE_DATA(inode);
- if (!try_module_get(THIS_MODULE))
+ if (!try_module_get(rtc->owner))
return -ENODEV;
ret = single_open(file, rtc_proc_show, rtc);
if (ret)
- module_put(THIS_MODULE);
+ module_put(rtc->owner);
return ret;
}
static int rtc_proc_release(struct inode *inode, struct file *file)
{
int res = single_release(inode, file);
- module_put(THIS_MODULE);
+ struct rtc_device *rtc = PDE_DATA(inode);
+
+ module_put(rtc->owner);
return res;
}
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] rtc: efi: add efi_procfs in efi_rtc_ops
2015-11-07 4:00 [PATCH 1/2] rtc: fix module reference count in rtc-proc Geliang Tang
@ 2015-11-07 4:00 ` Geliang Tang
2015-11-25 0:05 ` Alexandre Belloni
2015-11-30 19:03 ` [PATCH 1/2] rtc: fix module reference count in rtc-proc Alexandre Belloni
1 sibling, 1 reply; 4+ messages in thread
From: Geliang Tang @ 2015-11-07 4:00 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni; +Cc: Geliang Tang, rtc-linux, linux-kernel
Add efi_procfs in efi_rtc_ops to show rtc-efi info in /proc/driver/rtc.
Most of the code comes from efi_rtc_proc_show() in efirtc.
Signed-off-by: Geliang Tang <geliangtang@163.com>
---
drivers/rtc/rtc-efi.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 62 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index 3806961..96d3860 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -191,11 +191,69 @@ static int efi_set_time(struct device *dev, struct rtc_time *tm)
return status == EFI_SUCCESS ? 0 : -EINVAL;
}
+static int efi_procfs(struct device *dev, struct seq_file *seq)
+{
+ efi_time_t eft, alm;
+ efi_time_cap_t cap;
+ efi_bool_t enabled, pending;
+
+ memset(&eft, 0, sizeof(eft));
+ memset(&alm, 0, sizeof(alm));
+ memset(&cap, 0, sizeof(cap));
+
+ efi.get_time(&eft, &cap);
+ efi.get_wakeup_time(&enabled, &pending, &alm);
+
+ seq_printf(seq,
+ "Time\t\t: %u:%u:%u.%09u\n"
+ "Date\t\t: %u-%u-%u\n"
+ "Daylight\t: %u\n",
+ eft.hour, eft.minute, eft.second, eft.nanosecond,
+ eft.year, eft.month, eft.day,
+ eft.daylight);
+
+ if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
+ seq_puts(seq, "Timezone\t: unspecified\n");
+ else
+ /* XXX fixme: convert to string? */
+ seq_printf(seq, "Timezone\t: %u\n", eft.timezone);
+
+ seq_printf(seq,
+ "Alarm Time\t: %u:%u:%u.%09u\n"
+ "Alarm Date\t: %u-%u-%u\n"
+ "Alarm Daylight\t: %u\n"
+ "Enabled\t\t: %s\n"
+ "Pending\t\t: %s\n",
+ alm.hour, alm.minute, alm.second, alm.nanosecond,
+ alm.year, alm.month, alm.day,
+ alm.daylight,
+ enabled == 1 ? "yes" : "no",
+ pending == 1 ? "yes" : "no");
+
+ if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
+ seq_puts(seq, "Timezone\t: unspecified\n");
+ else
+ /* XXX fixme: convert to string? */
+ seq_printf(seq, "Timezone\t: %u\n", alm.timezone);
+
+ /*
+ * now prints the capabilities
+ */
+ seq_printf(seq,
+ "Resolution\t: %u\n"
+ "Accuracy\t: %u\n"
+ "SetstoZero\t: %u\n",
+ cap.resolution, cap.accuracy, cap.sets_to_zero);
+
+ return 0;
+}
+
static const struct rtc_class_ops efi_rtc_ops = {
- .read_time = efi_read_time,
- .set_time = efi_set_time,
- .read_alarm = efi_read_alarm,
- .set_alarm = efi_set_alarm,
+ .read_time = efi_read_time,
+ .set_time = efi_set_time,
+ .read_alarm = efi_read_alarm,
+ .set_alarm = efi_set_alarm,
+ .proc = efi_procfs,
};
static int __init efi_rtc_probe(struct platform_device *dev)
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] rtc: efi: add efi_procfs in efi_rtc_ops
2015-11-07 4:00 ` [PATCH 2/2] rtc: efi: add efi_procfs in efi_rtc_ops Geliang Tang
@ 2015-11-25 0:05 ` Alexandre Belloni
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2015-11-25 0:05 UTC (permalink / raw)
To: Geliang Tang; +Cc: Alessandro Zummo, rtc-linux, linux-kernel
Hi,
On 07/11/2015 at 12:00:22 +0800, Geliang Tang wrote :
> Add efi_procfs in efi_rtc_ops to show rtc-efi info in /proc/driver/rtc.
> Most of the code comes from efi_rtc_proc_show() in efirtc.
>
I'm actually wondering whether someone actually use those information in
/proc/driver/rtc. Do you have a use case?
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
> drivers/rtc/rtc-efi.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 62 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
> index 3806961..96d3860 100644
> --- a/drivers/rtc/rtc-efi.c
> +++ b/drivers/rtc/rtc-efi.c
> @@ -191,11 +191,69 @@ static int efi_set_time(struct device *dev, struct rtc_time *tm)
> return status == EFI_SUCCESS ? 0 : -EINVAL;
> }
>
> +static int efi_procfs(struct device *dev, struct seq_file *seq)
> +{
> + efi_time_t eft, alm;
> + efi_time_cap_t cap;
> + efi_bool_t enabled, pending;
> +
> + memset(&eft, 0, sizeof(eft));
> + memset(&alm, 0, sizeof(alm));
> + memset(&cap, 0, sizeof(cap));
> +
> + efi.get_time(&eft, &cap);
> + efi.get_wakeup_time(&enabled, &pending, &alm);
> +
> + seq_printf(seq,
> + "Time\t\t: %u:%u:%u.%09u\n"
> + "Date\t\t: %u-%u-%u\n"
> + "Daylight\t: %u\n",
> + eft.hour, eft.minute, eft.second, eft.nanosecond,
> + eft.year, eft.month, eft.day,
> + eft.daylight);
> +
> + if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
> + seq_puts(seq, "Timezone\t: unspecified\n");
> + else
> + /* XXX fixme: convert to string? */
> + seq_printf(seq, "Timezone\t: %u\n", eft.timezone);
> +
> + seq_printf(seq,
> + "Alarm Time\t: %u:%u:%u.%09u\n"
> + "Alarm Date\t: %u-%u-%u\n"
> + "Alarm Daylight\t: %u\n"
> + "Enabled\t\t: %s\n"
> + "Pending\t\t: %s\n",
> + alm.hour, alm.minute, alm.second, alm.nanosecond,
> + alm.year, alm.month, alm.day,
> + alm.daylight,
> + enabled == 1 ? "yes" : "no",
> + pending == 1 ? "yes" : "no");
> +
> + if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
> + seq_puts(seq, "Timezone\t: unspecified\n");
> + else
> + /* XXX fixme: convert to string? */
> + seq_printf(seq, "Timezone\t: %u\n", alm.timezone);
> +
> + /*
> + * now prints the capabilities
> + */
> + seq_printf(seq,
> + "Resolution\t: %u\n"
> + "Accuracy\t: %u\n"
> + "SetstoZero\t: %u\n",
> + cap.resolution, cap.accuracy, cap.sets_to_zero);
> +
> + return 0;
> +}
> +
> static const struct rtc_class_ops efi_rtc_ops = {
> - .read_time = efi_read_time,
> - .set_time = efi_set_time,
> - .read_alarm = efi_read_alarm,
> - .set_alarm = efi_set_alarm,
> + .read_time = efi_read_time,
> + .set_time = efi_set_time,
> + .read_alarm = efi_read_alarm,
> + .set_alarm = efi_set_alarm,
> + .proc = efi_procfs,
> };
>
> static int __init efi_rtc_probe(struct platform_device *dev)
> --
> 2.5.0
>
>
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] rtc: fix module reference count in rtc-proc
2015-11-07 4:00 [PATCH 1/2] rtc: fix module reference count in rtc-proc Geliang Tang
2015-11-07 4:00 ` [PATCH 2/2] rtc: efi: add efi_procfs in efi_rtc_ops Geliang Tang
@ 2015-11-30 19:03 ` Alexandre Belloni
1 sibling, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2015-11-30 19:03 UTC (permalink / raw)
To: Geliang Tang; +Cc: Alessandro Zummo, rtc-linux, linux-kernel
On 07/11/2015 at 12:00:21 +0800, Geliang Tang wrote :
> rtc-proc.c is not built as a module. Thus, rather than dealing with
> THIS_MODULE's reference count, we should deal with rtc->owner's
> reference count.
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
> drivers/rtc/rtc-proc.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
Both patches are applied, thanks.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-30 19:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-07 4:00 [PATCH 1/2] rtc: fix module reference count in rtc-proc Geliang Tang
2015-11-07 4:00 ` [PATCH 2/2] rtc: efi: add efi_procfs in efi_rtc_ops Geliang Tang
2015-11-25 0:05 ` Alexandre Belloni
2015-11-30 19:03 ` [PATCH 1/2] rtc: fix module reference count in rtc-proc Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).