Skip to content

Commit 726af7a

Browse files
committed
kernel-doc: parse DECLARE_KFIFO and DECLARE_KFIFO_PTR()
DECLARE_KFIFO and DECLARE_KFIFO_PTR needs similar handling to DECLARE_BITMAP because otherwise kernel-doc assumes the member name is the last, not first macro parameter. The origin comes from Jakub Mauro [1] patching the Perl kernel-doc parser in './scripts' Linux tree. [1] https://www.mail-archive.com/linux-doc@vger.kernel.org/msg17005.html Suggested-by: Randy Dunlap <rdunlap@infradead.org> Suggested-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
1 parent c369070 commit 726af7a

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

docs/linuxdoc-howto/all-in-a-tumble.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,27 @@ struct something {
428428
barbar;
429429
};
430430

431+
/**
432+
* struct lineevent_state - contains the state of a userspace event
433+
* @gdev: the GPIO device the event pertains to
434+
* @label: consumer label used to tag descriptors
435+
* @desc: the GPIO descriptor held by this event
436+
* @eflags: the event flags this line was requested with
437+
* @irq: the interrupt that trigger in response to events on this GPIO
438+
* @wait: wait queue that handles blocking reads of events
439+
* @events: KFIFO for the GPIO events (testing DECLARE_KFIFO)
440+
* @foobar: testing DECLARE_KFIFO_PTR
441+
* @read_lock: mutex lock to protect reads from colliding with adding
442+
* new events to the FIFO
443+
*/
444+
struct lineevent_state {
445+
struct gpio_device *gdev;
446+
const char *label;
447+
struct gpio_desc *desc;
448+
u32 eflags;
449+
int irq;
450+
wait_queue_head_t wait;
451+
DECLARE_KFIFO(events, struct gpioevent_data, 16);
452+
DECLARE_KFIFO_PTR(foobar, struct lirc_scancode);
453+
struct mutex read_lock;
454+
};

linuxdoc/kernel_doc.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,15 +2495,25 @@ def prepare_struct_union(self, proto):
24952495
members = re.sub(r"\s*CRYPTO_MINALIGN_ATTR", "", members)
24962496

24972497
# replace DECLARE_BITMAP
2498-
members = re.sub(r"DECLARE_BITMAP\s*\(([^,)]+), ([^,)]+)\)"
2498+
members = re.sub(r"DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)"
24992499
, r"unsigned long \1[BITS_TO_LONGS(\2)]"
25002500
, members )
25012501

25022502
# replace DECLARE_HASHTABLE
2503-
members = re.sub(r"DECLARE_HASHTABLE\s*\(([^,)]+), ([^,)]+)\)"
2503+
members = re.sub(r"DECLARE_HASHTABLE\s*\(([^,)]+),\s*([^,)]+)\)"
25042504
, r"unsigned long \1[1 << ((\2) - 1)]"
25052505
, members )
25062506

2507+
# replace DECLARE_KFIFO
2508+
members = re.sub(r"DECLARE_KFIFO\s*\(([^,)]+),\s*([^,)]+),\s*([^,)]+)\)"
2509+
, r"\2 \1"
2510+
, members )
2511+
2512+
# replace DECLARE_KFIFO_PTR
2513+
members = re.sub(r"DECLARE_KFIFO_PTR\s*\(([^,)]+),\s*([^,)]+)\)"
2514+
, r"\2 \1"
2515+
, members )
2516+
25072517
# Split nested struct/union elements as newer ones
25082518
NESTED = RE(r"(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;")
25092519
while NESTED.search(members):

0 commit comments

Comments
 (0)