Skip to content

Commit 4a35147

Browse files
David Altobelligregkh
authored andcommitted
hpilo: add poll f_op
Add poll handler to hpilo, to allow applications a low overhead method of waiting for data. Signed-off-by: David Altobelli <david.altobelli@hp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 9f70484 commit 4a35147

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

‎drivers/misc/hpilo.c‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/uaccess.h>
2424
#include <linux/io.h>
2525
#include <linux/wait.h>
26+
#include <linux/poll.h>
2627
#include "hpilo.h"
2728

2829
static struct class *ilo_class;
@@ -102,6 +103,22 @@ static int fifo_dequeue(struct ilo_hwinfo *hw, char *fifobar, int *entry)
102103
return ret;
103104
}
104105

106+
static int fifo_check_recv(struct ilo_hwinfo *hw, char *fifobar)
107+
{
108+
struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar);
109+
unsigned long flags;
110+
int ret = 0;
111+
u64 c;
112+
113+
spin_lock_irqsave(&hw->fifo_lock, flags);
114+
c = fifo_q->fifobar[fifo_q->head & fifo_q->imask];
115+
if (c & ENTRY_MASK_C)
116+
ret = 1;
117+
spin_unlock_irqrestore(&hw->fifo_lock, flags);
118+
119+
return ret;
120+
}
121+
105122
static int ilo_pkt_enqueue(struct ilo_hwinfo *hw, struct ccb *ccb,
106123
int dir, int id, int len)
107124
{
@@ -146,6 +163,13 @@ static int ilo_pkt_dequeue(struct ilo_hwinfo *hw, struct ccb *ccb,
146163
return ret;
147164
}
148165

166+
static int ilo_pkt_recv(struct ilo_hwinfo *hw, struct ccb *ccb)
167+
{
168+
char *fifobar = ccb->ccb_u3.recv_fifobar;
169+
170+
return fifo_check_recv(hw, fifobar);
171+
}
172+
149173
static inline void doorbell_set(struct ccb *ccb)
150174
{
151175
iowrite8(1, ccb->ccb_u5.db_base);
@@ -486,6 +510,21 @@ static ssize_t ilo_write(struct file *fp, const char __user *buf,
486510
return err ? -EFAULT : len;
487511
}
488512

513+
static unsigned int ilo_poll(struct file *fp, poll_table *wait)
514+
{
515+
struct ccb_data *data = fp->private_data;
516+
struct ccb *driver_ccb = &data->driver_ccb;
517+
518+
poll_wait(fp, &data->ccb_waitq, wait);
519+
520+
if (is_channel_reset(driver_ccb))
521+
return POLLERR;
522+
else if (ilo_pkt_recv(data->ilo_hw, driver_ccb))
523+
return POLLIN | POLLRDNORM;
524+
525+
return 0;
526+
}
527+
489528
static int ilo_close(struct inode *ip, struct file *fp)
490529
{
491530
int slot;
@@ -595,6 +634,7 @@ static const struct file_operations ilo_fops = {
595634
.owner = THIS_MODULE,
596635
.read = ilo_read,
597636
.write = ilo_write,
637+
.poll = ilo_poll,
598638
.open = ilo_open,
599639
.release = ilo_close,
600640
};
@@ -835,7 +875,7 @@ static void __exit ilo_exit(void)
835875
class_destroy(ilo_class);
836876
}
837877

838-
MODULE_VERSION("1.1");
878+
MODULE_VERSION("1.2");
839879
MODULE_ALIAS(ILO_NAME);
840880
MODULE_DESCRIPTION(ILO_NAME);
841881
MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>");

0 commit comments

Comments
 (0)