mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@cam.ac.uk>
To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: arnd@arndb.de, tglx@linutronix.de, Jonathan Cameron <jic23@cam.ac.uk>
Subject: [PATCH 07/21] staging:iio: Buffer device flattening.
Date: Thu, 31 Mar 2011 15:54:01 +0100	[thread overview]
Message-ID: <1301583255-28468-8-git-send-email-jic23@cam.ac.uk> (raw)
In-Reply-To: <1301583255-28468-1-git-send-email-jic23@cam.ac.uk>

Given we now only have one device we don't need the extra layer any more.
Hence this patch removes it.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/staging/iio/industrialio-ring.c |   76 ++++++++++---------------------
 drivers/staging/iio/ring_generic.h      |    8 +---
 drivers/staging/iio/ring_sw.c           |    3 +-
 3 files changed, 28 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c
index b503ea1..07d64bc 100644
--- a/drivers/staging/iio/industrialio-ring.c
+++ b/drivers/staging/iio/industrialio-ring.c
@@ -106,72 +106,60 @@ static const struct file_operations iio_ring_fileops = {
 	.llseek = noop_llseek,
 };
 
-static void iio_ring_access_release(struct device *dev)
+void iio_ring_access_release(struct device *dev)
 {
 	struct iio_ring_buffer *buf
-		= access_dev_to_iio_ring_buffer(dev);
+		= container_of(dev, struct iio_ring_buffer, dev);
 	cdev_del(&buf->access_handler.chrdev);
 	iio_device_free_chrdev_minor(MINOR(dev->devt));
 }
-
-static struct device_type iio_ring_access_type = {
-	.release = iio_ring_access_release,
-};
+EXPORT_SYMBOL(iio_ring_access_release);
 
 static inline int
-__iio_request_ring_buffer_access_chrdev(struct iio_ring_buffer *buf,
-					int id,
+__iio_request_ring_buffer_chrdev(struct iio_ring_buffer *buf,
 					struct module *owner)
 {
 	int ret, minor;
 
 	buf->access_handler.flags = 0;
 
-	buf->access_dev.parent = &buf->dev;
-	buf->access_dev.bus = &iio_bus_type;
-	buf->access_dev.type = &iio_ring_access_type;
-	device_initialize(&buf->access_dev);
+	buf->dev.bus = &iio_bus_type;
+	device_initialize(&buf->dev);
 
 	minor = iio_device_get_chrdev_minor();
 	if (minor < 0) {
 		ret = minor;
 		goto error_device_put;
 	}
-	buf->access_dev.devt = MKDEV(MAJOR(iio_devt), minor);
-
-
-	buf->access_id = id;
-
-	dev_set_name(&buf->access_dev, "%s:access%d",
-		     dev_name(&buf->dev),
-		     buf->access_id);
-	ret = device_add(&buf->access_dev);
+	buf->dev.devt = MKDEV(MAJOR(iio_devt), minor);
+	dev_set_name(&buf->dev, "%s:buffer%d",
+		     dev_name(buf->dev.parent),
+		     buf->id);
+	ret = device_add(&buf->dev);
 	if (ret < 0) {
-		printk(KERN_ERR "failed to add the ring access dev\n");
+		printk(KERN_ERR "failed to add the ring dev\n");
 		goto error_device_put;
 	}
-
 	cdev_init(&buf->access_handler.chrdev, &iio_ring_fileops);
 	buf->access_handler.chrdev.owner = owner;
-
-	ret = cdev_add(&buf->access_handler.chrdev, buf->access_dev.devt, 1);
+	ret = cdev_add(&buf->access_handler.chrdev, buf->dev.devt, 1);
 	if (ret) {
-		printk(KERN_ERR "failed to allocate ring access chrdev\n");
+		printk(KERN_ERR "failed to allocate ring chrdev\n");
 		goto error_device_unregister;
 	}
 	return 0;
 
 error_device_unregister:
-	device_unregister(&buf->access_dev);
+	device_unregister(&buf->dev);
 error_device_put:
-	put_device(&buf->access_dev);
+	put_device(&buf->dev);
 
 	return ret;
 }
 
-static void __iio_free_ring_buffer_access_chrdev(struct iio_ring_buffer *buf)
+static void __iio_free_ring_buffer_chrdev(struct iio_ring_buffer *buf)
 {
-	device_unregister(&buf->access_dev);
+	device_unregister(&buf->dev);
 }
 
 void iio_ring_buffer_init(struct iio_ring_buffer *ring,
@@ -344,36 +332,25 @@ int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, int id,
 
 	ring->id = id;
 
-	dev_set_name(&ring->dev, "%s:buffer%d",
-		     dev_name(ring->dev.parent),
-		     ring->id);
-	ret = device_add(&ring->dev);
-	if (ret)
-		goto error_ret;
-
-	ret = __iio_request_ring_buffer_access_chrdev(ring,
-						      0,
-						      ring->owner);
+	ret = __iio_request_ring_buffer_chrdev(ring, ring->owner);
 
 	if (ret)
-		goto error_remove_device;
-
+		goto error_ret;
 	if (ring->scan_el_attrs) {
 		ret = sysfs_create_group(&ring->dev.kobj,
 					 ring->scan_el_attrs);
 		if (ret) {
 			dev_err(&ring->dev,
 				"Failed to add sysfs scan elements\n");
-			goto error_free_ring_buffer_access_chrdev;
+			goto error_free_ring_buffer_chrdev;
 		}
 	} else if (channels) {
 		ret = sysfs_create_group(&ring->dev.kobj,
 					 &iio_scan_el_dummy_group);
 		if (ret)
-			goto error_free_ring_buffer_access_chrdev;
+			goto error_free_ring_buffer_chrdev;
 	}
 
-
 	INIT_LIST_HEAD(&ring->scan_el_dev_attr_list);
 	INIT_LIST_HEAD(&ring->scan_el_en_attr_list);
 	if (channels) {
@@ -388,10 +365,8 @@ int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, int id,
 	return 0;
 error_cleanup_dynamic:
 	__iio_ring_attr_cleanup(ring);
-error_free_ring_buffer_access_chrdev:
-	__iio_free_ring_buffer_access_chrdev(ring);
-error_remove_device:
-	device_del(&ring->dev);
+error_free_ring_buffer_chrdev:
+	__iio_free_ring_buffer_chrdev(ring);
 error_ret:
 	return ret;
 }
@@ -406,8 +381,7 @@ EXPORT_SYMBOL(iio_ring_buffer_register);
 void iio_ring_buffer_unregister(struct iio_ring_buffer *ring)
 {
 	__iio_ring_attr_cleanup(ring);
-	__iio_free_ring_buffer_access_chrdev(ring);
-	device_del(&ring->dev);
+	__iio_free_ring_buffer_chrdev(ring);
 }
 EXPORT_SYMBOL(iio_ring_buffer_unregister);
 
diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h
index 44c7543..ba441d9 100644
--- a/drivers/staging/iio/ring_generic.h
+++ b/drivers/staging/iio/ring_generic.h
@@ -68,11 +68,9 @@ struct iio_ring_access_funcs {
 /**
  * struct iio_ring_buffer - general ring buffer structure
  * @dev:		ring buffer device struct
- * @access_dev:		system device struct for the chrdev
  * @indio_dev:		industrial I/O device structure
  * @owner:		module that owns the ring buffer (for ref counting)
  * @id:			unique id number
- * @access_id:		device id number
  * @length:		[DEVICE] number of datums in ring
  * @bytes_per_datum:	[DEVICE] size of individual datum including timestamp
  * @bpe:		[DEVICE] size of individual channel value
@@ -92,11 +90,9 @@ struct iio_ring_access_funcs {
   **/
 struct iio_ring_buffer {
 	struct device dev;
-	struct device access_dev;
 	struct iio_dev *indio_dev;
 	struct module *owner;
 	int				id;
-	int				access_id;
 	int				length;
 	int				bytes_per_datum;
 	int				bpe;
@@ -398,8 +394,6 @@ static inline void iio_put_ring_buffer(struct iio_ring_buffer *ring)
 
 #define to_iio_ring_buffer(d)			\
 	container_of(d, struct iio_ring_buffer, dev)
-#define access_dev_to_iio_ring_buffer(d)			\
-	container_of(d, struct iio_ring_buffer, access_dev)
 
 /**
  * iio_ring_buffer_register() - register the buffer with IIO core
@@ -416,6 +410,8 @@ int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, int id,
 				struct iio_chan_spec *channels,
 				int num_channels);
 
+void iio_ring_access_release(struct device *dev);
+
 /**
  * iio_ring_buffer_unregister() - unregister the buffer from IIO core
  * @ring: the buffer to be unregistered
diff --git a/drivers/staging/iio/ring_sw.c b/drivers/staging/iio/ring_sw.c
index a429a3d..5fbf5ff 100644
--- a/drivers/staging/iio/ring_sw.c
+++ b/drivers/staging/iio/ring_sw.c
@@ -375,6 +375,7 @@ EXPORT_SYMBOL(iio_mark_update_needed_sw_rb);
 static void iio_sw_rb_release(struct device *dev)
 {
 	struct iio_ring_buffer *r = to_iio_ring_buffer(dev);
+	iio_ring_access_release(&r->dev);
 	kfree(iio_to_sw_ring(r));
 }
 
@@ -416,9 +417,7 @@ struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev)
 	iio_ring_buffer_init(buf, indio_dev);
 	__iio_init_sw_ring_buffer(ring);
 	buf->dev.type = &iio_sw_ring_type;
-	device_initialize(&buf->dev);
 	buf->dev.parent = &indio_dev->dev;
-	buf->dev.bus = &iio_bus_type;
 	dev_set_drvdata(&buf->dev, (void *)buf);
 
 	return buf;
-- 
1.7.3.4


  parent reply	other threads:[~2011-03-31 14:57 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-31 14:53 [RFC PATCH 00/21] IIO: Channel registration rework, buffer chardev combining and rewrite of triggers as 'virtual' irq_chips Jonathan Cameron
2011-03-31 14:53 ` [PATCH 01/21] staging:iio: allow channels to be set up using a table of iio_channel_spec structures Jonathan Cameron
2011-03-31 14:53 ` [PATCH 02/21] staging:iio:lis3l02dq - experimental move to new channel_spec approach Jonathan Cameron
2011-03-31 14:53 ` [PATCH 03/21] staging:iio:max1363 - experimental move to channel_spec registration Jonathan Cameron
2011-03-31 14:53 ` [PATCH 04/21] staging:iio: remove ability to escalate events Jonathan Cameron
2011-03-31 14:53 ` [PATCH 05/21] staging:iio: Add polling of events on the ring access chrdev Jonathan Cameron
2011-03-31 14:54 ` [PATCH 06/21] staging:iio: remove legacy event chrdev for the buffers Jonathan Cameron
2011-03-31 14:54 ` Jonathan Cameron [this message]
2011-03-31 14:54 ` [PATCH 08/21] staging:iio:lis3l02dq: General cleanup Jonathan Cameron
2011-03-31 14:54 ` [PATCH 09/21] staging:iio: Push interrupt setup down into the drivers for event lines Jonathan Cameron
2011-03-31 14:54 ` [PATCH 10/21] staging:iio: lis3l02dq - separate entirely interrupt handling for thesholds from that for the datardy signal Jonathan Cameron
2011-03-31 14:54 ` [PATCH 11/21] staging:iio: Remove legacy event handling Jonathan Cameron
2011-03-31 14:54 ` [PATCH 12/21] staging:iio:lis3l02dq make threshold interrupt threaded Jonathan Cameron
2011-03-31 14:54 ` [PATCH 13/21] arm: irq: export set flags Jonathan Cameron
2011-03-31 15:48   ` Thomas Gleixner
2011-03-31 14:54 ` [PATCH 14/21] irq: export handle_simple_irq and irq_to_desc to allow for virtual irqs in IIO Jonathan Cameron
2011-03-31 14:54 ` [PATCH 15/21] staging:iio: Add infrastructure for irq_chip based triggers Jonathan Cameron
2011-04-02 18:34   ` Jonathan Cameron
2011-03-31 14:54 ` [PATCH 16/21] stargate2 - add an IIO interrupt pool Jonathan Cameron
2011-03-31 14:54 ` [PATCH 17/21] staging:iio:Documentation generic_buffer.c update to new abi for buffers Jonathan Cameron
2011-03-31 14:54 ` [PATCH 18/21] staging:iio:ring_sw add function needed for threaded irq Jonathan Cameron
2011-03-31 14:54 ` [PATCH 19/21] staging:iio:lis3l02dq move to threaded trigger handling Jonathan Cameron
2011-03-31 14:54 ` [PATCH 20/21] staging:iio:trigger remove legacy pollfunc elements Jonathan Cameron
2011-03-31 14:54 ` [PATCH 21/21] staging:iio: rip out scan_el attributes. Now handled as iio_dev_attrs like everything else Jonathan Cameron
2011-03-31 15:28 ` [RFC PATCH 00/21] IIO: Channel registration rework, buffer chardev combining and rewrite of triggers as 'virtual' irq_chips Arnd Bergmann
2011-04-04 12:02 ` Michael Hennerich
2011-04-04 13:17   ` Jonathan Cameron
2011-04-04 13:26     ` Jonathan Cameron
2011-04-04 14:44     ` Michael Hennerich
2011-04-04 18:09       ` Jonathan Cameron
2011-04-04 14:49     ` Arnd Bergmann
2011-04-04 17:51       ` Jonathan Cameron
2011-04-11 18:38 ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1301583255-28468-8-git-send-email-jic23@cam.ac.uk \
    --to=jic23@cam.ac.uk \
    --cc=arnd@arndb.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®