From 581df51b0dfcf3148dad593cb13705fd6896d5ed Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Wed, 26 Oct 2011 18:59:20 +0000 Subject: dahdi: Expose dahdi devices in sysfs. This exposes dahdi devices in sysfs and also exposes attributes that will allow user space to control the registration order in spans. This facilitates loading drivers out of order yet keeping consistent span/channel numbering, which in turn will eventually allow the blacklist for DAHDI drivers to be removed. The default behavior, controlled with the auto_register module parameter on dahdi is to number the spans / channels in order like is currently done. So this change does not introduce any new behavior by default. * Writing (anything) to this attribute returns the span to its unassigned state * Fix dahdi_chan_unreg() echocan refcount * Add safeguard against duplicate unassignment to _dahdi_unregister_span() * Remove the span from device_node list, only in dahdi_unregister_device() and not in dahdi_unregister_span() * Free allocated span->span_device in span_sysfs_remove() [is it safe?, didn't cause problem so far...] Signed-off-by: Shaun Ruffell Signed-off-by: Oron Peled Signed-off-by: Tzafrir Cohen dahdi: Add "hardware_id" dahdi_device attribute. - The "hardware_id" does not change with device location (e.g: when a PCI card is moved from one slot to another). - Not all devices have this attribute. It is legal for it to be NULL (that is the default for all low-level drivers that do not set it explicitly). - When "hardware_id" is NULL, the sysfs attribute value is "\n" Signed-off-by: Oron Peled Acked-by: Shaun Ruffell git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10275 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- include/dahdi/kernel.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index 12e8ff2..bb32126 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -896,16 +896,21 @@ struct dahdi_span_ops { /** * dahdi_device - Represents a device that can contain one or more spans. * - * @spans: List of child spans. + * @spans: List of child spans. * @manufacturer: Device manufacturer. - * @location: The location of this device - * @devicetype: What type of device this is. + * @location: The location of this device. This should not change if + * the device is replaced (e.g: in the same PCI slot) + * @hardware_id: The hardware_id of this device (NULL for devices without + * a hardware_id). This should not change if the device is + * relocated to a different location (e.g: different PCI slot) + * @devicetype: What type of device this is. * */ struct dahdi_device { struct list_head spans; const char *manufacturer; const char *location; + const char *hardware_id; const char *devicetype; struct device dev; }; @@ -1164,6 +1169,7 @@ 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); +void dahdi_init_span(struct dahdi_span *span); /*! Allocate / free memory for a transcoder */ struct dahdi_transcoder *dahdi_transcoder_alloc(int numchans); @@ -1451,6 +1457,10 @@ typedef u32 __bitwise pm_message_t; #endif /* 2.6.26 */ #endif /* 2.6.31 */ +#ifndef CONFIG_TRACING +#define trace_printk printk +#endif + #ifndef DEFINE_SPINLOCK #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED #endif -- cgit v1.2.3