0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/module.h>
0011 #include <linux/init.h>
0012 #include <linux/device.h>
0013 #include <linux/string.h>
0014 #include <sound/ac97_codec.h>
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 static bool snd_ac97_check_id(struct snd_ac97 *ac97, unsigned int id,
0027 unsigned int id_mask)
0028 {
0029 ac97->id = ac97->bus->ops->read(ac97, AC97_VENDOR_ID1) << 16;
0030 ac97->id |= ac97->bus->ops->read(ac97, AC97_VENDOR_ID2);
0031
0032 if (ac97->id == 0x0 || ac97->id == 0xffffffff)
0033 return false;
0034
0035 if (id != 0 && id != (ac97->id & id_mask))
0036 return false;
0037
0038 return true;
0039 }
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id,
0056 unsigned int id_mask)
0057 {
0058 const struct snd_ac97_bus_ops *ops = ac97->bus->ops;
0059
0060 if (try_warm && ops->warm_reset) {
0061 ops->warm_reset(ac97);
0062 if (snd_ac97_check_id(ac97, id, id_mask))
0063 return 1;
0064 }
0065
0066 if (ops->reset)
0067 ops->reset(ac97);
0068 if (ops->warm_reset)
0069 ops->warm_reset(ac97);
0070
0071 if (snd_ac97_check_id(ac97, id, id_mask))
0072 return 0;
0073
0074 return -ENODEV;
0075 }
0076 EXPORT_SYMBOL_GPL(snd_ac97_reset);
0077
0078
0079
0080
0081
0082
0083 static int ac97_bus_match(struct device *dev, struct device_driver *drv)
0084 {
0085 return 1;
0086 }
0087
0088 struct bus_type ac97_bus_type = {
0089 .name = "ac97",
0090 .match = ac97_bus_match,
0091 };
0092
0093 static int __init ac97_bus_init(void)
0094 {
0095 return bus_register(&ac97_bus_type);
0096 }
0097
0098 subsys_initcall(ac97_bus_init);
0099
0100 static void __exit ac97_bus_exit(void)
0101 {
0102 bus_unregister(&ac97_bus_type);
0103 }
0104
0105 module_exit(ac97_bus_exit);
0106
0107 EXPORT_SYMBOL(ac97_bus_type);
0108
0109 MODULE_LICENSE("GPL");