summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-10-26 18:58:14 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-10-26 18:58:14 +0000
commit003582d221276735233c1155d5d64e3ee7eec4ac (patch)
tree66494feaba4f8cec822069d61c1ff46f136764ca /include
parent2ee9529e22a0c0ba57f01afebe86cdf2e6c72566 (diff)
dahdi: Register devices instead of individual spans.
Increasingly, spans are implemented by devices that support more than a single span. Introduce a 'struct dahdi_device' object which explicitly contains multiple spans. This will allow a cleaner representation of spans and devices in sysfs since order of arrival will not determine the layout of the devices. This also gives the core of dahdi a way to know the relationship between spans. This generalizes similar concepts that were previously xpp specific. The conversion of the xpp code was almost entirely done by Oron and Tzafrir. Signed-off-by: Shaun Ruffell <sruffell@digium.com> Signed-off-by: Oron Peled <oron.peled@xorcom.com> Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10273 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'include')
-rw-r--r--include/dahdi/kernel.h44
1 files changed, 32 insertions, 12 deletions
diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h
index 9ae9d1e..9dec702 100644
--- a/include/dahdi/kernel.h
+++ b/include/dahdi/kernel.h
@@ -42,7 +42,7 @@
#include <linux/config.h>
#endif
#include <linux/fs.h>
-#include <linux/kobject.h>
+#include <linux/device.h>
#include <linux/ioctl.h>
#ifdef CONFIG_DAHDI_NET
@@ -885,6 +885,26 @@ struct dahdi_span_ops {
/*! Opt: Provide the name of the echo canceller on a channel */
const char *(*echocan_name)(const struct dahdi_chan *chan);
+
+ /*! When using "pinned_spans", this function is called back when this
+ * span has been assigned with the system. */
+ void (*assigned)(struct dahdi_span *span);
+};
+
+/**
+ * dahdi_device - Represents a device that can contain one or more spans.
+ *
+ * @spans: List of child spans.
+ * @manufacturer: Device manufacturer.
+ * @location: The location of this device
+ * @devicetype: What type of device this is.
+ *
+ */
+struct dahdi_device {
+ struct list_head spans;
+ const char *manufacturer;
+ const char *location;
+ const char *devicetype;
};
struct dahdi_span {
@@ -892,9 +912,6 @@ struct dahdi_span {
char name[40]; /*!< Span name */
char desc[80]; /*!< Span description */
const char *spantype; /*!< span type in text form */
- const char *manufacturer; /*!< span's device manufacturer */
- char devicetype[80]; /*!< span's device type */
- char location[40]; /*!< span device's location in system */
int deflaw; /*!< Default law (DAHDI_MULAW or DAHDI_ALAW) */
int alarms; /*!< Pending alarms on span */
unsigned long flags;
@@ -933,7 +950,10 @@ struct dahdi_span {
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_entry;
#endif
- struct list_head node;
+ struct list_head spans_node;
+
+ struct dahdi_device *parent;
+ struct list_head device_node;
};
struct dahdi_transcoder_channel {
@@ -1031,6 +1051,7 @@ struct dahdi_dynamic {
long rxjif;
unsigned short txcnt;
unsigned short rxcnt;
+ struct dahdi_device *ddev;
struct dahdi_span span;
struct dahdi_chan *chans[256];
struct dahdi_dynamic_driver *driver;
@@ -1038,6 +1059,7 @@ struct dahdi_dynamic {
int timing;
int master;
unsigned char *msgbuf;
+ struct device *dev;
struct list_head list;
};
@@ -1131,10 +1153,11 @@ void dahdi_hdlc_putbuf(struct dahdi_chan *ss, unsigned char *rxb, int bytes);
* and 1 if the currently transmitted message is now done */
int dahdi_hdlc_getbuf(struct dahdi_chan *ss, unsigned char *bufptr, unsigned int *size);
-
-/*! Register a span. Returns 0 on success, -1 on failure. Pref-master is non-zero if
- we should have preference in being the master device */
-int dahdi_register(struct dahdi_span *span, int prefmaster);
+/*! Register a device. Returns 0 on success, -1 on failure. */
+struct dahdi_device *dahdi_create_device(void);
+int dahdi_register_device(struct dahdi_device *ddev, struct device *parent);
+void dahdi_unregister_device(struct dahdi_device *ddev);
+void dahdi_free_device(struct dahdi_device *ddev);
/*! Allocate / free memory for a transcoder */
struct dahdi_transcoder *dahdi_transcoder_alloc(int numchans);
@@ -1149,9 +1172,6 @@ int dahdi_transcoder_unregister(struct dahdi_transcoder *tc);
/*! \brief Alert a transcoder */
int dahdi_transcoder_alert(struct dahdi_transcoder_channel *ztc);
-/*! \brief Unregister a span */
-int dahdi_unregister(struct dahdi_span *span);
-
/*! \brief Gives a name to an LBO */
const char *dahdi_lboname(int lbo);