aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-07-24 16:50:00 +0200
committerJose Bollo <jose.bollo@iot.bzh>2018-07-25 15:12:48 +0200
commit8d4e6df897f521b2e0be51933f627261388cbd20 (patch)
tree8a6054be0669cc97ee2065a2a1cd5045efbe47b4
parent1bc97132d598cf393d92cb80b0e3a1c13436f570 (diff)
fdev: Simplify the code
Less code is faster and safer. Change-Id: Ide71fec5ee80f14482e2972a3d0f65ef0b589f12 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/fdev.c20
-rw-r--r--src/fdev.h2
2 files changed, 1 insertions, 21 deletions
diff --git a/src/fdev.c b/src/fdev.c
index a8f36956..03dc3efd 100644
--- a/src/fdev.c
+++ b/src/fdev.c
@@ -27,7 +27,6 @@ struct fdev
{
int fd;
uint32_t events;
- int repeat;
unsigned refcount;
struct fdev_itf *itf;
void *closure_itf;
@@ -45,7 +44,6 @@ struct fdev *fdev_create(int fd)
else {
fdev->fd = fd;
fdev->refcount = 3; /* set autoclose by default */
- fdev->repeat = -1; /* always repeat by default */
}
return fdev;
}
@@ -58,8 +56,6 @@ void fdev_set_itf(struct fdev *fdev, struct fdev_itf *itf, void *closure_itf)
void fdev_dispatch(struct fdev *fdev, uint32_t events)
{
- if (fdev->repeat > 0 && !--fdev->repeat && fdev->itf)
- fdev->itf->disable(fdev->closure_itf, fdev);
if (fdev->callback)
fdev->callback(fdev->closure_callback, events, fdev);
}
@@ -95,11 +91,6 @@ uint32_t fdev_events(const struct fdev *fdev)
return fdev->events;
}
-int fdev_repeat(const struct fdev *fdev)
-{
- return fdev->repeat;
-}
-
int fdev_autoclose(const struct fdev *fdev)
{
return 1 & fdev->refcount;
@@ -107,7 +98,7 @@ int fdev_autoclose(const struct fdev *fdev)
static inline int is_active(struct fdev *fdev)
{
- return fdev->repeat && fdev->callback;
+ return !!fdev->callback;
}
static inline void update_activity(struct fdev *fdev, int old_active)
@@ -140,15 +131,6 @@ void fdev_set_events(struct fdev *fdev, uint32_t events)
}
}
-void fdev_set_repeat(struct fdev *fdev, int count)
-{
- int oa;
-
- oa = is_active(fdev);
- fdev->repeat = count;
- update_activity(fdev, oa);
-}
-
void fdev_set_autoclose(struct fdev *fdev, int autoclose)
{
if (autoclose)
diff --git a/src/fdev.h b/src/fdev.h
index 1e2f49f6..c9d74430 100644
--- a/src/fdev.h
+++ b/src/fdev.h
@@ -40,10 +40,8 @@ extern void fdev_unref(struct fdev *fdev);
extern int fdev_fd(const struct fdev *fdev);
extern uint32_t fdev_events(const struct fdev *fdev);
-extern int fdev_repeat(const struct fdev *fdev);
extern int fdev_autoclose(const struct fdev *fdev);
extern void fdev_set_callback(struct fdev *fdev, void (*callback)(void*,uint32_t,struct fdev*), void *closure);
extern void fdev_set_events(struct fdev *fdev, uint32_t events);
-extern void fdev_set_repeat(struct fdev *fdev, int count);
extern void fdev_set_autoclose(struct fdev *fdev, int autoclose);