Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1427005 > unrolled thread
| Started by | Davidlohr Bueso <dave@stgolabs.net> |
|---|---|
| First post | 2016-06-20 22:20 +0200 |
| Last post | 2016-06-20 22:20 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 07/12] drivers/media: Employ atomic_fetch_inc() Davidlohr Bueso <dave@stgolabs.net> - 2016-06-20 22:20 +0200
| From | Davidlohr Bueso <dave@stgolabs.net> |
|---|---|
| Date | 2016-06-20 22:20 +0200 |
| Subject | [PATCH 07/12] drivers/media: Employ atomic_fetch_inc() |
| Message-ID | <rMdPQ-4rx-7@gated-at.bofh.it> |
Now that we have fetch_inc() we can stop using inc_return() - 1.
These are very similar to the existing OP-RETURN primitives we already
have, except they return the value of the atomic variable _before_
modification.
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: linux-media@vger.kernel.org
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
drivers/media/pci/cobalt/cobalt-driver.c | 2 +-
drivers/media/pci/cx18/cx18-driver.c | 2 +-
drivers/media/v4l2-core/v4l2-device.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/pci/cobalt/cobalt-driver.c b/drivers/media/pci/cobalt/cobalt-driver.c
index 8d6f04fc8013..70dfcb0c6a72 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.c
+++ b/drivers/media/pci/cobalt/cobalt-driver.c
@@ -683,7 +683,7 @@ static int cobalt_probe(struct pci_dev *pci_dev,
int i;
/* FIXME - module parameter arrays constrain max instances */
- i = atomic_inc_return(&cobalt_instance) - 1;
+ i = atomic_fetch_inc(&cobalt_instance);
cobalt = kzalloc(sizeof(struct cobalt), GFP_ATOMIC);
if (cobalt == NULL)
diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c
index 260e462d91b4..5cb3408c6859 100644
--- a/drivers/media/pci/cx18/cx18-driver.c
+++ b/drivers/media/pci/cx18/cx18-driver.c
@@ -908,7 +908,7 @@ static int cx18_probe(struct pci_dev *pci_dev,
struct cx18 *cx;
/* FIXME - module parameter arrays constrain max instances */
- i = atomic_inc_return(&cx18_instance) - 1;
+ i = atomic_fetch_inc(&cx18_instance);
if (i >= CX18_MAX_CARDS) {
printk(KERN_ERR "cx18: cannot manage card %d, driver has a "
"limit of 0 - %d\n", i, CX18_MAX_CARDS - 1);
diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index 06fa5f1b2cff..1bc5b68c2724 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -76,7 +76,7 @@ EXPORT_SYMBOL_GPL(v4l2_device_put);
int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
atomic_t *instance)
{
- int num = atomic_inc_return(instance) - 1;
+ int num = atomic_fetch_inc(instance);
int len = strlen(basename);
if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
--
2.6.6
Back to top | Article view | linux.kernel
csiph-web