All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3 for 2.6.33] Some fixes for kfifo and FHCI
@ 2010-01-27 14:08 ` Anton Vorontsov
  0 siblings, 0 replies; 12+ messages in thread
From: Anton Vorontsov @ 2010-01-27 14:08 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Greg Kroah-Hartman, Josh Boyer, Stefani Seibold, linuxppc-dev,
	linux-kernel, linux-usb

Hi all,

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

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 0/3 for 2.6.33] Some fixes for kfifo and FHCI
@ 2010-01-27 14:08 ` Anton Vorontsov
  0 siblings, 0 replies; 12+ messages in thread
From: Anton Vorontsov @ 2010-01-27 14:08 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-usb, Stefani Seibold, Greg Kroah-Hartman, linux-kernel,
	linuxppc-dev

Hi all,

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

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/3] kfifo: Make kfifo_initialized work after kfifo_free
  2010-01-27 14:08 ` Anton Vorontsov
@ 2010-01-27 14:09   ` Anton Vorontsov
  -1 siblings, 0 replies; 12+ messages in thread
From: Anton Vorontsov @ 2010-01-27 14:09 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Greg Kroah-Hartman, Josh Boyer, Stefani Seibold, linuxppc-dev,
	linux-kernel, linux-usb

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 <avorontsov@ru.mvista.com>
---
 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 1/3] kfifo: Make kfifo_initialized work after kfifo_free
@ 2010-01-27 14:09   ` Anton Vorontsov
  0 siblings, 0 replies; 12+ messages in thread
From: Anton Vorontsov @ 2010-01-27 14:09 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-usb, Stefani Seibold, Greg Kroah-Hartman, linux-kernel,
	linuxppc-dev

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 <avorontsov@ru.mvista.com>
---
 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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/3] USB: FHCI: Fix build after kfifo rework
  2010-01-27 14:08 ` Anton Vorontsov
@ 2010-01-27 14:09   ` Anton Vorontsov
  -1 siblings, 0 replies; 12+ messages in thread
From: Anton Vorontsov @ 2010-01-27 14:09 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Greg Kroah-Hartman, Josh Boyer, Stefani Seibold, linuxppc-dev,
	linux-kernel, linux-usb

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 <jwboyer@gmail.com>
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/3] USB: FHCI: Fix build after kfifo rework
@ 2010-01-27 14:09   ` Anton Vorontsov
  0 siblings, 0 replies; 12+ messages in thread
From: Anton Vorontsov @ 2010-01-27 14:09 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-usb, Stefani Seibold, Greg Kroah-Hartman, linux-kernel,
	linuxppc-dev

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 <jwboyer@gmail.com>
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/3] kfifo: Don't use integer as NULL pointer
  2010-01-27 14:08 ` Anton Vorontsov
@ 2010-01-27 14:09   ` Anton Vorontsov
  -1 siblings, 0 replies; 12+ messages in thread
From: Anton Vorontsov @ 2010-01-27 14:09 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Greg Kroah-Hartman, Josh Boyer, Stefani Seibold, linuxppc-dev,
	linux-kernel, linux-usb

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 <avorontsov@ru.mvista.com>
---
 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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/3] kfifo: Don't use integer as NULL pointer
@ 2010-01-27 14:09   ` Anton Vorontsov
  0 siblings, 0 replies; 12+ messages in thread
From: Anton Vorontsov @ 2010-01-27 14:09 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-usb, Stefani Seibold, Greg Kroah-Hartman, linux-kernel,
	linuxppc-dev

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 <avorontsov@ru.mvista.com>
---
 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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3 for 2.6.33] Some fixes for kfifo and FHCI
  2010-01-27 14:08 ` Anton Vorontsov
@ 2010-01-27 14:50   ` Greg KH
  -1 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2010-01-27 14:50 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Andrew Morton, Josh Boyer, Stefani Seibold, linuxppc-dev,
	linux-kernel, linux-usb

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3 for 2.6.33] Some fixes for kfifo and FHCI
@ 2010-01-27 14:50   ` Greg KH
  0 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2010-01-27 14:50 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Stefani Seibold, linux-usb, linux-kernel, linuxppc-dev, Andrew Morton

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3 for 2.6.33] Some fixes for kfifo and FHCI
  2010-01-27 14:50   ` Greg KH
@ 2010-01-27 15:47     ` Stefani Seibold
  -1 siblings, 0 replies; 12+ messages in thread
From: Stefani Seibold @ 2010-01-27 15:47 UTC (permalink / raw)
  To: Greg KH
  Cc: Anton Vorontsov, Andrew Morton, Josh Boyer, linuxppc-dev,
	linux-kernel, linux-usb

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 <stefani@seibold.net>




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3 for 2.6.33] Some fixes for kfifo and FHCI
@ 2010-01-27 15:47     ` Stefani Seibold
  0 siblings, 0 replies; 12+ messages in thread
From: Stefani Seibold @ 2010-01-27 15:47 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-usb, linux-kernel, linuxppc-dev, Andrew Morton, Anton Vorontsov

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 <stefani@seibold.net>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-01-27 16:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-27 14:08 [PATCH 0/3 for 2.6.33] Some fixes for kfifo and FHCI Anton Vorontsov
2010-01-27 14:08 ` Anton Vorontsov
2010-01-27 14:09 ` [PATCH 1/3] kfifo: Make kfifo_initialized work after kfifo_free Anton Vorontsov
2010-01-27 14:09   ` Anton Vorontsov
2010-01-27 14:09 ` [PATCH 2/3] USB: FHCI: Fix build after kfifo rework Anton Vorontsov
2010-01-27 14:09   ` Anton Vorontsov
2010-01-27 14:09 ` [PATCH 3/3] kfifo: Don't use integer as NULL pointer Anton Vorontsov
2010-01-27 14:09   ` Anton Vorontsov
2010-01-27 14:50 ` [PATCH 0/3 for 2.6.33] Some fixes for kfifo and FHCI Greg KH
2010-01-27 14:50   ` Greg KH
2010-01-27 15:47   ` Stefani Seibold
2010-01-27 15:47     ` Stefani Seibold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.