cpuset: use seq_*mask_* to print masks
[linux-2.6.git] / sound / i2c / i2c.c
index e4e505b9d88bbe75b02cdc74384384b2e0d384b3..5c0c77dd01c30f8a0a584dac38bb13fecd8edc59 100644 (file)
@@ -2,7 +2,7 @@
  *   Generic i2c interface for ALSA
  *
  *   (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
- *   Modified for the ALSA driver by Jaroslav Kysela <perex@suse.cz>
+ *   Modified for the ALSA driver by Jaroslav Kysela <perex@perex.cz>
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -20,7 +20,6 @@
  *
  */
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <sound/core.h>
 #include <sound/i2c.h>
 
-MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
+MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Generic i2c interface for ALSA");
 MODULE_LICENSE("GPL");
 
-static int snd_i2c_bit_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count);
-static int snd_i2c_bit_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count);
-static int snd_i2c_bit_probeaddr(snd_i2c_bus_t *bus, unsigned short addr);
+static int snd_i2c_bit_sendbytes(struct snd_i2c_device *device,
+                                unsigned char *bytes, int count);
+static int snd_i2c_bit_readbytes(struct snd_i2c_device *device,
+                                unsigned char *bytes, int count);
+static int snd_i2c_bit_probeaddr(struct snd_i2c_bus *bus,
+                                unsigned short addr);
 
-static snd_i2c_ops_t snd_i2c_bit_ops = {
+static struct snd_i2c_ops snd_i2c_bit_ops = {
        .sendbytes = snd_i2c_bit_sendbytes,
        .readbytes = snd_i2c_bit_readbytes,
        .probeaddr = snd_i2c_bit_probeaddr,
 };
 
-static int snd_i2c_bus_free(snd_i2c_bus_t *bus)
+static int snd_i2c_bus_free(struct snd_i2c_bus *bus)
 {
-       snd_i2c_bus_t *slave;
-       snd_i2c_device_t *device;
+       struct snd_i2c_bus *slave;
+       struct snd_i2c_device *device;
 
-       snd_assert(bus != NULL, return -EINVAL);
+       if (snd_BUG_ON(!bus))
+               return -EINVAL;
        while (!list_empty(&bus->devices)) {
                device = snd_i2c_device(bus->devices.next);
                snd_i2c_device_free(device);
@@ -66,17 +69,18 @@ static int snd_i2c_bus_free(snd_i2c_bus_t *bus)
        return 0;
 }
 
-static int snd_i2c_bus_dev_free(snd_device_t *device)
+static int snd_i2c_bus_dev_free(struct snd_device *device)
 {
-       snd_i2c_bus_t *bus = device->device_data;
+       struct snd_i2c_bus *bus = device->device_data;
        return snd_i2c_bus_free(bus);
 }
 
-int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t *master, snd_i2c_bus_t **ri2c)
+int snd_i2c_bus_create(struct snd_card *card, const char *name,
+                      struct snd_i2c_bus *master, struct snd_i2c_bus **ri2c)
 {
-       snd_i2c_bus_t *bus;
+       struct snd_i2c_bus *bus;
        int err;
-       static snd_device_ops_t ops = {
+       static struct snd_device_ops ops = {
                .dev_free =     snd_i2c_bus_dev_free,
        };
 
@@ -84,7 +88,7 @@ int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t *master
        bus = kzalloc(sizeof(*bus), GFP_KERNEL);
        if (bus == NULL)
                return -ENOMEM;
-       init_MUTEX(&bus->lock_mutex);
+       mutex_init(&bus->lock_mutex);
        INIT_LIST_HEAD(&bus->devices);
        INIT_LIST_HEAD(&bus->buses);
        bus->card = card;
@@ -102,12 +106,16 @@ int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t *master
        return 0;
 }
 
-int snd_i2c_device_create(snd_i2c_bus_t *bus, const char *name, unsigned char addr, snd_i2c_device_t **rdevice)
+EXPORT_SYMBOL(snd_i2c_bus_create);
+
+int snd_i2c_device_create(struct snd_i2c_bus *bus, const char *name,
+                         unsigned char addr, struct snd_i2c_device **rdevice)
 {
-       snd_i2c_device_t *device;
+       struct snd_i2c_device *device;
 
        *rdevice = NULL;
-       snd_assert(bus != NULL, return -EINVAL);
+       if (snd_BUG_ON(!bus))
+               return -EINVAL;
        device = kzalloc(sizeof(*device), GFP_KERNEL);
        if (device == NULL)
                return -ENOMEM;
@@ -119,7 +127,9 @@ int snd_i2c_device_create(snd_i2c_bus_t *bus, const char *name, unsigned char ad
        return 0;
 }
 
-int snd_i2c_device_free(snd_i2c_device_t *device)
+EXPORT_SYMBOL(snd_i2c_device_create);
+
+int snd_i2c_device_free(struct snd_i2c_device *device)
 {
        if (device->bus)
                list_del(&device->list);
@@ -129,51 +139,58 @@ int snd_i2c_device_free(snd_i2c_device_t *device)
        return 0;
 }
 
-int snd_i2c_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count)
+EXPORT_SYMBOL(snd_i2c_device_free);
+
+int snd_i2c_sendbytes(struct snd_i2c_device *device, unsigned char *bytes, int count)
 {
        return device->bus->ops->sendbytes(device, bytes, count);
 }
 
+EXPORT_SYMBOL(snd_i2c_sendbytes);
 
-int snd_i2c_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count)
+int snd_i2c_readbytes(struct snd_i2c_device *device, unsigned char *bytes, int count)
 {
        return device->bus->ops->readbytes(device, bytes, count);
 }
 
-int snd_i2c_probeaddr(snd_i2c_bus_t *bus, unsigned short addr)
+EXPORT_SYMBOL(snd_i2c_readbytes);
+
+int snd_i2c_probeaddr(struct snd_i2c_bus *bus, unsigned short addr)
 {
        return bus->ops->probeaddr(bus, addr);
 }
 
+EXPORT_SYMBOL(snd_i2c_probeaddr);
+
 /*
  *  bit-operations
  */
 
-static inline void snd_i2c_bit_hw_start(snd_i2c_bus_t *bus)
+static inline void snd_i2c_bit_hw_start(struct snd_i2c_bus *bus)
 {
        if (bus->hw_ops.bit->start)
                bus->hw_ops.bit->start(bus);
 }
 
-static inline void snd_i2c_bit_hw_stop(snd_i2c_bus_t *bus)
+static inline void snd_i2c_bit_hw_stop(struct snd_i2c_bus *bus)
 {
        if (bus->hw_ops.bit->stop)
                bus->hw_ops.bit->stop(bus);
 }
 
-static void snd_i2c_bit_direction(snd_i2c_bus_t *bus, int clock, int data)
+static void snd_i2c_bit_direction(struct snd_i2c_bus *bus, int clock, int data)
 {
        if (bus->hw_ops.bit->direction)
                bus->hw_ops.bit->direction(bus, clock, data);
 }
 
-static void snd_i2c_bit_set(snd_i2c_bus_t *bus, int clock, int data)
+static void snd_i2c_bit_set(struct snd_i2c_bus *bus, int clock, int data)
 {
        bus->hw_ops.bit->setlines(bus, clock, data);
 }
 
 #if 0
-static int snd_i2c_bit_clock(snd_i2c_bus_t *bus)
+static int snd_i2c_bit_clock(struct snd_i2c_bus *bus)
 {
        if (bus->hw_ops.bit->getclock)
                return bus->hw_ops.bit->getclock(bus);
@@ -181,12 +198,12 @@ static int snd_i2c_bit_clock(snd_i2c_bus_t *bus)
 }
 #endif
 
-static int snd_i2c_bit_data(snd_i2c_bus_t *bus, int ack)
+static int snd_i2c_bit_data(struct snd_i2c_bus *bus, int ack)
 {
        return bus->hw_ops.bit->getdata(bus, ack);
 }
 
-static void snd_i2c_bit_start(snd_i2c_bus_t *bus)
+static void snd_i2c_bit_start(struct snd_i2c_bus *bus)
 {
        snd_i2c_bit_hw_start(bus);
        snd_i2c_bit_direction(bus, 1, 1);       /* SCL - wr, SDA - wr */
@@ -195,7 +212,7 @@ static void snd_i2c_bit_start(snd_i2c_bus_t *bus)
        snd_i2c_bit_set(bus, 0, 0);
 }
 
-static void snd_i2c_bit_stop(snd_i2c_bus_t *bus)
+static void snd_i2c_bit_stop(struct snd_i2c_bus *bus)
 {
        snd_i2c_bit_set(bus, 0, 0);
        snd_i2c_bit_set(bus, 1, 0);
@@ -203,14 +220,14 @@ static void snd_i2c_bit_stop(snd_i2c_bus_t *bus)
        snd_i2c_bit_hw_stop(bus);
 }
 
-static void snd_i2c_bit_send(snd_i2c_bus_t *bus, int data)
+static void snd_i2c_bit_send(struct snd_i2c_bus *bus, int data)
 {
        snd_i2c_bit_set(bus, 0, data);
        snd_i2c_bit_set(bus, 1, data);
        snd_i2c_bit_set(bus, 0, data);
 }
 
-static int snd_i2c_bit_ack(snd_i2c_bus_t *bus)
+static int snd_i2c_bit_ack(struct snd_i2c_bus *bus)
 {
        int ack;
 
@@ -223,7 +240,7 @@ static int snd_i2c_bit_ack(snd_i2c_bus_t *bus)
        return ack ? -EIO : 0;
 }
 
-static int snd_i2c_bit_sendbyte(snd_i2c_bus_t *bus, unsigned char data)
+static int snd_i2c_bit_sendbyte(struct snd_i2c_bus *bus, unsigned char data)
 {
        int i, err;
 
@@ -234,7 +251,7 @@ static int snd_i2c_bit_sendbyte(snd_i2c_bus_t *bus, unsigned char data)
        return 0;
 }
 
-static int snd_i2c_bit_readbyte(snd_i2c_bus_t *bus, int last)
+static int snd_i2c_bit_readbyte(struct snd_i2c_bus *bus, int last)
 {
        int i;
        unsigned char data = 0;
@@ -252,9 +269,10 @@ static int snd_i2c_bit_readbyte(snd_i2c_bus_t *bus, int last)
        return data;
 }
 
-static int snd_i2c_bit_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count)
+static int snd_i2c_bit_sendbytes(struct snd_i2c_device *device,
+                                unsigned char *bytes, int count)
 {
-       snd_i2c_bus_t *bus = device->bus;
+       struct snd_i2c_bus *bus = device->bus;
        int err, res = 0;
 
        if (device->flags & SND_I2C_DEVICE_ADDRTEN)
@@ -275,9 +293,10 @@ static int snd_i2c_bit_sendbytes(snd_i2c_device_t *device, unsigned char *bytes,
        return res;
 }
 
-static int snd_i2c_bit_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count)
+static int snd_i2c_bit_readbytes(struct snd_i2c_device *device,
+                                unsigned char *bytes, int count)
 {
-       snd_i2c_bus_t *bus = device->bus;
+       struct snd_i2c_bus *bus = device->bus;
        int err, res = 0;
 
        if (device->flags & SND_I2C_DEVICE_ADDRTEN)
@@ -299,7 +318,7 @@ static int snd_i2c_bit_readbytes(snd_i2c_device_t *device, unsigned char *bytes,
        return res;
 }
 
-static int snd_i2c_bit_probeaddr(snd_i2c_bus_t *bus, unsigned short addr)
+static int snd_i2c_bit_probeaddr(struct snd_i2c_bus *bus, unsigned short addr)
 {
        int err;
 
@@ -313,12 +332,6 @@ static int snd_i2c_bit_probeaddr(snd_i2c_bus_t *bus, unsigned short addr)
        return err;
 }
 
-EXPORT_SYMBOL(snd_i2c_bus_create);
-EXPORT_SYMBOL(snd_i2c_device_create);
-EXPORT_SYMBOL(snd_i2c_device_free);
-EXPORT_SYMBOL(snd_i2c_sendbytes);
-EXPORT_SYMBOL(snd_i2c_readbytes);
-EXPORT_SYMBOL(snd_i2c_probeaddr);
 
 static int __init alsa_i2c_init(void)
 {