Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 498d319b authored by Stefani Seibold's avatar Stefani Seibold Committed by Linus Torvalds
Browse files

kfifo API type safety



This patch enhances the type safety for the kfifo API.  It is now safe
to put const data into a non const FIFO and the API will now generate a
compiler warning when reading from the fifo where the destination
address is pointing to a const variable.

As a side effect the kfifo_put() does now expect the value of an element
instead a pointer to the element.  This was suggested Russell King.  It
make the handling of the kfifo_put easier since there is no need to
create a helper variable for getting the address of a pointer or to pass
integers of different sizes.

IMHO the API break is okay, since there are currently only six users of
kfifo_put().

The code is also cleaner by kicking out the "if (0)" expressions.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: default avatarStefani Seibold <stefani@seibold.net>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a019e48c
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -34,7 +34,7 @@
 */
 */
void drm_flip_work_queue(struct drm_flip_work *work, void *val)
void drm_flip_work_queue(struct drm_flip_work *work, void *val)
{
{
	if (kfifo_put(&work->fifo, (const void **)&val)) {
	if (kfifo_put(&work->fifo, val)) {
		atomic_inc(&work->pending);
		atomic_inc(&work->pending);
	} else {
	} else {
		DRM_ERROR("%s fifo full!\n", work->name);
		DRM_ERROR("%s fifo full!\n", work->name);
+1 −1
Original line number Original line Diff line number Diff line
@@ -56,7 +56,7 @@ int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp)
		ev.id = ev_code;
		ev.id = ev_code;
		ev.timestamp = timestamp;
		ev.timestamp = timestamp;


		copied = kfifo_put(&ev_int->det_events, &ev);
		copied = kfifo_put(&ev_int->det_events, ev);
		if (copied != 0)
		if (copied != 0)
			wake_up_locked_poll(&ev_int->wait, POLLIN);
			wake_up_locked_poll(&ev_int->wait, POLLIN);
	}
	}
+1 −1
Original line number Original line Diff line number Diff line
@@ -446,7 +446,7 @@ static void rt2800mmio_txstatus_interrupt(struct rt2x00_dev *rt2x00dev)
		if (!rt2x00_get_field32(status, TX_STA_FIFO_VALID))
		if (!rt2x00_get_field32(status, TX_STA_FIFO_VALID))
			break;
			break;


		if (!kfifo_put(&rt2x00dev->txstatus_fifo, &status)) {
		if (!kfifo_put(&rt2x00dev->txstatus_fifo, status)) {
			rt2x00_warn(rt2x00dev, "TX status FIFO overrun, drop tx status report\n");
			rt2x00_warn(rt2x00dev, "TX status FIFO overrun, drop tx status report\n");
			break;
			break;
		}
		}
+1 −1
Original line number Original line Diff line number Diff line
@@ -164,7 +164,7 @@ static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev,


	valid = rt2x00_get_field32(tx_status, TX_STA_FIFO_VALID);
	valid = rt2x00_get_field32(tx_status, TX_STA_FIFO_VALID);
	if (valid) {
	if (valid) {
		if (!kfifo_put(&rt2x00dev->txstatus_fifo, &tx_status))
		if (!kfifo_put(&rt2x00dev->txstatus_fifo, tx_status))
			rt2x00_warn(rt2x00dev, "TX status FIFO overrun\n");
			rt2x00_warn(rt2x00dev, "TX status FIFO overrun\n");


		queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
		queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
+1 −1
Original line number Original line Diff line number Diff line
@@ -574,7 +574,7 @@ void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
	};
	};


	spin_lock_irqsave(&aer_recover_ring_lock, flags);
	spin_lock_irqsave(&aer_recover_ring_lock, flags);
	if (kfifo_put(&aer_recover_ring, &entry))
	if (kfifo_put(&aer_recover_ring, entry))
		schedule_work(&aer_recover_work);
		schedule_work(&aer_recover_work);
	else
	else
		pr_err("AER recover: Buffer overflow when recovering AER for %04x:%02x:%02x:%x\n",
		pr_err("AER recover: Buffer overflow when recovering AER for %04x:%02x:%02x:%x\n",
Loading