Skip to contentSkip to conversation

Some fixes for kfifo and FHCI

PATCH In review Anton Vorontsov 3 participants 6 messages Jan 27, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Some fixes for kfifo and FHCI

Hi all,

FHCI no longer builds after kfifo rework, this patch set is used to fix the issues.

Thanks,

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#1 lore raw

PATCH 1/3 kfifo: Make kfifo_initialized work after kfifo_free

After kfifo rework it's no longer possible to reliably know if kfifo is usable, since after kfifo_free(), kfifo_initialized() would still return true. The correct behaviour is needed for at least FHCI USB driver.

This patch fixes the issue by resetting the kfifo to zero values (the same approach is used in kfifo_alloc() if allocation failed).

---
 kernel/kfifo.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/kfifo.c +1 -0
index 32c5c15..3b00bf8 100644
@@ -97,6 +97,7 @@ EXPORT_SYMBOL(kfifo_alloc);
 void kfifo_free(struct kfifo *fifo)
 {
 	kfree(fifo->buffer);
+	_kfifo_init(fifo, NULL, 0);
 }
 EXPORT_SYMBOL(kfifo_free);
 
Signature · 1 line
1.6.5.7
#2 lore raw

PATCH 2/3 USB: FHCI: Fix build after kfifo rework

In reply to Anton Vorontsov

After kfifo rework FHCI fails to build:

CC drivers/usb/host/fhci-tds.o
drivers/usb/host/fhci-tds.c: In function 'fhci_ep0_free':
drivers/usb/host/fhci-tds.c:108: error: used struct type value where scalar is required drivers/usb/host/fhci-tds.c:118: error: used struct type value where scalar is required drivers/usb/host/fhci-tds.c:128: error: used struct type value where scalar is required

This is because kfifos are no longer pointers in the ep struct. So, instead of checking the pointers, we should now check if kfifo is initialized.

---
 drivers/usb/host/fhci-tds.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/usb/host/fhci-tds.c +3 -3
index d224ab4..e123289 100644
@@ -105,7 +105,7 @@ void fhci_ep0_free(struct fhci_usb *usb)
 		if (ep->td_base)
 			cpm_muram_free(cpm_muram_offset(ep->td_base));
 
-		if (ep->conf_frame_Q) {
+		if (kfifo_initialized(&ep->conf_frame_Q)) {
 			size = cq_howmany(&ep->conf_frame_Q);
 			for (; size; size--) {
 				struct packet *pkt = cq_get(&ep->conf_frame_Q);
@@ -115,7 +115,7 @@ void fhci_ep0_free(struct fhci_usb *usb)
 			cq_delete(&ep->conf_frame_Q);
 		}
 
-		if (ep->empty_frame_Q) {
+		if (kfifo_initialized(&ep->empty_frame_Q)) {
 			size = cq_howmany(&ep->empty_frame_Q);
 			for (; size; size--) {
 				struct packet *pkt = cq_get(&ep->empty_frame_Q);
@@ -125,7 +125,7 @@ void fhci_ep0_free(struct fhci_usb *usb)
 			cq_delete(&ep->empty_frame_Q);
 		}
 
-		if (ep->dummy_packets_Q) {
+		if (kfifo_initialized(&ep->dummy_packets_Q)) {
 			size = cq_howmany(&ep->dummy_packets_Q);
 			for (; size; size--) {
 				u8 *buff = cq_get(&ep->dummy_packets_Q);
Signature · 1 line
1.6.5.7
#3 lore raw

PATCH 3/3 kfifo: Don't use integer as NULL pointer

In reply to Anton Vorontsov

This patch fixes following sparse warnings:

include/linux/kfifo.h:127:25: warning: Using plain integer as NULL pointer kernel/kfifo.c:83:21: warning: Using plain integer as NULL pointer

---
 include/linux/kfifo.h |    2 +-
 kernel/kfifo.c        |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/kfifo.h +1 -1
index 6f6c5f3..bc0fc79 100644
@@ -124,7 +124,7 @@ extern __must_check unsigned int kfifo_out_peek(struct kfifo *fifo,
  */
 static inline bool kfifo_initialized(struct kfifo *fifo)
 {
-	return fifo->buffer != 0;
+	return fifo->buffer != NULL;
 }
 
 /**
kernel/kfifo.c +1 -1
index 3b00bf8..6d58e1a 100644
@@ -80,7 +80,7 @@ int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask)
 
 	buffer = kmalloc(size, gfp_mask);
 	if (!buffer) {
-		_kfifo_init(fifo, 0, 0);
+		_kfifo_init(fifo, NULL, 0);
 		return -ENOMEM;
 	}
 
Signature · 1 line
1.6.5.7
#4 lore raw
In reply to Anton Vorontsov
Quoted 4 lines · Anton Vorontsov

Hi all,

FHCI no longer builds after kfifo rework, this patch set is used to fix the issues.

If there are no objections to these, I'll queue these up and send them through my tree as they affect the FHCI driver.

thanks,

greg k-h

maintainer Acked-by
#5 lore raw

Am Mittwoch, den 27.01.2010, 06:50 -0800 schrieb Greg KH:

Quoted 9 lines · Anton Vorontsov
Quoted 4 lines

Hi all,

FHCI no longer builds after kfifo rework, this patch set is used to fix the issues.

If there are no objections to these, I'll queue these up and send them through my tree as they affect the FHCI driver.

Looks good for me, so