1 /* SPDX-License-Identifier: GPL-2.0 */
3 * GNSS receiver support
5 * Copyright (C) 2018 Johan Hovold <johan@kernel.org>
11 #include <linux/cdev.h>
12 #include <linux/device.h>
13 #include <linux/kfifo.h>
14 #include <linux/mutex.h>
15 #include <linux/rwsem.h>
16 #include <linux/types.h>
17 #include <linux/wait.h>
30 struct gnss_operations
{
31 int (*open
)(struct gnss_device
*gdev
);
32 void (*close
)(struct gnss_device
*gdev
);
33 int (*write_raw
)(struct gnss_device
*gdev
, const unsigned char *buf
,
45 struct rw_semaphore rwsem
;
46 const struct gnss_operations
*ops
;
48 unsigned int disconnected
:1;
50 struct mutex read_mutex
;
51 struct kfifo read_fifo
;
52 wait_queue_head_t read_queue
;
54 struct mutex write_mutex
;
58 struct gnss_device
*gnss_allocate_device(struct device
*parent
);
59 void gnss_put_device(struct gnss_device
*gdev
);
60 int gnss_register_device(struct gnss_device
*gdev
);
61 void gnss_deregister_device(struct gnss_device
*gdev
);
63 int gnss_insert_raw(struct gnss_device
*gdev
, const unsigned char *buf
,
66 static inline void gnss_set_drvdata(struct gnss_device
*gdev
, void *data
)
68 dev_set_drvdata(&gdev
->dev
, data
);
71 static inline void *gnss_get_drvdata(struct gnss_device
*gdev
)
73 return dev_get_drvdata(&gdev
->dev
);
76 #endif /* _LINUX_GNSS_H */