From: Jonathan Cameron Date: Fri, 12 Aug 2011 16:56:03 +0000 (+0100) Subject: staging:iio: Introduce iio_core.h and move all core only stuff out of iio.h. X-Git-Tag: next-20110824~7^2~80 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=df9c1c42c26f9a516dd44c956cff301741a0884e;p=karo-tx-linux.git staging:iio: Introduce iio_core.h and move all core only stuff out of iio.h. Also get rid of a few function defs where they are only now in one core file anyway. Whilst here add mask = 0 to get rid of warning. Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 07f88aa878ab..61cfb26d193b 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h @@ -23,9 +23,6 @@ * Currently assumes nano seconds. */ -/* Event interface flags */ -#define IIO_BUSY_BIT_POS 1 - /* naughty temporary hack to match these against the event version - need to flattern these together */ enum iio_chan_type { @@ -131,19 +128,7 @@ struct iio_chan_spec { unsigned modified:1; unsigned indexed:1; }; -/* Meant for internal use only */ -void __iio_device_attr_deinit(struct device_attribute *dev_attr); -int __iio_device_attr_init(struct device_attribute *dev_attr, - const char *postfix, - struct iio_chan_spec const *chan, - ssize_t (*readfunc)(struct device *dev, - struct device_attribute *attr, - char *buf), - ssize_t (*writefunc)(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len), - bool generic); + #define IIO_ST(si, rb, sb, sh) \ { .sign = si, .realbits = rb, .storagebits = sb, .shift = sh } @@ -166,20 +151,6 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, { .type = IIO_TIMESTAMP, .channel = -1, \ .scan_index = _si, .scan_type = IIO_ST('s', 64, 64, 0) } -int __iio_add_chan_devattr(const char *postfix, - const char *group, - struct iio_chan_spec const *chan, - ssize_t (*func)(struct device *dev, - struct device_attribute *attr, - char *buf), - ssize_t (*writefunc)(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len), - int mask, - bool generic, - struct device *dev, - struct list_head *attr_list); /** * iio_get_time_ns() - utility function to get a time stamp for events etc **/ @@ -344,13 +315,6 @@ int iio_push_event(struct iio_dev *dev_info, int ev_code, s64 timestamp); -/* Used to distinguish between bipolar and unipolar scan elemenents. - * Whilst this may seem obvious, we may well want to change the representation - * in the future!*/ -#define IIO_SIGNED(a) -(a) -#define IIO_UNSIGNED(a) (a) - -extern dev_t iio_devt; extern struct bus_type iio_bus_type; /** @@ -363,15 +327,6 @@ static inline void iio_put_device(struct iio_dev *dev) put_device(&dev->dev); }; -/** - * to_iio_dev() - get iio_dev for which we have the struct device - * @d: the struct device - **/ -static inline struct iio_dev *to_iio_dev(struct device *d) -{ - return container_of(d, struct iio_dev, dev); -}; - /* Can we make this smaller? */ #define IIO_ALIGN L1_CACHE_BYTES /** @@ -397,22 +352,6 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv) **/ void iio_free_device(struct iio_dev *dev); -/** - * iio_put() - internal module reference count reduce - **/ -void iio_put(void); - -/** - * iio_get() - internal module reference count increase - **/ -void iio_get(void); - -/** - * iio_device_get_chrdev_minor() - get an unused minor number - **/ -int iio_device_get_chrdev_minor(void); -void iio_device_free_chrdev_minor(int val); - /** * iio_ring_enabled() - helper function to test if any form of ring is enabled * @dev_info: IIO device info structure for device diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h new file mode 100644 index 000000000000..00e894d50e74 --- /dev/null +++ b/drivers/staging/iio/iio_core.h @@ -0,0 +1,48 @@ +/* The industrial I/O core function defs. + * + * Copyright (c) 2008 Jonathan Cameron + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * These definitions are meant for use only within the IIO core, not indvidual + * drivers. + */ + +/** + * iio_device_get_chrdev_minor() - get an unused minor number + **/ +int iio_device_get_chrdev_minor(void); +void iio_device_free_chrdev_minor(int val); + + +/** + * iio_put() - internal module reference count reduce + **/ +void iio_put(void); + +/** + * iio_get() - internal module reference count increase + **/ +void iio_get(void); + +extern dev_t iio_devt; + +int __iio_add_chan_devattr(const char *postfix, + const char *group, + struct iio_chan_spec const *chan, + ssize_t (*func)(struct device *dev, + struct device_attribute *attr, + char *buf), + ssize_t (*writefunc)(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len), + int mask, + bool generic, + struct device *dev, + struct list_head *attr_list); + +/* Event interface flags */ +#define IIO_BUSY_BIT_POS 1 diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 364964b1a815..cf268bc2ee1f 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -23,6 +23,7 @@ #include #include "iio.h" #include "trigger_consumer.h" +#include "iio_core.h" #define IIO_ID_PREFIX "device" #define IIO_ID_FORMAT IIO_ID_PREFIX "%d" @@ -35,7 +36,6 @@ static DEFINE_IDA(iio_chrdev_ida); static DEFINE_SPINLOCK(iio_ida_lock); dev_t iio_devt; -EXPORT_SYMBOL(iio_devt); #define IIO_DEV_MAX 256 struct bus_type iio_bus_type = { @@ -90,7 +90,7 @@ static const char * const iio_chan_info_postfix[] = { }; /* Return a negative errno on failure */ -int iio_get_new_ida_val(struct ida *this_ida) +static int iio_get_new_ida_val(struct ida *this_ida) { int ret; int val; @@ -109,15 +109,13 @@ ida_again: return val; } -EXPORT_SYMBOL(iio_get_new_ida_val); -void iio_free_ida_val(struct ida *this_ida, int id) +static void iio_free_ida_val(struct ida *this_ida, int id) { spin_lock(&iio_ida_lock); ida_remove(this_ida, id); spin_unlock(&iio_ida_lock); } -EXPORT_SYMBOL(iio_free_ida_val); int iio_push_event(struct iio_dev *dev_info, int ev_line, @@ -532,6 +530,7 @@ static int __iio_build_postfix(struct iio_chan_spec const *chan, return 0; } +static int __iio_device_attr_init(struct device_attribute *dev_attr, const char *postfix, struct iio_chan_spec const *chan, @@ -604,7 +603,7 @@ error_ret: return ret; } -void __iio_device_attr_deinit(struct device_attribute *dev_attr) +static void __iio_device_attr_deinit(struct device_attribute *dev_attr) { kfree(dev_attr->attr.name); } @@ -903,7 +902,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, struct iio_chan_spec const *chan) { - int ret = 0, i, mask; + int ret = 0, i, mask = 0; char *postfix; if (!chan->event_mask) return 0; @@ -1114,8 +1113,9 @@ static void iio_device_unregister_eventset(struct iio_dev *dev_info) static void iio_dev_release(struct device *device) { + struct iio_dev *dev_info = container_of(device, struct iio_dev, dev); iio_put(); - kfree(to_iio_dev(device)); + kfree(dev_info); } static struct device_type iio_dev_type = { diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index 843eb82a69ba..dce50b1a4ee9 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -21,6 +21,7 @@ #include #include "iio.h" +#include "iio_core.h" #include "ring_generic.h" /** diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 513a7a04099c..ebacfdadee1b 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -18,6 +18,7 @@ #include "iio.h" #include "trigger.h" +#include "iio_core.h" #include "trigger_consumer.h" /* RFC - Question of approach