#include <linux/slab.h>
#include <linux/anon_inodes.h>
#include <linux/debugfs.h>
-
-#ifdef DEBUG
-#define __debug_var industrialio_debug
-int industrialio_debug = 1;
-module_param(industrialio_debug, int, S_IRUGO | S_IWUSR);
-#else
-static int industrialio_debug;
-module_param(industrialio_debug, int, 0);
-#endif
-
#include "iio.h"
#include "iio_core.h"
#include "iio_core_trigger.h"
{
struct iio_dev *indio_dev = container_of(device, struct iio_dev, dev);
cdev_del(&indio_dev->chrdev);
- _DBG(0, "%s: Release iio_dev %p modes=%08x\n", __func__, indio_dev,
- indio_dev->modes);
if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
iio_device_unregister_trigger_consumer(indio_dev);
iio_device_unregister_eventset(indio_dev);
iio_device_unregister_sysfs(indio_dev);
iio_device_unregister_debugfs(indio_dev);
- _DBG(0, "%s: Freeing iio_dev %p\n", __func__, indio_dev);
kfree(indio_dev);
}
if (sizeof_priv) {
alloc_size = ALIGN(alloc_size, IIO_ALIGN);
alloc_size += sizeof_priv;
- DBG(0, "%s: alloc_size = %u + %u + %u + %u = %u\n", __func__,
- sizeof(struct iio_dev),
- ALIGN(alloc_size, IIO_ALIGN - sizeof(struct iio_dev)),
- sizeof_priv, IIO_ALIGN - 1, alloc_size + IIO_ALIGN - 1);
- } else {
- DBG(0, "%s: alloc_size = %u + %u = %u\n", __func__,
- sizeof(struct iio_dev), IIO_ALIGN - 1,
- alloc_size + IIO_ALIGN - 1);
}
/* ensure 32-byte alignment of whole construct ? */
alloc_size += IIO_ALIGN - 1;
}
dev_set_name(&dev->dev, "iio:device%d", dev->id);
get_device(&dev->dev);
- DBG(0, "%s: Allocated iio_dev %p\n", __func__, dev);
}
return dev;
{
if (dev) {
ida_simple_remove(&iio_ida, dev->id);
- DBG(0, "%s: Releasing iio_dev %p!\n", __func__, dev);
put_device(&dev->dev);
-// kfree(dev);
}
}
EXPORT_SYMBOL(iio_free_device);
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/slab.h>
-
-#ifdef DEBUG
-#define __debug_var industrialio_debug
-#endif
-
#include "iio.h"
#include "trigger.h"
#include "iio_core.h"
kfree(pf);
return NULL;
}
- DBG(0, "%s: Allocated pollfunc %p\n", __func__, pf);
pf->h = h;
pf->thread = thread;
pf->type = type;
void iio_dealloc_pollfunc(struct iio_poll_func *pf)
{
kfree(pf->name);
- DBG(0, "%s: Freeing pollfunc %p\n", __func__, pf);
kfree(pf);
}
EXPORT_SYMBOL_GPL(iio_dealloc_pollfunc);
CONFIG_IIO_CONSUMERS_PER_TRIGGER);
}
kfree(trig->name);
- DBG(0, "%s: Freeing trigger %p\n", __func__, trig);
kfree(trig);
}
IRQ_NOPROBE);
}
get_device(&trig->dev);
- DBG(0, "%s: Allocated trigger %p\n", __func__, trig);
}
return trig;
}
void iio_free_trigger(struct iio_trigger *trig)
{
- DBG(0, "%s: Releasing trigger %p\n", __func__, trig);
if (trig)
put_device(&trig->dev);
}
void iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
{
- _DBG(0, "%s: dev=%p\n", __func__, indio_dev);
indio_dev->groups[indio_dev->groupcounter++] =
&iio_trigger_consumer_attr_group;
}
void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
{
/* Clean up any associated but not attached triggers references */
- _DBG(0, "%s: dev=%p\n", __func__, indio_dev);
#if 0
if (indio_dev->trig)
iio_put_trigger(indio_dev->trig);
return 0;
mutex_lock(&iio_map_list_lock);
- DBG(0, "%s: Registering %p chan_map %p\n", __func__,
- indio_dev, maps);
while (maps[i].consumer_dev_name != NULL) {
mapi = kzalloc(sizeof(*mapi), GFP_KERNEL);
if (mapi == NULL) {
ret = -ENOMEM;
goto error_ret;
}
- DBG(0, "%s: Registering entry %p '%s','%s','%s' @ %p\n",
- __func__, &maps[i], maps[i].adc_channel_label,
- maps[i].consumer_dev_name, maps[i].consumer_channel, mapi);
mapi->map = &maps[i];
mapi->indio_dev = indio_dev;
list_add(&mapi->l, &iio_map_list);
i++;
}
error_ret:
- DBG(0, "%s: Done\n", __func__);
mutex_unlock(&iio_map_list_lock);
return ret;
return 0;
mutex_lock(&iio_map_list_lock);
- DBG(0, "%s: Unregistering %p chan_map %p\n", __func__,
- indio_dev, maps);
while (maps[i].consumer_dev_name != NULL) {
- DBG(0, "%s: Unregistering entry %p '%s','%s'\n",
- __func__, &maps[i], maps[i].adc_channel_label,
- maps[i].consumer_dev_name);
found_it = false;
list_for_each_entry(mapi, &iio_map_list, l)
if (&maps[i] == mapi->map) {
list_del(&mapi->l);
- DBG(0, "Freeing %p\n", mapi);
kfree(mapi);
found_it = true;
break;
i++;
}
error_ret:
- DBG(0, "%s: Done\n", __func__);
mutex_unlock(&iio_map_list_lock);
return ret;
int i;
const struct iio_chan_spec *chan = NULL;
- DBG(0, "%s: Searching channel '%s' out of %u channels from dev %p\n",
- __func__, name, indio_dev->num_channels, indio_dev);
for (i = 0; i < indio_dev->num_channels; i++) {
- DBG(0, "%s: dev %p '%s' chan[%d] ds name: '%s'\n",
- __func__, indio_dev, indio_dev->name, i,
- indio_dev->channels[i].datasheet_name);
if (indio_dev->channels[i].datasheet_name &&
strcmp(name, indio_dev->channels[i].datasheet_name) == 0) {
chan = &indio_dev->channels[i];
break;
}
}
- if (chan)
- DBG(0, "%s: found channel %p '%s'\n",
- __func__, chan, chan->datasheet_name);
- else
- DBG(0, "%s: channel '%s' not found\n",
- __func__, name);
return chan;
}
/* first find matching entry the channel map */
mutex_lock(&iio_map_list_lock);
- DBG(0, "%s: Searching for channel '%s' for device '%s'\n",
- __func__, channel_name, name);
list_for_each_entry(c_i, &iio_map_list, l) {
- DBG(0, "label='%s' dev='%s' key='%s'\n",
- c_i->map->adc_channel_label, c_i->map->consumer_dev_name,
- c_i->map->consumer_channel);
if ((name && strcmp(name, c_i->map->consumer_dev_name) != 0) ||
(channel_name &&
strcmp(channel_name, c_i->map->adc_channel_label) != 0))
get_device(&c->indio_dev->dev);
break;
}
- if (c)
- DBG(0, "found channel label='%s' dev='%s' key='%s' on iio_dev %p\n",
- c->map->adc_channel_label, c->map->consumer_dev_name,
- c->map->consumer_channel, c->indio_dev);
- else
- pr_err("Channel '%s' not found for device %s\n",
- channel_name, name);
+
mutex_unlock(&iio_map_list_lock);
if (c == NULL)
return ERR_PTR(-ENODEV);
}
/* for each map fill in the chans element */
- DBG(0, "%s: Searching channels for '%s'\n", __func__,
- name);
list_for_each_entry(c, &iio_map_list, l) {
- DBG(0, "label='%s' dev='%s' key='%s'\n",
- c->map->adc_channel_label, c->map->consumer_dev_name,
- c->map->consumer_channel);
if (name && strcmp(name, c->map->consumer_dev_name) != 0)
continue;
chans[mapind].indio_dev = c->indio_dev;