提交 d2102677 编写于 作者: G Greg Kroah-Hartman

Merge 3.4-rc5 into staging-next

This resolves the conflict in:
	drivers/staging/vt6656/ioctl.c
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
......@@ -108,7 +108,7 @@ Description:
physically equivalent inputs when non differential readings are
separately available. In differential only parts, then all that
is required is a consistent labeling. Units after application
of scale and offset are nanofarads..
of scale and offset are nanofarads.
What: /sys/bus/iio/devices/iio:deviceX/in_temp_raw
What: /sys/bus/iio/devices/iio:deviceX/in_tempX_raw
......@@ -119,7 +119,7 @@ KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Description:
Raw (unscaled no bias removal etc) temperature measurement.
It an axis is specified it generally means that the temperature
If an axis is specified it generally means that the temperature
sensor is associated with one part of a compound device (e.g.
a gyroscope axis). Units after application of scale and offset
are milli degrees Celsuis.
......@@ -232,7 +232,7 @@ Description:
If known for a device, scale to be applied to <type>Y[_name]_raw
post addition of <type>[Y][_name]_offset in order to obtain the
measured value in <type> units as specified in
<type>[Y][_name]_raw documentation.. If shared across all in
<type>[Y][_name]_raw documentation. If shared across all in
channels then Y and <x|y|z> are not present and the value is
called <type>[Y][_name]_scale. The peak modifier means this
value is applied to <type>Y[_name]_peak_raw values.
......@@ -243,6 +243,8 @@ What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_calibbias
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_calibbias
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_calibbias
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_calibbias
What: /sys/bus/iio/devices/iio:deviceX/in_illuminance0_calibbias
What: /sys/bus/iio/devices/iio:deviceX/in_proximity0_calibbias
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Description:
......@@ -258,6 +260,8 @@ What /sys/bus/iio/devices/iio:deviceX/in_accel_z_calibscale
What /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_calibscale
What /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_calibscale
What /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_calibscale
what /sys/bus/iio/devices/iio:deviceX/in_illuminance0_calibscale
what /sys/bus/iio/devices/iio:deviceX/in_proximity0_calibscale
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Description:
......@@ -453,10 +457,14 @@ What: /sys/.../events/in_magn_z_raw_thresh_rising_value
What: /sys/.../events/in_magn_z_raw_thresh_falling_value
What: /sys/.../events/in_voltageY_supply_raw_thresh_rising_value
What: /sys/.../events/in_voltageY_supply_raw_thresh_falling_value
What: /sys/.../events/in_voltageY_raw_thresh_rising_value
What: /sys/.../events/in_voltageY_raw_thresh_falling_value
What: /sys/.../events/in_voltageY_raw_thresh_falling_value
What: /sys/.../events/in_tempY_raw_thresh_falling_value
What: /sys/.../events/in_tempY_raw_thresh_rising_value
What: /sys/.../events/in_tempY_raw_thresh_falling_value
What: /sys/.../events/in_illuminance0_thresh_falling_value
what: /sys/.../events/in_illuminance0_thresh_rising_value
what: /sys/.../events/in_proximity0_thresh_falling_value
what: /sys/.../events/in_proximity0_thresh_rising_value
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
......@@ -490,9 +498,9 @@ What: /sys/.../events/in_magn_z_raw_roc_rising_value
What: /sys/.../events/in_magn_z_raw_roc_falling_value
What: /sys/.../events/in_voltageY_supply_raw_roc_rising_value
What: /sys/.../events/in_voltageY_supply_raw_roc_falling_value
What: /sys/.../events/in_voltageY_raw_roc_rising_value
What: /sys/.../events/in_voltageY_raw_roc_falling_value
What: /sys/.../events/in_voltageY_raw_roc_falling_value
What: /sys/.../events/in_tempY_raw_roc_falling_value
What: /sys/.../events/in_tempY_raw_roc_rising_value
What: /sys/.../events/in_tempY_raw_roc_falling_value
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
......@@ -556,6 +564,8 @@ What: /sys/.../events/in_tempY_thresh_falling_period
What: /sys/.../events/in_tempY_roc_rising_period
What: /sys/.../events/in_tempY_roc_falling_period
What: /sys/.../events/in_accel_x&y&z_mag_falling_period
What: /sys/.../events/in_intensity0_thresh_period
What: /sys/.../events/in_proximity0_thresh_period
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
......@@ -718,24 +728,3 @@ Contact: linux-iio@vger.kernel.org
Description:
This attribute is used to read the amount of quadrature error
present in the device at a given time.
What: /sys/.../iio:deviceX/ac_excitation_en
KernelVersion: 3.1.0
Contact: linux-iio@vger.kernel.org
Description:
This attribute, if available, is used to enable the AC
excitation mode found on some converters. In ac excitation mode,
the polarity of the excitation voltage is reversed on
alternate cycles, to eliminate DC errors.
What: /sys/.../iio:deviceX/bridge_switch_en
KernelVersion: 3.1.0
Contact: linux-iio@vger.kernel.org
Description:
This attribute, if available, is used to close or open the
bridge power down switch found on some converters.
In bridge applications, such as strain gauges and load cells,
the bridge itself consumes the majority of the current in the
system. To minimize the current consumption of the system,
the bridge can be disconnected (when it is not being used
using the bridge_switch_en attribute.
* NXP LPC32xx SoC ADC controller
Required properties:
- compatible: must be "nxp,lpc3220-adc"
- reg: physical base address of the controller and length of memory mapped
region.
- interrupts: The ADC interrupt
Example:
adc@40048000 {
compatible = "nxp,lpc3220-adc";
reg = <0x40048000 0x1000>;
interrupt-parent = <&mic>;
interrupts = <39 0>;
};
* ST SPEAr ADC device driver
Required properties:
- compatible: Should be "st,spear600-adc"
- reg: Address and length of the register set for the device
- interrupt-parent: Should be the phandle for the interrupt controller
that services interrupts for this device
- interrupts: Should contain the ADC interrupt
- sampling-frequency: Default sampling frequency
Optional properties:
- vref-external: External voltage reference in milli-volts. If omitted
the internal voltage reference will be used.
- average-samples: Number of samples to generate an average value. If
omitted, single data conversion will be used.
Examples:
adc: adc@d8200000 {
compatible = "st,spear600-adc";
reg = <0xd8200000 0x1000>;
interrupt-parent = <&vic1>;
interrupts = <6>;
sampling-frequency = <5000000>;
vref-external = <2500>; /* 2.5V VRef */
};
......@@ -3384,6 +3384,7 @@ IIO SUBSYSTEM AND DRIVERS
M: Jonathan Cameron <jic23@cam.ac.uk>
L: linux-iio@vger.kernel.org
S: Maintained
F: drivers/iio/
F: drivers/staging/iio/
IKANOS/ADI EAGLE ADSL USB DRIVER
......
......@@ -140,4 +140,8 @@ source "drivers/virt/Kconfig"
source "drivers/devfreq/Kconfig"
source "drivers/iio/Kconfig"
source "drivers/vme/Kconfig"
endmenu
......@@ -134,3 +134,5 @@ obj-$(CONFIG_VIRT_DRIVERS) += virt/
obj-$(CONFIG_HYPERV) += hv/
obj-$(CONFIG_PM_DEVFREQ) += devfreq/
obj-$(CONFIG_IIO) += iio/
obj-$(CONFIG_VME_BUS) += vme/
#
# Industrial I/O subsytem configuration
#
menuconfig IIO
tristate "Industrial I/O support"
depends on GENERIC_HARDIRQS
help
The industrial I/O subsystem provides a unified framework for
drivers for many different types of embedded sensors using a
number of different physical interfaces (i2c, spi, etc). See
Documentation/iio for more information.
if IIO
config IIO_BUFFER
bool "Enable buffer support within IIO"
help
Provide core support for various buffer based data
acquisition methods.
if IIO_BUFFER
config IIO_KFIFO_BUF
select IIO_TRIGGER
tristate "Industrial I/O buffering based on kfifo"
help
A simple fifo based on kfifo. Use this if you want a fifo
rather than a ring buffer. Note that this currently provides
no buffer events so it is up to userspace to work out how
often to read from the buffer.
endif # IIO_BUFFER
config IIO_TRIGGER
boolean "Enable triggered sampling support"
help
Provides IIO core support for triggers. Currently these
are used to initialize capture of samples to push into
ring buffers. The triggers are effectively a 'capture
data now' interrupt.
config IIO_CONSUMERS_PER_TRIGGER
int "Maximum number of consumers per trigger"
depends on IIO_TRIGGER
default "2"
help
This value controls the maximum number of consumers that a
given trigger may handle. Default is 2.
endif # IIO
#
# Makefile for the industrial I/O core.
#
obj-$(CONFIG_IIO) += industrialio.o
industrialio-y := industrialio-core.o industrialio-event.o inkern.o
industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o
industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o
obj-$(CONFIG_IIO_KFIFO_BUF) += kfifo_buf.o
......@@ -12,6 +12,12 @@
#ifndef _IIO_CORE_H_
#define _IIO_CORE_H_
#include <linux/kernel.h>
#include <linux/device.h>
struct iio_chan_spec;
struct iio_dev;
int __iio_add_chan_devattr(const char *postfix,
struct iio_chan_spec const *chan,
......
......@@ -21,10 +21,10 @@
#include <linux/slab.h>
#include <linux/poll.h>
#include "iio.h"
#include <linux/iio/iio.h>
#include "iio_core.h"
#include "sysfs.h"
#include "buffer.h"
#include <linux/iio/sysfs.h>
#include <linux/iio/buffer.h>
static const char * const iio_endian_prefix[] = {
[IIO_BE] = "be",
......@@ -124,13 +124,15 @@ static ssize_t iio_scan_el_store(struct device *dev,
const char *buf,
size_t len)
{
int ret = 0;
int ret;
bool state;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct iio_buffer *buffer = indio_dev->buffer;
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
state = !(buf[0] == '0');
ret = strtobool(buf, &state);
if (ret < 0)
return ret;
mutex_lock(&indio_dev->mlock);
if (iio_buffer_enabled(indio_dev)) {
ret = -EBUSY;
......@@ -169,17 +171,21 @@ static ssize_t iio_scan_el_ts_store(struct device *dev,
const char *buf,
size_t len)
{
int ret = 0;
int ret;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
bool state;
state = !(buf[0] == '0');
ret = strtobool(buf, &state);
if (ret < 0)
return ret;
mutex_lock(&indio_dev->mlock);
if (iio_buffer_enabled(indio_dev)) {
ret = -EBUSY;
goto error_ret;
}
indio_dev->buffer->scan_timestamp = state;
indio_dev->scan_timestamp = state;
error_ret:
mutex_unlock(&indio_dev->mlock);
......@@ -291,7 +297,7 @@ int iio_buffer_register(struct iio_dev *indio_dev,
goto error_cleanup_dynamic;
attrcount += ret;
if (channels[i].type == IIO_TIMESTAMP)
buffer->scan_index_timestamp =
indio_dev->scan_index_timestamp =
channels[i].scan_index;
}
if (indio_dev->masklength && buffer->scan_mask == NULL) {
......@@ -503,30 +509,41 @@ static const unsigned long *iio_scan_mask_match(const unsigned long *av_masks,
return NULL;
}
int iio_sw_buffer_preenable(struct iio_dev *indio_dev)
static int iio_compute_scan_bytes(struct iio_dev *indio_dev, const long *mask,
bool timestamp)
{
struct iio_buffer *buffer = indio_dev->buffer;
const struct iio_chan_spec *ch;
unsigned bytes = 0;
int length, i;
dev_dbg(&indio_dev->dev, "%s\n", __func__);
/* How much space will the demuxed element take? */
for_each_set_bit(i, buffer->scan_mask,
for_each_set_bit(i, mask,
indio_dev->masklength) {
ch = iio_find_channel_from_si(indio_dev, i);
length = ch->scan_type.storagebits/8;
length = ch->scan_type.storagebits / 8;
bytes = ALIGN(bytes, length);
bytes += length;
}
if (buffer->scan_timestamp) {
if (timestamp) {
ch = iio_find_channel_from_si(indio_dev,
buffer->scan_index_timestamp);
length = ch->scan_type.storagebits/8;
indio_dev->scan_index_timestamp);
length = ch->scan_type.storagebits / 8;
bytes = ALIGN(bytes, length);
bytes += length;
}
buffer->access->set_bytes_per_datum(buffer, bytes);
return bytes;
}
int iio_sw_buffer_preenable(struct iio_dev *indio_dev)
{
struct iio_buffer *buffer = indio_dev->buffer;
dev_dbg(&indio_dev->dev, "%s\n", __func__);
/* How much space will the demuxed element take? */
indio_dev->scan_bytes =
iio_compute_scan_bytes(indio_dev, buffer->scan_mask,
buffer->scan_timestamp);
buffer->access->set_bytes_per_datum(buffer, indio_dev->scan_bytes);
/* What scan mask do we actually have ?*/
if (indio_dev->available_scan_masks)
......@@ -638,19 +655,25 @@ int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data,
}
EXPORT_SYMBOL_GPL(iio_push_to_buffer);
static void iio_buffer_demux_free(struct iio_buffer *buffer)
{
struct iio_demux_table *p, *q;
list_for_each_entry_safe(p, q, &buffer->demux_list, l) {
list_del(&p->l);
kfree(p);
}
}
int iio_update_demux(struct iio_dev *indio_dev)
{
const struct iio_chan_spec *ch;
struct iio_buffer *buffer = indio_dev->buffer;
int ret, in_ind = -1, out_ind, length;
unsigned in_loc = 0, out_loc = 0;
struct iio_demux_table *p, *q;
struct iio_demux_table *p;
/* Clear out any old demux */
list_for_each_entry_safe(p, q, &buffer->demux_list, l) {
list_del(&p->l);
kfree(p);
}
iio_buffer_demux_free(buffer);
kfree(buffer->demux_bounce);
buffer->demux_bounce = NULL;
......@@ -704,7 +727,7 @@ int iio_update_demux(struct iio_dev *indio_dev)
goto error_clear_mux_table;
}
ch = iio_find_channel_from_si(indio_dev,
buffer->scan_index_timestamp);
indio_dev->scan_index_timestamp);
length = ch->scan_type.storagebits/8;
if (out_loc % length)
out_loc += length - out_loc % length;
......@@ -725,10 +748,8 @@ int iio_update_demux(struct iio_dev *indio_dev)
return 0;
error_clear_mux_table:
list_for_each_entry_safe(p, q, &buffer->demux_list, l) {
list_del(&p->l);
kfree(p);
}
iio_buffer_demux_free(buffer);
return ret;
}
EXPORT_SYMBOL_GPL(iio_update_demux);
......@@ -23,11 +23,11 @@
#include <linux/slab.h>
#include <linux/anon_inodes.h>
#include <linux/debugfs.h>
#include "iio.h"
#include <linux/iio/iio.h>
#include "iio_core.h"
#include "iio_core_trigger.h"
#include "sysfs.h"
#include "events.h"
#include <linux/iio/sysfs.h>
#include <linux/iio/events.h>
/* IDA to assign each registered device a unique id*/
static DEFINE_IDA(iio_ida);
......@@ -42,11 +42,6 @@ EXPORT_SYMBOL(iio_bus_type);
static struct dentry *iio_debugfs_dentry;
static const char * const iio_data_type_name[] = {
[IIO_RAW] = "raw",
[IIO_PROCESSED] = "input",
};
static const char * const iio_direction[] = {
[0] = "in",
[1] = "out",
......@@ -68,6 +63,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_ANGL] = "angl",
[IIO_TIMESTAMP] = "timestamp",
[IIO_CAPACITANCE] = "capacitance",
[IIO_ALTVOLTAGE] = "altvoltage",
};
static const char * const iio_modifier_names[] = {
......@@ -80,6 +76,8 @@ static const char * const iio_modifier_names[] = {
/* relies on pairs of these shared then separate */
static const char * const iio_chan_info_postfix[] = {
[IIO_CHAN_INFO_RAW] = "raw",
[IIO_CHAN_INFO_PROCESSED] = "input",
[IIO_CHAN_INFO_SCALE] = "scale",
[IIO_CHAN_INFO_OFFSET] = "offset",
[IIO_CHAN_INFO_CALIBSCALE] = "calibscale",
......@@ -90,6 +88,9 @@ static const char * const iio_chan_info_postfix[] = {
[IIO_CHAN_INFO_AVERAGE_RAW] = "mean_raw",
[IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY]
= "filter_low_pass_3db_frequency",
[IIO_CHAN_INFO_SAMP_FREQ] = "sampling_frequency",
[IIO_CHAN_INFO_FREQUENCY] = "frequency",
[IIO_CHAN_INFO_PHASE] = "phase",
};
const struct iio_chan_spec
......@@ -280,7 +281,7 @@ static ssize_t iio_read_channel_ext_info(struct device *dev,
ext_info = &this_attr->c->ext_info[this_attr->address];
return ext_info->read(indio_dev, this_attr->c, buf);
return ext_info->read(indio_dev, ext_info->private, this_attr->c, buf);
}
static ssize_t iio_write_channel_ext_info(struct device *dev,
......@@ -294,7 +295,8 @@ static ssize_t iio_write_channel_ext_info(struct device *dev,
ext_info = &this_attr->c->ext_info[this_attr->address];
return ext_info->write(indio_dev, this_attr->c, buf, len);
return ext_info->write(indio_dev, ext_info->private,
this_attr->c, buf, len);
}
static ssize_t iio_read_channel_info(struct device *dev,
......@@ -575,25 +577,12 @@ int __iio_add_chan_devattr(const char *postfix,
static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan)
{
int ret, i, attrcount = 0;
int ret, attrcount = 0;
int i;
const struct iio_chan_spec_ext_info *ext_info;
if (chan->channel < 0)
return 0;
ret = __iio_add_chan_devattr(iio_data_type_name[chan->processed_val],
chan,
&iio_read_channel_info,
(chan->output ?
&iio_write_channel_info : NULL),
0,
0,
&indio_dev->dev,
&indio_dev->channel_attr_list);
if (ret)
goto error_ret;
attrcount++;
for_each_set_bit(i, &chan->info_mask, sizeof(long)*8) {
ret = __iio_add_chan_devattr(iio_chan_info_postfix[i/2],
chan,
......@@ -752,7 +741,7 @@ static struct device_type iio_dev_type = {
.release = iio_dev_release,
};
struct iio_dev *iio_allocate_device(int sizeof_priv)
struct iio_dev *iio_device_alloc(int sizeof_priv)
{
struct iio_dev *dev;
size_t alloc_size;
......@@ -788,16 +777,16 @@ struct iio_dev *iio_allocate_device(int sizeof_priv)
return dev;
}
EXPORT_SYMBOL(iio_allocate_device);
EXPORT_SYMBOL(iio_device_alloc);
void iio_free_device(struct iio_dev *dev)
void iio_device_free(struct iio_dev *dev)
{
if (dev) {
ida_simple_remove(&iio_ida, dev->id);
kfree(dev);
}
}
EXPORT_SYMBOL(iio_free_device);
EXPORT_SYMBOL(iio_device_free);
/**
* iio_chrdev_open() - chrdev file open for buffer access and ioctls
......
......@@ -20,10 +20,10 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/wait.h>
#include "iio.h"
#include <linux/iio/iio.h>
#include "iio_core.h"
#include "sysfs.h"
#include "events.h"
#include <linux/iio/sysfs.h>
#include <linux/iio/events.h>
/**
* struct iio_event_interface - chrdev interface for an event line
......
......@@ -15,11 +15,11 @@
#include <linux/list.h>
#include <linux/slab.h>
#include "iio.h"
#include "trigger.h"
#include <linux/iio/iio.h>
#include <linux/iio/trigger.h>
#include "iio_core.h"
#include "iio_core_trigger.h"
#include "trigger_consumer.h"
#include <linux/iio/trigger_consumer.h>
/* RFC - Question of approach
* Make the common case (single sensor single trigger)
......@@ -360,9 +360,9 @@ static ssize_t iio_trigger_write_current(struct device *dev,
indio_dev->trig = trig;
if (oldtrig && indio_dev->trig != oldtrig)
iio_put_trigger(oldtrig);
iio_trigger_put(oldtrig);
if (indio_dev->trig)
iio_get_trigger(indio_dev->trig);
iio_trigger_get(indio_dev->trig);
return len;
}
......@@ -426,7 +426,7 @@ static void iio_trig_subirqunmask(struct irq_data *d)
trig->subirqs[d->irq - trig->subirq_base].enabled = true;
}
struct iio_trigger *iio_allocate_trigger(const char *fmt, ...)
struct iio_trigger *iio_trigger_alloc(const char *fmt, ...)
{
va_list vargs;
struct iio_trigger *trig;
......@@ -472,14 +472,14 @@ struct iio_trigger *iio_allocate_trigger(const char *fmt, ...)
}
return trig;
}
EXPORT_SYMBOL(iio_allocate_trigger);
EXPORT_SYMBOL(iio_trigger_alloc);
void iio_free_trigger(struct iio_trigger *trig)
void iio_trigger_free(struct iio_trigger *trig)
{
if (trig)
put_device(&trig->dev);
}
EXPORT_SYMBOL(iio_free_trigger);
EXPORT_SYMBOL(iio_trigger_free);
void iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
{
......@@ -491,7 +491,7 @@ void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
{
/* Clean up and associated but not attached triggers references */
if (indio_dev->trig)
iio_put_trigger(indio_dev->trig);
iio_trigger_put(indio_dev->trig);
}
int iio_triggered_buffer_postenable(struct iio_dev *indio_dev)
......
......@@ -11,11 +11,11 @@
#include <linux/slab.h>
#include <linux/mutex.h>
#include "iio.h"
#include <linux/iio/iio.h>
#include "iio_core.h"
#include "machine.h"
#include "driver.h"
#include "consumer.h"
#include <linux/iio/machine.h>
#include <linux/iio/driver.h>
#include <linux/iio/consumer.h>
struct iio_map_internal {
struct iio_dev *indio_dev;
......
......@@ -5,8 +5,7 @@
#include <linux/workqueue.h>
#include <linux/kfifo.h>
#include <linux/mutex.h>
#include "kfifo_buf.h"
#include <linux/iio/kfifo_buf.h>
struct iio_kfifo {
struct iio_buffer buffer;
......
......@@ -506,4 +506,5 @@ source "drivers/misc/ti-st/Kconfig"
source "drivers/misc/lis3lv02d/Kconfig"
source "drivers/misc/carma/Kconfig"
source "drivers/misc/altera-stapl/Kconfig"
source "drivers/misc/mei/Kconfig"
endmenu
......@@ -49,3 +49,4 @@ obj-y += carma/
obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o
obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/
obj-$(CONFIG_MAX8997_MUIC) += max8997-muic.o
obj-$(CONFIG_INTEL_MEI) += mei/
......@@ -200,7 +200,7 @@ int mei_hw_init(struct mei_device *dev)
if (!(dev->me_hw_state & ME_RDY_HRA))
dev_dbg(&dev->pdev->dev, "ME turn off ME_RDY.\n");
printk(KERN_ERR "mei: link layer initialization failed.\n");
dev_err(&dev->pdev->dev, "link layer initialization failed.\n");
ret = -ENODEV;
goto out;
}
......
......@@ -51,8 +51,7 @@ int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
int mei_wd_send(struct mei_device *dev);
int mei_wd_stop(struct mei_device *dev, bool preserve);
bool mei_wd_host_init(struct mei_device *dev);
void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout);
int mei_wd_host_init(struct mei_device *dev);
/*
* mei_watchdog_register - Registering watchdog interface
* once we got connection to the WD Client
......
......@@ -14,6 +14,8 @@
*
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
......@@ -39,16 +41,7 @@
#include "mei.h"
#include "interface.h"
#define MEI_READ_TIMEOUT 45
#define MEI_DRIVER_NAME "mei"
#define MEI_DEV_NAME "mei"
/*
* mei driver strings
*/
static char mei_driver_name[] = MEI_DRIVER_NAME;
static const char mei_driver_string[] = "Intel(R) Management Engine Interface";
static const char mei_driver_name[] = "mei";
/* The device pointer */
/* Currently this driver works as long as there is only a single AMT device. */
......@@ -931,7 +924,7 @@ static const struct file_operations mei_fops = {
* Misc Device Struct
*/
static struct miscdevice mei_misc_device = {
.name = MEI_DRIVER_NAME,
.name = "mei",
.fops = &mei_fops,
.minor = MISC_DYNAMIC_MINOR,
};
......@@ -1020,7 +1013,7 @@ static int __devinit mei_probe(struct pci_dev *pdev,
mutex_unlock(&mei_mutex);
pr_debug("mei: Driver initialization successful.\n");
pr_debug("initialization successful.\n");
return 0;
......@@ -1204,7 +1197,7 @@ static int __init mei_init_module(void)
{
int ret;
pr_debug("mei: %s\n", mei_driver_string);
pr_debug("loading.\n");
/* init pci module */
ret = pci_register_driver(&mei_driver);
if (ret < 0)
......@@ -1226,7 +1219,7 @@ static void __exit mei_exit_module(void)
misc_deregister(&mei_misc_device);
pci_unregister_driver(&mei_driver);
pr_debug("mei: Driver unloaded successfully.\n");
pr_debug("unloaded successfully.\n");
}
module_exit(mei_exit_module);
......
......@@ -45,23 +45,22 @@ const uuid_le mei_wd_guid = UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, 0x89,
0x9D, 0xA9, 0x15, 0x14, 0xCB,
0x32, 0xAB);
void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)
static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)
{
dev_dbg(&dev->pdev->dev, "timeout=%d.\n", timeout);
dev_dbg(&dev->pdev->dev, "wd: set timeout=%d.\n", timeout);
memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_PARAMS_SIZE);
memcpy(dev->wd_data + MEI_WD_PARAMS_SIZE,
&timeout, sizeof(u16));
memcpy(dev->wd_data + MEI_WD_PARAMS_SIZE, &timeout, sizeof(u16));
}
/**
* host_init_wd - mei initialization wd.
*
* @dev: the device structure
* returns -ENENT if wd client cannot be found
* -EIO if write has failed
*/
bool mei_wd_host_init(struct mei_device *dev)
int mei_wd_host_init(struct mei_device *dev)
{
bool ret = false;
mei_cl_init(&dev->wd_cl, dev);
/* look for WD client and connect to it */
......@@ -72,25 +71,21 @@ bool mei_wd_host_init(struct mei_device *dev)
mei_find_me_client_update_filext(dev, &dev->wd_cl,
&mei_wd_guid, MEI_WD_HOST_CLIENT_ID);
dev_dbg(&dev->pdev->dev, "check wd_cl\n");
if (MEI_FILE_CONNECTING == dev->wd_cl.state) {
if (mei_connect(dev, &dev->wd_cl)) {
dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n");
dev->wd_cl.state = MEI_FILE_DISCONNECTED;
dev->wd_cl.host_client_id = 0;
ret = false;
goto end;
} else {
dev->wd_cl.timer_count = CONNECT_TIMEOUT;
}
} else {
dev_dbg(&dev->pdev->dev, "Failed to find WD client\n");
ret = false;
goto end;
dev_dbg(&dev->pdev->dev, "wd: check client\n");
if (MEI_FILE_CONNECTING != dev->wd_cl.state) {
dev_info(&dev->pdev->dev, "wd: failed to find the client\n");
return -ENOENT;
}
end:
return ret;
if (mei_connect(dev, &dev->wd_cl)) {
dev_err(&dev->pdev->dev, "wd: failed to connect to the client\n");
dev->wd_cl.state = MEI_FILE_DISCONNECTED;
dev->wd_cl.host_client_id = 0;
return -EIO;
}
dev->wd_cl.timer_count = CONNECT_TIMEOUT;
return 0;
}
/**
......@@ -159,7 +154,7 @@ int mei_wd_stop(struct mei_device *dev, bool preserve)
if (ret)
goto out;
} else {
dev_dbg(&dev->pdev->dev, "send stop WD failed\n");
dev_err(&dev->pdev->dev, "wd: send stop failed\n");
}
dev->wd_pending = false;
......@@ -173,13 +168,13 @@ int mei_wd_stop(struct mei_device *dev, bool preserve)
dev->wd_stopped, 10 * HZ);
mutex_lock(&dev->device_lock);
if (dev->wd_stopped) {
dev_dbg(&dev->pdev->dev, "stop wd complete ret=%d.\n", ret);
dev_dbg(&dev->pdev->dev, "wd: stop completed ret=%d.\n", ret);
ret = 0;
} else {
if (!ret)
ret = -ETIMEDOUT;
dev_warn(&dev->pdev->dev,
"stop wd failed to complete ret=%d.\n", ret);
"wd: stop failed to complete ret=%d.\n", ret);
}
if (preserve)
......@@ -208,13 +203,15 @@ static int mei_wd_ops_start(struct watchdog_device *wd_dev)
mutex_lock(&dev->device_lock);
if (dev->mei_state != MEI_ENABLED) {
dev_dbg(&dev->pdev->dev, "mei_state != MEI_ENABLED mei_state= %d\n",
dev->mei_state);
dev_dbg(&dev->pdev->dev,
"wd: mei_state != MEI_ENABLED mei_state = %d\n",
dev->mei_state);
goto end_unlock;
}
if (dev->wd_cl.state != MEI_FILE_CONNECTED) {
dev_dbg(&dev->pdev->dev, "MEI Driver is not connected to Watchdog Client\n");
dev_dbg(&dev->pdev->dev,
"MEI Driver is not connected to Watchdog Client\n");
goto end_unlock;
}
......@@ -267,7 +264,7 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev)
mutex_lock(&dev->device_lock);
if (dev->wd_cl.state != MEI_FILE_CONNECTED) {
dev_dbg(&dev->pdev->dev, "wd is not connected.\n");
dev_err(&dev->pdev->dev, "wd: not connected.\n");
ret = -ENODEV;
goto end;
}
......@@ -277,16 +274,17 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev)
mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
dev->mei_host_buffer_is_empty = false;
dev_dbg(&dev->pdev->dev, "sending watchdog ping\n");
dev_dbg(&dev->pdev->dev, "wd: sending ping\n");
if (mei_wd_send(dev)) {
dev_dbg(&dev->pdev->dev, "wd send failed.\n");
dev_err(&dev->pdev->dev, "wd: send failed.\n");
ret = -EIO;
goto end;
}
if (mei_flow_ctrl_reduce(dev, &dev->wd_cl)) {
dev_dbg(&dev->pdev->dev, "mei_flow_ctrl_reduce() failed.\n");
dev_err(&dev->pdev->dev,
"wd: mei_flow_ctrl_reduce() failed.\n");
ret = -EIO;
goto end;
}
......@@ -346,7 +344,7 @@ static const struct watchdog_info wd_info = {
.options = WDIOF_KEEPALIVEPING,
};
struct watchdog_device amt_wd_dev = {
static struct watchdog_device amt_wd_dev = {
.info = &wd_info,
.ops = &wd_ops,
.timeout = AMT_WD_DEFAULT_TIMEOUT,
......@@ -362,10 +360,12 @@ void mei_watchdog_register(struct mei_device *dev)
dev->wd_due_counter = !!dev->wd_timeout;
if (watchdog_register_device(&amt_wd_dev)) {
dev_err(&dev->pdev->dev, "unable to register watchdog device.\n");
dev_err(&dev->pdev->dev,
"wd: unable to register watchdog device.\n");
dev->wd_interface_reg = false;
} else {
dev_dbg(&dev->pdev->dev, "successfully register watchdog interface.\n");
dev_dbg(&dev->pdev->dev,
"wd: successfully register watchdog interface.\n");
dev->wd_interface_reg = true;
}
}
......
......@@ -203,37 +203,6 @@ config WANXL_BUILD_FIRMWARE
You should never need this option, say N.
config PC300
tristate "Cyclades-PC300 support (RS-232/V.35, X.21, T1/E1 boards)"
depends on HDLC && PCI && BROKEN
---help---
This driver is broken because of struct tty_driver change.
Driver for the Cyclades-PC300 synchronous communication boards.
These boards provide synchronous serial interfaces to your
Linux box (interfaces currently available are RS-232/V.35, X.21 and
T1/E1). If you wish to support Multilink PPP, please select the
option later and read the file README.mlppp provided by PC300
package.
To compile this as a module, choose M here: the module
will be called pc300.
If unsure, say N.
config PC300_MLPPP
bool "Cyclades-PC300 MLPPP support"
depends on PC300 && PPP_MULTILINK && PPP_SYNC_TTY && HDLC_PPP
help
Multilink PPP over the PC300 synchronous communication boards.
comment "Cyclades-PC300 MLPPP support is disabled."
depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP)
comment "Refer to the file README.mlppp, provided by PC300 package."
depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP)
config PC300TOO
tristate "Cyclades PC300 RSV/X21 alternative support"
depends on HDLC && PCI
......
......@@ -17,10 +17,6 @@ obj-$(CONFIG_HDLC_FR) += hdlc_fr.o
obj-$(CONFIG_HDLC_PPP) += hdlc_ppp.o
obj-$(CONFIG_HDLC_X25) += hdlc_x25.o
pc300-y := pc300_drv.o
pc300-$(CONFIG_PC300_MLPPP) += pc300_tty.o
pc300-objs := $(pc300-y)
obj-$(CONFIG_HOSTESS_SV11) += z85230.o hostess_sv11.o
obj-$(CONFIG_SEALEVEL_4021) += z85230.o sealevel.o
obj-$(CONFIG_COSA) += cosa.o
......@@ -35,7 +31,6 @@ obj-$(CONFIG_SDLA) += sdla.o
obj-$(CONFIG_CYCLADES_SYNC) += cycx_drv.o cyclomx.o
obj-$(CONFIG_LAPBETHER) += lapbether.o
obj-$(CONFIG_SBNI) += sbni.o
obj-$(CONFIG_PC300) += pc300.o
obj-$(CONFIG_N2) += n2.o
obj-$(CONFIG_C101) += c101.o
obj-$(CONFIG_WANXL) += wanxl.o
......
......@@ -24,8 +24,6 @@ menuconfig STAGING
if STAGING
source "drivers/staging/serial/Kconfig"
source "drivers/staging/et131x/Kconfig"
source "drivers/staging/slicoss/Kconfig"
......@@ -74,8 +72,6 @@ source "drivers/staging/vt6655/Kconfig"
source "drivers/staging/vt6656/Kconfig"
source "drivers/staging/vme/Kconfig"
source "drivers/staging/sep/Kconfig"
source "drivers/staging/iio/Kconfig"
......@@ -116,12 +112,12 @@ source "drivers/staging/cptm1217/Kconfig"
source "drivers/staging/ste_rmi4/Kconfig"
source "drivers/staging/mei/Kconfig"
source "drivers/staging/nvec/Kconfig"
source "drivers/staging/media/Kconfig"
source "drivers/staging/net/Kconfig"
source "drivers/staging/omapdrm/Kconfig"
source "drivers/staging/android/Kconfig"
......
......@@ -3,8 +3,8 @@
# fix for build system bug...
obj-$(CONFIG_STAGING) += staging.o
obj-y += serial/
obj-y += media/
obj-y += net/
obj-$(CONFIG_ET131X) += et131x/
obj-$(CONFIG_SLICOSS) += slicoss/
obj-$(CONFIG_USBIP_CORE) += usbip/
......@@ -50,7 +50,6 @@ obj-$(CONFIG_FT1000) += ft1000/
obj-$(CONFIG_SPEAKUP) += speakup/
obj-$(CONFIG_TOUCHSCREEN_CLEARPAD_TM1217) += cptm1217/
obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4) += ste_rmi4/
obj-$(CONFIG_INTEL_MEI) += mei/
obj-$(CONFIG_MFD_NVEC) += nvec/
obj-$(CONFIG_DRM_OMAP) += omapdrm/
obj-$(CONFIG_ANDROID) += android/
......
......@@ -55,31 +55,14 @@ config ANDROID_LOW_MEMORY_KILLER
source "drivers/staging/android/switch/Kconfig"
config ANDROID_INTF_ALARM
config ANDROID_INTF_ALARM_DEV
bool "Android alarm driver"
depends on RTC_CLASS
default n
help
Provides non-wakeup and rtc backed wakeup alarms based on rtc or
elapsed realtime, and a non-wakeup alarm on the monotonic clock.
Also provides an interface to set the wall time which must be used
for elapsed realtime to work.
config ANDROID_INTF_ALARM_DEV
bool "Android alarm device"
depends on ANDROID_INTF_ALARM
default y
help
Exports the alarm interface to user-space.
config ANDROID_ALARM_OLDDRV_COMPAT
bool "Android Alarm compatability with old drivers"
depends on ANDROID_INTF_ALARM
default n
help
Provides preprocessor alias to aid compatability with
older out-of-tree drivers that use the Android Alarm
in-kernel API. This will be removed eventually.
Also exports the alarm interface to user-space.
endif # if ANDROID
......
......@@ -7,5 +7,4 @@ obj-$(CONFIG_ANDROID_TIMED_OUTPUT) += timed_output.o
obj-$(CONFIG_ANDROID_TIMED_GPIO) += timed_gpio.o
obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o
obj-$(CONFIG_ANDROID_SWITCH) += switch/
obj-$(CONFIG_ANDROID_INTF_ALARM) += alarm.o
obj-$(CONFIG_ANDROID_INTF_ALARM_DEV) += alarm-dev.o
......@@ -22,19 +22,9 @@
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/uaccess.h>
#include <linux/alarmtimer.h>
#include "android_alarm.h"
/* XXX - Hack out wakelocks, while they are out of tree */
struct wake_lock {
int i;
};
#define wake_lock(x)
#define wake_lock_timeout(x, y)
#define wake_unlock(x)
#define WAKE_LOCK_SUSPEND 0
#define wake_lock_init(x, y, z) ((x)->i = 1)
#define wake_lock_destroy(x)
#define ANDROID_ALARM_PRINT_INFO (1U << 0)
#define ANDROID_ALARM_PRINT_IO (1U << 1)
#define ANDROID_ALARM_PRINT_INT (1U << 2)
......@@ -54,19 +44,65 @@ module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP);
ANDROID_ALARM_RTC_WAKEUP_MASK | \
ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK)
/* support old usespace code */
/* support old userspace code */
#define ANDROID_ALARM_SET_OLD _IOW('a', 2, time_t) /* set alarm */
#define ANDROID_ALARM_SET_AND_WAIT_OLD _IOW('a', 3, time_t)
static int alarm_opened;
static DEFINE_SPINLOCK(alarm_slock);
static struct wake_lock alarm_wake_lock;
static struct wakeup_source alarm_wake_lock;
static DECLARE_WAIT_QUEUE_HEAD(alarm_wait_queue);
static uint32_t alarm_pending;
static uint32_t alarm_enabled;
static uint32_t wait_pending;
static struct android_alarm alarms[ANDROID_ALARM_TYPE_COUNT];
struct devalarm {
union {
struct hrtimer hrt;
struct alarm alrm;
} u;
enum android_alarm_type type;
};
static struct devalarm alarms[ANDROID_ALARM_TYPE_COUNT];
static int is_wakeup(enum android_alarm_type type)
{
if (type == ANDROID_ALARM_RTC_WAKEUP ||
type == ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP)
return 1;
return 0;
}
static void devalarm_start(struct devalarm *alrm, ktime_t exp)
{
if (is_wakeup(alrm->type))
alarm_start(&alrm->u.alrm, exp);
else
hrtimer_start(&alrm->u.hrt, exp, HRTIMER_MODE_ABS);
}
static int devalarm_try_to_cancel(struct devalarm *alrm)
{
int ret;
if (is_wakeup(alrm->type))
ret = alarm_try_to_cancel(&alrm->u.alrm);
else
ret = hrtimer_try_to_cancel(&alrm->u.hrt);
return ret;
}
static void devalarm_cancel(struct devalarm *alrm)
{
if (is_wakeup(alrm->type))
alarm_cancel(&alrm->u.alrm);
else
hrtimer_cancel(&alrm->u.hrt);
}
static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
......@@ -75,6 +111,8 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct timespec new_alarm_time;
struct timespec new_rtc_time;
struct timespec tmp_time;
struct rtc_time new_rtc_tm;
struct rtc_device *rtc_dev;
enum android_alarm_type alarm_type = ANDROID_ALARM_IOCTL_TO_TYPE(cmd);
uint32_t alarm_type_mask = 1U << alarm_type;
......@@ -101,11 +139,11 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case ANDROID_ALARM_CLEAR(0):
spin_lock_irqsave(&alarm_slock, flags);
pr_alarm(IO, "alarm %d clear\n", alarm_type);
android_alarm_try_to_cancel(&alarms[alarm_type]);
devalarm_try_to_cancel(&alarms[alarm_type]);
if (alarm_pending) {
alarm_pending &= ~alarm_type_mask;
if (!alarm_pending && !wait_pending)
wake_unlock(&alarm_wake_lock);
__pm_relax(&alarm_wake_lock);
}
alarm_enabled &= ~alarm_type_mask;
spin_unlock_irqrestore(&alarm_slock, flags);
......@@ -132,8 +170,7 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
pr_alarm(IO, "alarm %d set %ld.%09ld\n", alarm_type,
new_alarm_time.tv_sec, new_alarm_time.tv_nsec);
alarm_enabled |= alarm_type_mask;
android_alarm_start_range(&alarms[alarm_type],
timespec_to_ktime(new_alarm_time),
devalarm_start(&alarms[alarm_type],
timespec_to_ktime(new_alarm_time));
spin_unlock_irqrestore(&alarm_slock, flags);
if (ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_SET_AND_WAIT(0)
......@@ -144,7 +181,7 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
spin_lock_irqsave(&alarm_slock, flags);
pr_alarm(IO, "alarm wait\n");
if (!alarm_pending && wait_pending) {
wake_unlock(&alarm_wake_lock);
__pm_relax(&alarm_wake_lock);
wait_pending = 0;
}
spin_unlock_irqrestore(&alarm_slock, flags);
......@@ -163,7 +200,13 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
rv = -EFAULT;
goto err1;
}
rv = android_alarm_set_rtc(new_rtc_time);
rtc_time_to_tm(new_rtc_time.tv_sec, &new_rtc_tm);
rtc_dev = alarmtimer_get_rtcdev();
rv = do_settimeofday(&new_rtc_time);
if (rv < 0)
goto err1;
if (rtc_dev)
rv = rtc_set_time(rtc_dev, &new_rtc_tm);
spin_lock_irqsave(&alarm_slock, flags);
alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK;
wake_up(&alarm_wait_queue);
......@@ -179,8 +222,7 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
break;
case ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP:
case ANDROID_ALARM_ELAPSED_REALTIME:
tmp_time =
ktime_to_timespec(alarm_get_elapsed_realtime());
get_monotonic_boottime(&tmp_time);
break;
case ANDROID_ALARM_TYPE_COUNT:
case ANDROID_ALARM_SYSTEMTIME:
......@@ -224,14 +266,14 @@ static int alarm_release(struct inode *inode, struct file *file)
alarm_enabled &= ~alarm_type_mask;
}
spin_unlock_irqrestore(&alarm_slock, flags);
android_alarm_cancel(&alarms[i]);
devalarm_cancel(&alarms[i]);
spin_lock_irqsave(&alarm_slock, flags);
}
if (alarm_pending | wait_pending) {
if (alarm_pending)
pr_alarm(INFO, "alarm_release: clear "
"pending alarms %x\n", alarm_pending);
wake_unlock(&alarm_wake_lock);
__pm_relax(&alarm_wake_lock);
wait_pending = 0;
alarm_pending = 0;
}
......@@ -241,15 +283,15 @@ static int alarm_release(struct inode *inode, struct file *file)
return 0;
}
static void alarm_triggered(struct android_alarm *alarm)
static void devalarm_triggered(struct devalarm *alarm)
{
unsigned long flags;
uint32_t alarm_type_mask = 1U << alarm->type;
pr_alarm(INT, "alarm_triggered type %d\n", alarm->type);
pr_alarm(INT, "devalarm_triggered type %d\n", alarm->type);
spin_lock_irqsave(&alarm_slock, flags);
if (alarm_enabled & alarm_type_mask) {
wake_lock_timeout(&alarm_wake_lock, 5 * HZ);
__pm_wakeup_event(&alarm_wake_lock, 5000); /* 5secs */
alarm_enabled &= ~alarm_type_mask;
alarm_pending |= alarm_type_mask;
wake_up(&alarm_wait_queue);
......@@ -257,6 +299,25 @@ static void alarm_triggered(struct android_alarm *alarm)
spin_unlock_irqrestore(&alarm_slock, flags);
}
static enum hrtimer_restart devalarm_hrthandler(struct hrtimer *hrt)
{
struct devalarm *devalrm = container_of(hrt, struct devalarm, u.hrt);
devalarm_triggered(devalrm);
return HRTIMER_NORESTART;
}
static enum alarmtimer_restart devalarm_alarmhandler(struct alarm *alrm,
ktime_t now)
{
struct devalarm *devalrm = container_of(alrm, struct devalarm, u.alrm);
devalarm_triggered(devalrm);
return ALARMTIMER_NORESTART;
}
static const struct file_operations alarm_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = alarm_ioctl,
......@@ -279,17 +340,31 @@ static int __init alarm_dev_init(void)
if (err)
return err;
for (i = 0; i < ANDROID_ALARM_TYPE_COUNT; i++)
android_alarm_init(&alarms[i], i, alarm_triggered);
wake_lock_init(&alarm_wake_lock, WAKE_LOCK_SUSPEND, "alarm");
alarm_init(&alarms[ANDROID_ALARM_RTC_WAKEUP].u.alrm,
ALARM_REALTIME, devalarm_alarmhandler);
hrtimer_init(&alarms[ANDROID_ALARM_RTC].u.hrt,
CLOCK_REALTIME, HRTIMER_MODE_ABS);
alarm_init(&alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP].u.alrm,
ALARM_BOOTTIME, devalarm_alarmhandler);
hrtimer_init(&alarms[ANDROID_ALARM_ELAPSED_REALTIME].u.hrt,
CLOCK_BOOTTIME, HRTIMER_MODE_ABS);
hrtimer_init(&alarms[ANDROID_ALARM_SYSTEMTIME].u.hrt,
CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
for (i = 0; i < ANDROID_ALARM_TYPE_COUNT; i++) {
alarms[i].type = i;
if (!is_wakeup(i))
alarms[i].u.hrt.function = devalarm_hrthandler;
}
wakeup_source_init(&alarm_wake_lock, "alarm");
return 0;
}
static void __exit alarm_dev_exit(void)
{
misc_deregister(&alarm_device);
wake_lock_destroy(&alarm_wake_lock);
wakeup_source_trash(&alarm_wake_lock);
}
module_init(alarm_dev_init);
......
/* drivers/rtc/alarm.c
*
* Copyright (C) 2007-2009 Google, Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/time.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/miscdevice.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include "android_alarm.h"
/* XXX - Hack out wakelocks, while they are out of tree */
struct wake_lock {
int i;
};
#define wake_lock(x)
#define wake_lock_timeout(x, y)
#define wake_unlock(x)
#define WAKE_LOCK_SUSPEND 0
#define wake_lock_init(x, y, z) ((x)->i = 1)
#define wake_lock_destroy(x)
#define ANDROID_ALARM_PRINT_ERROR (1U << 0)
#define ANDROID_ALARM_PRINT_INIT_STATUS (1U << 1)
#define ANDROID_ALARM_PRINT_TSET (1U << 2)
#define ANDROID_ALARM_PRINT_CALL (1U << 3)
#define ANDROID_ALARM_PRINT_SUSPEND (1U << 4)
#define ANDROID_ALARM_PRINT_INT (1U << 5)
#define ANDROID_ALARM_PRINT_FLOW (1U << 6)
static int debug_mask = ANDROID_ALARM_PRINT_ERROR | \
ANDROID_ALARM_PRINT_INIT_STATUS;
module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP);
#define pr_alarm(debug_level_mask, args...) \
do { \
if (debug_mask & ANDROID_ALARM_PRINT_##debug_level_mask) { \
pr_info(args); \
} \
} while (0)
#define ANDROID_ALARM_WAKEUP_MASK ( \
ANDROID_ALARM_RTC_WAKEUP_MASK | \
ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK)
/* support old usespace code */
#define ANDROID_ALARM_SET_OLD _IOW('a', 2, time_t) /* set alarm */
#define ANDROID_ALARM_SET_AND_WAIT_OLD _IOW('a', 3, time_t)
struct alarm_queue {
struct rb_root alarms;
struct rb_node *first;
struct hrtimer timer;
ktime_t delta;
bool stopped;
ktime_t stopped_time;
};
static struct rtc_device *alarm_rtc_dev;
static DEFINE_SPINLOCK(alarm_slock);
static DEFINE_MUTEX(alarm_setrtc_mutex);
static struct wake_lock alarm_rtc_wake_lock;
static struct platform_device *alarm_platform_dev;
struct alarm_queue alarms[ANDROID_ALARM_TYPE_COUNT];
static bool suspended;
static void update_timer_locked(struct alarm_queue *base, bool head_removed)
{
struct android_alarm *alarm;
bool is_wakeup = base == &alarms[ANDROID_ALARM_RTC_WAKEUP] ||
base == &alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP];
if (base->stopped) {
pr_alarm(FLOW, "changed alarm while setting the wall time\n");
return;
}
if (is_wakeup && !suspended && head_removed)
wake_unlock(&alarm_rtc_wake_lock);
if (!base->first)
return;
alarm = container_of(base->first, struct android_alarm, node);
pr_alarm(FLOW, "selected alarm, type %d, func %pF at %lld\n",
alarm->type, alarm->function, ktime_to_ns(alarm->expires));
if (is_wakeup && suspended) {
pr_alarm(FLOW, "changed alarm while suspened\n");
wake_lock_timeout(&alarm_rtc_wake_lock, 1 * HZ);
return;
}
hrtimer_try_to_cancel(&base->timer);
base->timer.node.expires = ktime_add(base->delta, alarm->expires);
base->timer._softexpires = ktime_add(base->delta, alarm->softexpires);
hrtimer_start_expires(&base->timer, HRTIMER_MODE_ABS);
}
static void alarm_enqueue_locked(struct android_alarm *alarm)
{
struct alarm_queue *base = &alarms[alarm->type];
struct rb_node **link = &base->alarms.rb_node;
struct rb_node *parent = NULL;
struct android_alarm *entry;
int leftmost = 1;
bool was_first = false;
pr_alarm(FLOW, "added alarm, type %d, func %pF at %lld\n",
alarm->type, alarm->function, ktime_to_ns(alarm->expires));
if (base->first == &alarm->node) {
base->first = rb_next(&alarm->node);
was_first = true;
}
if (!RB_EMPTY_NODE(&alarm->node)) {
rb_erase(&alarm->node, &base->alarms);
RB_CLEAR_NODE(&alarm->node);
}
while (*link) {
parent = *link;
entry = rb_entry(parent, struct android_alarm, node);
/*
* We dont care about collisions. Nodes with
* the same expiry time stay together.
*/
if (alarm->expires.tv64 < entry->expires.tv64) {
link = &(*link)->rb_left;
} else {
link = &(*link)->rb_right;
leftmost = 0;
}
}
if (leftmost)
base->first = &alarm->node;
if (leftmost || was_first)
update_timer_locked(base, was_first);
rb_link_node(&alarm->node, parent, link);
rb_insert_color(&alarm->node, &base->alarms);
}
/**
* android_alarm_init - initialize an alarm
* @alarm: the alarm to be initialized
* @type: the alarm type to be used
* @function: alarm callback function
*/
void android_alarm_init(struct android_alarm *alarm,
enum android_alarm_type type, void (*function)(struct android_alarm *))
{
RB_CLEAR_NODE(&alarm->node);
alarm->type = type;
alarm->function = function;
pr_alarm(FLOW, "created alarm, type %d, func %pF\n", type, function);
}
/**
* android_alarm_start_range - (re)start an alarm
* @alarm: the alarm to be added
* @start: earliest expiry time
* @end: expiry time
*/
void android_alarm_start_range(struct android_alarm *alarm, ktime_t start,
ktime_t end)
{
unsigned long flags;
spin_lock_irqsave(&alarm_slock, flags);
alarm->softexpires = start;
alarm->expires = end;
alarm_enqueue_locked(alarm);
spin_unlock_irqrestore(&alarm_slock, flags);
}
/**
* android_alarm_try_to_cancel - try to deactivate an alarm
* @alarm: alarm to stop
*
* Returns:
* 0 when the alarm was not active
* 1 when the alarm was active
* -1 when the alarm may currently be excuting the callback function and
* cannot be stopped (it may also be inactive)
*/
int android_alarm_try_to_cancel(struct android_alarm *alarm)
{
struct alarm_queue *base = &alarms[alarm->type];
unsigned long flags;
bool first = false;
int ret = 0;
spin_lock_irqsave(&alarm_slock, flags);
if (!RB_EMPTY_NODE(&alarm->node)) {
pr_alarm(FLOW, "canceled alarm, type %d, func %pF at %lld\n",
alarm->type, alarm->function,
ktime_to_ns(alarm->expires));
ret = 1;
if (base->first == &alarm->node) {
base->first = rb_next(&alarm->node);
first = true;
}
rb_erase(&alarm->node, &base->alarms);
RB_CLEAR_NODE(&alarm->node);
if (first)
update_timer_locked(base, true);
} else
pr_alarm(FLOW, "tried to cancel alarm, type %d, func %pF\n",
alarm->type, alarm->function);
spin_unlock_irqrestore(&alarm_slock, flags);
if (!ret && hrtimer_callback_running(&base->timer))
ret = -1;
return ret;
}
/**
* android_alarm_cancel - cancel an alarm and wait for the handler to finish.
* @alarm: the alarm to be cancelled
*
* Returns:
* 0 when the alarm was not active
* 1 when the alarm was active
*/
int android_alarm_cancel(struct android_alarm *alarm)
{
for (;;) {
int ret = android_alarm_try_to_cancel(alarm);
if (ret >= 0)
return ret;
cpu_relax();
}
}
/**
* alarm_set_rtc - set the kernel and rtc walltime
* @new_time: timespec value containing the new time
*/
int android_alarm_set_rtc(struct timespec new_time)
{
int i;
int ret;
unsigned long flags;
struct rtc_time rtc_new_rtc_time;
struct timespec tmp_time;
rtc_time_to_tm(new_time.tv_sec, &rtc_new_rtc_time);
pr_alarm(TSET, "set rtc %ld %ld - rtc %02d:%02d:%02d %02d/%02d/%04d\n",
new_time.tv_sec, new_time.tv_nsec,
rtc_new_rtc_time.tm_hour, rtc_new_rtc_time.tm_min,
rtc_new_rtc_time.tm_sec, rtc_new_rtc_time.tm_mon + 1,
rtc_new_rtc_time.tm_mday,
rtc_new_rtc_time.tm_year + 1900);
mutex_lock(&alarm_setrtc_mutex);
spin_lock_irqsave(&alarm_slock, flags);
wake_lock(&alarm_rtc_wake_lock);
getnstimeofday(&tmp_time);
for (i = 0; i < ANDROID_ALARM_SYSTEMTIME; i++) {
hrtimer_try_to_cancel(&alarms[i].timer);
alarms[i].stopped = true;
alarms[i].stopped_time = timespec_to_ktime(tmp_time);
}
alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP].delta =
alarms[ANDROID_ALARM_ELAPSED_REALTIME].delta =
ktime_sub(alarms[ANDROID_ALARM_ELAPSED_REALTIME].delta,
timespec_to_ktime(timespec_sub(tmp_time, new_time)));
spin_unlock_irqrestore(&alarm_slock, flags);
ret = do_settimeofday(&new_time);
spin_lock_irqsave(&alarm_slock, flags);
for (i = 0; i < ANDROID_ALARM_SYSTEMTIME; i++) {
alarms[i].stopped = false;
update_timer_locked(&alarms[i], false);
}
spin_unlock_irqrestore(&alarm_slock, flags);
if (ret < 0) {
pr_alarm(ERROR, "alarm_set_rtc: Failed to set time\n");
goto err;
}
if (!alarm_rtc_dev) {
pr_alarm(ERROR,
"alarm_set_rtc: no RTC, time will be lost on reboot\n");
goto err;
}
ret = rtc_set_time(alarm_rtc_dev, &rtc_new_rtc_time);
if (ret < 0)
pr_alarm(ERROR, "alarm_set_rtc: "
"Failed to set RTC, time will be lost on reboot\n");
err:
wake_unlock(&alarm_rtc_wake_lock);
mutex_unlock(&alarm_setrtc_mutex);
return ret;
}
/**
* alarm_get_elapsed_realtime - get the elapsed real time in ktime_t format
*
* returns the time in ktime_t format
*/
ktime_t alarm_get_elapsed_realtime(void)
{
ktime_t now;
unsigned long flags;
struct alarm_queue *base = &alarms[ANDROID_ALARM_ELAPSED_REALTIME];
spin_lock_irqsave(&alarm_slock, flags);
now = base->stopped ? base->stopped_time : ktime_get_real();
now = ktime_sub(now, base->delta);
spin_unlock_irqrestore(&alarm_slock, flags);
return now;
}
static enum hrtimer_restart alarm_timer_triggered(struct hrtimer *timer)
{
struct alarm_queue *base;
struct android_alarm *alarm;
unsigned long flags;
ktime_t now;
spin_lock_irqsave(&alarm_slock, flags);
base = container_of(timer, struct alarm_queue, timer);
now = base->stopped ? base->stopped_time : hrtimer_cb_get_time(timer);
now = ktime_sub(now, base->delta);
pr_alarm(INT, "alarm_timer_triggered type %ld at %lld\n",
base - alarms, ktime_to_ns(now));
while (base->first) {
alarm = container_of(base->first, struct android_alarm, node);
if (alarm->softexpires.tv64 > now.tv64) {
pr_alarm(FLOW, "don't call alarm, %pF, %lld (s %lld)\n",
alarm->function, ktime_to_ns(alarm->expires),
ktime_to_ns(alarm->softexpires));
break;
}
base->first = rb_next(&alarm->node);
rb_erase(&alarm->node, &base->alarms);
RB_CLEAR_NODE(&alarm->node);
pr_alarm(CALL, "call alarm, type %d, func %pF, %lld (s %lld)\n",
alarm->type, alarm->function,
ktime_to_ns(alarm->expires),
ktime_to_ns(alarm->softexpires));
spin_unlock_irqrestore(&alarm_slock, flags);
alarm->function(alarm);
spin_lock_irqsave(&alarm_slock, flags);
}
if (!base->first)
pr_alarm(FLOW, "no more alarms of type %ld\n", base - alarms);
update_timer_locked(base, true);
spin_unlock_irqrestore(&alarm_slock, flags);
return HRTIMER_NORESTART;
}
static void alarm_triggered_func(void *p)
{
struct rtc_device *rtc = alarm_rtc_dev;
if (!(rtc->irq_data & RTC_AF))
return;
pr_alarm(INT, "rtc alarm triggered\n");
wake_lock_timeout(&alarm_rtc_wake_lock, 1 * HZ);
}
static int alarm_suspend(struct platform_device *pdev, pm_message_t state)
{
int err = 0;
unsigned long flags;
struct rtc_wkalrm rtc_alarm;
struct rtc_time rtc_current_rtc_time;
unsigned long rtc_current_time;
unsigned long rtc_alarm_time;
struct timespec rtc_delta;
struct timespec wall_time;
struct alarm_queue *wakeup_queue = NULL;
struct alarm_queue *tmp_queue = NULL;
pr_alarm(SUSPEND, "alarm_suspend(%p, %d)\n", pdev, state.event);
spin_lock_irqsave(&alarm_slock, flags);
suspended = true;
spin_unlock_irqrestore(&alarm_slock, flags);
hrtimer_cancel(&alarms[ANDROID_ALARM_RTC_WAKEUP].timer);
hrtimer_cancel(&alarms[
ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP].timer);
tmp_queue = &alarms[ANDROID_ALARM_RTC_WAKEUP];
if (tmp_queue->first)
wakeup_queue = tmp_queue;
tmp_queue = &alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP];
if (tmp_queue->first && (!wakeup_queue ||
hrtimer_get_expires(&tmp_queue->timer).tv64 <
hrtimer_get_expires(&wakeup_queue->timer).tv64))
wakeup_queue = tmp_queue;
if (wakeup_queue) {
rtc_read_time(alarm_rtc_dev, &rtc_current_rtc_time);
getnstimeofday(&wall_time);
rtc_tm_to_time(&rtc_current_rtc_time, &rtc_current_time);
set_normalized_timespec(&rtc_delta,
wall_time.tv_sec - rtc_current_time,
wall_time.tv_nsec);
rtc_alarm_time = timespec_sub(ktime_to_timespec(
hrtimer_get_expires(&wakeup_queue->timer)),
rtc_delta).tv_sec;
rtc_time_to_tm(rtc_alarm_time, &rtc_alarm.time);
rtc_alarm.enabled = 1;
rtc_set_alarm(alarm_rtc_dev, &rtc_alarm);
rtc_read_time(alarm_rtc_dev, &rtc_current_rtc_time);
rtc_tm_to_time(&rtc_current_rtc_time, &rtc_current_time);
pr_alarm(SUSPEND,
"rtc alarm set at %ld, now %ld, rtc delta %ld.%09ld\n",
rtc_alarm_time, rtc_current_time,
rtc_delta.tv_sec, rtc_delta.tv_nsec);
if (rtc_current_time + 1 >= rtc_alarm_time) {
pr_alarm(SUSPEND, "alarm about to go off\n");
memset(&rtc_alarm, 0, sizeof(rtc_alarm));
rtc_alarm.enabled = 0;
rtc_set_alarm(alarm_rtc_dev, &rtc_alarm);
spin_lock_irqsave(&alarm_slock, flags);
suspended = false;
wake_lock_timeout(&alarm_rtc_wake_lock, 2 * HZ);
update_timer_locked(&alarms[ANDROID_ALARM_RTC_WAKEUP],
false);
update_timer_locked(&alarms[
ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP], false);
err = -EBUSY;
spin_unlock_irqrestore(&alarm_slock, flags);
}
}
return err;
}
static int alarm_resume(struct platform_device *pdev)
{
struct rtc_wkalrm alarm;
unsigned long flags;
pr_alarm(SUSPEND, "alarm_resume(%p)\n", pdev);
memset(&alarm, 0, sizeof(alarm));
alarm.enabled = 0;
rtc_set_alarm(alarm_rtc_dev, &alarm);
spin_lock_irqsave(&alarm_slock, flags);
suspended = false;
update_timer_locked(&alarms[ANDROID_ALARM_RTC_WAKEUP], false);
update_timer_locked(&alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP],
false);
spin_unlock_irqrestore(&alarm_slock, flags);
return 0;
}
static struct rtc_task alarm_rtc_task = {
.func = alarm_triggered_func
};
static int rtc_alarm_add_device(struct device *dev,
struct class_interface *class_intf)
{
int err;
struct rtc_device *rtc = to_rtc_device(dev);
mutex_lock(&alarm_setrtc_mutex);
if (alarm_rtc_dev) {
err = -EBUSY;
goto err1;
}
alarm_platform_dev =
platform_device_register_simple("alarm", -1, NULL, 0);
if (IS_ERR(alarm_platform_dev)) {
err = PTR_ERR(alarm_platform_dev);
goto err2;
}
err = rtc_irq_register(rtc, &alarm_rtc_task);
if (err)
goto err3;
alarm_rtc_dev = rtc;
pr_alarm(INIT_STATUS, "using rtc device, %s, for alarms", rtc->name);
mutex_unlock(&alarm_setrtc_mutex);
return 0;
err3:
platform_device_unregister(alarm_platform_dev);
err2:
err1:
mutex_unlock(&alarm_setrtc_mutex);
return err;
}
static void rtc_alarm_remove_device(struct device *dev,
struct class_interface *class_intf)
{
if (dev == &alarm_rtc_dev->dev) {
pr_alarm(INIT_STATUS, "lost rtc device for alarms");
rtc_irq_unregister(alarm_rtc_dev, &alarm_rtc_task);
platform_device_unregister(alarm_platform_dev);
alarm_rtc_dev = NULL;
}
}
static struct class_interface rtc_alarm_interface = {
.add_dev = &rtc_alarm_add_device,
.remove_dev = &rtc_alarm_remove_device,
};
static struct platform_driver alarm_driver = {
.suspend = alarm_suspend,
.resume = alarm_resume,
.driver = {
.name = "alarm"
}
};
static int __init alarm_late_init(void)
{
unsigned long flags;
struct timespec tmp_time, system_time;
/* this needs to run after the rtc is read at boot */
spin_lock_irqsave(&alarm_slock, flags);
/* We read the current rtc and system time so we can later calulate
* elasped realtime to be (boot_systemtime + rtc - boot_rtc) ==
* (rtc - (boot_rtc - boot_systemtime))
*/
getnstimeofday(&tmp_time);
ktime_get_ts(&system_time);
alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP].delta =
alarms[ANDROID_ALARM_ELAPSED_REALTIME].delta =
timespec_to_ktime(timespec_sub(tmp_time, system_time));
spin_unlock_irqrestore(&alarm_slock, flags);
return 0;
}
static int __init alarm_driver_init(void)
{
int err;
int i;
for (i = 0; i < ANDROID_ALARM_SYSTEMTIME; i++) {
hrtimer_init(&alarms[i].timer,
CLOCK_REALTIME, HRTIMER_MODE_ABS);
alarms[i].timer.function = alarm_timer_triggered;
}
hrtimer_init(&alarms[ANDROID_ALARM_SYSTEMTIME].timer,
CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
alarms[ANDROID_ALARM_SYSTEMTIME].timer.function = alarm_timer_triggered;
err = platform_driver_register(&alarm_driver);
if (err < 0)
goto err1;
wake_lock_init(&alarm_rtc_wake_lock, WAKE_LOCK_SUSPEND, "alarm_rtc");
rtc_alarm_interface.class = rtc_class;
err = class_interface_register(&rtc_alarm_interface);
if (err < 0)
goto err2;
return 0;
err2:
wake_lock_destroy(&alarm_rtc_wake_lock);
platform_driver_unregister(&alarm_driver);
err1:
return err;
}
static void __exit alarm_exit(void)
{
class_interface_unregister(&rtc_alarm_interface);
wake_lock_destroy(&alarm_rtc_wake_lock);
platform_driver_unregister(&alarm_driver);
}
late_initcall(alarm_late_init);
module_init(alarm_driver_init);
module_exit(alarm_exit);
......@@ -33,65 +33,6 @@ enum android_alarm_type {
/* ANDROID_ALARM_TIME_CHANGE = 16 */
};
#ifdef __KERNEL__
#include <linux/ktime.h>
#include <linux/rbtree.h>
/*
* The alarm interface is similar to the hrtimer interface but adds support
* for wakeup from suspend. It also adds an elapsed realtime clock that can
* be used for periodic timers that need to keep runing while the system is
* suspended and not be disrupted when the wall time is set.
*/
/**
* struct alarm - the basic alarm structure
* @node: red black tree node for time ordered insertion
* @type: alarm type. rtc/elapsed-realtime/systemtime, wakeup/non-wakeup.
* @softexpires: the absolute earliest expiry time of the alarm.
* @expires: the absolute expiry time.
* @function: alarm expiry callback function
*
* The alarm structure must be initialized by alarm_init()
*
*/
struct android_alarm {
struct rb_node node;
enum android_alarm_type type;
ktime_t softexpires;
ktime_t expires;
void (*function)(struct android_alarm *);
};
void android_alarm_init(struct android_alarm *alarm,
enum android_alarm_type type, void (*function)(struct android_alarm *));
void android_alarm_start_range(struct android_alarm *alarm, ktime_t start,
ktime_t end);
int android_alarm_try_to_cancel(struct android_alarm *alarm);
int android_alarm_cancel(struct android_alarm *alarm);
ktime_t alarm_get_elapsed_realtime(void);
/* set rtc while preserving elapsed realtime */
int android_alarm_set_rtc(const struct timespec ts);
#ifdef CONFIG_ANDROID_ALARM_OLDDRV_COMPAT
/*
* Some older drivers depend on the old API,
* so provide compatability macros for now.
*/
#define alarm android_alarm
#define alarm_init(x, y, z) android_alarm_init(x, y, z)
#define alarm_start_range(x, y, z) android_alarm_start_range(x, y, z)
#define alarm_try_to_cancel(x) android_alarm_try_to_cancel(x)
#define alarm_cancel(x) android_alarm_cancel(x)
#define alarm_set_rtc(x) android_alarm_set_rtc(x)
#endif
#endif
enum android_alarm_return_flags {
ANDROID_ALARM_RTC_WAKEUP_MASK = 1U << ANDROID_ALARM_RTC_WAKEUP,
ANDROID_ALARM_RTC_MASK = 1U << ANDROID_ALARM_RTC,
......
......@@ -53,17 +53,17 @@ struct flat_binder_object {
/* 8 bytes of data. */
union {
void *binder; /* local object */
void __user *binder; /* local object */
signed long handle; /* remote object */
};
/* extra data associated with local object */
void *cookie;
void __user *cookie;
};
/*
* On 64-bit platforms where user code may run in 32-bits the driver must
* translate the buffer (and local binder) addresses apropriately.
* translate the buffer (and local binder) addresses appropriately.
*/
struct binder_write_read {
......@@ -139,9 +139,9 @@ struct binder_transaction_data {
union {
struct {
/* transaction data */
const void *buffer;
const void __user *buffer;
/* offsets from buffer to flat_binder_object structs */
const void *offsets;
const void __user *offsets;
} ptr;
uint8_t buf[8];
} data;
......
......@@ -424,11 +424,11 @@ struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc)
if (buffer_size(prz) > prz->buffer_size ||
buffer_start(prz) > buffer_size(prz))
pr_info("persistent_ram: found existing invalid buffer,"
" size %ld, start %ld\n",
" size %zu, start %zu\n",
buffer_size(prz), buffer_start(prz));
else {
pr_info("persistent_ram: found existing buffer,"
" size %ld, start %ld\n",
" size %zu, start %zu\n",
buffer_size(prz), buffer_start(prz));
persistent_ram_save_old(prz);
}
......
......@@ -99,6 +99,7 @@ EXPORT_SYMBOL_GPL(timed_output_dev_register);
void timed_output_dev_unregister(struct timed_output_dev *tdev)
{
tdev->enable(tdev, 0);
device_remove_file(tdev->dev, &dev_attr_enable);
device_destroy(timed_output_class, MKDEV(0, tdev->index));
dev_set_drvdata(tdev->dev, NULL);
......
......@@ -782,20 +782,20 @@ static int __init asus_oled_init(void)
oled_class = class_create(THIS_MODULE, ASUS_OLED_UNDERSCORE_NAME);
if (IS_ERR(oled_class)) {
err("Error creating " ASUS_OLED_UNDERSCORE_NAME " class");
printk(KERN_ERR "Error creating " ASUS_OLED_UNDERSCORE_NAME " class\n");
return PTR_ERR(oled_class);
}
retval = class_create_file(oled_class, &class_attr_version.attr);
if (retval) {
err("Error creating class version file");
printk(KERN_ERR "Error creating class version file\n");
goto error;
}
retval = usb_register(&oled_driver);
if (retval) {
err("usb_register failed. Error number %d", retval);
printk(KERN_ERR "usb_register failed. Error number %d\n", retval);
goto error;
}
......
......@@ -1115,20 +1115,20 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
{
case DDR_80_MHZ:
psDDRSetting = asT3LP_DDRSetting80MHz;
RegCount = (sizeof(asT3LP_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3LP_DDRSetting80MHz);
RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
break;
case DDR_100_MHZ:
psDDRSetting = asT3LP_DDRSetting100MHz;
RegCount = (sizeof(asT3LP_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3LP_DDRSetting100MHz);
RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
break;
case DDR_133_MHZ:
bOverrideSelfRefresh = TRUE;
psDDRSetting = asT3LP_DDRSetting133MHz;
RegCount = (sizeof(asT3LP_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3LP_DDRSetting133MHz);
RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
break;
......@@ -1146,20 +1146,20 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
{
case DDR_80_MHZ:
psDDRSetting = asT3LPB_DDRSetting80MHz;
RegCount=(sizeof(asT3LPB_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
RegCount=ARRAY_SIZE(asT3LPB_DDRSetting80MHz);
RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
break;
case DDR_100_MHZ:
psDDRSetting = asT3LPB_DDRSetting100MHz;
RegCount = (sizeof(asT3LPB_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3LPB_DDRSetting100MHz);
RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
break;
case DDR_133_MHZ:
bOverrideSelfRefresh = TRUE;
psDDRSetting = asT3LPB_DDRSetting133MHz;
RegCount = (sizeof(asT3LPB_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3LPB_DDRSetting133MHz);
RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
break;
......@@ -1167,7 +1167,7 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
case DDR_160_MHZ:
bOverrideSelfRefresh = TRUE;
psDDRSetting = asT3LPB_DDRSetting160MHz;
RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(DDR_SET_NODE);
RegCount = ARRAY_SIZE(asT3LPB_DDRSetting160MHz);
RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ;
psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ;
......@@ -1181,19 +1181,19 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
{
case DDR_80_MHZ:
psDDRSetting = asT3_DDRSetting80MHz;
RegCount = (sizeof(asT3_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3_DDRSetting80MHz);
RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
break;
case DDR_100_MHZ:
psDDRSetting = asT3_DDRSetting100MHz;
RegCount = (sizeof(asT3_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3_DDRSetting100MHz);
RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
break;
case DDR_133_MHZ:
psDDRSetting = asT3_DDRSetting133MHz;
RegCount = (sizeof(asT3_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3_DDRSetting133MHz);
RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
break;
......@@ -1207,20 +1207,20 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
{
case DDR_80_MHZ:
psDDRSetting = asT3B_DDRSetting80MHz;
RegCount = (sizeof(asT3B_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3B_DDRSetting80MHz);
RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
break;
case DDR_100_MHZ:
psDDRSetting = asT3B_DDRSetting100MHz;
RegCount = (sizeof(asT3B_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3B_DDRSetting100MHz);
RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
break;
case DDR_133_MHZ:
bOverrideSelfRefresh = TRUE;
psDDRSetting = asT3B_DDRSetting133MHz;
RegCount = (sizeof(asT3B_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
RegCount = ARRAY_SIZE(asT3B_DDRSetting133MHz);
RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
break;
......
此差异已折叠。
......@@ -835,7 +835,7 @@ int reset_card_proc(PMINI_ADAPTER ps_adapter)
Bcm_kill_all_URBs(psIntfAdapter);
/* Reset the UMA-B Device */
if (ps_adapter->chip_id >= T3LPB) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reseting UMA-B\n");
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Resetting UMA-B\n");
retval = usb_reset_device(psIntfAdapter->udev);
psIntfAdapter->psAdapter->StopAllXaction = FALSE;
......
......@@ -14,6 +14,26 @@ config COMEDI_DEBUG
This is an option for use by developers; most people should
say N here. This enables comedi core and driver debugging.
config COMEDI_DEFAULT_BUF_SIZE_KB
int "Comedi default initial asynchronous buffer size in KiB"
default "2048"
depends on COMEDI != n
---help---
This is the default asynchronous buffer size which is used for
commands running in the background in kernel space. This
defaults to 2048 KiB of memory so that a 16 channel card
running at 10 kHz has of 2-4 seconds of buffer.
config COMEDI_DEFAULT_BUF_MAXSIZE_KB
int "Comedi default maximum asynchronous buffer size in KiB"
default "20480"
depends on COMEDI != n
---help---
This is the default maximum asynchronous buffer size which can
be requested by a userspace program without root privileges.
This is set to 20480 KiB so that a fast I/O card with 16
channels running at 100 kHz has 2-4 seconds of buffer.
menuconfig COMEDI_MISC_DRIVERS
tristate "Comedi misc drivers"
depends on COMEDI
......@@ -211,6 +231,38 @@ config COMEDI_PCM3730
To compile this driver as a module, choose M here: the module will be
called pcm3730.
config COMEDI_AMPLC_DIO200_ISA
tristate "Amplicon PC212E/PC214E/PC215E/PC218E/PC272E"
select COMEDI_AMPLC_DIO200
depends on COMEDI_ISA_DRIVERS
default N
---help---
Enable support for Amplicon PC212E, PC214E, PC215E, PC218E and
PC272E ISA DIO boards
To compile this driver as a module, choose M here: the module will be
called amplc_dio200.
config COMEDI_AMPLC_PC236_ISA
tristate "Amplicon PC36AT DIO board support"
select COMEDI_AMPLC_PC236
default N
---help---
Enable support for Amplicon PC36AT ISA DIO board.
To compile this driver as a module, choose M here: the module will be
called amplc_pc236.
config COMEDI_AMPLC_PC263_ISA
tristate "Amplicon PC263 relay board support"
select COMEDI_AMPLC_PC263
default N
---help---
Enable support for Amplicon PC263 ISA relay board.
To compile this driver as a module, choose M here: the module will be
called amplc_pc263.
config COMEDI_RTI800
tristate "Analog Devices RTI-800/815 ISA card support"
default N
......@@ -240,6 +292,20 @@ config COMEDI_DAS16M1
To compile this driver as a module, choose M here: the module will be
called das16m1.
config COMEDI_DAS08_ISA
tristate "DAS-08 compatible ISA and PC/104 card support"
select COMEDI_DAS08
default N
---help---
Enable support for Keithley Metrabyte/ComputerBoards DAS08
and compatible ISA and PC/104 cards:
Keithley Metrabyte/ComputerBoards DAS08, DAS08-PGM, DAS08-PGH,
DAS08-PGL, DAS08-AOH, DAS08-AOL, DAS08-AOM, DAS08/JR-AO,
DAS08/JR-16-AO, PC104-DAS08, DAS08/JR/16.
To compile this driver as a module, choose M here: the module will be
called das08.
config COMEDI_DAS16
tristate "DAS-16 compatible ISA and PC/104 card support"
select COMEDI_8255
......@@ -772,31 +838,32 @@ config COMEDI_ADV_PCI_DIO
To compile this driver as a module, choose M here: the module will be
called adv_pci_dio.
config COMEDI_AMPLC_DIO200
tristate "Amplicon PC272E and PCI272 DIO board support"
select COMEDI_8255
config COMEDI_AMPLC_DIO200_PCI
tristate "Amplicon PCI215 and PCI272 DIO board support"
select COMEDI_AMPLC_DIO200
default N
---help---
Enable support for Amplicon PC272E and PCI272 DIO boards
Enable support for Amplicon PCI215 and PCI272 DIO boards.
To compile this driver as a module, choose M here: the module will be
called amplc_dio200.
config COMEDI_AMPLC_PC236
tristate "Amplicon PC36AT and PCI236 DIO board support"
select COMEDI_8255
config COMEDI_AMPLC_PC236_PCI
tristate "Amplicon PCI236 DIO board support"
select COMEDI_AMPLC_PC236
default N
---help---
Enable support for Amplicon PC36AT and PCI236 DIO boards
Enable support for Amplicon PCI236 DIO board.
To compile this driver as a module, choose M here: the module will be
called amplc_pc236.
config COMEDI_AMPLC_PC263
tristate "Amplicon PC263 and PCI263 relay board support"
config COMEDI_AMPLC_PC263_PCI
tristate "Amplicon PCI263 relay board support"
select COMEDI_AMPLC_PC263
default N
---help---
Enable support for Amplicon PC263 and PCI263 relay boards
Enable support for Amplicon PCI263 relay board.
To compile this driver as a module, choose M here: the module will be
called amplc_pc263.
......@@ -831,6 +898,16 @@ config COMEDI_CONTEC_PCI_DIO
To compile this driver as a module, choose M here: the module will be
called contec_pci_dio.
config COMEDI_DAS08_PCI
tristate "DAS-08 PCI support"
select COMEDI_DAS08
default N
---help---
Enable support for PCI DAS-08 cards.
To compile this driver as a module, choose M here: the module will be
called das08.
config COMEDI_DT3000
tristate "Data Translation DT3000 series support"
default N
......@@ -1357,20 +1434,6 @@ config COMEDI_8255
To compile this driver as a module, choose M here: the module will be
called 8255.
config COMEDI_DAS08
tristate "DAS-08 compatible support"
depends on COMEDI
select COMEDI_8255
default N
---help---
Enable support for DAS08 and compatible ISA, PC/104 and PCI cards.
Note that PCMCIA DAS08 cards are not directly supported by this
driver, and need a separate driver as a wrapper.
To compile this driver as a module, choose M here: the module will be
called das08.
config COMEDI_FC
tristate "Comedi shared functions for low-level driver support"
depends on COMEDI
......@@ -1382,3 +1445,22 @@ config COMEDI_FC
To compile this driver as a module, choose M here: the module will be
called comedi_fc.
config COMEDI_AMPLC_DIO200
def_tristate N
depends on COMEDI
select COMEDI_8255
config COMEDI_AMPLC_PC236
def_tristate N
depends on COMEDI
select COMEDI_8255
config COMEDI_AMPLC_PC263
def_tristate N
depends on COMEDI
config COMEDI_DAS08
def_tristate N
depends on COMEDI
select COMEDI_8255
......@@ -465,7 +465,7 @@
/* only relevant to kernel modules. */
#define COMEDI_CB_EOS 1 /* end of scan */
#define COMEDI_CB_EOA 2 /* end of acquisition */
#define COMEDI_CB_EOA 2 /* end of acquisition/output */
#define COMEDI_CB_BLOCK 4 /* data has arrived:
* wakes up read() / write() */
#define COMEDI_CB_EOBUF 8 /* DEPRECATED: end of buffer */
......
......@@ -58,14 +58,35 @@ MODULE_LICENSE("GPL");
#ifdef CONFIG_COMEDI_DEBUG
int comedi_debug;
EXPORT_SYMBOL(comedi_debug);
module_param(comedi_debug, int, 0644);
module_param(comedi_debug, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(comedi_debug,
"enable comedi core and driver debugging if non-zero (default 0)"
);
#endif
bool comedi_autoconfig = 1;
module_param(comedi_autoconfig, bool, 0444);
module_param(comedi_autoconfig, bool, S_IRUGO);
MODULE_PARM_DESC(comedi_autoconfig,
"enable drivers to auto-configure comedi devices (default 1)");
static int comedi_num_legacy_minors;
module_param(comedi_num_legacy_minors, int, 0444);
module_param(comedi_num_legacy_minors, int, S_IRUGO);
MODULE_PARM_DESC(comedi_num_legacy_minors,
"number of comedi minor devices to reserve for non-auto-configured devices (default 0)"
);
unsigned int comedi_default_buf_size_kb = CONFIG_COMEDI_DEFAULT_BUF_SIZE_KB;
module_param(comedi_default_buf_size_kb, uint, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(comedi_default_buf_size_kb,
"default asynchronous buffer size in KiB (default "
__MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_SIZE_KB) ")");
unsigned int comedi_default_buf_maxsize_kb
= CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB;
module_param(comedi_default_buf_maxsize_kb, uint, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(comedi_default_buf_maxsize_kb,
"default maximum size of asynchronous buffer in KiB (default "
__MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB) ")");
static DEFINE_SPINLOCK(comedi_file_info_table_lock);
static struct comedi_device_file_info
......@@ -280,7 +301,7 @@ static int do_devconfig_ioctl(struct comedi_device *dev,
if (ret == 0) {
if (!try_module_get(dev->driver->module)) {
comedi_device_detach(dev);
return -ENOSYS;
ret = -ENOSYS;
}
}
......@@ -1545,7 +1566,7 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
return retval;
}
static unsigned int comedi_poll(struct file *file, poll_table * wait)
static unsigned int comedi_poll(struct file *file, poll_table *wait)
{
unsigned int mask = 0;
const unsigned minor = iminor(file->f_dentry->d_inode);
......@@ -2192,7 +2213,6 @@ static void comedi_device_cleanup(struct comedi_device *dev)
int comedi_alloc_board_minor(struct device *hardware_device)
{
unsigned long flags;
struct comedi_device_file_info *info;
struct device *csdev;
unsigned i;
......@@ -2206,15 +2226,16 @@ int comedi_alloc_board_minor(struct device *hardware_device)
kfree(info);
return -ENOMEM;
}
info->hardware_device = hardware_device;
comedi_device_init(info->device);
spin_lock_irqsave(&comedi_file_info_table_lock, flags);
spin_lock(&comedi_file_info_table_lock);
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; ++i) {
if (comedi_file_info_table[i] == NULL) {
comedi_file_info_table[i] = info;
break;
}
}
spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
spin_unlock(&comedi_file_info_table_lock);
if (i == COMEDI_NUM_BOARD_MINORS) {
comedi_device_cleanup(info->device);
kfree(info->device);
......@@ -2271,14 +2292,13 @@ int comedi_alloc_board_minor(struct device *hardware_device)
void comedi_free_board_minor(unsigned minor)
{
unsigned long flags;
struct comedi_device_file_info *info;
BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS);
spin_lock_irqsave(&comedi_file_info_table_lock, flags);
spin_lock(&comedi_file_info_table_lock);
info = comedi_file_info_table[minor];
comedi_file_info_table[minor] = NULL;
spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
spin_unlock(&comedi_file_info_table_lock);
if (info) {
struct comedi_device *dev = info->device;
......@@ -2294,10 +2314,26 @@ void comedi_free_board_minor(unsigned minor)
}
}
int comedi_find_board_minor(struct device *hardware_device)
{
int minor;
struct comedi_device_file_info *info;
for (minor = 0; minor < COMEDI_NUM_BOARD_MINORS; minor++) {
spin_lock(&comedi_file_info_table_lock);
info = comedi_file_info_table[minor];
if (info && info->hardware_device == hardware_device) {
spin_unlock(&comedi_file_info_table_lock);
return minor;
}
spin_unlock(&comedi_file_info_table_lock);
}
return -ENODEV;
}
int comedi_alloc_subdevice_minor(struct comedi_device *dev,
struct comedi_subdevice *s)
{
unsigned long flags;
struct comedi_device_file_info *info;
struct device *csdev;
unsigned i;
......@@ -2309,14 +2345,14 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
info->device = dev;
info->read_subdevice = s;
info->write_subdevice = s;
spin_lock_irqsave(&comedi_file_info_table_lock, flags);
spin_lock(&comedi_file_info_table_lock);
for (i = COMEDI_FIRST_SUBDEVICE_MINOR; i < COMEDI_NUM_MINORS; ++i) {
if (comedi_file_info_table[i] == NULL) {
comedi_file_info_table[i] = info;
break;
}
}
spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
spin_unlock(&comedi_file_info_table_lock);
if (i == COMEDI_NUM_MINORS) {
kfree(info);
printk(KERN_ERR
......@@ -2372,7 +2408,6 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
void comedi_free_subdevice_minor(struct comedi_subdevice *s)
{
unsigned long flags;
struct comedi_device_file_info *info;
if (s == NULL)
......@@ -2383,10 +2418,10 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
BUG_ON(s->minor >= COMEDI_NUM_MINORS);
BUG_ON(s->minor < COMEDI_FIRST_SUBDEVICE_MINOR);
spin_lock_irqsave(&comedi_file_info_table_lock, flags);
spin_lock(&comedi_file_info_table_lock);
info = comedi_file_info_table[s->minor];
comedi_file_info_table[s->minor] = NULL;
spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
spin_unlock(&comedi_file_info_table_lock);
if (s->class_dev) {
device_destroy(comedi_class, MKDEV(COMEDI_MAJOR, s->minor));
......@@ -2397,13 +2432,12 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor)
{
unsigned long flags;
struct comedi_device_file_info *info;
BUG_ON(minor >= COMEDI_NUM_MINORS);
spin_lock_irqsave(&comedi_file_info_table_lock, flags);
spin_lock(&comedi_file_info_table_lock);
info = comedi_file_info_table[minor];
spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
spin_unlock(&comedi_file_info_table_lock);
return info;
}
EXPORT_SYMBOL_GPL(comedi_get_device_file_info);
......
......@@ -180,6 +180,9 @@ struct comedi_async {
unsigned int x);
};
struct pci_dev;
struct usb_interface;
struct comedi_driver {
struct comedi_driver *next;
......@@ -187,6 +190,8 @@ struct comedi_driver {
struct module *module;
int (*attach) (struct comedi_device *, struct comedi_devconfig *);
int (*detach) (struct comedi_device *);
int (*attach_pci) (struct comedi_device *, struct pci_dev *);
int (*attach_usb) (struct comedi_device *, struct usb_interface *);
/* number of elements in board_name and board_id arrays */
unsigned int num_names;
......@@ -230,10 +235,16 @@ struct comedi_device {
void (*close) (struct comedi_device *dev);
};
static inline const void *comedi_board(struct comedi_device *dev)
{
return dev->board_ptr;
}
struct comedi_device_file_info {
struct comedi_device *device;
struct comedi_subdevice *read_subdevice;
struct comedi_subdevice *write_subdevice;
struct device *hardware_device;
};
#ifdef CONFIG_COMEDI_DEBUG
......@@ -456,11 +467,12 @@ static inline void *comedi_aux_data(int options[], int n)
int comedi_alloc_subdevice_minor(struct comedi_device *dev,
struct comedi_subdevice *s);
void comedi_free_subdevice_minor(struct comedi_subdevice *s);
int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name);
int comedi_pci_auto_config(struct pci_dev *pcidev,
struct comedi_driver *driver);
void comedi_pci_auto_unconfig(struct pci_dev *pcidev);
struct usb_device; /* forward declaration */
int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name);
void comedi_usb_auto_unconfig(struct usb_device *usbdev);
int comedi_usb_auto_config(struct usb_interface *intf,
struct comedi_driver *driver);
void comedi_usb_auto_unconfig(struct usb_interface *intf);
#ifdef CONFIG_COMEDI_PCI_DRIVERS
#define CONFIG_COMEDI_PCI
......
......@@ -106,6 +106,26 @@ void comedi_device_detach(struct comedi_device *dev)
__comedi_device_detach(dev);
}
/* do a little post-config cleanup */
/* called with module refcount incremented, decrements it */
static int comedi_device_postconfig(struct comedi_device *dev)
{
int ret = postconfig(dev);
module_put(dev->driver->module);
if (ret < 0) {
__comedi_device_detach(dev);
return ret;
}
if (!dev->board_name) {
printk(KERN_WARNING "BUG: dev->board_name=<%p>\n",
dev->board_name);
dev->board_name = "BUG";
}
smp_wmb();
dev->attached = 1;
return 0;
}
int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_driver *driv;
......@@ -121,59 +141,36 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
if (driv->num_names) {
dev->board_ptr = comedi_recognize(driv, it->board_name);
if (dev->board_ptr == NULL) {
module_put(driv->module);
continue;
}
} else {
if (strcmp(driv->driver_name, it->board_name)) {
module_put(driv->module);
if (dev->board_ptr)
break;
} else if (strcmp(driv->driver_name, it->board_name))
break;
module_put(driv->module);
}
if (driv == NULL) {
/* recognize has failed if we get here */
/* report valid board names before returning error */
for (driv = comedi_drivers; driv; driv = driv->next) {
if (!try_module_get(driv->module)) {
printk(KERN_INFO
"comedi: failed to increment module count\n");
continue;
}
comedi_report_boards(driv);
module_put(driv->module);
}
/* initialize dev->driver here so
* comedi_error() can be called from attach */
dev->driver = driv;
ret = driv->attach(dev, it);
if (ret < 0) {
module_put(dev->driver->module);
__comedi_device_detach(dev);
return ret;
}
goto attached;
}
/* recognize has failed if we get here */
/* report valid board names before returning error */
for (driv = comedi_drivers; driv; driv = driv->next) {
if (!try_module_get(driv->module)) {
printk(KERN_INFO
"comedi: failed to increment module count\n");
continue;
}
comedi_report_boards(driv);
module_put(driv->module);
return -EIO;
}
return -EIO;
attached:
/* do a little post-config cleanup */
ret = postconfig(dev);
module_put(dev->driver->module);
/* initialize dev->driver here so
* comedi_error() can be called from attach */
dev->driver = driv;
ret = driv->attach(dev, it);
if (ret < 0) {
module_put(dev->driver->module);
__comedi_device_detach(dev);
return ret;
}
if (!dev->board_name) {
printk(KERN_WARNING "BUG: dev->board_name=<%p>\n",
dev->board_name);
dev->board_name = "BUG";
}
smp_wmb();
dev->attached = 1;
return 0;
return comedi_device_postconfig(dev);
}
int comedi_driver_register(struct comedi_driver *driver)
......@@ -242,6 +239,8 @@ static int postconfig(struct comedi_device *dev)
s->len_chanlist = 1;
if (s->do_cmd) {
unsigned int buf_size;
BUG_ON((s->subdev_flags & (SDF_CMD_READ |
SDF_CMD_WRITE)) == 0);
BUG_ON(!s->do_cmdtest);
......@@ -257,19 +256,20 @@ static int postconfig(struct comedi_device *dev)
async->subdevice = s;
s->async = async;
#define DEFAULT_BUF_MAXSIZE (64*1024)
#define DEFAULT_BUF_SIZE (64*1024)
async->max_bufsize = DEFAULT_BUF_MAXSIZE;
async->max_bufsize =
comedi_default_buf_maxsize_kb * 1024;
buf_size = comedi_default_buf_size_kb * 1024;
if (buf_size > async->max_bufsize)
buf_size = async->max_bufsize;
async->prealloc_buf = NULL;
async->prealloc_bufsz = 0;
if (comedi_buf_alloc(dev, s, DEFAULT_BUF_SIZE) < 0) {
if (comedi_buf_alloc(dev, s, buf_size) < 0) {
printk(KERN_INFO "Buffer allocation failed\n");
return -ENOMEM;
}
if (s->buf_change) {
ret = s->buf_change(dev, s, DEFAULT_BUF_SIZE);
ret = s->buf_change(dev, s, buf_size);
if (ret < 0)
return ret;
}
......@@ -814,67 +814,102 @@ void comedi_reset_async_buf(struct comedi_async *async)
async->events = 0;
}
static int comedi_auto_config(struct device *hardware_device,
const char *board_name, const int *options,
unsigned num_options)
static int
comedi_auto_config_helper(struct device *hardware_device,
struct comedi_driver *driver,
int (*attach_wrapper) (struct comedi_device *,
void *), void *context)
{
struct comedi_devconfig it;
int minor;
struct comedi_device_file_info *dev_file_info;
int retval;
unsigned *private_data = NULL;
struct comedi_device *comedi_dev;
int ret;
if (!comedi_autoconfig) {
dev_set_drvdata(hardware_device, NULL);
if (!comedi_autoconfig)
return 0;
}
minor = comedi_alloc_board_minor(hardware_device);
if (minor < 0)
return minor;
private_data = kmalloc(sizeof(unsigned), GFP_KERNEL);
if (private_data == NULL) {
retval = -ENOMEM;
goto cleanup;
dev_file_info = comedi_get_device_file_info(minor);
comedi_dev = dev_file_info->device;
mutex_lock(&comedi_dev->mutex);
if (comedi_dev->attached)
ret = -EBUSY;
else if (!try_module_get(driver->module)) {
printk(KERN_INFO "comedi: failed to increment module count\n");
ret = -EIO;
} else {
/* set comedi_dev->driver here for attach wrapper */
comedi_dev->driver = driver;
ret = (*attach_wrapper)(comedi_dev, context);
if (ret < 0) {
module_put(driver->module);
__comedi_device_detach(comedi_dev);
} else {
ret = comedi_device_postconfig(comedi_dev);
}
}
mutex_unlock(&comedi_dev->mutex);
if (ret < 0)
comedi_free_board_minor(minor);
return ret;
}
static int comedi_auto_config_wrapper(struct comedi_device *dev, void *context)
{
struct comedi_devconfig *it = context;
struct comedi_driver *driv = dev->driver;
if (driv->num_names) {
/* look for generic board entry matching driver name, which
* has already been copied to it->board_name */
dev->board_ptr = comedi_recognize(driv, it->board_name);
if (dev->board_ptr == NULL) {
printk(KERN_WARNING
"comedi: auto config failed to find board entry"
" '%s' for driver '%s'\n", it->board_name,
driv->driver_name);
comedi_report_boards(driv);
return -EINVAL;
}
}
*private_data = minor;
dev_set_drvdata(hardware_device, private_data);
return driv->attach(dev, it);
}
dev_file_info = comedi_get_device_file_info(minor);
static int comedi_auto_config(struct device *hardware_device,
struct comedi_driver *driver, const int *options,
unsigned num_options)
{
struct comedi_devconfig it;
memset(&it, 0, sizeof(it));
strncpy(it.board_name, board_name, COMEDI_NAMELEN);
strncpy(it.board_name, driver->driver_name, COMEDI_NAMELEN);
it.board_name[COMEDI_NAMELEN - 1] = '\0';
BUG_ON(num_options > COMEDI_NDEVCONFOPTS);
memcpy(it.options, options, num_options * sizeof(int));
mutex_lock(&dev_file_info->device->mutex);
retval = comedi_device_attach(dev_file_info->device, &it);
mutex_unlock(&dev_file_info->device->mutex);
cleanup:
if (retval < 0) {
kfree(private_data);
comedi_free_board_minor(minor);
}
return retval;
return comedi_auto_config_helper(hardware_device, driver,
comedi_auto_config_wrapper, &it);
}
static void comedi_auto_unconfig(struct device *hardware_device)
{
unsigned *minor = (unsigned *)dev_get_drvdata(hardware_device);
if (minor == NULL)
return;
BUG_ON(*minor >= COMEDI_NUM_BOARD_MINORS);
int minor;
comedi_free_board_minor(*minor);
dev_set_drvdata(hardware_device, NULL);
kfree(minor);
if (hardware_device == NULL)
return;
minor = comedi_find_board_minor(hardware_device);
if (minor < 0)
return;
BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS);
comedi_free_board_minor(minor);
}
int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name)
static int comedi_old_pci_auto_config(struct pci_dev *pcidev,
struct comedi_driver *driver)
{
int options[2];
......@@ -883,9 +918,30 @@ int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name)
/* pci slot */
options[1] = PCI_SLOT(pcidev->devfn);
return comedi_auto_config(&pcidev->dev, board_name,
return comedi_auto_config(&pcidev->dev, driver,
options, ARRAY_SIZE(options));
}
static int comedi_pci_attach_wrapper(struct comedi_device *dev, void *pcidev)
{
return dev->driver->attach_pci(dev, pcidev);
}
static int comedi_new_pci_auto_config(struct pci_dev *pcidev,
struct comedi_driver *driver)
{
return comedi_auto_config_helper(&pcidev->dev, driver,
comedi_pci_attach_wrapper, pcidev);
}
int comedi_pci_auto_config(struct pci_dev *pcidev, struct comedi_driver *driver)
{
if (driver->attach_pci)
return comedi_new_pci_auto_config(pcidev, driver);
else
return comedi_old_pci_auto_config(pcidev, driver);
}
EXPORT_SYMBOL_GPL(comedi_pci_auto_config);
void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
......@@ -894,16 +950,38 @@ void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
}
EXPORT_SYMBOL_GPL(comedi_pci_auto_unconfig);
int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name)
static int comedi_old_usb_auto_config(struct usb_interface *intf,
struct comedi_driver *driver)
{
BUG_ON(usbdev == NULL);
return comedi_auto_config(&usbdev->dev, board_name, NULL, 0);
return comedi_auto_config(&intf->dev, driver, NULL, 0);
}
static int comedi_usb_attach_wrapper(struct comedi_device *dev, void *intf)
{
return dev->driver->attach_usb(dev, intf);
}
static int comedi_new_usb_auto_config(struct usb_interface *intf,
struct comedi_driver *driver)
{
return comedi_auto_config_helper(&intf->dev, driver,
comedi_usb_attach_wrapper, intf);
}
int comedi_usb_auto_config(struct usb_interface *intf,
struct comedi_driver *driver)
{
BUG_ON(intf == NULL);
if (driver->attach_usb)
return comedi_new_usb_auto_config(intf, driver);
else
return comedi_old_usb_auto_config(intf, driver);
}
EXPORT_SYMBOL_GPL(comedi_usb_auto_config);
void comedi_usb_auto_unconfig(struct usb_device *usbdev)
void comedi_usb_auto_unconfig(struct usb_interface *intf)
{
BUG_ON(usbdev == NULL);
comedi_auto_unconfig(&usbdev->dev);
BUG_ON(intf == NULL);
comedi_auto_unconfig(&intf->dev);
}
EXPORT_SYMBOL_GPL(comedi_usb_auto_unconfig);
......@@ -107,31 +107,6 @@ struct subdev_8255_struct {
#define CALLBACK_FUNC (((struct subdev_8255_struct *)s->private)->cb_func)
#define subdevpriv ((struct subdev_8255_struct *)s->private)
static int dev_8255_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int dev_8255_detach(struct comedi_device *dev);
static struct comedi_driver driver_8255 = {
.driver_name = "8255",
.module = THIS_MODULE,
.attach = dev_8255_attach,
.detach = dev_8255_detach,
};
static int __init driver_8255_init_module(void)
{
return comedi_driver_register(&driver_8255);
}
static void __exit driver_8255_cleanup_module(void)
{
comedi_driver_unregister(&driver_8255);
}
module_init(driver_8255_init_module);
module_exit(driver_8255_cleanup_module);
static void do_config(struct comedi_device *dev, struct comedi_subdevice *s);
void subdev_8255_interrupt(struct comedi_device *dev,
struct comedi_subdevice *s)
{
......@@ -185,6 +160,23 @@ static int subdev_8255_insn(struct comedi_device *dev,
return 2;
}
static void do_config(struct comedi_device *dev, struct comedi_subdevice *s)
{
int config;
config = CR_CW;
/* 1 in io_bits indicates output, 1 in config indicates input */
if (!(s->io_bits & 0x0000ff))
config |= CR_A_IO;
if (!(s->io_bits & 0x00ff00))
config |= CR_B_IO;
if (!(s->io_bits & 0x0f0000))
config |= CR_C_LO_IO;
if (!(s->io_bits & 0xf00000))
config |= CR_C_HI_IO;
CALLBACK_FUNC(1, _8255_CR, config, CALLBACK_ARG);
}
static int subdev_8255_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
......@@ -222,23 +214,6 @@ static int subdev_8255_insn_config(struct comedi_device *dev,
return 1;
}
static void do_config(struct comedi_device *dev, struct comedi_subdevice *s)
{
int config;
config = CR_CW;
/* 1 in io_bits indicates output, 1 in config indicates input */
if (!(s->io_bits & 0x0000ff))
config |= CR_A_IO;
if (!(s->io_bits & 0x00ff00))
config |= CR_B_IO;
if (!(s->io_bits & 0x0f0000))
config |= CR_C_LO_IO;
if (!(s->io_bits & 0xf00000))
config |= CR_C_HI_IO;
CALLBACK_FUNC(1, _8255_CR, config, CALLBACK_ARG);
}
static int subdev_8255_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
......@@ -462,6 +437,25 @@ static int dev_8255_detach(struct comedi_device *dev)
return 0;
}
static struct comedi_driver driver_8255 = {
.driver_name = "8255",
.module = THIS_MODULE,
.attach = dev_8255_attach,
.detach = dev_8255_detach,
};
static int __init driver_8255_init_module(void)
{
return comedi_driver_register(&driver_8255);
}
module_init(driver_8255_init_module);
static void __exit driver_8255_cleanup_module(void)
{
comedi_driver_unregister(&driver_8255);
}
module_exit(driver_8255_cleanup_module);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
......@@ -22,46 +22,13 @@ Devices: [Adlink] ACL-7225b (acl7225b), [ICP] P16R16DIO (p16r16dio)
#define ACL7225_DI_LO 2 /* Digital input low byte (DI0-DI7) */
#define ACL7225_DI_HI 3 /* Digital input high byte (DI8-DI15) */
static int acl7225b_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int acl7225b_detach(struct comedi_device *dev);
struct boardtype {
const char *name; /* driver name */
int io_range; /* len of I/O space */
};
static const struct boardtype boardtypes[] = {
{"acl7225b", ACL7225_SIZE,},
{"p16r16dio", P16R16DIO_SIZE,},
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
#define this_board ((const struct boardtype *)dev->board_ptr)
static struct comedi_driver driver_acl7225b = {
.driver_name = "acl7225b",
.module = THIS_MODULE,
.attach = acl7225b_attach,
.detach = acl7225b_detach,
.board_name = &boardtypes[0].name,
.num_names = n_boardtypes,
.offset = sizeof(struct boardtype),
};
static int __init driver_acl7225b_init_module(void)
{
return comedi_driver_register(&driver_acl7225b);
}
static void __exit driver_acl7225b_cleanup_module(void)
{
comedi_driver_unregister(&driver_acl7225b);
}
module_init(driver_acl7225b_init_module);
module_exit(driver_acl7225b_cleanup_module);
static int acl7225b_do_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
......@@ -162,6 +129,33 @@ static int acl7225b_detach(struct comedi_device *dev)
return 0;
}
static const struct boardtype boardtypes[] = {
{ "acl7225b", ACL7225_SIZE, },
{ "p16r16dio", P16R16DIO_SIZE, },
};
static struct comedi_driver driver_acl7225b = {
.driver_name = "acl7225b",
.module = THIS_MODULE,
.attach = acl7225b_attach,
.detach = acl7225b_detach,
.board_name = &boardtypes[0].name,
.num_names = ARRAY_SIZE(boardtypes),
.offset = sizeof(struct boardtype),
};
static int __init driver_acl7225b_init_module(void)
{
return comedi_driver_register(&driver_acl7225b);
}
module_init(driver_acl7225b_init_module);
static void __exit driver_acl7225b_cleanup_module(void)
{
comedi_driver_unregister(&driver_acl7225b);
}
module_exit(driver_acl7225b_cleanup_module);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
......@@ -2528,14 +2528,12 @@ static const struct addi_board boardtypes[] = {
#endif
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct addi_board))
static struct comedi_driver driver_addi = {
.driver_name = ADDIDATA_DRIVER_NAME,
.module = THIS_MODULE,
.attach = i_ADDI_Attach,
.detach = i_ADDI_Detach,
.num_names = n_boardtypes,
.num_names = ARRAY_SIZE(boardtypes),
.board_name = &boardtypes[0].pc_DriverName,
.offset = sizeof(struct addi_board),
};
......@@ -2543,7 +2541,7 @@ static struct comedi_driver driver_addi = {
static int __devinit driver_addi_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, driver_addi.driver_name);
return comedi_pci_auto_config(dev, &driver_addi);
}
static void __devexit driver_addi_pci_remove(struct pci_dev *dev)
......
......@@ -85,17 +85,6 @@ static const struct pci6208_board pci6208_boards[] = {
}
};
/* This is used by modprobe to translate PCI IDs to drivers. Should
* only be used for PCI and ISA-PnP devices */
static DEFINE_PCI_DEVICE_TABLE(pci6208_pci_table) = {
/* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
/* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, 0x6208) },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, pci6208_pci_table);
/* Will be initialized in pci6208_find device(). */
#define thisboard ((const struct pci6208_board *)dev->board_ptr)
......@@ -107,157 +96,6 @@ struct pci6208_private {
#define devpriv ((struct pci6208_private *)dev->private)
static int pci6208_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int pci6208_detach(struct comedi_device *dev);
static struct comedi_driver driver_pci6208 = {
.driver_name = PCI6208_DRIVER_NAME,
.module = THIS_MODULE,
.attach = pci6208_attach,
.detach = pci6208_detach,
};
static int __devinit driver_pci6208_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, driver_pci6208.driver_name);
}
static void __devexit driver_pci6208_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
static struct pci_driver driver_pci6208_pci_driver = {
.id_table = pci6208_pci_table,
.probe = &driver_pci6208_pci_probe,
.remove = __devexit_p(&driver_pci6208_pci_remove)
};
static int __init driver_pci6208_init_module(void)
{
int retval;
retval = comedi_driver_register(&driver_pci6208);
if (retval < 0)
return retval;
driver_pci6208_pci_driver.name = (char *)driver_pci6208.driver_name;
return pci_register_driver(&driver_pci6208_pci_driver);
}
static void __exit driver_pci6208_cleanup_module(void)
{
pci_unregister_driver(&driver_pci6208_pci_driver);
comedi_driver_unregister(&driver_pci6208);
}
module_init(driver_pci6208_init_module);
module_exit(driver_pci6208_cleanup_module);
static int pci6208_find_device(struct comedi_device *dev, int bus, int slot);
static int
pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
int dev_minor);
/*read/write functions*/
static int pci6208_ao_winsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
static int pci6208_ao_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/* static int pci6208_dio_insn_bits (struct comedi_device *dev,
* struct comedi_subdevice *s, */
/* struct comedi_insn *insn,unsigned int *data); */
/* static int pci6208_dio_insn_config(struct comedi_device *dev,
* struct comedi_subdevice *s, */
/* struct comedi_insn *insn,unsigned int *data); */
/*
* Attach is called by the Comedi core to configure the driver
* for a particular board. If you specified a board_name array
* in the driver structure, dev->board_ptr contains that
* address.
*/
static int pci6208_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int retval;
unsigned long io_base;
printk(KERN_INFO "comedi%d: pci6208: ", dev->minor);
retval = alloc_private(dev, sizeof(struct pci6208_private));
if (retval < 0)
return retval;
retval = pci6208_find_device(dev, it->options[0], it->options[1]);
if (retval < 0)
return retval;
retval = pci6208_pci_setup(devpriv->pci_dev, &io_base, dev->minor);
if (retval < 0)
return retval;
dev->iobase = io_base;
dev->board_name = thisboard->name;
/*
* Allocate the subdevice structures. alloc_subdevice() is a
* convenient macro defined in comedidev.h.
*/
if (alloc_subdevices(dev, 2) < 0)
return -ENOMEM;
s = dev->subdevices + 0;
/* analog output subdevice */
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE; /* anything else to add here?? */
s->n_chan = thisboard->ao_chans;
s->maxdata = 0xffff; /* 16-bit DAC */
s->range_table = &range_bipolar10; /* this needs to be checked. */
s->insn_write = pci6208_ao_winsn;
s->insn_read = pci6208_ao_rinsn;
/* s=dev->subdevices+1; */
/* digital i/o subdevice */
/* s->type=COMEDI_SUBD_DIO; */
/* s->subdev_flags=SDF_READABLE|SDF_WRITABLE; */
/* s->n_chan=16; */
/* s->maxdata=1; */
/* s->range_table=&range_digital; */
/* s->insn_bits = pci6208_dio_insn_bits; */
/* s->insn_config = pci6208_dio_insn_config; */
printk(KERN_INFO "attached\n");
return 1;
}
/*
* _detach is called to deconfigure a device. It should deallocate
* resources.
* This function is also called when _attach() fails, so it should be
* careful not to release resources that were not necessarily
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
static int pci6208_detach(struct comedi_device *dev)
{
printk(KERN_INFO "comedi%d: pci6208: remove\n", dev->minor);
if (devpriv && devpriv->pci_dev) {
if (dev->iobase)
comedi_pci_disable(devpriv->pci_dev);
pci_dev_put(devpriv->pci_dev);
}
return 0;
}
static int pci6208_ao_winsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
......@@ -442,6 +280,125 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
return 0;
}
static int pci6208_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
int retval;
unsigned long io_base;
printk(KERN_INFO "comedi%d: pci6208: ", dev->minor);
retval = alloc_private(dev, sizeof(struct pci6208_private));
if (retval < 0)
return retval;
retval = pci6208_find_device(dev, it->options[0], it->options[1]);
if (retval < 0)
return retval;
retval = pci6208_pci_setup(devpriv->pci_dev, &io_base, dev->minor);
if (retval < 0)
return retval;
dev->iobase = io_base;
dev->board_name = thisboard->name;
if (alloc_subdevices(dev, 2) < 0)
return -ENOMEM;
s = dev->subdevices + 0;
/* analog output subdevice */
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE; /* anything else to add here?? */
s->n_chan = thisboard->ao_chans;
s->maxdata = 0xffff; /* 16-bit DAC */
s->range_table = &range_bipolar10; /* this needs to be checked. */
s->insn_write = pci6208_ao_winsn;
s->insn_read = pci6208_ao_rinsn;
/* s=dev->subdevices+1; */
/* digital i/o subdevice */
/* s->type=COMEDI_SUBD_DIO; */
/* s->subdev_flags=SDF_READABLE|SDF_WRITABLE; */
/* s->n_chan=16; */
/* s->maxdata=1; */
/* s->range_table=&range_digital; */
/* s->insn_bits = pci6208_dio_insn_bits; */
/* s->insn_config = pci6208_dio_insn_config; */
printk(KERN_INFO "attached\n");
return 1;
}
static int pci6208_detach(struct comedi_device *dev)
{
printk(KERN_INFO "comedi%d: pci6208: remove\n", dev->minor);
if (devpriv && devpriv->pci_dev) {
if (dev->iobase)
comedi_pci_disable(devpriv->pci_dev);
pci_dev_put(devpriv->pci_dev);
}
return 0;
}
static struct comedi_driver driver_pci6208 = {
.driver_name = PCI6208_DRIVER_NAME,
.module = THIS_MODULE,
.attach = pci6208_attach,
.detach = pci6208_detach,
};
static int __devinit driver_pci6208_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, &driver_pci6208);
}
static void __devexit driver_pci6208_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
/* This is used by modprobe to translate PCI IDs to drivers. Should
* only be used for PCI and ISA-PnP devices */
static DEFINE_PCI_DEVICE_TABLE(pci6208_pci_table) = {
/* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
/* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, 0x6208) },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, pci6208_pci_table);
static struct pci_driver driver_pci6208_pci_driver = {
.id_table = pci6208_pci_table,
.probe = driver_pci6208_pci_probe,
.remove = __devexit_p(driver_pci6208_pci_remove),
};
static int __init driver_pci6208_init_module(void)
{
int retval;
retval = comedi_driver_register(&driver_pci6208);
if (retval < 0)
return retval;
driver_pci6208_pci_driver.name = (char *)driver_pci6208.driver_name;
return pci_register_driver(&driver_pci6208_pci_driver);
}
module_init(driver_pci6208_init_module);
static void __exit driver_pci6208_cleanup_module(void)
{
pci_unregister_driver(&driver_pci6208_pci_driver);
comedi_driver_unregister(&driver_pci6208);
}
module_exit(driver_pci6208_cleanup_module);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
......@@ -43,13 +43,6 @@ Configuration Options:
#define PCI_DEVICE_ID_PCI7230 0x7230
static DEFINE_PCI_DEVICE_TABLE(adl_pci7230_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7230) },
{0}
};
MODULE_DEVICE_TABLE(pci, adl_pci7230_pci_table);
struct adl_pci7230_private {
int data;
struct pci_dev *pci_dev;
......@@ -57,27 +50,36 @@ struct adl_pci7230_private {
#define devpriv ((struct adl_pci7230_private *)dev->private)
static int adl_pci7230_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int adl_pci7230_detach(struct comedi_device *dev);
static struct comedi_driver driver_adl_pci7230 = {
.driver_name = "adl_pci7230",
.module = THIS_MODULE,
.attach = adl_pci7230_attach,
.detach = adl_pci7230_detach,
};
static int adl_pci7230_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
/* Digital IO */
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
outl((s->state << 16) & 0xffffffff, dev->iobase + PCI7230_DO);
}
return 2;
}
static int adl_pci7230_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
static int adl_pci7230_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
data[1] = inl(dev->iobase + PCI7230_DI) & 0xffffffff;
return 2;
}
static int adl_pci7230_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
......@@ -161,42 +163,18 @@ static int adl_pci7230_detach(struct comedi_device *dev)
return 0;
}
static int adl_pci7230_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
outl((s->state << 16) & 0xffffffff, dev->iobase + PCI7230_DO);
}
return 2;
}
static int adl_pci7230_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
data[1] = inl(dev->iobase + PCI7230_DI) & 0xffffffff;
return 2;
}
static struct comedi_driver driver_adl_pci7230 = {
.driver_name = "adl_pci7230",
.module = THIS_MODULE,
.attach = adl_pci7230_attach,
.detach = adl_pci7230_detach,
};
static int __devinit driver_adl_pci7230_pci_probe(struct pci_dev *dev,
const struct pci_device_id
*ent)
{
return comedi_pci_auto_config(dev, driver_adl_pci7230.driver_name);
return comedi_pci_auto_config(dev, &driver_adl_pci7230);
}
static void __devexit driver_adl_pci7230_pci_remove(struct pci_dev *dev)
......@@ -204,10 +182,16 @@ static void __devexit driver_adl_pci7230_pci_remove(struct pci_dev *dev)
comedi_pci_auto_unconfig(dev);
}
static DEFINE_PCI_DEVICE_TABLE(adl_pci7230_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7230) },
{0}
};
MODULE_DEVICE_TABLE(pci, adl_pci7230_pci_table);
static struct pci_driver driver_adl_pci7230_pci_driver = {
.id_table = adl_pci7230_pci_table,
.probe = &driver_adl_pci7230_pci_probe,
.remove = __devexit_p(&driver_adl_pci7230_pci_remove)
.id_table = adl_pci7230_pci_table,
.probe = driver_adl_pci7230_pci_probe,
.remove = __devexit_p(driver_adl_pci7230_pci_remove)
};
static int __init driver_adl_pci7230_init_module(void)
......@@ -222,14 +206,13 @@ static int __init driver_adl_pci7230_init_module(void)
(char *)driver_adl_pci7230.driver_name;
return pci_register_driver(&driver_adl_pci7230_pci_driver);
}
module_init(driver_adl_pci7230_init_module);
static void __exit driver_adl_pci7230_cleanup_module(void)
{
pci_unregister_driver(&driver_adl_pci7230_pci_driver);
comedi_driver_unregister(&driver_adl_pci7230);
}
module_init(driver_adl_pci7230_init_module);
module_exit(driver_adl_pci7230_cleanup_module);
MODULE_AUTHOR("Comedi http://www.comedi.org");
......
......@@ -48,13 +48,6 @@ Configuration Options:
#define PCI_DEVICE_ID_PCI7296 0x7296
static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296) },
{0}
};
MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table);
struct adl_pci7296_private {
int data;
struct pci_dev *pci_dev;
......@@ -62,16 +55,6 @@ struct adl_pci7296_private {
#define devpriv ((struct adl_pci7296_private *)dev->private)
static int adl_pci7296_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int adl_pci7296_detach(struct comedi_device *dev);
static struct comedi_driver driver_adl_pci7296 = {
.driver_name = "adl_pci7296",
.module = THIS_MODULE,
.attach = adl_pci7296_attach,
.detach = adl_pci7296_detach,
};
static int adl_pci7296_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
......@@ -172,11 +155,18 @@ static int adl_pci7296_detach(struct comedi_device *dev)
return 0;
}
static struct comedi_driver driver_adl_pci7296 = {
.driver_name = "adl_pci7296",
.module = THIS_MODULE,
.attach = adl_pci7296_attach,
.detach = adl_pci7296_detach,
};
static int __devinit driver_adl_pci7296_pci_probe(struct pci_dev *dev,
const struct pci_device_id
*ent)
{
return comedi_pci_auto_config(dev, driver_adl_pci7296.driver_name);
return comedi_pci_auto_config(dev, &driver_adl_pci7296);
}
static void __devexit driver_adl_pci7296_pci_remove(struct pci_dev *dev)
......@@ -184,10 +174,16 @@ static void __devexit driver_adl_pci7296_pci_remove(struct pci_dev *dev)
comedi_pci_auto_unconfig(dev);
}
static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296) },
{0}
};
MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table);
static struct pci_driver driver_adl_pci7296_pci_driver = {
.id_table = adl_pci7296_pci_table,
.probe = &driver_adl_pci7296_pci_probe,
.remove = __devexit_p(&driver_adl_pci7296_pci_remove)
.id_table = adl_pci7296_pci_table,
.probe = driver_adl_pci7296_pci_probe,
.remove = __devexit_p(driver_adl_pci7296_pci_remove)
};
static int __init driver_adl_pci7296_init_module(void)
......@@ -202,14 +198,13 @@ static int __init driver_adl_pci7296_init_module(void)
(char *)driver_adl_pci7296.driver_name;
return pci_register_driver(&driver_adl_pci7296_pci_driver);
}
module_init(driver_adl_pci7296_init_module);
static void __exit driver_adl_pci7296_cleanup_module(void)
{
pci_unregister_driver(&driver_adl_pci7296_pci_driver);
comedi_driver_unregister(&driver_adl_pci7296);
}
module_init(driver_adl_pci7296_init_module);
module_exit(driver_adl_pci7296_cleanup_module);
MODULE_AUTHOR("Comedi http://www.comedi.org");
......
......@@ -43,13 +43,6 @@ Configuration Options:
#define PCI_DEVICE_ID_PCI7432 0x7432
static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432) },
{0}
};
MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table);
struct adl_pci7432_private {
int data;
struct pci_dev *pci_dev;
......@@ -57,29 +50,44 @@ struct adl_pci7432_private {
#define devpriv ((struct adl_pci7432_private *)dev->private)
static int adl_pci7432_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int adl_pci7432_detach(struct comedi_device *dev);
static struct comedi_driver driver_adl_pci7432 = {
.driver_name = "adl_pci7432",
.module = THIS_MODULE,
.attach = adl_pci7432_attach,
.detach = adl_pci7432_detach,
};
static int adl_pci7432_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
printk(KERN_DEBUG "comedi: pci7432_do_insn_bits called\n");
printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]);
if (insn->n != 2)
return -EINVAL;
/* Digital IO */
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
printk(KERN_DEBUG "comedi: out: %8x on iobase %4lx\n", s->state,
dev->iobase + PCI7432_DO);
outl(s->state & 0xffffffff, dev->iobase + PCI7432_DO);
}
return 2;
}
static int adl_pci7432_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
unsigned int *data)
{
printk(KERN_DEBUG "comedi: pci7432_di_insn_bits called\n");
printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]);
static int adl_pci7432_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
if (insn->n != 2)
return -EINVAL;
/* */
data[1] = inl(dev->iobase + PCI7432_DI) & 0xffffffff;
printk(KERN_DEBUG "comedi: data1 %8x\n", data[1]);
return 2;
}
static int adl_pci7432_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
......@@ -166,50 +174,18 @@ static int adl_pci7432_detach(struct comedi_device *dev)
return 0;
}
static int adl_pci7432_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
printk(KERN_DEBUG "comedi: pci7432_do_insn_bits called\n");
printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]);
if (insn->n != 2)
return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
printk(KERN_DEBUG "comedi: out: %8x on iobase %4lx\n", s->state,
dev->iobase + PCI7432_DO);
outl(s->state & 0xffffffff, dev->iobase + PCI7432_DO);
}
return 2;
}
static int adl_pci7432_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
printk(KERN_DEBUG "comedi: pci7432_di_insn_bits called\n");
printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]);
if (insn->n != 2)
return -EINVAL;
data[1] = inl(dev->iobase + PCI7432_DI) & 0xffffffff;
printk(KERN_DEBUG "comedi: data1 %8x\n", data[1]);
return 2;
}
static struct comedi_driver driver_adl_pci7432 = {
.driver_name = "adl_pci7432",
.module = THIS_MODULE,
.attach = adl_pci7432_attach,
.detach = adl_pci7432_detach,
};
static int __devinit driver_adl_pci7432_pci_probe(struct pci_dev *dev,
const struct pci_device_id
*ent)
{
return comedi_pci_auto_config(dev, driver_adl_pci7432.driver_name);
return comedi_pci_auto_config(dev, &driver_adl_pci7432);
}
static void __devexit driver_adl_pci7432_pci_remove(struct pci_dev *dev)
......@@ -217,10 +193,16 @@ static void __devexit driver_adl_pci7432_pci_remove(struct pci_dev *dev)
comedi_pci_auto_unconfig(dev);
}
static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432) },
{0}
};
MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table);
static struct pci_driver driver_adl_pci7432_pci_driver = {
.id_table = adl_pci7432_pci_table,
.probe = &driver_adl_pci7432_pci_probe,
.remove = __devexit_p(&driver_adl_pci7432_pci_remove)
.id_table = adl_pci7432_pci_table,
.probe = driver_adl_pci7432_pci_probe,
.remove = __devexit_p(driver_adl_pci7432_pci_remove)
};
static int __init driver_adl_pci7432_init_module(void)
......@@ -235,14 +217,13 @@ static int __init driver_adl_pci7432_init_module(void)
(char *)driver_adl_pci7432.driver_name;
return pci_register_driver(&driver_adl_pci7432_pci_driver);
}
module_init(driver_adl_pci7432_init_module);
static void __exit driver_adl_pci7432_cleanup_module(void)
{
pci_unregister_driver(&driver_adl_pci7432_pci_driver);
comedi_driver_unregister(&driver_adl_pci7432);
}
module_init(driver_adl_pci7432_init_module);
module_exit(driver_adl_pci7432_cleanup_module);
MODULE_AUTHOR("Comedi http://www.comedi.org");
......
......@@ -56,13 +56,6 @@ Configuration Options:
#define PCI_DEVICE_ID_PCI8164 0x8164
static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164) },
{0}
};
MODULE_DEVICE_TABLE(pci, adl_pci8164_pci_table);
struct adl_pci8164_private {
int data;
struct pci_dev *pci_dev;
......@@ -70,159 +63,6 @@ struct adl_pci8164_private {
#define devpriv ((struct adl_pci8164_private *)dev->private)
static int adl_pci8164_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int adl_pci8164_detach(struct comedi_device *dev);
static struct comedi_driver driver_adl_pci8164 = {
.driver_name = "adl_pci8164",
.module = THIS_MODULE,
.attach = adl_pci8164_attach,
.detach = adl_pci8164_detach,
};
static int adl_pci8164_insn_read_msts(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
static int adl_pci8164_insn_read_ssts(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
static int adl_pci8164_insn_read_buf0(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
static int adl_pci8164_insn_read_buf1(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
static int adl_pci8164_insn_write_cmd(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
static int adl_pci8164_insn_write_otp(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
static int adl_pci8164_insn_write_buf0(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
static int adl_pci8164_insn_write_buf1(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data);
static int adl_pci8164_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct pci_dev *pcidev = NULL;
struct comedi_subdevice *s;
int bus, slot;
printk(KERN_INFO "comedi: attempt to attach...\n");
printk(KERN_INFO "comedi%d: adl_pci8164\n", dev->minor);
dev->board_name = "pci8164";
bus = it->options[0];
slot = it->options[1];
if (alloc_private(dev, sizeof(struct adl_pci8164_private)) < 0)
return -ENOMEM;
if (alloc_subdevices(dev, 4) < 0)
return -ENOMEM;
for_each_pci_dev(pcidev) {
if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
pcidev->device == PCI_DEVICE_ID_PCI8164) {
if (bus || slot) {
/* requested particular bus/slot */
if (pcidev->bus->number != bus
|| PCI_SLOT(pcidev->devfn) != slot)
continue;
}
devpriv->pci_dev = pcidev;
if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) {
printk(KERN_ERR "comedi%d: Failed to enable "
"PCI device and request regions\n", dev->minor);
return -EIO;
}
dev->iobase = pci_resource_start(pcidev, 2);
printk(KERN_DEBUG "comedi: base addr %4lx\n",
dev->iobase);
s = dev->subdevices + 0;
s->type = COMEDI_SUBD_PROC;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
/* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_msts;
s->insn_write = adl_pci8164_insn_write_cmd;
s = dev->subdevices + 1;
s->type = COMEDI_SUBD_PROC;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
/* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_ssts;
s->insn_write = adl_pci8164_insn_write_otp;
s = dev->subdevices + 2;
s->type = COMEDI_SUBD_PROC;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
/* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_buf0;
s->insn_write = adl_pci8164_insn_write_buf0;
s = dev->subdevices + 3;
s->type = COMEDI_SUBD_PROC;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
/* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_buf1;
s->insn_write = adl_pci8164_insn_write_buf1;
printk(KERN_INFO "comedi: attached\n");
return 1;
}
}
printk(KERN_ERR "comedi%d: no supported board found!"
"(req. bus/slot : %d/%d)\n", dev->minor, bus, slot);
return -EIO;
}
static int adl_pci8164_detach(struct comedi_device *dev)
{
printk(KERN_INFO "comedi%d: pci8164: remove\n", dev->minor);
if (devpriv && devpriv->pci_dev) {
if (dev->iobase)
comedi_pci_disable(devpriv->pci_dev);
pci_dev_put(devpriv->pci_dev);
}
return 0;
}
/*
all the read commands are the same except for the addition a constant
* const to the data for inw()
......@@ -384,11 +224,121 @@ static int adl_pci8164_insn_write_buf1(struct comedi_device *dev,
return 2;
}
static int adl_pci8164_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct pci_dev *pcidev = NULL;
struct comedi_subdevice *s;
int bus, slot;
printk(KERN_INFO "comedi: attempt to attach...\n");
printk(KERN_INFO "comedi%d: adl_pci8164\n", dev->minor);
dev->board_name = "pci8164";
bus = it->options[0];
slot = it->options[1];
if (alloc_private(dev, sizeof(struct adl_pci8164_private)) < 0)
return -ENOMEM;
if (alloc_subdevices(dev, 4) < 0)
return -ENOMEM;
for_each_pci_dev(pcidev) {
if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
pcidev->device == PCI_DEVICE_ID_PCI8164) {
if (bus || slot) {
/* requested particular bus/slot */
if (pcidev->bus->number != bus
|| PCI_SLOT(pcidev->devfn) != slot)
continue;
}
devpriv->pci_dev = pcidev;
if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) {
printk(KERN_ERR "comedi%d: Failed to enable "
"PCI device and request regions\n", dev->minor);
return -EIO;
}
dev->iobase = pci_resource_start(pcidev, 2);
printk(KERN_DEBUG "comedi: base addr %4lx\n",
dev->iobase);
s = dev->subdevices + 0;
s->type = COMEDI_SUBD_PROC;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
/* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_msts;
s->insn_write = adl_pci8164_insn_write_cmd;
s = dev->subdevices + 1;
s->type = COMEDI_SUBD_PROC;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
/* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_ssts;
s->insn_write = adl_pci8164_insn_write_otp;
s = dev->subdevices + 2;
s->type = COMEDI_SUBD_PROC;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
/* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_buf0;
s->insn_write = adl_pci8164_insn_write_buf0;
s = dev->subdevices + 3;
s->type = COMEDI_SUBD_PROC;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 0xffff;
s->len_chanlist = 4;
/* s->range_table = &range_axis; */
s->insn_read = adl_pci8164_insn_read_buf1;
s->insn_write = adl_pci8164_insn_write_buf1;
printk(KERN_INFO "comedi: attached\n");
return 1;
}
}
printk(KERN_ERR "comedi%d: no supported board found!"
"(req. bus/slot : %d/%d)\n", dev->minor, bus, slot);
return -EIO;
}
static int adl_pci8164_detach(struct comedi_device *dev)
{
printk(KERN_INFO "comedi%d: pci8164: remove\n", dev->minor);
if (devpriv && devpriv->pci_dev) {
if (dev->iobase)
comedi_pci_disable(devpriv->pci_dev);
pci_dev_put(devpriv->pci_dev);
}
return 0;
}
static struct comedi_driver driver_adl_pci8164 = {
.driver_name = "adl_pci8164",
.module = THIS_MODULE,
.attach = adl_pci8164_attach,
.detach = adl_pci8164_detach,
};
static int __devinit driver_adl_pci8164_pci_probe(struct pci_dev *dev,
const struct pci_device_id
*ent)
{
return comedi_pci_auto_config(dev, driver_adl_pci8164.driver_name);
return comedi_pci_auto_config(dev, &driver_adl_pci8164);
}
static void __devexit driver_adl_pci8164_pci_remove(struct pci_dev *dev)
......@@ -396,10 +346,16 @@ static void __devexit driver_adl_pci8164_pci_remove(struct pci_dev *dev)
comedi_pci_auto_unconfig(dev);
}
static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164) },
{0}
};
MODULE_DEVICE_TABLE(pci, adl_pci8164_pci_table);
static struct pci_driver driver_adl_pci8164_pci_driver = {
.id_table = adl_pci8164_pci_table,
.probe = &driver_adl_pci8164_pci_probe,
.remove = __devexit_p(&driver_adl_pci8164_pci_remove)
.id_table = adl_pci8164_pci_table,
.probe = driver_adl_pci8164_pci_probe,
.remove = __devexit_p(driver_adl_pci8164_pci_remove),
};
static int __init driver_adl_pci8164_init_module(void)
......@@ -414,14 +370,13 @@ static int __init driver_adl_pci8164_init_module(void)
(char *)driver_adl_pci8164.driver_name;
return pci_register_driver(&driver_adl_pci8164_pci_driver);
}
module_init(driver_adl_pci8164_init_module);
static void __exit driver_adl_pci8164_cleanup_module(void)
{
pci_unregister_driver(&driver_adl_pci8164_pci_driver);
comedi_driver_unregister(&driver_adl_pci8164);
}
module_init(driver_adl_pci8164_init_module);
module_exit(driver_adl_pci8164_cleanup_module);
MODULE_AUTHOR("Comedi http://www.comedi.org");
......
......@@ -289,16 +289,6 @@ a multiple of chanlist_len*convert_arg.
PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2); \
} while (0)
/* Function prototypes */
static int pci9111_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int pci9111_detach(struct comedi_device *dev);
static void pci9111_ai_munge(struct comedi_device *dev,
struct comedi_subdevice *s, void *data,
unsigned int num_bytes,
unsigned int start_chan_index);
static const struct comedi_lrange pci9111_hr_ai_range = {
5,
{
......@@ -310,14 +300,6 @@ static const struct comedi_lrange pci9111_hr_ai_range = {
}
};
static DEFINE_PCI_DEVICE_TABLE(pci9111_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID) },
/* { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID) }, */
{ 0 }
};
MODULE_DEVICE_TABLE(pci, pci9111_pci_table);
/* */
/* Board specification structure */
/* */
......@@ -354,51 +336,6 @@ static const struct pci9111_board pci9111_boards[] = {
#define pci9111_board_nbr \
(sizeof(pci9111_boards)/sizeof(struct pci9111_board))
static struct comedi_driver pci9111_driver = {
.driver_name = PCI9111_DRIVER_NAME,
.module = THIS_MODULE,
.attach = pci9111_attach,
.detach = pci9111_detach,
};
static int __devinit pci9111_driver_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, pci9111_driver.driver_name);
}
static void __devexit pci9111_driver_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
static struct pci_driver pci9111_driver_pci_driver = {
.id_table = pci9111_pci_table,
.probe = &pci9111_driver_pci_probe,
.remove = __devexit_p(&pci9111_driver_pci_remove)
};
static int __init pci9111_driver_init_module(void)
{
int retval;
retval = comedi_driver_register(&pci9111_driver);
if (retval < 0)
return retval;
pci9111_driver_pci_driver.name = (char *)pci9111_driver.driver_name;
return pci_register_driver(&pci9111_driver_pci_driver);
}
static void __exit pci9111_driver_cleanup_module(void)
{
pci_unregister_driver(&pci9111_driver_pci_driver);
comedi_driver_unregister(&pci9111_driver);
}
module_init(pci9111_driver_init_module);
module_exit(pci9111_driver_cleanup_module);
/* Private data structure */
struct pci9111_private_data {
......@@ -1470,6 +1407,57 @@ static int pci9111_detach(struct comedi_device *dev)
return 0;
}
static struct comedi_driver pci9111_driver = {
.driver_name = PCI9111_DRIVER_NAME,
.module = THIS_MODULE,
.attach = pci9111_attach,
.detach = pci9111_detach,
};
static int __devinit pci9111_driver_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, &pci9111_driver);
}
static void __devexit pci9111_driver_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
static DEFINE_PCI_DEVICE_TABLE(pci9111_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID) },
/* { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID) }, */
{ 0 }
};
MODULE_DEVICE_TABLE(pci, pci9111_pci_table);
static struct pci_driver pci9111_driver_pci_driver = {
.id_table = pci9111_pci_table,
.probe = pci9111_driver_pci_probe,
.remove = __devexit_p(pci9111_driver_pci_remove),
};
static int __init pci9111_driver_init_module(void)
{
int retval;
retval = comedi_driver_register(&pci9111_driver);
if (retval < 0)
return retval;
pci9111_driver_pci_driver.name = (char *)pci9111_driver.driver_name;
return pci_register_driver(&pci9111_driver_pci_driver);
}
module_init(pci9111_driver_init_module);
static void __exit pci9111_driver_cleanup_module(void)
{
pci_unregister_driver(&pci9111_driver_pci_driver);
comedi_driver_unregister(&pci9111_driver);
}
module_exit(pci9111_driver_cleanup_module);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
......@@ -277,14 +277,12 @@ static const struct boardtype boardtypes[] = {
10000, 40, 512},
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
static struct comedi_driver driver_pci9118 = {
.driver_name = "adl_pci9118",
.module = THIS_MODULE,
.attach = pci9118_attach,
.detach = pci9118_detach,
.num_names = n_boardtypes,
.num_names = ARRAY_SIZE(boardtypes),
.board_name = &boardtypes[0].name,
.offset = sizeof(struct boardtype),
};
......@@ -292,7 +290,7 @@ static struct comedi_driver driver_pci9118 = {
static int __devinit driver_pci9118_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, driver_pci9118.driver_name);
return comedi_pci_auto_config(dev, &driver_pci9118);
}
static void __devexit driver_pci9118_pci_remove(struct pci_dev *dev)
......
......@@ -264,14 +264,12 @@ static const struct boardtype boardtypes[] = {
{.name = DRV_NAME},
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
static struct comedi_driver driver_pci1710 = {
.driver_name = DRV_NAME,
.module = THIS_MODULE,
.attach = pci1710_attach,
.detach = pci1710_detach,
.num_names = n_boardtypes,
.num_names = ARRAY_SIZE(boardtypes),
.board_name = &boardtypes[0].name,
.offset = sizeof(struct boardtype),
};
......@@ -676,7 +674,9 @@ static void interrupt_pci1710_every_sample(void *d)
s->async->buf_int_count, s->async->buf_int_ptr,
s->async->buf_user_count, s->async->buf_user_ptr);
DPRINTK("adv_pci1710 EDBG: EOS2\n");
if ((!devpriv->neverending_ai) && (devpriv->ai_act_scan >= devpriv->ai_scans)) { /* all data sampled */
if ((!devpriv->neverending_ai) &&
(devpriv->ai_act_scan >= devpriv->ai_scans)) {
/* all data sampled */
pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
......@@ -804,8 +804,8 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d)
irq);
if (!dev->attached) /* is device attached? */
return IRQ_NONE; /* no, exit */
if (!(inw(dev->iobase + PCI171x_STATUS) & Status_IRQ)) /* is this interrupt from our board? */
/* is this interrupt from our board? */
if (!(inw(dev->iobase + PCI171x_STATUS) & Status_IRQ))
return IRQ_NONE; /* no, exit */
DPRINTK("adv_pci1710 EDBG: interrupt_service_pci1710() ST: %4x\n",
......@@ -814,7 +814,7 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d)
if (devpriv->ai_et) { /* Switch from initial TRIG_EXT to TRIG_xxx. */
devpriv->ai_et = 0;
devpriv->CntrlReg &= Control_CNT0;
devpriv->CntrlReg |= Control_SW; /* set software trigger */
devpriv->CntrlReg |= Control_SW; /* set software trigger */
outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
devpriv->CntrlReg = devpriv->ai_et_CntrlReg;
outb(0, dev->iobase + PCI171x_CLRFIFO);
......@@ -865,7 +865,8 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
devpriv->neverending_ai = 0;
devpriv->CntrlReg &= Control_CNT0;
if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { /* don't we want wake up every scan? devpriv->ai_eos=1; */
/* don't we want wake up every scan? devpriv->ai_eos=1; */
if ((devpriv->ai_flags & TRIG_WAKE_EOS)) {
devpriv->ai_eos = 1;
} else {
devpriv->CntrlReg |= Control_ONEFH;
......@@ -982,13 +983,13 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
#ifdef PCI171X_EXTDEBUG
pci171x_cmdtest_out(1, cmd);
#endif
DPRINTK
("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=1\n",
err);
DPRINTK(
"adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=1\n",
err);
return 1;
}
/* step 2: make sure trigger sources are unique and mutually compatible */
/* step2: make sure trigger srcs are unique and mutually compatible */
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) {
cmd->start_src = TRIG_NOW;
......@@ -1015,9 +1016,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
#ifdef PCI171X_EXTDEBUG
pci171x_cmdtest_out(2, cmd);
#endif
DPRINTK
("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=2\n",
err);
DPRINTK(
"adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=2\n",
err);
return 2;
}
......@@ -1065,9 +1066,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
#ifdef PCI171X_EXTDEBUG
pci171x_cmdtest_out(3, cmd);
#endif
DPRINTK
("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=3\n",
err);
DPRINTK(
"adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=3\n",
err);
return 3;
}
......@@ -1398,13 +1399,13 @@ static int pci1710_attach(struct comedi_device *dev,
while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH,
PCI_ANY_ID, pcidev))) {
if (strcmp(this_board->name, DRV_NAME) == 0) {
for (i = 0; i < n_boardtypes; ++i) {
for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
if (pcidev->device == boardtypes[i].device_id) {
board_index = i;
break;
}
}
if (i == n_boardtypes)
if (i == ARRAY_SIZE(boardtypes))
continue;
} else {
if (pcidev->device != boardtypes[board_index].device_id)
......@@ -1612,7 +1613,7 @@ static int pci1710_detach(struct comedi_device *dev)
static int __devinit driver_pci1710_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, driver_pci1710.driver_name);
return comedi_pci_auto_config(dev, &driver_pci1710);
}
static void __devexit driver_pci1710_pci_remove(struct pci_dev *dev)
......
......@@ -406,8 +406,6 @@ static const struct dio_boardtype boardtypes[] = {
IO_16b}
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct dio_boardtype))
static struct comedi_driver driver_pci_dio = {
.driver_name = "adv_pci_dio",
.module = THIS_MODULE,
......@@ -1134,7 +1132,7 @@ static int pci_dio_attach(struct comedi_device *dev,
for_each_pci_dev(pcidev) {
/* loop through cards supported by this driver */
for (i = 0; i < n_boardtypes; ++i) {
for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
if (boardtypes[i].vendor_id != pcidev->vendor)
continue;
if (boardtypes[i].device_id != pcidev->device)
......@@ -1319,7 +1317,7 @@ static int pci_dio_detach(struct comedi_device *dev)
static int __devinit driver_pci_dio_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
return comedi_pci_auto_config(dev, driver_pci_dio.driver_name);
return comedi_pci_auto_config(dev, &driver_pci_dio);
}
static void __devexit driver_pci_dio_pci_remove(struct pci_dev *dev)
......
......@@ -618,7 +618,7 @@ static int __devinit driver_amplc_pci230_pci_probe(struct pci_dev *dev,
const struct pci_device_id
*ent)
{
return comedi_pci_auto_config(dev, driver_amplc_pci230.driver_name);
return comedi_pci_auto_config(dev, &driver_amplc_pci230);
}
static void __devexit driver_amplc_pci230_pci_remove(struct pci_dev *dev)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册