lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <df1f6c8185aa476898c30836d45c49a1@diehl.com>
Date: Mon, 20 Jan 2025 13:10:44 +0000
From: Denis OSTERLAND-HEIM <denis.osterland@...hl.com>
To: Rodolfo Giometti <giometti@...eenne.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH] pps: add epoll support

This patch adds pps_context to store the per file read counter.

Signed-off-by: Denis Osterland-Heim <denis.osterland@...hl.com>
---
 drivers/pps/pps.c | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index 25d47907db17..b5834c592e2a 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -21,6 +21,12 @@

 #include "kc.h"

+struct pps_context {
+struct pps_device *pps;
+unsigned int ev;
+};
+
+
 /*
  * Local variables
  */
@@ -37,17 +43,19 @@ static DEFINE_IDR(pps_idr);

 static __poll_t pps_cdev_poll(struct file *file, poll_table *wait)
 {
-struct pps_device *pps = file->private_data;
+struct pps_context *ctx = file->private_data;
+struct pps_device *pps = ctx->pps;

 poll_wait(file, &pps->queue, wait);

-return EPOLLIN | EPOLLRDNORM;
+return (ctx->ev != pps->last_ev) ? (EPOLLIN | EPOLLRDNORM) : 0;
 }

 static int pps_cdev_fasync(int fd, struct file *file, int on)
 {
-struct pps_device *pps = file->private_data;
-return fasync_helper(fd, file, on, &pps->async_queue);
+struct pps_context *ctx = file->private_data;
+
+return fasync_helper(fd, file, on, &ctx->pps->async_queue);
 }

 static int pps_cdev_pps_fetch(struct pps_device *pps, struct pps_fdata *fdata)
@@ -90,7 +98,8 @@ static int pps_cdev_pps_fetch(struct pps_device *pps, struct pps_fdata *fdata)
 static long pps_cdev_ioctl(struct file *file,
 unsigned int cmd, unsigned long arg)
 {
-struct pps_device *pps = file->private_data;
+struct pps_context *ctx = file->private_data;
+struct pps_device *pps = ctx->pps;
 struct pps_kparams params;
 void __user *uarg = (void __user *) arg;
 int __user *iuarg = (int __user *) arg;
@@ -189,6 +198,7 @@ static long pps_cdev_ioctl(struct file *file,
 /* Return the fetched timestamp */
 spin_lock_irq(&pps->lock);

+ctx->ev = pps->last_ev;
 fdata.info.assert_sequence = pps->assert_sequence;
 fdata.info.clear_sequence = pps->clear_sequence;
 fdata.info.assert_tu = pps->assert_tu;
@@ -249,7 +259,8 @@ static long pps_cdev_ioctl(struct file *file,
 static long pps_cdev_compat_ioctl(struct file *file,
 unsigned int cmd, unsigned long arg)
 {
-struct pps_device *pps = file->private_data;
+struct pps_context *ctx = file->private_data;
+struct pps_device *pps = ctx->pps;
 void __user *uarg = (void __user *) arg;

 cmd = _IOC(_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), sizeof(void *));
@@ -275,6 +286,7 @@ static long pps_cdev_compat_ioctl(struct file *file,
 /* Return the fetched timestamp */
 spin_lock_irq(&pps->lock);

+ctx->ev = pps->last_ev;
 compat.info.assert_sequence = pps->assert_sequence;
 compat.info.clear_sequence = pps->clear_sequence;
 compat.info.current_mode = pps->current_mode;
@@ -300,7 +312,13 @@ static int pps_cdev_open(struct inode *inode, struct file *file)
 {
 struct pps_device *pps = container_of(inode->i_cdev,
 struct pps_device, cdev);
-file->private_data = pps;
+struct pps_context *ctx = kzalloc(sizeof(struct pps_context), GFP_KERNEL);
+
+if (unlikely(ZERO_OR_NULL_PTR(ctx)))
+return -ENOMEM;
+file->private_data = ctx;
+ctx->pps = pps;
+ctx->ev = pps->last_ev;
 kobject_get(&pps->dev->kobj);
 return 0;
 }
@@ -309,6 +327,7 @@ static int pps_cdev_release(struct inode *inode, struct file *file)
 {
 struct pps_device *pps = container_of(inode->i_cdev,
 struct pps_device, cdev);
+kfree(file->private_data);
 kobject_put(&pps->dev->kobj);
 return 0;
 }
--
2.45.2
Diehl Metering GmbH, Donaustrasse 120, 90451 Nuernberg
Sitz der Gesellschaft: Ansbach, Registergericht: Ansbach HRB 69
Geschaeftsfuehrer: Dr. Christof Bosbach (Sprecher), Dipl.-Dolm. Annette Geuther, Dipl.-Kfm. Reiner Edel, Jean-Claude Luttringer

Bitte denken Sie an die Umwelt, bevor Sie diese E-Mail drucken. Diese E-Mail kann vertrauliche Informationen enthalten. Sollten die in dieser E-Mail enthaltenen Informationen nicht für Sie bestimmt sein, informieren Sie bitte unverzueglich den Absender per E-Mail und loeschen Sie diese E-Mail in Ihrem System. Jede unberechtigte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt. Informationen zum Datenschutz finden Sie auf unserer Homepage<https://www.diehl.com/metering/de/impressum-und-rechtliche-hinweise/>.

Before printing, think about environmental responsibility.This message may contain confidential information. If you are not authorized to receive this information please advise the sender immediately by reply e-mail and delete this message without making any copies. Any form of unauthorized use, publication, reproduction, copying or disclosure of the e-mail is not permitted. Information about data protection can be found on our homepage<https://www.diehl.com/metering/en/data-protection/>.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ