2010-01-27 14:08:13

by Anton Vorontsov

[permalink] [raw]
Subject: [PATCH 0/3 for 2.6.33] 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,

--
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2


2010-01-27 14:09:38

by Anton Vorontsov

[permalink] [raw]
Subject: [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).

Signed-off-by: Anton Vorontsov <[email protected]>
---
kernel/kfifo.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index 32c5c15..3b00bf8 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -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);

--
1.6.5.7

2010-01-27 14:09:41

by Anton Vorontsov

[permalink] [raw]
Subject: [PATCH 2/3] USB: FHCI: Fix build after kfifo rework

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.

Reported-by: Josh Boyer <[email protected]>
Signed-off-by: Anton Vorontsov <[email protected]>
---
drivers/usb/host/fhci-tds.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c
index d224ab4..e123289 100644
--- a/drivers/usb/host/fhci-tds.c
+++ b/drivers/usb/host/fhci-tds.c
@@ -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);
--
1.6.5.7

2010-01-27 14:09:54

by Anton Vorontsov

[permalink] [raw]
Subject: [PATCH 3/3] kfifo: Don't use integer as NULL pointer

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

Signed-off-by: Anton Vorontsov <[email protected]>
---
include/linux/kfifo.h | 2 +-
kernel/kfifo.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 6f6c5f3..bc0fc79 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -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;
}

/**
diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index 3b00bf8..6d58e1a 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -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;
}

--
1.6.5.7

2010-01-27 14:55:25

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 0/3 for 2.6.33] Some fixes for kfifo and FHCI

On Wed, Jan 27, 2010 at 05:08:09PM +0300, Anton Vorontsov wrote:
> 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

2010-01-27 15:47:41

by Stefani Seibold

[permalink] [raw]
Subject: Re: [PATCH 0/3 for 2.6.33] Some fixes for kfifo and FHCI

Am Mittwoch, den 27.01.2010, 06:50 -0800 schrieb Greg KH:
> On Wed, Jan 27, 2010 at 05:08:09PM +0300, Anton Vorontsov wrote:
> > 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
Acked-by: Stefani Seibold <[email protected]>