From 0f45aa18e65cf3d768082d7d86054a0d2a20bb18 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sun, 19 Jun 2005 19:35:50 +0100 Subject: AUDIT: Allow filtering of user messages Turn the field from a bitmask to an enumeration and add a list to allow filtering of messages generated by userspace. We also define a list for file system watches in anticipation of that feature. Signed-off-by: David Woodhouse --- include/linux/audit.h | 15 ++++++--- kernel/audit.c | 36 +++++++++++--------- kernel/auditsc.c | 92 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 85 insertions(+), 58 deletions(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index bf2ad3ba72e..b5bda24f736 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -75,10 +75,15 @@ #define AUDIT_KERNEL 2000 /* Asynchronous audit record. NOT A REQUEST. */ /* Rule flags */ -#define AUDIT_PER_TASK 0x01 /* Apply rule at task creation (not syscall) */ -#define AUDIT_AT_ENTRY 0x02 /* Apply rule at syscall entry */ -#define AUDIT_AT_EXIT 0x04 /* Apply rule at syscall exit */ -#define AUDIT_PREPEND 0x10 /* Prepend to front of list */ +#define AUDIT_FILTER_USER 0x00 /* Apply rule to user-generated messages */ +#define AUDIT_FILTER_TASK 0x01 /* Apply rule at task creation (not syscall) */ +#define AUDIT_FILTER_ENTRY 0x02 /* Apply rule at syscall entry */ +#define AUDIT_FILTER_WATCH 0x03 /* Apply rule to file system watches */ +#define AUDIT_FILTER_EXIT 0x04 /* Apply rule at syscall exit */ + +#define AUDIT_NR_FILTERS 5 + +#define AUDIT_FILTER_PREPEND 0x10 /* Prepend to front of list */ /* Rule actions */ #define AUDIT_NEVER 0 /* Do not build context if rule matches */ @@ -230,6 +235,7 @@ extern int audit_socketcall(int nargs, unsigned long *args); extern int audit_sockaddr(int len, void *addr); extern int audit_avc_path(struct dentry *dentry, struct vfsmount *mnt); extern void audit_signal_info(int sig, struct task_struct *t); +extern int audit_filter_user(struct task_struct *tsk, int type); #else #define audit_alloc(t) ({ 0; }) #define audit_free(t) do { ; } while (0) @@ -246,6 +252,7 @@ extern void audit_signal_info(int sig, struct task_struct *t); #define audit_sockaddr(len, addr) ({ 0; }) #define audit_avc_path(dentry, mnt) ({ 0; }) #define audit_signal_info(s,t) do { ; } while (0) +#define audit_filter_user(struct ({ 1; }) #endif #ifdef CONFIG_AUDIT diff --git a/kernel/audit.c b/kernel/audit.c index ef35166fdc2..f0bbfe07313 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -107,13 +107,6 @@ static struct sk_buff_head audit_skb_queue; static struct task_struct *kauditd_task; static DECLARE_WAIT_QUEUE_HEAD(kauditd_wait); -/* There are three lists of rules -- one to search at task creation - * time, one to search at syscall entry time, and another to search at - * syscall exit time. */ -static LIST_HEAD(audit_tsklist); -static LIST_HEAD(audit_entlist); -static LIST_HEAD(audit_extlist); - /* The netlink socket is only to be read by 1 CPU, which lets us assume * that list additions and deletions never happen simultaneously in * auditsc.c */ @@ -376,6 +369,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) u16 msg_type = nlh->nlmsg_type; uid_t loginuid; /* loginuid of sender */ struct audit_sig_info sig_data; + struct task_struct *tsk; err = audit_netlink_ok(NETLINK_CB(skb).eff_cap, msg_type); if (err) @@ -435,15 +429,25 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) break; case AUDIT_USER: case AUDIT_FIRST_USER_MSG...AUDIT_LAST_USER_MSG: - ab = audit_log_start(NULL, msg_type); - if (!ab) - break; /* audit_panic has been called */ - audit_log_format(ab, - "user pid=%d uid=%u auid=%u" - " msg='%.1024s'", - pid, uid, loginuid, (char *)data); - audit_set_pid(ab, pid); - audit_log_end(ab); + read_lock(&tasklist_lock); + tsk = find_task_by_pid(pid); + if (tsk) + get_task_struct(tsk); + read_unlock(&tasklist_lock); + if (!tsk) + return -ESRCH; + + if (audit_filter_user(tsk, msg_type)) { + ab = audit_log_start(NULL, msg_type); + if (ab) { + audit_log_format(ab, + "user pid=%d uid=%u auid=%u msg='%.1024s'", + pid, uid, loginuid, (char *)data); + audit_set_pid(ab, pid); + audit_log_end(ab); + } + } + put_task_struct(tsk); break; case AUDIT_ADD: case AUDIT_DEL: diff --git a/kernel/auditsc.c b/kernel/auditsc.c index e75f84e1a1a..6b4fbb1c012 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -167,9 +167,16 @@ struct audit_context { /* There are three lists of rules -- one to search at task creation * time, one to search at syscall entry time, and another to search at * syscall exit time. */ -static LIST_HEAD(audit_tsklist); -static LIST_HEAD(audit_entlist); -static LIST_HEAD(audit_extlist); +static struct list_head audit_filter_list[AUDIT_NR_FILTERS] = { + LIST_HEAD_INIT(audit_filter_list[0]), + LIST_HEAD_INIT(audit_filter_list[1]), + LIST_HEAD_INIT(audit_filter_list[2]), + LIST_HEAD_INIT(audit_filter_list[3]), + LIST_HEAD_INIT(audit_filter_list[4]), +#if AUDIT_NR_FILTERS != 5 +#error Fix audit_filter_list initialiser +#endif +}; struct audit_entry { struct list_head list; @@ -210,16 +217,15 @@ static int audit_compare_rule(struct audit_rule *a, struct audit_rule *b) /* Note that audit_add_rule and audit_del_rule are called via * audit_receive() in audit.c, and are protected by * audit_netlink_sem. */ -static inline int audit_add_rule(struct audit_entry *entry, - struct list_head *list) +static inline void audit_add_rule(struct audit_entry *entry, + struct list_head *list) { - if (entry->rule.flags & AUDIT_PREPEND) { - entry->rule.flags &= ~AUDIT_PREPEND; + if (entry->rule.flags & AUDIT_FILTER_PREPEND) { + entry->rule.flags &= ~AUDIT_FILTER_PREPEND; list_add_rcu(&entry->list, list); } else { list_add_tail_rcu(&entry->list, list); } - return 0; } static void audit_free_rule(struct rcu_head *head) @@ -245,7 +251,7 @@ static inline int audit_del_rule(struct audit_rule *rule, return 0; } } - return -EFAULT; /* No matching rule */ + return -ENOENT; /* No matching rule */ } /* Copy rule from user-space to kernel-space. Called during @@ -260,6 +266,8 @@ static int audit_copy_rule(struct audit_rule *d, struct audit_rule *s) return -1; if (s->field_count < 0 || s->field_count > AUDIT_MAX_FIELDS) return -1; + if ((s->flags & ~AUDIT_FILTER_PREPEND) >= AUDIT_NR_FILTERS) + return -1; d->flags = s->flags; d->action = s->action; @@ -275,23 +283,20 @@ static int audit_copy_rule(struct audit_rule *d, struct audit_rule *s) int audit_receive_filter(int type, int pid, int uid, int seq, void *data, uid_t loginuid) { - u32 flags; struct audit_entry *entry; int err = 0; + int i; + unsigned listnr; switch (type) { case AUDIT_LIST: /* The *_rcu iterators not needed here because we are always called with audit_netlink_sem held. */ - list_for_each_entry(entry, &audit_tsklist, list) - audit_send_reply(pid, seq, AUDIT_LIST, 0, 1, - &entry->rule, sizeof(entry->rule)); - list_for_each_entry(entry, &audit_entlist, list) - audit_send_reply(pid, seq, AUDIT_LIST, 0, 1, - &entry->rule, sizeof(entry->rule)); - list_for_each_entry(entry, &audit_extlist, list) - audit_send_reply(pid, seq, AUDIT_LIST, 0, 1, - &entry->rule, sizeof(entry->rule)); + for (i=0; irule, sizeof(entry->rule)); + } audit_send_reply(pid, seq, AUDIT_LIST, 1, 1, NULL, 0); break; case AUDIT_ADD: @@ -301,26 +306,20 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data, kfree(entry); return -EINVAL; } - flags = entry->rule.flags; - if (!err && (flags & AUDIT_PER_TASK)) - err = audit_add_rule(entry, &audit_tsklist); - if (!err && (flags & AUDIT_AT_ENTRY)) - err = audit_add_rule(entry, &audit_entlist); - if (!err && (flags & AUDIT_AT_EXIT)) - err = audit_add_rule(entry, &audit_extlist); + listnr = entry->rule.flags & ~AUDIT_FILTER_PREPEND; + audit_add_rule(entry, &audit_filter_list[listnr]); audit_log(NULL, AUDIT_CONFIG_CHANGE, "auid=%u added an audit rule\n", loginuid); break; case AUDIT_DEL: - flags =((struct audit_rule *)data)->flags; - if (!err && (flags & AUDIT_PER_TASK)) - err = audit_del_rule(data, &audit_tsklist); - if (!err && (flags & AUDIT_AT_ENTRY)) - err = audit_del_rule(data, &audit_entlist); - if (!err && (flags & AUDIT_AT_EXIT)) - err = audit_del_rule(data, &audit_extlist); - audit_log(NULL, AUDIT_CONFIG_CHANGE, - "auid=%u removed an audit rule\n", loginuid); + listnr =((struct audit_rule *)data)->flags & ~AUDIT_FILTER_PREPEND; + if (listnr >= AUDIT_NR_FILTERS) + return -EINVAL; + + err = audit_del_rule(data, &audit_filter_list[listnr]); + if (!err) + audit_log(NULL, AUDIT_CONFIG_CHANGE, + "auid=%u removed an audit rule\n", loginuid); break; default: return -EINVAL; @@ -454,7 +453,7 @@ static enum audit_state audit_filter_task(struct task_struct *tsk) enum audit_state state; rcu_read_lock(); - list_for_each_entry_rcu(e, &audit_tsklist, list) { + list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TASK], list) { if (audit_filter_rules(tsk, &e->rule, NULL, &state)) { rcu_read_unlock(); return state; @@ -490,6 +489,23 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk, return AUDIT_BUILD_CONTEXT; } +int audit_filter_user(struct task_struct *tsk, int type) +{ + struct audit_entry *e; + enum audit_state state; + + rcu_read_lock(); + list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_USER], list) { + if (audit_filter_rules(tsk, &e->rule, NULL, &state)) { + rcu_read_unlock(); + return state != AUDIT_DISABLED; + } + } + rcu_read_unlock(); + return 1; /* Audit by default */ + +} + /* This should be called with task_lock() held. */ static inline struct audit_context *audit_get_context(struct task_struct *tsk, int return_valid, @@ -504,7 +520,7 @@ static inline struct audit_context *audit_get_context(struct task_struct *tsk, if (context->in_syscall && !context->auditable) { enum audit_state state; - state = audit_filter_syscall(tsk, context, &audit_extlist); + state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_EXIT]); if (state == AUDIT_RECORD_CONTEXT) context->auditable = 1; } @@ -876,7 +892,7 @@ void audit_syscall_entry(struct task_struct *tsk, int arch, int major, state = context->state; if (state == AUDIT_SETUP_CONTEXT || state == AUDIT_BUILD_CONTEXT) - state = audit_filter_syscall(tsk, context, &audit_entlist); + state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_ENTRY]); if (likely(state == AUDIT_DISABLED)) return; -- cgit v1.2.3 From d6e0e1585a1a9a15e48ec47206a809828afe4450 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 20 Jun 2005 16:02:09 +0100 Subject: AUDIT: Drop user-generated messages immediately while auditing disabled. Signed-off-by: David Woodhouse --- kernel/audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/audit.c b/kernel/audit.c index f0bbfe07313..ab6ac560cfe 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -437,7 +437,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) if (!tsk) return -ESRCH; - if (audit_filter_user(tsk, msg_type)) { + if (audit_enabled && audit_filter_user(tsk, msg_type)) { ab = audit_log_start(NULL, msg_type); if (ab) { audit_log_format(ab, -- cgit v1.2.3 From f7056d64ae101d910f965a2e39831f635ef7891b Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 20 Jun 2005 16:07:33 +0100 Subject: AUDIT: Really exempt auditd from having its actions audited. We were only avoiding it on syscall exit before; now stop _everything_. Signed-off-by: David Woodhouse --- kernel/auditsc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 6b4fbb1c012..48a39579c45 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -477,6 +477,9 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk, int word = AUDIT_WORD(ctx->major); int bit = AUDIT_BIT(ctx->major); + if (audit_pid && ctx->pid == audit_pid) + return AUDIT_DISABLED; + rcu_read_lock(); list_for_each_entry_rcu(e, list, list) { if ((e->rule.mask[word] & bit) == bit @@ -494,6 +497,9 @@ int audit_filter_user(struct task_struct *tsk, int type) struct audit_entry *e; enum audit_state state; + if (audit_pid && tsk->pid == audit_pid) + return AUDIT_DISABLED; + rcu_read_lock(); list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_USER], list) { if (audit_filter_rules(tsk, &e->rule, NULL, &state)) { @@ -816,7 +822,7 @@ void audit_free(struct task_struct *tsk) /* Check for system calls that do not go through the exit * function (e.g., exit_group), then free context block. */ - if (context->in_syscall && context->auditable && context->pid != audit_pid) + if (context->in_syscall && context->auditable) audit_log_exit(context); audit_free_context(context); @@ -921,7 +927,7 @@ void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code) if (likely(!context)) return; - if (context->in_syscall && context->auditable && context->pid != audit_pid) + if (context->in_syscall && context->auditable) audit_log_exit(context); context->in_syscall = 0; -- cgit v1.2.3 From ae7b961b1c943367dfe179411f120d7bf8eaba89 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 20 Jun 2005 16:11:05 +0100 Subject: AUDIT: Report lookup flags with path/inode records. When LOOKUP_PARENT is used, the inode which results is not the inode found at the pathname. Report the flags so that this doesn't generate misleading audit records. Signed-off-by: David Woodhouse --- fs/namei.c | 2 +- include/linux/audit.h | 4 ++-- kernel/auditsc.c | 18 +++++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index a7f7f44119b..6e888dd1046 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1043,7 +1043,7 @@ int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata out: if (unlikely(current->audit_context && nd && nd->dentry && nd->dentry->d_inode)) - audit_inode(name, nd->dentry->d_inode); + audit_inode(name, nd->dentry->d_inode, flags); return retval; } diff --git a/include/linux/audit.h b/include/linux/audit.h index b5bda24f736..5f812e4d01e 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -220,7 +220,7 @@ extern void audit_syscall_entry(struct task_struct *task, int arch, extern void audit_syscall_exit(struct task_struct *task, int failed, long return_code); extern void audit_getname(const char *name); extern void audit_putname(const char *name); -extern void audit_inode(const char *name, const struct inode *inode); +extern void audit_inode(const char *name, const struct inode *inode, unsigned flags); /* Private API (for audit.c only) */ extern int audit_receive_filter(int type, int pid, int uid, int seq, @@ -243,7 +243,7 @@ extern int audit_filter_user(struct task_struct *tsk, int type); #define audit_syscall_exit(t,f,r) do { ; } while (0) #define audit_getname(n) do { ; } while (0) #define audit_putname(n) do { ; } while (0) -#define audit_inode(n,i) do { ; } while (0) +#define audit_inode(n,i,f) do { ; } while (0) #define audit_receive_filter(t,p,u,s,d,l) ({ -EOPNOTSUPP; }) #define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) #define audit_get_loginuid(c) ({ -1; }) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 48a39579c45..031f979019d 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -95,6 +95,7 @@ struct audit_names { uid_t uid; gid_t gid; dev_t rdev; + unsigned flags; }; struct audit_aux_data { @@ -792,6 +793,8 @@ static void audit_log_exit(struct audit_context *context) audit_log_format(ab, " name="); audit_log_untrustedstring(ab, context->names[i].name); } + audit_log_format(ab, " flags=%x\n", context->names[i].flags); + if (context->names[i].ino != (unsigned long)-1) audit_log_format(ab, " inode=%lu dev=%02x:%02x mode=%#o" " ouid=%u ogid=%u rdev=%02x:%02x", @@ -1018,7 +1021,7 @@ void audit_putname(const char *name) /* Store the inode and device from a lookup. Called from * fs/namei.c:path_lookup(). */ -void audit_inode(const char *name, const struct inode *inode) +void audit_inode(const char *name, const struct inode *inode, unsigned flags) { int idx; struct audit_context *context = current->audit_context; @@ -1044,12 +1047,13 @@ void audit_inode(const char *name, const struct inode *inode) ++context->ino_count; #endif } - context->names[idx].ino = inode->i_ino; - context->names[idx].dev = inode->i_sb->s_dev; - context->names[idx].mode = inode->i_mode; - context->names[idx].uid = inode->i_uid; - context->names[idx].gid = inode->i_gid; - context->names[idx].rdev = inode->i_rdev; + context->names[idx].flags = flags; + context->names[idx].ino = inode->i_ino; + context->names[idx].dev = inode->i_sb->s_dev; + context->names[idx].mode = inode->i_mode; + context->names[idx].uid = inode->i_uid; + context->names[idx].gid = inode->i_gid; + context->names[idx].rdev = inode->i_rdev; } void auditsc_get_stamp(struct audit_context *ctx, -- cgit v1.2.3 From f6a789d19858a951e7ff9e297a44b377c21b6c33 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 21 Jun 2005 16:22:01 +0100 Subject: AUDIT: Spawn kernel thread to list filter rules. If we have enough rules to fill the netlink buffer space, it'll deadlock because auditctl isn't ever actually going to read from the socket until we return, and we aren't going to return until it reads... so we spawn a kernel thread to spew out the list and then exit. Signed-off-by: David Woodhouse --- include/linux/audit.h | 1 + kernel/audit.c | 2 +- kernel/auditsc.c | 53 +++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 5f812e4d01e..5d1a9dda5ac 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -281,6 +281,7 @@ extern void audit_send_reply(int pid, int seq, int type, int done, int multi, void *payload, int size); extern void audit_log_lost(const char *message); +extern struct semaphore audit_netlink_sem; #else #define audit_log(c,t,f,...) do { ; } while (0) #define audit_log_start(c,t) ({ NULL; }) diff --git a/kernel/audit.c b/kernel/audit.c index ab6ac560cfe..c1ab8dbbb67 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -110,7 +110,7 @@ static DECLARE_WAIT_QUEUE_HEAD(kauditd_wait); /* The netlink socket is only to be read by 1 CPU, which lets us assume * that list additions and deletions never happen simultaneously in * auditsc.c */ -static DECLARE_MUTEX(audit_netlink_sem); +DECLARE_MUTEX(audit_netlink_sem); /* AUDIT_BUFSIZ is the size of the temporary buffer used for formatting * audit records. Since printk uses a 1024 byte buffer, this buffer diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 031f979019d..cb8a4494515 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -39,6 +39,7 @@ #include #include #include +#include #include /* 0 = no checking @@ -281,24 +282,60 @@ static int audit_copy_rule(struct audit_rule *d, struct audit_rule *s) return 0; } +static int audit_list_rules(void *_dest) +{ + int pid, seq; + int *dest = _dest; + struct audit_entry *entry; + int i; + + pid = dest[0]; + seq = dest[1]; + kfree(dest); + + down(&audit_netlink_sem); + + /* The *_rcu iterators not needed here because we are + always called with audit_netlink_sem held. */ + for (i=0; irule, sizeof(entry->rule)); + } + audit_send_reply(pid, seq, AUDIT_LIST, 1, 1, NULL, 0); + + up(&audit_netlink_sem); + return 0; +} + int audit_receive_filter(int type, int pid, int uid, int seq, void *data, uid_t loginuid) { struct audit_entry *entry; + struct task_struct *tsk; + int *dest; int err = 0; - int i; unsigned listnr; switch (type) { case AUDIT_LIST: - /* The *_rcu iterators not needed here because we are - always called with audit_netlink_sem held. */ - for (i=0; irule, sizeof(entry->rule)); + /* We can't just spew out the rules here because we might fill + * the available socket buffer space and deadlock waiting for + * auditctl to read from it... which isn't ever going to + * happen if we're actually running in the context of auditctl + * trying to _send_ the stuff */ + + dest = kmalloc(2 * sizeof(int), GFP_KERNEL); + if (!dest) + return -ENOMEM; + dest[0] = pid; + dest[1] = seq; + + tsk = kthread_run(audit_list_rules, dest, "audit_list_rules"); + if (IS_ERR(tsk)) { + kfree(dest); + err = PTR_ERR(tsk); } - audit_send_reply(pid, seq, AUDIT_LIST, 1, 1, NULL, 0); break; case AUDIT_ADD: if (!(entry = kmalloc(sizeof(*entry), GFP_KERNEL))) -- cgit v1.2.3 From 4a4cd633b575609b741a1de7837223a2d9e1c34c Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 22 Jun 2005 14:56:47 +0100 Subject: AUDIT: Optimise the audit-disabled case for discarding user messages Also exempt USER_AVC message from being discarded to preserve existing behaviour for SE Linux. Signed-off-by: David Woodhouse --- include/linux/audit.h | 7 ++++--- kernel/audit.c | 32 ++++++++++++++------------------ kernel/auditsc.c | 21 ++++++++++++++++----- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 5d1a9dda5ac..77adef64053 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -51,7 +51,8 @@ #define AUDIT_WATCH_LIST 1009 /* List all file/dir watches */ #define AUDIT_SIGNAL_INFO 1010 /* Get info about sender of signal to auditd */ -#define AUDIT_FIRST_USER_MSG 1100 /* Userspace messages uninteresting to kernel */ +#define AUDIT_FIRST_USER_MSG 1100 /* Userspace messages mostly uninteresting to kernel */ +#define AUDIT_USER_AVC 1107 /* We filter this differently */ #define AUDIT_LAST_USER_MSG 1199 #define AUDIT_DAEMON_START 1200 /* Daemon startup record */ @@ -235,7 +236,7 @@ extern int audit_socketcall(int nargs, unsigned long *args); extern int audit_sockaddr(int len, void *addr); extern int audit_avc_path(struct dentry *dentry, struct vfsmount *mnt); extern void audit_signal_info(int sig, struct task_struct *t); -extern int audit_filter_user(struct task_struct *tsk, int type); +extern int audit_filter_user(int pid, int type); #else #define audit_alloc(t) ({ 0; }) #define audit_free(t) do { ; } while (0) @@ -252,7 +253,7 @@ extern int audit_filter_user(struct task_struct *tsk, int type); #define audit_sockaddr(len, addr) ({ 0; }) #define audit_avc_path(dentry, mnt) ({ 0; }) #define audit_signal_info(s,t) do { ; } while (0) -#define audit_filter_user(struct ({ 1; }) +#define audit_filter_user(p,t) ({ 1; }) #endif #ifdef CONFIG_AUDIT diff --git a/kernel/audit.c b/kernel/audit.c index c1ab8dbbb67..09a37581213 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -429,25 +429,21 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) break; case AUDIT_USER: case AUDIT_FIRST_USER_MSG...AUDIT_LAST_USER_MSG: - read_lock(&tasklist_lock); - tsk = find_task_by_pid(pid); - if (tsk) - get_task_struct(tsk); - read_unlock(&tasklist_lock); - if (!tsk) - return -ESRCH; - - if (audit_enabled && audit_filter_user(tsk, msg_type)) { - ab = audit_log_start(NULL, msg_type); - if (ab) { - audit_log_format(ab, - "user pid=%d uid=%u auid=%u msg='%.1024s'", - pid, uid, loginuid, (char *)data); - audit_set_pid(ab, pid); - audit_log_end(ab); - } + if (!audit_enabled && msg_type != AUDIT_USER_AVC) + return 0; + + err = audit_filter_user(pid, msg_type); + if (err == 1) { + err = 0; + ab = audit_log_start(NULL, msg_type); + if (ab) { + audit_log_format(ab, + "user pid=%d uid=%u auid=%u msg='%.1024s'", + pid, uid, loginuid, (char *)data); + audit_set_pid(ab, pid); + audit_log_end(ab); + } } - put_task_struct(tsk); break; case AUDIT_ADD: case AUDIT_DEL: diff --git a/kernel/auditsc.c b/kernel/auditsc.c index cb8a4494515..fc858b0c044 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -530,22 +530,33 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk, return AUDIT_BUILD_CONTEXT; } -int audit_filter_user(struct task_struct *tsk, int type) +int audit_filter_user(int pid, int type) { + struct task_struct *tsk; struct audit_entry *e; enum audit_state state; + int ret = 1; - if (audit_pid && tsk->pid == audit_pid) - return AUDIT_DISABLED; + read_lock(&tasklist_lock); + tsk = find_task_by_pid(pid); + if (tsk) + get_task_struct(tsk); + read_unlock(&tasklist_lock); + + if (!tsk) + return -ESRCH; rcu_read_lock(); list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_USER], list) { if (audit_filter_rules(tsk, &e->rule, NULL, &state)) { - rcu_read_unlock(); - return state != AUDIT_DISABLED; + if (state == AUDIT_DISABLED) + ret = 0; + break; } } rcu_read_unlock(); + put_task_struct(tsk); + return 1; /* Audit by default */ } -- cgit v1.2.3 From 177bbc733a1d9c935bc3d6efd776a6699b29b1ca Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 22 Jun 2005 15:01:16 +0100 Subject: Add audit subsystem to MAINTAINERS, for my sins. Signed-off-by: David Woodhouse --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index e3f0f3f157c..10ca899693d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -358,6 +358,13 @@ L: linux-atm-general@lists.sourceforge.net W: http://linux-atm.sourceforge.net S: Maintained +AUDIT SUBSYSTEM +P: David Woodhouse +M: dwmw2@infradead.org +L: linux-audit@redhat.com +W: http://people.redhat.com/sgrubb/audit/ +S: Maintained + ATMEL WIRELESS DRIVER P: Simon Kelley M: simon@thekelleys.org.uk -- cgit v1.2.3 From 9ad9ad385be27fcc7c16d290d972c6173e780a61 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 22 Jun 2005 15:04:33 +0100 Subject: AUDIT: Wait for backlog to clear when generating messages. Add a gfp_mask to audit_log_start() and audit_log(), to reduce the amount of GFP_ATOMIC allocation -- most of it doesn't need to be GFP_ATOMIC. Also if the mask includes __GFP_WAIT, then wait up to 60 seconds for the auditd backlog to clear instead of immediately abandoning the message. The timeout should probably be made configurable, but for now it'll suffice that it only happens if auditd is actually running. Signed-off-by: David Woodhouse --- include/linux/audit.h | 8 +++--- kernel/audit.c | 60 +++++++++++++++++++++++++++++++----------- kernel/auditsc.c | 14 +++++----- security/selinux/avc.c | 4 +-- security/selinux/hooks.c | 2 +- security/selinux/ss/services.c | 4 +-- 6 files changed, 61 insertions(+), 31 deletions(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 77adef64053..2f56546eb24 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -259,11 +259,11 @@ extern int audit_filter_user(int pid, int type); #ifdef CONFIG_AUDIT /* These are defined in audit.c */ /* Public API */ -extern void audit_log(struct audit_context *ctx, int type, - const char *fmt, ...) - __attribute__((format(printf,3,4))); +extern void audit_log(struct audit_context *ctx, int gfp_mask, + int type, const char *fmt, ...) + __attribute__((format(printf,4,5))); -extern struct audit_buffer *audit_log_start(struct audit_context *ctx,int type); +extern struct audit_buffer *audit_log_start(struct audit_context *ctx, int gfp_mask, int type); extern void audit_log_format(struct audit_buffer *ab, const char *fmt, ...) __attribute__((format(printf,2,3))); diff --git a/kernel/audit.c b/kernel/audit.c index 09a37581213..644ab825118 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -106,6 +106,7 @@ static LIST_HEAD(audit_freelist); static struct sk_buff_head audit_skb_queue; static struct task_struct *kauditd_task; static DECLARE_WAIT_QUEUE_HEAD(kauditd_wait); +static DECLARE_WAIT_QUEUE_HEAD(audit_backlog_wait); /* The netlink socket is only to be read by 1 CPU, which lets us assume * that list additions and deletions never happen simultaneously in @@ -130,6 +131,7 @@ struct audit_buffer { struct list_head list; struct sk_buff *skb; /* formatted skb ready to send */ struct audit_context *ctx; /* NULL or associated context */ + int gfp_mask; }; static void audit_set_pid(struct audit_buffer *ab, pid_t pid) @@ -226,7 +228,7 @@ static int audit_set_rate_limit(int limit, uid_t loginuid) { int old = audit_rate_limit; audit_rate_limit = limit; - audit_log(NULL, AUDIT_CONFIG_CHANGE, + audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, "audit_rate_limit=%d old=%d by auid=%u", audit_rate_limit, old, loginuid); return old; @@ -236,7 +238,7 @@ static int audit_set_backlog_limit(int limit, uid_t loginuid) { int old = audit_backlog_limit; audit_backlog_limit = limit; - audit_log(NULL, AUDIT_CONFIG_CHANGE, + audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, "audit_backlog_limit=%d old=%d by auid=%u", audit_backlog_limit, old, loginuid); return old; @@ -248,7 +250,7 @@ static int audit_set_enabled(int state, uid_t loginuid) if (state != 0 && state != 1) return -EINVAL; audit_enabled = state; - audit_log(NULL, AUDIT_CONFIG_CHANGE, + audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, "audit_enabled=%d old=%d by auid=%u", audit_enabled, old, loginuid); return old; @@ -262,7 +264,7 @@ static int audit_set_failure(int state, uid_t loginuid) && state != AUDIT_FAIL_PANIC) return -EINVAL; audit_failure = state; - audit_log(NULL, AUDIT_CONFIG_CHANGE, + audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, "audit_failure=%d old=%d by auid=%u", audit_failure, old, loginuid); return old; @@ -274,6 +276,7 @@ int kauditd_thread(void *dummy) while (1) { skb = skb_dequeue(&audit_skb_queue); + wake_up(&audit_backlog_wait); if (skb) { if (audit_pid) { int err = netlink_unicast(audit_sock, skb, audit_pid, 0); @@ -417,7 +420,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) if (status_get->mask & AUDIT_STATUS_PID) { int old = audit_pid; audit_pid = status_get->pid; - audit_log(NULL, AUDIT_CONFIG_CHANGE, + audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, "audit_pid=%d old=%d by auid=%u", audit_pid, old, loginuid); } @@ -435,7 +438,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) err = audit_filter_user(pid, msg_type); if (err == 1) { err = 0; - ab = audit_log_start(NULL, msg_type); + ab = audit_log_start(NULL, GFP_KERNEL, msg_type); if (ab) { audit_log_format(ab, "user pid=%d uid=%u auid=%u msg='%.1024s'", @@ -522,7 +525,7 @@ static int __init audit_init(void) skb_queue_head_init(&audit_skb_queue); audit_initialized = 1; audit_enabled = audit_default; - audit_log(NULL, AUDIT_KERNEL, "initialized"); + audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL, "initialized"); return 0; } __initcall(audit_init); @@ -586,6 +589,7 @@ static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx, goto err; ab->ctx = ctx; + ab->gfp_mask = gfp_mask; nlh = (struct nlmsghdr *)skb_put(ab->skb, NLMSG_SPACE(0)); nlh->nlmsg_type = type; nlh->nlmsg_flags = 0; @@ -644,17 +648,42 @@ static inline void audit_get_stamp(struct audit_context *ctx, * syscall, then the syscall is marked as auditable and an audit record * will be written at syscall exit. If there is no associated task, tsk * should be NULL. */ -struct audit_buffer *audit_log_start(struct audit_context *ctx, int type) + +struct audit_buffer *audit_log_start(struct audit_context *ctx, int gfp_mask, + int type) { struct audit_buffer *ab = NULL; struct timespec t; unsigned int serial; + int reserve; if (!audit_initialized) return NULL; - if (audit_backlog_limit - && skb_queue_len(&audit_skb_queue) > audit_backlog_limit) { + if (gfp_mask & __GFP_WAIT) + reserve = 0; + else + reserve = 5; /* Allow atomic callers to go up to five + entries over the normal backlog limit */ + + while (audit_backlog_limit + && skb_queue_len(&audit_skb_queue) > audit_backlog_limit + reserve) { + if (gfp_mask & __GFP_WAIT) { + int ret = 1; + /* Wait for auditd to drain the queue a little */ + DECLARE_WAITQUEUE(wait, current); + set_current_state(TASK_INTERRUPTIBLE); + add_wait_queue(&audit_backlog_wait, &wait); + + if (audit_backlog_limit && + skb_queue_len(&audit_skb_queue) > audit_backlog_limit) + ret = schedule_timeout(HZ * 60); + + __set_current_state(TASK_RUNNING); + remove_wait_queue(&audit_backlog_wait, &wait); + if (ret) + continue; + } if (audit_rate_check()) printk(KERN_WARNING "audit: audit_backlog=%d > " @@ -665,7 +694,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, int type) return NULL; } - ab = audit_buffer_alloc(ctx, GFP_ATOMIC, type); + ab = audit_buffer_alloc(ctx, gfp_mask, type); if (!ab) { audit_log_lost("out of memory in audit_log_start"); return NULL; @@ -689,7 +718,7 @@ static inline int audit_expand(struct audit_buffer *ab, int extra) { struct sk_buff *skb = ab->skb; int ret = pskb_expand_head(skb, skb_headroom(skb), extra, - GFP_ATOMIC); + ab->gfp_mask); if (ret < 0) { audit_log_lost("out of memory in audit_expand"); return 0; @@ -808,7 +837,7 @@ void audit_log_d_path(struct audit_buffer *ab, const char *prefix, audit_log_format(ab, " %s", prefix); /* We will allow 11 spaces for ' (deleted)' to be appended */ - path = kmalloc(PATH_MAX+11, GFP_KERNEL); + path = kmalloc(PATH_MAX+11, ab->gfp_mask); if (!path) { audit_log_format(ab, ""); return; @@ -849,12 +878,13 @@ void audit_log_end(struct audit_buffer *ab) /* Log an audit record. This is a convenience function that calls * audit_log_start, audit_log_vformat, and audit_log_end. It may be * called in any context. */ -void audit_log(struct audit_context *ctx, int type, const char *fmt, ...) +void audit_log(struct audit_context *ctx, int gfp_mask, int type, + const char *fmt, ...) { struct audit_buffer *ab; va_list args; - ab = audit_log_start(ctx, type); + ab = audit_log_start(ctx, gfp_mask, type); if (ab) { va_start(args, fmt); audit_log_vformat(ab, fmt, args); diff --git a/kernel/auditsc.c b/kernel/auditsc.c index fc858b0c044..f463fd23084 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -346,7 +346,7 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data, } listnr = entry->rule.flags & ~AUDIT_FILTER_PREPEND; audit_add_rule(entry, &audit_filter_list[listnr]); - audit_log(NULL, AUDIT_CONFIG_CHANGE, + audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, "auid=%u added an audit rule\n", loginuid); break; case AUDIT_DEL: @@ -356,7 +356,7 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data, err = audit_del_rule(data, &audit_filter_list[listnr]); if (!err) - audit_log(NULL, AUDIT_CONFIG_CHANGE, + audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, "auid=%u removed an audit rule\n", loginuid); break; default: @@ -756,7 +756,7 @@ static void audit_log_exit(struct audit_context *context) struct audit_buffer *ab; struct audit_aux_data *aux; - ab = audit_log_start(context, AUDIT_SYSCALL); + ab = audit_log_start(context, GFP_KERNEL, AUDIT_SYSCALL); if (!ab) return; /* audit_panic has been called */ audit_log_format(ab, "arch=%x syscall=%d", @@ -788,7 +788,7 @@ static void audit_log_exit(struct audit_context *context) for (aux = context->aux; aux; aux = aux->next) { - ab = audit_log_start(context, aux->type); + ab = audit_log_start(context, GFP_KERNEL, aux->type); if (!ab) continue; /* audit_panic has been called */ @@ -825,14 +825,14 @@ static void audit_log_exit(struct audit_context *context) } if (context->pwd && context->pwdmnt) { - ab = audit_log_start(context, AUDIT_CWD); + ab = audit_log_start(context, GFP_KERNEL, AUDIT_CWD); if (ab) { audit_log_d_path(ab, "cwd=", context->pwd, context->pwdmnt); audit_log_end(ab); } } for (i = 0; i < context->name_count; i++) { - ab = audit_log_start(context, AUDIT_PATH); + ab = audit_log_start(context, GFP_KERNEL, AUDIT_PATH); if (!ab) continue; /* audit_panic has been called */ @@ -1118,7 +1118,7 @@ int audit_set_loginuid(struct task_struct *task, uid_t loginuid) if (task->audit_context) { struct audit_buffer *ab; - ab = audit_log_start(NULL, AUDIT_LOGIN); + ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN); if (ab) { audit_log_format(ab, "login pid=%d uid=%u " "old auid=%u new auid=%u", diff --git a/security/selinux/avc.c b/security/selinux/avc.c index 451502467a9..2d088bb65ee 100644 --- a/security/selinux/avc.c +++ b/security/selinux/avc.c @@ -242,7 +242,7 @@ void __init avc_init(void) avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node), 0, SLAB_PANIC, NULL, NULL); - audit_log(current->audit_context, AUDIT_KERNEL, "AVC INITIALIZED\n"); + audit_log(current->audit_context, GFP_KERNEL, AUDIT_KERNEL, "AVC INITIALIZED\n"); } int avc_get_hash_stats(char *page) @@ -550,7 +550,7 @@ void avc_audit(u32 ssid, u32 tsid, return; } - ab = audit_log_start(current->audit_context, AUDIT_AVC); + ab = audit_log_start(current->audit_context, GFP_ATOMIC, AUDIT_AVC); if (!ab) return; /* audit_panic has been called */ audit_log_format(ab, "avc: %s ", denied ? "denied" : "granted"); diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index db845cbd584..b5220a266dc 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3419,7 +3419,7 @@ static int selinux_nlmsg_perm(struct sock *sk, struct sk_buff *skb) err = selinux_nlmsg_lookup(isec->sclass, nlh->nlmsg_type, &perm); if (err) { if (err == -EINVAL) { - audit_log(current->audit_context, AUDIT_SELINUX_ERR, + audit_log(current->audit_context, GFP_KERNEL, AUDIT_SELINUX_ERR, "SELinux: unrecognized netlink message" " type=%hu for sclass=%hu\n", nlh->nlmsg_type, isec->sclass); diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index b6149147d5c..2947cf85dc5 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c @@ -365,7 +365,7 @@ static int security_validtrans_handle_fail(struct context *ocontext, goto out; if (context_struct_to_string(tcontext, &t, &tlen) < 0) goto out; - audit_log(current->audit_context, AUDIT_SELINUX_ERR, + audit_log(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR, "security_validate_transition: denied for" " oldcontext=%s newcontext=%s taskcontext=%s tclass=%s", o, n, t, policydb.p_class_val_to_name[tclass-1]); @@ -742,7 +742,7 @@ static int compute_sid_handle_invalid_context( goto out; if (context_struct_to_string(newcontext, &n, &nlen) < 0) goto out; - audit_log(current->audit_context, AUDIT_SELINUX_ERR, + audit_log(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR, "security_compute_sid: invalid context %s" " for scontext=%s" " tcontext=%s" -- cgit v1.2.3 From 9470178e620fe8f512928eed34994572c1c44be4 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 22 Jun 2005 15:40:55 +0100 Subject: AUDIT: Remove stray declaration of tsk from audit_receive_msg(). It's not used any more. Signed-off-by: David Woodhouse --- kernel/audit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/audit.c b/kernel/audit.c index 644ab825118..9af947a63ed 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -372,7 +372,6 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) u16 msg_type = nlh->nlmsg_type; uid_t loginuid; /* loginuid of sender */ struct audit_sig_info sig_data; - struct task_struct *tsk; err = audit_netlink_ok(NETLINK_CB(skb).eff_cap, msg_type); if (err) -- cgit v1.2.3 From 9e94e66a5bc739ab525ec0a26ba75300aaf154f3 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Thu, 23 Jun 2005 18:33:54 +0100 Subject: AUDIT: No really, we don't want to audit auditd. Signed-off-by: David Woodhouse --- kernel/auditsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index f463fd23084..20c7d8560af 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -573,7 +573,7 @@ static inline struct audit_context *audit_get_context(struct task_struct *tsk, context->return_valid = return_valid; context->return_code = return_code; - if (context->in_syscall && !context->auditable) { + if (context->in_syscall && !context->auditable && tsk->pid != audit_pid) { enum audit_state state; state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_EXIT]); if (state == AUDIT_RECORD_CONTEXT) -- cgit v1.2.3 From 993e2d4106e94dae6e8cfbeb32073bd12cdee203 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 24 Jun 2005 08:21:49 +0100 Subject: AUDIT: Return correct result from audit_filter_rules() When the task refcounting was added to audit_filter_rules() it became more of a problem that this function was violating the 'only one return from each function' rule. In fixing it to use a variable to store 'ret' I stupidly neglected to actually change the 'return 1;' at the end. This makes it not work very well. Signed-off-by: David Woodhouse --- kernel/auditsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 20c7d8560af..7b123f0a948 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -557,7 +557,7 @@ int audit_filter_user(int pid, int type) rcu_read_unlock(); put_task_struct(tsk); - return 1; /* Audit by default */ + return ret; /* Audit by default */ } -- cgit v1.2.3 From 5bb289b5a0becb53ac3e1d60815ff8b779296b73 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 24 Jun 2005 14:14:05 +0100 Subject: AUDIT: Clean up user message filtering Don't look up the task by its pid and then use the syscall filtering helper. Just implement our own filter helper which operates solely on the information in the netlink_skb_parms. Signed-off-by: David Woodhouse --- include/linux/audit.h | 5 +++-- kernel/audit.c | 2 +- kernel/auditsc.c | 56 ++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 2f56546eb24..38999f827a3 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -205,6 +205,7 @@ struct audit_sig_info { struct audit_buffer; struct audit_context; struct inode; +struct netlink_skb_parms; #define AUDITSC_INVALID 0 #define AUDITSC_SUCCESS 1 @@ -236,7 +237,7 @@ extern int audit_socketcall(int nargs, unsigned long *args); extern int audit_sockaddr(int len, void *addr); extern int audit_avc_path(struct dentry *dentry, struct vfsmount *mnt); extern void audit_signal_info(int sig, struct task_struct *t); -extern int audit_filter_user(int pid, int type); +extern int audit_filter_user(struct netlink_skb_parms *cb, int type); #else #define audit_alloc(t) ({ 0; }) #define audit_free(t) do { ; } while (0) @@ -253,7 +254,7 @@ extern int audit_filter_user(int pid, int type); #define audit_sockaddr(len, addr) ({ 0; }) #define audit_avc_path(dentry, mnt) ({ 0; }) #define audit_signal_info(s,t) do { ; } while (0) -#define audit_filter_user(p,t) ({ 1; }) +#define audit_filter_user(cb,t) ({ 1; }) #endif #ifdef CONFIG_AUDIT diff --git a/kernel/audit.c b/kernel/audit.c index 9af947a63ed..6f1784dd80a 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -434,7 +434,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) if (!audit_enabled && msg_type != AUDIT_USER_AVC) return 0; - err = audit_filter_user(pid, msg_type); + err = audit_filter_user(&NETLINK_CB(skb), msg_type); if (err == 1) { err = 0; ab = audit_log_start(NULL, GFP_KERNEL, msg_type); diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 7b123f0a948..34a990223c9 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -40,6 +40,7 @@ #include #include #include +#include #include /* 0 = no checking @@ -530,35 +531,62 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk, return AUDIT_BUILD_CONTEXT; } -int audit_filter_user(int pid, int type) +static int audit_filter_user_rules(struct netlink_skb_parms *cb, + struct audit_rule *rule, + enum audit_state *state) +{ + int i; + + for (i = 0; i < rule->field_count; i++) { + u32 field = rule->fields[i] & ~AUDIT_NEGATE; + u32 value = rule->values[i]; + int result = 0; + + switch (field) { + case AUDIT_PID: + result = (cb->creds.pid == value); + break; + case AUDIT_UID: + result = (cb->creds.uid == value); + break; + case AUDIT_GID: + result = (cb->creds.gid == value); + break; + case AUDIT_LOGINUID: + result = (cb->loginuid == value); + break; + } + + if (rule->fields[i] & AUDIT_NEGATE) + result = !result; + if (!result) + return 0; + } + switch (rule->action) { + case AUDIT_NEVER: *state = AUDIT_DISABLED; break; + case AUDIT_POSSIBLE: *state = AUDIT_BUILD_CONTEXT; break; + case AUDIT_ALWAYS: *state = AUDIT_RECORD_CONTEXT; break; + } + return 1; +} + +int audit_filter_user(struct netlink_skb_parms *cb, int type) { - struct task_struct *tsk; struct audit_entry *e; enum audit_state state; int ret = 1; - read_lock(&tasklist_lock); - tsk = find_task_by_pid(pid); - if (tsk) - get_task_struct(tsk); - read_unlock(&tasklist_lock); - - if (!tsk) - return -ESRCH; - rcu_read_lock(); list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_USER], list) { - if (audit_filter_rules(tsk, &e->rule, NULL, &state)) { + if (audit_filter_user_rules(cb, &e->rule, &state)) { if (state == AUDIT_DISABLED) ret = 0; break; } } rcu_read_unlock(); - put_task_struct(tsk); return ret; /* Audit by default */ - } /* This should be called with task_lock() held. */ -- cgit v1.2.3 From e1b09eba2686eca94a3a188042b518df6044a3c1 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 24 Jun 2005 17:24:11 +0100 Subject: AUDIT: Use KERN_NOTICE for printk of audit records They aren't errors. Signed-off-by: David Woodhouse --- kernel/audit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 6f1784dd80a..2617d055240 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -286,7 +286,7 @@ int kauditd_thread(void *dummy) audit_pid = 0; } } else { - printk(KERN_ERR "%s\n", skb->data + NLMSG_SPACE(0)); + printk(KERN_NOTICE "%s\n", skb->data + NLMSG_SPACE(0)); kfree_skb(skb); } } else { @@ -868,7 +868,7 @@ void audit_log_end(struct audit_buffer *ab) ab->skb = NULL; wake_up_interruptible(&kauditd_wait); } else { - printk("%s\n", ab->skb->data + NLMSG_SPACE(0)); + printk(KERN_NOTICE "%s\n", ab->skb->data + NLMSG_SPACE(0)); } } audit_buffer_free(ab); -- cgit v1.2.3 From 13774024da8ebdf17212c0f5a83f5b0681a649eb Mon Sep 17 00:00:00 2001 From: Badari Pulavarty Date: Sat, 2 Jul 2005 13:49:07 +0100 Subject: AUDIT: Fix definition of audit_log_start() if audit not enabled audit_log_start() seems to take 3 arguments, but its defined to take only 2 when AUDIT is turned off. security/selinux/avc.c:553:75: macro "audit_log_start" passed 3 arguments, but takes just 2 Signed-off-by: Andrew Morton Signed-off-by: David Woodhouse --- include/linux/audit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 38999f827a3..c22405fc2dd 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -286,7 +286,7 @@ extern void audit_log_lost(const char *message); extern struct semaphore audit_netlink_sem; #else #define audit_log(c,t,f,...) do { ; } while (0) -#define audit_log_start(c,t) ({ NULL; }) +#define audit_log_start(c,g,t) ({ NULL; }) #define audit_log_vformat(b,f,a) do { ; } while (0) #define audit_log_format(b,f,...) do { ; } while (0) #define audit_log_end(b) do { ; } while (0) -- cgit v1.2.3 From 7b430437c0de81681ecfa8efa8f55823df733529 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sat, 2 Jul 2005 13:50:40 +0100 Subject: AUDIT: Fix definition of audit_log() if audit not enabled audit_log() also takes an extra argument, although it's a vararg function so the compiler didn't really notice. Signed-off-by: David Woodhouse --- include/linux/audit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index c22405fc2dd..d68e85580a5 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -285,7 +285,7 @@ extern void audit_send_reply(int pid, int seq, int type, extern void audit_log_lost(const char *message); extern struct semaphore audit_netlink_sem; #else -#define audit_log(c,t,f,...) do { ; } while (0) +#define audit_log(c,g,t,f,...) do { ; } while (0) #define audit_log_start(c,g,t) ({ NULL; }) #define audit_log_vformat(b,f,a) do { ; } while (0) #define audit_log_format(b,f,...) do { ; } while (0) -- cgit v1.2.3 From ac4cec443a80bfde829516e7a7db10f7325aa528 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sat, 2 Jul 2005 14:08:48 +0100 Subject: AUDIT: Stop waiting for backlog after audit_panic() happens We force a rate-limit on auditable events by making them wait for space on the backlog queue. However, if auditd really is AWOL then this could potentially bring the entire system to a halt, depending on the audit rules in effect. Firstly, make sure the wait time is honoured correctly -- it's the maximum time the process should wait, rather than the time to wait _each_ time round the loop. We were getting re-woken _each_ time a packet was dequeued, and the timeout was being restarted each time. Secondly, reset the wait time after audit_panic() is called. In general this will be reset to zero, to allow progress to be made. If the system is configured to _actually_ panic on audit_panic() then that will already have happened; otherwise we know that audit records are being lost anyway. These two tunables can't be exposed via AUDIT_GET and AUDIT_SET because those aren't particularly well-designed. It probably should have been done by sysctls or sysfs anyway -- one for a later patch. Signed-off-by: David Woodhouse --- kernel/audit.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 2617d055240..b683f2b5e86 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -79,6 +79,8 @@ static int audit_rate_limit; /* Number of outstanding audit_buffers allowed. */ static int audit_backlog_limit = 64; +static int audit_backlog_wait_time = 60 * HZ; +static int audit_backlog_wait_overflow = 0; /* The identity of the user shutting down the audit system. */ uid_t audit_sig_uid = -1; @@ -655,6 +657,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, int gfp_mask, struct timespec t; unsigned int serial; int reserve; + unsigned long timeout_start = jiffies; if (!audit_initialized) return NULL; @@ -667,8 +670,9 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, int gfp_mask, while (audit_backlog_limit && skb_queue_len(&audit_skb_queue) > audit_backlog_limit + reserve) { - if (gfp_mask & __GFP_WAIT) { - int ret = 1; + if (gfp_mask & __GFP_WAIT && audit_backlog_wait_time + && time_before(jiffies, timeout_start + audit_backlog_wait_time)) { + /* Wait for auditd to drain the queue a little */ DECLARE_WAITQUEUE(wait, current); set_current_state(TASK_INTERRUPTIBLE); @@ -676,12 +680,11 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, int gfp_mask, if (audit_backlog_limit && skb_queue_len(&audit_skb_queue) > audit_backlog_limit) - ret = schedule_timeout(HZ * 60); + schedule_timeout(timeout_start + audit_backlog_wait_time - jiffies); __set_current_state(TASK_RUNNING); remove_wait_queue(&audit_backlog_wait, &wait); - if (ret) - continue; + continue; } if (audit_rate_check()) printk(KERN_WARNING @@ -690,6 +693,8 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, int gfp_mask, skb_queue_len(&audit_skb_queue), audit_backlog_limit); audit_log_lost("backlog limit exceeded"); + audit_backlog_wait_time = audit_backlog_wait_overflow; + wake_up(&audit_backlog_wait); return NULL; } -- cgit v1.2.3 From 21af6c4f2aa5f63138871b4ddd77d7ebf2588c9d Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sat, 2 Jul 2005 14:10:46 +0100 Subject: AUDIT: Really don't audit auditd. The pid in the audit context isn't always set up. Use tsk->pid when checking whether it's auditd in audit_filter_syscall(), instead of ctx->pid. Remove a band-aid which did the same elsewhere. Signed-off-by: David Woodhouse --- kernel/auditsc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 34a990223c9..0fdd90194ec 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -516,7 +516,7 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk, int word = AUDIT_WORD(ctx->major); int bit = AUDIT_BIT(ctx->major); - if (audit_pid && ctx->pid == audit_pid) + if (audit_pid && tsk->pid == audit_pid) return AUDIT_DISABLED; rcu_read_lock(); @@ -601,7 +601,7 @@ static inline struct audit_context *audit_get_context(struct task_struct *tsk, context->return_valid = return_valid; context->return_code = return_code; - if (context->in_syscall && !context->auditable && tsk->pid != audit_pid) { + if (context->in_syscall && !context->auditable) { enum audit_state state; state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_EXIT]); if (state == AUDIT_RECORD_CONTEXT) -- cgit v1.2.3 From b67dbf9d4c1987c370fd18fdc4cf9d8aaea604c2 Mon Sep 17 00:00:00 2001 From: Greg KH Date: Thu, 7 Jul 2005 14:37:53 -0700 Subject: [PATCH] add securityfs for all LSMs to use Here's a small patch against 2.6.13-rc2 that adds securityfs, a virtual fs that all LSMs can use instead of creating their own. The fs should be mounted at /sys/kernel/security, and the fs creates that mount point. This will make the LSB people happy that we aren't creating a new /my_lsm_fs directory in the root for every different LSM. It has changed a bit since the last version, thanks to comments from Mike Waychison. Signed-off-by: Greg Kroah-Hartman Signed-off-by: Chris Wright --- include/linux/security.h | 5 + security/Makefile | 2 +- security/inode.c | 347 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 353 insertions(+), 1 deletion(-) create mode 100644 security/inode.c diff --git a/include/linux/security.h b/include/linux/security.h index b42095a68b1..cd3d8a9f951 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -1983,6 +1983,11 @@ extern int register_security (struct security_operations *ops); extern int unregister_security (struct security_operations *ops); extern int mod_reg_security (const char *name, struct security_operations *ops); extern int mod_unreg_security (const char *name, struct security_operations *ops); +extern struct dentry *securityfs_create_file(const char *name, mode_t mode, + struct dentry *parent, void *data, + struct file_operations *fops); +extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent); +extern void securityfs_remove(struct dentry *dentry); #else /* CONFIG_SECURITY */ diff --git a/security/Makefile b/security/Makefile index 197cc2f3f1e..8cbbf2f3670 100644 --- a/security/Makefile +++ b/security/Makefile @@ -11,7 +11,7 @@ obj-y += commoncap.o endif # Object file lists -obj-$(CONFIG_SECURITY) += security.o dummy.o +obj-$(CONFIG_SECURITY) += security.o dummy.o inode.o # Must precede capability.o in order to stack properly. obj-$(CONFIG_SECURITY_SELINUX) += selinux/built-in.o obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o diff --git a/security/inode.c b/security/inode.c new file mode 100644 index 00000000000..a5964502ae3 --- /dev/null +++ b/security/inode.c @@ -0,0 +1,347 @@ +/* + * inode.c - securityfs + * + * Copyright (C) 2005 Greg Kroah-Hartman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + * + * Based on fs/debugfs/inode.c which had the following copyright notice: + * Copyright (C) 2004 Greg Kroah-Hartman + * Copyright (C) 2004 IBM Inc. + */ + +/* #define DEBUG */ +#include +#include +#include +#include +#include +#include +#include +#include + +#define SECURITYFS_MAGIC 0x73636673 + +static struct vfsmount *mount; +static int mount_count; + +/* + * TODO: + * I think I can get rid of these default_file_ops, but not quite sure... + */ +static ssize_t default_read_file(struct file *file, char __user *buf, + size_t count, loff_t *ppos) +{ + return 0; +} + +static ssize_t default_write_file(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + return count; +} + +static int default_open(struct inode *inode, struct file *file) +{ + if (inode->u.generic_ip) + file->private_data = inode->u.generic_ip; + + return 0; +} + +static struct file_operations default_file_ops = { + .read = default_read_file, + .write = default_write_file, + .open = default_open, +}; + +static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev) +{ + struct inode *inode = new_inode(sb); + + if (inode) { + inode->i_mode = mode; + inode->i_uid = 0; + inode->i_gid = 0; + inode->i_blksize = PAGE_CACHE_SIZE; + inode->i_blocks = 0; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + switch (mode & S_IFMT) { + default: + init_special_inode(inode, mode, dev); + break; + case S_IFREG: + inode->i_fop = &default_file_ops; + break; + case S_IFDIR: + inode->i_op = &simple_dir_inode_operations; + inode->i_fop = &simple_dir_operations; + + /* directory inodes start off with i_nlink == 2 (for "." entry) */ + inode->i_nlink++; + break; + } + } + return inode; +} + +/* SMP-safe */ +static int mknod(struct inode *dir, struct dentry *dentry, + int mode, dev_t dev) +{ + struct inode *inode; + int error = -EPERM; + + if (dentry->d_inode) + return -EEXIST; + + inode = get_inode(dir->i_sb, mode, dev); + if (inode) { + d_instantiate(dentry, inode); + dget(dentry); + error = 0; + } + return error; +} + +static int mkdir(struct inode *dir, struct dentry *dentry, int mode) +{ + int res; + + mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; + res = mknod(dir, dentry, mode, 0); + if (!res) + dir->i_nlink++; + return res; +} + +static int create(struct inode *dir, struct dentry *dentry, int mode) +{ + mode = (mode & S_IALLUGO) | S_IFREG; + return mknod(dir, dentry, mode, 0); +} + +static inline int positive(struct dentry *dentry) +{ + return dentry->d_inode && !d_unhashed(dentry); +} + +static int fill_super(struct super_block *sb, void *data, int silent) +{ + static struct tree_descr files[] = {{""}}; + + return simple_fill_super(sb, SECURITYFS_MAGIC, files); +} + +static struct super_block *get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, + void *data) +{ + return get_sb_single(fs_type, flags, data, fill_super); +} + +static struct file_system_type fs_type = { + .owner = THIS_MODULE, + .name = "securityfs", + .get_sb = get_sb, + .kill_sb = kill_litter_super, +}; + +static int create_by_name(const char *name, mode_t mode, + struct dentry *parent, + struct dentry **dentry) +{ + int error = 0; + + *dentry = NULL; + + /* If the parent is not specified, we create it in the root. + * We need the root dentry to do this, which is in the super + * block. A pointer to that is in the struct vfsmount that we + * have around. + */ + if (!parent ) { + if (mount && mount->mnt_sb) { + parent = mount->mnt_sb->s_root; + } + } + if (!parent) { + pr_debug("securityfs: Ah! can not find a parent!\n"); + return -EFAULT; + } + + down(&parent->d_inode->i_sem); + *dentry = lookup_one_len(name, parent, strlen(name)); + if (!IS_ERR(dentry)) { + if ((mode & S_IFMT) == S_IFDIR) + error = mkdir(parent->d_inode, *dentry, mode); + else + error = create(parent->d_inode, *dentry, mode); + } else + error = PTR_ERR(dentry); + up(&parent->d_inode->i_sem); + + return error; +} + +/** + * securityfs_create_file - create a file in the securityfs filesystem + * + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this paramater is NULL, then the + * file will be created in the root of the securityfs filesystem. + * @data: a pointer to something that the caller will want to get to later + * on. The inode.u.generic_ip pointer will point to this value on + * the open() call. + * @fops: a pointer to a struct file_operations that should be used for + * this file. + * + * This is the basic "create a file" function for securityfs. It allows for a + * wide range of flexibility in createing a file, or a directory (if you + * want to create a directory, the securityfs_create_dir() function is + * recommended to be used instead.) + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the securityfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, NULL will be returned. + * + * If securityfs is not enabled in the kernel, the value -ENODEV will be + * returned. It is not wise to check for this value, but rather, check for + * NULL or !NULL instead as to eliminate the need for #ifdef in the calling + * code. + */ +struct dentry *securityfs_create_file(const char *name, mode_t mode, + struct dentry *parent, void *data, + struct file_operations *fops) +{ + struct dentry *dentry = NULL; + int error; + + pr_debug("securityfs: creating file '%s'\n",name); + + error = simple_pin_fs("securityfs", &mount, &mount_count); + if (error) { + dentry = ERR_PTR(error); + goto exit; + } + + error = create_by_name(name, mode, parent, &dentry); + if (error) { + dentry = ERR_PTR(error); + simple_release_fs(&mount, &mount_count); + goto exit; + } + + if (dentry->d_inode) { + if (fops) + dentry->d_inode->i_fop = fops; + if (data) + dentry->d_inode->u.generic_ip = data; + } +exit: + return dentry; +} +EXPORT_SYMBOL_GPL(securityfs_create_file); + +/** + * securityfs_create_dir - create a directory in the securityfs filesystem + * + * @name: a pointer to a string containing the name of the directory to + * create. + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this paramater is NULL, then the + * directory will be created in the root of the securityfs filesystem. + * + * This function creates a directory in securityfs with the given name. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the securityfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, NULL will be returned. + * + * If securityfs is not enabled in the kernel, the value -ENODEV will be + * returned. It is not wise to check for this value, but rather, check for + * NULL or !NULL instead as to eliminate the need for #ifdef in the calling + * code. + */ +struct dentry *securityfs_create_dir(const char *name, struct dentry *parent) +{ + return securityfs_create_file(name, + S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, + parent, NULL, NULL); +} +EXPORT_SYMBOL_GPL(securityfs_create_dir); + +/** + * securityfs_remove - removes a file or directory from the securityfs filesystem + * + * @dentry: a pointer to a the dentry of the file or directory to be + * removed. + * + * This function removes a file or directory in securityfs that was previously + * created with a call to another securityfs function (like + * securityfs_create_file() or variants thereof.) + * + * This function is required to be called in order for the file to be + * removed, no automatic cleanup of files will happen when a module is + * removed, you are responsible here. + */ +void securityfs_remove(struct dentry *dentry) +{ + struct dentry *parent; + + if (!dentry) + return; + + parent = dentry->d_parent; + if (!parent || !parent->d_inode) + return; + + down(&parent->d_inode->i_sem); + if (positive(dentry)) { + if (dentry->d_inode) { + if (S_ISDIR(dentry->d_inode->i_mode)) + simple_rmdir(parent->d_inode, dentry); + else + simple_unlink(parent->d_inode, dentry); + dput(dentry); + } + } + up(&parent->d_inode->i_sem); + simple_release_fs(&mount, &mount_count); +} +EXPORT_SYMBOL_GPL(securityfs_remove); + +static decl_subsys(security, NULL, NULL); + +static int __init securityfs_init(void) +{ + int retval; + + kset_set_kset_s(&security_subsys, kernel_subsys); + retval = subsystem_register(&security_subsys); + if (retval) + return retval; + + retval = register_filesystem(&fs_type); + if (retval) + subsystem_unregister(&security_subsys); + return retval; +} + +static void __exit securityfs_exit(void) +{ + simple_release_fs(&mount, &mount_count); + unregister_filesystem(&fs_type); + subsystem_unregister(&security_subsys); +} + +core_initcall(securityfs_init); +module_exit(securityfs_exit); +MODULE_LICENSE("GPL"); + -- cgit v1.2.3 From 5a73c308754e27829c94544e010f133019cbd432 Mon Sep 17 00:00:00 2001 From: "serue@us.ibm.com" Date: Fri, 8 Jul 2005 15:44:19 -0500 Subject: [PATCH] seclvl securityfs Once again, the simple_attr in libfs was actually sufficient - I'd thought the __attribute__(format(printk(1,2))) was more mysterious than it really is. At last, here is the full patch to make seclvl use securityfs. Signed-off-by: Serge Hallyn Signed-off-by: Chris Wright -- seclvl.c | 228 +++++++++++++++++++-------------------------------------------- 1 files changed, 70 insertions(+), 158 deletions(-) Index: linux-2.6.13-rc1/security/seclvl.c =================================================================== --- security/seclvl.c | 228 +++++++++++++++++------------------------------------- 1 file changed, 70 insertions(+), 158 deletions(-) diff --git a/security/seclvl.c b/security/seclvl.c index c8e87b22c9b..f8700e935b3 100644 --- a/security/seclvl.c +++ b/security/seclvl.c @@ -118,69 +118,6 @@ MODULE_PARM_DESC(hideHash, "When set to 0, reading seclvl/passwd from sysfs " } \ } while (0) -/** - * kobject stuff - */ - -struct subsystem seclvl_subsys; - -struct seclvl_obj { - char *name; - struct list_head slot_list; - struct kobject kobj; -}; - -/** - * There is a seclvl_attribute struct for each file in sysfs. - * - * In our case, we have one of these structs for "passwd" and another - * for "seclvl". - */ -struct seclvl_attribute { - struct attribute attr; - ssize_t(*show) (struct seclvl_obj *, char *); - ssize_t(*store) (struct seclvl_obj *, const char *, size_t); -}; - -/** - * When this function is called, one of the files in sysfs is being - * written to. attribute->store is a function pointer to whatever the - * struct seclvl_attribute store function pointer points to. It is - * unique for "passwd" and "seclvl". - */ -static ssize_t -seclvl_attr_store(struct kobject *kobj, - struct attribute *attr, const char *buf, size_t len) -{ - struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj); - struct seclvl_attribute *attribute = - container_of(attr, struct seclvl_attribute, attr); - return attribute->store ? attribute->store(obj, buf, len) : -EIO; -} - -static ssize_t -seclvl_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) -{ - struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj); - struct seclvl_attribute *attribute = - container_of(attr, struct seclvl_attribute, attr); - return attribute->show ? attribute->show(obj, buf) : -EIO; -} - -/** - * Callback function pointers for show and store - */ -static struct sysfs_ops seclvlfs_sysfs_ops = { - .show = seclvl_attr_show, - .store = seclvl_attr_store, -}; - -static struct kobj_type seclvl_ktype = { - .sysfs_ops = &seclvlfs_sysfs_ops -}; - -decl_subsys(seclvl, &seclvl_ktype, NULL); - /** * The actual security level. Ranges between -1 and 2 inclusive. */ @@ -212,97 +149,44 @@ static int seclvl_sanity(int reqlvl) return 0; } -/** - * Called whenever the user reads the sysfs handle to this kernel - * object - */ -static ssize_t seclvl_read_file(struct seclvl_obj *obj, char *buff) -{ - return snprintf(buff, PAGE_SIZE, "%d\n", seclvl); -} - /** * security level advancement rules: * Valid levels are -1 through 2, inclusive. * From -1, stuck. [ in case compiled into kernel ] * From 0 or above, can only increment. */ -static int do_seclvl_advance(int newlvl) +static void do_seclvl_advance(void *data, u64 val) { - if (newlvl <= seclvl) { - seclvl_printk(1, KERN_WARNING, "Cannot advance to seclvl " - "[%d]\n", newlvl); - return -EINVAL; - } + int ret; + int newlvl = (int)val; + + ret = seclvl_sanity(newlvl); + if (ret) + return; + if (newlvl > 2) { seclvl_printk(1, KERN_WARNING, "Cannot advance to seclvl " "[%d]\n", newlvl); - return -EINVAL; + return; } if (seclvl == -1) { seclvl_printk(1, KERN_WARNING, "Not allowed to advance to " "seclvl [%d]\n", seclvl); - return -EPERM; + return; } - seclvl = newlvl; - return 0; + seclvl = newlvl; /* would it be more "correct" to set *data? */ + return; } -/** - * Called whenever the user writes to the sysfs handle to this kernel - * object (seclvl/seclvl). It expects a single-digit number. - */ -static ssize_t -seclvl_write_file(struct seclvl_obj *obj, const char *buff, size_t count) +static u64 seclvl_int_get(void *data) { - unsigned long val; - if (count > 2 || (count == 2 && buff[1] != '\n')) { - seclvl_printk(1, KERN_WARNING, "Invalid value passed to " - "seclvl: [%s]\n", buff); - return -EINVAL; - } - val = buff[0] - 48; - if (seclvl_sanity(val)) { - seclvl_printk(1, KERN_WARNING, "Illegal secure level " - "requested: [%d]\n", (int)val); - return -EPERM; - } - if (do_seclvl_advance(val)) { - seclvl_printk(0, KERN_ERR, "Failure advancing security level " - "to %lu\n", val); - } - return count; + return *(int *)data; } -/* Generate sysfs_attr_seclvl */ -static struct seclvl_attribute sysfs_attr_seclvl = -__ATTR(seclvl, (S_IFREG | S_IRUGO | S_IWUSR), seclvl_read_file, - seclvl_write_file); +DEFINE_SIMPLE_ATTRIBUTE(seclvl_file_ops, seclvl_int_get, do_seclvl_advance, "%lld\n"); static unsigned char hashedPassword[SHA1_DIGEST_SIZE]; -/** - * Called whenever the user reads the sysfs passwd handle. - */ -static ssize_t seclvl_read_passwd(struct seclvl_obj *obj, char *buff) -{ - /* So just how good *is* your password? :-) */ - char tmp[3]; - int i = 0; - buff[0] = '\0'; - if (hideHash) { - /* Security through obscurity */ - return 0; - } - while (i < SHA1_DIGEST_SIZE) { - snprintf(tmp, 3, "%02x", hashedPassword[i]); - strncat(buff, tmp, 2); - i++; - } - strcat(buff, "\n"); - return ((SHA1_DIGEST_SIZE * 2) + 1); -} - /** * Converts a block of plaintext of into its SHA1 hashed value. * @@ -347,12 +231,15 @@ plaintext_to_sha1(unsigned char *hash, const char *plaintext, int len) * object. It hashes the password and compares the hashed results. */ static ssize_t -seclvl_write_passwd(struct seclvl_obj *obj, const char *buff, size_t count) +passwd_write_file(struct file * file, const char __user * buf, + size_t count, loff_t *ppos) { int i; unsigned char tmp[SHA1_DIGEST_SIZE]; + char *page; int rc; int len; + if (!*passwd && !*sha1_passwd) { seclvl_printk(0, KERN_ERR, "Attempt to password-unlock the " "seclvl module, but neither a plain text " @@ -363,13 +250,26 @@ seclvl_write_passwd(struct seclvl_obj *obj, const char *buff, size_t count) "maintainer about this event.\n"); return -EINVAL; } - len = strlen(buff); + + if (count < 0 || count >= PAGE_SIZE) + return -ENOMEM; + if (*ppos != 0) { + return -EINVAL; + } + page = (char *)get_zeroed_page(GFP_KERNEL); + if (!page) + return -ENOMEM; + len = -EFAULT; + if (copy_from_user(page, buf, count)) + goto out; + + len = strlen(page); /* ``echo "secret" > seclvl/passwd'' includes a newline */ - if (buff[len - 1] == '\n') { + if (page[len - 1] == '\n') { len--; } /* Hash the password, then compare the hashed values */ - if ((rc = plaintext_to_sha1(tmp, buff, len))) { + if ((rc = plaintext_to_sha1(tmp, page, len))) { seclvl_printk(0, KERN_ERR, "Error hashing password: rc = " "[%d]\n", rc); return rc; @@ -382,13 +282,16 @@ seclvl_write_passwd(struct seclvl_obj *obj, const char *buff, size_t count) seclvl_printk(0, KERN_INFO, "Password accepted; seclvl reduced to 0.\n"); seclvl = 0; - return count; + len = count; + +out: + free_page((unsigned long)page); + return len; } -/* Generate sysfs_attr_passwd */ -static struct seclvl_attribute sysfs_attr_passwd = -__ATTR(passwd, (S_IFREG | S_IRUGO | S_IWUSR), seclvl_read_passwd, - seclvl_write_passwd); +static struct file_operations passwd_file_ops = { + .write = passwd_write_file, +}; /** * Explicitely disallow ptrace'ing the init process. @@ -647,22 +550,34 @@ static int processPassword(void) } /** - * Sysfs registrations + * securityfs registrations */ -static int doSysfsRegistrations(void) +struct dentry *dir_ino, *seclvl_ino, *passwd_ino; + +static int seclvlfs_register(void) { - int rc = 0; - if ((rc = subsystem_register(&seclvl_subsys))) { - seclvl_printk(0, KERN_WARNING, - "Error [%d] registering seclvl subsystem\n", rc); - return rc; - } - sysfs_create_file(&seclvl_subsys.kset.kobj, &sysfs_attr_seclvl.attr); + dir_ino = securityfs_create_dir("seclvl", NULL); + if (!dir_ino) + return -EFAULT; + + seclvl_ino = securityfs_create_file("seclvl", S_IRUGO | S_IWUSR, + dir_ino, &seclvl, &seclvl_file_ops); + if (!seclvl_ino) + goto out_deldir; if (*passwd || *sha1_passwd) { - sysfs_create_file(&seclvl_subsys.kset.kobj, - &sysfs_attr_passwd.attr); + passwd_ino = securityfs_create_file("passwd", S_IRUGO | S_IWUSR, + dir_ino, NULL, &passwd_file_ops); + if (!passwd_ino) + goto out_delf; } return 0; + +out_deldir: + securityfs_remove(dir_ino); +out_delf: + securityfs_remove(seclvl_ino); + + return -EFAULT; } /** @@ -677,8 +592,6 @@ static int __init seclvl_init(void) rc = -EINVAL; goto exit; } - sysfs_attr_seclvl.attr.owner = THIS_MODULE; - sysfs_attr_passwd.attr.owner = THIS_MODULE; if (initlvl < -1 || initlvl > 2) { seclvl_printk(0, KERN_ERR, "Error: bad initial securelevel " "[%d].\n", initlvl); @@ -706,7 +619,7 @@ static int __init seclvl_init(void) } /* if primary module registered */ secondary = 1; } /* if we registered ourselves with the security framework */ - if ((rc = doSysfsRegistrations())) { + if ((rc = seclvlfs_register())) { seclvl_printk(0, KERN_ERR, "Error registering with sysfs\n"); goto exit; } @@ -724,12 +637,11 @@ static int __init seclvl_init(void) */ static void __exit seclvl_exit(void) { - sysfs_remove_file(&seclvl_subsys.kset.kobj, &sysfs_attr_seclvl.attr); + securityfs_remove(seclvl_ino); if (*passwd || *sha1_passwd) { - sysfs_remove_file(&seclvl_subsys.kset.kobj, - &sysfs_attr_passwd.attr); + securityfs_remove(passwd_ino); } - subsystem_unregister(&seclvl_subsys); + securityfs_remove(dir_ino); if (secondary == 1) { mod_unreg_security(MY_NAME, &seclvl_ops); } else if (unregister_security(&seclvl_ops)) { -- cgit v1.2.3 From ad3f9a2238e401a1fc493b8c91341f9e57940eda Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 13 Jul 2005 15:28:29 +0100 Subject: Fix positioning of audit in MAINTAINERS. Signed-off-by: David Woodhouse --- MAINTAINERS | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index a47b7410247..6b2de371f0f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -363,13 +363,6 @@ L: linux-atm-general@lists.sourceforge.net W: http://linux-atm.sourceforge.net S: Maintained -AUDIT SUBSYSTEM -P: David Woodhouse -M: dwmw2@infradead.org -L: linux-audit@redhat.com -W: http://people.redhat.com/sgrubb/audit/ -S: Maintained - ATMEL WIRELESS DRIVER P: Simon Kelley M: simon@thekelleys.org.uk @@ -378,7 +371,10 @@ W: http://atmelwlandriver.sourceforge.net/ S: Maintained AUDIT SUBSYSTEM -L: linux-audit@redhat.com (subscribers-only) +P: David Woodhouse +M: dwmw2@infradead.org +L: linux-audit@redhat.com +W: http://people.redhat.com/sgrubb/audit/ S: Maintained AX.25 NETWORK LAYER -- cgit v1.2.3 From 6c8c8ba5d7e31b37d0184c388183a6039a672417 Mon Sep 17 00:00:00 2001 From: Victor Fusco Date: Wed, 13 Jul 2005 22:26:57 +0100 Subject: [AUDIT] Fix sparse warning about gfp_mask type Fix the sparse warning "implicit cast to nocast type" Signed-off-by: Victor Fusco Signed-off-by: Domen Puncer Signed-off-by: Andrew Morton Signed-off-by: David Woodhouse --- kernel/audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/audit.c b/kernel/audit.c index b683f2b5e86..518a833b676 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -564,7 +564,7 @@ static void audit_buffer_free(struct audit_buffer *ab) } static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx, - int gfp_mask, int type) + unsigned int __nocast gfp_mask, int type) { unsigned long flags; struct audit_buffer *ab = NULL; -- cgit v1.2.3 From 582edda586120004d0fb67113115fa442a0a1571 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 13 Jul 2005 22:39:34 +0100 Subject: AUDIT: Exempt the whole auditd thread-group from auditing and not just the one thread. Signed-off-by: David Woodhouse --- kernel/auditsc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 0fdd90194ec..86d91fe2d93 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -516,7 +516,7 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk, int word = AUDIT_WORD(ctx->major); int bit = AUDIT_BIT(ctx->major); - if (audit_pid && tsk->pid == audit_pid) + if (audit_pid && tsk->tgid == audit_tgid) return AUDIT_DISABLED; rcu_read_lock(); @@ -1255,7 +1255,7 @@ void audit_signal_info(int sig, struct task_struct *t) extern pid_t audit_sig_pid; extern uid_t audit_sig_uid; - if (unlikely(audit_pid && t->pid == audit_pid)) { + if (unlikely(audit_pid && t->tgid == audit_pid)) { if (sig == SIGTERM || sig == SIGHUP) { struct audit_context *ctx = current->audit_context; audit_sig_pid = current->pid; -- cgit v1.2.3 From f55619642e863990d5a46cf2c2c840170d22a9f9 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 13 Jul 2005 22:47:07 +0100 Subject: AUDIT: Avoid scheduling in idle thread When we flush a pending syscall audit record due to audit_free(), we might be doing that in the context of the idle thread. So use GFP_ATOMIC Signed-off-by: David Woodhouse --- kernel/auditsc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 86d91fe2d93..517b253f1ef 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -41,6 +41,7 @@ #include #include #include +#include #include /* 0 = no checking @@ -778,13 +779,13 @@ static void audit_log_task_info(struct audit_buffer *ab) up_read(&mm->mmap_sem); } -static void audit_log_exit(struct audit_context *context) +static void audit_log_exit(struct audit_context *context, unsigned int gfp_mask) { int i; struct audit_buffer *ab; struct audit_aux_data *aux; - ab = audit_log_start(context, GFP_KERNEL, AUDIT_SYSCALL); + ab = audit_log_start(context, gfp_mask, AUDIT_SYSCALL); if (!ab) return; /* audit_panic has been called */ audit_log_format(ab, "arch=%x syscall=%d", @@ -900,9 +901,11 @@ void audit_free(struct task_struct *tsk) return; /* Check for system calls that do not go through the exit - * function (e.g., exit_group), then free context block. */ + * function (e.g., exit_group), then free context block. + * We use GFP_ATOMIC here because we might be doing this + * in the context of the idle thread */ if (context->in_syscall && context->auditable) - audit_log_exit(context); + audit_log_exit(context, GFP_ATOMIC); audit_free_context(context); } @@ -1007,7 +1010,7 @@ void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code) return; if (context->in_syscall && context->auditable) - audit_log_exit(context); + audit_log_exit(context, GFP_KERNEL); context->in_syscall = 0; context->auditable = 0; -- cgit v1.2.3 From 351bb722590b2329ac5e72c4b824b8b6ce6e3082 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Thu, 14 Jul 2005 14:40:06 +0100 Subject: AUDIT: Fix compile error in audit_filter_syscall We didn't rename it to audit_tgid after all. Except once... Doh. Signed-off-by: David Woodhouse --- kernel/auditsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 517b253f1ef..242d45e5373 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -517,7 +517,7 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk, int word = AUDIT_WORD(ctx->major); int bit = AUDIT_BIT(ctx->major); - if (audit_pid && tsk->tgid == audit_tgid) + if (audit_pid && tsk->tgid == audit_pid) return AUDIT_DISABLED; rcu_read_lock(); -- cgit v1.2.3 From d5b454f2c40c9efd0cc113bc3220ebcb66b7c022 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 15 Jul 2005 12:56:03 +0100 Subject: AUDIT: Fix livelock in audit_serial(). The tricks with atomic_t were bizarre. Just do it sensibly instead. Signed-off-by: David Woodhouse --- kernel/audit.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 518a833b676..27ffcf363f8 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -610,26 +610,25 @@ err: * (timestamp,serial) tuple is unique for each syscall and is live from * syscall entry to syscall exit. * - * Atomic values are only guaranteed to be 24-bit, so we count down. - * * NOTE: Another possibility is to store the formatted records off the * audit context (for those records that have a context), and emit them * all at syscall exit. However, this could delay the reporting of * significant errors until syscall exit (or never, if the system * halts). */ + unsigned int audit_serial(void) { - static atomic_t serial = ATOMIC_INIT(0xffffff); - unsigned int a, b; + static spinlock_t serial_lock = SPIN_LOCK_UNLOCKED; + static unsigned int serial = 0; + + unsigned long flags; + unsigned int ret; - do { - a = atomic_read(&serial); - if (atomic_dec_and_test(&serial)) - atomic_set(&serial, 0xffffff); - b = atomic_read(&serial); - } while (b != a - 1); + spin_lock_irqsave(&serial_lock, flags); + ret = serial++; + spin_unlock_irqrestore(&serial_lock, flags); - return 0xffffff - b; + return ret; } static inline void audit_get_stamp(struct audit_context *ctx, -- cgit v1.2.3 From ce625a801664d8ed7344117bbb57510e4e0e872c Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 18 Jul 2005 14:24:46 -0400 Subject: AUDIT: Reduce contention in audit_serial() ... by generating serial numbers only if an audit context is actually _used_, rather than doing so at syscall entry even when the context isn't necessarily marked auditable. Signed-off-by: David Woodhouse --- kernel/audit.c | 4 +++- kernel/auditsc.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 27ffcf363f8..d321e251d32 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -625,7 +625,9 @@ unsigned int audit_serial(void) unsigned int ret; spin_lock_irqsave(&serial_lock, flags); - ret = serial++; + do { + ret = ++serial; + } while (unlikely(!ret)); spin_unlock_irqrestore(&serial_lock, flags); return ret; diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 242d45e5373..46b45abceb9 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -984,7 +984,7 @@ void audit_syscall_entry(struct task_struct *tsk, int arch, int major, if (likely(state == AUDIT_DISABLED)) return; - context->serial = audit_serial(); + context->serial = 0; context->ctime = CURRENT_TIME; context->in_syscall = 1; context->auditable = !!(state == AUDIT_RECORD_CONTEXT); @@ -1138,6 +1138,8 @@ void audit_inode(const char *name, const struct inode *inode, unsigned flags) void auditsc_get_stamp(struct audit_context *ctx, struct timespec *t, unsigned int *serial) { + if (!ctx->serial) + ctx->serial = audit_serial(); t->tv_sec = ctx->ctime.tv_sec; t->tv_nsec = ctx->ctime.tv_nsec; *serial = ctx->serial; -- cgit v1.2.3 From 413a1c7520ad6207c9122a749983c500f29e3e32 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 17 Aug 2005 14:45:55 +0100 Subject: AUDIT: Fix task refcount leak in audit_filter_syscall() Signed-off-by: David Woodhouse --- kernel/auditsc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 46b45abceb9..a73176eaa57 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -1007,7 +1007,7 @@ void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code) /* Not having a context here is ok, since the parent may have * called __put_task_struct. */ if (likely(!context)) - return; + goto out; if (context->in_syscall && context->auditable) audit_log_exit(context, GFP_KERNEL); @@ -1026,6 +1026,7 @@ void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code) audit_zero_context(context, context->state); tsk->audit_context = context; } + out: put_task_struct(tsk); } -- cgit v1.2.3 From c3896495942392f1a792da1cafba7a573cbf6fc2 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 17 Aug 2005 14:49:57 +0100 Subject: AUDIT: Speed up audit_filter_syscall() for the non-auditable case. It was showing up fairly high on profiles even when no rules were set. Make sure the common path stays as fast as possible. Signed-off-by: David Woodhouse --- kernel/auditsc.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index a73176eaa57..818ef9fdab3 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -513,20 +513,23 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk, struct list_head *list) { struct audit_entry *e; - enum audit_state state; - int word = AUDIT_WORD(ctx->major); - int bit = AUDIT_BIT(ctx->major); + enum audit_state state; if (audit_pid && tsk->tgid == audit_pid) return AUDIT_DISABLED; rcu_read_lock(); - list_for_each_entry_rcu(e, list, list) { - if ((e->rule.mask[word] & bit) == bit - && audit_filter_rules(tsk, &e->rule, ctx, &state)) { - rcu_read_unlock(); - return state; - } + if (!list_empty(list)) { + int word = AUDIT_WORD(ctx->major); + int bit = AUDIT_BIT(ctx->major); + + list_for_each_entry_rcu(e, list, list) { + if ((e->rule.mask[word] & bit) == bit + && audit_filter_rules(tsk, &e->rule, ctx, &state)) { + rcu_read_unlock(); + return state; + } + } } rcu_read_unlock(); return AUDIT_BUILD_CONTEXT; @@ -1023,7 +1026,6 @@ void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code) } else { audit_free_names(context); audit_free_aux(context); - audit_zero_context(context, context->state); tsk->audit_context = context; } out: -- cgit v1.2.3 From 3c789a19054034847afe80af2f23ebb0eebfbad6 Mon Sep 17 00:00:00 2001 From: Amy Griffis Date: Wed, 17 Aug 2005 16:05:35 +0100 Subject: AUDIT: Prevent duplicate syscall rules The following patch against audit.81 prevents duplicate syscall rules in a given filter list by walking the list on each rule add. I also removed the unused struct audit_entry in audit.c and made the static inlines in auditsc.c consistent. Signed-off-by: Amy Griffis Signed-off-by: David Woodhouse --- kernel/audit.c | 5 --- kernel/auditsc.c | 95 +++++++++++++++++++++++++++++++++----------------------- 2 files changed, 56 insertions(+), 44 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index d321e251d32..8376ec10cf2 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -142,11 +142,6 @@ static void audit_set_pid(struct audit_buffer *ab, pid_t pid) nlh->nlmsg_pid = pid; } -struct audit_entry { - struct list_head list; - struct audit_rule rule; -}; - static void audit_panic(const char *message) { switch (audit_failure) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 818ef9fdab3..488ba3dea8b 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -190,9 +190,36 @@ struct audit_entry { extern int audit_pid; +/* Copy rule from user-space to kernel-space. Called from + * audit_add_rule during AUDIT_ADD. */ +static inline int audit_copy_rule(struct audit_rule *d, struct audit_rule *s) +{ + int i; + + if (s->action != AUDIT_NEVER + && s->action != AUDIT_POSSIBLE + && s->action != AUDIT_ALWAYS) + return -1; + if (s->field_count < 0 || s->field_count > AUDIT_MAX_FIELDS) + return -1; + if ((s->flags & ~AUDIT_FILTER_PREPEND) >= AUDIT_NR_FILTERS) + return -1; + + d->flags = s->flags; + d->action = s->action; + d->field_count = s->field_count; + for (i = 0; i < d->field_count; i++) { + d->fields[i] = s->fields[i]; + d->values[i] = s->values[i]; + } + for (i = 0; i < AUDIT_BITMASK_SIZE; i++) d->mask[i] = s->mask[i]; + return 0; +} + /* Check to see if two rules are identical. It is called from + * audit_add_rule during AUDIT_ADD and * audit_del_rule during AUDIT_DEL. */ -static int audit_compare_rule(struct audit_rule *a, struct audit_rule *b) +static inline int audit_compare_rule(struct audit_rule *a, struct audit_rule *b) { int i; @@ -221,18 +248,37 @@ static int audit_compare_rule(struct audit_rule *a, struct audit_rule *b) /* Note that audit_add_rule and audit_del_rule are called via * audit_receive() in audit.c, and are protected by * audit_netlink_sem. */ -static inline void audit_add_rule(struct audit_entry *entry, +static inline int audit_add_rule(struct audit_rule *rule, struct list_head *list) { + struct audit_entry *entry; + + /* Do not use the _rcu iterator here, since this is the only + * addition routine. */ + list_for_each_entry(entry, list, list) { + if (!audit_compare_rule(rule, &entry->rule)) { + return -EEXIST; + } + } + + if (!(entry = kmalloc(sizeof(*entry), GFP_KERNEL))) + return -ENOMEM; + if (audit_copy_rule(&entry->rule, rule)) { + kfree(entry); + return -EINVAL; + } + if (entry->rule.flags & AUDIT_FILTER_PREPEND) { entry->rule.flags &= ~AUDIT_FILTER_PREPEND; list_add_rcu(&entry->list, list); } else { list_add_tail_rcu(&entry->list, list); } + + return 0; } -static void audit_free_rule(struct rcu_head *head) +static inline void audit_free_rule(struct rcu_head *head) { struct audit_entry *e = container_of(head, struct audit_entry, rcu); kfree(e); @@ -258,32 +304,6 @@ static inline int audit_del_rule(struct audit_rule *rule, return -ENOENT; /* No matching rule */ } -/* Copy rule from user-space to kernel-space. Called during - * AUDIT_ADD. */ -static int audit_copy_rule(struct audit_rule *d, struct audit_rule *s) -{ - int i; - - if (s->action != AUDIT_NEVER - && s->action != AUDIT_POSSIBLE - && s->action != AUDIT_ALWAYS) - return -1; - if (s->field_count < 0 || s->field_count > AUDIT_MAX_FIELDS) - return -1; - if ((s->flags & ~AUDIT_FILTER_PREPEND) >= AUDIT_NR_FILTERS) - return -1; - - d->flags = s->flags; - d->action = s->action; - d->field_count = s->field_count; - for (i = 0; i < d->field_count; i++) { - d->fields[i] = s->fields[i]; - d->values[i] = s->values[i]; - } - for (i = 0; i < AUDIT_BITMASK_SIZE; i++) d->mask[i] = s->mask[i]; - return 0; -} - static int audit_list_rules(void *_dest) { int pid, seq; @@ -313,7 +333,6 @@ static int audit_list_rules(void *_dest) int audit_receive_filter(int type, int pid, int uid, int seq, void *data, uid_t loginuid) { - struct audit_entry *entry; struct task_struct *tsk; int *dest; int err = 0; @@ -340,16 +359,14 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data, } break; case AUDIT_ADD: - if (!(entry = kmalloc(sizeof(*entry), GFP_KERNEL))) - return -ENOMEM; - if (audit_copy_rule(&entry->rule, data)) { - kfree(entry); + listnr =((struct audit_rule *)data)->flags & ~AUDIT_FILTER_PREPEND; + if (listnr >= AUDIT_NR_FILTERS) return -EINVAL; - } - listnr = entry->rule.flags & ~AUDIT_FILTER_PREPEND; - audit_add_rule(entry, &audit_filter_list[listnr]); - audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, - "auid=%u added an audit rule\n", loginuid); + + err = audit_add_rule(data, &audit_filter_list[listnr]); + if (!err) + audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, + "auid=%u added an audit rule\n", loginuid); break; case AUDIT_DEL: listnr =((struct audit_rule *)data)->flags & ~AUDIT_FILTER_PREPEND; -- cgit v1.2.3 From 2c40579bdc2a94977fcff2521d5b53a97c33e77a Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 22 Aug 2005 18:20:50 +0200 Subject: [PATCH] SECURITY must depend on SYSFS CONFIG_SECURITY=y and CONFIG_SYSFS=n results in the following compile error: <-- snip --> ... LD vmlinux security/built-in.o: In function `securityfs_init': inode.c:(.init.text+0x1c2): undefined reference to `kernel_subsys' make: *** [vmlinux] Error 1 <-- snip --> Signed-off-by: Adrian Bunk Signed-off-by: Chris Wright --- security/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/security/Kconfig b/security/Kconfig index dcf04a09185..64d3f1e9ca8 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -35,6 +35,7 @@ config KEYS_DEBUG_PROC_KEYS config SECURITY bool "Enable different security models" + depends on SYSFS help This allows you to choose different security modules to be configured into your kernel. -- cgit v1.2.3 From 17888225c2f392bfdbac6c7f0713cbd9a4d02b05 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sat, 27 Aug 2005 10:23:46 +0100 Subject: Fix missing audit_syscall_exit() on ppc64 sigsuspend exit path When we leave sigsuspend() directly into a signal handler, we don't want to go via the normal syscall exit path -- it'll corrupt r4 and r5 which are supposed to be giving information to the signal handler, and it'll give us one more single-step SIGTRAP than we need if single-stepping is in operation. However, we _should_ be calling audit_syscall_exit(), which would normally get invoked in that patch. It's not wonderfully pretty, but I suspect the best answer is just to call it directly... Signed-off-by: David Woodhouse --- arch/ppc64/kernel/asm-offsets.c | 1 + arch/ppc64/kernel/entry.S | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/ppc64/kernel/asm-offsets.c b/arch/ppc64/kernel/asm-offsets.c index abb9e5b5da0..6f910fa2746 100644 --- a/arch/ppc64/kernel/asm-offsets.c +++ b/arch/ppc64/kernel/asm-offsets.c @@ -68,6 +68,7 @@ int main(void) DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr)); #endif /* CONFIG_ALTIVEC */ DEFINE(MM, offsetof(struct task_struct, mm)); + DEFINE(AUDITCONTEXT, offsetof(struct task_struct, audit_context)); DEFINE(DCACHEL1LINESIZE, offsetof(struct ppc64_caches, dline_size)); DEFINE(DCACHEL1LOGLINESIZE, offsetof(struct ppc64_caches, log_dline_size)); diff --git a/arch/ppc64/kernel/entry.S b/arch/ppc64/kernel/entry.S index b61572eb2a7..ae5d563ad93 100644 --- a/arch/ppc64/kernel/entry.S +++ b/arch/ppc64/kernel/entry.S @@ -276,12 +276,20 @@ _GLOBAL(ppc64_rt_sigsuspend) _GLOBAL(ppc32_rt_sigsuspend) bl .save_nvgprs bl .sys32_rt_sigsuspend - /* If sigsuspend() returns zero, we are going into a signal handler */ 70: cmpdi 0,r3,0 - beq .ret_from_except - /* If it returned -EINTR, we need to return via syscall_exit to set + /* If it returned an error, we need to return via syscall_exit to set the SO bit in cr0 and potentially stop for ptrace. */ - b syscall_exit + bne syscall_exit + /* If sigsuspend() returns zero, we are going into a signal handler. We + may need to call audit_syscall_exit() to mark the exit from sigsuspend() */ + ld r3,PACACURRENT(r13) + ld r4,AUDITCONTEXT(r3) + cmpdi 0,r4,0 + beq .ret_from_except /* No audit_context: Leave immediately. */ + li r4, 2 /* AUDITSC_FAILURE */ + li r5,-4 /* It's always -EINTR */ + bl .audit_syscall_exit + b .ret_from_except _GLOBAL(ppc_fork) bl .save_nvgprs -- cgit v1.2.3 From b01f2cc1c37ac3d5ca313c90370a586dffe5aca9 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sat, 27 Aug 2005 10:25:43 +0100 Subject: [AUDIT] Allow filtering on system call success _or_ failure Signed-off-by: David Woodhouse --- kernel/auditsc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 488ba3dea8b..88696f639aa 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -440,8 +440,12 @@ static int audit_filter_rules(struct task_struct *tsk, result = (ctx->return_code == value); break; case AUDIT_SUCCESS: - if (ctx && ctx->return_valid) - result = (ctx->return_valid == AUDITSC_SUCCESS); + if (ctx && ctx->return_valid) { + if (value) + result = (ctx->return_valid == AUDITSC_SUCCESS); + else + result = (ctx->return_valid == AUDITSC_FAILURE); + } break; case AUDIT_DEVMAJOR: if (ctx) { -- cgit v1.2.3 From b6ddc518520887a62728b0414efbf802a9dfdd55 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 6 Sep 2005 08:09:03 +0100 Subject: Fix build failure on ppc64 without CONFIG_AUDIT We shouldn't call audit_syscall_exit() unless it actually exists. Signed-off-by: David Woodhouse --- arch/ppc64/kernel/entry.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/ppc64/kernel/entry.S b/arch/ppc64/kernel/entry.S index ae5d563ad93..14cd56ac40d 100644 --- a/arch/ppc64/kernel/entry.S +++ b/arch/ppc64/kernel/entry.S @@ -282,6 +282,7 @@ _GLOBAL(ppc32_rt_sigsuspend) bne syscall_exit /* If sigsuspend() returns zero, we are going into a signal handler. We may need to call audit_syscall_exit() to mark the exit from sigsuspend() */ +#ifdef CONFIG_AUDIT ld r3,PACACURRENT(r13) ld r4,AUDITCONTEXT(r3) cmpdi 0,r4,0 @@ -289,6 +290,7 @@ _GLOBAL(ppc32_rt_sigsuspend) li r4, 2 /* AUDITSC_FAILURE */ li r5,-4 /* It's always -EINTR */ bl .audit_syscall_exit +#endif b .ret_from_except _GLOBAL(ppc_fork) -- cgit v1.2.3 From 7b4af953321fa65ae5705cb3becc742ab1ba1d6f Mon Sep 17 00:00:00 2001 From: "Arnaud Patard (Rtp)" Date: Thu, 8 Sep 2005 07:42:02 +0200 Subject: [WATCHDOG] s3c2410_wdt.c-state_warning.patch I've noticed that the patch from Ben Dooks (commit af4bb822bc65efb087cd36b83789f22161a6515b on your git tree) is introducing a warning. It's using 'u32 state' instead of 'pm_message_t state'. I've attached a one liner to fix it. Signed-Off-By: Arnaud Patard Signed-off-by: Ben Dooks Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/s3c2410_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index 8b292bf343c..3625b2601b4 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c @@ -464,7 +464,7 @@ static void s3c2410wdt_shutdown(struct device *dev) static unsigned long wtcon_save; static unsigned long wtdat_save; -static int s3c2410wdt_suspend(struct device *dev, u32 state, u32 level) +static int s3c2410wdt_suspend(struct device *dev, pm_message_t state, u32 level) { if (level == SUSPEND_POWER_DOWN) { /* Save watchdog state, and turn it off. */ -- cgit v1.2.3 From 180536f8274b76d69a589ab9af4b73d3b780e62f Mon Sep 17 00:00:00 2001 From: Wim Van Sebroeck Date: Sat, 10 Sep 2005 20:53:57 +0200 Subject: [WATCHDOG] Kconfig+Makefile-clean2 Clean the Kconfig+Makefile according to a sorted list of the drivers of each architecture (and sub-architecture). Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/Kconfig | 43 +++++++++++++++++++++--------------------- drivers/char/watchdog/Makefile | 2 +- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index c3898afce3a..f5af900704a 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig @@ -84,6 +84,17 @@ config 977_WATCHDOG Not sure? It's safe to say N. +config IXP2000_WATCHDOG + tristate "IXP2000 Watchdog" + depends on WATCHDOG && ARCH_IXP2000 + help + Say Y here if to include support for the watchdog timer + in the Intel IXP2000(2400, 2800, 2850) network processors. + This driver can be built as a module by choosing M. The module + will be called ixp2000_wdt. + + Say N if you are unsure. + config IXP4XX_WATCHDOG tristate "IXP4xx Watchdog" depends on WATCHDOG && ARCH_IXP4XX @@ -100,17 +111,6 @@ config IXP4XX_WATCHDOG Say N if you are unsure. -config IXP2000_WATCHDOG - tristate "IXP2000 Watchdog" - depends on WATCHDOG && ARCH_IXP2000 - help - Say Y here if to include support for the watchdog timer - in the Intel IXP2000(2400, 2800, 2850) network processors. - This driver can be built as a module by choosing M. The module - will be called ixp2000_wdt. - - Say N if you are unsure. - config S3C2410_WATCHDOG tristate "S3C2410 Watchdog" depends on WATCHDOG && ARCH_S3C2410 @@ -353,6 +353,17 @@ config BOOKE_WDT Please see Documentation/watchdog/watchdog-api.txt for more information. +# PPC64 Architecture + +config WATCHDOG_RTAS + tristate "RTAS watchdog" + depends on WATCHDOG && PPC_RTAS + help + This driver adds watchdog support for the RTAS watchdog. + + To compile this driver as a module, choose M here. The module + will be called wdrtas. + # MIPS Architecture config INDYDOG @@ -421,16 +432,6 @@ config WATCHDOG_RIO machines. The watchdog timeout period is normally one minute but can be changed with a boot-time parameter. -# ppc64 RTAS watchdog -config WATCHDOG_RTAS - tristate "RTAS watchdog" - depends on WATCHDOG && PPC_RTAS - help - This driver adds watchdog support for the RTAS watchdog. - - To compile this driver as a module, choose M here. The module - will be called wdrtas. - # # ISA-based Watchdog Cards # diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index cfeac6f1013..fbd5cf63064 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile @@ -50,10 +50,10 @@ obj-$(CONFIG_MACHZ_WDT) += machzwd.o # PowerPC Architecture obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o +obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o # PPC64 Architecture obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o -obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o # MIPS Architecture obj-$(CONFIG_INDYDOG) += indydog.o -- cgit v1.2.3 From 3be10211abcb631ba9631274d6cfe6e5b1e8559c Mon Sep 17 00:00:00 2001 From: James Chapman Date: Wed, 17 Aug 2005 09:01:33 +0200 Subject: [WATCHDOG] mv64x60_wdt.patch Add mv64x60 (Marvell Discovery) watchdog support. Signed-off-by: James Chapman Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/Kconfig | 4 + drivers/char/watchdog/Makefile | 1 + drivers/char/watchdog/mv64x60_wdt.c | 252 ++++++++++++++++++++++++++++++++++++ include/asm-ppc/mv64x60.h | 8 ++ 4 files changed, 265 insertions(+) create mode 100644 drivers/char/watchdog/mv64x60_wdt.c diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index f5af900704a..e8ad14d9a7f 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig @@ -346,6 +346,10 @@ config 8xx_WDT tristate "MPC8xx Watchdog Timer" depends on WATCHDOG && 8xx +config MV64X60_WDT + tristate "MV64X60 (Marvell Discovery) Watchdog Timer" + depends on WATCHDOG && MV64X60 + config BOOKE_WDT tristate "PowerPC Book-E Watchdog Timer" depends on WATCHDOG && (BOOKE || 4xx) diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index fbd5cf63064..2373e1710ae 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile @@ -50,6 +50,7 @@ obj-$(CONFIG_MACHZ_WDT) += machzwd.o # PowerPC Architecture obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o +obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o # PPC64 Architecture diff --git a/drivers/char/watchdog/mv64x60_wdt.c b/drivers/char/watchdog/mv64x60_wdt.c new file mode 100644 index 00000000000..1436aea3b28 --- /dev/null +++ b/drivers/char/watchdog/mv64x60_wdt.c @@ -0,0 +1,252 @@ +/* + * mv64x60_wdt.c - MV64X60 (Marvell Discovery) watchdog userspace interface + * + * Author: James Chapman + * + * Platform-specific setup code should configure the dog to generate + * interrupt or reset as required. This code only enables/disables + * and services the watchdog. + * + * Derived from mpc8xx_wdt.c, with the following copyright. + * + * 2002 (c) Florian Schirmer This file is licensed under + * the terms of the GNU General Public License version 2. This program + * is licensed "as is" without any warranty of any kind, whether express + * or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* MV64x60 WDC (config) register access definitions */ +#define MV64x60_WDC_CTL1_MASK (3 << 24) +#define MV64x60_WDC_CTL1(val) ((val & 3) << 24) +#define MV64x60_WDC_CTL2_MASK (3 << 26) +#define MV64x60_WDC_CTL2(val) ((val & 3) << 26) + +/* Flags bits */ +#define MV64x60_WDOG_FLAG_OPENED 0 +#define MV64x60_WDOG_FLAG_ENABLED 1 + +static unsigned long wdt_flags; +static int wdt_status; +static void __iomem *mv64x60_regs; +static int mv64x60_wdt_timeout; + +static void mv64x60_wdt_reg_write(u32 val) +{ + /* Allow write only to CTL1 / CTL2 fields, retaining values in + * other fields. + */ + u32 data = readl(mv64x60_regs + MV64x60_WDT_WDC); + data &= ~(MV64x60_WDC_CTL1_MASK | MV64x60_WDC_CTL2_MASK); + data |= val; + writel(data, mv64x60_regs + MV64x60_WDT_WDC); +} + +static void mv64x60_wdt_service(void) +{ + /* Write 01 followed by 10 to CTL2 */ + mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x01)); + mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x02)); +} + +static void mv64x60_wdt_handler_disable(void) +{ + if (test_and_clear_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) { + /* Write 01 followed by 10 to CTL1 */ + mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01)); + mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02)); + printk(KERN_NOTICE "mv64x60_wdt: watchdog deactivated\n"); + } +} + +static void mv64x60_wdt_handler_enable(void) +{ + if (!test_and_set_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) { + /* Write 01 followed by 10 to CTL1 */ + mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01)); + mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02)); + printk(KERN_NOTICE "mv64x60_wdt: watchdog activated\n"); + } +} + +static int mv64x60_wdt_open(struct inode *inode, struct file *file) +{ + if (test_and_set_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags)) + return -EBUSY; + + mv64x60_wdt_service(); + mv64x60_wdt_handler_enable(); + + return 0; +} + +static int mv64x60_wdt_release(struct inode *inode, struct file *file) +{ + mv64x60_wdt_service(); + +#if !defined(CONFIG_WATCHDOG_NOWAYOUT) + mv64x60_wdt_handler_disable(); +#endif + + clear_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags); + + return 0; +} + +static ssize_t mv64x60_wdt_write(struct file *file, const char *data, + size_t len, loff_t * ppos) +{ + if (*ppos != file->f_pos) + return -ESPIPE; + + if (len) + mv64x60_wdt_service(); + + return len; +} + +static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + int timeout; + static struct watchdog_info info = { + .options = WDIOF_KEEPALIVEPING, + .firmware_version = 0, + .identity = "MV64x60 watchdog", + }; + + switch (cmd) { + case WDIOC_GETSUPPORT: + if (copy_to_user((void *)arg, &info, sizeof(info))) + return -EFAULT; + break; + + case WDIOC_GETSTATUS: + case WDIOC_GETBOOTSTATUS: + if (put_user(wdt_status, (int *)arg)) + return -EFAULT; + wdt_status &= ~WDIOF_KEEPALIVEPING; + break; + + case WDIOC_GETTEMP: + return -EOPNOTSUPP; + + case WDIOC_SETOPTIONS: + return -EOPNOTSUPP; + + case WDIOC_KEEPALIVE: + mv64x60_wdt_service(); + wdt_status |= WDIOF_KEEPALIVEPING; + break; + + case WDIOC_SETTIMEOUT: + return -EOPNOTSUPP; + + case WDIOC_GETTIMEOUT: + timeout = mv64x60_wdt_timeout * HZ; + if (put_user(timeout, (int *)arg)) + return -EFAULT; + break; + + default: + return -ENOIOCTLCMD; + } + + return 0; +} + +static struct file_operations mv64x60_wdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = mv64x60_wdt_write, + .ioctl = mv64x60_wdt_ioctl, + .open = mv64x60_wdt_open, + .release = mv64x60_wdt_release, +}; + +static struct miscdevice mv64x60_wdt_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &mv64x60_wdt_fops, +}; + +static int __devinit mv64x60_wdt_probe(struct device *dev) +{ + struct platform_device *pd = to_platform_device(dev); + struct mv64x60_wdt_pdata *pdata = pd->dev.platform_data; + int bus_clk = 133; + + mv64x60_wdt_timeout = 10; + if (pdata) { + mv64x60_wdt_timeout = pdata->timeout; + bus_clk = pdata->bus_clk; + } + + mv64x60_regs = mv64x60_get_bridge_vbase(); + + writel((mv64x60_wdt_timeout * (bus_clk * 1000000)) >> 8, + mv64x60_regs + MV64x60_WDT_WDC); + + return misc_register(&mv64x60_wdt_miscdev); +} + +static int __devexit mv64x60_wdt_remove(struct device *dev) +{ + misc_deregister(&mv64x60_wdt_miscdev); + + mv64x60_wdt_service(); + mv64x60_wdt_handler_disable(); + + return 0; +} + +static struct device_driver mv64x60_wdt_driver = { + .name = MV64x60_WDT_NAME, + .bus = &platform_bus_type, + .probe = mv64x60_wdt_probe, + .remove = __devexit_p(mv64x60_wdt_remove), +}; + +static struct platform_device *mv64x60_wdt_dev; + +static int __init mv64x60_wdt_init(void) +{ + int ret; + + printk(KERN_INFO "MV64x60 watchdog driver\n"); + + mv64x60_wdt_dev = platform_device_register_simple(MV64x60_WDT_NAME, + -1, NULL, 0); + if (IS_ERR(mv64x60_wdt_dev)) { + ret = PTR_ERR(mv64x60_wdt_dev); + goto out; + } + + ret = driver_register(&mv64x60_wdt_driver); + out: + return ret; +} + +static void __exit mv64x60_wdt_exit(void) +{ + driver_unregister(&mv64x60_wdt_driver); + platform_device_unregister(mv64x60_wdt_dev); +} + +module_init(mv64x60_wdt_init); +module_exit(mv64x60_wdt_exit); + +MODULE_AUTHOR("James Chapman "); +MODULE_DESCRIPTION("MV64x60 watchdog driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); diff --git a/include/asm-ppc/mv64x60.h b/include/asm-ppc/mv64x60.h index 835930d6faa..75c2ffa26b2 100644 --- a/include/asm-ppc/mv64x60.h +++ b/include/asm-ppc/mv64x60.h @@ -119,6 +119,14 @@ extern spinlock_t mv64x60_lock; #define MV64x60_64BIT_WIN_COUNT 24 +/* Watchdog Platform Device, Driver Data */ +#define MV64x60_WDT_NAME "wdt" + +struct mv64x60_wdt_pdata { + int timeout; /* watchdog expiry in seconds, default 10 */ + int bus_clk; /* bus clock in MHz, default 133 */ +}; + /* * Define a structure that's used to pass in config information to the * core routines. -- cgit v1.2.3 From cc90ef0f9b24d1b017c8cfa22db5195c17b5c968 Mon Sep 17 00:00:00 2001 From: David Hardeman Date: Wed, 17 Aug 2005 09:07:44 +0200 Subject: [WATCHDOG] i6300esb.patch I wrote earlier to the list[1] asking for a driver for the watchdog included in the 6300ESB chipset. I got a 2.4 driver via private email from Ross Biro which I've changed into what I hope resembles a 2.6 driver (which was done by looking a lot at the watchdog drivers already in the 2.6 tree). I've attached the result, and I'm hoping to get some feedback on the coding as a first step. I can't actually test it on the hardware right now as I won't have physical access until April. So my own tests have been limited to "compiles-without-warnings" and "can-be-insmodded-in-other-machine-without-oops". [1] http://marc.theaimsgroup.com/?l=linux-kernel&m=110711079825794&w=2 [2] http://marc.theaimsgroup.com/?l=linux-kernel&m=110711973917746&w=2 Signed-off-by: David Hardeman Signed-off-by: Andrew Morton Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/Kconfig | 10 + drivers/char/watchdog/Makefile | 1 + drivers/char/watchdog/i6300esb.c | 508 +++++++++++++++++++++++++++++++++++++++ drivers/char/watchdog/i6300esb.h | 62 +++++ 4 files changed, 581 insertions(+) create mode 100644 drivers/char/watchdog/i6300esb.c create mode 100644 drivers/char/watchdog/i6300esb.h diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index e8ad14d9a7f..742c9c5bb1a 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig @@ -234,6 +234,16 @@ config WAFER_WDT To compile this driver as a module, choose M here: the module will be called wafer5823wdt. +config I6300ESB_WDT + tristate "Intel 6300ESB Timer/Watchdog" + depends on WATCHDOG && X86 && PCI + ---help--- + Hardware driver for the watchdog timer built into the Intel + 6300ESB controller hub. + + To compile this driver as a module, choose M here: the + module will be called i6300esb. + config I8XX_TCO tristate "Intel i8xx TCO Timer/Watchdog" depends on WATCHDOG && (X86 || IA64) && PCI diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index 2373e1710ae..2f45ba6a6d1 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile @@ -39,6 +39,7 @@ obj-$(CONFIG_SC520_WDT) += sc520_wdt.o obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o obj-$(CONFIG_IB700_WDT) += ib700wdt.o obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o +obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o diff --git a/drivers/char/watchdog/i6300esb.c b/drivers/char/watchdog/i6300esb.c new file mode 100644 index 00000000000..87273839aea --- /dev/null +++ b/drivers/char/watchdog/i6300esb.c @@ -0,0 +1,508 @@ +/* + * i6300esb 0.03: Watchdog timer driver for Intel 6300ESB chipset + * + * (c) Copyright 2004 Google Inc. + * + * 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 the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * based on i810-tco.c which is + * + * (c) Copyright 2000 kernel concepts + * developed for + * Jentro AG, Haar/Munich (Germany) + * + * which is in turn based on softdog.c by Alan Cox + * + * The timer is implemented in the following I/O controller hubs: + * (See the intel documentation on http://developer.intel.com.) + * 6300ESB chip : document number 300641-003 + * + * 2004YYZZ Ross Biro + * Initial version 0.01 + * 2004YYZZ Ross Biro + * Version 0.02 + * 20050210 David Härdeman + * Ported driver to kernel 2.6 + */ + +/* + * Includes, defines, variables, module parameters, ... + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "i6300esb.h" + +/* Module and version information */ +#define ESB_VERSION "0.03" +#define ESB_MODULE_NAME "i6300ESB timer" +#define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION +#define PFX ESB_MODULE_NAME ": " + +/* internal variables */ +static void __iomem *BASEADDR; +static spinlock_t esb_lock; /* Guards the hardware */ +static unsigned long timer_alive; +static struct pci_dev *esb_pci; +static unsigned short triggered; /* The status of the watchdog upon boot */ +static char esb_expect_close; + +/* module parameters */ +#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat (1 (2 * 0x03ff)) + return -EINVAL; + + spin_lock(&esb_lock); + + /* We shift by 9, so if we are passed a value of 1 sec, + * val will be 1 << 9 = 512, then write that to two + * timers => 2 * 512 = 1024 (which is decremented at 1KHz) + */ + val = time << 9; + + /* Write timer 1 */ + esb_unlock_registers(); + writel(val, ESB_TIMER1_REG); + + /* Write timer 2 */ + esb_unlock_registers(); + writel(val, ESB_TIMER2_REG); + + /* Reload */ + esb_unlock_registers(); + writew(0x10, ESB_RELOAD_REG); + + /* FIXME: Do we need to flush everything out? */ + + /* Done */ + heartbeat = time; + spin_unlock(&esb_lock); + return 0; +} + +static int esb_timer_read (void) +{ + u32 count; + + /* This isn't documented, and doesn't take into + * acount which stage is running, but it looks + * like a 20 bit count down, so we might as well report it. + */ + pci_read_config_dword(esb_pci, 0x64, &count); + return (int)count; +} + +/* + * /dev/watchdog handling + */ + +static int esb_open (struct inode *inode, struct file *file) +{ + /* /dev/watchdog can only be opened once */ + if (test_and_set_bit(0, &timer_alive)) + return -EBUSY; + + /* Reload and activate timer */ + esb_timer_keepalive (); + esb_timer_start (); + + return nonseekable_open(inode, file); +} + +static int esb_release (struct inode *inode, struct file *file) +{ + /* Shut off the timer. */ + if (esb_expect_close == 42) { + esb_timer_stop (); + } else { + printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); + esb_timer_keepalive (); + } + clear_bit(0, &timer_alive); + esb_expect_close = 0; + return 0; +} + +static ssize_t esb_write (struct file *file, const char __user *data, + size_t len, loff_t * ppos) +{ + /* See if we got the magic character 'V' and reload the timer */ + if (len) { + if (!nowayout) { + size_t i; + + /* note: just in case someone wrote the magic character + * five months ago... */ + esb_expect_close = 0; + + /* scan to see whether or not we got the magic character */ + for (i = 0; i != len; i++) { + char c; + if(get_user(c, data+i)) + return -EFAULT; + if (c == 'V') + esb_expect_close = 42; + } + } + + /* someone wrote to us, we should reload the timer */ + esb_timer_keepalive (); + } + return len; +} + +static int esb_ioctl (struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + int new_options, retval = -EINVAL; + int new_heartbeat; + void __user *argp = (void __user *)arg; + int __user *p = argp; + static struct watchdog_info ident = { + .options = WDIOF_SETTIMEOUT | + WDIOF_KEEPALIVEPING | + WDIOF_MAGICCLOSE, + .firmware_version = 0, + .identity = ESB_MODULE_NAME, + }; + + switch (cmd) { + case WDIOC_GETSUPPORT: + return copy_to_user(argp, &ident, + sizeof (ident)) ? -EFAULT : 0; + + case WDIOC_GETSTATUS: + return put_user (esb_timer_read(), p); + + case WDIOC_GETBOOTSTATUS: + return put_user (triggered, p); + + case WDIOC_KEEPALIVE: + esb_timer_keepalive (); + return 0; + + case WDIOC_SETOPTIONS: + { + if (get_user (new_options, p)) + return -EFAULT; + + if (new_options & WDIOS_DISABLECARD) { + esb_timer_stop (); + retval = 0; + } + + if (new_options & WDIOS_ENABLECARD) { + esb_timer_keepalive (); + esb_timer_start (); + retval = 0; + } + + return retval; + } + + case WDIOC_SETTIMEOUT: + { + if (get_user(new_heartbeat, p)) + return -EFAULT; + + if (esb_timer_set_heartbeat(new_heartbeat)) + return -EINVAL; + + esb_timer_keepalive (); + /* Fall */ + } + + case WDIOC_GETTIMEOUT: + return put_user(heartbeat, p); + + default: + return -ENOIOCTLCMD; + } +} + +/* + * Notify system + */ + +static int esb_notify_sys (struct notifier_block *this, unsigned long code, void *unused) +{ + if (code==SYS_DOWN || code==SYS_HALT) { + /* Turn the WDT off */ + esb_timer_stop (); + } + + return NOTIFY_DONE; +} + +/* + * Kernel Interfaces + */ + +static struct file_operations esb_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = esb_write, + .ioctl = esb_ioctl, + .open = esb_open, + .release = esb_release, +}; + +static struct miscdevice esb_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &esb_fops, +}; + +static struct notifier_block esb_notifier = { + .notifier_call = esb_notify_sys, +}; + +/* + * Data for PCI driver interface + * + * This data only exists for exporting the supported + * PCI ids via MODULE_DEVICE_TABLE. We do not actually + * register a pci_driver, because someone else might one day + * want to register another driver on the same PCI id. + */ +static struct pci_device_id esb_pci_tbl[] = { + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9, PCI_ANY_ID, PCI_ANY_ID, }, + { 0, }, /* End of list */ +}; +MODULE_DEVICE_TABLE (pci, esb_pci_tbl); + +/* + * Init & exit routines + */ + +static unsigned char __init esb_getdevice (void) +{ + u8 val1; + unsigned short val2; + + struct pci_dev *dev = NULL; + /* + * Find the PCI device + */ + + while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + if (pci_match_device(esb_pci_tbl, dev)) { + esb_pci = dev; + break; + } + } + + if (esb_pci) { + if (pci_enable_device(esb_pci)) { + printk (KERN_ERR PFX "failed to enable device\n"); + goto out; + } + + if (pci_request_region(esb_pci, 0, ESB_MODULE_NAME)) { + printk (KERN_ERR PFX "failed to request region\n"); + goto err_disable; + } + + BASEADDR = ioremap(pci_resource_start(esb_pci, 0), + pci_resource_len(esb_pci, 0)); + if (BASEADDR == NULL) { + /* Something's wrong here, BASEADDR has to be set */ + printk (KERN_ERR PFX "failed to get BASEADDR\n"); + goto err_release; + } + + /* + * The watchdog has two timers, it can be setup so that the + * expiry of timer1 results in an interrupt and the expiry of + * timer2 results in a reboot. We set it to not generate + * any interrupts as there is not much we can do with it + * right now. + * + * We also enable reboots and set the timer frequency to + * the PCI clock divided by 2^15 (approx 1KHz). + */ + pci_write_config_word(esb_pci, ESB_CONFIG_REG, 0x0003); + + /* Check that the WDT isn't already locked */ + pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val1); + if (val1 & ESB_WDT_LOCK) + printk (KERN_WARNING PFX "nowayout already set\n"); + + /* Set the timer to watchdog mode and disable it for now */ + pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x00); + + /* Check if the watchdog was previously triggered */ + esb_unlock_registers(); + val2 = readw(ESB_RELOAD_REG); + triggered = (val2 & (0x01 << 9) >> 9); + + /* Reset trigger flag and timers */ + esb_unlock_registers(); + writew((0x11 << 8), ESB_RELOAD_REG); + + /* Done */ + return 1; + +err_release: + pci_release_region(esb_pci, 0); +err_disable: + pci_disable_device(esb_pci); + } +out: + return 0; +} + +static int __init watchdog_init (void) +{ + int ret; + + spin_lock_init(&esb_lock); + + /* Check whether or not the hardware watchdog is there */ + if (!esb_getdevice () || esb_pci == NULL) + return -ENODEV; + + /* Check that the heartbeat value is within it's range ; if not reset to the default */ + if (esb_timer_set_heartbeat (heartbeat)) { + esb_timer_set_heartbeat (WATCHDOG_HEARTBEAT); + printk(KERN_INFO PFX "heartbeat value must be 1, All Rights Reserved. + * http://www.kernelconcepts.de + * + * 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 the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Neither kernel concepts nor Nils Faerber admit liability nor provide + * warranty for any of this software. This material is provided + * "AS-IS" and at no charge. + * + * (c) Copyright 2000 kernel concepts + * developed for + * Jentro AG, Haar/Munich (Germany) + * + * TCO timer driver for i8xx chipsets + * based on softdog.c by Alan Cox + * + * For history and the complete list of supported I/O Controller Hub's + * see i8xx_tco.c + */ + + +/* + * Some address definitions for the TCO + */ + +/* PCI configuration registers */ +#define ESB_CONFIG_REG 0x60 /* Config register */ +#define ESB_LOCK_REG 0x68 /* WDT lock register */ + +/* Memory mapped registers */ +#define ESB_TIMER1_REG BASEADDR + 0x00 /* Timer1 value after each reset */ +#define ESB_TIMER2_REG BASEADDR + 0x04 /* Timer2 value after each reset */ +#define ESB_GINTSR_REG BASEADDR + 0x08 /* General Interrupt Status Register */ +#define ESB_RELOAD_REG BASEADDR + 0x0c /* Reload register */ + + +/* + * Some register bits + */ + +/* Lock register bits */ +#define ESB_WDT_FUNC ( 0x01 << 2 ) /* Watchdog functionality */ +#define ESB_WDT_ENABLE ( 0x01 << 1 ) /* Enable WDT */ +#define ESB_WDT_LOCK ( 0x01 << 0 ) /* Lock (nowayout) */ + +/* Config register bits */ +#define ESB_WDT_REBOOT ( 0x01 << 5 ) /* Enable reboot on timeout */ +#define ESB_WDT_FREQ ( 0x01 << 2 ) /* Decrement frequency */ +#define ESB_WDT_INTTYPE ( 0x11 << 0 ) /* Interrupt type on timer1 timeout */ + + +/* + * Some magic constants + */ +#define ESB_UNLOCK1 0x80 /* Step 1 to unlock reset registers */ +#define ESB_UNLOCK2 0x86 /* Step 2 to unlock reset registers */ -- cgit v1.2.3 From c69af038cad5e6ea86e927a17b70b49af1f7cbfa Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Wed, 17 Aug 2005 09:09:13 +0200 Subject: [WATCHDOG] removes pci_find_device from i6300esb.c This patch changes pci_find_device to pci_get_device (encapsulated in for_each_pci_dev) in i6300esb watchdog card with appropriate adding pci_dev_put. Generated in 2.6.13-rc5-mm1 kernel version. Signed-off-by: Jiri Slaby Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/i6300esb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/char/watchdog/i6300esb.c b/drivers/char/watchdog/i6300esb.c index 87273839aea..20ceb5fe28b 100644 --- a/drivers/char/watchdog/i6300esb.c +++ b/drivers/char/watchdog/i6300esb.c @@ -368,12 +368,11 @@ static unsigned char __init esb_getdevice (void) * Find the PCI device */ - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) if (pci_match_device(esb_pci_tbl, dev)) { esb_pci = dev; break; } - } if (esb_pci) { if (pci_enable_device(esb_pci)) { @@ -430,6 +429,7 @@ err_release: pci_release_region(esb_pci, 0); err_disable: pci_disable_device(esb_pci); + pci_dev_put(esb_pci); } out: return 0; @@ -481,6 +481,7 @@ err_unmap: pci_release_region(esb_pci, 0); /* err_disable: */ pci_disable_device(esb_pci); + pci_dev_put(esb_pci); /* out: */ return ret; } @@ -497,6 +498,7 @@ static void __exit watchdog_cleanup (void) iounmap(BASEADDR); pci_release_region(esb_pci, 0); pci_disable_device(esb_pci); + pci_dev_put(esb_pci); } module_init(watchdog_init); -- cgit v1.2.3 From 28562af3d4b21d687dd57c44006aeeed1036c781 Mon Sep 17 00:00:00 2001 From: Naveen Gupta Date: Wed, 17 Aug 2005 09:10:10 +0200 Subject: [WATCHDOG] i6300esb.c-WDT_ENABLE-bug This patch sets the WDT_ENABLE bit of the Lock Register to enable the watchdog and WDT_LOCK bit only if nowayout is set. The old code always sets the WDT_LOCK bit of watchdog timer for Intel 6300ESB chipset. So, we end up locking the watchdog instead of enabling it. Signed-off-by: Naveen Gupta Signed-off-by: David Hardeman Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/char/watchdog/i6300esb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/watchdog/i6300esb.c b/drivers/char/watchdog/i6300esb.c index 20ceb5fe28b..f0e96fbd648 100644 --- a/drivers/char/watchdog/i6300esb.c +++ b/drivers/char/watchdog/i6300esb.c @@ -97,7 +97,7 @@ static void esb_timer_start(void) u8 val; /* Enable or Enable + Lock? */ - val = 0x02 | nowayout ? 0x01 : 0x00; + val = 0x02 | (nowayout ? 0x01 : 0x00); pci_write_config_byte(esb_pci, ESB_LOCK_REG, val); } -- cgit v1.2.3 From ce2f50b4ae71f700c7b4b0bf0ff11c328611dae8 Mon Sep 17 00:00:00 2001 From: Naveen Gupta Date: Wed, 17 Aug 2005 09:11:46 +0200 Subject: [WATCHDOG] i6300esb-set_correct_reload_register_bit This patch writes into bit 8 of the reload register to perform the correct 'Reload Sequence' instead of writing into bit 4 of Watchdog for Intel 6300ESB chipset. Signed-off-by: Naveen Gupta Signed-off-by: David Hardeman Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/char/watchdog/i6300esb.c | 6 +++--- drivers/char/watchdog/i6300esb.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/char/watchdog/i6300esb.c b/drivers/char/watchdog/i6300esb.c index f0e96fbd648..c04b246858a 100644 --- a/drivers/char/watchdog/i6300esb.c +++ b/drivers/char/watchdog/i6300esb.c @@ -109,7 +109,7 @@ static int esb_timer_stop(void) spin_lock(&esb_lock); /* First, reset timers as suggested by the docs */ esb_unlock_registers(); - writew(0x10, ESB_RELOAD_REG); + writew(ESB_WDT_RELOAD, ESB_RELOAD_REG); /* Then disable the WDT */ pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x0); pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val); @@ -123,7 +123,7 @@ static void esb_timer_keepalive(void) { spin_lock(&esb_lock); esb_unlock_registers(); - writew(0x10, ESB_RELOAD_REG); + writew(ESB_WDT_RELOAD, ESB_RELOAD_REG); /* FIXME: Do we need to flush anything here? */ spin_unlock(&esb_lock); } @@ -153,7 +153,7 @@ static int esb_timer_set_heartbeat(int time) /* Reload */ esb_unlock_registers(); - writew(0x10, ESB_RELOAD_REG); + writew(ESB_WDT_RELOAD, ESB_RELOAD_REG); /* FIXME: Do we need to flush everything out? */ diff --git a/drivers/char/watchdog/i6300esb.h b/drivers/char/watchdog/i6300esb.h index b5b47e3dda1..20c923bbb1c 100644 --- a/drivers/char/watchdog/i6300esb.h +++ b/drivers/char/watchdog/i6300esb.h @@ -54,6 +54,8 @@ #define ESB_WDT_FREQ ( 0x01 << 2 ) /* Decrement frequency */ #define ESB_WDT_INTTYPE ( 0x11 << 0 ) /* Interrupt type on timer1 timeout */ +/* Reload register bits */ +#define ESB_WDT_RELOAD ( 0x01 << 8 ) /* prevent timeout */ /* * Some magic constants -- cgit v1.2.3 From 811f999160487c586917937e95506cb8528472a3 Mon Sep 17 00:00:00 2001 From: Naveen Gupta Date: Sun, 21 Aug 2005 13:02:41 +0200 Subject: [WATCHDOG] i6300esb.c-pci_dev_put+nowayout-patch One pci_dev_put was misused (there was one case without putting the device). Changed nowayout according to other drivers. Signed-off-by: Jiri Slaby Signed-off-by: Naveen Gupta Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/char/watchdog/i6300esb.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/char/watchdog/i6300esb.c b/drivers/char/watchdog/i6300esb.c index c04b246858a..823924e4249 100644 --- a/drivers/char/watchdog/i6300esb.c +++ b/drivers/char/watchdog/i6300esb.c @@ -69,11 +69,7 @@ static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ module_param(heartbeat, int, 0); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1 Date: Mon, 22 Aug 2005 09:05:03 +0200 Subject: [WATCHDOG] i6300esb.c-2-bugs-little-cleanup.patch In i6300esb.c watchdog card driver were 2 bugs (misused pc_match_device and pci_dev_put wasn't called in one error case) and one little cleanup was done (long line was converted to a shorter one with using built-in macro). Signed-off-by: Jiri Slaby Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/char/watchdog/i6300esb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/watchdog/i6300esb.c b/drivers/char/watchdog/i6300esb.c index 823924e4249..575d6cd9e59 100644 --- a/drivers/char/watchdog/i6300esb.c +++ b/drivers/char/watchdog/i6300esb.c @@ -345,7 +345,7 @@ static struct notifier_block esb_notifier = { * want to register another driver on the same PCI id. */ static struct pci_device_id esb_pci_tbl[] = { - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9, PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9), }, { 0, }, /* End of list */ }; MODULE_DEVICE_TABLE (pci, esb_pci_tbl); @@ -365,7 +365,7 @@ static unsigned char __init esb_getdevice (void) */ for_each_pci_dev(dev) { - if (pci_match_device(esb_pci_tbl, dev)) { + if (pci_match_id(esb_pci_tbl, dev)) { esb_pci = dev; break; } -- cgit v1.2.3 From abda5c8bd20d3bd42718b0438b8a81a73ffa4372 Mon Sep 17 00:00:00 2001 From: David Hardeman Date: Thu, 1 Sep 2005 22:34:53 +0200 Subject: [WATCHDOG] i6300.h-removal-patch the attached patch moves the content of drivers/char/watchdog/i6300.h into drivers/char/watchdog/i6300.c, since it is the only file using the defines there is no real reason to have a separate header. Also cleaned up the comments a bit and added myself to the copyright holders. Signed-off-by: David Hardeman Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/char/watchdog/i6300esb.c | 40 ++++++++++++++++++------- drivers/char/watchdog/i6300esb.h | 64 ---------------------------------------- 2 files changed, 30 insertions(+), 74 deletions(-) delete mode 100644 drivers/char/watchdog/i6300esb.h diff --git a/drivers/char/watchdog/i6300esb.c b/drivers/char/watchdog/i6300esb.c index 575d6cd9e59..93785f13242 100644 --- a/drivers/char/watchdog/i6300esb.c +++ b/drivers/char/watchdog/i6300esb.c @@ -1,20 +1,15 @@ /* - * i6300esb 0.03: Watchdog timer driver for Intel 6300ESB chipset + * i6300esb: Watchdog timer driver for Intel 6300ESB chipset * * (c) Copyright 2004 Google Inc. + * (c) Copyright 2005 David Härdeman * * 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 the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * - * based on i810-tco.c which is - * - * (c) Copyright 2000 kernel concepts - * developed for - * Jentro AG, Haar/Munich (Germany) - * - * which is in turn based on softdog.c by Alan Cox + * based on i810-tco.c which is in turn based on softdog.c * * The timer is implemented in the following I/O controller hubs: * (See the intel documentation on http://developer.intel.com.) @@ -47,14 +42,39 @@ #include #include -#include "i6300esb.h" - /* Module and version information */ #define ESB_VERSION "0.03" #define ESB_MODULE_NAME "i6300ESB timer" #define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION #define PFX ESB_MODULE_NAME ": " +/* PCI configuration registers */ +#define ESB_CONFIG_REG 0x60 /* Config register */ +#define ESB_LOCK_REG 0x68 /* WDT lock register */ + +/* Memory mapped registers */ +#define ESB_TIMER1_REG BASEADDR + 0x00 /* Timer1 value after each reset */ +#define ESB_TIMER2_REG BASEADDR + 0x04 /* Timer2 value after each reset */ +#define ESB_GINTSR_REG BASEADDR + 0x08 /* General Interrupt Status Register */ +#define ESB_RELOAD_REG BASEADDR + 0x0c /* Reload register */ + +/* Lock register bits */ +#define ESB_WDT_FUNC ( 0x01 << 2 ) /* Watchdog functionality */ +#define ESB_WDT_ENABLE ( 0x01 << 1 ) /* Enable WDT */ +#define ESB_WDT_LOCK ( 0x01 << 0 ) /* Lock (nowayout) */ + +/* Config register bits */ +#define ESB_WDT_REBOOT ( 0x01 << 5 ) /* Enable reboot on timeout */ +#define ESB_WDT_FREQ ( 0x01 << 2 ) /* Decrement frequency */ +#define ESB_WDT_INTTYPE ( 0x11 << 0 ) /* Interrupt type on timer1 timeout */ + +/* Reload register bits */ +#define ESB_WDT_RELOAD ( 0x01 << 8 ) /* prevent timeout */ + +/* Magic constants */ +#define ESB_UNLOCK1 0x80 /* Step 1 to unlock reset registers */ +#define ESB_UNLOCK2 0x86 /* Step 2 to unlock reset registers */ + /* internal variables */ static void __iomem *BASEADDR; static spinlock_t esb_lock; /* Guards the hardware */ diff --git a/drivers/char/watchdog/i6300esb.h b/drivers/char/watchdog/i6300esb.h deleted file mode 100644 index 20c923bbb1c..00000000000 --- a/drivers/char/watchdog/i6300esb.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * i6300esb: Watchdog timer driver for Intel 6300ESB chipset - * - * (c) Copyright 2000 kernel concepts , All Rights Reserved. - * http://www.kernelconcepts.de - * - * 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 the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * Neither kernel concepts nor Nils Faerber admit liability nor provide - * warranty for any of this software. This material is provided - * "AS-IS" and at no charge. - * - * (c) Copyright 2000 kernel concepts - * developed for - * Jentro AG, Haar/Munich (Germany) - * - * TCO timer driver for i8xx chipsets - * based on softdog.c by Alan Cox - * - * For history and the complete list of supported I/O Controller Hub's - * see i8xx_tco.c - */ - - -/* - * Some address definitions for the TCO - */ - -/* PCI configuration registers */ -#define ESB_CONFIG_REG 0x60 /* Config register */ -#define ESB_LOCK_REG 0x68 /* WDT lock register */ - -/* Memory mapped registers */ -#define ESB_TIMER1_REG BASEADDR + 0x00 /* Timer1 value after each reset */ -#define ESB_TIMER2_REG BASEADDR + 0x04 /* Timer2 value after each reset */ -#define ESB_GINTSR_REG BASEADDR + 0x08 /* General Interrupt Status Register */ -#define ESB_RELOAD_REG BASEADDR + 0x0c /* Reload register */ - - -/* - * Some register bits - */ - -/* Lock register bits */ -#define ESB_WDT_FUNC ( 0x01 << 2 ) /* Watchdog functionality */ -#define ESB_WDT_ENABLE ( 0x01 << 1 ) /* Enable WDT */ -#define ESB_WDT_LOCK ( 0x01 << 0 ) /* Lock (nowayout) */ - -/* Config register bits */ -#define ESB_WDT_REBOOT ( 0x01 << 5 ) /* Enable reboot on timeout */ -#define ESB_WDT_FREQ ( 0x01 << 2 ) /* Decrement frequency */ -#define ESB_WDT_INTTYPE ( 0x11 << 0 ) /* Interrupt type on timer1 timeout */ - -/* Reload register bits */ -#define ESB_WDT_RELOAD ( 0x01 << 8 ) /* prevent timeout */ - -/* - * Some magic constants - */ -#define ESB_UNLOCK1 0x80 /* Step 1 to unlock reset registers */ -#define ESB_UNLOCK2 0x86 /* Step 2 to unlock reset registers */ -- cgit v1.2.3 From d532134d4cad1da0ad0efc1d5db9f74475df80c6 Mon Sep 17 00:00:00 2001 From: Andrey Panin Date: Fri, 19 Aug 2005 23:15:11 +0200 Subject: [WATCHDOG] driver-for-ibm-automatic-server-restart-watchdog.patch This patch adds driver for IBM Automatic Server Restart watchdog hardware found in some IBM eServer xSeries machines. This driver is based on the ugly driver provided by IBM. Driver was tested on IBM eServer 226. Signed-off-by: Andrey Panin Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/char/watchdog/Kconfig | 10 + drivers/char/watchdog/Makefile | 1 + drivers/char/watchdog/ibmasr.c | 407 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 418 insertions(+) create mode 100644 drivers/char/watchdog/ibmasr.c diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index 742c9c5bb1a..5f93452188b 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig @@ -224,6 +224,16 @@ config IB700_WDT Most people will say N. +config IBMASR + tristate "IBM Automatic Server Restart" + depends on WATCHDOG && X86 + help + This is the driver for the IBM Automatic Server Restart watchdog + timer builtin into some eServer xSeries machines. + + To compile this driver as a module, choose M here: the + module will be called ibmasr. + config WAFER_WDT tristate "ICP Wafer 5823 Single Board Computer Watchdog" depends on WATCHDOG && X86 diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index 2f45ba6a6d1..f90a802a7d3 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile @@ -38,6 +38,7 @@ obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o obj-$(CONFIG_SC520_WDT) += sc520_wdt.o obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o obj-$(CONFIG_IB700_WDT) += ib700wdt.o +obj-$(CONFIG_IBMASR) += ibmasr.o obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o diff --git a/drivers/char/watchdog/ibmasr.c b/drivers/char/watchdog/ibmasr.c new file mode 100644 index 00000000000..a32c073d29b --- /dev/null +++ b/drivers/char/watchdog/ibmasr.c @@ -0,0 +1,407 @@ +/* + * IBM Automatic Server Restart driver. + * + * Copyright (c) 2005 Andrey Panin + * + * Based on driver written by Pete Reynolds. + * Copyright (c) IBM Corporation, 1998-2004. + * + * This software may be used and distributed according to the terms + * of the GNU Public License, incorporated herein by reference. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +enum { + ASMTYPE_UNKNOWN, + ASMTYPE_TOPAZ, + ASMTYPE_JASPER, + ASMTYPE_PEARL, + ASMTYPE_JUNIPER, + ASMTYPE_SPRUCE, +}; + +#define PFX "ibmasr: " + +#define TOPAZ_ASR_REG_OFFSET 4 +#define TOPAZ_ASR_TOGGLE 0x40 +#define TOPAZ_ASR_DISABLE 0x80 + +/* PEARL ASR S/W REGISTER SUPERIO PORT ADDRESSES */ +#define PEARL_BASE 0xe04 +#define PEARL_WRITE 0xe06 +#define PEARL_READ 0xe07 + +#define PEARL_ASR_DISABLE_MASK 0x80 /* bit 7: disable = 1, enable = 0 */ +#define PEARL_ASR_TOGGLE_MASK 0x40 /* bit 6: 0, then 1, then 0 */ + +/* JASPER OFFSET FROM SIO BASE ADDR TO ASR S/W REGISTERS. */ +#define JASPER_ASR_REG_OFFSET 0x38 + +#define JASPER_ASR_DISABLE_MASK 0x01 /* bit 0: disable = 1, enable = 0 */ +#define JASPER_ASR_TOGGLE_MASK 0x02 /* bit 1: 0, then 1, then 0 */ + +#define JUNIPER_BASE_ADDRESS 0x54b /* Base address of Juniper ASR */ +#define JUNIPER_ASR_DISABLE_MASK 0x01 /* bit 0: disable = 1 enable = 0 */ +#define JUNIPER_ASR_TOGGLE_MASK 0x02 /* bit 1: 0, then 1, then 0 */ + +#define SPRUCE_BASE_ADDRESS 0x118e /* Base address of Spruce ASR */ +#define SPRUCE_ASR_DISABLE_MASK 0x01 /* bit 1: disable = 1 enable = 0 */ +#define SPRUCE_ASR_TOGGLE_MASK 0x02 /* bit 0: 0, then 1, then 0 */ + + +static int nowayout = WATCHDOG_NOWAYOUT; + +static unsigned long asr_is_open; +static char asr_expect_close; + +static unsigned int asr_type, asr_base, asr_length; +static unsigned int asr_read_addr, asr_write_addr; +static unsigned char asr_toggle_mask, asr_disable_mask; + +static void asr_toggle(void) +{ + unsigned char reg = inb(asr_read_addr); + + outb(reg & ~asr_toggle_mask, asr_write_addr); + reg = inb(asr_read_addr); + + outb(reg | asr_toggle_mask, asr_write_addr); + reg = inb(asr_read_addr); + + outb(reg & ~asr_toggle_mask, asr_write_addr); + reg = inb(asr_read_addr); +} + +static void asr_enable(void) +{ + unsigned char reg; + + if (asr_type == ASMTYPE_TOPAZ) { + /* asr_write_addr == asr_read_addr */ + reg = inb(asr_read_addr); + outb(reg & ~(TOPAZ_ASR_TOGGLE | TOPAZ_ASR_DISABLE), + asr_read_addr); + } else { + /* + * First make sure the hardware timer is reset by toggling + * ASR hardware timer line. + */ + asr_toggle(); + + reg = inb(asr_read_addr); + outb(reg & ~asr_disable_mask, asr_write_addr); + } + reg = inb(asr_read_addr); +} + +static void asr_disable(void) +{ + unsigned char reg = inb(asr_read_addr); + + if (asr_type == ASMTYPE_TOPAZ) + /* asr_write_addr == asr_read_addr */ + outb(reg | TOPAZ_ASR_TOGGLE | TOPAZ_ASR_DISABLE, + asr_read_addr); + else { + outb(reg | asr_toggle_mask, asr_write_addr); + reg = inb(asr_read_addr); + + outb(reg | asr_disable_mask, asr_write_addr); + } + reg = inb(asr_read_addr); +} + +static int __init asr_get_base_address(void) +{ + unsigned char low, high; + const char *type = ""; + + asr_length = 1; + + switch (asr_type) { + case ASMTYPE_TOPAZ: + /* SELECT SuperIO CHIP FOR QUERYING (WRITE 0x07 TO BOTH 0x2E and 0x2F) */ + outb(0x07, 0x2e); + outb(0x07, 0x2f); + + /* SELECT AND READ THE HIGH-NIBBLE OF THE GPIO BASE ADDRESS */ + outb(0x60, 0x2e); + high = inb(0x2f); + + /* SELECT AND READ THE LOW-NIBBLE OF THE GPIO BASE ADDRESS */ + outb(0x61, 0x2e); + low = inb(0x2f); + + asr_base = (high << 16) | low; + asr_read_addr = asr_write_addr = + asr_base + TOPAZ_ASR_REG_OFFSET; + asr_length = 5; + + break; + + case ASMTYPE_JASPER: + type = "Jaspers "; + + /* FIXME: need to use pci_config_lock here, but it's not exported */ + +/* spin_lock_irqsave(&pci_config_lock, flags);*/ + + /* Select the SuperIO chip in the PCI I/O port register */ + outl(0x8000f858, 0xcf8); + + /* + * Read the base address for the SuperIO chip. + * Only the lower 16 bits are valid, but the address is word + * aligned so the last bit must be masked off. + */ + asr_base = inl(0xcfc) & 0xfffe; + +/* spin_unlock_irqrestore(&pci_config_lock, flags);*/ + + asr_read_addr = asr_write_addr = + asr_base + JASPER_ASR_REG_OFFSET; + asr_toggle_mask = JASPER_ASR_TOGGLE_MASK; + asr_disable_mask = JASPER_ASR_DISABLE_MASK; + asr_length = JASPER_ASR_REG_OFFSET + 1; + + break; + + case ASMTYPE_PEARL: + type = "Pearls "; + asr_base = PEARL_BASE; + asr_read_addr = PEARL_READ; + asr_write_addr = PEARL_WRITE; + asr_toggle_mask = PEARL_ASR_TOGGLE_MASK; + asr_disable_mask = PEARL_ASR_DISABLE_MASK; + asr_length = 4; + break; + + case ASMTYPE_JUNIPER: + type = "Junipers "; + asr_base = JUNIPER_BASE_ADDRESS; + asr_read_addr = asr_write_addr = asr_base; + asr_toggle_mask = JUNIPER_ASR_TOGGLE_MASK; + asr_disable_mask = JUNIPER_ASR_DISABLE_MASK; + break; + + case ASMTYPE_SPRUCE: + type = "Spruce's "; + asr_base = SPRUCE_BASE_ADDRESS; + asr_read_addr = asr_write_addr = asr_base; + asr_toggle_mask = SPRUCE_ASR_TOGGLE_MASK; + asr_disable_mask = SPRUCE_ASR_DISABLE_MASK; + break; + } + + if (!request_region(asr_base, asr_length, "ibmasr")) { + printk(KERN_ERR PFX "address %#x already in use\n", + asr_base); + return -EBUSY; + } + + printk(KERN_INFO PFX "found %sASR @ addr %#x\n", type, asr_base); + + return 0; +} + + +static ssize_t asr_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + if (count) { + if (!nowayout) { + size_t i; + + /* In case it was set long ago */ + asr_expect_close = 0; + + for (i = 0; i != count; i++) { + char c; + if (get_user(c, buf + i)) + return -EFAULT; + if (c == 'V') + asr_expect_close = 42; + } + } + asr_toggle(); + } + return count; +} + +static int asr_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + static const struct watchdog_info ident = { + .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | + WDIOF_MAGICCLOSE, + .identity = "IBM ASR" + }; + void __user *argp = (void __user *)arg; + int __user *p = argp; + int heartbeat; + + switch (cmd) { + case WDIOC_GETSUPPORT: + return copy_to_user(argp, &ident, sizeof(ident)) ? + -EFAULT : 0; + + case WDIOC_GETSTATUS: + case WDIOC_GETBOOTSTATUS: + return put_user(0, p); + + case WDIOC_KEEPALIVE: + asr_toggle(); + return 0; + + + case WDIOC_SETTIMEOUT: + if (get_user(heartbeat, p)) + return -EFAULT; + /* Fall */ + + case WDIOC_GETTIMEOUT: + heartbeat = 256; + return put_user(heartbeat, p); + + case WDIOC_SETOPTIONS: { + int new_options, retval = -EINVAL; + + if (get_user(new_options, p)) + return -EFAULT; + + if (new_options & WDIOS_DISABLECARD) { + asr_disable(); + retval = 0; + } + + if (new_options & WDIOS_ENABLECARD) { + asr_enable(); + asr_toggle(); + retval = 0; + } + + return retval; + } + } + + return -ENOIOCTLCMD; +} + +static int asr_open(struct inode *inode, struct file *file) +{ + if(test_and_set_bit(0, &asr_is_open)) + return -EBUSY; + + asr_toggle(); + asr_enable(); + + return nonseekable_open(inode, file); +} + +static int asr_release(struct inode *inode, struct file *file) +{ + if (asr_expect_close == 42) + asr_disable(); + else { + printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n"); + asr_toggle(); + } + clear_bit(0, &asr_is_open); + asr_expect_close = 0; + return 0; +} + +static struct file_operations asr_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = asr_write, + .ioctl = asr_ioctl, + .open = asr_open, + .release = asr_release, +}; + +static struct miscdevice asr_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &asr_fops, +}; + + +struct ibmasr_id { + const char *desc; + int type; +}; + +static struct ibmasr_id __initdata ibmasr_id_table[] = { + { "IBM Automatic Server Restart - eserver xSeries 220", ASMTYPE_TOPAZ }, + { "IBM Automatic Server Restart - Machine Type 8673", ASMTYPE_PEARL }, + { "IBM Automatic Server Restart - Machine Type 8480", ASMTYPE_JASPER }, + { "IBM Automatic Server Restart - Machine Type 8482", ASMTYPE_JUNIPER }, + { "IBM Automatic Server Restart - Machine Type 8648", ASMTYPE_SPRUCE }, + { NULL } +}; + +static int __init ibmasr_init(void) +{ + struct ibmasr_id *id; + int rc; + + for (id = ibmasr_id_table; id->desc; id++) { + if (dmi_find_device(DMI_DEV_TYPE_OTHER, id->desc, NULL)) { + asr_type = id->type; + break; + } + } + + if (!asr_type) + return -ENODEV; + + rc = misc_register(&asr_miscdev); + if (rc < 0) { + printk(KERN_ERR PFX "failed to register misc device\n"); + return rc; + } + + rc = asr_get_base_address(); + if (rc) { + misc_deregister(&asr_miscdev); + return rc; + } + + return 0; +} + +static void __exit ibmasr_exit(void) +{ + if (!nowayout) + asr_disable(); + + misc_deregister(&asr_miscdev); + + release_region(asr_base, asr_length); +} + +module_init(ibmasr_init); +module_exit(ibmasr_exit); + +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +MODULE_DESCRIPTION("IBM Automatic Server Restart driver"); +MODULE_AUTHOR("Andrey Panin"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); -- cgit v1.2.3 From cd7b80079b120406de902ee1eaa2dbdaa867dada Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 19 Aug 2005 23:21:01 +0200 Subject: [WATCHDOG] driver-for-ibm-automatic-server-restart-watchdog-fix Add fixed timeout comments Cc: Andrey Panin Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/char/watchdog/ibmasr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/char/watchdog/ibmasr.c b/drivers/char/watchdog/ibmasr.c index a32c073d29b..4f90015be7d 100644 --- a/drivers/char/watchdog/ibmasr.c +++ b/drivers/char/watchdog/ibmasr.c @@ -267,7 +267,10 @@ static int asr_ioctl(struct inode *inode, struct file *file, asr_toggle(); return 0; - + /* + * The hardware has a fixed timeout value, so WDIOC_SETTIMEOUT + * is a noop and WDIOC_GETTIMEOUT always returns 256. + */ case WDIOC_SETTIMEOUT: if (get_user(heartbeat, p)) return -EFAULT; -- cgit v1.2.3 From 266aa1c4b3d004123d330eb412cc26a3d10f9029 Mon Sep 17 00:00:00 2001 From: Wim Van Sebroeck Date: Fri, 19 Aug 2005 23:31:41 +0200 Subject: [WATCHDOG] driver-for-ibm-automatic-server-restart-watchdog-fix2.patch The device/watchdog has a fixed timeout/heartbeat. So we don't support the WDIOC_SETTIMEOUT ioctl call and we also may not set the WDIOF_SETTIMEOUT flag. Cc: Andrey Panin Cc: Andrew Morton Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/ibmasr.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/char/watchdog/ibmasr.c b/drivers/char/watchdog/ibmasr.c index 4f90015be7d..294c474ae48 100644 --- a/drivers/char/watchdog/ibmasr.c +++ b/drivers/char/watchdog/ibmasr.c @@ -246,7 +246,7 @@ static int asr_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { static const struct watchdog_info ident = { - .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | + .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, .identity = "IBM ASR" }; @@ -268,14 +268,9 @@ static int asr_ioctl(struct inode *inode, struct file *file, return 0; /* - * The hardware has a fixed timeout value, so WDIOC_SETTIMEOUT - * is a noop and WDIOC_GETTIMEOUT always returns 256. + * The hardware has a fixed timeout value, so no WDIOC_SETTIMEOUT + * and WDIOC_GETTIMEOUT always returns 256. */ - case WDIOC_SETTIMEOUT: - if (get_user(heartbeat, p)) - return -EFAULT; - /* Fall */ - case WDIOC_GETTIMEOUT: heartbeat = 256; return put_user(heartbeat, p); -- cgit v1.2.3 From 3809ad384af43ad883f47ee22a6faa33cedd61bc Mon Sep 17 00:00:00 2001 From: "Ian E. Morgan" Date: Thu, 1 Sep 2005 22:49:17 +0200 Subject: [WATCHDOG] New SBC8360 watchdog driver (revised) New SBC8360 watchdog driver patch From: Ian E. Morgan Signed-off-by: Wim Van Sebroeck Signed-off-by: Andrew Morton --- drivers/char/watchdog/Kconfig | 13 ++ drivers/char/watchdog/Makefile | 1 + drivers/char/watchdog/sbc8360.c | 419 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 433 insertions(+) create mode 100644 drivers/char/watchdog/sbc8360.c diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index 5f93452188b..e18a4102163 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig @@ -309,6 +309,19 @@ config 60XX_WDT You can compile this driver directly into the kernel, or use it as a module. The module will be called sbc60xxwdt. +config SBC8360_WDT + tristate "SBC8360 Watchdog Timer" + depends on WATCHDOG && X86 + ---help--- + + This is the driver for the hardware watchdog on the SBC8360 Single + Board Computer produced by Axiomtek Co., Ltd. (www.axiomtek.com). + + To compile this driver as a module, choose M here: the + module will be called sbc8360.ko. + + Most people will say N. + config CPU5_WDT tristate "SMA CPU5 Watchdog" depends on WATCHDOG && X86 diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index f90a802a7d3..c7f74026bd3 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile @@ -45,6 +45,7 @@ obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o +obj-$(CONFIG_SBC8360_WDT) += sbc8360.o obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o diff --git a/drivers/char/watchdog/sbc8360.c b/drivers/char/watchdog/sbc8360.c new file mode 100644 index 00000000000..06daf426d5b --- /dev/null +++ b/drivers/char/watchdog/sbc8360.c @@ -0,0 +1,419 @@ +/* + * SBC8360 Watchdog driver + * + * (c) Copyright 2005 Webcon, Inc. + * + * Based on ib700wdt.c, which is based on advantechwdt.c which is based + * on acquirewdt.c which is based on wdt.c. + * + * (c) Copyright 2001 Charles Howes + * + * Based on advantechwdt.c which is based on acquirewdt.c which + * is based on wdt.c. + * + * (c) Copyright 2000-2001 Marek Michalkiewicz + * + * Based on acquirewdt.c which is based on wdt.c. + * Original copyright messages: + * + * (c) Copyright 1996 Alan Cox , All Rights Reserved. + * http://www.redhat.com + * + * 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 the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide + * warranty for any of this software. This material is provided + * "AS-IS" and at no charge. + * + * (c) Copyright 1995 Alan Cox + * + * 14-Dec-2001 Matt Domsch + * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT + * Added timeout module option to override default + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +static unsigned long sbc8360_is_open; +static spinlock_t sbc8360_lock; +static char expect_close; + +#define PFX "sbc8360: " + +/* + * + * Watchdog Timer Configuration + * + * The function of the watchdog timer is to reset the system automatically + * and is defined at I/O port 0120H and 0121H. To enable the watchdog timer + * and allow the system to reset, write appropriate values from the table + * below to I/O port 0120H and 0121H. To disable the timer, write a zero + * value to I/O port 0121H for the system to stop the watchdog function. + * + * The following describes how the timer should be programmed (according to + * the vendor documentation) + * + * Enabling Watchdog: + * MOV AX,000AH (enable, phase I) + * MOV DX,0120H + * OUT DX,AX + * MOV AX,000BH (enable, phase II) + * MOV DX,0120H + * OUT DX,AX + * MOV AX,000nH (set multiplier n, from 1-4) + * MOV DX,0120H + * OUT DX,AX + * MOV AX,000mH (set base timer m, from 0-F) + * MOV DX,0121H + * OUT DX,AX + * + * Reset timer: + * MOV AX,000mH (same as set base timer, above) + * MOV DX,0121H + * OUT DX,AX + * + * Disabling Watchdog: + * MOV AX,0000H (a zero value) + * MOV DX,0120H + * OUT DX,AX + * + * Watchdog timeout configuration values: + * N + * M | 1 2 3 4 + * --|---------------------------------- + * 0 | 0.5s 5s 50s 100s + * 1 | 1s 10s 100s 200s + * 2 | 1.5s 15s 150s 300s + * 3 | 2s 20s 200s 400s + * 4 | 2.5s 25s 250s 500s + * 5 | 3s 30s 300s 600s + * 6 | 3.5s 35s 350s 700s + * 7 | 4s 40s 400s 800s + * 8 | 4.5s 45s 450s 900s + * 9 | 5s 50s 500s 1000s + * A | 5.5s 55s 550s 1100s + * B | 6s 60s 600s 1200s + * C | 6.5s 65s 650s 1300s + * D | 7s 70s 700s 1400s + * E | 7.5s 75s 750s 1500s + * F | 8s 80s 800s 1600s + * + * Another way to say the same things is: + * For N=1, Timeout = (M+1) * 0.5s + * For N=2, Timeout = (M+1) * 5s + * For N=3, Timeout = (M+1) * 50s + * For N=4, Timeout = (M+1) * 100s + * + */ + +static int wd_times[64][2] = { + {0, 1}, /* 0 = 0.5s */ + {1, 1}, /* 1 = 1s */ + {2, 1}, /* 2 = 1.5s */ + {3, 1}, /* 3 = 2s */ + {4, 1}, /* 4 = 2.5s */ + {5, 1}, /* 5 = 3s */ + {6, 1}, /* 6 = 3.5s */ + {7, 1}, /* 7 = 4s */ + {8, 1}, /* 8 = 4.5s */ + {9, 1}, /* 9 = 5s */ + {0xA, 1}, /* 10 = 5.5s */ + {0xB, 1}, /* 11 = 6s */ + {0xC, 1}, /* 12 = 6.5s */ + {0xD, 1}, /* 13 = 7s */ + {0xE, 1}, /* 14 = 7.5s */ + {0xF, 1}, /* 15 = 8s */ + {0, 2}, /* 16 = 5s */ + {1, 2}, /* 17 = 10s */ + {2, 2}, /* 18 = 15s */ + {3, 2}, /* 19 = 20s */ + {4, 2}, /* 20 = 25s */ + {5, 2}, /* 21 = 30s */ + {6, 2}, /* 22 = 35s */ + {7, 2}, /* 23 = 40s */ + {8, 2}, /* 24 = 45s */ + {9, 2}, /* 25 = 50s */ + {0xA, 2}, /* 26 = 55s */ + {0xB, 2}, /* 27 = 60s */ + {0xC, 2}, /* 28 = 65s */ + {0xD, 2}, /* 29 = 70s */ + {0xE, 2}, /* 30 = 75s */ + {0xF, 2}, /* 31 = 80s */ + {0, 3}, /* 32 = 50s */ + {1, 3}, /* 33 = 100s */ + {2, 3}, /* 34 = 150s */ + {3, 3}, /* 35 = 200s */ + {4, 3}, /* 36 = 250s */ + {5, 3}, /* 37 = 300s */ + {6, 3}, /* 38 = 350s */ + {7, 3}, /* 39 = 400s */ + {8, 3}, /* 40 = 450s */ + {9, 3}, /* 41 = 500s */ + {0xA, 3}, /* 42 = 550s */ + {0xB, 3}, /* 43 = 600s */ + {0xC, 3}, /* 44 = 650s */ + {0xD, 3}, /* 45 = 700s */ + {0xE, 3}, /* 46 = 750s */ + {0xF, 3}, /* 47 = 800s */ + {0, 4}, /* 48 = 100s */ + {1, 4}, /* 49 = 200s */ + {2, 4}, /* 50 = 300s */ + {3, 4}, /* 51 = 400s */ + {4, 4}, /* 52 = 500s */ + {5, 4}, /* 53 = 600s */ + {6, 4}, /* 54 = 700s */ + {7, 4}, /* 55 = 800s */ + {8, 4}, /* 56 = 900s */ + {9, 4}, /* 57 = 1000s */ + {0xA, 4}, /* 58 = 1100s */ + {0xB, 4}, /* 59 = 1200s */ + {0xC, 4}, /* 60 = 1300s */ + {0xD, 4}, /* 61 = 1400s */ + {0xE, 4}, /* 62 = 1500s */ + {0xF, 4} /* 63 = 1600s */ +}; + +#define SBC8360_ENABLE 0x120 +#define SBC8360_BASETIME 0x121 + +static int timeout = 27; +static int wd_margin = 0xB; +static int wd_multiplier = 2; + +#ifdef CONFIG_WATCHDOG_NOWAYOUT +static int nowayout = 1; +#else +static int nowayout = 0; +#endif + +module_param(timeout, int, 27); +MODULE_PARM_DESC(timeout, "Index into timeout table (0-63) (default=27 (60s))"); +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, + "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +/* + * Kernel methods. + */ + +/* Activate and pre-configure watchdog */ +static void sbc8360_activate(void) +{ + /* Enable the watchdog */ + outb(0x0A, SBC8360_ENABLE); + msleep_interruptible(100); + outb(0x0B, SBC8360_ENABLE); + msleep_interruptible(100); + /* Set timeout multiplier */ + outb(wd_multiplier, SBC8360_ENABLE); + msleep_interruptible(100); + /* Nothing happens until first sbc8360_ping() */ +} + +/* Kernel pings watchdog */ +static void sbc8360_ping(void) +{ + /* Write the base timer register */ + outb(wd_margin, SBC8360_BASETIME); +} + +/* Userspace pings kernel driver, or requests clean close */ +static ssize_t sbc8360_write(struct file *file, const char __user * buf, + size_t count, loff_t * ppos) +{ + if (count) { + if (!nowayout) { + size_t i; + + /* In case it was set long ago */ + expect_close = 0; + + for (i = 0; i != count; i++) { + char c; + if (get_user(c, buf + i)) + return -EFAULT; + if (c == 'V') + expect_close = 42; + } + } + sbc8360_ping(); + } + return count; +} + +static int sbc8360_open(struct inode *inode, struct file *file) +{ + spin_lock(&sbc8360_lock); + if (test_and_set_bit(0, &sbc8360_is_open)) { + spin_unlock(&sbc8360_lock); + return -EBUSY; + } + if (nowayout) + __module_get(THIS_MODULE); + + /* Activate and ping once to start the countdown */ + spin_unlock(&sbc8360_lock); + sbc8360_activate(); + sbc8360_ping(); + return nonseekable_open(inode, file); +} + +static int sbc8360_close(struct inode *inode, struct file *file) +{ + spin_lock(&sbc8360_lock); + if (expect_close == 42) + outb(0, SBC8360_ENABLE); + else + printk(KERN_CRIT PFX + "SBC8360 device closed unexpectedly. SBC8360 will not stop!\n"); + + clear_bit(0, &sbc8360_is_open); + expect_close = 0; + spin_unlock(&sbc8360_lock); + return 0; +} + +/* + * Notifier for system down + */ + +static int sbc8360_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if (code == SYS_DOWN || code == SYS_HALT) { + /* Disable the SBC8360 Watchdog */ + outb(0, SBC8360_ENABLE); + } + return NOTIFY_DONE; +} + +/* + * Kernel Interfaces + */ + +static struct file_operations sbc8360_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = sbc8360_write, + .open = sbc8360_open, + .release = sbc8360_close, +}; + +static struct miscdevice sbc8360_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &sbc8360_fops, +}; + +/* + * The SBC8360 needs to learn about soft shutdowns in order to + * turn the timebomb registers off. + */ + +static struct notifier_block sbc8360_notifier = { + .notifier_call = sbc8360_notify_sys, +}; + +static int __init sbc8360_init(void) +{ + int res; + unsigned long int mseconds = 60000; + + spin_lock_init(&sbc8360_lock); + res = misc_register(&sbc8360_miscdev); + if (res) { + printk(KERN_ERR PFX "failed to register misc device\n"); + goto out_nomisc; + } + + if (!request_region(SBC8360_ENABLE, 1, "SBC8360")) { + printk(KERN_ERR PFX "ENABLE method I/O %X is not available.\n", + SBC8360_ENABLE); + res = -EIO; + goto out_noenablereg; + } + if (!request_region(SBC8360_BASETIME, 1, "SBC8360")) { + printk(KERN_ERR PFX + "BASETIME method I/O %X is not available.\n", + SBC8360_BASETIME); + res = -EIO; + goto out_nobasetimereg; + } + + res = register_reboot_notifier(&sbc8360_notifier); + if (res) { + printk(KERN_ERR PFX "Failed to register reboot notifier.\n"); + goto out_noreboot; + } + + if (timeout < 0 || timeout > 63) { + printk(KERN_ERR PFX "Invalid timeout index (must be 0-63).\n"); + res = -EINVAL; + goto out_noreboot; + } + + wd_margin = wd_times[timeout][0]; + wd_multiplier = wd_times[timeout][1]; + + if (wd_multiplier == 1) + mseconds = (wd_margin + 1) * 500; + else if (wd_multiplier == 2) + mseconds = (wd_margin + 1) * 5000; + else if (wd_multiplier == 3) + mseconds = (wd_margin + 1) * 50000; + else if (wd_multiplier == 4) + mseconds = (wd_margin + 1) * 100000; + + /* My kingdom for the ability to print "0.5 seconds" in the kernel! */ + printk(KERN_INFO PFX "Timeout set at %ld ms.\n", mseconds); + + return 0; + + out_noreboot: + release_region(SBC8360_ENABLE, 1); + release_region(SBC8360_BASETIME, 1); + out_noenablereg: + out_nobasetimereg: + misc_deregister(&sbc8360_miscdev); + out_nomisc: + return res; +} + +static void __exit sbc8360_exit(void) +{ + misc_deregister(&sbc8360_miscdev); + unregister_reboot_notifier(&sbc8360_notifier); + release_region(SBC8360_ENABLE, 1); + release_region(SBC8360_BASETIME, 1); +} + +module_init(sbc8360_init); +module_exit(sbc8360_exit); + +MODULE_AUTHOR("Ian E. Morgan "); +MODULE_DESCRIPTION("SBC8360 watchdog driver"); +MODULE_LICENSE("GPL"); +MODULE_VERSION("1.0"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); + +/* end of sbc8360.c */ -- cgit v1.2.3 From b4cc4aa24ca47b6a2bdb9029020502cff7c6e774 Mon Sep 17 00:00:00 2001 From: Jose Miguel Goncalves Date: Tue, 6 Sep 2005 17:05:30 -0700 Subject: [WATCHDOG] w83977f-watchdog-driver.patch In a project for my company I've needed to use the watchdog device in a PCM-5335 SBC from AAEON. The watchdog timer is from a Winbond's SuperIO chip, the W83977F. I've made this driver based on two others already on the kernel tree, the w83877f_wdt and the wdt977. Signed-off-by: Jose Goncalves Signed-off-by: Andrew Morton Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/Kconfig | 13 + drivers/char/watchdog/Makefile | 1 + drivers/char/watchdog/w83977f_wdt.c | 548 ++++++++++++++++++++++++++++++++++++ 3 files changed, 562 insertions(+) create mode 100644 drivers/char/watchdog/w83977f_wdt.c diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index e18a4102163..2d78962b4de 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig @@ -360,6 +360,19 @@ config W83877F_WDT Most people will say N. +config W83977F_WDT + tristate "W83977F (PCM-5335) Watchdog Timer" + depends on WATCHDOG && X86 + ---help--- + This is the driver for the hardware watchdog on the W83977F I/O chip + as used in AAEON's PCM-5335 SBC (and likely others). This + watchdog simply watches your kernel to make sure it doesn't freeze, + and if it does, it reboots your computer after a certain amount of + time. + + To compile this driver as a module, choose M here: the + module will be called w83977f_wdt. + config MACHZ_WDT tristate "ZF MachZ Watchdog" depends on WATCHDOG && X86 diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index c7f74026bd3..3ca8a12a151 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile @@ -49,6 +49,7 @@ obj-$(CONFIG_SBC8360_WDT) += sbc8360.o obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o +obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o obj-$(CONFIG_MACHZ_WDT) += machzwd.o # PowerPC Architecture diff --git a/drivers/char/watchdog/w83977f_wdt.c b/drivers/char/watchdog/w83977f_wdt.c new file mode 100644 index 00000000000..366d47bca16 --- /dev/null +++ b/drivers/char/watchdog/w83977f_wdt.c @@ -0,0 +1,548 @@ +/* + * W83977F Watchdog Timer Driver for Winbond W83977F I/O Chip + * + * (c) Copyright 2005 Jose Goncalves + * + * Based on w83877f_wdt.c by Scott Jennings, + * and wdt977.c by Woody Suwalski + * + * ----------------------- + * + * 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 the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define WATCHDOG_VERSION "1.00" +#define WATCHDOG_NAME "W83977F WDT" +#define PFX WATCHDOG_NAME ": " +#define DRIVER_VERSION WATCHDOG_NAME " driver, v" WATCHDOG_VERSION "\n" + +#define IO_INDEX_PORT 0x3F0 +#define IO_DATA_PORT (IO_INDEX_PORT+1) + +#define UNLOCK_DATA 0x87 +#define LOCK_DATA 0xAA +#define DEVICE_REGISTER 0x07 + +#define DEFAULT_TIMEOUT 45 /* default timeout in seconds */ + +static int timeout = DEFAULT_TIMEOUT; +static int timeoutW; /* timeout in watchdog counter units */ +static unsigned long timer_alive; +static int testmode; +static char expect_close; +static spinlock_t spinlock; + +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (15..7635), default=" __MODULE_STRING(DEFAULT_TIMEOUT) ")"); +module_param(testmode, int, 0); +MODULE_PARM_DESC(testmode,"Watchdog testmode (1 = no reboot), default=0"); + +#ifdef CONFIG_WATCHDOG_NOWAYOUT +static int nowayout = 1; +#else +static int nowayout = 0; +#endif + +module_param(nowayout, int, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); + +/* + * Start the watchdog + */ + +static int wdt_start(void) +{ + unsigned long flags; + + spin_lock_irqsave(&spinlock, flags); + + /* Unlock the SuperIO chip */ + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + + /* + * Select device Aux2 (device=8) to set watchdog regs F2, F3 and F4. + * F2 has the timeout in watchdog counter units. + * F3 is set to enable watchdog LED blink at timeout. + * F4 is used to just clear the TIMEOUT'ed state (bit 0). + */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + outb_p(0xF2,IO_INDEX_PORT); + outb_p(timeoutW,IO_DATA_PORT); + outb_p(0xF3,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + outb_p(0xF4,IO_INDEX_PORT); + outb_p(0x00,IO_DATA_PORT); + + /* Set device Aux2 active */ + outb_p(0x30,IO_INDEX_PORT); + outb_p(0x01,IO_DATA_PORT); + + /* + * Select device Aux1 (dev=7) to set GP16 as the watchdog output + * (in reg E6) and GP13 as the watchdog LED output (in reg E3). + * Map GP16 at pin 119. + * In test mode watch the bit 0 on F4 to indicate "triggered" or + * check watchdog LED on SBC. + */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x07,IO_DATA_PORT); + if (!testmode) + { + unsigned pin_map; + + outb_p(0xE6,IO_INDEX_PORT); + outb_p(0x0A,IO_DATA_PORT); + outb_p(0x2C,IO_INDEX_PORT); + pin_map = inb_p(IO_DATA_PORT); + pin_map |= 0x10; + pin_map &= ~(0x20); + outb_p(0x2C,IO_INDEX_PORT); + outb_p(pin_map,IO_DATA_PORT); + } + outb_p(0xE3,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + + /* Set device Aux1 active */ + outb_p(0x30,IO_INDEX_PORT); + outb_p(0x01,IO_DATA_PORT); + + /* Lock the SuperIO chip */ + outb_p(LOCK_DATA,IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + + printk(KERN_INFO PFX "activated.\n"); + + return 0; +} + +/* + * Stop the watchdog + */ + +static int wdt_stop(void) +{ + unsigned long flags; + + spin_lock_irqsave(&spinlock, flags); + + /* Unlock the SuperIO chip */ + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + + /* + * Select device Aux2 (device=8) to set watchdog regs F2, F3 and F4. + * F2 is reset to its default value (watchdog timer disabled). + * F3 is reset to its default state. + * F4 clears the TIMEOUT'ed state (bit 0) - back to default. + */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + outb_p(0xF2,IO_INDEX_PORT); + outb_p(0xFF,IO_DATA_PORT); + outb_p(0xF3,IO_INDEX_PORT); + outb_p(0x00,IO_DATA_PORT); + outb_p(0xF4,IO_INDEX_PORT); + outb_p(0x00,IO_DATA_PORT); + outb_p(0xF2,IO_INDEX_PORT); + outb_p(0x00,IO_DATA_PORT); + + /* + * Select device Aux1 (dev=7) to set GP16 (in reg E6) and + * Gp13 (in reg E3) as inputs. + */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x07,IO_DATA_PORT); + if (!testmode) + { + outb_p(0xE6,IO_INDEX_PORT); + outb_p(0x01,IO_DATA_PORT); + } + outb_p(0xE3,IO_INDEX_PORT); + outb_p(0x01,IO_DATA_PORT); + + /* Lock the SuperIO chip */ + outb_p(LOCK_DATA,IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + + printk(KERN_INFO PFX "shutdown.\n"); + + return 0; +} + +/* + * Send a keepalive ping to the watchdog + * This is done by simply re-writing the timeout to reg. 0xF2 + */ + +static int wdt_keepalive(void) +{ + unsigned long flags; + + spin_lock_irqsave(&spinlock, flags); + + /* Unlock the SuperIO chip */ + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + + /* Select device Aux2 (device=8) to kick watchdog reg F2 */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + outb_p(0xF2,IO_INDEX_PORT); + outb_p(timeoutW,IO_DATA_PORT); + + /* Lock the SuperIO chip */ + outb_p(LOCK_DATA,IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + + return 0; +} + +/* + * Set the watchdog timeout value + */ + +static int wdt_set_timeout(int t) +{ + int tmrval; + + /* + * Convert seconds to watchdog counter time units, rounding up. + * On PCM-5335 watchdog units are 30 seconds/step with 15 sec startup + * value. This information is supplied in the PCM-5335 manual and was + * checked by me on a real board. This is a bit strange because W83977f + * datasheet says counter unit is in minutes! + */ + if (t < 15) + return -EINVAL; + + tmrval = ((t + 15) + 29) / 30; + + if (tmrval > 255) + return -EINVAL; + + /* + * timeout is the timeout in seconds, + * timeoutW is the timeout in watchdog counter units. + */ + timeoutW = tmrval; + timeout = (timeoutW * 30) - 15; + return 0; +} + +/* + * Get the watchdog status + */ + +static int wdt_get_status(int *status) +{ + int new_status; + unsigned long flags; + + spin_lock_irqsave(&spinlock, flags); + + /* Unlock the SuperIO chip */ + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + outb_p(UNLOCK_DATA,IO_INDEX_PORT); + + /* Select device Aux2 (device=8) to read watchdog reg F4 */ + outb_p(DEVICE_REGISTER,IO_INDEX_PORT); + outb_p(0x08,IO_DATA_PORT); + outb_p(0xF4,IO_INDEX_PORT); + new_status = inb_p(IO_DATA_PORT); + + /* Lock the SuperIO chip */ + outb_p(LOCK_DATA,IO_INDEX_PORT); + + spin_unlock_irqrestore(&spinlock, flags); + + *status = 0; + if (new_status & 1) + *status |= WDIOF_CARDRESET; + + return 0; +} + + +/* + * /dev/watchdog handling + */ + +static int wdt_open(struct inode *inode, struct file *file) +{ + /* If the watchdog is alive we don't need to start it again */ + if( test_and_set_bit(0, &timer_alive) ) + return -EBUSY; + + if (nowayout) + __module_get(THIS_MODULE); + + wdt_start(); + return nonseekable_open(inode, file); +} + +static int wdt_release(struct inode *inode, struct file *file) +{ + /* + * Shut off the timer. + * Lock it in if it's a module and we set nowayout + */ + if (expect_close == 42) + { + wdt_stop(); + clear_bit(0, &timer_alive); + } else { + wdt_keepalive(); + printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n"); + } + expect_close = 0; + return 0; +} + +/* + * wdt_write: + * @file: file handle to the watchdog + * @buf: buffer to write (unused as data does not matter here + * @count: count of bytes + * @ppos: pointer to the position to write. No seeks allowed + * + * A write to a watchdog device is defined as a keepalive signal. Any + * write of data will do, as we we don't define content meaning. + */ + +static ssize_t wdt_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + /* See if we got the magic character 'V' and reload the timer */ + if(count) + { + if (!nowayout) + { + size_t ofs; + + /* note: just in case someone wrote the magic character long ago */ + expect_close = 0; + + /* scan to see whether or not we got the magic character */ + for(ofs = 0; ofs != count; ofs++) + { + char c; + if (get_user(c, buf + ofs)) + return -EFAULT; + if (c == 'V') { + expect_close = 42; + } + } + } + + /* someone wrote to us, we should restart timer */ + wdt_keepalive(); + } + return count; +} + +/* + * wdt_ioctl: + * @inode: inode of the device + * @file: file handle to the device + * @cmd: watchdog command + * @arg: argument pointer + * + * The watchdog API defines a common set of functions for all watchdogs + * according to their available features. + */ + +static struct watchdog_info ident = { + .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, + .firmware_version = 1, + .identity = WATCHDOG_NAME, +}; + +static int wdt_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + int status; + int new_options, retval = -EINVAL; + int new_timeout; + union { + struct watchdog_info __user *ident; + int __user *i; + } uarg; + + uarg.i = (int __user *)arg; + + switch(cmd) + { + default: + return -ENOIOCTLCMD; + + case WDIOC_GETSUPPORT: + return copy_to_user(uarg.ident, &ident, sizeof(ident)) ? -EFAULT : 0; + + case WDIOC_GETSTATUS: + wdt_get_status(&status); + return put_user(status, uarg.i); + + case WDIOC_GETBOOTSTATUS: + return put_user(0, uarg.i); + + case WDIOC_KEEPALIVE: + wdt_keepalive(); + return 0; + + case WDIOC_SETOPTIONS: + if (get_user (new_options, uarg.i)) + return -EFAULT; + + if (new_options & WDIOS_DISABLECARD) { + wdt_stop(); + retval = 0; + } + + if (new_options & WDIOS_ENABLECARD) { + wdt_start(); + retval = 0; + } + + return retval; + + case WDIOC_SETTIMEOUT: + if (get_user(new_timeout, uarg.i)) + return -EFAULT; + + if (wdt_set_timeout(new_timeout)) + return -EINVAL; + + wdt_keepalive(); + /* Fall */ + + case WDIOC_GETTIMEOUT: + return put_user(timeout, uarg.i); + + } +} + +static int wdt_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if (code==SYS_DOWN || code==SYS_HALT) + wdt_stop(); + return NOTIFY_DONE; +} + +static struct file_operations wdt_fops= +{ + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = wdt_write, + .ioctl = wdt_ioctl, + .open = wdt_open, + .release = wdt_release, +}; + +static struct miscdevice wdt_miscdev= +{ + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &wdt_fops, +}; + +static struct notifier_block wdt_notifier = { + .notifier_call = wdt_notify_sys, +}; + +static int __init w83977f_wdt_init(void) +{ + int rc; + + printk(KERN_INFO PFX DRIVER_VERSION); + + spin_lock_init(&spinlock); + + /* + * Check that the timeout value is within it's range ; + * if not reset to the default + */ + if (wdt_set_timeout(timeout)) { + wdt_set_timeout(DEFAULT_TIMEOUT); + printk(KERN_INFO PFX "timeout value must be 15<=timeout<=7635, using %d\n", + DEFAULT_TIMEOUT); + } + + if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME)) + { + printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", + IO_INDEX_PORT); + rc = -EIO; + goto err_out; + } + + rc = misc_register(&wdt_miscdev); + if (rc) + { + printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", + wdt_miscdev.minor, rc); + goto err_out_region; + } + + rc = register_reboot_notifier(&wdt_notifier); + if (rc) + { + printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", + rc); + goto err_out_miscdev; + } + + printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n", + timeout, nowayout, testmode); + + return 0; + +err_out_miscdev: + misc_deregister(&wdt_miscdev); +err_out_region: + release_region(IO_INDEX_PORT,2); +err_out: + return rc; +} + +static void __exit w83977f_wdt_exit(void) +{ + wdt_stop(); + misc_deregister(&wdt_miscdev); + unregister_reboot_notifier(&wdt_notifier); + release_region(IO_INDEX_PORT,2); +} + +module_init(w83977f_wdt_init); +module_exit(w83977f_wdt_exit); + +MODULE_AUTHOR("Jose Goncalves "); +MODULE_DESCRIPTION("Driver for watchdog timer in W83977F I/O chip"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); -- cgit v1.2.3 From 3908bb1867e7455c4ea132b758970c312513c37d Mon Sep 17 00:00:00 2001 From: Wim Van Sebroeck Date: Sun, 11 Sep 2005 23:58:22 +0200 Subject: [WATCHDOG] sbc8360+w83977f_wdt-consolidate_CONFIG_WATCHDOG_NOWAYOUT_handling Attached patch removes #ifdef CONFIG_WATCHDOG_NOWAYOUT mess and replaces it with common define in linux/watchdog.h. Signed-Off-By: Wim Van Sebroeck --- drivers/char/watchdog/sbc8360.c | 7 +------ drivers/char/watchdog/w83977f_wdt.c | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/char/watchdog/sbc8360.c b/drivers/char/watchdog/sbc8360.c index 06daf426d5b..c6cbf808d8c 100644 --- a/drivers/char/watchdog/sbc8360.c +++ b/drivers/char/watchdog/sbc8360.c @@ -199,12 +199,7 @@ static int wd_times[64][2] = { static int timeout = 27; static int wd_margin = 0xB; static int wd_multiplier = 2; - -#ifdef CONFIG_WATCHDOG_NOWAYOUT -static int nowayout = 1; -#else -static int nowayout = 0; -#endif +static int nowayout = WATCHDOG_NOWAYOUT; module_param(timeout, int, 27); MODULE_PARM_DESC(timeout, "Index into timeout table (0-63) (default=27 (60s))"); diff --git a/drivers/char/watchdog/w83977f_wdt.c b/drivers/char/watchdog/w83977f_wdt.c index 366d47bca16..a7ff64c8921 100644 --- a/drivers/char/watchdog/w83977f_wdt.c +++ b/drivers/char/watchdog/w83977f_wdt.c @@ -58,12 +58,7 @@ MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (15..7635), default=" __MO module_param(testmode, int, 0); MODULE_PARM_DESC(testmode,"Watchdog testmode (1 = no reboot), default=0"); -#ifdef CONFIG_WATCHDOG_NOWAYOUT -static int nowayout = 1; -#else -static int nowayout = 0; -#endif - +static int nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, int, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); -- cgit v1.2.3 From c315b7e840a1f336ffefb21d3130f9799af2ecd6 Mon Sep 17 00:00:00 2001 From: Wim Van Sebroeck Date: Mon, 12 Sep 2005 00:21:19 +0200 Subject: [WATCHDOG] pcwd_pci-include+WDIOC_SETOPTIONS-patch Clean-up includes Check results for start + stop in the WDIOC_SETOPTIONS ioctl call Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/pcwd_pci.c | 44 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c index 2b13afb09c5..5a80adbf803 100644 --- a/drivers/char/watchdog/pcwd_pci.c +++ b/drivers/char/watchdog/pcwd_pci.c @@ -29,27 +29,29 @@ * Includes, defines, variables, module parameters, ... */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include /* For CONFIG_WATCHDOG_NOWAYOUT/... */ +#include /* For module specific items */ +#include /* For new moduleparam's */ +#include /* For standard types (like size_t) */ +#include /* For the -ENODEV/... values */ +#include /* For printk/panic/... */ +#include /* For mdelay function */ +#include /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ +#include /* For the watchdog specific items */ +#include /* For notifier support */ +#include /* For reboot_notifier stuff */ +#include /* For __init/__exit/... */ +#include /* For file operations */ +#include /* For pci functions */ +#include /* For io-port access */ +#include /* For spin_lock/spin_unlock/... */ + +#include /* For copy_to_user/put_user/... */ +#include /* For inb/outb/... */ /* Module and version information */ #define WATCHDOG_VERSION "1.01" -#define WATCHDOG_DATE "15 Mar 2005" +#define WATCHDOG_DATE "02 Sep 2005" #define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" #define WATCHDOG_NAME "pcwd_pci" #define PFX WATCHDOG_NAME ": " @@ -335,12 +337,14 @@ static int pcipcwd_ioctl(struct inode *inode, struct file *file, return -EFAULT; if (new_options & WDIOS_DISABLECARD) { - pcipcwd_stop(); + if (pcipcwd_stop()) + return -EIO; retval = 0; } if (new_options & WDIOS_ENABLECARD) { - pcipcwd_start(); + if (pcipcwd_start()) + return -EIO; retval = 0; } -- cgit v1.2.3 From 9f566cfde14e185bcc3589ba7470788ed193535a Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Tue, 30 Aug 2005 21:00:46 +0200 Subject: [ALSA] snd-ca0106: Tidy up volume controls CA0106 driver Playback volume controls were appearing in both the playback and capture displays of alsamixer. Now those playback controls only appear in the playback display. Signed-off-by: James Courtier-Dutton --- sound/pci/ca0106/ca0106_mixer.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index b6b8882ce70..c10e4a54301 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -482,7 +482,7 @@ static int snd_ca0106_volume_put_feedback(snd_kcontrol_t * kcontrol, static snd_kcontrol_new_t snd_ca0106_volume_control_analog_front = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Analog Front Volume", + .name = "Analog Front Playback Volume", .info = snd_ca0106_volume_info, .get = snd_ca0106_volume_get_analog_front, .put = snd_ca0106_volume_put_analog_front @@ -490,7 +490,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_front = static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Analog Center/LFE Volume", + .name = "Analog Center/LFE Playback Volume", .info = snd_ca0106_volume_info, .get = snd_ca0106_volume_get_analog_center_lfe, .put = snd_ca0106_volume_put_analog_center_lfe @@ -498,7 +498,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe = static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Analog Side Volume", + .name = "Analog Side Playback Volume", .info = snd_ca0106_volume_info, .get = snd_ca0106_volume_get_analog_unknown, .put = snd_ca0106_volume_put_analog_unknown @@ -506,7 +506,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown = static snd_kcontrol_new_t snd_ca0106_volume_control_analog_rear = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Analog Rear Volume", + .name = "Analog Rear Playback Volume", .info = snd_ca0106_volume_info, .get = snd_ca0106_volume_get_analog_rear, .put = snd_ca0106_volume_put_analog_rear @@ -514,7 +514,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_rear = static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_front = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SPDIF Front Volume", + .name = "SPDIF Front Playback Volume", .info = snd_ca0106_volume_info, .get = snd_ca0106_volume_get_spdif_front, .put = snd_ca0106_volume_put_spdif_front @@ -522,7 +522,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_front = static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_center_lfe = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SPDIF Center/LFE Volume", + .name = "SPDIF Center/LFE Playback Volume", .info = snd_ca0106_volume_info, .get = snd_ca0106_volume_get_spdif_center_lfe, .put = snd_ca0106_volume_put_spdif_center_lfe @@ -530,7 +530,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_center_lfe = static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_unknown = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SPDIF Unknown Volume", + .name = "SPDIF Unknown Playback Volume", .info = snd_ca0106_volume_info, .get = snd_ca0106_volume_get_spdif_unknown, .put = snd_ca0106_volume_put_spdif_unknown @@ -538,7 +538,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_unknown = static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_rear = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SPDIF Rear Volume", + .name = "SPDIF Rear Playback Volume", .info = snd_ca0106_volume_info, .get = snd_ca0106_volume_get_spdif_rear, .put = snd_ca0106_volume_put_spdif_rear @@ -547,7 +547,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_rear = static snd_kcontrol_new_t snd_ca0106_volume_control_feedback = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "CAPTURE feedback into PLAYBACK", + .name = "CAPTURE feedback Playback Volume", .info = snd_ca0106_volume_info, .get = snd_ca0106_volume_get_feedback, .put = snd_ca0106_volume_put_feedback -- cgit v1.2.3 From ee71508e7359c16b43d6232e52cd19ec328e1f7c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 31 Aug 2005 17:31:07 +0200 Subject: [ALSA] Fix EAPD for MSI S270 AC97 Codec Fix pin47 setting for EAPD control on MSI S270 laptop. Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_patch.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index b584172c110..0acf51dd447 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -2145,8 +2145,13 @@ int patch_alc655(ac97_t * ac97) val = snd_ac97_read(ac97, 0x7a); /* misc control */ if (ac97->id == 0x414c4780) /* ALC658 */ val &= ~(1 << 1); /* Pin 47 is spdif input pin */ - else /* ALC655 */ - val |= (1 << 1); /* Pin 47 is spdif input pin */ + else { /* ALC655 */ + if (ac97->subsystem_vendor == 0x1462 && + ac97->subsystem_device == 0x0131) /* MSI S270 laptop */ + val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */ + else + val |= (1 << 1); /* Pin 47 is spdif input pin */ + } val &= ~(1 << 12); /* vref enable */ snd_ac97_write_cache(ac97, 0x7a, val); /* set default: spdif-in enabled, -- cgit v1.2.3 From 12bb5b78e512898034cdd8813f2889743fa6fa3d Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 1 Sep 2005 08:14:40 +0200 Subject: [ALSA] ad1889: add AD1889 driver PCI drivers,AD1889 driver move the AD1889 driver to the kernel tree Acked-by: Thibaut Varene Acked-by: Kyle McMartin Signed-off-by: Clemens Ladisch --- sound/pci/Kconfig | 12 + sound/pci/Makefile | 2 + sound/pci/ad1889.c | 1089 ++++++++++++++++++++++++++++++++++++++++++++++++++++ sound/pci/ad1889.h | 189 +++++++++ 4 files changed, 1292 insertions(+) create mode 100644 sound/pci/ad1889.c create mode 100644 sound/pci/ad1889.h diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 1e458919cce..a5d593c66f9 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -316,6 +316,18 @@ config SND_YMFPCI To compile this driver as a module, choose M here: the module will be called snd-ymfpci. +config SND_AD1889 + tristate "Analog Devices AD1889" + depends on SND + select SND_AC97_CODEC + help + Say Y here to include support for the integrated AC97 sound + device found in particular on the Hewlett-Packard [BCJ]-xxx0 + class PA-RISC workstations, using the AD1819 codec. + + To compile this as a module, choose M here: the module + will be called snd-ad1889. + config SND_ALS4000 tristate "Avance Logic ALS4000" depends on SND && ISA_DMA_API diff --git a/sound/pci/Makefile b/sound/pci/Makefile index b40575c3349..42fabfcfc2a 100644 --- a/sound/pci/Makefile +++ b/sound/pci/Makefile @@ -3,6 +3,7 @@ # Copyright (c) 2001 by Jaroslav Kysela # +snd-ad1889-objs := ad1889.o snd-als4000-objs := als4000.o snd-atiixp-objs := atiixp.o snd-atiixp-modem-objs := atiixp_modem.o @@ -25,6 +26,7 @@ snd-via82xx-objs := via82xx.o snd-via82xx-modem-objs := via82xx_modem.o # Toplevel Module Dependency +obj-$(CONFIG_SND_AD1889) += snd-ad1889.o obj-$(CONFIG_SND_ALS4000) += snd-als4000.o obj-$(CONFIG_SND_ATIIXP) += snd-atiixp.o obj-$(CONFIG_SND_ATIIXP_MODEM) += snd-atiixp-modem.o diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c new file mode 100644 index 00000000000..37e8df24711 --- /dev/null +++ b/sound/pci/ad1889.c @@ -0,0 +1,1089 @@ +/* Analog Devices 1889 audio driver + * + * This is a driver for the AD1889 PCI audio chipset found + * on the HP PA-RISC [BCJ]-xxx0 workstations. + * + * Copyright (C) 2004-2005, Kyle McMartin + * Copyright (C) 2005, Thibaut Varene + * Based on the OSS AD1889 driver by Randolph Chung + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * TODO: + * Do we need to take care of CCS register? + * Maybe we could use finer grained locking (separate locks for pb/cap)? + * Wishlist: + * Control Interface (mixer) support + * Better AC97 support (VSR...)? + * PM support + * MIDI support + * Game Port support + * SG DMA support (this will need *alot* of work) + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "ad1889.h" +#include "ac97/ac97_id.h" + +#define AD1889_DRVVER "$Revision: 1.1 $" + +MODULE_AUTHOR("Kyle McMartin , Thibaut Varene "); +MODULE_DESCRIPTION("Analog Devices AD1889 ALSA sound driver"); +MODULE_LICENSE("GPL"); +MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1889}}"); + +static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; +module_param_array(index, int, NULL, 0444); +MODULE_PARM_DESC(index, "Index value for the AD1889 soundcard."); + +static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; +module_param_array(id, charp, NULL, 0444); +MODULE_PARM_DESC(id, "ID string for the AD1889 soundcard."); + +static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; +module_param_array(enable, bool, NULL, 0444); +MODULE_PARM_DESC(enable, "Enable AD1889 soundcard."); + +static char *ac97_quirk[SNDRV_CARDS]; +module_param_array(ac97_quirk, charp, NULL, 0444); +MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); + +#define DEVNAME "ad1889" +#define PFX DEVNAME ": " + +/* let's use the global sound debug interfaces */ +#define ad1889_debug(fmt, arg...) snd_printd(KERN_DEBUG fmt, ## arg) + +/* keep track of some hw registers */ +struct ad1889_register_state { + u16 reg; /* reg setup */ + u32 addr; /* dma base address */ + unsigned long size; /* DMA buffer size */ +}; + +struct snd_ad1889 { + snd_card_t *card; + struct pci_dev *pci; + + int irq; + unsigned long bar; + void __iomem *iobase; + + ac97_t *ac97; + ac97_bus_t *ac97_bus; + snd_pcm_t *pcm; + snd_info_entry_t *proc; + + snd_pcm_substream_t *psubs; + snd_pcm_substream_t *csubs; + + /* playback register state */ + struct ad1889_register_state wave; + struct ad1889_register_state ramc; + + spinlock_t lock; +}; + +static inline u16 +ad1889_readw(struct snd_ad1889 *chip, unsigned reg) +{ + return readw(chip->iobase + reg); +} + +static inline void +ad1889_writew(struct snd_ad1889 *chip, unsigned reg, u16 val) +{ + writew(val, chip->iobase + reg); +} + +static inline u32 +ad1889_readl(struct snd_ad1889 *chip, unsigned reg) +{ + return readl(chip->iobase + reg); +} + +static inline void +ad1889_writel(struct snd_ad1889 *chip, unsigned reg, u32 val) +{ + writel(val, chip->iobase + reg); +} + +static inline void +ad1889_unmute(struct snd_ad1889 *chip) +{ + u16 st; + st = ad1889_readw(chip, AD_DS_WADA) & + ~(AD_DS_WADA_RWAM | AD_DS_WADA_LWAM); + ad1889_writew(chip, AD_DS_WADA, st); + ad1889_readw(chip, AD_DS_WADA); +} + +static inline void +ad1889_mute(struct snd_ad1889 *chip) +{ + u16 st; + st = ad1889_readw(chip, AD_DS_WADA) | AD_DS_WADA_RWAM | AD_DS_WADA_LWAM; + ad1889_writew(chip, AD_DS_WADA, st); + ad1889_readw(chip, AD_DS_WADA); +} + +static inline void +ad1889_load_adc_buffer_address(struct snd_ad1889 *chip, u32 address) +{ + ad1889_writel(chip, AD_DMA_ADCBA, address); + ad1889_writel(chip, AD_DMA_ADCCA, address); +} + +static inline void +ad1889_load_adc_buffer_count(struct snd_ad1889 *chip, u32 count) +{ + ad1889_writel(chip, AD_DMA_ADCBC, count); + ad1889_writel(chip, AD_DMA_ADCCC, count); +} + +static inline void +ad1889_load_adc_interrupt_count(struct snd_ad1889 *chip, u32 count) +{ + ad1889_writel(chip, AD_DMA_ADCIB, count); + ad1889_writel(chip, AD_DMA_ADCIC, count); +} + +static inline void +ad1889_load_wave_buffer_address(struct snd_ad1889 *chip, u32 address) +{ + ad1889_writel(chip, AD_DMA_WAVBA, address); + ad1889_writel(chip, AD_DMA_WAVCA, address); +} + +static inline void +ad1889_load_wave_buffer_count(struct snd_ad1889 *chip, u32 count) +{ + ad1889_writel(chip, AD_DMA_WAVBC, count); + ad1889_writel(chip, AD_DMA_WAVCC, count); +} + +static inline void +ad1889_load_wave_interrupt_count(struct snd_ad1889 *chip, u32 count) +{ + ad1889_writel(chip, AD_DMA_WAVIB, count); + ad1889_writel(chip, AD_DMA_WAVIC, count); +} + +static void +ad1889_channel_reset(struct snd_ad1889 *chip, unsigned int channel) +{ + u16 reg; + + if (channel & AD_CHAN_WAV) { + /* Disable wave channel */ + reg = ad1889_readw(chip, AD_DS_WSMC) & ~AD_DS_WSMC_WAEN; + ad1889_writew(chip, AD_DS_WSMC, reg); + chip->wave.reg = reg; + + /* disable IRQs */ + reg = ad1889_readw(chip, AD_DMA_WAV); + reg &= AD_DMA_IM_DIS; + reg &= ~AD_DMA_LOOP; + ad1889_writew(chip, AD_DMA_WAV, reg); + + /* clear IRQ and address counters and pointers */ + ad1889_load_wave_buffer_address(chip, 0x0); + ad1889_load_wave_buffer_count(chip, 0x0); + ad1889_load_wave_interrupt_count(chip, 0x0); + + /* flush */ + ad1889_readw(chip, AD_DMA_WAV); + } + + if (channel & AD_CHAN_ADC) { + /* Disable ADC channel */ + reg = ad1889_readw(chip, AD_DS_RAMC) & ~AD_DS_RAMC_ADEN; + ad1889_writew(chip, AD_DS_RAMC, reg); + chip->ramc.reg = reg; + + reg = ad1889_readw(chip, AD_DMA_ADC); + reg &= AD_DMA_IM_DIS; + reg &= ~AD_DMA_LOOP; + ad1889_writew(chip, AD_DMA_ADC, reg); + + ad1889_load_adc_buffer_address(chip, 0x0); + ad1889_load_adc_buffer_count(chip, 0x0); + ad1889_load_adc_interrupt_count(chip, 0x0); + + /* flush */ + ad1889_readw(chip, AD_DMA_ADC); + } +} + +static inline u16 +snd_ad1889_ac97_read(ac97_t *ac97, unsigned short reg) +{ + struct snd_ad1889 *chip = ac97->private_data; + return ad1889_readw(chip, AD_AC97_BASE + reg); +} + +static inline void +snd_ad1889_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) +{ + struct snd_ad1889 *chip = ac97->private_data; + ad1889_writew(chip, AD_AC97_BASE + reg, val); +} + +static int +snd_ad1889_ac97_ready(struct snd_ad1889 *chip) +{ + int retry = 400; /* average needs 352 msec */ + + while (!(ad1889_readw(chip, AD_AC97_ACIC) & AD_AC97_ACIC_ACRDY) + && --retry) + mdelay(1); + if (!retry) { + snd_printk(KERN_ERR PFX "[%s] Link is not ready.\n", + __FUNCTION__); + return -EIO; + } + ad1889_debug("[%s] ready after %d ms\n", __FUNCTION__, 400 - retry); + + return 0; +} + +static int +snd_ad1889_hw_params(snd_pcm_substream_t *substream, + snd_pcm_hw_params_t *hw_params) +{ + return snd_pcm_lib_malloc_pages(substream, + params_buffer_bytes(hw_params)); +} + +static int +snd_ad1889_hw_free(snd_pcm_substream_t *substream) +{ + return snd_pcm_lib_free_pages(substream); +} + +static snd_pcm_hardware_t snd_ad1889_playback_hw = { + .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, + .rate_min = 8000, /* docs say 7000, but we're lazy */ + .rate_max = 48000, + .channels_min = 1, + .channels_max = 2, + .buffer_bytes_max = BUFFER_BYTES_MAX, + .period_bytes_min = PERIOD_BYTES_MIN, + .period_bytes_max = PERIOD_BYTES_MAX, + .periods_min = PERIODS_MIN, + .periods_max = PERIODS_MAX, + /*.fifo_size = 0,*/ +}; + +static snd_pcm_hardware_t snd_ad1889_capture_hw = { + .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rates = SNDRV_PCM_RATE_48000, + .rate_min = 48000, /* docs say we could to VSR, but we're lazy */ + .rate_max = 48000, + .channels_min = 1, + .channels_max = 2, + .buffer_bytes_max = BUFFER_BYTES_MAX, + .period_bytes_min = PERIOD_BYTES_MIN, + .period_bytes_max = PERIOD_BYTES_MAX, + .periods_min = PERIODS_MIN, + .periods_max = PERIODS_MAX, + /*.fifo_size = 0,*/ +}; + +static int +snd_ad1889_playback_open(snd_pcm_substream_t *ss) +{ + struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); + snd_pcm_runtime_t *rt = ss->runtime; + + chip->psubs = ss; + rt->hw = snd_ad1889_playback_hw; + + return 0; +} + +static int +snd_ad1889_capture_open(snd_pcm_substream_t *ss) +{ + struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); + snd_pcm_runtime_t *rt = ss->runtime; + + chip->csubs = ss; + rt->hw = snd_ad1889_capture_hw; + + return 0; +} + +static int +snd_ad1889_playback_close(snd_pcm_substream_t *ss) +{ + struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); + chip->psubs = NULL; + return 0; +} + +static int +snd_ad1889_capture_close(snd_pcm_substream_t *ss) +{ + struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); + chip->csubs = NULL; + return 0; +} + +static int +snd_ad1889_playback_prepare(snd_pcm_substream_t *ss) +{ + struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); + snd_pcm_runtime_t *rt = ss->runtime; + unsigned int size = snd_pcm_lib_buffer_bytes(ss); + unsigned int count = snd_pcm_lib_period_bytes(ss); + u16 reg; + + ad1889_channel_reset(chip, AD_CHAN_WAV); + + reg = ad1889_readw(chip, AD_DS_WSMC); + + /* Mask out 16-bit / Stereo */ + reg &= ~(AD_DS_WSMC_WA16 | AD_DS_WSMC_WAST); + + if (snd_pcm_format_width(rt->format) == 16) + reg |= AD_DS_WSMC_WA16; + + if (rt->channels > 1) + reg |= AD_DS_WSMC_WAST; + + /* let's make sure we don't clobber ourselves */ + spin_lock_irq(&chip->lock); + + chip->wave.size = size; + chip->wave.reg = reg; + chip->wave.addr = rt->dma_addr; + + ad1889_writew(chip, AD_DS_WSMC, chip->wave.reg); + + /* Set sample rates on the codec */ + ad1889_writew(chip, AD_DS_WAS, rt->rate); + + /* Set up DMA */ + ad1889_load_wave_buffer_address(chip, chip->wave.addr); + ad1889_load_wave_buffer_count(chip, size); + ad1889_load_wave_interrupt_count(chip, count); + + /* writes flush */ + ad1889_readw(chip, AD_DS_WSMC); + + spin_unlock_irq(&chip->lock); + + ad1889_debug("prepare playback: addr = 0x%x, count = %u, " + "size = %u, reg = 0x%x, rate = %u\n", chip->wave.addr, + count, size, reg, rt->rate); + return 0; +} + +static int +snd_ad1889_capture_prepare(snd_pcm_substream_t *ss) +{ + struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); + snd_pcm_runtime_t *rt = ss->runtime; + unsigned int size = snd_pcm_lib_buffer_bytes(ss); + unsigned int count = snd_pcm_lib_period_bytes(ss); + u16 reg; + + ad1889_channel_reset(chip, AD_CHAN_ADC); + + reg = ad1889_readw(chip, AD_DS_RAMC); + + /* Mask out 16-bit / Stereo */ + reg &= ~(AD_DS_RAMC_AD16 | AD_DS_RAMC_ADST); + + if (snd_pcm_format_width(rt->format) == 16) + reg |= AD_DS_RAMC_AD16; + + if (rt->channels > 1) + reg |= AD_DS_RAMC_ADST; + + /* let's make sure we don't clobber ourselves */ + spin_lock_irq(&chip->lock); + + chip->ramc.size = size; + chip->ramc.reg = reg; + chip->ramc.addr = rt->dma_addr; + + ad1889_writew(chip, AD_DS_RAMC, chip->ramc.reg); + + /* Set up DMA */ + ad1889_load_adc_buffer_address(chip, chip->ramc.addr); + ad1889_load_adc_buffer_count(chip, size); + ad1889_load_adc_interrupt_count(chip, count); + + /* writes flush */ + ad1889_readw(chip, AD_DS_RAMC); + + spin_unlock_irq(&chip->lock); + + ad1889_debug("prepare capture: addr = 0x%x, count = %u, " + "size = %u, reg = 0x%x, rate = %u\n", chip->ramc.addr, + count, size, reg, rt->rate); + return 0; +} + +/* this is called in atomic context with IRQ disabled. + Must be as fast as possible and not sleep. + DMA should be *triggered* by this call. + The WSMC "WAEN" bit triggers DMA Wave On/Off */ +static int +snd_ad1889_playback_trigger(snd_pcm_substream_t *ss, int cmd) +{ + u16 wsmc; + struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); + + wsmc = ad1889_readw(chip, AD_DS_WSMC); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + /* enable DMA loop & interrupts */ + ad1889_writew(chip, AD_DMA_WAV, AD_DMA_LOOP | AD_DMA_IM_CNT); + wsmc |= AD_DS_WSMC_WAEN; + /* 1 to clear CHSS bit */ + ad1889_writel(chip, AD_DMA_CHSS, AD_DMA_CHSS_WAVS); + ad1889_unmute(chip); + break; + case SNDRV_PCM_TRIGGER_STOP: + ad1889_mute(chip); + wsmc &= ~AD_DS_WSMC_WAEN; + break; + default: + snd_BUG(); + return -EINVAL; + } + + chip->wave.reg = wsmc; + ad1889_writew(chip, AD_DS_WSMC, wsmc); + ad1889_readw(chip, AD_DS_WSMC); /* flush */ + + /* reset the chip when STOP - will disable IRQs */ + if (cmd == SNDRV_PCM_TRIGGER_STOP) + ad1889_channel_reset(chip, AD_CHAN_WAV); + + return 0; +} + +/* this is called in atomic context with IRQ disabled. + Must be as fast as possible and not sleep. + DMA should be *triggered* by this call. + The RAMC "ADEN" bit triggers DMA ADC On/Off */ +static int +snd_ad1889_capture_trigger(snd_pcm_substream_t *ss, int cmd) +{ + u16 ramc; + struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); + + ramc = ad1889_readw(chip, AD_DS_RAMC); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + /* enable DMA loop & interrupts */ + ad1889_writew(chip, AD_DMA_ADC, AD_DMA_LOOP | AD_DMA_IM_CNT); + ramc |= AD_DS_RAMC_ADEN; + /* 1 to clear CHSS bit */ + ad1889_writel(chip, AD_DMA_CHSS, AD_DMA_CHSS_ADCS); + break; + case SNDRV_PCM_TRIGGER_STOP: + ramc &= ~AD_DS_RAMC_ADEN; + break; + default: + return -EINVAL; + } + + chip->ramc.reg = ramc; + ad1889_writew(chip, AD_DS_RAMC, ramc); + ad1889_readw(chip, AD_DS_RAMC); /* flush */ + + /* reset the chip when STOP - will disable IRQs */ + if (cmd == SNDRV_PCM_TRIGGER_STOP) + ad1889_channel_reset(chip, AD_CHAN_ADC); + + return 0; +} + +/* Called in atomic context with IRQ disabled */ +static snd_pcm_uframes_t +snd_ad1889_playback_pointer(snd_pcm_substream_t *ss) +{ + size_t ptr = 0; + struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); + + if (unlikely(!(chip->wave.reg & AD_DS_WSMC_WAEN))) + return 0; + + ptr = ad1889_readl(chip, AD_DMA_WAVCA); + ptr -= chip->wave.addr; + + snd_assert((ptr >= 0) && (ptr < chip->wave.size), return 0); + + return bytes_to_frames(ss->runtime, ptr); +} + +/* Called in atomic context with IRQ disabled */ +static snd_pcm_uframes_t +snd_ad1889_capture_pointer(snd_pcm_substream_t *ss) +{ + size_t ptr = 0; + struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); + + if (unlikely(!(chip->ramc.reg & AD_DS_RAMC_ADEN))) + return 0; + + ptr = ad1889_readl(chip, AD_DMA_ADCCA); + ptr -= chip->ramc.addr; + + snd_assert((ptr >= 0) && (ptr < chip->ramc.size), return 0); + + return bytes_to_frames(ss->runtime, ptr); +} + +static snd_pcm_ops_t snd_ad1889_playback_ops = { + .open = snd_ad1889_playback_open, + .close = snd_ad1889_playback_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = snd_ad1889_hw_params, + .hw_free = snd_ad1889_hw_free, + .prepare = snd_ad1889_playback_prepare, + .trigger = snd_ad1889_playback_trigger, + .pointer = snd_ad1889_playback_pointer, +}; + +static snd_pcm_ops_t snd_ad1889_capture_ops = { + .open = snd_ad1889_capture_open, + .close = snd_ad1889_capture_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = snd_ad1889_hw_params, + .hw_free = snd_ad1889_hw_free, + .prepare = snd_ad1889_capture_prepare, + .trigger = snd_ad1889_capture_trigger, + .pointer = snd_ad1889_capture_pointer, +}; + +static irqreturn_t +snd_ad1889_interrupt(int irq, + void *dev_id, + struct pt_regs *regs) +{ + unsigned long st; + struct snd_ad1889 *chip = dev_id; + + st = ad1889_readl(chip, AD_DMA_DISR); + + /* clear ISR */ + ad1889_writel(chip, AD_DMA_DISR, st); + + st &= AD_INTR_MASK; + + if (unlikely(!st)) + return IRQ_NONE; + + if (st & (AD_DMA_DISR_PMAI|AD_DMA_DISR_PTAI)) + ad1889_debug("Unexpected master or target abort interrupt!\n"); + + if ((st & AD_DMA_DISR_WAVI) && chip->psubs) + snd_pcm_period_elapsed(chip->psubs); + if ((st & AD_DMA_DISR_ADCI) && chip->csubs) + snd_pcm_period_elapsed(chip->csubs); + + return IRQ_HANDLED; +} + +static void +snd_ad1889_pcm_free(snd_pcm_t *pcm) +{ + struct snd_ad1889 *chip = pcm->private_data; + chip->pcm = NULL; + snd_pcm_lib_preallocate_free_for_all(pcm); +} + +static int __devinit +snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, snd_pcm_t **rpcm) +{ + int err; + snd_pcm_t *pcm; + + if (rpcm) + *rpcm = NULL; + + err = snd_pcm_new(chip->card, chip->card->driver, device, 1, 1, &pcm); + if (err < 0) + return err; + + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, + &snd_ad1889_playback_ops); + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, + &snd_ad1889_capture_ops); + + pcm->private_data = chip; + pcm->private_free = snd_ad1889_pcm_free; + pcm->info_flags = 0; + strcpy(pcm->name, chip->card->shortname); + + chip->pcm = pcm; + chip->psubs = NULL; + chip->csubs = NULL; + + err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_dma_pci_data(chip->pci), + BUFFER_BYTES_MAX / 2, + BUFFER_BYTES_MAX); + + if (err < 0) { + snd_printk(KERN_ERR PFX "buffer allocation error: %d\n", err); + return err; + } + + if (rpcm) + *rpcm = pcm; + + return 0; +} + +static void +snd_ad1889_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +{ + struct snd_ad1889 *chip = entry->private_data; + u16 reg; + int tmp; + + reg = ad1889_readw(chip, AD_DS_WSMC); + snd_iprintf(buffer, "Wave output: %s\n", + (reg & AD_DS_WSMC_WAEN) ? "enabled" : "disabled"); + snd_iprintf(buffer, "Wave Channels: %s\n", + (reg & AD_DS_WSMC_WAST) ? "stereo" : "mono"); + snd_iprintf(buffer, "Wave Quality: %d-bit linear\n", + (reg & AD_DS_WSMC_WA16) ? 16 : 8); + + /* WARQ is at offset 12 */ + tmp = (reg & AD_DS_WSMC_WARQ) ? + (((reg & AD_DS_WSMC_WARQ >> 12) & 0x01) ? 12 : 18) : 4; + tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1; + + snd_iprintf(buffer, "Wave FIFO: %d %s words\n\n", tmp, + (reg & AD_DS_WSMC_WAST) ? "stereo" : "mono"); + + + snd_iprintf(buffer, "Synthesis output: %s\n", + reg & AD_DS_WSMC_SYEN ? "enabled" : "disabled"); + + /* SYRQ is at offset 4 */ + tmp = (reg & AD_DS_WSMC_SYRQ) ? + (((reg & AD_DS_WSMC_SYRQ >> 4) & 0x01) ? 12 : 18) : 4; + tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1; + + snd_iprintf(buffer, "Synthesis FIFO: %d %s words\n\n", tmp, + (reg & AD_DS_WSMC_WAST) ? "stereo" : "mono"); + + reg = ad1889_readw(chip, AD_DS_RAMC); + snd_iprintf(buffer, "ADC input: %s\n", + (reg & AD_DS_RAMC_ADEN) ? "enabled" : "disabled"); + snd_iprintf(buffer, "ADC Channels: %s\n", + (reg & AD_DS_RAMC_ADST) ? "stereo" : "mono"); + snd_iprintf(buffer, "ADC Quality: %d-bit linear\n", + (reg & AD_DS_RAMC_AD16) ? 16 : 8); + + /* ACRQ is at offset 4 */ + tmp = (reg & AD_DS_RAMC_ACRQ) ? + (((reg & AD_DS_RAMC_ACRQ >> 4) & 0x01) ? 12 : 18) : 4; + tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1; + + snd_iprintf(buffer, "ADC FIFO: %d %s words\n\n", tmp, + (reg & AD_DS_RAMC_ADST) ? "stereo" : "mono"); + + snd_iprintf(buffer, "Resampler input: %s\n", + reg & AD_DS_RAMC_REEN ? "enabled" : "disabled"); + + /* RERQ is at offset 12 */ + tmp = (reg & AD_DS_RAMC_RERQ) ? + (((reg & AD_DS_RAMC_RERQ >> 12) & 0x01) ? 12 : 18) : 4; + tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1; + + snd_iprintf(buffer, "Resampler FIFO: %d %s words\n\n", tmp, + (reg & AD_DS_WSMC_WAST) ? "stereo" : "mono"); + + + /* doc says LSB represents -1.5dB, but the max value (-94.5dB) + suggests that LSB is -3dB, which is more coherent with the logarithmic + nature of the dB scale */ + reg = ad1889_readw(chip, AD_DS_WADA); + snd_iprintf(buffer, "Left: %s, -%d dB\n", + (reg & AD_DS_WADA_LWAM) ? "mute" : "unmute", + ((reg & AD_DS_WADA_LWAA) >> 8) * 3); + reg = ad1889_readw(chip, AD_DS_WADA); + snd_iprintf(buffer, "Right: %s, -%d dB\n", + (reg & AD_DS_WADA_RWAM) ? "mute" : "unmute", + ((reg & AD_DS_WADA_RWAA) >> 8) * 3); + + reg = ad1889_readw(chip, AD_DS_WAS); + snd_iprintf(buffer, "Wave samplerate: %u Hz\n", reg); + reg = ad1889_readw(chip, AD_DS_RES); + snd_iprintf(buffer, "Resampler samplerate: %u Hz\n", reg); +} + +static void __devinit +snd_ad1889_proc_init(struct snd_ad1889 *chip) +{ + snd_info_entry_t *entry; + + if (!snd_card_proc_new(chip->card, chip->card->driver, &entry)) + snd_info_set_text_ops(entry, chip, 1024, snd_ad1889_proc_read); +} + +static struct ac97_quirk ac97_quirks[] = { + { + .subvendor = 0x11d4, /* AD */ + .subdevice = 0x1889, /* AD1889 */ + .codec_id = AC97_ID_AD1819, + .name = "AD1889", + .type = AC97_TUNE_HP_ONLY + }, + { } /* terminator */ +}; + +static void __devinit +snd_ad1889_ac97_xinit(struct snd_ad1889 *chip) +{ + u16 reg; + + reg = ad1889_readw(chip, AD_AC97_ACIC); + reg |= AD_AC97_ACIC_ACRD; /* Reset Disable */ + ad1889_writew(chip, AD_AC97_ACIC, reg); + ad1889_readw(chip, AD_AC97_ACIC); /* flush posted write */ + udelay(10); + /* Interface Enable */ + reg |= AD_AC97_ACIC_ACIE; + ad1889_writew(chip, AD_AC97_ACIC, reg); + + snd_ad1889_ac97_ready(chip); + + /* Audio Stream Output | Variable Sample Rate Mode */ + reg = ad1889_readw(chip, AD_AC97_ACIC); + reg |= AD_AC97_ACIC_ASOE | AD_AC97_ACIC_VSRM; + ad1889_writew(chip, AD_AC97_ACIC, reg); + ad1889_readw(chip, AD_AC97_ACIC); /* flush posted write */ + +} + +static void +snd_ad1889_ac97_bus_free(ac97_bus_t *bus) +{ + struct snd_ad1889 *chip = bus->private_data; + chip->ac97_bus = NULL; +} + +static void +snd_ad1889_ac97_free(ac97_t *ac97) +{ + struct snd_ad1889 *chip = ac97->private_data; + chip->ac97 = NULL; +} + +static int __devinit +snd_ad1889_ac97_init(struct snd_ad1889 *chip, const char *quirk_override) +{ + int err; + ac97_template_t ac97; + static ac97_bus_ops_t ops = { + .write = snd_ad1889_ac97_write, + .read = snd_ad1889_ac97_read, + }; + + /* doing that here, it works. */ + snd_ad1889_ac97_xinit(chip); + + err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus); + if (err < 0) + return err; + + chip->ac97_bus->private_free = snd_ad1889_ac97_bus_free; + + memset(&ac97, 0, sizeof(ac97)); + ac97.private_data = chip; + ac97.private_free = snd_ad1889_ac97_free; + ac97.pci = chip->pci; + + err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97); + if (err < 0) + return err; + + snd_ac97_tune_hardware(chip->ac97, ac97_quirks, quirk_override); + + return 0; +} + +static int +snd_ad1889_free(struct snd_ad1889 *chip) +{ + if (chip->irq < 0) + goto skip_hw; + + spin_lock_irq(&chip->lock); + + ad1889_mute(chip); + + /* Turn off interrupt on count and zero DMA registers */ + ad1889_channel_reset(chip, AD_CHAN_WAV | AD_CHAN_ADC); + + /* clear DISR. If we don't, we'd better jump off the Eiffel Tower */ + ad1889_writel(chip, AD_DMA_DISR, AD_DMA_DISR_PTAI | AD_DMA_DISR_PMAI); + ad1889_readl(chip, AD_DMA_DISR); /* flush, dammit! */ + + spin_unlock_irq(&chip->lock); + + synchronize_irq(chip->irq); + + if (chip->irq >= 0) + free_irq(chip->irq, (void*)chip); + +skip_hw: + if (chip->iobase) + iounmap(chip->iobase); + + pci_release_regions(chip->pci); + pci_disable_device(chip->pci); + + kfree(chip); + return 0; +} + +static inline int +snd_ad1889_dev_free(snd_device_t *device) +{ + struct snd_ad1889 *chip = device->device_data; + return snd_ad1889_free(chip); +} + +static int __devinit +snd_ad1889_init(struct snd_ad1889 *chip) +{ + ad1889_writew(chip, AD_DS_CCS, AD_DS_CCS_CLKEN); /* turn on clock */ + ad1889_readw(chip, AD_DS_CCS); /* flush posted write */ + + mdelay(10); + + /* enable Master and Target abort interrupts */ + ad1889_writel(chip, AD_DMA_DISR, AD_DMA_DISR_PMAE | AD_DMA_DISR_PTAE); + + return 0; +} + +static int __devinit +snd_ad1889_create(snd_card_t *card, + struct pci_dev *pci, + struct snd_ad1889 **rchip) +{ + int err; + + struct snd_ad1889 *chip; + static snd_device_ops_t ops = { + .dev_free = snd_ad1889_dev_free, + }; + + *rchip = NULL; + + if ((err = pci_enable_device(pci)) < 0) + return err; + + /* check PCI availability (32bit DMA) */ + if (pci_set_dma_mask(pci, 0xffffffff) < 0 || + pci_set_consistent_dma_mask(pci, 0xffffffff) < 0) { + printk(KERN_ERR PFX "error setting 32-bit DMA mask.\n"); + pci_disable_device(pci); + return -ENXIO; + } + + /* allocate chip specific data with zero-filled memory */ + if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL) { + pci_disable_device(pci); + return -ENOMEM; + } + + chip->card = card; + card->private_data = chip; + chip->pci = pci; + chip->irq = -1; + + /* (1) PCI resource allocation */ + if ((err = pci_request_regions(pci, card->driver)) < 0) + goto free_and_ret; + + chip->bar = pci_resource_start(pci, 0); + chip->iobase = ioremap_nocache(chip->bar, pci_resource_len(pci, 0)); + if (chip->iobase == NULL) { + printk(KERN_ERR PFX "unable to reserve region.\n"); + err = -EBUSY; + goto free_and_ret; + } + + pci_set_master(pci); + + spin_lock_init(&chip->lock); /* only now can we call ad1889_free */ + + if (request_irq(pci->irq, snd_ad1889_interrupt, + SA_INTERRUPT|SA_SHIRQ, card->driver, (void*)chip)) { + printk(KERN_ERR PFX "cannot obtain IRQ %d\n", pci->irq); + snd_ad1889_free(chip); + return -EBUSY; + } + + chip->irq = pci->irq; + synchronize_irq(chip->irq); + + /* (2) initialization of the chip hardware */ + if ((err = snd_ad1889_init(chip)) < 0) { + snd_ad1889_free(chip); + return err; + } + + if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { + snd_ad1889_free(chip); + return err; + } + + snd_card_set_dev(card, &pci->dev); + + *rchip = chip; + + return 0; + +free_and_ret: + if (chip) + kfree(chip); + pci_disable_device(pci); + + return err; +} + +static int __devinit +snd_ad1889_probe(struct pci_dev *pci, + const struct pci_device_id *pci_id) +{ + int err; + static int devno; + snd_card_t *card; + struct snd_ad1889 *chip; + + /* (1) */ + if (devno >= SNDRV_CARDS) + return -ENODEV; + if (!enable[devno]) { + devno++; + return -ENOENT; + } + + /* (2) */ + card = snd_card_new(index[devno], id[devno], THIS_MODULE, 0); + /* XXX REVISIT: we can probably allocate chip in this call */ + if (card == NULL) + return -ENOMEM; + + strcpy(card->driver, "AD1889"); + strcpy(card->shortname, "Analog Devices AD1889"); + + /* (3) */ + err = snd_ad1889_create(card, pci, &chip); + if (err < 0) + goto free_and_ret; + + /* (4) */ + sprintf(card->longname, "%s at 0x%lx irq %i", + card->shortname, chip->bar, chip->irq); + + /* (5) */ + /* register AC97 mixer */ + err = snd_ad1889_ac97_init(chip, ac97_quirk[devno]); + if (err < 0) + goto free_and_ret; + + err = snd_ad1889_pcm_init(chip, 0, NULL); + if (err < 0) + goto free_and_ret; + + /* register proc interface */ + snd_ad1889_proc_init(chip); + + /* (6) */ + err = snd_card_register(card); + if (err < 0) + goto free_and_ret; + + /* (7) */ + pci_set_drvdata(pci, card); + + devno++; + return 0; + +free_and_ret: + snd_card_free(card); + return err; +} + +static void __devexit +snd_ad1889_remove(struct pci_dev *pci) +{ + snd_card_free(pci_get_drvdata(pci)); + pci_set_drvdata(pci, NULL); +} + +static struct pci_device_id snd_ad1889_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_ANALOG_DEVICES, PCI_DEVICE_ID_AD1889JS) }, + { 0, }, +}; +MODULE_DEVICE_TABLE(pci, snd_ad1889_ids); + +static struct pci_driver ad1889_pci = { + .name = "AD1889 Audio", + .id_table = snd_ad1889_ids, + .probe = snd_ad1889_probe, + .remove = __devexit_p(snd_ad1889_remove), +}; + +static int __init +alsa_ad1889_init(void) +{ + return pci_register_driver(&ad1889_pci); +} + +static void __exit +alsa_ad1889_fini(void) +{ + pci_unregister_driver(&ad1889_pci); +} + +module_init(alsa_ad1889_init); +module_exit(alsa_ad1889_fini); diff --git a/sound/pci/ad1889.h b/sound/pci/ad1889.h new file mode 100644 index 00000000000..5e6dad5341a --- /dev/null +++ b/sound/pci/ad1889.h @@ -0,0 +1,189 @@ +/* Analog Devices 1889 audio driver + * Copyright (C) 2004, Kyle McMartin + */ + +#ifndef __AD1889_H__ +#define __AD1889_H__ + +#define AD_DS_WSMC 0x00 /* wave/synthesis channel mixer control */ +#define AD_DS_WSMC_SYEN 0x0004 /* synthesis channel enable */ +#define AD_DS_WSMC_SYRQ 0x0030 /* synth. fifo request point */ +#define AD_DS_WSMC_WA16 0x0100 /* wave channel 16bit select */ +#define AD_DS_WSMC_WAST 0x0200 /* wave channel stereo select */ +#define AD_DS_WSMC_WAEN 0x0400 /* wave channel enable */ +#define AD_DS_WSMC_WARQ 0x3000 /* wave fifo request point */ + +#define AD_DS_RAMC 0x02 /* resampler/ADC channel mixer control */ +#define AD_DS_RAMC_AD16 0x0001 /* ADC channel 16bit select */ +#define AD_DS_RAMC_ADST 0x0002 /* ADC channel stereo select */ +#define AD_DS_RAMC_ADEN 0x0004 /* ADC channel enable */ +#define AD_DS_RAMC_ACRQ 0x0030 /* ADC fifo request point */ +#define AD_DS_RAMC_REEN 0x0400 /* resampler channel enable */ +#define AD_DS_RAMC_RERQ 0x3000 /* res. fifo request point */ + +#define AD_DS_WADA 0x04 /* wave channel mix attenuation */ +#define AD_DS_WADA_RWAM 0x0080 /* right wave mute */ +#define AD_DS_WADA_RWAA 0x001f /* right wave attenuation */ +#define AD_DS_WADA_LWAM 0x8000 /* left wave mute */ +#define AD_DS_WADA_LWAA 0x3e00 /* left wave attenuation */ + +#define AD_DS_SYDA 0x06 /* synthesis channel mix attenuation */ +#define AD_DS_SYDA_RSYM 0x0080 /* right synthesis mute */ +#define AD_DS_SYDA_RSYA 0x001f /* right synthesis attenuation */ +#define AD_DS_SYDA_LSYM 0x8000 /* left synthesis mute */ +#define AD_DS_SYDA_LSYA 0x3e00 /* left synthesis attenuation */ + +#define AD_DS_WAS 0x08 /* wave channel sample rate */ +#define AD_DS_WAS_WAS 0xffff /* sample rate mask */ + +#define AD_DS_RES 0x0a /* resampler channel sample rate */ +#define AD_DS_RES_RES 0xffff /* sample rate mask */ + +#define AD_DS_CCS 0x0c /* chip control/status */ +#define AD_DS_CCS_ADO 0x0001 /* ADC channel overflow */ +#define AD_DS_CCS_REO 0x0002 /* resampler channel overflow */ +#define AD_DS_CCS_SYU 0x0004 /* synthesis channel underflow */ +#define AD_DS_CCS_WAU 0x0008 /* wave channel underflow */ +/* bits 4 -> 7, 9, 11 -> 14 reserved */ +#define AD_DS_CCS_XTD 0x0100 /* xtd delay control (4096 clock cycles) */ +#define AD_DS_CCS_PDALL 0x0400 /* power */ +#define AD_DS_CCS_CLKEN 0x8000 /* clock */ + +#define AD_DMA_RESBA 0x40 /* RES base address */ +#define AD_DMA_RESCA 0x44 /* RES current address */ +#define AD_DMA_RESBC 0x48 /* RES base count */ +#define AD_DMA_RESCC 0x4c /* RES current count */ + +#define AD_DMA_ADCBA 0x50 /* ADC base address */ +#define AD_DMA_ADCCA 0x54 /* ADC current address */ +#define AD_DMA_ADCBC 0x58 /* ADC base count */ +#define AD_DMA_ADCCC 0x5c /* ADC current count */ + +#define AD_DMA_SYNBA 0x60 /* synth base address */ +#define AD_DMA_SYNCA 0x64 /* synth current address */ +#define AD_DMA_SYNBC 0x68 /* synth base count */ +#define AD_DMA_SYNCC 0x6c /* synth current count */ + +#define AD_DMA_WAVBA 0x70 /* wave base address */ +#define AD_DMA_WAVCA 0x74 /* wave current address */ +#define AD_DMA_WAVBC 0x78 /* wave base count */ +#define AD_DMA_WAVCC 0x7c /* wave current count */ + +#define AD_DMA_RESIC 0x80 /* RES dma interrupt current byte count */ +#define AD_DMA_RESIB 0x84 /* RES dma interrupt base byte count */ + +#define AD_DMA_ADCIC 0x88 /* ADC dma interrupt current byte count */ +#define AD_DMA_ADCIB 0x8c /* ADC dma interrupt base byte count */ + +#define AD_DMA_SYNIC 0x90 /* synth dma interrupt current byte count */ +#define AD_DMA_SYNIB 0x94 /* synth dma interrupt base byte count */ + +#define AD_DMA_WAVIC 0x98 /* wave dma interrupt current byte count */ +#define AD_DMA_WAVIB 0x9c /* wave dma interrupt base byte count */ + +#define AD_DMA_ICC 0xffffff /* current byte count mask */ +#define AD_DMA_IBC 0xffffff /* base byte count mask */ +/* bits 24 -> 31 reserved */ + +/* 4 bytes pad */ +#define AD_DMA_ADC 0xa8 /* ADC dma control and status */ +#define AD_DMA_SYNTH 0xb0 /* Synth dma control and status */ +#define AD_DMA_WAV 0xb8 /* wave dma control and status */ +#define AD_DMA_RES 0xa0 /* Resample dma control and status */ + +#define AD_DMA_SGDE 0x0001 /* SGD mode enable */ +#define AD_DMA_LOOP 0x0002 /* loop enable */ +#define AD_DMA_IM 0x000c /* interrupt mode mask */ +#define AD_DMA_IM_DIS (~AD_DMA_IM) /* disable */ +#define AD_DMA_IM_CNT 0x0004 /* interrupt on count */ +#define AD_DMA_IM_SGD 0x0008 /* interrupt on SGD flag */ +#define AD_DMA_IM_EOL 0x000c /* interrupt on End of Linked List */ +#define AD_DMA_SGDS 0x0030 /* SGD status */ +#define AD_DMA_SFLG 0x0040 /* SGD flag */ +#define AD_DMA_EOL 0x0080 /* SGD end of list */ +/* bits 8 -> 15 reserved */ + +#define AD_DMA_DISR 0xc0 /* dma interrupt status */ +#define AD_DMA_DISR_RESI 0x000001 /* resampler channel interrupt */ +#define AD_DMA_DISR_ADCI 0x000002 /* ADC channel interrupt */ +#define AD_DMA_DISR_SYNI 0x000004 /* synthesis channel interrupt */ +#define AD_DMA_DISR_WAVI 0x000008 /* wave channel interrupt */ +/* bits 4, 5 reserved */ +#define AD_DMA_DISR_SEPS 0x000040 /* serial eeprom status */ +/* bits 7 -> 13 reserved */ +#define AD_DMA_DISR_PMAI 0x004000 /* pci master abort interrupt */ +#define AD_DMA_DISR_PTAI 0x008000 /* pci target abort interrupt */ +#define AD_DMA_DISR_PTAE 0x010000 /* pci target abort interrupt enable */ +#define AD_DMA_DISR_PMAE 0x020000 /* pci master abort interrupt enable */ +/* bits 19 -> 31 reserved */ + +/* interrupt mask */ +#define AD_INTR_MASK (AD_DMA_DISR_RESI|AD_DMA_DISR_ADCI| \ + AD_DMA_DISR_WAVI|AD_DMA_DISR_SYNI| \ + AD_DMA_DISR_PMAI|AD_DMA_DISR_PTAI) + +#define AD_DMA_CHSS 0xc4 /* dma channel stop status */ +#define AD_DMA_CHSS_RESS 0x000001 /* resampler channel stopped */ +#define AD_DMA_CHSS_ADCS 0x000002 /* ADC channel stopped */ +#define AD_DMA_CHSS_SYNS 0x000004 /* synthesis channel stopped */ +#define AD_DMA_CHSS_WAVS 0x000008 /* wave channel stopped */ + +#define AD_GPIO_IPC 0xc8 /* gpio port control */ +#define AD_GPIO_OP 0xca /* gpio output port status */ +#define AD_GPIO_IP 0xcc /* gpio input port status */ + +#define AD_AC97_BASE 0x100 /* ac97 base register */ + +#define AD_AC97_RESET 0x100 /* reset */ + +#define AD_AC97_PWR_CTL 0x126 /* == AC97_POWERDOWN */ +#define AD_AC97_PWR_ADC 0x0001 /* ADC ready status */ +#define AD_AC97_PWR_DAC 0x0002 /* DAC ready status */ +#define AD_AC97_PWR_PR0 0x0100 /* PR0 (ADC) powerdown */ +#define AD_AC97_PWR_PR1 0x0200 /* PR1 (DAC) powerdown */ + +#define AD_MISC_CTL 0x176 /* misc control */ +#define AD_MISC_CTL_DACZ 0x8000 /* set for zero fill, unset for repeat */ +#define AD_MISC_CTL_ARSR 0x0001 /* set for SR1, unset for SR0 */ +#define AD_MISC_CTL_ALSR 0x0100 +#define AD_MISC_CTL_DLSR 0x0400 +#define AD_MISC_CTL_DRSR 0x0004 + +#define AD_AC97_SR0 0x178 /* sample rate 0, 0xbb80 == 48K */ +#define AD_AC97_SR0_48K 0xbb80 /* 48KHz */ +#define AD_AC97_SR1 0x17a /* sample rate 1 */ + +#define AD_AC97_ACIC 0x180 /* ac97 codec interface control */ +#define AD_AC97_ACIC_ACIE 0x0001 /* analog codec interface enable */ +#define AD_AC97_ACIC_ACRD 0x0002 /* analog codec reset disable */ +#define AD_AC97_ACIC_ASOE 0x0004 /* audio stream output enable */ +#define AD_AC97_ACIC_VSRM 0x0008 /* variable sample rate mode */ +#define AD_AC97_ACIC_FSDH 0x0100 /* force SDATA_OUT high */ +#define AD_AC97_ACIC_FSYH 0x0200 /* force sync high */ +#define AD_AC97_ACIC_ACRDY 0x8000 /* analog codec ready status */ +/* bits 10 -> 14 reserved */ + + +#define AD_DS_MEMSIZE 512 +#define AD_OPL_MEMSIZE 16 +#define AD_MIDI_MEMSIZE 16 + +#define AD_WAV_STATE 0 +#define AD_ADC_STATE 1 +#define AD_MAX_STATES 2 + +#define AD_CHAN_WAV 0x0001 +#define AD_CHAN_ADC 0x0002 +#define AD_CHAN_RES 0x0004 +#define AD_CHAN_SYN 0x0008 + + +/* The chip would support 4 GB buffers and 16 MB periods, + * but let's not overdo it ... */ +#define BUFFER_BYTES_MAX (256 * 1024) +#define PERIOD_BYTES_MIN 32 +#define PERIOD_BYTES_MAX (BUFFER_BYTES_MAX / 2) +#define PERIODS_MIN 2 +#define PERIODS_MAX (BUFFER_BYTES_MAX / PERIOD_BYTES_MIN) + +#endif /* __AD1889_H__ */ -- cgit v1.2.3 From 8e3d759d4b5d841c2a665cffe6cd237dab49e3b1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 1 Sep 2005 11:56:34 +0200 Subject: [ALSA] atiixp - Fix PM resume ATIIXP driver Fixed PM resume on atiixp driver. Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 188df085b7e..19c7bd08d06 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1453,6 +1453,7 @@ static int snd_atiixp_resume(snd_card_t *card) atiixp_dma_t *dma = &chip->dmas[i]; if (dma->substream && dma->suspended) { dma->ops->enable_dma(chip, 1); + dma->substream->ops->prepare(dma->substream); writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN, chip->remap_addr + dma->ops->llp_offset); writel(dma->saved_curptr, chip->remap_addr + dma->ops->dt_cur); -- cgit v1.2.3 From 5d529390dc944e5d17e46cb5ca93519153f9bf07 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 1 Sep 2005 13:56:23 +0200 Subject: [ALSA] intel8x0 - Add quirk for IBM NetVisa A30p Intel8x0 driver Added ac97_quirk entry for IBM NetVisa A30p. Signed-off-by: Takashi Iwai --- sound/pci/intel8x0.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 7b548416dce..d846cbfaa31 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -1758,6 +1758,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = { .name = "MS-9128", .type = AC97_TUNE_ALC_JACK }, + { + .subvendor = 0x1014, + .subdevice = 0x0267, + .name = "IBM NetVista A30p", /* AD1981B */ + .type = AC97_TUNE_HP_ONLY + }, { .subvendor = 0x1028, .subdevice = 0x00d8, -- cgit v1.2.3 From 84010e6f04a59e88e4eb784ff33f2da97ac022f4 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 2 Sep 2005 07:57:59 +0200 Subject: [ALSA] ad1889: add AD1889 driver docs Documentation move the AD1889 driver docs to the kernel tree, too Signed-off-by: Clemens Ladisch --- Documentation/sound/alsa/ALSA-Configuration.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index ebfcdf28485..f626f4a9a61 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -148,6 +148,16 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards. This module does not support autoprobe thus main port must be specified!!! Other ports are optional. + Module snd-ad1889 + ----------------- + + Module for Analog Devices AD1889 chips. + + ac97_quirk - AC'97 workaround for strange hardware + See the description of intel8x0 module for details. + + This module supports up to 8 cards. + Module snd-ali5451 ------------------ -- cgit v1.2.3 From b73c1c122a097500e1c3dd495045432a1c818b92 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 2 Sep 2005 08:49:21 +0200 Subject: [ALSA] hdsp: always initialize card name RME HDSP driver When using the kernel firmware loader, initialize the card shortname before registering the card with ALSA to prevent it from using a default card ID. Signed-off-by: Clemens Ladisch --- sound/pci/rme9652/hdsp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 6694866089b..e4a90396912 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -4899,6 +4899,7 @@ static int snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp) } if (!(hdsp->state & HDSP_InitializationComplete)) { + strcpy(card->shortname, "Hammerfall DSP"); sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, hdsp->port, hdsp->irq); -- cgit v1.2.3 From a5022b0dc6e45254437b75289e773876bb43e262 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 2 Sep 2005 14:03:05 +0200 Subject: [ALSA] Fix ALC658D support AC97 Codec Fix the internal speaker problem (e.g. Targa Traveller 826) with ALC658D codec. The info is taken from Cyberlink/realtek-modified code. Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_codec.c | 1 + sound/pci/ac97/ac97_id.h | 1 + sound/pci/ac97/ac97_patch.c | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 5501f4440c9..3b66fa68936 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -112,6 +112,7 @@ static const ac97_codec_id_t snd_ac97_codec_ids[] = { { 0x414c4723, 0xffffffff, "ALC650F", NULL, NULL }, /* already patched */ { 0x414c4720, 0xfffffff0, "ALC650", patch_alc650, NULL }, { 0x414c4760, 0xfffffff0, "ALC655", patch_alc655, NULL }, +{ 0x414c4781, 0xffffffff, "ALC658D", NULL, NULL }, /* already patched */ { 0x414c4780, 0xfffffff0, "ALC658", patch_alc655, NULL }, { 0x414c4790, 0xfffffff0, "ALC850", patch_alc850, NULL }, { 0x414c4730, 0xffffffff, "ALC101", NULL, NULL }, diff --git a/sound/pci/ac97/ac97_id.h b/sound/pci/ac97/ac97_id.h index dadf387ad0b..6d73514dc49 100644 --- a/sound/pci/ac97/ac97_id.h +++ b/sound/pci/ac97/ac97_id.h @@ -52,6 +52,7 @@ #define AC97_ID_ALC650F 0x414c4723 #define AC97_ID_ALC655 0x414c4760 #define AC97_ID_ALC658 0x414c4780 +#define AC97_ID_ALC658D 0x414c4781 #define AC97_ID_ALC850 0x414c4790 #define AC97_ID_YMF753 0x594d4803 #define AC97_ID_VT1616 0x49434551 diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 0acf51dd447..045ddc743ed 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -2134,7 +2134,13 @@ int patch_alc655(ac97_t * ac97) { unsigned int val; - ac97->spec.dev_flags = (ac97->id == 0x414c4780); /* ALC658 */ + if (ac97->id == AC97_ID_ALC658) { + ac97->spec.dev_flags = 1; /* ALC658 */ + if ((snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f) == 2) { + ac97->id = AC97_ID_ALC658D; + ac97->spec.dev_flags = 2; + } + } ac97->build_ops = &patch_alc655_ops; @@ -2143,7 +2149,7 @@ int patch_alc655(ac97_t * ac97) /* adjust default values */ val = snd_ac97_read(ac97, 0x7a); /* misc control */ - if (ac97->id == 0x414c4780) /* ALC658 */ + if (ac97->spec.dev_flags) /* ALC658 */ val &= ~(1 << 1); /* Pin 47 is spdif input pin */ else { /* ALC655 */ if (ac97->subsystem_vendor == 0x1462 && @@ -2164,6 +2170,11 @@ int patch_alc655(ac97_t * ac97) /* full DAC volume */ snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808); snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808); + + /* update undocumented bit... */ + if (ac97->id == AC97_ID_ALC658D) + snd_ac97_update_bits(ac97, 0x74, 0x0800, 0x0800); + return 0; } -- cgit v1.2.3 From 025cd2f6b1624f536d4df564add3d13ea5022f53 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Sat, 3 Sep 2005 12:05:47 +0200 Subject: [ALSA] snd-ca0106, snd-emu10k1: Add symlink in the sys tree. CA0106 driver,EMU10K1/EMU10K2 driver A thread appeared on the LKML. This patch implements the fix. Question: in sysfs, /sys/bus/*/drivers lists the driver names, with their exported .name (eg. '.name = 'EMU10K1_Audigy'' in the module code, from now on 'driver name'). In /sys/modules, the kernel modules are listed with their module name, eg. snd_emu10k1. However, it seems to me that in sysfs, there is no way in particular to tell, which module has which .name. That is, that snd_emu10k1 is EMU10K1_Audigy and vice versa. I wonder whether it wouldn't be possible to add a symlink to the particular module from the driver, and/or from the module to the driver, so the list of devices handled by the module and the module name would be accessible. This way, I would know which driver name corresponds to which module name and vice versa. Answer: For PCI drivers, just add the line: .owner = THIS_MODULE, to their struct pci_driver definition and you will get the symlink created for you. Signed-off-by: James Courtier-Dutton --- sound/pci/ca0106/ca0106_main.c | 1 + sound/pci/emu10k1/emu10k1.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 7e27bfc3743..4a1abb12ee5 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1390,6 +1390,7 @@ MODULE_DEVICE_TABLE(pci, snd_ca0106_ids); // pci_driver definition static struct pci_driver driver = { .name = "CA0106", + .owner = THIS_MODULE, .id_table = snd_ca0106_ids, .probe = snd_ca0106_probe, .remove = __devexit_p(snd_ca0106_remove), diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index fc377c4b666..b0e00f0a7c2 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c @@ -223,6 +223,7 @@ static void __devexit snd_card_emu10k1_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "EMU10K1_Audigy", + .owner = THIS_MODULE, .id_table = snd_emu10k1_ids, .probe = snd_card_emu10k1_probe, .remove = __devexit_p(snd_card_emu10k1_remove), -- cgit v1.2.3 From 49045d3d4dc7c43310b1fca693e29fcdbe68faba Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 5 Sep 2005 10:31:05 +0200 Subject: [ALSA] usb-audio: add SNDRV_PCM_INFO_BATCH flag USB generic driver Add the SNDRV_PCM_INFO_BATCH flag to the PCM hardware information to indicate that the driver uses double buffering. Signed-off-by: Clemens Ladisch --- sound/usb/usbaudio.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index bfbec587665..da22f25d4ef 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -1439,9 +1439,11 @@ static int snd_usb_pcm_prepare(snd_pcm_substream_t *substream) static snd_pcm_hardware_t snd_usb_playback = { - .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID), + .info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_BATCH | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER, .buffer_bytes_max = (256*1024), .period_bytes_min = 64, .period_bytes_max = (128*1024), @@ -1451,9 +1453,11 @@ static snd_pcm_hardware_t snd_usb_playback = static snd_pcm_hardware_t snd_usb_capture = { - .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID), + .info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_BATCH | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER, .buffer_bytes_max = (256*1024), .period_bytes_min = 64, .period_bytes_max = (128*1024), -- cgit v1.2.3 From 4d23359b7ec8b03da2154df935af7d625075f6cf Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 5 Sep 2005 10:35:20 +0200 Subject: [ALSA] sparse address space annotations ALSA Core,RawMidi Midlevel,ALSA<-OSS emulation,ALSA sequencer RME32 driver,RME96 driver,EMU10K1/EMU10K2 driver,NM256 driver Add sparse annotations where we do strange this with __iomem/__user pointers. Signed-off-by: Clemens Ladisch --- sound/core/memory.c | 4 ++-- sound/core/oss/pcm_oss.c | 7 +++++-- sound/core/rawmidi.c | 8 ++++++-- sound/core/seq/seq_clientmgr.c | 7 +++++-- sound/pci/emu10k1/emufx.c | 12 ++++++------ sound/pci/nm256/nm256.c | 2 +- sound/pci/rme32.c | 6 ++++-- sound/pci/rme96.c | 6 ++++-- 8 files changed, 33 insertions(+), 19 deletions(-) diff --git a/sound/core/memory.c b/sound/core/memory.c index 291b4769bde..8fa888fc53a 100644 --- a/sound/core/memory.c +++ b/sound/core/memory.c @@ -249,7 +249,7 @@ int __exit snd_memory_info_done(void) int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count) { #if defined(__i386__) || defined(CONFIG_SPARC32) - return copy_to_user(dst, (const void*)src, count) ? -EFAULT : 0; + return copy_to_user(dst, (const void __force*)src, count) ? -EFAULT : 0; #else char buf[256]; while (count) { @@ -280,7 +280,7 @@ int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count) { #if defined(__i386__) || defined(CONFIG_SPARC32) - return copy_from_user((void*)dst, src, count) ? -EFAULT : 0; + return copy_from_user((void __force *)dst, src, count) ? -EFAULT : 0; #else char buf[256]; while (count) { diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index a13bd7bb4c9..1e606399d74 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -850,7 +850,9 @@ static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char __u return xfer > 0 ? xfer : -EAGAIN; } } else { - tmp = snd_pcm_oss_write2(substream, (const char *)buf, runtime->oss.period_bytes, 0); + tmp = snd_pcm_oss_write2(substream, + (const char __force *)buf, + runtime->oss.period_bytes, 0); if (tmp <= 0) return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; runtime->oss.bytes += tmp; @@ -926,7 +928,8 @@ static ssize_t snd_pcm_oss_read1(snd_pcm_substream_t *substream, char __user *bu xfer += tmp; runtime->oss.buffer_used -= tmp; } else { - tmp = snd_pcm_oss_read2(substream, (char *)buf, runtime->oss.period_bytes, 0); + tmp = snd_pcm_oss_read2(substream, (char __force *)buf, + runtime->oss.period_bytes, 0); if (tmp <= 0) return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; runtime->oss.bytes += tmp; diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index edba4118271..d705ec79429 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -984,7 +984,9 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun spin_lock_irq(&runtime->lock); } spin_unlock_irq(&runtime->lock); - count1 = snd_rawmidi_kernel_read1(substream, (unsigned char *)buf, count, 0); + count1 = snd_rawmidi_kernel_read1(substream, + (unsigned char __force *)buf, + count, 0); if (count1 < 0) return result > 0 ? result : count1; result += count1; @@ -1213,7 +1215,9 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, size spin_lock_irq(&runtime->lock); } spin_unlock_irq(&runtime->lock); - count1 = snd_rawmidi_kernel_write1(substream, (unsigned char *)buf, count, 0); + count1 = snd_rawmidi_kernel_write1(substream, + (unsigned char __force *)buf, + count, 0); if (count1 < 0) return result > 0 ? result : count1; result += count1; diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index d8f76afd284..bd106625a78 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -413,7 +413,9 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, l } count -= sizeof(snd_seq_event_t); buf += sizeof(snd_seq_event_t); - err = snd_seq_expand_var_event(&cell->event, count, (char *)buf, 0, sizeof(snd_seq_event_t)); + err = snd_seq_expand_var_event(&cell->event, count, + (char __force *)buf, 0, + sizeof(snd_seq_event_t)); if (err < 0) break; result += err; @@ -1009,7 +1011,8 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, size_t c } /* set user space pointer */ event.data.ext.len = extlen | SNDRV_SEQ_EXT_USRPTR; - event.data.ext.ptr = (char*)buf + sizeof(snd_seq_event_t); + event.data.ext.ptr = (char __force *)buf + + sizeof(snd_seq_event_t); len += extlen; /* increment data length */ } else { #ifdef CONFIG_COMPAT diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 637c555cfdb..2f7a03103c9 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -470,7 +470,7 @@ static void snd_emu10k1_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr { u_int32_t *code; snd_assert(*ptr < 512, return); - code = (u_int32_t *)icode->code + (*ptr) * 2; + code = (u_int32_t __force *)icode->code + (*ptr) * 2; set_bit(*ptr, icode->code_valid); code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff); code[1] = ((op & 0x0f) << 20) | ((r & 0x3ff) << 10) | (a & 0x3ff); @@ -485,7 +485,7 @@ static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned i { u_int32_t *code; snd_assert(*ptr < 1024, return); - code = (u_int32_t *)icode->code + (*ptr) * 2; + code = (u_int32_t __force *)icode->code + (*ptr) * 2; set_bit(*ptr, icode->code_valid); code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff); code[1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff); @@ -1042,7 +1042,7 @@ static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu) err = -ENOMEM; goto __err; } - gpr_map = (u32 *)icode->gpr_map; + gpr_map = (u32 __force *)icode->gpr_map; icode->tram_data_map = icode->gpr_map + 512; icode->tram_addr_map = icode->tram_data_map + 256; @@ -1431,7 +1431,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) __err: kfree(controls); if (icode != NULL) { - kfree((void *)icode->gpr_map); + kfree((void __force *)icode->gpr_map); kfree(icode); } return err; @@ -1511,7 +1511,7 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) err = -ENOMEM; goto __err; } - gpr_map = (u32 *)icode->gpr_map; + gpr_map = (u32 __force *)icode->gpr_map; icode->tram_data_map = icode->gpr_map + 256; icode->tram_addr_map = icode->tram_data_map + 160; @@ -2032,7 +2032,7 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) kfree(ipcm); kfree(controls); if (icode != NULL) { - kfree((void *)icode->gpr_map); + kfree((void __force *)icode->gpr_map); kfree(icode); } return err; diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 2bbeb10ff7c..24f146b6eba 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -840,7 +840,7 @@ static void snd_nm256_setup_stream(nm256_t *chip, nm256_stream_t *s, runtime->hw = *hw_ptr; runtime->hw.buffer_bytes_max = s->bufsize; runtime->hw.period_bytes_max = s->bufsize / 2; - runtime->dma_area = (void*) s->bufptr; + runtime->dma_area = (void __force *) s->bufptr; runtime->dma_addr = s->bufptr_addr; runtime->dma_bytes = s->bufsize; runtime->private_data = s; diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 456be39e8e4..cfb5f44b2d4 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -692,7 +692,8 @@ snd_rme32_playback_hw_params(snd_pcm_substream_t * substream, if (err < 0) return err; } else { - runtime->dma_area = (void *)(rme32->iobase + RME32_IO_DATA_BUFFER); + runtime->dma_area = (void __force *)(rme32->iobase + + RME32_IO_DATA_BUFFER); runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER; runtime->dma_bytes = RME32_BUFFER_SIZE; } @@ -746,7 +747,8 @@ snd_rme32_capture_hw_params(snd_pcm_substream_t * substream, if (err < 0) return err; } else { - runtime->dma_area = (void *)rme32->iobase + RME32_IO_DATA_BUFFER; + runtime->dma_area = (void __force *)rme32->iobase + + RME32_IO_DATA_BUFFER; runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER; runtime->dma_bytes = RME32_BUFFER_SIZE; } diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 9645e9004a4..2da33138fa4 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -985,7 +985,8 @@ snd_rme96_playback_hw_params(snd_pcm_substream_t *substream, snd_pcm_runtime_t *runtime = substream->runtime; int err, rate, dummy; - runtime->dma_area = (void *)(rme96->iobase + RME96_IO_PLAY_BUFFER); + runtime->dma_area = (void __force *)(rme96->iobase + + RME96_IO_PLAY_BUFFER); runtime->dma_addr = rme96->port + RME96_IO_PLAY_BUFFER; runtime->dma_bytes = RME96_BUFFER_SIZE; @@ -1037,7 +1038,8 @@ snd_rme96_capture_hw_params(snd_pcm_substream_t *substream, snd_pcm_runtime_t *runtime = substream->runtime; int err, isadat, rate; - runtime->dma_area = (void *)(rme96->iobase + RME96_IO_REC_BUFFER); + runtime->dma_area = (void __force *)(rme96->iobase + + RME96_IO_REC_BUFFER); runtime->dma_addr = rme96->port + RME96_IO_REC_BUFFER; runtime->dma_bytes = RME96_BUFFER_SIZE; -- cgit v1.2.3 From db67319ac29d2f35ece30bce6a9b611afd6b600f Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 5 Sep 2005 10:36:27 +0200 Subject: [ALSA] opti93x: optimize a register access Opti9xx drivers When clearing some bits in a register, don't bother with the bits that won't be changed anyway. Signed-off-by: Clemens Ladisch --- sound/isa/opti9xx/opti92x-ad1848.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 411a702d85b..782750d62eb 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -1038,8 +1038,7 @@ static int snd_opti93x_capture_prepare(snd_pcm_substream_t *substream) chip->c_dma_size = size; snd_opti93x_out_mask(chip, OPTi93X_IFACE_CONF, - OPTi93X_CAPTURE_ENABLE | OPTi93X_CAPTURE_PIO, - (unsigned char)~(OPTi93X_CAPTURE_ENABLE | OPTi93X_CAPTURE_PIO)); + OPTi93X_CAPTURE_ENABLE | OPTi93X_CAPTURE_PIO, 0); snd_dma_program(chip->dma2, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT); -- cgit v1.2.3 From 0ca21611b668eee9ac07bb85825ce30002976550 Mon Sep 17 00:00:00 2001 From: Davide Libenzi Date: Mon, 5 Sep 2005 11:56:47 +0200 Subject: [ALSA] hda-codec - Bring the Vaio's RA826G HDA (82801) to life ... HDA Codec driver Add the subsystem PCI devid to the list (on top of 2.6.13). Signed-off-by: Davide Libenzi Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index eeb900ab79a..1218f1d1bf9 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1526,6 +1526,7 @@ static struct hda_board_config alc880_cfg_tbl[] = { /* Back 3 jack, front 2 jack (Internal add Aux-In) */ { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, + { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST }, /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, -- cgit v1.2.3 From a76af199dc025e8f5cf6b9542efadc3de5163a7a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Sep 2005 16:56:40 +0200 Subject: [ALSA] Add snd_card_set_dev() ARM AACI PL041 driver,PARISC Harmony driver Added snd_card_set_dev() calls to register the device pointer for the card. Signed-off-by: Takashi Iwai --- sound/arm/aaci.c | 2 ++ sound/parisc/harmony.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 98877030d57..34195b74860 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -900,6 +900,8 @@ static int __devinit aaci_probe(struct amba_device *dev, void *id) if (ret) goto out; + snd_card_set_dev(aaci->card, &dev->dev); + ret = snd_card_register(aaci->card); if (ret == 0) { dev_info(&dev->dev, "%s, fifo %d\n", aaci->card->longname, diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index d7a8f9f5896..f560dd8cdb9 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -880,6 +880,8 @@ snd_harmony_create(snd_card_t *card, goto free_and_ret; } + snd_card_set_dev(card, &padev->dev); + *rchip = h; return 0; -- cgit v1.2.3 From 0be3b5d3fb94c36c517655d18a936681d7108667 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Sep 2005 17:11:40 +0200 Subject: [ALSA] hda-intel - Check validity of DMA position HDA Intel driver Check the validity of the current DMA position when position_fix=0 (auto) is set. If the DMA position overcomes the threshold, the driver changes the fix behavior automatically to use POSBUF. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 63 ++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 15107df1f49..96f9e872919 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -62,7 +62,7 @@ MODULE_PARM_DESC(enable, "Enable Intel HD audio interface."); module_param_array(model, charp, NULL, 0444); MODULE_PARM_DESC(model, "Use the given board model."); module_param_array(position_fix, int, NULL, 0444); -MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = FIFO size, 1 = none, 2 = POSBUF)."); +MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size)."); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," @@ -211,9 +211,10 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; /* position fix mode */ enum { - POS_FIX_FIFO, + POS_FIX_AUTO, POS_FIX_NONE, - POS_FIX_POSBUF + POS_FIX_POSBUF, + POS_FIX_FIFO, }; /* Defines for ATI HD Audio support in SB450 south bridge */ @@ -243,6 +244,7 @@ struct snd_azx_dev { unsigned int fragsize; /* size of each period in bytes */ unsigned int frags; /* number for period in the play buffer */ unsigned int fifo_size; /* FIFO size */ + unsigned int last_pos; /* last updated period position */ void __iomem *sd_addr; /* stream descriptor pointer */ @@ -256,6 +258,7 @@ struct snd_azx_dev { unsigned int opened: 1; unsigned int running: 1; + unsigned int period_updating: 1; }; /* CORB/RIRB */ @@ -724,11 +727,9 @@ static void azx_init_chip(azx_t *chip) /* initialize the codec command I/O */ azx_init_cmd_io(chip); - if (chip->position_fix == POS_FIX_POSBUF) { - /* program the position buffer */ - azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); - azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr)); - } + /* program the position buffer */ + azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); + azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr)); /* For ATI SB450 azalia HD audio, we need to enable snoop */ if (chip->driver_type == AZX_DRIVER_ATI) { @@ -763,9 +764,11 @@ static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs) if (status & azx_dev->sd_int_sta_mask) { azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); if (azx_dev->substream && azx_dev->running) { + azx_dev->period_updating = 1; spin_unlock(&chip->reg_lock); snd_pcm_period_elapsed(azx_dev->substream); spin_lock(&chip->reg_lock); + azx_dev->period_updating = 0; } } } @@ -866,11 +869,9 @@ static int azx_setup_controller(azx_t *chip, azx_dev_t *azx_dev) /* upper BDL address */ azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr)); - if (chip->position_fix == POS_FIX_POSBUF) { - /* enable the position buffer */ - if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) - azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); - } + /* enable the position buffer */ + if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) + azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); /* set the interrupt enable bits in the descriptor control register */ azx_sd_writel(azx_dev, SD_CTL, azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK); @@ -1078,6 +1079,7 @@ static int azx_pcm_prepare(snd_pcm_substream_t *substream) azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1; else azx_dev->fifo_size = 0; + azx_dev->last_pos = 0; return hinfo->ops.prepare(hinfo, apcm->codec, azx_dev->stream_tag, azx_dev->format_val, substream); @@ -1133,6 +1135,26 @@ static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream) pos = azx_sd_readl(azx_dev, SD_LPIB); if (chip->position_fix == POS_FIX_FIFO) pos += azx_dev->fifo_size; + else if (chip->position_fix == POS_FIX_AUTO && azx_dev->period_updating) { + /* check the validity of DMA position */ + unsigned int diff = 0; + azx_dev->last_pos += azx_dev->fragsize; + if (azx_dev->last_pos > pos) + diff = azx_dev->last_pos - pos; + if (azx_dev->last_pos >= azx_dev->bufsize) { + if (pos < azx_dev->fragsize) + diff = 0; + azx_dev->last_pos = 0; + } + if (diff > 0 && diff <= azx_dev->fifo_size) + pos += azx_dev->fifo_size; + else { + snd_printdd(KERN_INFO "hda_intel: DMA position fix %d, switching to posbuf\n", diff); + chip->position_fix = POS_FIX_POSBUF; + pos = *azx_dev->posbuf; + } + azx_dev->period_updating = 0; + } } if (pos >= azx_dev->bufsize) pos = 0; @@ -1244,8 +1266,7 @@ static int __devinit azx_init_stream(azx_t *chip) azx_dev_t *azx_dev = &chip->azx_dev[i]; azx_dev->bdl = (u32 *)(chip->bdl.area + off); azx_dev->bdl_addr = chip->bdl.addr + off; - if (chip->position_fix == POS_FIX_POSBUF) - azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8); + azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8); /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */ @@ -1437,13 +1458,11 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); goto errout; } - if (chip->position_fix == POS_FIX_POSBUF) { - /* allocate memory for the position buffer */ - if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), - chip->num_streams * 8, &chip->posbuf)) < 0) { - snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); - goto errout; - } + /* allocate memory for the position buffer */ + if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), + chip->num_streams * 8, &chip->posbuf)) < 0) { + snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); + goto errout; } /* allocate CORB/RIRB */ if ((err = azx_alloc_cmd_io(chip)) < 0) -- cgit v1.2.3 From 6243008b82222d6244b055beeeba94b14f23b7e2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Sep 2005 17:12:29 +0200 Subject: [ALSA] Update/fix ALSA document Documentation Update/fix ALSA document. Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/ALSA-Configuration.txt | 106 ++++++++++++++++-------- 1 file changed, 70 insertions(+), 36 deletions(-) diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index f626f4a9a61..a7fc75f53bb 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -75,7 +75,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. adsp_map - PCM device number maps assigned to the 2st OSS device. - Default: 1 nonblock_open - - Don't block opening busy PCM devices. + - Don't block opening busy PCM devices. Default: 1 For example, when dsp_map=2, /dev/dsp will be mapped to PCM #2 of the card #0. Similarly, when adsp_map=0, /dev/adsp will be mapped @@ -199,15 +199,20 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module snd-atiixp ----------------- - Module for ATI IXP 150/200/250 AC97 controllers. + Module for ATI IXP 150/200/250/400 AC97 controllers. - ac97_clock - AC'97 clock (defalut = 48000) + ac97_clock - AC'97 clock (default = 48000) ac97_quirk - AC'97 workaround for strange hardware - See the description of intel8x0 module for details. + See "AC97 Quirk Option" section below. spdif_aclink - S/PDIF transfer over AC-link (default = 1) This module supports up to 8 cards and autoprobe. + ATI IXP has two different methods to control SPDIF output. One is + over AC-link and another is over the "direct" SPDIF output. The + implementation depends on the motherboard, and you'll need to + choose the correct one via spdif_aclink module option. + Module snd-atiixp-modem ----------------------- @@ -240,7 +245,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. The hardware EQ hardware and SPDIF is only present in the Vortex2 and Advantage. - Note: Some ALSA mixer applicactions don't handle the SPDIF samplerate + Note: Some ALSA mixer applications don't handle the SPDIF sample rate control correctly. If you have problems regarding this, try another ALSA compliant mixer (alsamixer works). @@ -312,7 +317,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. mpu_port - 0x300,0x310,0x320,0x330, 0 = disable (default) fm_port - 0x388 (default), 0 = disable (default) - soft_ac3 - Sofware-conversion of raw SPDIF packets (model 033 only) + soft_ac3 - Software-conversion of raw SPDIF packets (model 033 only) (default = 1) joystick_port - Joystick port address (0 = disable, 1 = auto-detect) @@ -394,7 +399,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module for PCI sound cards based on CS4610/CS4612/CS4614/CS4615/CS4622/ CS4624/CS4630/CS4280 PCI chips. - external_amp - Force to enable external amplifer. + external_amp - Force to enable external amplifier. thinkpad - Force to enable Thinkpad's CLKRUN control. mmap_valid - Support OSS mmap mode (default = 0). @@ -630,7 +635,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. VIA VT8251/VT8237A model - force the model name - position_fix - Fix DMA pointer (0 = FIFO size, 1 = none, 2 = POSBUF) + position_fix - Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size) Module supports up to 8 cards. @@ -666,6 +671,11 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. allout 5-jack in back, 2-jack in front, SPDIF out auto auto-config reading BIOS (default) + If the default configuration doesn't work and one of the above + matches with your device, report it together with the PCI + subsystem ID (output of "lspci -nv") to ALSA BTS or alsa-devel + ML (see the section "Links and Addresses"). + Note 2: If you get click noises on output, try the module option position_fix=1 or 2. position_fix=1 will use the SD_LPIB register value without FIFO size correction as the current @@ -793,18 +803,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. ac97_clock - AC'97 codec clock base (0 = auto-detect) ac97_quirk - AC'97 workaround for strange hardware - The following strings are accepted: - default = don't override the default setting - disable = disable the quirk - hp_only = use headphone control as master - swap_hp = swap headphone and master controls - swap_surround = swap master and surround controls - ad_sharing = for AD1985, turn on OMS bit and use headphone - alc_jack = for ALC65x, turn on the jack sense mode - inv_eapd = inverted EAPD implementation - mute_led = bind EAPD bit for turning on/off mute LED - For backward compatibility, the corresponding integer - value -1, 0, ... are accepted, too. + See "AC97 Quirk Option" section below. buggy_irq - Enable workaround for buggy interrupts on some motherboards (default off) @@ -818,13 +817,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. motherboard has these devices, use the ns558 or snd-mpu401 modules, respectively. - The ac97_quirk option is used to enable/override the workaround - for specific devices. Some hardware have swapped output pins - between Master and Headphone, or Surround. The driver provides - the auto-detection of known problematic devices, but some might - be unknown or wrongly detected. In such a case, pass the proper - value with this option. - The power-management is supported. Module snd-intel8x0m @@ -976,7 +968,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. with machines with other (most likely CS423x or OPL3SAx) chips, even though the device is detected in lspci. In such a case, try other drivers, e.g. snd-cs4232 or snd-opl3sa2. Some has ISA-PnP - but some doesn't have ISA PnP. You'll need to speicfy isapnp=0 + but some doesn't have ISA PnP. You'll need to specify isapnp=0 and proper hardware parameters in the case without ISA PnP. Note: some laptops need a workaround for AC97 RESET. For the @@ -1312,7 +1304,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. channels [VIA8233/C, 8235, 8237 only] ac97_quirk - AC'97 workaround for strange hardware - See the description of intel8x0 module for details. + See "AC97 Quirk Option" section below. Module supports autoprobe and multiple bus-master chips (max 8). @@ -1337,16 +1329,17 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. "lspci -nv"). If dxs_support=5 does not work, try dxs_support=4; if it doesn't work too, try dxs_support=1. (dxs_support=1 is - usually for old motherboards. The correct implementated + usually for old motherboards. The correct implemented board should work with 4 or 5.) If it still doesn't work and the default setting is ok, dxs_support=3 is the right choice. If the default setting doesn't work at all, try dxs_support=2 to disable the DXS channels. In any cases, please let us know the result and the - subsystem vendor/device ids. + subsystem vendor/device ids. See "Links and Addresses" + below. Note: for the MPU401 on VIA823x, use snd-mpu401 driver - additonally. The mpu_port option is for VIA686 chips only. + additionally. The mpu_port option is for VIA686 chips only. Module snd-via82xx-modem ------------------------ @@ -1408,8 +1401,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards. The module is compiled only when PCMCIA is supported on kernel. - To activate the driver via the card manager, you'll need to set - up /etc/pcmcia/vxpocket.conf. See the sound/pcmcia/vx/vxpocket.c. + With the older 2.6.x kernel, to activate the driver via the card + manager, you'll need to set up /etc/pcmcia/vxpocket.conf. See the + sound/pcmcia/vx/vxpocket.c. 2.6.13 or later kernel requires no + longer require a config file. When the driver is compiled as a module and the hotplug firmware is supported, the firmware data is loaded via hotplug automatically. @@ -1421,6 +1416,9 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Note: the driver is build only when CONFIG_ISA is set. + Note2: snd-vxp440 driver is merged to snd-vxpocket driver since + ALSA 1.0.10. + Module snd-ymfpci ----------------- @@ -1446,6 +1444,37 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Note: the driver is build only when CONFIG_ISA is set. +AC97 Quirk Option +================= + +The ac97_quirk option is used to enable/override the workaround for +specific devices on drivers for on-board AC'97 controllers like +snd-intel8x0. Some hardware have swapped output pins between Master +and Headphone, or Surround (thanks to confusion of AC'97 +specifications from version to version :-) + +The driver provides the auto-detection of known problematic devices, +but some might be unknown or wrongly detected. In such a case, pass +the proper value with this option. + +The following strings are accepted: + - default Don't override the default setting + - disable Disable the quirk + - hp_only Bind Master and Headphone controls as a single control + - swap_hp Swap headphone and master controls + - swap_surround Swap master and surround controls + - ad_sharing For AD1985, turn on OMS bit and use headphone + - alc_jack For ALC65x, turn on the jack sense mode + - inv_eapd Inverted EAPD implementation + - mute_led Bind EAPD bit for turning on/off mute LED + +For backward compatibility, the corresponding integer value -1, 0, +... are accepted, too. + +For example, if "Master" volume control has no effect on your device +but only "Headphone" does, pass ac97_quirk=hp_only module option. + + Configuring Non-ISAPNP Cards ============================ @@ -1599,9 +1628,14 @@ commands to the snd-page-alloc driver: use. -Links -===== +Links and Addresses +=================== ALSA project homepage http://www.alsa-project.org + ALSA Bug Tracking System + https://bugtrack.alsa-project.org/bugs/ + + ALSA Developers ML + mailto:alsa-devel@lists.sourceforge.net -- cgit v1.2.3 From ecbcfe36fa882e9f8f2be63ac0c42978336bf997 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Sep 2005 17:15:37 +0200 Subject: [ALSA] Introduce snd_card_set_generic_dev() ALSA Core A new function snd_card_set_generic_dev() is introduced to add the 'generic device' support for devices without proper bus on sysfs. It's a last resort, and should be removed in future when they have a proper bus, instead. Signed-off-by: Takashi Iwai --- include/sound/core.h | 8 ++- sound/core/Kconfig | 2 +- sound/core/init.c | 185 ++++++++++++++++++++++++++++----------------------- sound/core/sound.c | 15 ++++- 4 files changed, 121 insertions(+), 89 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index 3dc41fd5c54..26160adcdff 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -168,6 +168,9 @@ struct _snd_card { wait_queue_head_t shutdown_sleep; struct work_struct free_workq; /* for free in workqueue */ struct device *dev; +#ifdef CONFIG_SND_GENERIC_DRIVER + struct snd_generic_device *generic_dev; +#endif #ifdef CONFIG_PM int (*pm_suspend)(snd_card_t *card, pm_message_t state); @@ -176,9 +179,6 @@ struct _snd_card { unsigned int power_state; /* power state */ struct semaphore power_lock; /* power lock */ wait_queue_head_t power_sleep; -#ifdef CONFIG_SND_GENERIC_PM - struct snd_generic_device *pm_dev; /* for ISA */ -#endif #endif #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) @@ -348,6 +348,8 @@ int snd_card_file_remove(snd_card_t *card, struct file *file); #ifndef snd_card_set_dev #define snd_card_set_dev(card,devptr) ((card)->dev = (devptr)) #endif +/* register a generic device (for ISA, etc) */ +int snd_card_set_generic_dev(snd_card_t *card); /* device.c */ diff --git a/sound/core/Kconfig b/sound/core/Kconfig index d1e800b9866..6ae1d2e24b4 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig @@ -128,6 +128,6 @@ config SND_DEBUG_DETECT Say Y here to enable extra-verbose log messages printed when detecting devices. -config SND_GENERIC_PM +config SND_GENERIC_DRIVER bool depends on SND diff --git a/sound/core/init.c b/sound/core/init.c index d72f58f450c..c9c9929121d 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -226,8 +226,10 @@ int snd_card_disconnect(snd_card_t * card) return 0; } -#if defined(CONFIG_PM) && defined(CONFIG_SND_GENERIC_PM) -static void snd_generic_device_unregister(struct snd_generic_device *dev); +#ifdef CONFIG_SND_GENERIC_DRIVER +static void snd_generic_device_unregister(snd_card_t *card); +#else +#define snd_generic_device_unregister(x) /*NOP*/ #endif /** @@ -253,14 +255,7 @@ int snd_card_free(snd_card_t * card) #ifdef CONFIG_PM wake_up(&card->power_sleep); -#ifdef CONFIG_SND_GENERIC_PM - if (card->pm_dev) { - snd_generic_device_unregister(card->pm_dev); - card->pm_dev = NULL; - } -#endif #endif - /* wait, until all devices are ready for the free operation */ wait_event(card->shutdown_sleep, card->files == NULL); @@ -288,6 +283,7 @@ int snd_card_free(snd_card_t * card) snd_printk(KERN_WARNING "unable to free card info\n"); /* Not fatal error */ } + snd_generic_device_unregister(card); while (card->s_f_ops) { s_f_ops = card->s_f_ops; card->s_f_ops = s_f_ops->next; @@ -665,6 +661,96 @@ int snd_card_file_remove(snd_card_t *card, struct file *file) return 0; } +#ifdef CONFIG_SND_GENERIC_DRIVER +/* + * generic device without a proper bus using platform_device + * (e.g. ISA) + */ +struct snd_generic_device { + struct platform_device pdev; + snd_card_t *card; +}; + +#define get_snd_generic_card(dev) container_of(to_platform_device(dev), struct snd_generic_device, pdev)->card + +#define SND_GENERIC_NAME "snd_generic" + +#ifdef CONFIG_PM +static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level); +static int snd_generic_resume(struct device *dev, u32 level); +#endif + +/* initialized in sound.c */ +struct device_driver snd_generic_driver = { + .name = SND_GENERIC_NAME, + .bus = &platform_bus_type, +#ifdef CONFIG_PM + .suspend = snd_generic_suspend, + .resume = snd_generic_resume, +#endif +}; + +void snd_generic_device_release(struct device *dev) +{ +} + +static int snd_generic_device_register(snd_card_t *card) +{ + struct snd_generic_device *dev; + int err; + + if (card->generic_dev) + return 0; /* already registered */ + + dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); + if (! dev) { + snd_printk(KERN_ERR "can't allocate generic_device\n"); + return -ENOMEM; + } + + dev->pdev.name = SND_GENERIC_NAME; + dev->pdev.id = card->number; + dev->pdev.dev.release = snd_generic_device_release; + dev->card = card; + if ((err = platform_device_register(&dev->pdev)) < 0) { + kfree(dev); + return err; + } + card->generic_dev = dev; + return 0; +} + +static void snd_generic_device_unregister(snd_card_t *card) +{ + struct snd_generic_device *dev = card->generic_dev; + if (dev) { + platform_device_unregister(&dev->pdev); + kfree(dev); + card->generic_dev = NULL; + } +} + +/** + * snd_card_set_generic_dev - assign the generic device to the card + * @card: soundcard structure + * + * Assigns a generic device to the card. This function is provided as the + * last resort, for devices without any proper bus. Thus this won't override + * the device already assigned to the card. + * + * Returns zero if successful, or a negative error code. + */ +int snd_card_set_generic_dev(snd_card_t *card) +{ + int err; + if ((err = snd_generic_device_register(card)) < 0) + return err; + if (! card->dev) + snd_card_set_dev(card, &card->generic_dev->pdev.dev); + return 0; +} +#endif /* CONFIG_SND_GENERIC_DRIVER */ + #ifdef CONFIG_PM /** * snd_power_wait - wait until the power-state is changed. @@ -730,75 +816,7 @@ int snd_card_set_pm_callback(snd_card_t *card, return 0; } -#ifdef CONFIG_SND_GENERIC_PM -/* - * use platform_device for generic power-management without a proper bus - * (e.g. ISA) - */ -struct snd_generic_device { - struct platform_device pdev; - snd_card_t *card; -}; - -#define get_snd_generic_card(dev) container_of(to_platform_device(dev), struct snd_generic_device, pdev)->card - -#define SND_GENERIC_NAME "snd_generic_pm" - -static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level); -static int snd_generic_resume(struct device *dev, u32 level); - -static struct device_driver snd_generic_driver = { - .name = SND_GENERIC_NAME, - .bus = &platform_bus_type, - .suspend = snd_generic_suspend, - .resume = snd_generic_resume, -}; - -static int generic_driver_registered; - -static void generic_driver_unregister(void) -{ - if (generic_driver_registered) { - generic_driver_registered--; - if (! generic_driver_registered) - driver_unregister(&snd_generic_driver); - } -} - -static struct snd_generic_device *snd_generic_device_register(snd_card_t *card) -{ - struct snd_generic_device *dev; - - if (! generic_driver_registered) { - if (driver_register(&snd_generic_driver) < 0) - return NULL; - } - generic_driver_registered++; - - dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); - if (! dev) { - generic_driver_unregister(); - return NULL; - } - - dev->pdev.name = SND_GENERIC_NAME; - dev->pdev.id = card->number; - dev->card = card; - if (platform_device_register(&dev->pdev) < 0) { - kfree(dev); - generic_driver_unregister(); - return NULL; - } - return dev; -} - -static void snd_generic_device_unregister(struct snd_generic_device *dev) -{ - platform_device_unregister(&dev->pdev); - kfree(dev); - generic_driver_unregister(); -} - +#ifdef CONFIG_SND_GENERIC_DRIVER /* suspend/resume callbacks for snd_generic platform device */ static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level) { @@ -846,13 +864,12 @@ int snd_card_set_generic_pm_callback(snd_card_t *card, int (*resume)(snd_card_t *), void *private_data) { - card->pm_dev = snd_generic_device_register(card); - if (! card->pm_dev) - return -ENOMEM; - snd_card_set_pm_callback(card, suspend, resume, private_data); - return 0; + int err; + if ((err = snd_generic_device_register(card)) < 0) + return err; + return snd_card_set_pm_callback(card, suspend, resume, private_data); } -#endif /* CONFIG_SND_GENERIC_PM */ +#endif /* CONFIG_SND_GENERIC_DRIVER */ #ifdef CONFIG_PCI int snd_card_pci_suspend(struct pci_dev *dev, pm_message_t state) diff --git a/sound/core/sound.c b/sound/core/sound.c index 3271e924549..9e76bddb2c0 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -328,6 +328,10 @@ int __exit snd_minor_info_done(void) * INIT PART */ +#ifdef CONFIG_SND_GENERIC_DRIVER +extern struct device_driver snd_generic_driver; +#endif + static int __init alsa_sound_init(void) { short controlnum; @@ -354,6 +358,9 @@ static int __init alsa_sound_init(void) return -ENOMEM; } snd_info_minor_register(); +#ifdef CONFIG_SND_GENERIC_DRIVER + driver_register(&snd_generic_driver); +#endif for (controlnum = 0; controlnum < cards_limit; controlnum++) devfs_mk_cdev(MKDEV(major, controlnum<<5), S_IFCHR | device_mode, "snd/controlC%d", controlnum); #ifndef MODULE @@ -369,6 +376,9 @@ static void __exit alsa_sound_exit(void) for (controlnum = 0; controlnum < cards_limit; controlnum++) devfs_remove("snd/controlC%d", controlnum); +#ifdef CONFIG_SND_GENERIC_DRIVER + driver_unregister(&snd_generic_driver); +#endif snd_info_minor_unregister(); snd_info_done(); snd_memory_done(); @@ -416,10 +426,13 @@ EXPORT_SYMBOL(snd_card_register); EXPORT_SYMBOL(snd_component_add); EXPORT_SYMBOL(snd_card_file_add); EXPORT_SYMBOL(snd_card_file_remove); +#ifdef CONFIG_SND_GENERIC_DRIVER +EXPORT_SYMBOL(snd_card_set_generic_dev); +#endif #ifdef CONFIG_PM EXPORT_SYMBOL(snd_power_wait); EXPORT_SYMBOL(snd_card_set_pm_callback); -#if defined(CONFIG_PM) && defined(CONFIG_SND_GENERIC_PM) +#ifdef CONFIG_SND_GENERIC_DRIVER EXPORT_SYMBOL(snd_card_set_generic_pm_callback); #endif #ifdef CONFIG_PCI -- cgit v1.2.3 From 16dab54b8cbac39bd3f639db5d7d0fd8300a6cb0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Sep 2005 17:17:58 +0200 Subject: [ALSA] Add snd_card_set_generic_dev() call ARM,SA11xx UDA1341 driver,Generic drivers,MPU401 UART,MIPS MIPS AU1x00 driver,PPC,PPC PowerMac driver,SPARC,SPARC AMD7930 driver SPARC cs4231 driver,SPARC DBRI driver - Added snd_card_set_generic_dev() call. - Added SND_GENERIC_DRIVER to Kconfig. - Clean up the error path in probe if necessary. Signed-off-by: Takashi Iwai --- sound/arm/Kconfig | 1 + sound/arm/sa11xx-uda1341.c | 5 ++++- sound/drivers/Kconfig | 5 +++++ sound/drivers/dummy.c | 4 ++++ sound/drivers/mpu401/mpu401.c | 26 ++++++++++++++++---------- sound/drivers/mtpav.c | 3 +++ sound/drivers/serial-u16550.c | 26 ++++++++++++++------------ sound/drivers/virmidi.c | 4 ++++ sound/mips/Kconfig | 1 + sound/mips/au1x00.c | 5 +++++ sound/ppc/Kconfig | 1 + sound/ppc/powermac.c | 3 +++ sound/sparc/Kconfig | 3 +++ sound/sparc/amd7930.c | 3 +++ sound/sparc/cs4231.c | 3 +++ sound/sparc/dbri.c | 29 ++++++++++++++--------------- 16 files changed, 84 insertions(+), 38 deletions(-) diff --git a/sound/arm/Kconfig b/sound/arm/Kconfig index 2e4a5e0d16d..0864a7ce414 100644 --- a/sound/arm/Kconfig +++ b/sound/arm/Kconfig @@ -7,6 +7,7 @@ config SND_SA11XX_UDA1341 tristate "SA11xx UDA1341TS driver (iPaq H3600)" depends on ARCH_SA1100 && SND && L3 select SND_PCM + select SND_GENERIC_DRIVER help Say Y here if you have a Compaq iPaq H3x00 handheld computer and want to use its Philips UDA 1341 audio chip. diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index 174bc032d1a..813959f185e 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c @@ -21,7 +21,7 @@ * merged HAL layer (patches from Brian) */ -/* $Id: sa11xx-uda1341.c,v 1.21 2005/01/28 19:34:04 tiwai Exp $ */ +/* $Id: sa11xx-uda1341.c,v 1.22 2005/09/05 16:17:58 tiwai Exp $ */ /*************************************************************************************************** * @@ -946,6 +946,9 @@ static int __init sa11xx_uda1341_init(void) strcpy(card->shortname, "H3600 UDA1341TS"); sprintf(card->longname, "Compaq iPAQ H3600 with Philips UDA1341TS"); + if ((err = snd_card_set_generic_dev(card)) < 0) + goto nodev; + if ((err = snd_card_register(card)) == 0) { printk( KERN_INFO "iPAQ audio support initialized\n" ); return 0; diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig index 3b2bee19e2c..efcb4eb2d1a 100644 --- a/sound/drivers/Kconfig +++ b/sound/drivers/Kconfig @@ -29,6 +29,7 @@ config SND_DUMMY tristate "Dummy (/dev/null) soundcard" depends on SND select SND_PCM + select SND_GENERIC_DRIVER help Say Y here to include the dummy driver. This driver does nothing, but emulates various mixer controls and PCM devices. @@ -44,6 +45,7 @@ config SND_VIRMIDI depends on SND_SEQUENCER select SND_TIMER select SND_RAWMIDI + select SND_GENERIC_DRIVER help Say Y here to include the virtual MIDI driver. This driver allows to connect applications using raw MIDI devices to @@ -59,6 +61,7 @@ config SND_MTPAV depends on SND select SND_TIMER select SND_RAWMIDI + select SND_GENERIC_DRIVER help To use a MOTU MidiTimePiece AV multiport MIDI adapter connected to the parallel port, say Y here and make sure that @@ -72,6 +75,7 @@ config SND_SERIAL_U16550 depends on SND select SND_TIMER select SND_RAWMIDI + select SND_GENERIC_DRIVER help To include support for MIDI serial port interfaces, say Y here and read . @@ -88,6 +92,7 @@ config SND_MPU401 tristate "Generic MPU-401 UART driver" depends on SND select SND_MPU401_UART + select SND_GENERIC_DRIVER help Say Y here to include support for MIDI ports compatible with the Roland MPU-401 interface in UART mode. diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index a61640cf7ae..977d98d26a8 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -600,6 +600,10 @@ static int __init snd_card_dummy_probe(int dev) strcpy(card->driver, "Dummy"); strcpy(card->shortname, "Dummy"); sprintf(card->longname, "Dummy %i", dev + 1); + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto __nodev; + if ((err = snd_card_register(card)) == 0) { snd_dummy_cards[dev] = card; return 0; diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c index cb36ecb7869..54e2ff9b5ca 100644 --- a/sound/drivers/mpu401/mpu401.c +++ b/sound/drivers/mpu401/mpu401.c @@ -77,20 +77,26 @@ static int snd_mpu401_create(int dev, snd_card_t **rcard) strcat(card->longname, "polled"); } - if (snd_mpu401_uart_new(card, 0, - MPU401_HW_MPU401, - port[dev], 0, - irq[dev], irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL) < 0) { + if ((err = snd_mpu401_uart_new(card, 0, + MPU401_HW_MPU401, + port[dev], 0, + irq[dev], irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL)) < 0) { printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); - snd_card_free(card); - return -ENODEV; - } - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; + goto _err; } + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; + *rcard = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __devinit snd_mpu401_probe(int dev) diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index 1280a57c49e..b8199d20be8 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -757,6 +757,9 @@ static int __init alsa_card_mtpav_init(void) if (err < 0) goto __error; + if ((err = snd_card_set_generic_dev(mtp_card->card)) < 0) + goto __error; + err = snd_card_register(mtp_card->card); // don't snd_card_register until AFTER all cards reources done! //printk("snd_card_register returned %d\n", err); diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 986df35fb82..fd3bb9dd1d2 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -928,15 +928,11 @@ static int __init snd_serial_probe(int dev) base[dev], adaptor[dev], droponfull[dev], - &uart)) < 0) { - snd_card_free(card); - return err; - } + &uart)) < 0) + goto _err; - if ((err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi)) < 0) + goto _err; sprintf(card->longname, "%s at 0x%lx, irq %d speed %d div %d outs %d ins %d adaptor %s droponfull %d", card->shortname, @@ -949,12 +945,18 @@ static int __init snd_serial_probe(int dev) adaptor_names[uart->adaptor], uart->drop_on_full); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; + snd_serial_cards[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __init alsa_card_serial_init(void) diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c index 5937711e950..af12185ab8a 100644 --- a/sound/drivers/virmidi.c +++ b/sound/drivers/virmidi.c @@ -116,6 +116,10 @@ static int __init snd_card_virmidi_probe(int dev) strcpy(card->driver, "VirMIDI"); strcpy(card->shortname, "VirMIDI"); sprintf(card->longname, "Virtual MIDI Card %i", dev + 1); + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto __nodev; + if ((err = snd_card_register(card)) == 0) { snd_virmidi_cards[dev] = card; return 0; diff --git a/sound/mips/Kconfig b/sound/mips/Kconfig index 531f8ba96a7..2433b772740 100644 --- a/sound/mips/Kconfig +++ b/sound/mips/Kconfig @@ -8,6 +8,7 @@ config SND_AU1X00 depends on (SOC_AU1000 || SOC_AU1100 || SOC_AU1500) && SND select SND_PCM select SND_AC97_CODEC + select SND_GENERIC_DRIVER help ALSA Sound driver for the Au1x00's AC97 port. diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c index c20522b0213..3f9684f1d1d 100644 --- a/sound/mips/au1x00.c +++ b/sound/mips/au1x00.c @@ -667,6 +667,11 @@ au1000_init(void) strcpy(au1000->card->shortname, "Au1000-AC97"); sprintf(au1000->card->longname, "AMD Au1000--AC97 ALSA Driver"); + if ((err = snd_card_set_generic_dev(au1000->card)) < 0) { + snd_card_free(au1000->card); + return err; + } + if ((err = snd_card_register(au1000->card)) < 0) { snd_card_free(au1000->card); return err; diff --git a/sound/ppc/Kconfig b/sound/ppc/Kconfig index 75213bf4d56..bda5bc4e614 100644 --- a/sound/ppc/Kconfig +++ b/sound/ppc/Kconfig @@ -13,6 +13,7 @@ config SND_POWERMAC tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)" depends on SND && I2C && INPUT && PPC_PMAC select SND_PCM + select SND_GENERIC_DRIVER help Say Y here to include support for the integrated sound device. diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c index 231f6432ea6..a6d8cbf4064 100644 --- a/sound/ppc/powermac.c +++ b/sound/ppc/powermac.c @@ -131,6 +131,9 @@ static int __init snd_pmac_probe(void) if (enable_beep) snd_pmac_attach_beep(chip); + if ((err = snd_card_set_generic_dev(card)) < 0) + goto __error; + if ((err = snd_card_register(card)) < 0) goto __error; diff --git a/sound/sparc/Kconfig b/sound/sparc/Kconfig index 25a8a558ef9..09ab138646a 100644 --- a/sound/sparc/Kconfig +++ b/sound/sparc/Kconfig @@ -7,6 +7,7 @@ config SND_SUN_AMD7930 tristate "Sun AMD7930" depends on SBUS && SND select SND_PCM + select SND_GENERIC_DRIVER help Say Y here to include support for AMD7930 sound device on Sun. @@ -17,6 +18,7 @@ config SND_SUN_CS4231 tristate "Sun CS4231" depends on SND select SND_PCM + select SND_GENERIC_DRIVER help Say Y here to include support for CS4231 sound device on Sun. @@ -27,6 +29,7 @@ config SND_SUN_DBRI tristate "Sun DBRI" depends on SND && SBUS select SND_PCM + select SND_GENERIC_DRIVER help Say Y here to include support for DBRI sound device on Sun. diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index bd8a850e93e..ed0d5f2f088 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -1088,6 +1088,9 @@ static int __init amd7930_attach(int prom_node, struct sbus_dev *sdev) if ((err = snd_amd7930_mixer(amd)) < 0) goto out_err; + if ((err = snd_card_set_generic_dev(card)) < 0) + goto out_err; + if ((err = snd_card_register(card)) < 0) goto out_err; diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 36f9fe4d7be..bd169f54118 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1915,6 +1915,9 @@ static int cs4231_attach_finish(snd_card_t *card, cs4231_t *chip) if ((err = snd_cs4231_timer(chip)) < 0) goto out_err; + if ((err = snd_card_set_generic_dev(card)) < 0) + goto out_err; + if ((err = snd_card_register(card)) < 0) goto out_err; diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 941c7b1e7eb..a56f81bb004 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2657,26 +2657,20 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) } dbri = (snd_dbri_t *) card->private_data; - if ((err = snd_dbri_pcm(dbri)) < 0) { - snd_dbri_free(dbri); - snd_card_free(card); - return err; - } + if ((err = snd_dbri_pcm(dbri)) < 0) + goto _err; - if ((err = snd_dbri_mixer(dbri)) < 0) { - snd_dbri_free(dbri); - snd_card_free(card); - return err; - } + if ((err = snd_dbri_mixer(dbri)) < 0) + goto _err; /* /proc file handling */ snd_dbri_proc(dbri); - if ((err = snd_card_register(card)) < 0) { - snd_dbri_free(dbri); - snd_card_free(card); - return err; - } + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n", dev, dbri->regs, @@ -2684,6 +2678,11 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) dev++; return 0; + + _err: + snd_dbri_free(dbri); + snd_card_free(card); + return err; } /* Probe for the dbri chip and then attach the driver. */ -- cgit v1.2.3 From 43bcd973d6d05d16b876e09dcc49a09d3e48e88d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Sep 2005 17:19:20 +0200 Subject: [ALSA] Add snd_card_set_generic_dev() call to ISA drivers ISA,CMI8330 driver,ES18xx driver,OPL3SA2 driver,Sound Galaxy driver Sound Scape driver,AD1848 driver,CS4231 driver,CS4236+ driver ES1688 driver,GUS Classic driver,GUS Extreme driver,GUS MAX driver AMD InterWave driver,Opti9xx drivers,SB16/AWE driver,SB8 driver Wavefront drivers - Added snd_card_set_generic_dev() call. - Added SND_GENERIC_DRIVER to Kconfig. - Clean up the error path in probe if necessary. Signed-off-by: Takashi Iwai --- sound/isa/Kconfig | 18 ++-- sound/isa/ad1848/ad1848.c | 37 ++++---- sound/isa/cmi8330.c | 77 +++++++++-------- sound/isa/cs423x/cs4231.c | 46 +++++----- sound/isa/cs423x/cs4236.c | 97 ++++++++++----------- sound/isa/es1688/es1688.c | 61 +++++++------- sound/isa/es18xx.c | 81 +++++++++--------- sound/isa/gus/gusclassic.c | 115 +++++++++++-------------- sound/isa/gus/gusextreme.c | 49 ++++------- sound/isa/gus/gusmax.c | 145 ++++++++++++++------------------ sound/isa/gus/interwave.c | 167 ++++++++++++++++--------------------- sound/isa/opl3sa2.c | 36 +++++--- sound/isa/opti9xx/opti92x-ad1848.c | 8 +- sound/isa/sb/sb16.c | 144 +++++++++++++++----------------- sound/isa/sb/sb8.c | 62 +++++++------- sound/isa/sgalaxy.c | 65 ++++++++------- sound/isa/sscape.c | 22 +++-- sound/isa/wavefront/wavefront.c | 5 ++ 18 files changed, 587 insertions(+), 648 deletions(-) diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 5c394831152..5d6c300ac0d 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig @@ -6,12 +6,12 @@ menu "ISA devices" config SND_AD1848_LIB tristate select SND_PCM - select SND_GENERIC_PM + select SND_GENERIC_DRIVER config SND_CS4231_LIB tristate select SND_PCM - select SND_GENERIC_PM + select SND_GENERIC_DRIVER config SND_AD1816A tristate "Analog Devices SoundPort AD1816A" @@ -97,6 +97,7 @@ config SND_ES1688 select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM + select SND_GENERIC_DRIVER help Say Y here to include support for ESS AudioDrive ES688 or ES1688 chips. @@ -110,7 +111,7 @@ config SND_ES18XX select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_PM + select SND_GENERIC_DRIVER help Say Y here to include support for ESS AudioDrive ES18xx chips. @@ -126,6 +127,7 @@ config SND_GUSCLASSIC select SND_RAWMIDI select SND_PCM select SND_GUS_SYNTH + select SND_GENERIC_DRIVER help Say Y here to include support for Gravis UltraSound Classic soundcards. @@ -140,6 +142,7 @@ config SND_GUSEXTREME select SND_MPU401_UART select SND_PCM select SND_GUS_SYNTH + select SND_GENERIC_DRIVER help Say Y here to include support for Gravis UltraSound Extreme soundcards. @@ -153,6 +156,7 @@ config SND_GUSMAX select SND_RAWMIDI select SND_CS4231_LIB select SND_GUS_SYNTH + select SND_GENERIC_DRIVER help Say Y here to include support for Gravis UltraSound MAX soundcards. @@ -166,7 +170,7 @@ config SND_INTERWAVE select SND_RAWMIDI select SND_CS4231_LIB select SND_GUS_SYNTH - select ISAPNP + select SND_GENERIC_DRIVER help Say Y here to include support for AMD InterWave based soundcards (Gravis UltraSound Plug & Play, STB SoundRage32, @@ -181,7 +185,7 @@ config SND_INTERWAVE_STB select SND_RAWMIDI select SND_CS4231_LIB select SND_GUS_SYNTH - select ISAPNP + select SND_GENERIC_DRIVER help Say Y here to include support for AMD InterWave based soundcards with a TEA6330T bass and treble regulator @@ -224,6 +228,7 @@ config SND_OPTI93X select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM + select SND_GENERIC_DRIVER help Say Y here to include support for soundcards based on Opti 82C93x chips. @@ -237,6 +242,7 @@ config SND_SB8 select SND_OPL3_LIB select SND_RAWMIDI select SND_PCM + select SND_GENERIC_DRIVER help Say Y here to include support for Creative Sound Blaster 1.0/ 2.0/Pro (8-bit) or 100% compatible soundcards. @@ -250,6 +256,7 @@ config SND_SB16 select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM + select SND_GENERIC_DRIVER help Say Y here to include support for Sound Blaster 16 soundcards (including the Plug and Play version). @@ -263,6 +270,7 @@ config SND_SBAWE select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM + select SND_GENERIC_DRIVER help Say Y here to include support for Sound Blaster AWE soundcards (including the Plug and Play version). diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index 8c399340cd7..3ebcc482b07 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c @@ -91,35 +91,36 @@ static int __init snd_card_ad1848_probe(int dev) irq[dev], dma1[dev], thinkpad[dev] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT, - &chip)) < 0) { - snd_card_free(card); - return err; - } + &chip)) < 0) + goto _err; + + if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0) + goto _err; + + if ((err = snd_ad1848_mixer(chip)) < 0) + goto _err; - if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_ad1848_mixer(chip)) < 0) { - snd_card_free(card); - return err; - } strcpy(card->driver, "AD1848"); strcpy(card->shortname, pcm->name); sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", pcm->name, chip->port, irq[dev], dma1[dev]); - if (thinkpad[dev]) { + if (thinkpad[dev]) strcat(card->longname, " [Thinkpad]"); - } - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; + snd_ad1848_cards[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __init alsa_card_ad1848_init(void) diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index 1fce8b9f37c..5252206ea38 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -438,33 +438,37 @@ static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip) /* */ +#ifdef CONFIG_PNP +#define is_isapnp_selected(dev) isapnp[dev] +#else +#define is_isapnp_selected(dev) 0 +#endif + +#define PFX "cmi8330: " + static int __devinit snd_cmi8330_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { snd_card_t *card; struct snd_cmi8330 *acard; - unsigned long flags; int i, err; -#ifdef CONFIG_PNP - if (!isapnp[dev]) { -#endif + if (! is_isapnp_selected(dev)) { if (wssport[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify wssport\n"); + snd_printk(KERN_ERR PFX "specify wssport\n"); return -EINVAL; } if (sbport[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify sbport\n"); + snd_printk(KERN_ERR PFX "specify sbport\n"); return -EINVAL; } -#ifdef CONFIG_PNP } -#endif + card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_cmi8330)); if (card == NULL) { - snd_printk("could not get a new card\n"); + snd_printk(KERN_ERR PFX "could not get a new card\n"); return -ENOMEM; } acard = (struct snd_cmi8330 *)card->private_data; @@ -473,9 +477,8 @@ static int __devinit snd_cmi8330_probe(int dev, #ifdef CONFIG_PNP if (isapnp[dev]) { if ((err = snd_cmi8330_pnp(dev, acard, pcard, pid)) < 0) { - snd_printk("PnP detection failed\n"); - snd_card_free(card); - return err; + snd_printk(KERN_ERR PFX "PnP detection failed\n"); + goto _err; } snd_card_set_dev(card, &pcard->card->dev); } @@ -487,14 +490,13 @@ static int __devinit snd_cmi8330_probe(int dev, wssdma[dev], AD1848_HW_DETECT, &acard->wss)) < 0) { - snd_printk("(AD1848) device busy??\n"); - snd_card_free(card); - return err; + snd_printk(KERN_ERR PFX "(AD1848) device busy??\n"); + goto _err; } if (acard->wss->hardware != AD1848_HW_CMI8330) { - snd_printk("(AD1848) not found during probe\n"); - snd_card_free(card); - return -ENODEV; + snd_printk(KERN_ERR PFX "(AD1848) not found during probe\n"); + err = -ENODEV; + goto _err; } if ((err = snd_sbdsp_create(card, sbport[dev], @@ -503,32 +505,26 @@ static int __devinit snd_cmi8330_probe(int dev, sbdma8[dev], sbdma16[dev], SB_HW_AUTO, &acard->sb)) < 0) { - snd_printk("(SB16) device busy??\n"); - snd_card_free(card); - return err; + snd_printk(KERN_ERR PFX "(SB16) device busy??\n"); + goto _err; } if (acard->sb->hardware != SB_HW_16) { - snd_printk("(SB16) not found during probe\n"); - snd_card_free(card); - return -ENODEV; + snd_printk(KERN_ERR PFX "(SB16) not found during probe\n"); + goto _err; } - spin_lock_irqsave(&acard->wss->reg_lock, flags); snd_ad1848_out(acard->wss, AD1848_MISC_INFO, 0x40); /* switch on MODE2 */ for (i = CMI8330_RMUX3D; i <= CMI8330_CDINGAIN; i++) snd_ad1848_out(acard->wss, i, snd_cmi8330_image[i - CMI8330_RMUX3D]); - spin_unlock_irqrestore(&acard->wss->reg_lock, flags); if ((err = snd_cmi8330_mixer(card, acard)) < 0) { - snd_printk("failed to create mixers\n"); - snd_card_free(card); - return err; + snd_printk(KERN_ERR PFX "failed to create mixers\n"); + goto _err; } if ((err = snd_cmi8330_pcm(card, acard)) < 0) { - snd_printk("failed to create pcms\n"); - snd_card_free(card); - return err; + snd_printk(KERN_ERR PFX "failed to create pcms\n"); + goto _err; } strcpy(card->driver, "CMI8330/C3D"); @@ -539,16 +535,21 @@ static int __devinit snd_cmi8330_probe(int dev, wssirq[dev], wssdma[dev]); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; if (pcard) pnp_set_card_drvdata(pcard, card); else snd_cmi8330_legacy[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } #ifdef CONFIG_PNP @@ -594,10 +595,8 @@ static int __init alsa_card_cmi8330_init(void) for (dev = 0; dev < SNDRV_CARDS; dev++) { if (!enable[dev]) continue; -#ifdef CONFIG_PNP - if (isapnp[dev]) + if (is_isapnp_selected(dev)) continue; -#endif if (snd_cmi8330_probe(dev, NULL, NULL) >= 0) cards++; } diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index 7640837659e..9be5416bcb9 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -76,15 +76,15 @@ static int __init snd_card_cs4231_probe(int dev) int err; if (port[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify port\n"); + snd_printk(KERN_ERR "specify port\n"); return -EINVAL; } if (irq[dev] == SNDRV_AUTO_IRQ) { - snd_printk("specify irq\n"); + snd_printk(KERN_ERR "specify irq\n"); return -EINVAL; } if (dma1[dev] == SNDRV_AUTO_DMA) { - snd_printk("specify dma1\n"); + snd_printk(KERN_ERR "specify dma1\n"); return -EINVAL; } card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); @@ -96,15 +96,11 @@ static int __init snd_card_cs4231_probe(int dev) dma1[dev], dma2[dev], CS4231_HW_DETECT, - 0, &chip)) < 0) { - snd_card_free(card); - return err; - } + 0, &chip)) < 0) + goto _err; - if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) + goto _err; strcpy(card->driver, "CS4231"); strcpy(card->shortname, pcm->name); @@ -113,14 +109,10 @@ static int __init snd_card_cs4231_probe(int dev) if (dma2[dev] >= 0) sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); - if ((err = snd_cs4231_mixer(chip)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_cs4231_mixer(chip)) < 0) + goto _err; + if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) + goto _err; if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { if (mpu_irq[dev] == SNDRV_AUTO_IRQ) @@ -130,14 +122,20 @@ static int __init snd_card_cs4231_probe(int dev) mpu_irq[dev], mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL) < 0) - printk(KERN_ERR "cs4231: MPU401 not detected\n"); - } - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; + printk(KERN_WARNING "cs4231: MPU401 not detected\n"); } + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; snd_cs4231_cards[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __init alsa_card_cs4231_init(void) diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 39f4eff44f5..d28315dc72f 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -387,6 +387,12 @@ static void snd_card_cs4236_free(snd_card_t *card) } } +#ifdef CONFIG_PNP +#define is_isapnp_selected(dev) isapnp[dev] +#else +#define is_isapnp_selected(dev) 0 +#endif + static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { @@ -397,20 +403,16 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, opl3_t *opl3; int err; -#ifdef CONFIG_PNP - if (!isapnp[dev]) { -#endif + if (! is_isapnp_selected(dev)) { if (port[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify port\n"); + snd_printk(KERN_ERR "specify port\n"); return -EINVAL; } if (cport[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify cport\n"); + snd_printk(KERN_ERR "specify cport\n"); return -EINVAL; } -#ifdef CONFIG_PNP } -#endif card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_cs4236)); if (card == NULL) @@ -421,8 +423,7 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, if (isapnp[dev]) { if ((err = snd_card_cs4236_pnp(dev, acard, pcard, pid))<0) { printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n"); - snd_card_free(card); - return -ENXIO; + goto _err; } snd_card_set_dev(card, &pcard->card->dev); } @@ -430,8 +431,8 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT) if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) { printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]); - snd_card_free(card); - return -ENOMEM; + err = -EBUSY; + goto _err; } #ifdef CS4232 @@ -443,18 +444,14 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, dma2[dev], CS4231_HW_DETECT, 0, - &chip)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_mixer(chip)) < 0) { - snd_card_free(card); - return err; - } + &chip)) < 0) + goto _err; + + if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) + goto _err; + + if ((err = snd_cs4231_mixer(chip)) < 0) + goto _err; #else /* CS4236 */ if ((err = snd_cs4236_create(card, @@ -465,18 +462,14 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, dma2[dev], CS4231_HW_DETECT, 0, - &chip)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4236_mixer(chip)) < 0) { - snd_card_free(card); - return err; - } + &chip)) < 0) + goto _err; + + if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0) + goto _err; + + if ((err = snd_cs4236_mixer(chip)) < 0) + goto _err; #endif strcpy(card->driver, pcm->name); strcpy(card->shortname, pcm->name); @@ -488,21 +481,17 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, if (dma2[dev] >= 0) sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); - if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) + goto _err; if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { if (snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2, OPL3_HW_OPL3_CS, 0, &opl3) < 0) { - printk(KERN_ERR IDENT ": OPL3 not detected\n"); + printk(KERN_WARNING IDENT ": OPL3 not detected\n"); } else { - if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) + goto _err; } } @@ -513,17 +502,23 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, mpu_port[dev], 0, mpu_irq[dev], mpu_irq[dev] >= 0 ? SA_INTERRUPT : 0, NULL) < 0) - printk(KERN_ERR IDENT ": MPU401 not detected\n"); - } - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; + printk(KERN_WARNING IDENT ": MPU401 not detected\n"); } + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; if (pcard) pnp_set_card_drvdata(pcard, card); else snd_cs4236_legacy[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } #ifdef CONFIG_PNP @@ -569,10 +564,8 @@ static int __init alsa_card_cs423x_init(void) for (dev = 0; dev < SNDRV_CARDS; dev++) { if (!enable[dev]) continue; -#ifdef CONFIG_PNP - if (isapnp[dev]) + if (is_isapnp_selected(dev)) continue; -#endif if (snd_card_cs423x_probe(dev, NULL, NULL) >= 0) cards++; } diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index c5eaec087b4..26a7d335ed8 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -70,6 +70,7 @@ MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); static snd_card_t *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +#define PFX "es1688: " static int __init snd_audiodrive_probe(int dev) { @@ -89,47 +90,41 @@ static int __init snd_audiodrive_probe(int dev) xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + err = -EBUSY; + goto _err; } } xmpu_irq = mpu_irq[dev]; xdma = dma8[dev]; if (xdma == SNDRV_AUTO_DMA) { if ((xdma = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA\n"); + err = -EBUSY; + goto _err; } } if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], xirq, xmpu_irq, xdma, - ES1688_HW_AUTO, &chip)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_es1688_mixer(chip)) < 0) { - snd_card_free(card); - return err; - } + ES1688_HW_AUTO, &chip)) < 0) + goto _err; + + if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0) + goto _err; + + if ((err = snd_es1688_mixer(chip)) < 0) + goto _err; strcpy(card->driver, "ES1688"); strcpy(card->shortname, pcm->name); sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port, xirq, xdma); if ((snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_OPL3, 0, &opl3)) < 0) { - printk(KERN_ERR "es1688: opl3 not detected at 0x%lx\n", chip->port); + printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->port); } else { - if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) + goto _err; } if (xmpu_irq >= 0 && xmpu_irq != SNDRV_AUTO_IRQ && chip->mpu_port > 0) { @@ -137,18 +132,22 @@ static int __init snd_audiodrive_probe(int dev) chip->mpu_port, 0, xmpu_irq, SA_INTERRUPT, - NULL)) < 0) { - snd_card_free(card); - return err; - } - } - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; + NULL)) < 0) + goto _err; } + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; + snd_audiodrive_cards[dev] = card; return 0; + _err: + snd_card_free(card); + return err; } static int __init snd_audiodrive_legacy_auto_probe(unsigned long xport) diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 1d832b2adb7..f654d594836 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1988,6 +1988,12 @@ static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard, } #endif /* CONFIG_PNP */ +#ifdef CONFIG_PNP +#define is_isapnp_selected(dev) isapnp[dev] +#else +#define is_isapnp_selected(dev) 0 +#endif + static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { @@ -1996,7 +2002,6 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, int xirq, xdma1, xdma2; snd_card_t *card; struct snd_audiodrive *acard; - snd_rawmidi_t *rmidi = NULL; es18xx_t *chip; opl3_t *opl3; int err; @@ -2019,25 +2024,25 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + err = -EBUSY; + goto _err; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA1\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + err = -EBUSY; + goto _err; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA2\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + err = -EBUSY; + goto _err; } } @@ -2046,10 +2051,8 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, mpu_port[dev], fm_port[dev], xirq, xdma1, xdma2, - &chip)) < 0) { - snd_card_free(card); - return err; - } + &chip)) < 0) + goto _err; sprintf(card->driver, "ES%x", chip->version); sprintf(card->shortname, "ESS AudioDrive ES%x", chip->version); @@ -2064,23 +2067,18 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, chip->port, xirq, xdma1); - if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_es18xx_mixer(chip)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) + goto _err; + + if ((err = snd_es18xx_mixer(chip)) < 0) + goto _err; if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { - snd_printk(KERN_ERR PFX "opl3 not detected at 0x%lx\n", chip->fm_port); + snd_printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->fm_port); } else { - if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) + goto _err; } } @@ -2088,25 +2086,28 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, chip->mpu_port, 0, xirq, 0, - &rmidi)) < 0) { - snd_card_free(card); - return err; - } - chip->rmidi = rmidi; + &chip->rmidi)) < 0) + goto _err; } + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + /* Power Management */ snd_card_set_isa_pm_callback(card, snd_es18xx_suspend, snd_es18xx_resume, chip); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_card_register(card)) < 0) + goto _err; + if (pcard) pnp_set_card_drvdata(pcard, card); else snd_audiodrive_legacy[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport) @@ -2117,10 +2118,8 @@ static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport) for ( ; dev < SNDRV_CARDS; dev++) { if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) continue; -#ifdef CONFIG_PNP - if (isapnp[dev]) + if (is_isapnp_selected(dev)) continue; -#endif port[dev] = xport; res = snd_audiodrive_probe(dev, NULL, NULL); if (res < 0) @@ -2177,10 +2176,8 @@ static int __init alsa_card_es18xx_init(void) for (dev = 0; dev < SNDRV_CARDS; dev++) { if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) continue; -#ifdef CONFIG_PNP - if (isapnp[dev]) + if (is_isapnp_selected(dev)) continue; -#endif if (snd_audiodrive_probe(dev, NULL, NULL) >= 0) cards++; } diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index a99fa5040b4..39cef38835c 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -72,40 +72,24 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +#define PFX "gusclassic: " static int __init snd_gusclassic_detect(snd_gus_card_t * gus) { - snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; + unsigned char d; - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { - snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0) + snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { + snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif + } udelay(160); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ udelay(160); -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { - snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { + snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif - + } return 0; } @@ -137,25 +121,25 @@ static int __init snd_gusclassic_probe(int dev) xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + err = -EBUSY; + goto _err; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA1\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + err = -EBUSY; + goto _err; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA2\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + err = -EBUSY; + goto _err; } } @@ -164,47 +148,48 @@ static int __init snd_gusclassic_probe(int dev) port[dev], xirq, xdma1, xdma2, 0, channels[dev], pcm_channels[dev], - 0, &gus)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_gusclassic_detect(gus)) < 0) { - snd_card_free(card); - return err; - } + 0, &gus)) < 0) + goto _err; + + if ((err = snd_gusclassic_detect(gus)) < 0) + goto _err; + snd_gusclassic_init(dev, gus); - if ((err = snd_gus_initialize(gus)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gus_initialize(gus)) < 0) + goto _err; + if (gus->max_flag || gus->ess_flag) { - snd_printdd("GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); - snd_card_free(card); - return -ENODEV; - } - if ((err = snd_gf1_new_mixer(gus)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) { - snd_card_free(card); - return err; + snd_printk(KERN_ERR PFX "GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); + err = -ENODEV; + goto _err; } + + if ((err = snd_gf1_new_mixer(gus)) < 0) + goto _err; + + if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) + goto _err; + if (!gus->ace_flag) { - if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) + goto _err; } sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1); if (dma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; + snd_gusclassic_cards[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport) diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index bc6fecb18dc..d2e7cb1df53 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -87,6 +87,7 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); static snd_card_t *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +#define PFX "gusextreme: " static int __init snd_gusextreme_detect(int dev, snd_card_t * card, @@ -94,6 +95,7 @@ static int __init snd_gusextreme_detect(int dev, es1688_t *es1688) { unsigned long flags; + unsigned char d; /* * This is main stuff - enable access to GF1 chip... @@ -123,36 +125,17 @@ static int __init snd_gusextreme_detect(int dev, udelay(100); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { - snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); - return -EIO; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { + snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); return -EIO; -#endif + } udelay(160); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ udelay(160); -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { - snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); - return -EIO; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { + snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); return -EIO; -#endif - + } return 0; } @@ -205,7 +188,7 @@ static int __init snd_gusextreme_probe(int dev) xgf1_irq = gf1_irq[dev]; if (xgf1_irq == SNDRV_AUTO_IRQ) { if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) { - snd_printk("unable to find a free IRQ for GF1\n"); + snd_printk(KERN_ERR PFX "unable to find a free IRQ for GF1\n"); err = -EBUSY; goto out; } @@ -213,7 +196,7 @@ static int __init snd_gusextreme_probe(int dev) xess_irq = irq[dev]; if (xess_irq == SNDRV_AUTO_IRQ) { if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) { - snd_printk("unable to find a free IRQ for ES1688\n"); + snd_printk(KERN_ERR PFX "unable to find a free IRQ for ES1688\n"); err = -EBUSY; goto out; } @@ -226,7 +209,7 @@ static int __init snd_gusextreme_probe(int dev) xgf1_dma = dma1[dev]; if (xgf1_dma == SNDRV_AUTO_DMA) { if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) { - snd_printk("unable to find a free DMA for GF1\n"); + snd_printk(KERN_ERR PFX "unable to find a free DMA for GF1\n"); err = -EBUSY; goto out; } @@ -234,7 +217,7 @@ static int __init snd_gusextreme_probe(int dev) xess_dma = dma8[dev]; if (xess_dma == SNDRV_AUTO_DMA) { if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) { - snd_printk("unable to find a free DMA for ES1688\n"); + snd_printk(KERN_ERR PFX "unable to find a free DMA for ES1688\n"); err = -EBUSY; goto out; } @@ -264,7 +247,7 @@ static int __init snd_gusextreme_probe(int dev) goto out; if (!gus->ess_flag) { - snd_printdd("GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); + snd_printk(KERN_ERR PFX "GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); err = -ENODEV; goto out; } @@ -287,7 +270,7 @@ static int __init snd_gusextreme_probe(int dev) if (snd_opl3_create(card, es1688->port, es1688->port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { - printk(KERN_ERR "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); + printk(KERN_ERR PFX "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); } else { if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) goto out; @@ -303,6 +286,10 @@ static int __init snd_gusextreme_probe(int dev) sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto out; + if ((err = snd_card_register(card)) < 0) goto out; diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 400ff34710f..0bb44b51934 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -82,39 +82,25 @@ struct snd_gusmax { static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +#define PFX "gusmax: " static int __init snd_gusmax_detect(snd_gus_card_t * gus) { - snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; + unsigned char d; - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { - snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0) + snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { + snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif + } udelay(160); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ udelay(160); -#ifdef CONFIG_SND_DEBUG_DETECT - { - unsigned char d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { - snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { + snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif + } + return 0; } @@ -239,25 +225,25 @@ static int __init snd_gusmax_probe(int dev) xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + err = -EBUSY; + goto _err; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA1\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + err = -EBUSY; + goto _err; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA2\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + err = -EBUSY; + goto _err; } } @@ -266,31 +252,28 @@ static int __init snd_gusmax_probe(int dev) -xirq, xdma1, xdma2, 0, channels[dev], pcm_channels[dev], - 0, &gus)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_gusmax_detect(gus)) < 0) { - snd_card_free(card); - return err; - } + 0, &gus)) < 0) + goto _err; + + if ((err = snd_gusmax_detect(gus)) < 0) + goto _err; + maxcard->gus_status_reg = gus->gf1.reg_irqstat; maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; snd_gusmax_init(dev, card, gus); - if ((err = snd_gus_initialize(gus)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gus_initialize(gus)) < 0) + goto _err; + if (!gus->max_flag) { - printk(KERN_ERR "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); - snd_card_free(card); - return -ENODEV; + snd_printk(KERN_ERR PFX "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); + err = -ENODEV; + goto _err; } if (request_irq(xirq, snd_gusmax_interrupt, SA_INTERRUPT, "GUS MAX", (void *)maxcard)) { - snd_card_free(card); - printk(KERN_ERR "gusmax: unable to grab IRQ %d\n", xirq); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); + err = -EBUSY; + goto _err; } maxcard->irq = xirq; @@ -301,50 +284,46 @@ static int __init snd_gusmax_probe(int dev) CS4231_HWSHARE_IRQ | CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2, - &cs4231)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_mixer(cs4231)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) { - snd_card_free(card); - return err; - } + &cs4231)) < 0) + goto _err; + + if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) + goto _err; + + if ((err = snd_cs4231_mixer(cs4231)) < 0) + goto _err; + + if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) + goto _err; + if (pcm_channels[dev] > 0) { - if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { - snd_card_free(card); - return err; - } - } - if ((err = snd_gusmax_mixer(cs4231)) < 0) { - snd_card_free(card); - return err; + if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) + goto _err; } + if ((err = snd_gusmax_mixer(cs4231)) < 0) + goto _err; - if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) + goto _err; sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1); if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%i", xdma2); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; maxcard->gus = gus; maxcard->cs4231 = cs4231; snd_gusmax_cards[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __init snd_gusmax_legacy_auto_probe(unsigned long xport) diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 46e867daba6..358cba9d738 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -73,6 +73,12 @@ static int midi[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; +#ifdef SNDRV_STB +#define PFX "interwave-stb: " +#else +#define PFX "interwave: " +#endif + module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for InterWave soundcard."); module_param_array(id, charp, NULL, 0444); @@ -249,38 +255,20 @@ static int __devinit snd_interwave_detect(struct snd_interwave *iwcard, { unsigned long flags; unsigned char rev1, rev2; + int d; snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ -#ifdef CONFIG_SND_DEBUG_DETECT - { - int d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { - snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { + snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif + } udelay(160); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ udelay(160); -#ifdef CONFIG_SND_DEBUG_DETECT - { - int d; - - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { - snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); - return -ENODEV; - } - } -#else - if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1) + if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { + snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; -#endif - + } spin_lock_irqsave(&gus->reg_lock, flags); rev1 = snd_gf1_look8(gus, SNDRV_GF1_GB_VERSION_NUMBER); snd_gf1_write8(gus, SNDRV_GF1_GB_VERSION_NUMBER, ~rev1); @@ -686,35 +674,33 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, card->private_free = snd_interwave_free; #ifdef CONFIG_PNP if (isapnp[dev]) { - if (snd_interwave_pnp(dev, iwcard, pcard, pid)) { - snd_card_free(card); - return -ENODEV; - } + if ((err = snd_interwave_pnp(dev, iwcard, pcard, pid)) < 0) + goto _err; snd_card_set_dev(card, &pcard->card->dev); } #endif xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + err = -EBUSY; + goto _err; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA1\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + err = -EBUSY; + goto _err; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA2\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + err = -EBUSY; + goto _err; } } @@ -722,32 +708,28 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, port[dev], -xirq, xdma1, xdma2, 0, 32, - pcm_channels[dev], effect[dev], &gus)) < 0) { - snd_card_free(card); - return err; - } + pcm_channels[dev], effect[dev], &gus)) < 0) + goto _err; + if ((err = snd_interwave_detect(iwcard, gus, dev #ifdef SNDRV_STB , &i2c_bus #endif - )) < 0) { - snd_card_free(card); - return err; - } + )) < 0) + goto _err; + iwcard->gus_status_reg = gus->gf1.reg_irqstat; iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; snd_interwave_init(dev, gus); snd_interwave_detect_memory(gus); - if ((err = snd_gus_initialize(gus)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gus_initialize(gus)) < 0) + goto _err; if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) { - snd_card_free(card); - snd_printk("unable to grab IRQ %d\n", xirq); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); + err = -EBUSY; + goto _err; } iwcard->irq = xirq; @@ -758,34 +740,28 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, CS4231_HWSHARE_IRQ | CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2, - &cs4231)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) { - snd_card_free(card); - return err; - } + &cs4231)) < 0) + goto _err; + + if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) + goto _err; + sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A'); strcat(pcm->name, " (codec)"); - if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_cs4231_mixer(cs4231)) < 0) { - snd_card_free(card); - return err; - } + + if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) + goto _err; + + if ((err = snd_cs4231_mixer(cs4231)) < 0) + goto _err; + if (pcm_channels[dev] > 0) { - if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { - snd_card_free(card); - return err; - } - } - if ((err = snd_interwave_mixer(cs4231)) < 0) { - snd_card_free(card); - return err; + if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) + goto _err; } + if ((err = snd_interwave_mixer(cs4231)) < 0) + goto _err; + #ifdef SNDRV_STB { snd_ctl_elem_id_t id1, id2; @@ -795,28 +771,20 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, strcpy(id1.name, "Master Playback Switch"); strcpy(id2.name, id1.name); id2.index = 1; - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + goto _err; strcpy(id1.name, "Master Playback Volume"); strcpy(id2.name, id1.name); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + goto _err; + if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) + goto _err; } #endif gus->uart_enable = midi[dev]; - if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) + goto _err; #ifndef SNDRV_STB str = "AMD InterWave"; @@ -835,10 +803,11 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; iwcard->cs4231 = cs4231; iwcard->gus = gus; @@ -847,6 +816,10 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, else snd_interwave_legacy[dev++] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __devinit snd_interwave_probe_legacy_port(unsigned long xport) diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 75bd6eca63e..e2d615bbb2f 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -143,6 +143,8 @@ struct snd_opl3sa2 { static snd_card_t *snd_opl3sa2_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +#define PFX "opl3sa2: " + #ifdef CONFIG_PNP static struct pnp_device_id snd_opl3sa2_pnpbiosids[] = { @@ -231,7 +233,7 @@ static int __init snd_opl3sa2_detect(opl3sa2_t *chip) card = chip->card; port = chip->port; if ((chip->res_port = request_region(port, 2, "OPL3-SA control")) == NULL) { - snd_printk(KERN_ERR "opl3sa2: can't grab port 0x%lx\n", port); + snd_printk(KERN_ERR PFX "can't grab port 0x%lx\n", port); return -EBUSY; } // snd_printk("REG 0A = 0x%x\n", snd_opl3sa2_read(chip, 0x0a)); @@ -668,6 +670,12 @@ static int snd_opl3sa2_dev_free(snd_device_t *device) return snd_opl3sa2_free(chip); } +#ifdef CONFIG_PNP +#define is_isapnp_selected(dev) isapnp[dev] +#else +#define is_isapnp_selected(dev) 0 +#endif + static int __devinit snd_opl3sa2_probe(int dev, struct pnp_dev *pdev, struct pnp_card_link *pcard, @@ -683,28 +691,25 @@ static int __devinit snd_opl3sa2_probe(int dev, }; int err; -#ifdef CONFIG_PNP - if (!isapnp[dev]) { -#endif + if (! is_isapnp_selected(dev)) { if (port[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify port\n"); + snd_printk(KERN_ERR PFX "specify port\n"); return -EINVAL; } if (wss_port[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify wss_port\n"); + snd_printk(KERN_ERR PFX "specify wss_port\n"); return -EINVAL; } if (fm_port[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify fm_port\n"); + snd_printk(KERN_ERR PFX "specify fm_port\n"); return -EINVAL; } if (midi_port[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify midi_port\n"); + snd_printk(KERN_ERR PFX "specify midi_port\n"); return -EINVAL; } -#ifdef CONFIG_PNP } -#endif + card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; @@ -742,7 +747,7 @@ static int __devinit snd_opl3sa2_probe(int dev, if ((err = snd_opl3sa2_detect(chip)) < 0) goto __error; if (request_irq(xirq, snd_opl3sa2_interrupt, SA_INTERRUPT, "OPL3-SA2", (void *)chip)) { - snd_printk(KERN_ERR "opl3sa2: can't grab IRQ %d\n", xirq); + snd_printk(KERN_ERR PFX "can't grab IRQ %d\n", xirq); err = -ENODEV; goto __error; } @@ -795,6 +800,9 @@ static int __devinit snd_opl3sa2_probe(int dev, if (dma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); + if ((err = snd_card_set_generic_dev(card)) < 0) + goto __error; + if ((err = snd_card_register(card)) < 0) goto __error; @@ -852,8 +860,10 @@ static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *card, int res; for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; + if (!enable[dev]) + continue; + if (is_isapnp_selected(dev)) + continue; res = snd_opl3sa2_probe(dev, NULL, card, id); if (res < 0) return res; diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 782750d62eb..a490bcacdfa 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -1894,8 +1894,8 @@ static void snd_card_opti9xx_free(snd_card_t *card) } } -static int __devinit snd_card_opti9xx_probe(struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1}; @@ -1965,6 +1965,10 @@ static int __devinit snd_card_opti9xx_probe(struct pnp_card_link *pcard, snd_card_free(card); return error; } + if ((error = snd_card_set_generic_dev(card)) < 0) { + snd_card_free(card); + return error; + } #ifdef CONFIG_PNP } #endif /* CONFIG_PNP */ diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 60e2c53c49f..7888783d68f 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -351,6 +351,12 @@ static void snd_sb16_free(snd_card_t *card) } } +#ifdef CONFIG_PNP +#define is_isapnp_selected(dev) isapnp[dev] +#else +#define is_isapnp_selected(dev) 0 +#endif + static int __init snd_sb16_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) @@ -378,10 +384,8 @@ static int __init snd_sb16_probe(int dev, card->private_free = snd_sb16_free; #ifdef CONFIG_PNP if (isapnp[dev]) { - if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid))) { - snd_card_free(card); - return err; - } + if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid))) + goto _err; snd_card_set_dev(card, &pcard->card->dev); } #endif @@ -389,41 +393,37 @@ static int __init snd_sb16_probe(int dev, xirq = irq[dev]; xdma8 = dma8[dev]; xdma16 = dma16[dev]; -#ifdef CONFIG_PNP - if (!isapnp[dev]) { -#endif - if (xirq == SNDRV_AUTO_IRQ) { - if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); - return -EBUSY; + if (! is_isapnp_selected(dev)) { + if (xirq == SNDRV_AUTO_IRQ) { + if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + err = -EBUSY; + goto _err; + } } - } - if (xdma8 == SNDRV_AUTO_DMA) { - if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) { - snd_card_free(card); - snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); - return -EBUSY; + if (xdma8 == SNDRV_AUTO_DMA) { + if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); + err = -EBUSY; + goto _err; + } } - } - if (xdma16 == SNDRV_AUTO_DMA) { - if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) { - snd_card_free(card); - snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); - return -EBUSY; + if (xdma16 == SNDRV_AUTO_DMA) { + if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); + err = -EBUSY; + goto _err; + } } - } - /* non-PnP FM port address is hardwired with base port address */ - fm_port[dev] = port[dev]; - /* block the 0x388 port to avoid PnP conflicts */ - acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); + /* non-PnP FM port address is hardwired with base port address */ + fm_port[dev] = port[dev]; + /* block the 0x388 port to avoid PnP conflicts */ + acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); #ifdef SNDRV_SBAWE_EMU8000 - /* non-PnP AWE port address is hardwired with base port address */ - awe_port[dev] = port[dev] + 0x400; + /* non-PnP AWE port address is hardwired with base port address */ + awe_port[dev] = port[dev] + 0x400; #endif -#ifdef CONFIG_PNP } -#endif if ((err = snd_sbdsp_create(card, port[dev], @@ -432,28 +432,20 @@ static int __init snd_sb16_probe(int dev, xdma8, xdma16, SB_HW_AUTO, - &chip)) < 0) { - snd_card_free(card); - return err; - } + &chip)) < 0) + goto _err; + if (chip->hardware != SB_HW_16) { - snd_card_free(card); - snd_printdd("SB 16 chip was not detected at 0x%lx\n", port[dev]); - return -ENODEV; + snd_printk(KERN_ERR PFX "SB 16 chip was not detected at 0x%lx\n", port[dev]); + err = -ENODEV; + goto _err; } chip->mpu_port = mpu_port[dev]; -#ifdef CONFIG_PNP - if (!isapnp[dev] && (err = snd_sb16dsp_configure(chip)) < 0) { -#else - if ((err = snd_sb16dsp_configure(chip)) < 0) { -#endif - snd_card_free(card); - return -ENXIO; - } - if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { - snd_card_free(card); - return -ENXIO; - } + if (! is_isapnp_selected(dev) && (err = snd_sb16dsp_configure(chip)) < 0) + goto _err; + + if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) + goto _err; strcpy(card->driver, #ifdef SNDRV_SBAWE_EMU8000 @@ -474,10 +466,8 @@ static int __init snd_sb16_probe(int dev, if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) { if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB, chip->mpu_port, 0, - xirq, 0, &chip->rmidi)) < 0) { - snd_card_free(card); - return -ENXIO; - } + xirq, 0, &chip->rmidi)) < 0) + goto _err; chip->rmidi_callback = snd_mpu401_uart_interrupt; } @@ -499,17 +489,13 @@ static int __init snd_sb16_probe(int dev, #else int seqdev = 1; #endif - if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) { - snd_card_free(card); - return -ENXIO; - } + if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) + goto _err; } } - if ((err = snd_sbmixer_new(chip)) < 0) { - snd_card_free(card); - return -ENXIO; - } + if ((err = snd_sbmixer_new(chip)) < 0) + goto _err; #ifdef CONFIG_SND_SB16_CSP /* CSP chip on SB16ASP/AWE32 */ @@ -525,11 +511,11 @@ static int __init snd_sb16_probe(int dev, #endif #ifdef SNDRV_SBAWE_EMU8000 if (awe_port[dev] > 0) { - if (snd_emu8000_new(card, 1, awe_port[dev], - seq_ports[dev], NULL) < 0) { + if ((err = snd_emu8000_new(card, 1, awe_port[dev], + seq_ports[dev], NULL)) < 0) { snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]); - snd_card_free(card); - return -ENXIO; + + goto _err; } } #endif @@ -541,15 +527,21 @@ static int __init snd_sb16_probe(int dev, (mic_agc[dev] ? 0x00 : 0x01)); spin_unlock_irqrestore(&chip->mixer_lock, flags); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; + if (pcard) pnp_set_card_drvdata(pcard, card); else snd_sb16_legacy[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __init snd_sb16_probe_legacy_port(unsigned long xport) @@ -560,10 +552,8 @@ static int __init snd_sb16_probe_legacy_port(unsigned long xport) for ( ; dev < SNDRV_CARDS; dev++) { if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) continue; -#ifdef CONFIG_PNP - if (isapnp[dev]) + if (is_isapnp_selected(dev)) continue; -#endif port[dev] = xport; res = snd_sb16_probe(dev, NULL, NULL); if (res < 0) @@ -621,10 +611,8 @@ static int __init alsa_card_sb16_init(void) for (dev = 0; dev < SNDRV_CARDS; dev++) { if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) continue; -#ifdef CONFIG_PNP - if (isapnp[dev]) + if (is_isapnp_selected(dev)) continue; -#endif if (!snd_sb16_probe(dev, NULL, NULL)) { cards++; continue; diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index e2cbc4202b3..c41ac25e85c 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -107,54 +107,47 @@ static int __init snd_sb8_probe(int dev) dma8[dev], -1, SB_HW_AUTO, - &chip)) < 0) { - snd_card_free(card); - return err; - } + &chip)) < 0) + goto _err; + if (chip->hardware >= SB_HW_16) { - snd_card_free(card); if (chip->hardware == SB_HW_ALS100) - snd_printdd("ALS100 chip detected at 0x%lx, try snd-als100 module\n", + snd_printk(KERN_WARNING "ALS100 chip detected at 0x%lx, try snd-als100 module\n", port[dev]); else - snd_printdd("SB 16 chip detected at 0x%lx, try snd-sb16 module\n", - port[dev]); - return -ENODEV; + snd_printk(KERN_WARNING "SB 16 chip detected at 0x%lx, try snd-sb16 module\n", + port[dev]); + err = -ENODEV; + goto _err; } - if ((err = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_sbmixer_new(chip)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) + goto _err; + + if ((err = snd_sbmixer_new(chip)) < 0) + goto _err; + if (chip->hardware == SB_HW_10 || chip->hardware == SB_HW_20) { if ((err = snd_opl3_create(card, chip->port + 8, 0, OPL3_HW_AUTO, 1, &opl3)) < 0) { - snd_printk(KERN_ERR "sb8: no OPL device at 0x%lx\n", chip->port + 8); + snd_printk(KERN_WARNING "sb8: no OPL device at 0x%lx\n", chip->port + 8); } } else { if ((err = snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_AUTO, 1, &opl3)) < 0) { - snd_printk(KERN_ERR "sb8: no OPL device at 0x%lx-0x%lx\n", + snd_printk(KERN_WARNING "sb8: no OPL device at 0x%lx-0x%lx\n", chip->port, chip->port + 2); } } if (err >= 0) { - if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) + goto _err; } - if ((err = snd_sb8dsp_midi(chip, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_sb8dsp_midi(chip, 0, NULL)) < 0) + goto _err; strcpy(card->driver, chip->hardware == SB_HW_PRO ? "SB Pro" : "SB8"); strcpy(card->shortname, chip->name); @@ -162,12 +155,19 @@ static int __init snd_sb8_probe(int dev) chip->name, chip->port, irq[dev], dma8[dev]); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; + snd_sb8_cards[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __init snd_card_sb8_legacy_auto_probe(unsigned long xport) diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c index 17f585b0ddc..52f2294da62 100644 --- a/sound/isa/sgalaxy.c +++ b/sound/isa/sgalaxy.c @@ -67,6 +67,8 @@ MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); static snd_card_t *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +#define PFX "sgalaxy: " + /* */ @@ -135,7 +137,7 @@ static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) } #if 0 - snd_printdd("sgalaxy - setting up IRQ/DMA for WSS\n"); + snd_printdd(PFX "setting up IRQ/DMA for WSS\n"); #endif /* initialize IRQ for WSS codec */ @@ -160,7 +162,7 @@ static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) static int __init snd_sgalaxy_detect(int dev, int irq, int dma) { #if 0 - snd_printdd("sgalaxy - switching to WSS mode\n"); + snd_printdd(PFX "switching to WSS mode\n"); #endif /* switch to WSS mode */ @@ -223,11 +225,11 @@ static int __init snd_sgalaxy_probe(int dev) ad1848_t *chip; if (sbport[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify SB port\n"); + snd_printk(KERN_ERR PFX "specify SB port\n"); return -EINVAL; } if (wssport[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify WSS port\n"); + snd_printk(KERN_ERR PFX "specify WSS port\n"); return -EINVAL; } card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); @@ -237,46 +239,39 @@ static int __init snd_sgalaxy_probe(int dev) xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + err = -EBUSY; + goto _err; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA\n"); - return -EBUSY; + snd_printk(KERN_ERR PFX "unable to find a free DMA\n"); + err = -EBUSY; + goto _err; } } - if ((err = snd_sgalaxy_detect(dev, xirq, xdma1)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_sgalaxy_detect(dev, xirq, xdma1)) < 0) + goto _err; if ((err = snd_ad1848_create(card, wssport[dev] + 4, xirq, xdma1, - AD1848_HW_DETECT, &chip)) < 0) { - snd_card_free(card); - return err; - } + AD1848_HW_DETECT, &chip)) < 0) + goto _err; if ((err = snd_ad1848_pcm(chip, 0, NULL)) < 0) { - snd_printdd("sgalaxy - error creating new ad1848 PCM device\n"); - snd_card_free(card); - return err; + snd_printdd(PFX "error creating new ad1848 PCM device\n"); + goto _err; } if ((err = snd_ad1848_mixer(chip)) < 0) { - snd_printdd("sgalaxy - error creating new ad1848 mixer\n"); - snd_card_free(card); - return err; + snd_printdd(PFX "error creating new ad1848 mixer\n"); + goto _err; } - if (snd_sgalaxy_mixer(chip) < 0) { - snd_printdd("sgalaxy - the mixer rewrite failed\n"); - snd_card_free(card); - return err; + if ((err = snd_sgalaxy_mixer(chip)) < 0) { + snd_printdd(PFX "the mixer rewrite failed\n"); + goto _err; } strcpy(card->driver, "Sound Galaxy"); @@ -284,12 +279,18 @@ static int __init snd_sgalaxy_probe(int dev) sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", wssport[dev], xirq, xdma1); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_card_set_generic_dev(card)) < 0) + goto _err; + + if ((err = snd_card_register(card)) < 0) + goto _err; + snd_sgalaxy_cards[dev] = card; return 0; + + _err: + snd_card_free(card); + return err; } static int __init alsa_card_sgalaxy_init(void) diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 3959ed694ee..9f6b58c7920 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -1262,11 +1262,6 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca */ sscape_write(sscape, GA_INTENA_REG, 0x80); - if ((err = snd_card_register(card)) < 0) { - printk(KERN_ERR "sscape: Failed to register sound card\n"); - goto _release_card; - } - /* * Initialize mixer */ @@ -1396,6 +1391,13 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, if (ret < 0) return ret; snd_card_set_dev(card, &pcard->card->dev); + + if ((ret = snd_card_register(card)) < 0) { + printk(KERN_ERR "sscape: Failed to register sound card\n"); + snd_card_free(card); + return ret; + } + pnp_set_card_drvdata(pcard, card); ++sscape_cards; ++idx; @@ -1460,6 +1462,16 @@ static int __init sscape_manual_probe(struct params *params) if (ret < 0) return ret; + if ((ret = snd_card_set_generic_dev(card)) < 0) { + snd_card_free(card); + return ret; + } + if ((ret = snd_card_register(card)) < 0) { + printk(KERN_ERR "sscape: Failed to register sound card\n"); + snd_card_free(card); + return ret; + } + sscape_card[sscape_cards] = card; params++; sscape_cards++; diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 79b022070ba..0a572e0a47e 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -622,6 +622,11 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, ics2115_port[dev], ics2115_irq[dev]); + if ((err = snd_card_set_generic_dev(card)) < 0) { + snd_card_free(card); + return err; + } + if ((err = snd_card_register(card)) < 0) { snd_card_free(card); return err; -- cgit v1.2.3 From a4f508b27c6b32d15c923b119b3e90a2d6a9500f Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 6 Sep 2005 08:00:19 +0200 Subject: [ALSA] rtctimer: add option to make RTC timer the default sequencer timer ALSA Core,ALSA sequencer Add an option to make the RTC timer the default sequencer timer. This becomes necessary for precise MIDI timing when the system timer runs at less than 1000 Hz. Signed-off-by: Clemens Ladisch --- sound/core/Kconfig | 12 ++++++++++++ sound/core/seq/seq.c | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 6ae1d2e24b4..48cf45cfd0b 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig @@ -99,6 +99,18 @@ config SND_RTCTIMER To compile this driver as a module, choose M here: the module will be called snd-rtctimer. +config SND_SEQ_RTCTIMER_DEFAULT + bool "Use RTC as default sequencer timer" + depends on SND_RTCTIMER && SND_SEQUENCER + default y + help + Say Y here to use the RTC timer as the default sequencer + timer. This is strongly recommended because it ensures + precise MIDI timing even when the system timer runs at less + than 1000 Hz. + + If in doubt, say Y. + config SND_VERBOSE_PRINTK bool "Verbose printk" depends on SND diff --git a/sound/core/seq/seq.c b/sound/core/seq/seq.c index 7449d2a6262..24644150f24 100644 --- a/sound/core/seq/seq.c +++ b/sound/core/seq/seq.c @@ -43,7 +43,13 @@ int seq_client_load[64] = {[0 ... 63] = -1}; int seq_default_timer_class = SNDRV_TIMER_CLASS_GLOBAL; int seq_default_timer_sclass = SNDRV_TIMER_SCLASS_NONE; int seq_default_timer_card = -1; -int seq_default_timer_device = SNDRV_TIMER_GLOBAL_SYSTEM; +int seq_default_timer_device = +#ifdef CONFIG_SND_SEQ_RTCTIMER_DEFAULT + SNDRV_TIMER_GLOBAL_RTC +#else + SNDRV_TIMER_GLOBAL_SYSTEM +#endif + ; int seq_default_timer_subdevice = 0; int seq_default_timer_resolution = 0; /* Hz */ -- cgit v1.2.3 From 821690cdc82e4090ef6f91947f76a231fad5cbb1 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier Date: Wed, 7 Sep 2005 13:28:14 +0200 Subject: [ALSA] Correct detection of iBook G4 1420Mhz soundcard PPC PMAC driver Here is a patch to correct detection of the soundcard on my iBook model (bought really recently). Without that fix, there were only andui in the headphone, and the mixer was totaly non functional. Signed-off-by: Takashi Iwai --- sound/ppc/pmac.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index c89e82eb06a..9774e568ee0 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -988,6 +988,7 @@ static int __init snd_pmac_detect(pmac_t *chip) case 0x33: case 0x29: case 0x24: + case 0x5c: chip->num_freqs = ARRAY_SIZE(tumbler_freqs); chip->model = PMAC_SNAPPER; chip->can_byte_swap = 0; /* FIXME: check this */ -- cgit v1.2.3 From ec9e1c5c9c7350cc8214f8b9c529f9678036d9a8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Sep 2005 13:29:22 +0200 Subject: [ALSA] hda-codec - Assign audio PCMS first HDA Codec driver,HDA Intel driver,HDA generic driver Assign audio PCMs first before modem PCMs. The modem stream is assigned up to device #6, to be consistent over different models. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.h | 1 + sound/pci/hda/hda_intel.c | 29 ++++++++++++++++++++++++++--- sound/pci/hda/hda_proc.c | 2 ++ sound/pci/hda/patch_si3054.c | 1 + 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 63a29a8a286..bb53bcf7674 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -505,6 +505,7 @@ struct hda_pcm_stream { struct hda_pcm { char *name; struct hda_pcm_stream stream[2]; + unsigned int is_modem; /* modem codec? */ }; /* codec information */ diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 96f9e872919..2098de7c567 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -164,7 +164,9 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; /* max buffer size - no h/w limit, you can increase as you like */ #define AZX_MAX_BUF_SIZE (1024*1024*1024) /* max number of PCM devics per card */ -#define AZX_MAX_PCMS 8 +#define AZX_MAX_AUDIO_PCMS 6 +#define AZX_MAX_MODEM_PCMS 2 +#define AZX_MAX_PCMS (AZX_MAX_AUDIO_PCMS + AZX_MAX_MODEM_PCMS) /* RIRB int mask: overrun[2], response[0] */ #define RIRB_INT_RESPONSE 0x01 @@ -1225,12 +1227,33 @@ static int __devinit azx_pcm_create(azx_t *chip) if ((err = snd_hda_build_pcms(chip->bus)) < 0) return err; + /* create audio PCMs */ pcm_dev = 0; list_for_each(p, &chip->bus->codec_list) { codec = list_entry(p, struct hda_codec, list); for (c = 0; c < codec->num_pcms; c++) { - if (pcm_dev >= AZX_MAX_PCMS) { - snd_printk(KERN_ERR SFX "Too many PCMs\n"); + if (codec->pcm_info[c].is_modem) + continue; /* create later */ + if (pcm_dev >= AZX_MAX_AUDIO_PCMS) { + snd_printk(KERN_ERR SFX "Too many audio PCMs\n"); + return -EINVAL; + } + err = create_codec_pcm(chip, codec, &codec->pcm_info[c], pcm_dev); + if (err < 0) + return err; + pcm_dev++; + } + } + + /* create modem PCMs */ + pcm_dev = AZX_MAX_AUDIO_PCMS; + list_for_each(p, &chip->bus->codec_list) { + codec = list_entry(p, struct hda_codec, list); + for (c = 0; c < codec->num_pcms; c++) { + if (! codec->pcm_info[c].is_modem) + continue; /* already created */ + if (pcm_dev >= AZX_MAX_MODEM_PCMS) { + snd_printk(KERN_ERR SFX "Too many modem PCMs\n"); return -EINVAL; } err = create_codec_pcm(chip, codec, &codec->pcm_info[c], pcm_dev); diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index de1217bd8e6..08f6a6efc5e 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c @@ -207,6 +207,8 @@ static void print_codec_info(snd_info_entry_t *entry, snd_info_buffer_t *buffer) snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id); snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id); snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id); + if (! codec->afg) + return; snd_iprintf(buffer, "Default PCM: "); print_pcm_caps(buffer, codec, codec->afg); snd_iprintf(buffer, "Default Amp-In caps: "); diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c index b0270d1b64c..c41fb9acdce 100644 --- a/sound/pci/hda/patch_si3054.c +++ b/sound/pci/hda/patch_si3054.c @@ -214,6 +214,7 @@ static int si3054_build_pcms(struct hda_codec *codec) info->name = "Si3054 Modem"; info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm; info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm; + info->is_modem = 1; return 0; } -- cgit v1.2.3 From df8db936e5e829ab3ff66346dbdf4033fa3ce588 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Sep 2005 13:38:19 +0200 Subject: [ALSA] Fix DocBook warnings PCM Midlevel,RawMidi Midlevel Fix DocBook warnings. Signed-off-by: Takashi Iwai --- sound/core/pcm_lib.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++-- sound/core/pcm_memory.c | 2 +- sound/core/pcm_native.c | 9 ++++ sound/core/rawmidi.c | 2 +- 4 files changed, 124 insertions(+), 6 deletions(-) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 0082914a7e3..0503980c23d 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -524,6 +524,9 @@ void snd_interval_mul(const snd_interval_t *a, const snd_interval_t *b, snd_inte /** * snd_interval_div - refine the interval value with division + * @a: dividend + * @b: divisor + * @c: quotient * * c = a / b * @@ -555,7 +558,11 @@ void snd_interval_div(const snd_interval_t *a, const snd_interval_t *b, snd_inte /** * snd_interval_muldivk - refine the interval value - * + * @a: dividend 1 + * @b: dividend 2 + * @k: divisor (as integer) + * @c: result + * * c = a * b / k * * Returns non-zero if the value is changed, zero if not changed. @@ -582,6 +589,10 @@ void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b, /** * snd_interval_mulkdiv - refine the interval value + * @a: dividend 1 + * @k: dividend 2 (as integer) + * @b: divisor + * @c: result * * c = a * k / b * @@ -618,6 +629,11 @@ void snd_interval_mulkdiv(const snd_interval_t *a, unsigned int k, /** * snd_interval_ratnum - refine the interval value + * @i: interval to refine + * @rats_count: number of ratnum_t + * @rats: ratnum_t array + * @nump: pointer to store the resultant numerator + * @denp: pointer to store the resultant denominator * * Returns non-zero if the value is changed, zero if not changed. */ @@ -715,6 +731,11 @@ int snd_interval_ratnum(snd_interval_t *i, /** * snd_interval_ratden - refine the interval value + * @i: interval to refine + * @rats_count: number of ratden_t + * @rats: ratden_t array + * @nump: pointer to store the resultant numerator + * @denp: pointer to store the resultant denominator * * Returns non-zero if the value is changed, zero if not changed. */ @@ -936,6 +957,11 @@ int snd_pcm_hw_rule_add(snd_pcm_runtime_t *runtime, unsigned int cond, /** * snd_pcm_hw_constraint_mask + * @runtime: PCM runtime instance + * @var: hw_params variable to apply the mask + * @mask: the bitmap mask + * + * Apply the constraint of the given bitmap mask to a mask parameter. */ int snd_pcm_hw_constraint_mask(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, u_int32_t mask) @@ -951,6 +977,11 @@ int snd_pcm_hw_constraint_mask(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t va /** * snd_pcm_hw_constraint_mask64 + * @runtime: PCM runtime instance + * @var: hw_params variable to apply the mask + * @mask: the 64bit bitmap mask + * + * Apply the constraint of the given bitmap mask to a mask parameter. */ int snd_pcm_hw_constraint_mask64(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, u_int64_t mask) @@ -967,6 +998,10 @@ int snd_pcm_hw_constraint_mask64(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t /** * snd_pcm_hw_constraint_integer + * @runtime: PCM runtime instance + * @var: hw_params variable to apply the integer constraint + * + * Apply the constraint of integer to an interval parameter. */ int snd_pcm_hw_constraint_integer(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var) { @@ -976,6 +1011,12 @@ int snd_pcm_hw_constraint_integer(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t /** * snd_pcm_hw_constraint_minmax + * @runtime: PCM runtime instance + * @var: hw_params variable to apply the range + * @min: the minimal value + * @max: the maximal value + * + * Apply the min/max range constraint to an interval parameter. */ int snd_pcm_hw_constraint_minmax(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, unsigned int min, unsigned int max) @@ -999,6 +1040,12 @@ static int snd_pcm_hw_rule_list(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_constraint_list + * @runtime: PCM runtime instance + * @cond: condition bits + * @var: hw_params variable to apply the list constraint + * @l: list + * + * Apply the list of constraints to an interval parameter. */ int snd_pcm_hw_constraint_list(snd_pcm_runtime_t *runtime, unsigned int cond, @@ -1027,6 +1074,10 @@ static int snd_pcm_hw_rule_ratnums(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_constraint_ratnums + * @runtime: PCM runtime instance + * @cond: condition bits + * @var: hw_params variable to apply the ratnums constraint + * @r: ratnums_t constriants */ int snd_pcm_hw_constraint_ratnums(snd_pcm_runtime_t *runtime, unsigned int cond, @@ -1054,6 +1105,10 @@ static int snd_pcm_hw_rule_ratdens(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_constraint_ratdens + * @runtime: PCM runtime instance + * @cond: condition bits + * @var: hw_params variable to apply the ratdens constraint + * @r: ratdens_t constriants */ int snd_pcm_hw_constraint_ratdens(snd_pcm_runtime_t *runtime, unsigned int cond, @@ -1079,6 +1134,10 @@ static int snd_pcm_hw_rule_msbits(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_constraint_msbits + * @runtime: PCM runtime instance + * @cond: condition bits + * @width: sample bits width + * @msbits: msbits width */ int snd_pcm_hw_constraint_msbits(snd_pcm_runtime_t *runtime, unsigned int cond, @@ -1101,6 +1160,10 @@ static int snd_pcm_hw_rule_step(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_constraint_step + * @runtime: PCM runtime instance + * @cond: condition bits + * @var: hw_params variable to apply the step constraint + * @step: step size */ int snd_pcm_hw_constraint_step(snd_pcm_runtime_t *runtime, unsigned int cond, @@ -1126,6 +1189,9 @@ static int snd_pcm_hw_rule_pow2(snd_pcm_hw_params_t *params, snd_pcm_hw_rule_t * /** * snd_pcm_hw_constraint_pow2 + * @runtime: PCM runtime instance + * @cond: condition bits + * @var: hw_params variable to apply the power-of-2 constraint */ int snd_pcm_hw_constraint_pow2(snd_pcm_runtime_t *runtime, unsigned int cond, @@ -1162,7 +1228,7 @@ static void _snd_pcm_hw_param_any(snd_pcm_hw_params_t *params, } #if 0 -/** +/* * snd_pcm_hw_param_any */ int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, @@ -1185,7 +1251,7 @@ void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params) } #if 0 -/** +/* * snd_pcm_hw_params_any * * Fill PARAMS with full configuration space boundaries @@ -1199,6 +1265,9 @@ int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) /** * snd_pcm_hw_param_value + * @params: the hw_params instance + * @var: parameter to retrieve + * @dir: pointer to the direction (-1,0,1) or NULL * * Return the value for field PAR if it's fixed in configuration space * defined by PARAMS. Return -EINVAL otherwise @@ -1228,6 +1297,9 @@ static int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params, /** * snd_pcm_hw_param_value_min + * @params: the hw_params instance + * @var: parameter to retrieve + * @dir: pointer to the direction (-1,0,1) or NULL * * Return the minimum value for field PAR. */ @@ -1251,6 +1323,9 @@ unsigned int snd_pcm_hw_param_value_min(const snd_pcm_hw_params_t *params, /** * snd_pcm_hw_param_value_max + * @params: the hw_params instance + * @var: parameter to retrieve + * @dir: pointer to the direction (-1,0,1) or NULL * * Return the maximum value for field PAR. */ @@ -1302,7 +1377,7 @@ int _snd_pcm_hw_param_setinteger(snd_pcm_hw_params_t *params, } #if 0 -/** +/* * snd_pcm_hw_param_setinteger * * Inside configuration space defined by PARAMS remove from PAR all @@ -1347,6 +1422,10 @@ static int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_param_first + * @pcm: PCM instance + * @params: the hw_params instance + * @var: parameter to retrieve + * @dir: pointer to the direction (-1,0,1) or NULL * * Inside configuration space defined by PARAMS remove from PAR all * values > minimum. Reduce configuration space accordingly. @@ -1388,6 +1467,10 @@ static int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_param_last + * @pcm: PCM instance + * @params: the hw_params instance + * @var: parameter to retrieve + * @dir: pointer to the direction (-1,0,1) or NULL * * Inside configuration space defined by PARAMS remove from PAR all * values < maximum. Reduce configuration space accordingly. @@ -1439,6 +1522,11 @@ int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_param_min + * @pcm: PCM instance + * @params: the hw_params instance + * @var: parameter to retrieve + * @val: minimal value + * @dir: pointer to the direction (-1,0,1) or NULL * * Inside configuration space defined by PARAMS remove from PAR all * values < VAL. Reduce configuration space accordingly. @@ -1494,6 +1582,11 @@ static int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_param_max + * @pcm: PCM instance + * @params: the hw_params instance + * @var: parameter to retrieve + * @val: maximal value + * @dir: pointer to the direction (-1,0,1) or NULL * * Inside configuration space defined by PARAMS remove from PAR all * values >= VAL + 1. Reduce configuration space accordingly. @@ -1565,6 +1658,11 @@ int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_param_set + * @pcm: PCM instance + * @params: the hw_params instance + * @var: parameter to retrieve + * @val: value to set + * @dir: pointer to the direction (-1,0,1) or NULL * * Inside configuration space defined by PARAMS remove from PAR all * values != VAL. Reduce configuration space accordingly. @@ -1599,6 +1697,10 @@ static int _snd_pcm_hw_param_mask(snd_pcm_hw_params_t *params, /** * snd_pcm_hw_param_mask + * @pcm: PCM instance + * @params: the hw_params instance + * @var: parameter to retrieve + * @val: mask to apply * * Inside configuration space defined by PARAMS remove from PAR all values * not contained in MASK. Reduce configuration space accordingly. @@ -1671,6 +1773,11 @@ static int boundary_nearer(int min, int mindir, /** * snd_pcm_hw_param_near + * @pcm: PCM instance + * @params: the hw_params instance + * @var: parameter to retrieve + * @best: value to set + * @dir: pointer to the direction (-1,0,1) or NULL * * Inside configuration space defined by PARAMS set PAR to the available value * nearest to VAL. Reduce configuration space accordingly. @@ -1747,6 +1854,8 @@ int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, /** * snd_pcm_hw_param_choose + * @pcm: PCM instance + * @params: the hw_params instance * * Choose one configuration from configuration space defined by PARAMS * The configuration chosen is that obtained fixing in this order: diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index 9a174fb9656..5df76738470 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -244,7 +244,7 @@ int snd_pcm_lib_preallocate_pages(snd_pcm_substream_t *substream, /** * snd_pcm_lib_preallocate_pages_for_all - pre-allocation for continous memory type (all substreams) - * @substream: the pcm substream instance + * @pcm: the pcm instance * @type: DMA type (SNDRV_DMA_TYPE_*) * @data: DMA type dependant data * @size: the requested pre-allocation size in bytes diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 03c17159dd8..b829a272755 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -859,6 +859,7 @@ static struct action_ops snd_pcm_action_start = { /** * snd_pcm_start + * @substream: the PCM substream instance * * Start all linked streams. */ @@ -908,6 +909,8 @@ static struct action_ops snd_pcm_action_stop = { /** * snd_pcm_stop + * @substream: the PCM substream instance + * @state: PCM state after stopping the stream * * Try to stop all running streams in the substream group. * The state of each stream is changed to the given value after that unconditionally. @@ -919,6 +922,7 @@ int snd_pcm_stop(snd_pcm_substream_t *substream, int state) /** * snd_pcm_drain_done + * @substream: the PCM substream * * Stop the DMA only when the given stream is playback. * The state is changed to SETUP. @@ -1040,6 +1044,7 @@ static struct action_ops snd_pcm_action_suspend = { /** * snd_pcm_suspend + * @substream: the PCM substream * * Trigger SUSPEND to all linked streams. * After this call, all streams are changed to SUSPENDED state. @@ -1057,6 +1062,7 @@ int snd_pcm_suspend(snd_pcm_substream_t *substream) /** * snd_pcm_suspend_all + * @pcm: the PCM instance * * Trigger SUSPEND to all substreams in the given pcm. * After this call, all streams are changed to SUSPENDED state. @@ -1272,6 +1278,9 @@ static struct action_ops snd_pcm_action_prepare = { /** * snd_pcm_prepare + * @substream: the PCM substream instance + * + * Prepare the PCM substream to be triggerable. */ int snd_pcm_prepare(snd_pcm_substream_t *substream) { diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index d705ec79429..4f4b4101b2f 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1109,7 +1109,7 @@ int snd_rawmidi_transmit_ack(snd_rawmidi_substream_t * substream, int count) /** * snd_rawmidi_transmit - copy from the buffer to the device * @substream: the rawmidi substream - * @buf: the buffer pointer + * @buffer: the buffer pointer * @count: the data size to transfer * * Copies data from the buffer to the device and advances the pointer. -- cgit v1.2.3 From 8cdfd2519c6c9a1e6057dc5970b2542b35895738 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Sep 2005 14:08:11 +0200 Subject: [ALSA] Remove superfluous PCI ID definitions CS46xx driver,EMU10K1/EMU10K2 driver,PCM Midlevel,Trident driver YMFPCI driver,BT87x driver,CMIPCI driver,CS4281 driver ENS1370/1+ driver,ES1938 driver,ES1968 driver,Intel8x0 driver Intel8x0-modem driver,Maestro3 driver,RME32 driver,RME96 driver SonicVibes driver,VIA82xx driver,ALI5451 driver,ICE1712 driver ICE1724 driver,NM256 driver,RME HDSP driver,RME9652 driver Remove superfluous PCI ID definitions. Signed-off-by: Takashi Iwai --- include/sound/cs46xx.h | 13 -------- include/sound/emu10k1.h | 7 ----- include/sound/pcm.h | 1 + include/sound/trident.h | 17 ----------- include/sound/ymfpci.h | 22 -------------- sound/pci/ali5451/ali5451.c | 10 +------ sound/pci/bt87x.c | 10 ------- sound/pci/cmipci.c | 26 ---------------- sound/pci/cs4281.c | 11 ------- sound/pci/cs46xx/cs46xx_lib.c | 11 ------- sound/pci/ens1370.c | 7 ----- sound/pci/es1938.c | 7 ----- sound/pci/es1968.c | 19 ------------ sound/pci/ice1712/ice1712.c | 6 ---- sound/pci/ice1712/ice1724.c | 6 ---- sound/pci/intel8x0.c | 70 +++++-------------------------------------- sound/pci/intel8x0m.c | 61 +++++-------------------------------- sound/pci/maestro3.c | 29 ------------------ sound/pci/nm256/nm256.c | 15 ---------- sound/pci/rme32.c | 14 --------- sound/pci/rme96.c | 19 ------------ sound/pci/rme9652/hdsp.c | 7 ----- sound/pci/rme9652/hdspm.c | 12 -------- sound/pci/rme9652/rme9652.c | 7 ----- sound/pci/sonicvibes.c | 7 ----- sound/pci/via82xx.c | 8 ----- 26 files changed, 17 insertions(+), 405 deletions(-) diff --git a/include/sound/cs46xx.h b/include/sound/cs46xx.h index 9b94510eda6..5821db8ffb9 100644 --- a/include/sound/cs46xx.h +++ b/include/sound/cs46xx.h @@ -29,19 +29,6 @@ #include "ac97_codec.h" #include "cs46xx_dsp_spos.h" -#ifndef PCI_VENDOR_ID_CIRRUS -#define PCI_VENDOR_ID_CIRRUS 0x1013 -#endif -#ifndef PCI_DEVICE_ID_CIRRUS_4610 -#define PCI_DEVICE_ID_CIRRUS_4610 0x6001 -#endif -#ifndef PCI_DEVICE_ID_CIRRUS_4612 -#define PCI_DEVICE_ID_CIRRUS_4612 0x6003 -#endif -#ifndef PCI_DEVICE_ID_CIRRUS_4615 -#define PCI_DEVICE_ID_CIRRUS_4615 0x6004 -#endif - /* * Direct registers */ diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 4e3993dfcef..67bf3f18e96 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -35,13 +35,6 @@ #include #include -#ifndef PCI_VENDOR_ID_CREATIVE -#define PCI_VENDOR_ID_CREATIVE 0x1102 -#endif -#ifndef PCI_DEVICE_ID_CREATIVE_EMU10K1 -#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002 -#endif - /* ------------------- DEFINES -------------------- */ #define EMUPAGESIZE 4096 diff --git a/include/sound/pcm.h b/include/sound/pcm.h index d6361dab037..7a7f7287288 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -910,6 +910,7 @@ int snd_pcm_format_big_endian(snd_pcm_format_t format); * Returns 1 if the given PCM format is CPU-endian, 0 if * opposite, or a negative error code if endian not specified. */ +int snd_pcm_format_cpu_endian(snd_pcm_format_t format); #ifdef SNDRV_LITTLE_ENDIAN #define snd_pcm_format_cpu_endian(format) snd_pcm_format_little_endian(format) #else diff --git a/include/sound/trident.h b/include/sound/trident.h index f5254ec36e6..a408d392505 100644 --- a/include/sound/trident.h +++ b/include/sound/trident.h @@ -33,23 +33,6 @@ //#include "ainstr_gf1.h" #include "ainstr_simple.h" -#ifndef PCI_VENDOR_ID_TRIDENT -#define PCI_VENDOR_ID_TRIDENT 0x1023 -#endif -#ifndef PCI_DEVICE_ID_TRIDENT_4DWAVE_DX -#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000 -#endif -#ifndef PCI_DEVICE_ID_TRIDENT_4DWAVE_NX -#define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001 -#endif - -#ifndef PCI_VENDOR_ID_SI -#define PCI_VENDOR_ID_SI 0x1039 -#endif -#ifndef PCI_DEVICE_ID_SI_7018 -#define PCI_DEVICE_ID_SI_7018 0x7018 -#endif - #define TRIDENT_DEVICE_ID_DX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_DX) #define TRIDENT_DEVICE_ID_NX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_NX) #define TRIDENT_DEVICE_ID_SI7018 ((PCI_VENDOR_ID_SI<<16)|PCI_DEVICE_ID_SI_7018) diff --git a/include/sound/ymfpci.h b/include/sound/ymfpci.h index 9a3c1e6c820..c3bccbfd8d4 100644 --- a/include/sound/ymfpci.h +++ b/include/sound/ymfpci.h @@ -28,28 +28,6 @@ #include "timer.h" #include -#ifndef PCI_VENDOR_ID_YAMAHA -#define PCI_VENDOR_ID_YAMAHA 0x1073 -#endif -#ifndef PCI_DEVICE_ID_YAMAHA_724 -#define PCI_DEVICE_ID_YAMAHA_724 0x0004 -#endif -#ifndef PCI_DEVICE_ID_YAMAHA_724F -#define PCI_DEVICE_ID_YAMAHA_724F 0x000d -#endif -#ifndef PCI_DEVICE_ID_YAMAHA_740 -#define PCI_DEVICE_ID_YAMAHA_740 0x000a -#endif -#ifndef PCI_DEVICE_ID_YAMAHA_740C -#define PCI_DEVICE_ID_YAMAHA_740C 0x000c -#endif -#ifndef PCI_DEVICE_ID_YAMAHA_744 -#define PCI_DEVICE_ID_YAMAHA_744 0x0010 -#endif -#ifndef PCI_DEVICE_ID_YAMAHA_754 -#define PCI_DEVICE_ID_YAMAHA_754 0x0012 -#endif - /* * Direct registers */ diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 4943299cf13..7f835d46dc1 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -78,15 +78,7 @@ MODULE_PARM_DESC(spdif, "Support SPDIF I/O"); * Constants definition */ -#ifndef PCI_VENDOR_ID_ALI -#define PCI_VENDOR_ID_ALI 0x10b9 -#endif - -#ifndef PCI_DEVICE_ID_ALI_5451 -#define PCI_DEVICE_ID_ALI_5451 0x5451 -#endif - -#define DEVICE_ID_ALI5451 ((PCI_VENDOR_ID_ALI<<16)|PCI_DEVICE_ID_ALI_5451) +#define DEVICE_ID_ALI5451 ((PCI_VENDOR_ID_AL<<16)|PCI_DEVICE_ID_AL_M5451) #define ALI_CHANNELS 32 diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index c5557eaf3e2..2d124250bee 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -59,16 +59,6 @@ module_param(load_all, bool, 0444); MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards"); -#ifndef PCI_VENDOR_ID_BROOKTREE -#define PCI_VENDOR_ID_BROOKTREE 0x109e -#endif -#ifndef PCI_DEVICE_ID_BROOKTREE_878 -#define PCI_DEVICE_ID_BROOKTREE_878 0x0878 -#endif -#ifndef PCI_DEVICE_ID_BROOKTREE_879 -#define PCI_DEVICE_ID_BROOKTREE_879 0x0879 -#endif - /* register offsets */ #define REG_INT_STAT 0x100 /* interrupt status */ #define REG_INT_MASK 0x104 /* interrupt mask */ diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index b098b51099c..97ad90d47bc 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -79,13 +79,6 @@ module_param_array(joystick_port, int, NULL, 0444); MODULE_PARM_DESC(joystick_port, "Joystick port address."); #endif -#ifndef PCI_DEVICE_ID_CMEDIA_CM8738 -#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111 -#endif -#ifndef PCI_DEVICE_ID_CMEDIA_CM8738B -#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112 -#endif - /* * CM8x38 registers definition */ @@ -347,25 +340,6 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address."); #define CM_EXTENT_SYNTH 0x4 -/* - * pci ids - */ -#ifndef PCI_VENDOR_ID_CMEDIA -#define PCI_VENDOR_ID_CMEDIA 0x13F6 -#endif -#ifndef PCI_DEVICE_ID_CMEDIA_CM8338A -#define PCI_DEVICE_ID_CMEDIA_CM8338A 0x0100 -#endif -#ifndef PCI_DEVICE_ID_CMEDIA_CM8338B -#define PCI_DEVICE_ID_CMEDIA_CM8338B 0x0101 -#endif -#ifndef PCI_DEVICE_ID_CMEDIA_CM8738 -#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111 -#endif -#ifndef PCI_DEVICE_ID_CMEDIA_CM8738B -#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112 -#endif - /* * channels for playback / capture */ diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index c7a370d4f92..e3e03028c72 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -56,17 +56,6 @@ MODULE_PARM_DESC(enable, "Enable CS4281 soundcard."); module_param_array(dual_codec, bool, NULL, 0444); MODULE_PARM_DESC(dual_codec, "Secondary Codec ID (0 = disabled)."); -/* - * - */ - -#ifndef PCI_VENDOR_ID_CIRRUS -#define PCI_VENDOR_ID_CIRRUS 0x1013 -#endif -#ifndef PCI_DEVICE_ID_CIRRUS_4281 -#define PCI_DEVICE_ID_CIRRUS_4281 0x6005 -#endif - /* * Direct registers */ diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 4b052158ee3..fd9c82c07b3 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -3524,17 +3524,6 @@ static void amp_voyetra_4294(cs46xx_t *chip, int change) #endif -/* - * piix4 pci ids - */ -#ifndef PCI_VENDOR_ID_INTEL -#define PCI_VENDOR_ID_INTEL 0x8086 -#endif /* PCI_VENDOR_ID_INTEL */ - -#ifndef PCI_DEVICE_ID_INTEL_82371AB_3 -#define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113 -#endif /* PCI_DEVICE_ID_INTEL_82371AB_3 */ - /* * Handle the CLKRUN on a thinkpad. We must disable CLKRUN support * whenever we need to beat on the chip. diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index f06b95f41a1..e2c3a375855 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -100,13 +100,6 @@ MODULE_PARM_DESC(joystick, "Enable joystick."); #endif #endif /* SUPPORT_JOYSTICK */ -#ifndef PCI_DEVICE_ID_ENSONIQ_CT5880 -#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880 -#endif -#ifndef PCI_DEVICE_ID_ENSONIQ_ES1371 -#define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371 -#endif - /* ES1371 chip ID */ /* This is a little confusing because all ES1371 compatible chips have the same DEVICE_ID, the only thing differentiating them is the REV_ID field. diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index b492777bc30..b3f78a5bb64 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -76,13 +76,6 @@ MODULE_SUPPORTED_DEVICE("{{ESS,ES1938}," #define SUPPORT_JOYSTICK 1 #endif -#ifndef PCI_VENDOR_ID_ESS -#define PCI_VENDOR_ID_ESS 0x125d -#endif -#ifndef PCI_DEVICE_ID_ESS_ES1938 -#define PCI_DEVICE_ID_ESS_ES1938 0x1969 -#endif - static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 9d7a2878393..8cfe80fcd77 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -160,25 +160,6 @@ MODULE_PARM_DESC(joystick, "Enable joystick."); #endif -/* PCI Dev ID's */ - -#ifndef PCI_VENDOR_ID_ESS -#define PCI_VENDOR_ID_ESS 0x125D -#endif - -#define PCI_VENDOR_ID_ESS_OLD 0x1285 /* Platform Tech, the people the ESS - was bought form */ - -#ifndef PCI_DEVICE_ID_ESS_M2E -#define PCI_DEVICE_ID_ESS_M2E 0x1978 -#endif -#ifndef PCI_DEVICE_ID_ESS_M2 -#define PCI_DEVICE_ID_ESS_M2 0x1968 -#endif -#ifndef PCI_DEVICE_ID_ESS_M1 -#define PCI_DEVICE_ID_ESS_M1 0x0100 -#endif - #define NR_APUS 64 #define NR_APU_REGS 16 diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index b97f50d10ba..f4616053150 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -100,12 +100,6 @@ MODULE_PARM_DESC(cs8427_timeout, "Define reset timeout for cs8427 chip in msec r module_param_array(model, charp, NULL, 0444); MODULE_PARM_DESC(model, "Use the given board model."); -#ifndef PCI_VENDOR_ID_ICE -#define PCI_VENDOR_ID_ICE 0x1412 -#endif -#ifndef PCI_DEVICE_ID_ICE_1712 -#define PCI_DEVICE_ID_ICE_1712 0x1712 -#endif static struct pci_device_id snd_ice1712_ids[] = { { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_ICE_1712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICE1712 */ diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index c7af5e5fee1..78fc05c0800 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -83,12 +83,6 @@ MODULE_PARM_DESC(enable, "Enable ICE1724 soundcard."); module_param_array(model, charp, NULL, 0444); MODULE_PARM_DESC(model, "Use the given board model."); -#ifndef PCI_VENDOR_ID_ICE -#define PCI_VENDOR_ID_ICE 0x1412 -#endif -#ifndef PCI_DEVICE_ID_VT1724 -#define PCI_DEVICE_ID_VT1724 0x1724 -#endif /* Both VT1720 and VT1724 have the same PCI IDs */ static struct pci_device_id snd_vt1724_ids[] = { diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index d846cbfaa31..b96f87e7339 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -94,62 +94,6 @@ MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 c /* * Direct registers */ - -#ifndef PCI_DEVICE_ID_INTEL_82801 -#define PCI_DEVICE_ID_INTEL_82801 0x2415 -#endif -#ifndef PCI_DEVICE_ID_INTEL_82901 -#define PCI_DEVICE_ID_INTEL_82901 0x2425 -#endif -#ifndef PCI_DEVICE_ID_INTEL_82801BA -#define PCI_DEVICE_ID_INTEL_82801BA 0x2445 -#endif -#ifndef PCI_DEVICE_ID_INTEL_440MX -#define PCI_DEVICE_ID_INTEL_440MX 0x7195 -#endif -#ifndef PCI_DEVICE_ID_INTEL_ICH3 -#define PCI_DEVICE_ID_INTEL_ICH3 0x2485 -#endif -#ifndef PCI_DEVICE_ID_INTEL_ICH4 -#define PCI_DEVICE_ID_INTEL_ICH4 0x24c5 -#endif -#ifndef PCI_DEVICE_ID_INTEL_ICH5 -#define PCI_DEVICE_ID_INTEL_ICH5 0x24d5 -#endif -#ifndef PCI_DEVICE_ID_INTEL_ESB_5 -#define PCI_DEVICE_ID_INTEL_ESB_5 0x25a6 -#endif -#ifndef PCI_DEVICE_ID_INTEL_ICH6_18 -#define PCI_DEVICE_ID_INTEL_ICH6_18 0x266e -#endif -#ifndef PCI_DEVICE_ID_INTEL_ICH7_20 -#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de -#endif -#ifndef PCI_DEVICE_ID_INTEL_ESB2_14 -#define PCI_DEVICE_ID_INTEL_ESB2_14 0x2698 -#endif -#ifndef PCI_DEVICE_ID_SI_7012 -#define PCI_DEVICE_ID_SI_7012 0x7012 -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_MCP_AUDIO -#define PCI_DEVICE_ID_NVIDIA_MCP_AUDIO 0x01b1 -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_CK804_AUDIO -#define PCI_DEVICE_ID_NVIDIA_CK804_AUDIO 0x0059 -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO -#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_CK8_AUDIO -#define PCI_DEVICE_ID_NVIDIA_CK8_AUDIO 0x008a -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO -#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO -#define PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO 0x00ea -#endif - enum { DEVICE_INTEL, DEVICE_INTEL_ICH4, DEVICE_SIS, DEVICE_ALI, DEVICE_NFORCE }; #define ICHREG(x) ICH_REG_##x @@ -2801,19 +2745,19 @@ static struct shortname_table { unsigned int id; const char *s; } shortnames[] __devinitdata = { - { PCI_DEVICE_ID_INTEL_82801, "Intel 82801AA-ICH" }, - { PCI_DEVICE_ID_INTEL_82901, "Intel 82901AB-ICH0" }, - { PCI_DEVICE_ID_INTEL_82801BA, "Intel 82801BA-ICH2" }, + { PCI_DEVICE_ID_INTEL_82801AA_5, "Intel 82801AA-ICH" }, + { PCI_DEVICE_ID_INTEL_82801AB_5, "Intel 82901AB-ICH0" }, + { PCI_DEVICE_ID_INTEL_82801BA_4, "Intel 82801BA-ICH2" }, { PCI_DEVICE_ID_INTEL_440MX, "Intel 440MX" }, - { PCI_DEVICE_ID_INTEL_ICH3, "Intel 82801CA-ICH3" }, - { PCI_DEVICE_ID_INTEL_ICH4, "Intel 82801DB-ICH4" }, - { PCI_DEVICE_ID_INTEL_ICH5, "Intel ICH5" }, + { PCI_DEVICE_ID_INTEL_82801CA_5, "Intel 82801CA-ICH3" }, + { PCI_DEVICE_ID_INTEL_82801DB_5, "Intel 82801DB-ICH4" }, + { PCI_DEVICE_ID_INTEL_82801EB_5, "Intel ICH5" }, { PCI_DEVICE_ID_INTEL_ESB_5, "Intel 6300ESB" }, { PCI_DEVICE_ID_INTEL_ICH6_18, "Intel ICH6" }, { PCI_DEVICE_ID_INTEL_ICH7_20, "Intel ICH7" }, { PCI_DEVICE_ID_INTEL_ESB2_14, "Intel ESB2" }, { PCI_DEVICE_ID_SI_7012, "SiS SI7012" }, - { PCI_DEVICE_ID_NVIDIA_MCP_AUDIO, "NVidia nForce" }, + { PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO, "NVidia nForce" }, { PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO, "NVidia nForce2" }, { PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO, "NVidia nForce3" }, { PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO, "NVidia CK8S" }, diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index bb758c77d21..282b4bd67c3 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -73,51 +73,6 @@ MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect)."); /* * Direct registers */ - -#ifndef PCI_DEVICE_ID_INTEL_82801_6 -#define PCI_DEVICE_ID_INTEL_82801_6 0x2416 -#endif -#ifndef PCI_DEVICE_ID_INTEL_82901_6 -#define PCI_DEVICE_ID_INTEL_82901_6 0x2426 -#endif -#ifndef PCI_DEVICE_ID_INTEL_82801BA_6 -#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2446 -#endif -#ifndef PCI_DEVICE_ID_INTEL_440MX_6 -#define PCI_DEVICE_ID_INTEL_440MX_6 0x7196 -#endif -#ifndef PCI_DEVICE_ID_INTEL_ICH3_6 -#define PCI_DEVICE_ID_INTEL_ICH3_6 0x2486 -#endif -#ifndef PCI_DEVICE_ID_INTEL_ICH4_6 -#define PCI_DEVICE_ID_INTEL_ICH4_6 0x24c6 -#endif -#ifndef PCI_DEVICE_ID_INTEL_ICH5_6 -#define PCI_DEVICE_ID_INTEL_ICH5_6 0x24d6 -#endif -#ifndef PCI_DEVICE_ID_INTEL_ICH6_6 -#define PCI_DEVICE_ID_INTEL_ICH6_6 0x266d -#endif -#ifndef PCI_DEVICE_ID_INTEL_ICH7_6 -#define PCI_DEVICE_ID_INTEL_ICH7_6 0x27dd -#endif -#ifndef PCI_DEVICE_ID_SI_7013 -#define PCI_DEVICE_ID_SI_7013 0x7013 -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_MCP_MODEM -#define PCI_DEVICE_ID_NVIDIA_MCP_MODEM 0x01c1 -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_MCP2_MODEM -#define PCI_DEVICE_ID_NVIDIA_MCP2_MODEM 0x0069 -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM -#define PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM 0x0089 -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_MCP3_MODEM -#define PCI_DEVICE_ID_NVIDIA_MCP3_MODEM 0x00d9 -#endif - - enum { DEVICE_INTEL, DEVICE_SIS, DEVICE_ALI, DEVICE_NFORCE }; #define ICHREG(x) ICH_REG_##x @@ -1283,18 +1238,18 @@ static struct shortname_table { unsigned int id; const char *s; } shortnames[] __devinitdata = { - { PCI_DEVICE_ID_INTEL_82801_6, "Intel 82801AA-ICH" }, - { PCI_DEVICE_ID_INTEL_82901_6, "Intel 82901AB-ICH0" }, + { PCI_DEVICE_ID_INTEL_82801AA_6, "Intel 82801AA-ICH" }, + { PCI_DEVICE_ID_INTEL_82801AB_6, "Intel 82901AB-ICH0" }, { PCI_DEVICE_ID_INTEL_82801BA_6, "Intel 82801BA-ICH2" }, { PCI_DEVICE_ID_INTEL_440MX_6, "Intel 440MX" }, - { PCI_DEVICE_ID_INTEL_ICH3_6, "Intel 82801CA-ICH3" }, - { PCI_DEVICE_ID_INTEL_ICH4_6, "Intel 82801DB-ICH4" }, - { PCI_DEVICE_ID_INTEL_ICH5_6, "Intel ICH5" }, - { PCI_DEVICE_ID_INTEL_ICH6_6, "Intel ICH6" }, - { PCI_DEVICE_ID_INTEL_ICH7_6, "Intel ICH7" }, + { PCI_DEVICE_ID_INTEL_82801CA_6, "Intel 82801CA-ICH3" }, + { PCI_DEVICE_ID_INTEL_82801DB_6, "Intel 82801DB-ICH4" }, + { PCI_DEVICE_ID_INTEL_82801EB_6, "Intel ICH5" }, + { PCI_DEVICE_ID_INTEL_ICH6_17, "Intel ICH6" }, + { PCI_DEVICE_ID_INTEL_ICH7_19, "Intel ICH7" }, { 0x7446, "AMD AMD768" }, { PCI_DEVICE_ID_SI_7013, "SiS SI7013" }, - { PCI_DEVICE_ID_NVIDIA_MCP_MODEM, "NVidia nForce" }, + { PCI_DEVICE_ID_NVIDIA_MCP1_MODEM, "NVidia nForce" }, { PCI_DEVICE_ID_NVIDIA_MCP2_MODEM, "NVidia nForce2" }, { PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM, "NVidia nForce2s" }, { PCI_DEVICE_ID_NVIDIA_MCP3_MODEM, "NVidia nForce3" }, diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 39b5e7db154..7b85a472292 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -872,35 +872,6 @@ struct snd_m3 { /* * pci ids */ - -#ifndef PCI_VENDOR_ID_ESS -#define PCI_VENDOR_ID_ESS 0x125D -#endif -#ifndef PCI_DEVICE_ID_ESS_ALLEGRO_1 -#define PCI_DEVICE_ID_ESS_ALLEGRO_1 0x1988 -#endif -#ifndef PCI_DEVICE_ID_ESS_ALLEGRO -#define PCI_DEVICE_ID_ESS_ALLEGRO 0x1989 -#endif -#ifndef PCI_DEVICE_ID_ESS_CANYON3D_2LE -#define PCI_DEVICE_ID_ESS_CANYON3D_2LE 0x1990 -#endif -#ifndef PCI_DEVICE_ID_ESS_CANYON3D_2 -#define PCI_DEVICE_ID_ESS_CANYON3D_2 0x1992 -#endif -#ifndef PCI_DEVICE_ID_ESS_MAESTRO3 -#define PCI_DEVICE_ID_ESS_MAESTRO3 0x1998 -#endif -#ifndef PCI_DEVICE_ID_ESS_MAESTRO3_1 -#define PCI_DEVICE_ID_ESS_MAESTRO3_1 0x1999 -#endif -#ifndef PCI_DEVICE_ID_ESS_MAESTRO3_HW -#define PCI_DEVICE_ID_ESS_MAESTRO3_HW 0x199a -#endif -#ifndef PCI_DEVICE_ID_ESS_MAESTRO3_2 -#define PCI_DEVICE_ID_ESS_MAESTRO3_2 0x199b -#endif - static struct pci_device_id snd_m3_ids[] = { {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO_1, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 24f146b6eba..542b58e4bf4 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -259,21 +259,6 @@ struct snd_nm256 { /* * PCI ids */ - -#ifndef PCI_VENDOR_ID_NEOMAGIC -#define PCI_VENDOR_ID_NEOMEGIC 0x10c8 -#endif -#ifndef PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO -#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005 -#endif -#ifndef PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO -#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006 -#endif -#ifndef PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO -#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016 -#endif - - static struct pci_device_id snd_nm256_ids[] = { {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index cfb5f44b2d4..a511de5a385 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -192,20 +192,6 @@ MODULE_SUPPORTED_DEVICE("{{RME,Digi32}," "{RME,Digi32/8}," "{RME,Digi32 PRO}}"); #define RME32_PRO_REVISION_WITH_8414 150 -/* PCI vendor/device ID's */ -#ifndef PCI_VENDOR_ID_XILINX_RME -# define PCI_VENDOR_ID_XILINX_RME 0xea60 -#endif -#ifndef PCI_DEVICE_ID_DIGI32 -# define PCI_DEVICE_ID_DIGI32 0x9896 -#endif -#ifndef PCI_DEVICE_ID_DIGI32_PRO -# define PCI_DEVICE_ID_DIGI32_PRO 0x9897 -#endif -#ifndef PCI_DEVICE_ID_DIGI32_8 -# define PCI_DEVICE_ID_DIGI32_8 0x9898 -#endif - typedef struct snd_rme32 { spinlock_t lock; int irq; diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 2da33138fa4..6653c21bfa0 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -200,25 +200,6 @@ MODULE_PARM_DESC(enable, "Enable RME Digi96 soundcard."); #define RME96_AD1852_VOL_BITS 14 #define RME96_AD1855_VOL_BITS 10 -/* - * PCI vendor/device ids, could in the future be defined in , - * therefore #ifndef is used. - */ -#ifndef PCI_VENDOR_ID_XILINX -#define PCI_VENDOR_ID_XILINX 0x10ee -#endif -#ifndef PCI_DEVICE_ID_DIGI96 -#define PCI_DEVICE_ID_DIGI96 0x3fc0 -#endif -#ifndef PCI_DEVICE_ID_DIGI96_8 -#define PCI_DEVICE_ID_DIGI96_8 0x3fc1 -#endif -#ifndef PCI_DEVICE_ID_DIGI96_8_PRO -#define PCI_DEVICE_ID_DIGI96_8_PRO 0x3fc2 -#endif -#ifndef PCI_DEVICE_ID_DIGI96_8_PAD_OR_PST -#define PCI_DEVICE_ID_DIGI96_8_PAD_OR_PST 0x3fc3 -#endif typedef struct snd_rme96 { spinlock_t lock; diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index e4a90396912..e456ccaaaf6 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -370,13 +370,6 @@ MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP}," #define UNITY_GAIN 32768 #define MINUS_INFINITY_GAIN 0 -#ifndef PCI_VENDOR_ID_XILINX -#define PCI_VENDOR_ID_XILINX 0x10ee -#endif -#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP -#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5 -#endif - /* the size of a substream (1 mono data stream) */ #define HDSP_CHANNEL_BUFFER_SAMPLES (16*1024) diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 5d786d113b2..7c67c028691 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -301,18 +301,6 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}"); #define UNITY_GAIN 32768 /* = 65536/2 */ #define MINUS_INFINITY_GAIN 0 -/* PCI info */ -#ifndef PCI_VENDOR_ID_XILINX -#define PCI_VENDOR_ID_XILINX 0x10ee -#endif -#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP -#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5 -#endif -#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI -#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6 -#endif - - /* Number of channels for different Speed Modes */ #define MADI_SS_CHANNELS 64 #define MADI_DS_CHANNELS 32 diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index 8ee4d6fd6ea..da317e8c085 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -120,13 +120,6 @@ MODULE_SUPPORTED_DEVICE("{{RME,Hammerfall}," #define RME9652_REV15_buf_pos(x) ((((x)&0xE0000000)>>26)|((x)&RME9652_buf_pos)) -#ifndef PCI_VENDOR_ID_XILINX -#define PCI_VENDOR_ID_XILINX 0x10ee -#endif -#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL -#define PCI_DEVICE_ID_XILINX_HAMMERFALL 0x3fc4 -#endif - /* amount of io space we remap for register access. i'm not sure we even need this much, but 1K is nice round number :) */ diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 60ecb2bdb65..3d431390c1c 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -50,13 +50,6 @@ MODULE_SUPPORTED_DEVICE("{{S3,SonicVibes PCI}}"); #define SUPPORT_JOYSTICK 1 #endif -#ifndef PCI_VENDOR_ID_S3 -#define PCI_VENDOR_ID_S3 0x5333 -#endif -#ifndef PCI_DEVICE_ID_S3_SONICVIBES -#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00 -#endif - static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 56c6e52d726..c7bddfb9fb6 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -104,14 +104,6 @@ module_param_array(dxs_support, int, NULL, 0444); MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); -/* pci ids */ -#ifndef PCI_DEVICE_ID_VIA_82C686_5 -#define PCI_DEVICE_ID_VIA_82C686_5 0x3058 -#endif -#ifndef PCI_DEVICE_ID_VIA_8233_5 -#define PCI_DEVICE_ID_VIA_8233_5 0x3059 -#endif - /* revision numbers for via686 */ #define VIA_REV_686_A 0x10 #define VIA_REV_686_B 0x11 -- cgit v1.2.3 From 0dd119f703d50759f0835f342e385f82cbf8b89e Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Wed, 7 Sep 2005 14:28:33 +0200 Subject: [ALSA] pci_find_device remove Memalloc module,CS46xx driver,VIA82xx driver,ALI5451 driver au88x0 driver Replace pci_find_device() with pci_get_device() and pci_dev_put(). Signed-off-by: Jiri Slaby Signed-off-by: Takashi Iwai --- include/sound/cs46xx.h | 1 - sound/core/memalloc.c | 3 ++- sound/pci/ali5451/ali5451.c | 16 +++++++++------- sound/pci/au88x0/au88x0.c | 26 ++++++++++++++++---------- sound/pci/cs46xx/cs46xx_lib.c | 13 +++++++++---- sound/pci/via82xx.c | 3 ++- 6 files changed, 38 insertions(+), 24 deletions(-) diff --git a/include/sound/cs46xx.h b/include/sound/cs46xx.h index 5821db8ffb9..b0c0e192eb5 100644 --- a/include/sound/cs46xx.h +++ b/include/sound/cs46xx.h @@ -1702,7 +1702,6 @@ struct _snd_cs46xx { void (*active_ctrl)(cs46xx_t *, int); void (*mixer_init)(cs46xx_t *); - struct pci_dev *acpi_dev; int acpi_port; snd_kcontrol_t *eapd_switch; /* for amplifier hack */ int accept_valid; /* accept mmap valid (for OSS) */ diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 39a54a41552..91124ddbdda 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -590,7 +590,7 @@ static int snd_mem_proc_write(struct file *file, const char __user *buffer, alloced = 0; pci = NULL; - while ((pci = pci_find_device(vendor, device, pci)) != NULL) { + while ((pci = pci_get_device(vendor, device, pci)) != NULL) { if (mask > 0 && mask < 0xffffffff) { if (pci_set_dma_mask(pci, mask) < 0 || pci_set_consistent_dma_mask(pci, mask) < 0) { @@ -604,6 +604,7 @@ static int snd_mem_proc_write(struct file *file, const char __user *buffer, if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), size, &dmab) < 0) { printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size); + pci_dev_put(pci); return (int)count; } snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci)); diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 7f835d46dc1..703770f6a50 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -318,13 +318,12 @@ static void ali_read_regs(ali_t *codec, int channel) static void ali_read_cfg(unsigned int vendor, unsigned deviceid) { unsigned int dwVal; - struct pci_dev *pci_dev = NULL; + struct pci_dev *pci_dev; int i,j; - - pci_dev = pci_find_device(vendor, deviceid, pci_dev); - if (pci_dev == NULL) - return ; + pci_dev = pci_get_device(vendor, deviceid, NULL); + if (pci_dev == NULL) + return ; printk("\nM%x PCI CFG\n", deviceid); printk(" "); @@ -341,6 +340,7 @@ static void ali_read_cfg(unsigned int vendor, unsigned deviceid) } printk("\n"); } + pci_dev_put(pci_dev); } static void ali_read_ac97regs(ali_t *codec, int secondary) { @@ -2108,6 +2108,8 @@ static int snd_ali_free(ali_t * codec) #ifdef CONFIG_PM kfree(codec->image); #endif + pci_dev_put(codec->pci_m1533); + pci_dev_put(codec->pci_m7101); kfree(codec); return 0; } @@ -2297,7 +2299,7 @@ static int __devinit snd_ali_create(snd_card_t * card, codec->chregs.data.ainten = 0x00; /* M1533: southbridge */ - pci_dev = pci_find_device(0x10b9, 0x1533, NULL); + pci_dev = pci_get_device(0x10b9, 0x1533, NULL); codec->pci_m1533 = pci_dev; if (! codec->pci_m1533) { snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); @@ -2305,7 +2307,7 @@ static int __devinit snd_ali_create(snd_card_t * card, return -ENODEV; } /* M7101: power management */ - pci_dev = pci_find_device(0x10b9, 0x7101, NULL); + pci_dev = pci_get_device(0x10b9, 0x7101, NULL); codec->pci_m7101 = pci_dev; if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index f6236c63aaa..0e33e0650cf 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c @@ -79,19 +79,21 @@ static void vortex_fix_agp_bridge(struct pci_dev *via) static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix) { - struct pci_dev *via; + struct pci_dev *via = NULL; /* autodetect if workarounds are required */ if (fix == 255) { /* VIA KT133 */ - via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8365_1, NULL); + via = pci_get_device(PCI_VENDOR_ID_VIA, + PCI_DEVICE_ID_VIA_8365_1, NULL); /* VIA Apollo */ if (via == NULL) { - via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C598_1, NULL); - } - /* AMD Irongate */ - if (via == NULL) { - via = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL); + via = pci_get_device(PCI_VENDOR_ID_VIA, + PCI_DEVICE_ID_VIA_82C598_1, NULL); + /* AMD Irongate */ + if (via == NULL) + via = pci_get_device(PCI_VENDOR_ID_AMD, + PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL); } if (via) { printk(KERN_INFO CARD_NAME ": Activating latency workaround...\n"); @@ -101,13 +103,17 @@ static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix) } else { if (fix & 0x1) vortex_fix_latency(vortex); - if ((fix & 0x2) && (via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8365_1, NULL))) + if ((fix & 0x2) && (via = pci_get_device(PCI_VENDOR_ID_VIA, + PCI_DEVICE_ID_VIA_8365_1, NULL))) vortex_fix_agp_bridge(via); - if ((fix & 0x4) && (via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C598_1, NULL))) + if ((fix & 0x4) && (via = pci_get_device(PCI_VENDOR_ID_VIA, + PCI_DEVICE_ID_VIA_82C598_1, NULL))) vortex_fix_agp_bridge(via); - if ((fix & 0x8) && (via = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL))) + if ((fix & 0x8) && (via = pci_get_device(PCI_VENDOR_ID_AMD, + PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL))) vortex_fix_agp_bridge(via); } + pci_dev_put(via); } // component-destructor diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index fd9c82c07b3..03329a7efb9 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -3537,7 +3537,7 @@ static void clkrun_hack(cs46xx_t *chip, int change) { u16 control, nval; - if (chip->acpi_dev == NULL) + if (!chip->acpi_port) return; chip->amplifier += change; @@ -3560,15 +3560,20 @@ static void clkrun_hack(cs46xx_t *chip, int change) */ static void clkrun_init(cs46xx_t *chip) { + struct pci_dev *pdev; u8 pp; - chip->acpi_dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL); - if (chip->acpi_dev == NULL) + chip->acpi_port = 0; + + pdev = pci_get_device(PCI_VENDOR_ID_INTEL, + PCI_DEVICE_ID_INTEL_82371AB_3, NULL); + if (pdev == NULL) return; /* Not a thinkpad thats for sure */ /* Find the control port */ - pci_read_config_byte(chip->acpi_dev, 0x41, &pp); + pci_read_config_byte(pdev, 0x41, &pp); chip->acpi_port = pp << 8; + pci_dev_put(pdev); } diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index c7bddfb9fb6..cfd2c9cc9b3 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -1927,11 +1927,12 @@ static int snd_via82xx_chip_init(via82xx_t *chip) * DXS channels don't work properly with VRA if MC97 is disabled. */ struct pci_dev *pci; - pci = pci_find_device(0x1106, 0x3068, NULL); /* MC97 */ + pci = pci_get_device(0x1106, 0x3068, NULL); /* MC97 */ if (pci) { unsigned char data; pci_read_config_byte(pci, 0x44, &data); pci_write_config_byte(pci, 0x44, data | 0x40); + pci_dev_put(pci); } } -- cgit v1.2.3 From a28f1cda0d01f6f98e3bef6a07c483a90f6a35d6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Sep 2005 15:26:56 +0200 Subject: [ALSA] hda-intel - Fix modem PCM creation HDA Intel driver Fix a bug of modem PCM creation (due to a typo). Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 2098de7c567..a8eaeb463b0 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1252,7 +1252,7 @@ static int __devinit azx_pcm_create(azx_t *chip) for (c = 0; c < codec->num_pcms; c++) { if (! codec->pcm_info[c].is_modem) continue; /* already created */ - if (pcm_dev >= AZX_MAX_MODEM_PCMS) { + if (pcm_dev >= AZX_MAX_PCMS) { snd_printk(KERN_ERR SFX "Too many modem PCMs\n"); return -EINVAL; } -- cgit v1.2.3 From f328385309f310626751c54f694641459e2d4582 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Sep 2005 17:08:40 +0200 Subject: [ALSA] powermac - Add AUTO_DRC config PPC,PPC Tumbler driver Added AUTO_DRC kernel config to enable/disable the auto-DRC-toggle feature on tumbler/snapper. Signed-off-by: Takashi Iwai --- sound/ppc/Kconfig | 14 +++++++++++++- sound/ppc/tumbler.c | 23 +++++++++++++++++------ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/sound/ppc/Kconfig b/sound/ppc/Kconfig index bda5bc4e614..206b9333f91 100644 --- a/sound/ppc/Kconfig +++ b/sound/ppc/Kconfig @@ -20,5 +20,17 @@ config SND_POWERMAC To compile this driver as a module, choose M here: the module will be called snd-powermac. -endmenu +config SND_POWERMAC_AUTO_DRC + bool "Toggle DRC automatically at headphone/line plug-in" + depends on SND_POWERMAC + default y + help + Say Y here to enable the automatic toggle of DRC (dynamic + range compression) on Tumbler/Snapper. + If this feature is enabled, DRC is turned off when the + headphone/line jack is plugged, and turned on when unplugged. + Note that you can turn on/off DRC manually even without this + option. + +endmenu diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index b94437c024b..65384afcfc3 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c @@ -948,7 +948,6 @@ static void device_change_handler(void *self) msleep(10); check_mute(chip, &mix->amp_mute, 1, mix->auto_mute_notify, chip->speaker_sw_ctl); - mix->drc_enable = 0; } else { /* unmute speaker, mute others */ check_mute(chip, &mix->amp_mute, 0, mix->auto_mute_notify, @@ -960,20 +959,21 @@ static void device_change_handler(void *self) if (mix->line_mute.addr != 0) check_mute(chip, &mix->line_mute, 1, mix->auto_mute_notify, chip->lineout_sw_ctl); - mix->drc_enable = 1; } - if (mix->auto_mute_notify) { + if (mix->auto_mute_notify) snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hp_detect_ctl->id); + +#ifdef CONFIG_SND_POWERMAC_AUTO_DRC + mix->drc_enable = ! (headphone || lineout); + if (mix->auto_mute_notify) snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->drc_sw_ctl->id); - } - - /* first set the DRC so the speaker do not explode -ReneR */ if (chip->model == PMAC_TUMBLER) tumbler_set_drc(mix); else snapper_set_drc(mix); +#endif /* reset the master volume so the correct amplification is applied */ tumbler_set_master_volume(mix); @@ -1370,6 +1370,17 @@ int __init snd_pmac_tumbler_init(pmac_t *chip) if ((err = snd_ctl_add(chip->card, chip->drc_sw_ctl)) < 0) return err; + /* set initial DRC range to 60% */ + if (chip->model == PMAC_TUMBLER) + mix->drc_range = (TAS3001_DRC_MAX * 6) / 10; + else + mix->drc_range = (TAS3004_DRC_MAX * 6) / 10; + mix->drc_enable = 1; /* will be changed later if AUTO_DRC is set */ + if (chip->model == PMAC_TUMBLER) + tumbler_set_drc(mix); + else + snapper_set_drc(mix); + #ifdef CONFIG_PM chip->suspend = tumbler_suspend; chip->resume = tumbler_resume; -- cgit v1.2.3 From 10f69f9e42833b82288882d10901dc86adc3e473 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Sep 2005 13:48:34 +0200 Subject: [ALSA] pcm-oss - Add bugg-yptr option Documentation,ALSA<-OSS emulation Added 'buggy-ptr' proc option to switch the behavior of GETOPTR ioctl. Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/ALSA-Configuration.txt | 2 ++ include/sound/pcm_oss.h | 3 ++- sound/core/oss/pcm_oss.c | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index a7fc75f53bb..57e82a5fae7 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -1592,6 +1592,8 @@ Proc interfaces (/proc/asound) - whole-frag write only whole fragments (optimization affecting playback only) - no-silence do not fill silence ahead to avoid clicks + - buggy-ptr Returns the whitespace blocks in GETOPTR ioctl + instead of filled blocks Example: echo "x11amp 128 16384" > /proc/asound/card0/pcm0p/oss echo "squake 0 0 disable" > /proc/asound/card0/pcm0c/oss diff --git a/include/sound/pcm_oss.h b/include/sound/pcm_oss.h index 518728536bc..0b67c9d105a 100644 --- a/include/sound/pcm_oss.h +++ b/include/sound/pcm_oss.h @@ -32,7 +32,8 @@ struct _snd_pcm_oss_setup { block:1, nonblock:1, partialfrag:1, - nosilence:1; + nosilence:1, + buggyptr:1; unsigned int periods; unsigned int period_size; snd_pcm_oss_setup_t *next; diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 1e606399d74..a038fd8a53f 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -1543,7 +1543,11 @@ static int snd_pcm_oss_get_ptr(snd_pcm_oss_file_t *pcm_oss_file, int stream, str } else { delay = snd_pcm_oss_bytes(substream, delay); if (stream == SNDRV_PCM_STREAM_PLAYBACK) { - info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes; + snd_pcm_oss_setup_t *setup = substream->oss.setup; + if (setup && setup->buggyptr) + info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes; + else + info.blocks = (delay + fixup) / runtime->oss.period_bytes; info.bytes = (runtime->oss.bytes - delay) & INT_MAX; } else { delay += fixup; @@ -2350,6 +2354,8 @@ static void snd_pcm_oss_proc_write(snd_info_entry_t *entry, template.partialfrag = 1; } else if (!strcmp(str, "no-silence")) { template.nosilence = 1; + } else if (!strcmp(str, "buggy-ptr")) { + template.buggyptr = 1; } } while (*str); if (setup == NULL) { -- cgit v1.2.3 From a06147d22865e9becb2918baec59d618fb09d896 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Sep 2005 19:54:17 +0200 Subject: [ALSA] intel8x0 - Add buggy_semaphore option Documentation,Intel8x0 driver Added buggy_semaphore module option to snd-intel8x0 driver for a workaround for hardwards with buggy codec semaphores. Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/ALSA-Configuration.txt | 6 +++++- sound/pci/intel8x0.c | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 57e82a5fae7..13cba955cb5 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -805,7 +805,11 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. ac97_quirk - AC'97 workaround for strange hardware See "AC97 Quirk Option" section below. buggy_irq - Enable workaround for buggy interrupts on some - motherboards (default off) + motherboards (default yes on nForce chips, + otherwise off) + buggy_semaphore - Enable workaround for hardwares with buggy + semaphores (e.g. on some ASUS laptops) + (default off) Module supports autoprobe and multiple bus-master chips (max 8). diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index b96f87e7339..47965dfcbee 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -69,6 +69,7 @@ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; static char *ac97_quirk[SNDRV_CARDS]; +static int buggy_semaphore[SNDRV_CARDS]; static int buggy_irq[SNDRV_CARDS]; static int xbox[SNDRV_CARDS]; @@ -86,6 +87,8 @@ module_param_array(ac97_clock, int, NULL, 0444); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect)."); module_param_array(ac97_quirk, charp, NULL, 0444); MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); +module_param_array(buggy_semaphore, bool, NULL, 0444); +MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores."); module_param_array(buggy_irq, bool, NULL, 0444); MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards."); module_param_array(xbox, bool, NULL, 0444); @@ -367,6 +370,7 @@ struct _snd_intel8x0 { unsigned fix_nocache: 1; /* workaround for 440MX */ unsigned buggy_irq: 1; /* workaround for buggy mobos */ unsigned xbox: 1; /* workaround for Xbox AC'97 detection */ + unsigned buggy_semaphore: 1; /* workaround for buggy codec semaphore */ int spdif_idx; /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */ unsigned int sdm_saved; /* SDM reg value */ @@ -521,6 +525,9 @@ static int snd_intel8x0_codec_semaphore(intel8x0_t *chip, unsigned int codec) if ((igetdword(chip, ICHREG(GLOB_STA)) & codec) == 0) return -EIO; + if (chip->buggy_semaphore) + return 0; /* just ignore ... */ + /* Anyone holding a semaphore for 1 msec should be shot... */ time = 100; do { @@ -2549,6 +2556,7 @@ struct ich_reg_info { static int __devinit snd_intel8x0_create(snd_card_t * card, struct pci_dev *pci, unsigned long device_type, + int buggy_sem, intel8x0_t ** r_intel8x0) { intel8x0_t *chip; @@ -2606,6 +2614,7 @@ static int __devinit snd_intel8x0_create(snd_card_t * card, chip->card = card; chip->pci = pci; chip->irq = -1; + chip->buggy_semaphore = buggy_sem; if (pci->vendor == PCI_VENDOR_ID_INTEL && pci->device == PCI_DEVICE_ID_INTEL_440MX) @@ -2810,7 +2819,8 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci, } } - if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, &chip)) < 0) { + if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, + buggy_semaphore[dev], &chip)) < 0) { snd_card_free(card); return err; } -- cgit v1.2.3 From 8648811f1db85eeacb821591ef11a2c229c29aa0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 9 Sep 2005 13:56:32 +0200 Subject: [ALSA] hda-codec - Added ASUS A6 HDA Codec driver Added ASUS A6 support for ALC880 codec. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 1218f1d1bf9..45f286faa21 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1582,6 +1582,7 @@ static struct hda_board_config alc880_cfg_tbl[] = { { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG }, { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG }, { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG }, + { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG }, { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS }, { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG }, { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS }, -- cgit v1.2.3 From ca2c0966562cfbf9273167a5b60e8fddc24078d6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 9 Sep 2005 14:20:23 +0200 Subject: [ALSA] Replace with kzalloc() - core stuff Control Midlevel,ALSA Core,HWDEP Midlevel,PCM Midlevel,RawMidi Midlevel Timer Midlevel,ALSA<-OSS emulation Replace kcalloc(1,..) with kzalloc(). Signed-off-by: Takashi Iwai --- sound/core/control.c | 12 ++++++------ sound/core/control_compat.c | 8 ++++---- sound/core/device.c | 2 +- sound/core/hwdep.c | 2 +- sound/core/info.c | 8 ++++---- sound/core/init.c | 4 ++-- sound/core/oss/mixer_oss.c | 26 +++++++++++++------------- sound/core/oss/pcm_oss.c | 2 +- sound/core/oss/pcm_plugin.c | 2 +- sound/core/pcm.c | 6 +++--- sound/core/pcm_memory.c | 2 +- sound/core/pcm_native.c | 2 +- sound/core/rawmidi.c | 6 +++--- sound/core/timer.c | 10 +++++----- 14 files changed, 46 insertions(+), 46 deletions(-) diff --git a/sound/core/control.c b/sound/core/control.c index 227f3cf0277..736edf358e0 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -69,7 +69,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file) err = -EFAULT; goto __error2; } - ctl = kcalloc(1, sizeof(*ctl), GFP_KERNEL); + ctl = kzalloc(sizeof(*ctl), GFP_KERNEL); if (ctl == NULL) { err = -ENOMEM; goto __error; @@ -162,7 +162,7 @@ void snd_ctl_notify(snd_card_t *card, unsigned int mask, snd_ctl_elem_id_t *id) goto _found; } } - ev = kcalloc(1, sizeof(*ev), GFP_ATOMIC); + ev = kzalloc(sizeof(*ev), GFP_ATOMIC); if (ev) { ev->id = *id; ev->mask = mask; @@ -195,7 +195,7 @@ snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * control, unsigned int access) snd_runtime_check(control != NULL, return NULL); snd_runtime_check(control->count > 0, return NULL); - kctl = kcalloc(1, sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL); + kctl = kzalloc(sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL); if (kctl == NULL) return NULL; *kctl = *control; @@ -521,7 +521,7 @@ static int snd_ctl_card_info(snd_card_t * card, snd_ctl_file_t * ctl, { snd_ctl_card_info_t *info; - info = kcalloc(1, sizeof(*info), GFP_KERNEL); + info = kzalloc(sizeof(*info), GFP_KERNEL); if (! info) return -ENOMEM; down_read(&snd_ioctl_rwsem); @@ -929,7 +929,7 @@ static int snd_ctl_elem_add(snd_ctl_file_t *file, snd_ctl_elem_info_t *info, int return -EINVAL; } private_size *= info->count; - ue = kcalloc(1, sizeof(struct user_element) + private_size, GFP_KERNEL); + ue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL); if (ue == NULL) return -ENOMEM; ue->info = *info; @@ -1185,7 +1185,7 @@ static int _snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn, struct list_head * { snd_kctl_ioctl_t *pn; - pn = kcalloc(1, sizeof(snd_kctl_ioctl_t), GFP_KERNEL); + pn = kzalloc(sizeof(snd_kctl_ioctl_t), GFP_KERNEL); if (pn == NULL) return -ENOMEM; pn->fioctl = fcn; diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c index 7fdabea4bfc..207c7de5129 100644 --- a/sound/core/control_compat.c +++ b/sound/core/control_compat.c @@ -92,7 +92,7 @@ static int snd_ctl_elem_info_compat(snd_ctl_file_t *ctl, struct sndrv_ctl_elem_i struct sndrv_ctl_elem_info *data; int err; - data = kcalloc(1, sizeof(*data), GFP_KERNEL); + data = kzalloc(sizeof(*data), GFP_KERNEL); if (! data) return -ENOMEM; @@ -271,7 +271,7 @@ static int snd_ctl_elem_read_user_compat(snd_card_t *card, struct sndrv_ctl_elem_value *data; int err, type, count; - data = kcalloc(1, sizeof(*data), GFP_KERNEL); + data = kzalloc(sizeof(*data), GFP_KERNEL); if (data == NULL) return -ENOMEM; @@ -291,7 +291,7 @@ static int snd_ctl_elem_write_user_compat(snd_ctl_file_t *file, struct sndrv_ctl_elem_value *data; int err, type, count; - data = kcalloc(1, sizeof(*data), GFP_KERNEL); + data = kzalloc(sizeof(*data), GFP_KERNEL); if (data == NULL) return -ENOMEM; @@ -313,7 +313,7 @@ static int snd_ctl_elem_add_compat(snd_ctl_file_t *file, struct sndrv_ctl_elem_info *data; int err; - data = kcalloc(1, sizeof(*data), GFP_KERNEL); + data = kzalloc(sizeof(*data), GFP_KERNEL); if (! data) return -ENOMEM; diff --git a/sound/core/device.c b/sound/core/device.c index ca00ad7740c..1f509f56e60 100644 --- a/sound/core/device.c +++ b/sound/core/device.c @@ -49,7 +49,7 @@ int snd_device_new(snd_card_t *card, snd_device_type_t type, snd_assert(card != NULL, return -ENXIO); snd_assert(device_data != NULL, return -ENXIO); snd_assert(ops != NULL, return -ENXIO); - dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (dev == NULL) return -ENOMEM; dev->card = card; diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 997dd41c584..9383f1294fb 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -359,7 +359,7 @@ int snd_hwdep_new(snd_card_t * card, char *id, int device, snd_hwdep_t ** rhwdep snd_assert(rhwdep != NULL, return -EINVAL); *rhwdep = NULL; snd_assert(card != NULL, return -ENXIO); - hwdep = kcalloc(1, sizeof(*hwdep), GFP_KERNEL); + hwdep = kzalloc(sizeof(*hwdep), GFP_KERNEL); if (hwdep == NULL) return -ENOMEM; hwdep->card = card; diff --git a/sound/core/info.c b/sound/core/info.c index 7f8bdf7b005..37024d68a26 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -295,7 +295,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) goto __error; } } - data = kcalloc(1, sizeof(*data), GFP_KERNEL); + data = kzalloc(sizeof(*data), GFP_KERNEL); if (data == NULL) { err = -ENOMEM; goto __error; @@ -304,7 +304,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) switch (entry->content) { case SNDRV_INFO_CONTENT_TEXT: if (mode == O_RDONLY || mode == O_RDWR) { - buffer = kcalloc(1, sizeof(*buffer), GFP_KERNEL); + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); if (buffer == NULL) { kfree(data); err = -ENOMEM; @@ -323,7 +323,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) data->rbuffer = buffer; } if (mode == O_WRONLY || mode == O_RDWR) { - buffer = kcalloc(1, sizeof(*buffer), GFP_KERNEL); + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); if (buffer == NULL) { if (mode == O_RDWR) { vfree(data->rbuffer->buffer); @@ -752,7 +752,7 @@ char *snd_info_get_str(char *dest, char *src, int len) static snd_info_entry_t *snd_info_create_entry(const char *name) { snd_info_entry_t *entry; - entry = kcalloc(1, sizeof(*entry), GFP_KERNEL); + entry = kzalloc(sizeof(*entry), GFP_KERNEL); if (entry == NULL) return NULL; entry->name = kstrdup(name, GFP_KERNEL); diff --git a/sound/core/init.c b/sound/core/init.c index c9c9929121d..a5702014a70 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -72,7 +72,7 @@ snd_card_t *snd_card_new(int idx, const char *xid, if (extra_size < 0) extra_size = 0; - card = kcalloc(1, sizeof(*card) + extra_size, GFP_KERNEL); + card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL); if (card == NULL) return NULL; if (xid) { @@ -702,7 +702,7 @@ static int snd_generic_device_register(snd_card_t *card) if (card->generic_dev) return 0; /* already registered */ - dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (! dev) { snd_printk(KERN_ERR "can't allocate generic_device\n"); return -ENOMEM; diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 98fc0766f88..69e1059112d 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -53,7 +53,7 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file) err = snd_card_file_add(card, file); if (err < 0) return err; - fmixer = kcalloc(1, sizeof(*fmixer), GFP_KERNEL); + fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL); if (fmixer == NULL) { snd_card_file_remove(card, file); return -ENOMEM; @@ -517,8 +517,8 @@ static void snd_mixer_oss_get_volume1_vol(snd_mixer_oss_file_t *fmixer, up_read(&card->controls_rwsem); return; } - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); @@ -551,8 +551,8 @@ static void snd_mixer_oss_get_volume1_sw(snd_mixer_oss_file_t *fmixer, up_read(&card->controls_rwsem); return; } - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); @@ -612,8 +612,8 @@ static void snd_mixer_oss_put_volume1_vol(snd_mixer_oss_file_t *fmixer, down_read(&card->controls_rwsem); if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) return; - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); @@ -649,8 +649,8 @@ static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer, up_read(&fmixer->card->controls_rwsem); return; } - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); @@ -768,8 +768,8 @@ static int snd_mixer_oss_get_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int snd_ctl_elem_value_t *uctl; int err, idx; - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) { err = -ENOMEM; goto __unlock; @@ -813,8 +813,8 @@ static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int int err; unsigned int idx; - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) { err = -ENOMEM; goto __unlock; diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index a038fd8a53f..842c28b2ed5 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -1740,7 +1740,7 @@ static int snd_pcm_oss_open_file(struct file *file, snd_assert(rpcm_oss_file != NULL, return -EINVAL); *rpcm_oss_file = NULL; - pcm_oss_file = kcalloc(1, sizeof(*pcm_oss_file), GFP_KERNEL); + pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL); if (pcm_oss_file == NULL) return -ENOMEM; diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c index 6430410c6c0..fc23373c000 100644 --- a/sound/core/oss/pcm_plugin.c +++ b/sound/core/oss/pcm_plugin.c @@ -171,7 +171,7 @@ int snd_pcm_plugin_build(snd_pcm_plug_t *plug, snd_assert(plug != NULL, return -ENXIO); snd_assert(src_format != NULL && dst_format != NULL, return -ENXIO); - plugin = kcalloc(1, sizeof(*plugin) + extra, GFP_KERNEL); + plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL); if (plugin == NULL) return -ENOMEM; plugin->name = name; diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 9f4c9209b27..1be470e942e 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -597,7 +597,7 @@ int snd_pcm_new_stream(snd_pcm_t *pcm, int stream, int substream_count) } prev = NULL; for (idx = 0, prev = NULL; idx < substream_count; idx++) { - substream = kcalloc(1, sizeof(*substream), GFP_KERNEL); + substream = kzalloc(sizeof(*substream), GFP_KERNEL); if (substream == NULL) return -ENOMEM; substream->pcm = pcm; @@ -657,7 +657,7 @@ int snd_pcm_new(snd_card_t * card, char *id, int device, snd_assert(rpcm != NULL, return -EINVAL); *rpcm = NULL; snd_assert(card != NULL, return -ENXIO); - pcm = kcalloc(1, sizeof(*pcm), GFP_KERNEL); + pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); if (pcm == NULL) return -ENOMEM; pcm->card = card; @@ -795,7 +795,7 @@ int snd_pcm_open_substream(snd_pcm_t *pcm, int stream, if (substream == NULL) return -EAGAIN; - runtime = kcalloc(1, sizeof(*runtime), GFP_KERNEL); + runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); if (runtime == NULL) return -ENOMEM; diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index 5df76738470..b3f5344f60b 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -321,7 +321,7 @@ int snd_pcm_lib_malloc_pages(snd_pcm_substream_t *substream, size_t size) if (substream->dma_buffer.area != NULL && substream->dma_buffer.bytes >= size) { dmab = &substream->dma_buffer; /* use the pre-allocated buffer */ } else { - dmab = kcalloc(1, sizeof(*dmab), GFP_KERNEL); + dmab = kzalloc(sizeof(*dmab), GFP_KERNEL); if (! dmab) return -ENOMEM; dmab->dev = substream->dma_buffer.dev; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index b829a272755..67abebabf83 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2001,7 +2001,7 @@ static int snd_pcm_open_file(struct file *file, snd_assert(rpcm_file != NULL, return -EINVAL); *rpcm_file = NULL; - pcm_file = kcalloc(1, sizeof(*pcm_file), GFP_KERNEL); + pcm_file = kzalloc(sizeof(*pcm_file), GFP_KERNEL); if (pcm_file == NULL) { return -ENOMEM; } diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 4f4b4101b2f..7c20eafecb8 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -101,7 +101,7 @@ static int snd_rawmidi_runtime_create(snd_rawmidi_substream_t * substream) { snd_rawmidi_runtime_t *runtime; - if ((runtime = kcalloc(1, sizeof(*runtime), GFP_KERNEL)) == NULL) + if ((runtime = kzalloc(sizeof(*runtime), GFP_KERNEL)) == NULL) return -ENOMEM; spin_lock_init(&runtime->lock); init_waitqueue_head(&runtime->sleep); @@ -1374,7 +1374,7 @@ static int snd_rawmidi_alloc_substreams(snd_rawmidi_t *rmidi, INIT_LIST_HEAD(&stream->substreams); for (idx = 0; idx < count; idx++) { - substream = kcalloc(1, sizeof(*substream), GFP_KERNEL); + substream = kzalloc(sizeof(*substream), GFP_KERNEL); if (substream == NULL) return -ENOMEM; substream->stream = direction; @@ -1417,7 +1417,7 @@ int snd_rawmidi_new(snd_card_t * card, char *id, int device, snd_assert(rrawmidi != NULL, return -EINVAL); *rrawmidi = NULL; snd_assert(card != NULL, return -ENXIO); - rmidi = kcalloc(1, sizeof(*rmidi), GFP_KERNEL); + rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL); if (rmidi == NULL) return -ENOMEM; rmidi->card = card; diff --git a/sound/core/timer.c b/sound/core/timer.c index 4104f6e292e..22b10462408 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -98,7 +98,7 @@ static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left); static snd_timer_instance_t *snd_timer_instance_new(char *owner, snd_timer_t *timer) { snd_timer_instance_t *timeri; - timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL); + timeri = kzalloc(sizeof(*timeri), GFP_KERNEL); if (timeri == NULL) return NULL; timeri->owner = kstrdup(owner, GFP_KERNEL); @@ -764,7 +764,7 @@ int snd_timer_new(snd_card_t *card, char *id, snd_timer_id_t *tid, snd_timer_t * snd_assert(tid != NULL, return -EINVAL); snd_assert(rtimer != NULL, return -EINVAL); *rtimer = NULL; - timer = kcalloc(1, sizeof(*timer), GFP_KERNEL); + timer = kzalloc(sizeof(*timer), GFP_KERNEL); if (timer == NULL) return -ENOMEM; timer->tmr_class = tid->dev_class; @@ -1017,7 +1017,7 @@ static int snd_timer_register_system(void) return err; strcpy(timer->name, "system timer"); timer->hw = snd_timer_system; - priv = kcalloc(1, sizeof(*priv), GFP_KERNEL); + priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) { snd_timer_free(timer); return -ENOMEM; @@ -1202,7 +1202,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file) { snd_timer_user_t *tu; - tu = kcalloc(1, sizeof(*tu), GFP_KERNEL); + tu = kzalloc(sizeof(*tu), GFP_KERNEL); if (tu == NULL) return -ENOMEM; spin_lock_init(&tu->qlock); @@ -1513,7 +1513,7 @@ static int snd_timer_user_info(struct file *file, snd_timer_info_t __user *_info t = tu->timeri->timer; snd_assert(t != NULL, return -ENXIO); - info = kcalloc(1, sizeof(*info), GFP_KERNEL); + info = kzalloc(sizeof(*info), GFP_KERNEL); if (! info) return -ENOMEM; info->card = t->card ? t->card->number : -1; -- cgit v1.2.3 From ecca82b4b447f8df73c807a018dac3e2863912d9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 9 Sep 2005 14:20:49 +0200 Subject: [ALSA] Replace with kzalloc() - seq stuff ALSA sequencer,Instrument layer,ALSA<-OSS sequencer Replace kcalloc(1,..) with kzalloc(). Signed-off-by: Takashi Iwai --- sound/core/seq/instr/ainstr_gf1.c | 2 +- sound/core/seq/instr/ainstr_iw.c | 6 +++--- sound/core/seq/oss/seq_oss_init.c | 2 +- sound/core/seq/oss/seq_oss_midi.c | 6 +++--- sound/core/seq/oss/seq_oss_readq.c | 2 +- sound/core/seq/oss/seq_oss_synth.c | 4 ++-- sound/core/seq/oss/seq_oss_timer.c | 2 +- sound/core/seq/oss/seq_oss_writeq.c | 2 +- sound/core/seq/seq_clientmgr.c | 2 +- sound/core/seq/seq_device.c | 2 +- sound/core/seq/seq_dummy.c | 2 +- sound/core/seq/seq_fifo.c | 2 +- sound/core/seq/seq_instr.c | 4 ++-- sound/core/seq/seq_memory.c | 2 +- sound/core/seq/seq_midi.c | 2 +- sound/core/seq/seq_midi_event.c | 2 +- sound/core/seq/seq_ports.c | 4 ++-- sound/core/seq/seq_prioq.c | 2 +- sound/core/seq/seq_queue.c | 2 +- sound/core/seq/seq_system.c | 4 ++-- sound/core/seq/seq_timer.c | 2 +- sound/core/seq/seq_virmidi.c | 6 +++--- 22 files changed, 32 insertions(+), 32 deletions(-) diff --git a/sound/core/seq/instr/ainstr_gf1.c b/sound/core/seq/instr/ainstr_gf1.c index 32e91c6b25f..207c2c54bf1 100644 --- a/sound/core/seq/instr/ainstr_gf1.c +++ b/sound/core/seq/instr/ainstr_gf1.c @@ -61,7 +61,7 @@ static int snd_seq_gf1_copy_wave_from_stream(snd_gf1_ops_t *ops, return -EFAULT; *data += sizeof(xp); *len -= sizeof(xp); - wp = kcalloc(1, sizeof(*wp), gfp_mask); + wp = kzalloc(sizeof(*wp), gfp_mask); if (wp == NULL) return -ENOMEM; wp->share_id[0] = le32_to_cpu(xp.share_id[0]); diff --git a/sound/core/seq/instr/ainstr_iw.c b/sound/core/seq/instr/ainstr_iw.c index 2622b8679ca..b3cee092b1a 100644 --- a/sound/core/seq/instr/ainstr_iw.c +++ b/sound/core/seq/instr/ainstr_iw.c @@ -92,7 +92,7 @@ static int snd_seq_iwffff_copy_env_from_stream(__u32 req_stype, points_size = (le16_to_cpu(rx.nattack) + le16_to_cpu(rx.nrelease)) * 2 * sizeof(__u16); if (points_size > *len) return -EINVAL; - rp = kcalloc(1, sizeof(*rp) + points_size, gfp_mask); + rp = kzalloc(sizeof(*rp) + points_size, gfp_mask); if (rp == NULL) return -ENOMEM; rp->nattack = le16_to_cpu(rx.nattack); @@ -139,7 +139,7 @@ static int snd_seq_iwffff_copy_wave_from_stream(snd_iwffff_ops_t *ops, return -EFAULT; *data += sizeof(xp); *len -= sizeof(xp); - wp = kcalloc(1, sizeof(*wp), gfp_mask); + wp = kzalloc(sizeof(*wp), gfp_mask); if (wp == NULL) return -ENOMEM; wp->share_id[0] = le32_to_cpu(xp.share_id[0]); @@ -273,7 +273,7 @@ static int snd_seq_iwffff_put(void *private_data, snd_seq_kinstr_t *instr, snd_seq_iwffff_instr_free(ops, ip, atomic); return -EINVAL; } - lp = kcalloc(1, sizeof(*lp), gfp_mask); + lp = kzalloc(sizeof(*lp), gfp_mask); if (lp == NULL) { snd_seq_iwffff_instr_free(ops, ip, atomic); return -ENOMEM; diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c index bac4b4f1a94..1ab1cf8158c 100644 --- a/sound/core/seq/oss/seq_oss_init.c +++ b/sound/core/seq/oss/seq_oss_init.c @@ -193,7 +193,7 @@ snd_seq_oss_open(struct file *file, int level) int i, rc; seq_oss_devinfo_t *dp; - if ((dp = kcalloc(1, sizeof(*dp), GFP_KERNEL)) == NULL) { + if ((dp = kzalloc(sizeof(*dp), GFP_KERNEL)) == NULL) { snd_printk(KERN_ERR "can't malloc device info\n"); return -ENOMEM; } diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c index 9aece6c65db..f0e95c8f2ee 100644 --- a/sound/core/seq/oss/seq_oss_midi.c +++ b/sound/core/seq/oss/seq_oss_midi.c @@ -76,8 +76,8 @@ snd_seq_oss_midi_lookup_ports(int client) snd_seq_client_info_t *clinfo; snd_seq_port_info_t *pinfo; - clinfo = kcalloc(1, sizeof(*clinfo), GFP_KERNEL); - pinfo = kcalloc(1, sizeof(*pinfo), GFP_KERNEL); + clinfo = kzalloc(sizeof(*clinfo), GFP_KERNEL); + pinfo = kzalloc(sizeof(*pinfo), GFP_KERNEL); if (! clinfo || ! pinfo) { kfree(clinfo); kfree(pinfo); @@ -172,7 +172,7 @@ snd_seq_oss_midi_check_new_port(snd_seq_port_info_t *pinfo) /* * allocate midi info record */ - if ((mdev = kcalloc(1, sizeof(*mdev), GFP_KERNEL)) == NULL) { + if ((mdev = kzalloc(sizeof(*mdev), GFP_KERNEL)) == NULL) { snd_printk(KERN_ERR "can't malloc midi info\n"); return -ENOMEM; } diff --git a/sound/core/seq/oss/seq_oss_readq.c b/sound/core/seq/oss/seq_oss_readq.c index 0a6f2a64f69..55571e15cd3 100644 --- a/sound/core/seq/oss/seq_oss_readq.c +++ b/sound/core/seq/oss/seq_oss_readq.c @@ -46,7 +46,7 @@ snd_seq_oss_readq_new(seq_oss_devinfo_t *dp, int maxlen) { seq_oss_readq_t *q; - if ((q = kcalloc(1, sizeof(*q), GFP_KERNEL)) == NULL) { + if ((q = kzalloc(sizeof(*q), GFP_KERNEL)) == NULL) { snd_printk(KERN_ERR "can't malloc read queue\n"); return NULL; } diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 1a7736cbf3a..8257fce2ca1 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c @@ -103,7 +103,7 @@ snd_seq_oss_synth_register(snd_seq_device_t *dev) snd_seq_oss_reg_t *reg = SNDRV_SEQ_DEVICE_ARGPTR(dev); unsigned long flags; - if ((rec = kcalloc(1, sizeof(*rec), GFP_KERNEL)) == NULL) { + if ((rec = kzalloc(sizeof(*rec), GFP_KERNEL)) == NULL) { snd_printk(KERN_ERR "can't malloc synth info\n"); return -ENOMEM; } @@ -499,7 +499,7 @@ snd_seq_oss_synth_sysex(seq_oss_devinfo_t *dp, int dev, unsigned char *buf, snd_ sysex = dp->synths[dev].sysex; if (sysex == NULL) { - sysex = kcalloc(1, sizeof(*sysex), GFP_KERNEL); + sysex = kzalloc(sizeof(*sysex), GFP_KERNEL); if (sysex == NULL) return -ENOMEM; dp->synths[dev].sysex = sysex; diff --git a/sound/core/seq/oss/seq_oss_timer.c b/sound/core/seq/oss/seq_oss_timer.c index 42ca9493fa6..64d594b3170 100644 --- a/sound/core/seq/oss/seq_oss_timer.c +++ b/sound/core/seq/oss/seq_oss_timer.c @@ -46,7 +46,7 @@ snd_seq_oss_timer_new(seq_oss_devinfo_t *dp) { seq_oss_timer_t *rec; - rec = kcalloc(1, sizeof(*rec), GFP_KERNEL); + rec = kzalloc(sizeof(*rec), GFP_KERNEL); if (rec == NULL) return NULL; diff --git a/sound/core/seq/oss/seq_oss_writeq.c b/sound/core/seq/oss/seq_oss_writeq.c index 87f85f7ee81..b2037802454 100644 --- a/sound/core/seq/oss/seq_oss_writeq.c +++ b/sound/core/seq/oss/seq_oss_writeq.c @@ -38,7 +38,7 @@ snd_seq_oss_writeq_new(seq_oss_devinfo_t *dp, int maxlen) seq_oss_writeq_t *q; snd_seq_client_pool_t pool; - if ((q = kcalloc(1, sizeof(*q), GFP_KERNEL)) == NULL) + if ((q = kzalloc(sizeof(*q), GFP_KERNEL)) == NULL) return NULL; q->dp = dp; q->maxlen = maxlen; diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index bd106625a78..a886db94b1f 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -203,7 +203,7 @@ static client_t *seq_create_client1(int client_index, int poolsize) client_t *client; /* init client data */ - client = kcalloc(1, sizeof(*client), GFP_KERNEL); + client = kzalloc(sizeof(*client), GFP_KERNEL); if (client == NULL) return NULL; client->pool = snd_seq_pool_new(poolsize); diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c index 4d80f39612e..252b5273100 100644 --- a/sound/core/seq/seq_device.c +++ b/sound/core/seq/seq_device.c @@ -200,7 +200,7 @@ int snd_seq_device_new(snd_card_t *card, int device, char *id, int argsize, if (ops == NULL) return -ENOMEM; - dev = kcalloc(1, sizeof(*dev)*2 + argsize, GFP_KERNEL); + dev = kzalloc(sizeof(*dev)*2 + argsize, GFP_KERNEL); if (dev == NULL) { unlock_driver(ops); return -ENOMEM; diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c index ea945a5d2a0..5dd0e6a19e5 100644 --- a/sound/core/seq/seq_dummy.c +++ b/sound/core/seq/seq_dummy.c @@ -153,7 +153,7 @@ create_port(int idx, int type) snd_seq_port_callback_t pcb; snd_seq_dummy_port_t *rec; - if ((rec = kcalloc(1, sizeof(*rec), GFP_KERNEL)) == NULL) + if ((rec = kzalloc(sizeof(*rec), GFP_KERNEL)) == NULL) return NULL; rec->client = my_client; diff --git a/sound/core/seq/seq_fifo.c b/sound/core/seq/seq_fifo.c index 3b7647ca7ad..4767cfdc361 100644 --- a/sound/core/seq/seq_fifo.c +++ b/sound/core/seq/seq_fifo.c @@ -33,7 +33,7 @@ fifo_t *snd_seq_fifo_new(int poolsize) { fifo_t *f; - f = kcalloc(1, sizeof(*f), GFP_KERNEL); + f = kzalloc(sizeof(*f), GFP_KERNEL); if (f == NULL) { snd_printd("malloc failed for snd_seq_fifo_new() \n"); return NULL; diff --git a/sound/core/seq/seq_instr.c b/sound/core/seq/seq_instr.c index 5b40ea2ba8f..019d43a462d 100644 --- a/sound/core/seq/seq_instr.c +++ b/sound/core/seq/seq_instr.c @@ -53,7 +53,7 @@ static snd_seq_kinstr_t *snd_seq_instr_new(int add_len, int atomic) { snd_seq_kinstr_t *instr; - instr = kcalloc(1, sizeof(snd_seq_kinstr_t) + add_len, atomic ? GFP_ATOMIC : GFP_KERNEL); + instr = kzalloc(sizeof(snd_seq_kinstr_t) + add_len, atomic ? GFP_ATOMIC : GFP_KERNEL); if (instr == NULL) return NULL; instr->add_len = add_len; @@ -77,7 +77,7 @@ snd_seq_kinstr_list_t *snd_seq_instr_list_new(void) { snd_seq_kinstr_list_t *list; - list = kcalloc(1, sizeof(snd_seq_kinstr_list_t), GFP_KERNEL); + list = kzalloc(sizeof(snd_seq_kinstr_list_t), GFP_KERNEL); if (list == NULL) return NULL; spin_lock_init(&list->lock); diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c index 03acb2d519b..d4d7d326c4b 100644 --- a/sound/core/seq/seq_memory.c +++ b/sound/core/seq/seq_memory.c @@ -452,7 +452,7 @@ pool_t *snd_seq_pool_new(int poolsize) pool_t *pool; /* create pool block */ - pool = kcalloc(1, sizeof(*pool), GFP_KERNEL); + pool = kzalloc(sizeof(*pool), GFP_KERNEL); if (pool == NULL) { snd_printd("seq: malloc failed for pool\n"); return NULL; diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index 4374829ea77..b4674ae3bc3 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c @@ -322,7 +322,7 @@ snd_seq_midisynth_register_port(snd_seq_device_t *dev) client = synths[card->number]; if (client == NULL) { newclient = 1; - client = kcalloc(1, sizeof(*client), GFP_KERNEL); + client = kzalloc(sizeof(*client), GFP_KERNEL); if (client == NULL) { up(®ister_mutex); kfree(info); diff --git a/sound/core/seq/seq_midi_event.c b/sound/core/seq/seq_midi_event.c index 603b63716db..2dc1aecfb42 100644 --- a/sound/core/seq/seq_midi_event.c +++ b/sound/core/seq/seq_midi_event.c @@ -118,7 +118,7 @@ int snd_midi_event_new(int bufsize, snd_midi_event_t **rdev) snd_midi_event_t *dev; *rdev = NULL; - dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (dev == NULL) return -ENOMEM; if (bufsize > 0) { diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index b976951fc10..57ec31df0d1 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -141,7 +141,7 @@ client_port_t *snd_seq_create_port(client_t *client, int port) } /* create a new port */ - new_port = kcalloc(1, sizeof(*new_port), GFP_KERNEL); + new_port = kzalloc(sizeof(*new_port), GFP_KERNEL); if (! new_port) { snd_printd("malloc failed for registering client port\n"); return NULL; /* failure, out of memory */ @@ -488,7 +488,7 @@ int snd_seq_port_connect(client_t *connector, unsigned long flags; int exclusive; - subs = kcalloc(1, sizeof(*subs), GFP_KERNEL); + subs = kzalloc(sizeof(*subs), GFP_KERNEL); if (! subs) return -ENOMEM; diff --git a/sound/core/seq/seq_prioq.c b/sound/core/seq/seq_prioq.c index a519732ed83..cd641bca994 100644 --- a/sound/core/seq/seq_prioq.c +++ b/sound/core/seq/seq_prioq.c @@ -59,7 +59,7 @@ prioq_t *snd_seq_prioq_new(void) { prioq_t *f; - f = kcalloc(1, sizeof(*f), GFP_KERNEL); + f = kzalloc(sizeof(*f), GFP_KERNEL); if (f == NULL) { snd_printd("oops: malloc failed for snd_seq_prioq_new()\n"); return NULL; diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c index 98de2e711fd..5f5c3cb37cb 100644 --- a/sound/core/seq/seq_queue.c +++ b/sound/core/seq/seq_queue.c @@ -111,7 +111,7 @@ static queue_t *queue_new(int owner, int locked) { queue_t *q; - q = kcalloc(1, sizeof(*q), GFP_KERNEL); + q = kzalloc(sizeof(*q), GFP_KERNEL); if (q == NULL) { snd_printd("malloc failed for snd_seq_queue_new()\n"); return NULL; diff --git a/sound/core/seq/seq_system.c b/sound/core/seq/seq_system.c index e8f0a6683d5..0d9eff85ab8 100644 --- a/sound/core/seq/seq_system.c +++ b/sound/core/seq/seq_system.c @@ -126,8 +126,8 @@ int __init snd_seq_system_client_init(void) snd_seq_client_info_t *inf; snd_seq_port_info_t *port; - inf = kcalloc(1, sizeof(*inf), GFP_KERNEL); - port = kcalloc(1, sizeof(*port), GFP_KERNEL); + inf = kzalloc(sizeof(*inf), GFP_KERNEL); + port = kzalloc(sizeof(*port), GFP_KERNEL); if (! inf || ! port) { kfree(inf); kfree(port); diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c index a7f76fc9528..b57a3c07ff6 100644 --- a/sound/core/seq/seq_timer.c +++ b/sound/core/seq/seq_timer.c @@ -60,7 +60,7 @@ seq_timer_t *snd_seq_timer_new(void) { seq_timer_t *tmr; - tmr = kcalloc(1, sizeof(*tmr), GFP_KERNEL); + tmr = kzalloc(sizeof(*tmr), GFP_KERNEL); if (tmr == NULL) { snd_printd("malloc failed for snd_seq_timer_new() \n"); return NULL; diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index a66484b5cf0..e4f512aa742 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -205,7 +205,7 @@ static int snd_virmidi_input_open(snd_rawmidi_substream_t * substream) snd_virmidi_t *vmidi; unsigned long flags; - vmidi = kcalloc(1, sizeof(*vmidi), GFP_KERNEL); + vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL); if (vmidi == NULL) return -ENOMEM; vmidi->substream = substream; @@ -233,7 +233,7 @@ static int snd_virmidi_output_open(snd_rawmidi_substream_t * substream) snd_rawmidi_runtime_t *runtime = substream->runtime; snd_virmidi_t *vmidi; - vmidi = kcalloc(1, sizeof(*vmidi), GFP_KERNEL); + vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL); if (vmidi == NULL) return -ENOMEM; vmidi->substream = substream; @@ -508,7 +508,7 @@ int snd_virmidi_new(snd_card_t *card, int device, snd_rawmidi_t **rrmidi) &rmidi)) < 0) return err; strcpy(rmidi->name, rmidi->id); - rdev = kcalloc(1, sizeof(*rdev), GFP_KERNEL); + rdev = kzalloc(sizeof(*rdev), GFP_KERNEL); if (rdev == NULL) { snd_device_free(card, rmidi); return -ENOMEM; -- cgit v1.2.3 From 9e76a76efc43d604a20bf0c5564caaf028a24d2e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 9 Sep 2005 14:21:17 +0200 Subject: [ALSA] Replace with kzalloc() - isa stuff ES18xx driver,OPL3SA2 driver,AD1816A driver,AD1848 driver,CS4231 driver ES1688 driver,GUS Library,Opti9xx drivers,EMU8000 driver SB16/AWE driver,SB drivers Replace kcalloc(1,..) with kzalloc(). Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a_lib.c | 2 +- sound/isa/ad1848/ad1848_lib.c | 2 +- sound/isa/cs423x/cs4231_lib.c | 2 +- sound/isa/es1688/es1688_lib.c | 2 +- sound/isa/es18xx.c | 2 +- sound/isa/gus/gus_main.c | 2 +- sound/isa/gus/gus_mem_proc.c | 4 ++-- sound/isa/gus/gus_pcm.c | 2 +- sound/isa/opl3sa2.c | 2 +- sound/isa/opti9xx/opti92x-ad1848.c | 2 +- sound/isa/sb/emu8000.c | 2 +- sound/isa/sb/emu8000_pcm.c | 2 +- sound/isa/sb/sb16_csp.c | 2 +- sound/isa/sb/sb_common.c | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index ae860360ecf..27a9dcfbba0 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -591,7 +591,7 @@ int snd_ad1816a_create(snd_card_t *card, *rchip = NULL; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; chip->irq = -1; diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c index bc642dc9454..303861cd03c 100644 --- a/sound/isa/ad1848/ad1848_lib.c +++ b/sound/isa/ad1848/ad1848_lib.c @@ -890,7 +890,7 @@ int snd_ad1848_create(snd_card_t * card, int err; *rchip = NULL; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; spin_lock_init(&chip->reg_lock); diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 3199941edd9..32318258cd8 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -1480,7 +1480,7 @@ static int snd_cs4231_new(snd_card_t * card, cs4231_t *chip; *rchip = NULL; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; chip->hardware = hardware; diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 17f68d07d9b..aac898765c0 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -649,7 +649,7 @@ int snd_es1688_create(snd_card_t * card, int err; *rchip = NULL; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; chip->irq = -1; diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index f654d594836..d0ea19f4270 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1686,7 +1686,7 @@ static int __devinit snd_es18xx_new_device(snd_card_t * card, int err; *rchip = NULL; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; spin_lock_init(&chip->reg_lock); diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index a636d9ce350..8f2872f8e8f 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -157,7 +157,7 @@ int snd_gus_create(snd_card_t * card, }; *rgus = NULL; - gus = kcalloc(1, sizeof(*gus), GFP_KERNEL); + gus = kzalloc(sizeof(*gus), GFP_KERNEL); if (gus == NULL) return -ENOMEM; gus->gf1.irq = -1; diff --git a/sound/isa/gus/gus_mem_proc.c b/sound/isa/gus/gus_mem_proc.c index 886763f1213..7f96ac237f3 100644 --- a/sound/isa/gus/gus_mem_proc.c +++ b/sound/isa/gus/gus_mem_proc.c @@ -98,7 +98,7 @@ int snd_gf1_mem_proc_init(snd_gus_card_t * gus) for (idx = 0; idx < 4; idx++) { if (gus->gf1.mem_alloc.banks_8[idx].size > 0) { - priv = kcalloc(1, sizeof(*priv), GFP_KERNEL); + priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) return -ENOMEM; priv->gus = gus; @@ -115,7 +115,7 @@ int snd_gf1_mem_proc_init(snd_gus_card_t * gus) } for (idx = 0; idx < 4; idx++) { if (gus->gf1.rom_present & (1 << idx)) { - priv = kcalloc(1, sizeof(*priv), GFP_KERNEL); + priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) return -ENOMEM; priv->rom = 1; diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index b75066ab46f..beb01365dc4 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -666,7 +666,7 @@ static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream) snd_pcm_runtime_t *runtime = substream->runtime; int err; - pcmp = kcalloc(1, sizeof(*pcmp), GFP_KERNEL); + pcmp = kzalloc(sizeof(*pcmp), GFP_KERNEL); if (pcmp == NULL) return -ENOMEM; pcmp->gus = gus; diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index e2d615bbb2f..e2d2babcd20 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -715,7 +715,7 @@ static int __devinit snd_opl3sa2_probe(int dev, return -ENOMEM; strcpy(card->driver, "OPL3SA2"); strcpy(card->shortname, "Yamaha OPL3-SA2"); - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { err = -ENOMEM; goto __error; diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index a490bcacdfa..73573cb1db6 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -1273,7 +1273,7 @@ static int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip, opti93x_t *codec; *rcodec = NULL; - codec = kcalloc(1, sizeof(*codec), GFP_KERNEL); + codec = kzalloc(sizeof(*codec), GFP_KERNEL); if (codec == NULL) return -ENOMEM; codec->irq = -1; diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 028af406659..5375705c054 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -1097,7 +1097,7 @@ snd_emu8000_new(snd_card_t *card, int index, long port, int seq_ports, snd_seq_d if (seq_ports <= 0) return 0; - hw = kcalloc(1, sizeof(*hw), GFP_KERNEL); + hw = kzalloc(sizeof(*hw), GFP_KERNEL); if (hw == NULL) return -ENOMEM; spin_lock_init(&hw->reg_lock); diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index db5eb8b5505..0209790dc4b 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -233,7 +233,7 @@ static int emu8k_pcm_open(snd_pcm_substream_t *subs) emu8k_pcm_t *rec; snd_pcm_runtime_t *runtime = subs->runtime; - rec = kcalloc(1, sizeof(*rec), GFP_KERNEL); + rec = kzalloc(sizeof(*rec), GFP_KERNEL); if (! rec) return -ENOMEM; diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index d64790bcd83..7192d4c758e 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -122,7 +122,7 @@ int snd_sb_csp_new(sb_t *chip, int device, snd_hwdep_t ** rhwdep) if ((err = snd_hwdep_new(chip->card, "SB16-CSP", device, &hw)) < 0) return err; - if ((p = kcalloc(1, sizeof(*p), GFP_KERNEL)) == NULL) { + if ((p = kzalloc(sizeof(*p), GFP_KERNEL)) == NULL) { snd_device_free(chip->card, hw); return -ENOMEM; } diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index 5b6bde213ea..f0f205ae425 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c @@ -221,7 +221,7 @@ int snd_sbdsp_create(snd_card_t *card, snd_assert(r_chip != NULL, return -EINVAL); *r_chip = NULL; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; spin_lock_init(&chip->reg_lock); -- cgit v1.2.3 From e560d8d8368ad8b6161839984b253de622863265 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 9 Sep 2005 14:21:46 +0200 Subject: [ALSA] Replace with kzalloc() - pci stuff AD1889 driver,ATIIXP driver,ATIIXP-modem driver,AZT3328 driver BT87x driver,CMIPCI driver,CS4281 driver,ENS1370/1+ driver ES1938 driver,ES1968 driver,FM801 driver,Intel8x0 driver Intel8x0-modem driver,Maestro3 driver,SonicVibes driver,VIA82xx driver VIA82xx-modem driver,AC97 Codec,AK4531 codec,au88x0 driver CA0106 driver,CS46xx driver,EMU10K1/EMU10K2 driver,HDA Codec driver HDA generic driver,HDA Intel driver,ICE1712 driver,ICE1724 driver KORG1212 driver,MIXART driver,NM256 driver,Trident driver,YMFPCI driver Replace kcalloc(1,..) with kzalloc(). Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_codec.c | 4 ++-- sound/pci/ac97/ak4531_codec.c | 2 +- sound/pci/ad1889.c | 4 ++-- sound/pci/atiixp.c | 2 +- sound/pci/atiixp_modem.c | 2 +- sound/pci/au88x0/au88x0.c | 2 +- sound/pci/azt3328.c | 2 +- sound/pci/bt87x.c | 2 +- sound/pci/ca0106/ca0106_main.c | 6 +++--- sound/pci/cmipci.c | 2 +- sound/pci/cs4281.c | 2 +- sound/pci/cs46xx/cs46xx_lib.c | 4 ++-- sound/pci/emu10k1/emu10k1_main.c | 2 +- sound/pci/emu10k1/emu10k1x.c | 6 +++--- sound/pci/emu10k1/emufx.c | 8 ++++---- sound/pci/emu10k1/emupcm.c | 10 +++++----- sound/pci/emu10k1/p16v.c | 4 ++-- sound/pci/ens1370.c | 2 +- sound/pci/es1938.c | 2 +- sound/pci/es1968.c | 6 +++--- sound/pci/fm801.c | 2 +- sound/pci/hda/hda_codec.c | 6 +++--- sound/pci/hda/hda_generic.c | 4 ++-- sound/pci/hda/hda_intel.c | 2 +- sound/pci/hda/patch_analog.c | 6 +++--- sound/pci/hda/patch_cmedia.c | 2 +- sound/pci/hda/patch_realtek.c | 6 +++--- sound/pci/hda/patch_si3054.c | 2 +- sound/pci/hda/patch_sigmatel.c | 4 ++-- sound/pci/ice1712/aureon.c | 2 +- sound/pci/ice1712/ice1712.c | 2 +- sound/pci/ice1712/ice1724.c | 2 +- sound/pci/ice1712/juli.c | 2 +- sound/pci/ice1712/phase.c | 4 ++-- sound/pci/ice1712/pontis.c | 2 +- sound/pci/intel8x0.c | 2 +- sound/pci/intel8x0m.c | 2 +- sound/pci/korg1212/korg1212.c | 2 +- sound/pci/maestro3.c | 2 +- sound/pci/mixart/mixart.c | 4 ++-- sound/pci/nm256/nm256.c | 2 +- sound/pci/sonicvibes.c | 2 +- sound/pci/trident/trident_main.c | 4 ++-- sound/pci/via82xx.c | 2 +- sound/pci/via82xx_modem.c | 2 +- sound/pci/ymfpci/ymfpci_main.c | 6 +++--- 46 files changed, 76 insertions(+), 76 deletions(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 3b66fa68936..e64cb07a39c 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -1797,7 +1797,7 @@ int snd_ac97_bus(snd_card_t *card, int num, ac97_bus_ops_t *ops, snd_assert(card != NULL, return -EINVAL); snd_assert(rbus != NULL, return -EINVAL); - bus = kcalloc(1, sizeof(*bus), GFP_KERNEL); + bus = kzalloc(sizeof(*bus), GFP_KERNEL); if (bus == NULL) return -ENOMEM; bus->card = card; @@ -1906,7 +1906,7 @@ int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97) } card = bus->card; - ac97 = kcalloc(1, sizeof(*ac97), GFP_KERNEL); + ac97 = kzalloc(sizeof(*ac97), GFP_KERNEL); if (ac97 == NULL) return -ENOMEM; ac97->private_data = template->private_data; diff --git a/sound/pci/ac97/ak4531_codec.c b/sound/pci/ac97/ak4531_codec.c index f9ce0fd2f52..4032c574837 100644 --- a/sound/pci/ac97/ak4531_codec.c +++ b/sound/pci/ac97/ak4531_codec.c @@ -357,7 +357,7 @@ int snd_ak4531_mixer(snd_card_t * card, ak4531_t * _ak4531, ak4531_t ** rak4531) snd_assert(rak4531 != NULL, return -EINVAL); *rak4531 = NULL; snd_assert(card != NULL && _ak4531 != NULL, return -EINVAL); - ak4531 = kcalloc(1, sizeof(*ak4531), GFP_KERNEL); + ak4531 = kzalloc(sizeof(*ak4531), GFP_KERNEL); if (ak4531 == NULL) return -ENOMEM; *ak4531 = *_ak4531; diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 37e8df24711..8ce9cb4c797 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -50,7 +50,7 @@ #include "ad1889.h" #include "ac97/ac97_id.h" -#define AD1889_DRVVER "$Revision: 1.1 $" +#define AD1889_DRVVER "$Revision: 1.2 $" MODULE_AUTHOR("Kyle McMartin , Thibaut Varene "); MODULE_DESCRIPTION("Analog Devices AD1889 ALSA sound driver"); @@ -928,7 +928,7 @@ snd_ad1889_create(snd_card_t *card, } /* allocate chip specific data with zero-filled memory */ - if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL) { + if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) { pci_disable_device(pci); return -ENOMEM; } diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 19c7bd08d06..874157f2701 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1531,7 +1531,7 @@ static int __devinit snd_atiixp_create(snd_card_t *card, if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 8d2002951bd..4de637e4dd4 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1208,7 +1208,7 @@ static int __devinit snd_atiixp_create(snd_card_t *card, if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index 0e33e0650cf..76b1c301869 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c @@ -156,7 +156,7 @@ snd_vortex_create(snd_card_t * card, struct pci_dev *pci, vortex_t ** rchip) } pci_set_dma_mask(pci, VORTEX_DMA_MASK); - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 72bba7b2d98..26069d2e027 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -1345,7 +1345,7 @@ static int __devinit snd_azf3328_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 2d124250bee..639f08098f8 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -710,7 +710,7 @@ static int __devinit snd_bt87x_create(snd_card_t *card, if (err < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (!chip) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 4a1abb12ee5..ba07960921d 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -352,7 +352,7 @@ static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream, snd_pcm_runtime_t *runtime = substream->runtime; int err; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; @@ -419,7 +419,7 @@ static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, i snd_pcm_runtime_t *runtime = substream->runtime; int err; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) { snd_printk("open_capture_channel: failed epcm alloc\n"); return -ENOMEM; @@ -1144,7 +1144,7 @@ static int __devinit snd_ca0106_create(snd_card_t *card, return -ENXIO; } - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 97ad90d47bc..583b2713d86 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -2775,7 +2775,7 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci, if ((err = pci_enable_device(pci)) < 0) return err; - cm = kcalloc(1, sizeof(*cm), GFP_KERNEL); + cm = kzalloc(sizeof(*cm), GFP_KERNEL); if (cm == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index e3e03028c72..421430bad98 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1383,7 +1383,7 @@ static int __devinit snd_cs4281_create(snd_card_t * card, *rchip = NULL; if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 03329a7efb9..6e3855b8b33 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -1304,7 +1304,7 @@ static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pc cs46xx_pcm_t * cpcm; snd_pcm_runtime_t *runtime = substream->runtime; - cpcm = kcalloc(1, sizeof(*cpcm), GFP_KERNEL); + cpcm = kzalloc(sizeof(*cpcm), GFP_KERNEL); if (cpcm == NULL) return -ENOMEM; if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), @@ -3774,7 +3774,7 @@ int __devinit snd_cs46xx_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index e69d5b739e8..03617ec0742 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -865,7 +865,7 @@ int __devinit snd_emu10k1_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - emu = kcalloc(1, sizeof(*emu), GFP_KERNEL); + emu = kzalloc(sizeof(*emu), GFP_KERNEL); if (emu == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 52c7826df44..8c151af521d 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -395,7 +395,7 @@ static int snd_emu10k1x_playback_open(snd_pcm_substream_t *substream) if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) return err; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = chip; @@ -571,7 +571,7 @@ static int snd_emu10k1x_pcm_open_capture(snd_pcm_substream_t *substream) if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) return err; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; @@ -920,7 +920,7 @@ static int __devinit snd_emu10k1x_create(snd_card_t *card, return -ENXIO; } - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 2f7a03103c9..646b5d972e6 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -1036,7 +1036,7 @@ static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu) spin_lock_init(&emu->fx8010.irq_lock); INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); - if ((icode = kcalloc(1, sizeof(*icode), GFP_KERNEL)) == NULL || + if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL || (icode->gpr_map = (u_int32_t __user *)kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), GFP_KERNEL)) == NULL || (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(*controls), GFP_KERNEL)) == NULL) { err = -ENOMEM; @@ -1503,11 +1503,11 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) spin_lock_init(&emu->fx8010.irq_lock); INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); - if ((icode = kcalloc(1, sizeof(*icode), GFP_KERNEL)) == NULL) + if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL) return -ENOMEM; if ((icode->gpr_map = (u_int32_t __user *)kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), GFP_KERNEL)) == NULL || (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(emu10k1_fx8010_control_gpr_t), GFP_KERNEL)) == NULL || - (ipcm = kcalloc(1, sizeof(*ipcm), GFP_KERNEL)) == NULL) { + (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) { err = -ENOMEM; goto __err; } @@ -2217,7 +2217,7 @@ static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigne kfree(ipcm); return res; case SNDRV_EMU10K1_IOCTL_PCM_PEEK: - ipcm = kcalloc(1, sizeof(*ipcm), GFP_KERNEL); + ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL); if (ipcm == NULL) return -ENOMEM; if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 9c35f6dde1b..66ba27afe96 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -1016,7 +1016,7 @@ static int snd_emu10k1_efx_playback_open(snd_pcm_substream_t * substream) snd_pcm_runtime_t *runtime = substream->runtime; int i; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = emu; @@ -1049,7 +1049,7 @@ static int snd_emu10k1_playback_open(snd_pcm_substream_t * substream) snd_pcm_runtime_t *runtime = substream->runtime; int i, err; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = emu; @@ -1094,7 +1094,7 @@ static int snd_emu10k1_capture_open(snd_pcm_substream_t * substream) snd_pcm_runtime_t *runtime = substream->runtime; emu10k1_pcm_t *epcm; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = emu; @@ -1130,7 +1130,7 @@ static int snd_emu10k1_capture_mic_open(snd_pcm_substream_t * substream) emu10k1_pcm_t *epcm; snd_pcm_runtime_t *runtime = substream->runtime; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = emu; @@ -1170,7 +1170,7 @@ static int snd_emu10k1_capture_efx_open(snd_pcm_substream_t * substream) int nefx = emu->audigy ? 64 : 32; int idx; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) return -ENOMEM; epcm->emu = emu; diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index a1691330d3b..d59c7f345ad 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -178,7 +178,7 @@ static int snd_p16v_pcm_open_playback_channel(snd_pcm_substream_t *substream, in snd_pcm_runtime_t *runtime = substream->runtime; int err; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); //snd_printk("epcm kcalloc: %p\n", epcm); if (epcm == NULL) @@ -214,7 +214,7 @@ static int snd_p16v_pcm_open_capture_channel(snd_pcm_substream_t *substream, int snd_pcm_runtime_t *runtime = substream->runtime; int err; - epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); + epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); //snd_printk("epcm kcalloc: %p\n", epcm); if (epcm == NULL) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index e2c3a375855..a38f7102ecc 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1943,7 +1943,7 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, *rensoniq = NULL; if ((err = pci_enable_device(pci)) < 0) return err; - ensoniq = kcalloc(1, sizeof(*ensoniq), GFP_KERNEL); + ensoniq = kzalloc(sizeof(*ensoniq), GFP_KERNEL); if (ensoniq == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index b3f78a5bb64..356c493d931 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1494,7 +1494,7 @@ static int __devinit snd_es1938_create(snd_card_t * card, return -ENXIO; } - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 8cfe80fcd77..10a487a78d6 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -1577,7 +1577,7 @@ static int snd_es1968_playback_open(snd_pcm_substream_t *substream) if (apu1 < 0) return apu1; - es = kcalloc(1, sizeof(*es), GFP_KERNEL); + es = kzalloc(sizeof(*es), GFP_KERNEL); if (!es) { snd_es1968_free_apu_pair(chip, apu1); return -ENOMEM; @@ -1622,7 +1622,7 @@ static int snd_es1968_capture_open(snd_pcm_substream_t *substream) return apu2; } - es = kcalloc(1, sizeof(*es), GFP_KERNEL); + es = kzalloc(sizeof(*es), GFP_KERNEL); if (!es) { snd_es1968_free_apu_pair(chip, apu1); snd_es1968_free_apu_pair(chip, apu2); @@ -2569,7 +2569,7 @@ static int __devinit snd_es1968_create(snd_card_t * card, return -ENXIO; } - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (! chip) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 36b2f62e857..aaa41fb480a 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1263,7 +1263,7 @@ static int __devinit snd_fm801_create(snd_card_t * card, *rchip = NULL; if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 20f7762f714..3815403ed09 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -288,7 +288,7 @@ static int init_unsol_queue(struct hda_bus *bus) { struct hda_bus_unsolicited *unsol; - unsol = kcalloc(1, sizeof(*unsol), GFP_KERNEL); + unsol = kzalloc(sizeof(*unsol), GFP_KERNEL); if (! unsol) { snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n"); return -ENOMEM; @@ -358,7 +358,7 @@ int snd_hda_bus_new(snd_card_t *card, const struct hda_bus_template *temp, if (busp) *busp = NULL; - bus = kcalloc(1, sizeof(*bus), GFP_KERNEL); + bus = kzalloc(sizeof(*bus), GFP_KERNEL); if (bus == NULL) { snd_printk(KERN_ERR "can't allocate struct hda_bus\n"); return -ENOMEM; @@ -493,7 +493,7 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, return -EBUSY; } - codec = kcalloc(1, sizeof(*codec), GFP_KERNEL); + codec = kzalloc(sizeof(*codec), GFP_KERNEL); if (codec == NULL) { snd_printk(KERN_ERR "can't allocate struct hda_codec\n"); return -ENOMEM; diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 1229227af5b..5b829a1a4c6 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -98,7 +98,7 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid struct hda_gnode *node; int nconns; - node = kcalloc(1, sizeof(*node), GFP_KERNEL); + node = kzalloc(sizeof(*node), GFP_KERNEL); if (node == NULL) return -ENOMEM; node->nid = nid; @@ -886,7 +886,7 @@ int snd_hda_parse_generic_codec(struct hda_codec *codec) return -ENODEV; } - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) { printk(KERN_ERR "hda_generic: can't allocate spec\n"); return -ENOMEM; diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index a8eaeb463b0..7e0c05936c3 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1402,7 +1402,7 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (NULL == chip) { snd_printk(KERN_ERR SFX "cannot allocate chip\n"); diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index bceb83a42a3..da6874d3988 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -465,7 +465,7 @@ static int patch_ad1986a(struct hda_codec *codec) { struct ad198x_spec *spec; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; @@ -623,7 +623,7 @@ static int patch_ad1983(struct hda_codec *codec) { struct ad198x_spec *spec; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; @@ -764,7 +764,7 @@ static int patch_ad1981(struct hda_codec *codec) { struct ad198x_spec *spec; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index 07fb4f5a54b..523c362ec44 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c @@ -667,7 +667,7 @@ static int patch_cmi9880(struct hda_codec *codec) { struct cmi_spec *spec; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 45f286faa21..849b5b50c92 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2095,7 +2095,7 @@ static int patch_alc880(struct hda_codec *codec) int board_config; int i, err; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; @@ -2367,7 +2367,7 @@ static int patch_alc260(struct hda_codec *codec) struct alc_spec *spec; int board_config; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; @@ -2617,7 +2617,7 @@ static int patch_alc882(struct hda_codec *codec) { struct alc_spec *spec; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c index c41fb9acdce..d014b7bb70d 100644 --- a/sound/pci/hda/patch_si3054.c +++ b/sound/pci/hda/patch_si3054.c @@ -283,7 +283,7 @@ static struct hda_codec_ops si3054_patch_ops = { static int patch_si3054(struct hda_codec *codec) { - struct si3054_spec *spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + struct si3054_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; codec->spec = spec; diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 9d503da7320..33a8adaea76 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -919,7 +919,7 @@ static int patch_stac9200(struct hda_codec *codec) struct sigmatel_spec *spec; int err; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; @@ -957,7 +957,7 @@ static int patch_stac922x(struct hda_codec *codec) struct sigmatel_spec *spec; int err; - spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) return -ENOMEM; diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c index 4405d96cbed..2e0a31613ee 100644 --- a/sound/pci/ice1712/aureon.c +++ b/sound/pci/ice1712/aureon.c @@ -1796,7 +1796,7 @@ static int __devinit aureon_init(ice1712_t *ice) } /* to remeber the register values of CS8415 */ - ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); + ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL); if (! ice->akm) return -ENOMEM; ice->akm_codecs = 1; diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index f4616053150..7d4d9b0c6b1 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -2529,7 +2529,7 @@ static int __devinit snd_ice1712_create(snd_card_t * card, return -ENXIO; } - ice = kcalloc(1, sizeof(*ice), GFP_KERNEL); + ice = kzalloc(sizeof(*ice), GFP_KERNEL); if (ice == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 78fc05c0800..1e7119acfd4 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -2124,7 +2124,7 @@ static int __devinit snd_vt1724_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - ice = kcalloc(1, sizeof(*ice), GFP_KERNEL); + ice = kzalloc(sizeof(*ice), GFP_KERNEL); if (ice == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index 3fb297b969c..2437876a44e 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c @@ -182,7 +182,7 @@ static int __devinit juli_init(ice1712_t *ice) ice->num_total_dacs = 2; ice->num_total_adcs = 2; - ak = ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); + ak = ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL); if (! ak) return -ENOMEM; ice->akm_codecs = 1; diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c index 5bf734b04fa..dcf1e8ca3f6 100644 --- a/sound/pci/ice1712/phase.c +++ b/sound/pci/ice1712/phase.c @@ -122,7 +122,7 @@ static int __devinit phase22_init(ice1712_t *ice) } // Initialize analog chips - ak = ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); + ak = ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL); if (! ak) return -ENOMEM; ice->akm_codecs = 1; @@ -386,7 +386,7 @@ static int __devinit phase28_init(ice1712_t *ice) ice->num_total_adcs = 2; // Initialize analog chips - ak = ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); + ak = ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL); if (!ak) return -ENOMEM; ice->akm_codecs = 1; diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c index 25f827d8fbd..a5f852b1f57 100644 --- a/sound/pci/ice1712/pontis.c +++ b/sound/pci/ice1712/pontis.c @@ -781,7 +781,7 @@ static int __devinit pontis_init(ice1712_t *ice) ice->num_total_adcs = 2; /* to remeber the register values */ - ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); + ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL); if (! ice->akm) return -ENOMEM; ice->akm_codecs = 1; diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 47965dfcbee..5975cd58054 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2604,7 +2604,7 @@ static int __devinit snd_intel8x0_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 282b4bd67c3..38493d77528 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -1113,7 +1113,7 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index d2aa9c82d41..5f61536f112 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -2220,7 +2220,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, if ((err = pci_enable_device(pci)) < 0) return err; - korg1212 = kcalloc(1, sizeof(*korg1212), GFP_KERNEL); + korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL); if (korg1212 == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 7b85a472292..635531c2aa0 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -2660,7 +2660,7 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, return -ENXIO; } - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 6c868d91363..2636d507bdf 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1004,7 +1004,7 @@ static int __devinit snd_mixart_create(mixart_mgr_t *mgr, snd_card_t *card, int .dev_free = snd_mixart_chip_dev_free, }; - mgr->chip[idx] = chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (! chip) { snd_printk(KERN_ERR "cannot allocate chip\n"); return -ENOMEM; @@ -1292,7 +1292,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, /* */ - mgr = kcalloc(1, sizeof(*mgr), GFP_KERNEL); + mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); if (! mgr) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 542b58e4bf4..b44d56c2dd3 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1389,7 +1389,7 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci, if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 3d431390c1c..57c8ff5f526 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -1250,7 +1250,7 @@ static int __devinit snd_sonicvibes_create(snd_card_t * card, return -ENXIO; } - sonic = kcalloc(1, sizeof(*sonic), GFP_KERNEL); + sonic = kzalloc(sizeof(*sonic), GFP_KERNEL); if (sonic == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index f30d9d94786..777da9a7298 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -2960,7 +2960,7 @@ static int __devinit snd_trident_mixer(trident_t * trident, int pcm_spdif_device .read = snd_trident_codec_read, }; - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (!uctl) return -ENOMEM; @@ -3546,7 +3546,7 @@ int __devinit snd_trident_create(snd_card_t * card, return -ENXIO; } - trident = kcalloc(1, sizeof(*trident), GFP_KERNEL); + trident = kzalloc(sizeof(*trident), GFP_KERNEL); if (trident == NULL) { pci_disable_device(pci); return -ENOMEM; diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index cfd2c9cc9b3..a58f88a552a 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2058,7 +2058,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL) { + if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) { pci_disable_device(pci); return -ENOMEM; } diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 5872d438a04..e36f538d02f 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -1083,7 +1083,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL) { + if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) { pci_disable_device(pci); return -ENOMEM; } diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 054836412dc..27fa523639a 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -839,7 +839,7 @@ static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream) snd_pcm_runtime_t *runtime = substream->runtime; ymfpci_pcm_t *ypcm; - ypcm = kcalloc(1, sizeof(*ypcm), GFP_KERNEL); + ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL); if (ypcm == NULL) return -ENOMEM; ypcm->chip = chip; @@ -957,7 +957,7 @@ static int snd_ymfpci_capture_open(snd_pcm_substream_t * substream, snd_pcm_runtime_t *runtime = substream->runtime; ymfpci_pcm_t *ypcm; - ypcm = kcalloc(1, sizeof(*ypcm), GFP_KERNEL); + ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL); if (ypcm == NULL) return -ENOMEM; ypcm->chip = chip; @@ -2270,7 +2270,7 @@ int __devinit snd_ymfpci_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; -- cgit v1.2.3 From 561b220a4dece18d67177413e6fa21b49aa4acce Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 9 Sep 2005 14:22:34 +0200 Subject: [ALSA] Replace with kzalloc() - others Documentation,SA11xx UDA1341 driver,Generic drivers,MPU401 UART,OPL3 OPL4,Digigram VX core,I2C cs8427,I2C lib core,I2C tea6330t,L3 drivers AK4114 receiver,AK4117 receiver,PDAudioCF driver,PPC PMAC driver SPARC AMD7930 driver,SPARC cs4231 driver,Synth,Common EMU synth USB generic driver,USB USX2Y Replace kcalloc(1,..) with kzalloc(). Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 10 +++++----- sound/arm/sa11xx-uda1341.c | 4 ++-- sound/drivers/dummy.c | 4 ++-- sound/drivers/mpu401/mpu401_uart.c | 2 +- sound/drivers/mtpav.c | 2 +- sound/drivers/opl3/opl3_lib.c | 2 +- sound/drivers/opl3/opl3_oss.c | 2 +- sound/drivers/opl4/opl4_lib.c | 2 +- sound/drivers/serial-u16550.c | 2 +- sound/drivers/vx/vx_core.c | 2 +- sound/drivers/vx/vx_pcm.c | 2 +- sound/i2c/cs8427.c | 2 +- sound/i2c/i2c.c | 4 ++-- sound/i2c/l3/uda1341.c | 6 +++--- sound/i2c/other/ak4114.c | 2 +- sound/i2c/other/ak4117.c | 2 +- sound/i2c/tea6330t.c | 2 +- sound/pcmcia/pdaudiocf/pdaudiocf_core.c | 2 +- sound/ppc/pmac.c | 2 +- sound/sparc/amd7930.c | 2 +- sound/sparc/cs4231.c | 4 ++-- sound/synth/emux/emux.c | 2 +- sound/synth/emux/emux_seq.c | 2 +- sound/synth/emux/soundfont.c | 8 ++++---- sound/synth/util_mem.c | 2 +- sound/usb/usbaudio.c | 2 +- sound/usb/usbmidi.c | 6 +++--- sound/usb/usbmixer.c | 10 +++++----- sound/usb/usx2y/usbusx2yaudio.c | 2 +- 29 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index 0475478c248..24e85520890 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -447,7 +447,7 @@ .... /* allocate a chip-specific data with zero filled */ - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; @@ -949,7 +949,7 @@ After allocating a card instance via snd_card_new() (with NULL on the 4th arg), call - kcalloc(). + kzalloc(). @@ -958,7 +958,7 @@ mychip_t *chip; card = snd_card_new(index[dev], id[dev], THIS_MODULE, NULL); ..... - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); ]]> @@ -1136,7 +1136,7 @@ return -ENXIO; } - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pci_disable_device(pci); return -ENOMEM; @@ -1292,7 +1292,7 @@ need to initialize this number as -1 before actual allocation, since irq 0 is valid. The port address and its resource pointer can be initialized as null by - kcalloc() automatically, so you + kzalloc() automatically, so you don't have to take care of resetting them. diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index 813959f185e..6ee912259cc 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c @@ -21,7 +21,7 @@ * merged HAL layer (patches from Brian) */ -/* $Id: sa11xx-uda1341.c,v 1.22 2005/09/05 16:17:58 tiwai Exp $ */ +/* $Id: sa11xx-uda1341.c,v 1.23 2005/09/09 13:22:34 tiwai Exp $ */ /*************************************************************************************************** * @@ -918,7 +918,7 @@ static int __init sa11xx_uda1341_init(void) if (card == NULL) return -ENOMEM; - sa11xx_uda1341 = kcalloc(1, sizeof(*sa11xx_uda1341), GFP_KERNEL); + sa11xx_uda1341 = kzalloc(sizeof(*sa11xx_uda1341), GFP_KERNEL); if (sa11xx_uda1341 == NULL) return -ENOMEM; spin_lock_init(&chip->s[0].dma_lock); diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 977d98d26a8..64ef7f62851 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -337,7 +337,7 @@ static int snd_card_dummy_playback_open(snd_pcm_substream_t * substream) snd_card_dummy_pcm_t *dpcm; int err; - dpcm = kcalloc(1, sizeof(*dpcm), GFP_KERNEL); + dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); if (dpcm == NULL) return -ENOMEM; init_timer(&dpcm->timer); @@ -368,7 +368,7 @@ static int snd_card_dummy_capture_open(snd_pcm_substream_t * substream) snd_card_dummy_pcm_t *dpcm; int err; - dpcm = kcalloc(1, sizeof(*dpcm), GFP_KERNEL); + dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); if (dpcm == NULL) return -ENOMEM; init_timer(&dpcm->timer); diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index 0f83c5241b6..fe3f921ffbe 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -463,7 +463,7 @@ int snd_mpu401_uart_new(snd_card_t * card, int device, *rrawmidi = NULL; if ((err = snd_rawmidi_new(card, "MPU-401U", device, 1, 1, &rmidi)) < 0) return err; - mpu = kcalloc(1, sizeof(*mpu), GFP_KERNEL); + mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); if (mpu == NULL) { snd_device_free(card, rmidi); return -ENOMEM; diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index b8199d20be8..3a25c89d298 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -688,7 +688,7 @@ static int snd_mtpav_get_RAWMIDI(mtpav_t * mcard) static mtpav_t *new_mtpav(void) { - mtpav_t *ncrd = kcalloc(1, sizeof(*ncrd), GFP_KERNEL); + mtpav_t *ncrd = kzalloc(sizeof(*ncrd), GFP_KERNEL); if (ncrd != NULL) { spin_lock_init(&ncrd->spinlock); diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index c313e5205cb..1f84d78260d 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -354,7 +354,7 @@ int snd_opl3_new(snd_card_t *card, int err; *ropl3 = NULL; - opl3 = kcalloc(1, sizeof(*opl3), GFP_KERNEL); + opl3 = kzalloc(sizeof(*opl3), GFP_KERNEL); if (opl3 == NULL) return -ENOMEM; diff --git a/sound/drivers/opl3/opl3_oss.c b/sound/drivers/opl3/opl3_oss.c index 33da334ae98..21a2b409d6d 100644 --- a/sound/drivers/opl3/opl3_oss.c +++ b/sound/drivers/opl3/opl3_oss.c @@ -241,7 +241,7 @@ static int snd_opl3_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, } size = sizeof(*put) + sizeof(fm_xinstrument_t); - put = kcalloc(1, size, GFP_KERNEL); + put = kzalloc(size, GFP_KERNEL); if (put == NULL) return -ENOMEM; /* build header */ diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c index 8261464dade..380c2c704c5 100644 --- a/sound/drivers/opl4/opl4_lib.c +++ b/sound/drivers/opl4/opl4_lib.c @@ -204,7 +204,7 @@ int snd_opl4_create(snd_card_t *card, if (ropl4) *ropl4 = NULL; - opl4 = kcalloc(1, sizeof(*opl4), GFP_KERNEL); + opl4 = kzalloc(sizeof(*opl4), GFP_KERNEL); if (!opl4) return -ENOMEM; diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index fd3bb9dd1d2..416172ea1f4 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -779,7 +779,7 @@ static int __init snd_uart16550_create(snd_card_t * card, int err; - if ((uart = kcalloc(1, sizeof(*uart), GFP_KERNEL)) == NULL) + if ((uart = kzalloc(sizeof(*uart), GFP_KERNEL)) == NULL) return -ENOMEM; uart->adaptor = adaptor; uart->card = card; diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index c6fa5afa3e9..4697b1d75cb 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -782,7 +782,7 @@ vx_core_t *snd_vx_create(snd_card_t *card, struct snd_vx_hardware *hw, snd_assert(card && hw && ops, return NULL); - chip = kcalloc(1, sizeof(*chip) + extra_size, GFP_KERNEL); + chip = kzalloc(sizeof(*chip) + extra_size, GFP_KERNEL); if (! chip) { snd_printk(KERN_ERR "vx_core: no memory\n"); return NULL; diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index d4becf44e24..c2312d912fc 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c @@ -473,7 +473,7 @@ static int vx_alloc_pipe(vx_core_t *chip, int capture, return err; /* initialize the pipe record */ - pipe = kcalloc(1, sizeof(*pipe), GFP_KERNEL); + pipe = kzalloc(sizeof(*pipe), GFP_KERNEL); if (! pipe) { /* release the pipe */ vx_init_rmh(&rmh, CMD_FREE_PIPE); diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c index a3fda859dd1..a21f7d541f8 100644 --- a/sound/i2c/cs8427.c +++ b/sound/i2c/cs8427.c @@ -200,7 +200,7 @@ int snd_cs8427_create(snd_i2c_bus_t *bus, if ((err = snd_i2c_device_create(bus, "CS8427", CS8427_ADDR | (addr & 7), &device)) < 0) return err; - chip = device->private_data = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = device->private_data = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { snd_i2c_device_free(device); return -ENOMEM; diff --git a/sound/i2c/i2c.c b/sound/i2c/i2c.c index e8fa7e1a68e..e4e505b9d88 100644 --- a/sound/i2c/i2c.c +++ b/sound/i2c/i2c.c @@ -81,7 +81,7 @@ int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t *master }; *ri2c = NULL; - bus = kcalloc(1, sizeof(*bus), GFP_KERNEL); + bus = kzalloc(sizeof(*bus), GFP_KERNEL); if (bus == NULL) return -ENOMEM; init_MUTEX(&bus->lock_mutex); @@ -108,7 +108,7 @@ int snd_i2c_device_create(snd_i2c_bus_t *bus, const char *name, unsigned char ad *rdevice = NULL; snd_assert(bus != NULL, return -EINVAL); - device = kcalloc(1, sizeof(*device), GFP_KERNEL); + device = kzalloc(sizeof(*device), GFP_KERNEL); if (device == NULL) return -ENOMEM; device->addr = addr; diff --git a/sound/i2c/l3/uda1341.c b/sound/i2c/l3/uda1341.c index e13122f3fc5..103a7dcd0dd 100644 --- a/sound/i2c/l3/uda1341.c +++ b/sound/i2c/l3/uda1341.c @@ -17,7 +17,7 @@ * 2002-05-12 Tomas Kasparek another code cleanup */ -/* $Id: uda1341.c,v 1.15 2005/01/03 12:05:20 tiwai Exp $ */ +/* $Id: uda1341.c,v 1.16 2005/09/09 13:22:34 tiwai Exp $ */ #include #include @@ -670,7 +670,7 @@ int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clnt) snd_assert(card != NULL, return -EINVAL); - uda1341 = kcalloc(1, sizeof(*uda1341), GFP_KERNEL); + uda1341 = kzalloc(sizeof(*uda1341), GFP_KERNEL); if (uda1341 == NULL) return -ENOMEM; @@ -707,7 +707,7 @@ static int uda1341_attach(struct l3_client *clnt) { struct uda1341 *uda; - uda = kcalloc(1, sizeof(*uda), 0, GFP_KERNEL); + uda = kzalloc(sizeof(*uda), 0, GFP_KERNEL); if (!uda) return -ENOMEM; diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index 5adde308a00..af5eadcddd9 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -92,7 +92,7 @@ int snd_ak4114_create(snd_card_t *card, .dev_free = snd_ak4114_dev_free, }; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; spin_lock_init(&chip->lock); diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c index 0419c4336a5..d51b51dd86d 100644 --- a/sound/i2c/other/ak4117.c +++ b/sound/i2c/other/ak4117.c @@ -83,7 +83,7 @@ int snd_ak4117_create(snd_card_t *card, ak4117_read_t *read, ak4117_write_t *wri .dev_free = snd_ak4117_dev_free, }; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; spin_lock_init(&chip->lock); diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c index 2da8d7f157f..fd65da65426 100644 --- a/sound/i2c/tea6330t.c +++ b/sound/i2c/tea6330t.c @@ -281,7 +281,7 @@ int snd_tea6330t_update_mixer(snd_card_t * card, u8 default_treble, default_bass; unsigned char bytes[7]; - tea = kcalloc(1, sizeof(*tea), GFP_KERNEL); + tea = kzalloc(sizeof(*tea), GFP_KERNEL); if (tea == NULL) return -ENOMEM; if ((err = snd_i2c_device_create(bus, "TEA6330T", TEA6330T_ADDR, &device)) < 0) { diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c index a2132e3763d..0208c54896b 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c @@ -151,7 +151,7 @@ pdacf_t *snd_pdacf_create(snd_card_t *card) { pdacf_t *chip; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return NULL; chip->card = card; diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 9774e568ee0..e35b48d29c4 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -1160,7 +1160,7 @@ int __init snd_pmac_new(snd_card_t *card, pmac_t **chip_return) snd_runtime_check(chip_return, return -EINVAL); *chip_return = NULL; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; chip->card = card; diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index ed0d5f2f088..46d504ba7e0 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -967,7 +967,7 @@ static int __init snd_amd7930_create(snd_card_t *card, int err; *ramd = NULL; - amd = kcalloc(1, sizeof(*amd), GFP_KERNEL); + amd = kzalloc(sizeof(*amd), GFP_KERNEL); if (amd == NULL) return -ENOMEM; diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index bd169f54118..2fb27c4e951 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1969,7 +1969,7 @@ static int __init snd_cs4231_sbus_create(snd_card_t *card, int err; *rchip = NULL; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; @@ -2083,7 +2083,7 @@ static int __init snd_cs4231_ebus_create(snd_card_t *card, int err; *rchip = NULL; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c index 60d0b2c6669..9e2b4c0c8a8 100644 --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c @@ -40,7 +40,7 @@ int snd_emux_new(snd_emux_t **remu) snd_emux_t *emu; *remu = NULL; - emu = kcalloc(1, sizeof(*emu), GFP_KERNEL); + emu = kzalloc(sizeof(*emu), GFP_KERNEL); if (emu == NULL) return -ENOMEM; diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index e41b28d9bf5..8ccd33f4aa5 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -146,7 +146,7 @@ snd_emux_create_port(snd_emux_t *emu, char *name, int i, type, cap; /* Allocate structures for this channel */ - if ((p = kcalloc(1, sizeof(*p), GFP_KERNEL)) == NULL) { + if ((p = kzalloc(sizeof(*p), GFP_KERNEL)) == NULL) { snd_printk("no memory\n"); return NULL; } diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index 901a7db05bd..d0925ea5083 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -266,7 +266,7 @@ newsf(snd_sf_list_t *sflist, int type, char *name) } /* not found -- create a new one */ - sf = kcalloc(1, sizeof(*sf), GFP_KERNEL); + sf = kzalloc(sizeof(*sf), GFP_KERNEL); if (sf == NULL) return NULL; sf->id = sflist->fonts_size; @@ -346,7 +346,7 @@ sf_zone_new(snd_sf_list_t *sflist, snd_soundfont_t *sf) { snd_sf_zone_t *zp; - if ((zp = kcalloc(1, sizeof(*zp), GFP_KERNEL)) == NULL) + if ((zp = kzalloc(sizeof(*zp), GFP_KERNEL)) == NULL) return NULL; zp->next = sf->zones; sf->zones = zp; @@ -377,7 +377,7 @@ sf_sample_new(snd_sf_list_t *sflist, snd_soundfont_t *sf) { snd_sf_sample_t *sp; - if ((sp = kcalloc(1, sizeof(*sp), GFP_KERNEL)) == NULL) + if ((sp = kzalloc(sizeof(*sp), GFP_KERNEL)) == NULL) return NULL; sp->next = sf->samples; @@ -1362,7 +1362,7 @@ snd_sf_new(snd_sf_callback_t *callback, snd_util_memhdr_t *hdr) { snd_sf_list_t *sflist; - if ((sflist = kcalloc(1, sizeof(*sflist), GFP_KERNEL)) == NULL) + if ((sflist = kzalloc(sizeof(*sflist), GFP_KERNEL)) == NULL) return NULL; init_MUTEX(&sflist->presets_mutex); diff --git a/sound/synth/util_mem.c b/sound/synth/util_mem.c index 8b131a11e54..5f75bf31bc3 100644 --- a/sound/synth/util_mem.c +++ b/sound/synth/util_mem.c @@ -38,7 +38,7 @@ snd_util_memhdr_new(int memsize) { snd_util_memhdr_t *hdr; - hdr = kcalloc(1, sizeof(*hdr), GFP_KERNEL); + hdr = kzalloc(sizeof(*hdr), GFP_KERNEL); if (hdr == NULL) return NULL; hdr->size = memsize; diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index da22f25d4ef..d5ae2055b89 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -3136,7 +3136,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, return -ENOMEM; } - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (! chip) { snd_card_free(card); return -ENOMEM; diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index 93dedde3c42..e0d0365453b 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c @@ -841,7 +841,7 @@ static int snd_usbmidi_in_endpoint_create(snd_usb_midi_t* umidi, int length; rep->in = NULL; - ep = kcalloc(1, sizeof(*ep), GFP_KERNEL); + ep = kzalloc(sizeof(*ep), GFP_KERNEL); if (!ep) return -ENOMEM; ep->umidi = umidi; @@ -913,7 +913,7 @@ static int snd_usbmidi_out_endpoint_create(snd_usb_midi_t* umidi, void* buffer; rep->out = NULL; - ep = kcalloc(1, sizeof(*ep), GFP_KERNEL); + ep = kzalloc(sizeof(*ep), GFP_KERNEL); if (!ep) return -ENOMEM; ep->umidi = umidi; @@ -1537,7 +1537,7 @@ int snd_usb_create_midi_interface(snd_usb_audio_t* chip, int out_ports, in_ports; int i, err; - umidi = kcalloc(1, sizeof(*umidi), GFP_KERNEL); + umidi = kzalloc(sizeof(*umidi), GFP_KERNEL); if (!umidi) return -ENOMEM; umidi->chip = chip; diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index fa7056f5caa..c3c08c9cb46 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c @@ -824,7 +824,7 @@ static void build_feature_ctl(mixer_build_t *state, unsigned char *desc, if (check_ignored_ctl(state, unitid, control)) return; - cval = kcalloc(1, sizeof(*cval), GFP_KERNEL); + cval = kzalloc(sizeof(*cval), GFP_KERNEL); if (! cval) { snd_printk(KERN_ERR "cannot malloc kcontrol\n"); return; @@ -997,7 +997,7 @@ static void build_mixer_unit_ctl(mixer_build_t *state, unsigned char *desc, if (check_ignored_ctl(state, unitid, 0)) return; - cval = kcalloc(1, sizeof(*cval), GFP_KERNEL); + cval = kzalloc(sizeof(*cval), GFP_KERNEL); if (! cval) return; @@ -1244,7 +1244,7 @@ static int build_audio_procunit(mixer_build_t *state, int unitid, unsigned char continue; if (check_ignored_ctl(state, unitid, valinfo->control)) continue; - cval = kcalloc(1, sizeof(*cval), GFP_KERNEL); + cval = kzalloc(sizeof(*cval), GFP_KERNEL); if (! cval) { snd_printk(KERN_ERR "cannot malloc kcontrol\n"); return -ENOMEM; @@ -1430,7 +1430,7 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned if (check_ignored_ctl(state, unitid, 0)) return 0; - cval = kcalloc(1, sizeof(*cval), GFP_KERNEL); + cval = kzalloc(sizeof(*cval), GFP_KERNEL); if (! cval) { snd_printk(KERN_ERR "cannot malloc kcontrol\n"); return -ENOMEM; @@ -1945,7 +1945,7 @@ int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif) strcpy(chip->card->mixername, "USB Mixer"); - mixer = kcalloc(1, sizeof(*mixer), GFP_KERNEL); + mixer = kzalloc(sizeof(*mixer), GFP_KERNEL); if (!mixer) return -ENOMEM; mixer->chip = chip; diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 62dfd28b3b0..0f09e0de52d 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -957,7 +957,7 @@ static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int c for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { - usX2Y_substream[i] = kcalloc(1, sizeof(snd_usX2Y_substream_t), GFP_KERNEL); + usX2Y_substream[i] = kzalloc(sizeof(snd_usX2Y_substream_t), GFP_KERNEL); if (NULL == usX2Y_substream[i]) { snd_printk(KERN_ERR "cannot malloc\n"); return -ENOMEM; -- cgit v1.2.3 From 1b44c28dc180f4d0ea109e1fe4339b3403c2d530 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 9 Sep 2005 15:05:33 +0200 Subject: [ALSA] Another fix for DocBook PCM Midlevel Revive snd_pcm_format_cpu_endian() document. Signed-off-by: Takashi Iwai --- include/sound/pcm.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 7a7f7287288..2b23a596707 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -903,7 +903,8 @@ int snd_pcm_format_unsigned(snd_pcm_format_t format); int snd_pcm_format_linear(snd_pcm_format_t format); int snd_pcm_format_little_endian(snd_pcm_format_t format); int snd_pcm_format_big_endian(snd_pcm_format_t format); -/* +#if 0 /* just for DocBook */ +/** * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian * @format: the format to check * @@ -911,6 +912,7 @@ int snd_pcm_format_big_endian(snd_pcm_format_t format); * opposite, or a negative error code if endian not specified. */ int snd_pcm_format_cpu_endian(snd_pcm_format_t format); +#endif /* DocBook */ #ifdef SNDRV_LITTLE_ENDIAN #define snd_pcm_format_cpu_endian(format) snd_pcm_format_little_endian(format) #else -- cgit v1.2.3 From afe0f1f6688f4c4c9235873121548e76dedd8ef8 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Sat, 10 Sep 2005 10:24:10 +0200 Subject: [ALSA] snd-emu10k1: ALSA bug#1297: Fix a error recognising the SB Live Platinum. EMU10K1/EMU10K2 driver The card does not have an AC97 chip. .subsystem = 0x80611102 Signed-off-by: James Courtier-Dutton --- sound/pci/emu10k1/emu10k1_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 03617ec0742..e87e8427f25 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -754,12 +754,11 @@ static emu_chip_details_t emu_chip_details[] = { .emu10k1_chip = 1, .ac97_chip = 1, .sblive51 = 1} , - /* Tested by alsa bugtrack user "hus" 12th Sept 2005 */ + /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */ {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, - .driver = "EMU10K1", .name = "SBLive! Player 5.1 [SB0060]", + .driver = "EMU10K1", .name = "SBLive! Platinum 5.1 [SB0060]", .id = "Live", .emu10k1_chip = 1, - .ac97_chip = 1, .sblive51 = 1} , {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", -- cgit v1.2.3 From 4338829e09db2d320a00b4e0ed0bcc49859d73cc Mon Sep 17 00:00:00 2001 From: Martin Habets Date: Sat, 10 Sep 2005 15:39:00 +0200 Subject: [ALSA] Several fixes for the Sun DBRI driver SPARC DBRI driver This patch contains the following fixes to the Alsa DBRI driver: - Remove 2.6.13 build warning on the prom_getproperty() call. - Rework command synchronization: send a sequence number with D_WAIT, and check it in the completion interrupt. Move synchronization delays from _cmdsend() to _cmdlock() allowing the CPU to do other usefull things while the DBRI is processing the commands. - Fix first argument of printk() calls. - Enable burst transfers for DBRI. Original 2.4 patch from Krzysztof Helt - Make dbri_debug module parameter writable from sysfs. Remove obsolete write access to the /proc debug file. - Replace udelay() with msleep_interruptible() where possible. - Update documentation comments. Signed-off-by: Martin Habets Signed-off-by: Takashi Iwai --- sound/sparc/dbri.c | 205 +++++++++++++++++++++++++++-------------------------- 1 file changed, 103 insertions(+), 102 deletions(-) diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index a56f81bb004..b5c4c15ae7f 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -1,6 +1,6 @@ /* * Driver for DBRI sound chip found on Sparcs. - * Copyright (C) 2004 Martin Habets (mhabets@users.sourceforge.net) + * Copyright (C) 2004, 2005 Martin Habets (mhabets@users.sourceforge.net) * * Based entirely upon drivers/sbus/audio/dbri.c which is: * Copyright (C) 1997 Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de) @@ -43,6 +43,12 @@ * audio devices. But the SUN HW group decided against it, at least on my * LX the speakerbox connector has at least 1 pin missing and 1 wrongly * connected. + * + * I've tried to stick to the following function naming conventions: + * snd_* ALSA stuff + * cs4215_* CS4215 codec specfic stuff + * dbri_* DBRI high-level stuff + * other DBRI low-level stuff */ #include @@ -87,7 +93,7 @@ MODULE_PARM_DESC(enable, "Enable Sun DBRI soundcard."); #define D_DESC (1<<5) static int dbri_debug = 0; -module_param(dbri_debug, int, 0444); +module_param(dbri_debug, int, 0644); MODULE_PARM_DESC(dbri_debug, "Debug value for Sun DBRI soundcard."); #ifdef DBRI_DEBUG @@ -320,7 +326,8 @@ typedef struct snd_dbri { void __iomem *regs; /* dbri HW regs */ int dbri_version; /* 'e' and up is OK */ int dbri_irqp; /* intr queue pointer */ - int wait_seen; + int wait_send; /* sequence of command buffers send */ + int wait_ackd; /* sequence of command buffers acknowledged */ struct dbri_pipe pipes[DBRI_NO_PIPES]; /* DBRI's 32 data pipes */ struct dbri_desc descs[DBRI_NO_DESCS]; @@ -625,16 +632,13 @@ static __u32 reverse_bytes(__u32 b, int len) Commands are sent to the DBRI by building a list of them in memory, then writing the address of the first list item to DBRI register 8. -The list is terminated with a WAIT command, which can generate a -CPU interrupt if required. +The list is terminated with a WAIT command, which generates a +CPU interrupt to signal completion. Since the DBRI can run in parallel with the CPU, several means of -synchronization present themselves. The original scheme (Rudolf's) -was to set a flag when we "cmdlock"ed the DBRI, clear the flag when -an interrupt signaled completion, and wait on a wait_queue if a routine -attempted to cmdlock while the flag was set. The problems arose when -we tried to cmdlock from inside an interrupt handler, which might -cause scheduling in an interrupt (if we waited), etc, etc +synchronization present themselves. The method implemented here is close +to the original scheme (Rudolf's), and uses 2 counters (wait_send and +wait_ackd) to synchronize the command buffer between the CPU and the DBRI. A more sophisticated scheme might involve a circular command buffer or an array of command buffers. A routine could fill one with @@ -642,70 +646,75 @@ commands and link it onto a list. When a interrupt signaled completion of the current command buffer, look on the list for the next one. -I've decided to implement something much simpler - after each command, -the CPU waits for the DBRI to finish the command by polling the P bit -in DBRI register 0. I've tried to implement this in such a way -that might make implementing a more sophisticated scheme easier. - Every time a routine wants to write commands to the DBRI, it must first call dbri_cmdlock() and get an initial pointer into dbri->dma->cmd -in return. After the commands have been writen, dbri_cmdsend() is -called with the final pointer value. +in return. dbri_cmdlock() will block if the previous commands have not +been completed yet. After this the commands can be written to the buffer, +and dbri_cmdsend() is called with the final pointer value to send them +to the DBRI. */ +static void dbri_process_interrupt_buffer(snd_dbri_t * dbri); + enum dbri_lock_t { NoGetLock, GetLock }; +#define MAXLOOPS 10 static volatile s32 *dbri_cmdlock(snd_dbri_t * dbri, enum dbri_lock_t get) { + int maxloops = MAXLOOPS; + #ifndef SMP if ((get == GetLock) && spin_is_locked(&dbri->lock)) { printk(KERN_ERR "DBRI: cmdlock called while in spinlock."); } #endif + /* Delay if previous commands are still being processed */ + while ((--maxloops) > 0 && (dbri->wait_send != dbri->wait_ackd)) { + msleep_interruptible(1); + /* If dbri_cmdlock() got called from inside the + * interrupt handler, this will do the processing. + */ + dbri_process_interrupt_buffer(dbri); + } + if (maxloops == 0) { + printk(KERN_ERR "DBRI: Chip never completed command buffer %d\n", + dbri->wait_send); + } else { + dprintk(D_CMD, "Chip completed command buffer (%d)\n", + MAXLOOPS - maxloops - 1); + } + /*if (get == GetLock) spin_lock(&dbri->lock); */ return &dbri->dma->cmd[0]; } -static void dbri_process_interrupt_buffer(snd_dbri_t *); - static void dbri_cmdsend(snd_dbri_t * dbri, volatile s32 * cmd) { - int MAXLOOPS = 1000000; - int maxloops = MAXLOOPS; volatile s32 *ptr; + u32 reg; for (ptr = &dbri->dma->cmd[0]; ptr < cmd; ptr++) { dprintk(D_CMD, "cmd: %lx:%08x\n", (unsigned long)ptr, *ptr); } if ((cmd - &dbri->dma->cmd[0]) >= DBRI_NO_CMDS - 1) { - printk("DBRI: Command buffer overflow! (bug in driver)\n"); + printk(KERN_ERR "DBRI: Command buffer overflow! (bug in driver)\n"); /* Ignore the last part. */ cmd = &dbri->dma->cmd[DBRI_NO_CMDS - 3]; } + dbri->wait_send++; + dbri->wait_send &= 0xffff; /* restrict it to a 16 bit counter. */ *(cmd++) = DBRI_CMD(D_PAUSE, 0, 0); - *(cmd++) = DBRI_CMD(D_WAIT, 1, 0); - dbri->wait_seen = 0; + *(cmd++) = DBRI_CMD(D_WAIT, 1, dbri->wait_send); + + /* Set command pointer and signal it is valid. */ sbus_writel(dbri->dma_dvma, dbri->regs + REG8); - while ((--maxloops) > 0 && (sbus_readl(dbri->regs + REG0) & D_P)) - barrier(); - if (maxloops == 0) { - printk(KERN_ERR "DBRI: Chip never completed command buffer\n"); - dprintk(D_CMD, "DBRI: Chip never completed command buffer\n"); - } else { - while ((--maxloops) > 0 && (!dbri->wait_seen)) - dbri_process_interrupt_buffer(dbri); - if (maxloops == 0) { - printk(KERN_ERR "DBRI: Chip never acked WAIT\n"); - dprintk(D_CMD, "DBRI: Chip never acked WAIT\n"); - } else { - dprintk(D_CMD, "Chip completed command " - "buffer (%d)\n", MAXLOOPS - maxloops); - } - } + reg = sbus_readl(dbri->regs + REG0); + reg |= D_P; + sbus_writel(reg, dbri->regs + REG0); /*spin_unlock(&dbri->lock); */ } @@ -757,10 +766,11 @@ static void dbri_initialize(snd_dbri_t * dbri) for (n = 0; n < DBRI_NO_PIPES; n++) dbri->pipes[n].desc = dbri->pipes[n].first_desc = -1; - /* We should query the openprom to see what burst sizes this - * SBus supports. For now, just disable all SBus bursts */ + /* A brute approach - DBRI falls back to working burst size by itself + * On SS20 D_S does not work, so do not try so high. */ tmp = sbus_readl(dbri->regs + REG0); - tmp &= ~(D_G | D_S | D_E); + tmp |= D_G | D_E; + tmp &= ~D_S; sbus_writel(tmp, dbri->regs + REG0); /* @@ -805,13 +815,13 @@ static void reset_pipe(snd_dbri_t * dbri, int pipe) volatile int *cmd; if (pipe < 0 || pipe > 31) { - printk("DBRI: reset_pipe called with illegal pipe number\n"); + printk(KERN_ERR "DBRI: reset_pipe called with illegal pipe number\n"); return; } sdp = dbri->pipes[pipe].sdp; if (sdp == 0) { - printk("DBRI: reset_pipe called on uninitialized pipe\n"); + printk(KERN_ERR "DBRI: reset_pipe called on uninitialized pipe\n"); return; } @@ -834,12 +844,12 @@ static void reset_pipe(snd_dbri_t * dbri, int pipe) static void setup_pipe(snd_dbri_t * dbri, int pipe, int sdp) { if (pipe < 0 || pipe > 31) { - printk("DBRI: setup_pipe called with illegal pipe number\n"); + printk(KERN_ERR "DBRI: setup_pipe called with illegal pipe number\n"); return; } if ((sdp & 0xf800) != sdp) { - printk("DBRI: setup_pipe called with strange SDP value\n"); + printk(KERN_ERR "DBRI: setup_pipe called with strange SDP value\n"); /* sdp &= 0xf800; */ } @@ -872,13 +882,13 @@ static void link_time_slot(snd_dbri_t * dbri, int pipe, int nextpipe; if (pipe < 0 || pipe > 31 || basepipe < 0 || basepipe > 31) { - printk - ("DBRI: link_time_slot called with illegal pipe number\n"); + printk(KERN_ERR + "DBRI: link_time_slot called with illegal pipe number\n"); return; } if (dbri->pipes[pipe].sdp == 0 || dbri->pipes[basepipe].sdp == 0) { - printk("DBRI: link_time_slot called on uninitialized pipe\n"); + printk(KERN_ERR "DBRI: link_time_slot called on uninitialized pipe\n"); return; } @@ -960,8 +970,8 @@ static void unlink_time_slot(snd_dbri_t * dbri, int pipe, int val; if (pipe < 0 || pipe > 31 || prevpipe < 0 || prevpipe > 31) { - printk - ("DBRI: unlink_time_slot called with illegal pipe number\n"); + printk(KERN_ERR + "DBRI: unlink_time_slot called with illegal pipe number\n"); return; } @@ -1001,22 +1011,22 @@ static void xmit_fixed(snd_dbri_t * dbri, int pipe, unsigned int data) volatile s32 *cmd; if (pipe < 16 || pipe > 31) { - printk("DBRI: xmit_fixed: Illegal pipe number\n"); + printk(KERN_ERR "DBRI: xmit_fixed: Illegal pipe number\n"); return; } if (D_SDP_MODE(dbri->pipes[pipe].sdp) == 0) { - printk("DBRI: xmit_fixed: Uninitialized pipe %d\n", pipe); + printk(KERN_ERR "DBRI: xmit_fixed: Uninitialized pipe %d\n", pipe); return; } if (D_SDP_MODE(dbri->pipes[pipe].sdp) != D_SDP_FIXED) { - printk("DBRI: xmit_fixed: Non-fixed pipe %d\n", pipe); + printk(KERN_ERR "DBRI: xmit_fixed: Non-fixed pipe %d\n", pipe); return; } if (!(dbri->pipes[pipe].sdp & D_SDP_TO_SER)) { - printk("DBRI: xmit_fixed: Called on receive pipe %d\n", pipe); + printk(KERN_ERR "DBRI: xmit_fixed: Called on receive pipe %d\n", pipe); return; } @@ -1036,17 +1046,17 @@ static void xmit_fixed(snd_dbri_t * dbri, int pipe, unsigned int data) static void recv_fixed(snd_dbri_t * dbri, int pipe, volatile __u32 * ptr) { if (pipe < 16 || pipe > 31) { - printk("DBRI: recv_fixed called with illegal pipe number\n"); + printk(KERN_ERR "DBRI: recv_fixed called with illegal pipe number\n"); return; } if (D_SDP_MODE(dbri->pipes[pipe].sdp) != D_SDP_FIXED) { - printk("DBRI: recv_fixed called on non-fixed pipe %d\n", pipe); + printk(KERN_ERR "DBRI: recv_fixed called on non-fixed pipe %d\n", pipe); return; } if (dbri->pipes[pipe].sdp & D_SDP_TO_SER) { - printk("DBRI: recv_fixed called on transmit pipe %d\n", pipe); + printk(KERN_ERR "DBRI: recv_fixed called on transmit pipe %d\n", pipe); return; } @@ -1075,12 +1085,12 @@ static int setup_descs(snd_dbri_t * dbri, int streamno, unsigned int period) int last_desc = -1; if (info->pipe < 0 || info->pipe > 15) { - printk("DBRI: setup_descs: Illegal pipe number\n"); + printk(KERN_ERR "DBRI: setup_descs: Illegal pipe number\n"); return -2; } if (dbri->pipes[info->pipe].sdp == 0) { - printk("DBRI: setup_descs: Uninitialized pipe %d\n", + printk(KERN_ERR "DBRI: setup_descs: Uninitialized pipe %d\n", info->pipe); return -2; } @@ -1090,20 +1100,20 @@ static int setup_descs(snd_dbri_t * dbri, int streamno, unsigned int period) if (streamno == DBRI_PLAY) { if (!(dbri->pipes[info->pipe].sdp & D_SDP_TO_SER)) { - printk("DBRI: setup_descs: Called on receive pipe %d\n", + printk(KERN_ERR "DBRI: setup_descs: Called on receive pipe %d\n", info->pipe); return -2; } } else { if (dbri->pipes[info->pipe].sdp & D_SDP_TO_SER) { - printk - ("DBRI: setup_descs: Called on transmit pipe %d\n", + printk(KERN_ERR + "DBRI: setup_descs: Called on transmit pipe %d\n", info->pipe); return -2; } /* Should be able to queue multiple buffers to receive on a pipe */ if (pipe_active(dbri, info->pipe)) { - printk("DBRI: recv_on_pipe: Called on active pipe %d\n", + printk(KERN_ERR "DBRI: recv_on_pipe: Called on active pipe %d\n", info->pipe); return -2; } @@ -1120,7 +1130,7 @@ static int setup_descs(snd_dbri_t * dbri, int streamno, unsigned int period) break; } if (desc == DBRI_NO_DESCS) { - printk("DBRI: setup_descs: No descriptors\n"); + printk(KERN_ERR "DBRI: setup_descs: No descriptors\n"); return -1; } @@ -1165,7 +1175,7 @@ static int setup_descs(snd_dbri_t * dbri, int streamno, unsigned int period) } if (first_desc == -1 || last_desc == -1) { - printk("DBRI: setup_descs: Not enough descriptors available\n"); + printk(KERN_ERR "DBRI: setup_descs: Not enough descriptors available\n"); return -1; } @@ -1270,7 +1280,7 @@ static void reset_chi(snd_dbri_t * dbri, enum master_or_slave master_or_slave, int divisor = 12288 / clockrate; if (divisor > 255 || divisor * clockrate != 12288) - printk("DBRI: illegal bits_per_frame in setup_chi\n"); + printk(KERN_ERR "DBRI: illegal bits_per_frame in setup_chi\n"); *(cmd++) = DBRI_CMD(D_CHI, 0, D_CHI_CHICM(divisor) | D_CHI_FD | D_CHI_BPF(bits_per_frame)); @@ -1474,7 +1484,6 @@ static int cs4215_setctrl(snd_dbri_t * dbri) /* Temporarily mute outputs, and wait 1/8000 sec (125 us) * to make sure this takes. This avoids clicking noises. */ - cs4215_setdata(dbri, 1); udelay(125); @@ -1530,8 +1539,8 @@ static int cs4215_setctrl(snd_dbri_t * dbri) tmp |= D_C; /* Enable CHI */ sbus_writel(tmp, dbri->regs + REG0); - for (i = 64; ((dbri->mm.status & 0xe4) != 0x20); --i) { - udelay(125); + for (i = 10; ((dbri->mm.status & 0xe4) != 0x20); --i) { + msleep_interruptible(1); } if (i == 0) { dprintk(D_MM, "CS4215 didn't respond to CLB (0x%02x)\n", @@ -1678,8 +1687,8 @@ buffer and calls dbri_process_one_interrupt() for each interrupt word. Complicated interrupts are handled by dedicated functions (which appear first in this file). Any pending interrupts can be serviced by calling dbri_process_interrupt_buffer(), which works even if the CPU's -interrupts are disabled. This function is used by dbri_cmdsend() -to make sure we're synced up with the chip after each command sequence, +interrupts are disabled. This function is used by dbri_cmdlock() +to make sure we're synced up with the chip before each command sequence, even if we're running cli'ed. */ @@ -1765,11 +1774,13 @@ DECLARE_TASKLET(xmit_descs_task, xmit_descs, 0); * Called by main interrupt handler when DBRI signals transmission complete * on a pipe (interrupt triggered by the B bit in a transmit descriptor). * - * Walks through the pipe's list of transmit buffer descriptors, releasing - * each one's DMA buffer (if present), flagging the descriptor available, - * and signaling its callback routine (if present), before proceeding - * to the next one. Stops when the first descriptor is found without + * Walks through the pipe's list of transmit buffer descriptors and marks + * them as available. Stops when the first descriptor is found without * TBC (Transmit Buffer Complete) set, or we've run through them all. + * + * The DMA buffers are not released, but re-used. Since the transmit buffer + * descriptors are not clobbered, they can be re-submitted as is. This is + * done by the xmit_descs() tasklet above since that could take longer. */ static void transmission_complete_intr(snd_dbri_t * dbri, int pipe) @@ -1885,7 +1896,11 @@ static void dbri_process_one_interrupt(snd_dbri_t * dbri, int x) } if (channel == D_INTR_CMD && command == D_WAIT) { - dbri->wait_seen++; + dbri->wait_ackd = val; + if (dbri->wait_send != val) { + printk(KERN_ERR "Processing wait command %d when %d was send.\n", + val, dbri->wait_send); + } return; } @@ -1994,8 +2009,7 @@ static irqreturn_t snd_dbri_interrupt(int irq, void *dev_id, * The only one I've seen is MRR, which will be triggered * if you let a transmit pipe underrun, then try to CDP it. * - * If these things persist, we should probably reset - * and re-init the chip. + * If these things persist, we reset the chip. */ if ((++errcnt) % 10 == 0) { dprintk(D_INT, "Interrupt errors exceeded.\n"); @@ -2094,7 +2108,7 @@ static int snd_dbri_hw_params(snd_pcm_substream_t * substream, if ((ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) { - snd_printk(KERN_ERR "malloc_pages failed with %d\n", ret); + printk(KERN_ERR "malloc_pages failed with %d\n", ret); return ret; } @@ -2455,8 +2469,7 @@ static int __init snd_dbri_mixer(snd_dbri_t * dbri) for (idx = 0; idx < NUM_CS4215_CONTROLS; idx++) { if ((err = snd_ctl_add(card, - snd_ctl_new1(&dbri_controls[idx], - dbri))) < 0) + snd_ctl_new1(&dbri_controls[idx], dbri))) < 0) return err; } @@ -2490,8 +2503,6 @@ static void dbri_debug_read(snd_info_entry_t * entry, int pipe; snd_iprintf(buffer, "debug=%d\n", dbri_debug); - snd_iprintf(buffer, "CHI pipe in=%d, out=%d\n", - dbri->chi_in_pipe, dbri->chi_out_pipe); for (pipe = 0; pipe < 32; pipe++) { if (pipe_active(dbri, pipe)) { struct dbri_pipe *pptr = &dbri->pipes[pipe]; @@ -2506,18 +2517,6 @@ static void dbri_debug_read(snd_info_entry_t * entry, } } } - -static void dbri_debug_write(snd_info_entry_t * entry, - snd_info_buffer_t * buffer) -{ - char line[80]; - int i; - - if (snd_info_get_line(buffer, line, 80) == 0) { - sscanf(line, "%d\n", &i); - dbri_debug = i & 0x3f; - } -} #endif void snd_dbri_proc(snd_dbri_t * dbri) @@ -2531,9 +2530,7 @@ void snd_dbri_proc(snd_dbri_t * dbri) #ifdef DBRI_DEBUG err = snd_card_proc_new(dbri->card, "debug", &entry); snd_info_set_text_ops(entry, dbri, 4096, dbri_debug_read); - entry->mode = S_IFREG | S_IRUGO | S_IWUSR; /* Writable for root */ - entry->c.text.write_size = 256; - entry->c.text.write = dbri_debug_write; + entry->mode = S_IFREG | S_IRUGO; /* Readable only. */ #endif } @@ -2637,7 +2634,11 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) return -ENOENT; } - prom_getproperty(prom_node, "intr", (char *)&irq, sizeof(irq)); + err = prom_getproperty(prom_node, "intr", (char *)&irq, sizeof(irq)); + if (err < 0) { + printk(KERN_ERR "DBRI-%d: Firmware node lacks IRQ property.\n", dev); + return -ENODEV; + } card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(snd_dbri_t)); -- cgit v1.2.3 From 3bcd4649bca99ee9242f20d7da35e3f8741c6549 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 12 Sep 2005 08:20:54 +0200 Subject: [ALSA] set owner field in struct pci_driver AD1889 driver,ALS4000 driver,ATIIXP driver,ATIIXP-modem driver AZT3328 driver,BT87x driver,CMIPCI driver,CS4281 driver ENS1370/1+ driver,ES1938 driver,ES1968 driver,FM801 driver Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,RME32 driver RME96 driver,SonicVibes driver,VIA82xx driver,VIA82xx-modem driver ALI5451 driver,au88x0 driver,CS46xx driver,EMU10K1/EMU10K2 driver HDA Intel driver,ICE1712 driver,ICE1724 driver,KORG1212 driver MIXART driver,NM256 driver,RME HDSP driver,RME9652 driver Trident driver,Digigram VX222 driver,YMFPCI driver Set the module owner field in each driver's struct pci_driver to get the driver symlink in the sysfs device directory. Signed-off-by: Clemens Ladisch --- sound/pci/ad1889.c | 3 ++- sound/pci/ali5451/ali5451.c | 1 + sound/pci/als4000.c | 1 + sound/pci/atiixp.c | 1 + sound/pci/atiixp_modem.c | 1 + sound/pci/au88x0/au88x0.c | 1 + sound/pci/azt3328.c | 1 + sound/pci/bt87x.c | 1 + sound/pci/cmipci.c | 1 + sound/pci/cs4281.c | 1 + sound/pci/cs46xx/cs46xx.c | 1 + sound/pci/emu10k1/emu10k1x.c | 1 + sound/pci/ens1370.c | 1 + sound/pci/es1938.c | 1 + sound/pci/es1968.c | 1 + sound/pci/fm801.c | 1 + sound/pci/hda/hda_intel.c | 1 + sound/pci/ice1712/ice1712.c | 1 + sound/pci/ice1712/ice1724.c | 1 + sound/pci/intel8x0.c | 1 + sound/pci/intel8x0m.c | 1 + sound/pci/korg1212/korg1212.c | 1 + sound/pci/maestro3.c | 1 + sound/pci/mixart/mixart.c | 1 + sound/pci/nm256/nm256.c | 1 + sound/pci/rme32.c | 1 + sound/pci/rme96.c | 1 + sound/pci/rme9652/hdsp.c | 1 + sound/pci/rme9652/hdspm.c | 1 + sound/pci/rme9652/rme9652.c | 1 + sound/pci/sonicvibes.c | 1 + sound/pci/trident/trident.c | 1 + sound/pci/via82xx.c | 1 + sound/pci/via82xx_modem.c | 1 + sound/pci/vx222/vx222.c | 1 + sound/pci/ymfpci/ymfpci.c | 1 + 36 files changed, 37 insertions(+), 1 deletion(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 8ce9cb4c797..d7d99a25c5e 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -50,7 +50,7 @@ #include "ad1889.h" #include "ac97/ac97_id.h" -#define AD1889_DRVVER "$Revision: 1.2 $" +#define AD1889_DRVVER "$Revision: 1.3 $" MODULE_AUTHOR("Kyle McMartin , Thibaut Varene "); MODULE_DESCRIPTION("Analog Devices AD1889 ALSA sound driver"); @@ -1068,6 +1068,7 @@ MODULE_DEVICE_TABLE(pci, snd_ad1889_ids); static struct pci_driver ad1889_pci = { .name = "AD1889 Audio", + .owner = THIS_MODULE, .id_table = snd_ad1889_ids, .probe = snd_ad1889_probe, .remove = __devexit_p(snd_ad1889_remove), diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 703770f6a50..d683f7736a6 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -2411,6 +2411,7 @@ static void __devexit snd_ali_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "ALI 5451", + .owner = THIS_MODULE, .id_table = snd_ali_ids, .probe = snd_ali_probe, .remove = __devexit_p(snd_ali_remove), diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index ca28b229c70..196ec1c61bb 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -770,6 +770,7 @@ static void __devexit snd_card_als4000_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "ALS4000", + .owner = THIS_MODULE, .id_table = snd_als4000_ids, .probe = snd_card_als4000_probe, .remove = __devexit_p(snd_card_als4000_remove), diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 874157f2701..241eacf1e65 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1645,6 +1645,7 @@ static void __devexit snd_atiixp_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "ATI IXP AC97 controller", + .owner = THIS_MODULE, .id_table = snd_atiixp_ids, .probe = snd_atiixp_probe, .remove = __devexit_p(snd_atiixp_remove), diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 4de637e4dd4..8a59598167f 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1318,6 +1318,7 @@ static void __devexit snd_atiixp_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "ATI IXP MC97 controller", + .owner = THIS_MODULE, .id_table = snd_atiixp_ids, .probe = snd_atiixp_probe, .remove = __devexit_p(snd_atiixp_remove), diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index 76b1c301869..04b695d6fd4 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c @@ -373,6 +373,7 @@ static void __devexit snd_vortex_remove(struct pci_dev *pci) // pci_driver definition static struct pci_driver driver = { .name = CARD_NAME_SHORT, + .owner = THIS_MODULE, .id_table = snd_vortex_ids, .probe = snd_vortex_probe, .remove = __devexit_p(snd_vortex_remove), diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 26069d2e027..d5261bdec58 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -1511,6 +1511,7 @@ static void __devexit snd_azf3328_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "AZF3328", + .owner = THIS_MODULE, .id_table = snd_azf3328_ids, .probe = snd_azf3328_probe, .remove = __devexit_p(snd_azf3328_remove), diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 639f08098f8..2236c958aec 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -901,6 +901,7 @@ static struct pci_device_id snd_bt87x_default_ids[] = { static struct pci_driver driver = { .name = "Bt87x", + .owner = THIS_MODULE, .id_table = snd_bt87x_ids, .probe = snd_bt87x_probe, .remove = __devexit_p(snd_bt87x_remove), diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 583b2713d86..1eb3315d136 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -3037,6 +3037,7 @@ static void __devexit snd_cmipci_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "C-Media PCI", + .owner = THIS_MODULE, .id_table = snd_cmipci_ids, .probe = snd_cmipci_probe, .remove = __devexit_p(snd_cmipci_remove), diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 421430bad98..dc87e0144b5 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -2108,6 +2108,7 @@ static int cs4281_resume(snd_card_t *card) static struct pci_driver driver = { .name = "CS4281", + .owner = THIS_MODULE, .id_table = snd_cs4281_ids, .probe = snd_cs4281_probe, .remove = __devexit_p(snd_cs4281_remove), diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index b9fff4ee6f9..32b4f8465ce 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c @@ -163,6 +163,7 @@ static void __devexit snd_card_cs46xx_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "Sound Fusion CS46xx", + .owner = THIS_MODULE, .id_table = snd_cs46xx_ids, .probe = snd_card_cs46xx_probe, .remove = __devexit_p(snd_card_cs46xx_remove), diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 8c151af521d..ad15755a63c 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -1615,6 +1615,7 @@ MODULE_DEVICE_TABLE(pci, snd_emu10k1x_ids); // pci_driver definition static struct pci_driver driver = { .name = "EMU10K1X", + .owner = THIS_MODULE, .id_table = snd_emu10k1x_ids, .probe = snd_emu10k1x_probe, .remove = __devexit_p(snd_emu10k1x_remove), diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index a38f7102ecc..bef9a59f46d 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -2387,6 +2387,7 @@ static void __devexit snd_audiopci_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = DRIVER_NAME, + .owner = THIS_MODULE, .id_table = snd_audiopci_ids, .probe = snd_audiopci_probe, .remove = __devexit_p(snd_audiopci_remove), diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index 356c493d931..17fa80c2387 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1746,6 +1746,7 @@ static void __devexit snd_es1938_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "ESS ES1938 (Solo-1)", + .owner = THIS_MODULE, .id_table = snd_es1938_ids, .probe = snd_es1938_probe, .remove = __devexit_p(snd_es1938_remove), diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 10a487a78d6..ecdcada90ca 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2763,6 +2763,7 @@ static void __devexit snd_es1968_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "ES1968 (ESS Maestro)", + .owner = THIS_MODULE, .id_table = snd_es1968_ids, .probe = snd_es1968_probe, .remove = __devexit_p(snd_es1968_remove), diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index aaa41fb480a..e5cfa2a0c24 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1462,6 +1462,7 @@ static void __devexit snd_card_fm801_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "FM801", + .owner = THIS_MODULE, .id_table = snd_fm801_ids, .probe = snd_card_fm801_probe, .remove = __devexit_p(snd_card_fm801_remove), diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 7e0c05936c3..9590ece2099 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1603,6 +1603,7 @@ MODULE_DEVICE_TABLE(pci, azx_ids); /* pci_driver definition */ static struct pci_driver driver = { .name = "HDA Intel", + .owner = THIS_MODULE, .id_table = azx_ids, .probe = azx_probe, .remove = __devexit_p(azx_remove), diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 7d4d9b0c6b1..a6d98013c33 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -2735,6 +2735,7 @@ static void __devexit snd_ice1712_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "ICE1712", + .owner = THIS_MODULE, .id_table = snd_ice1712_ids, .probe = snd_ice1712_probe, .remove = __devexit_p(snd_ice1712_remove), diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 1e7119acfd4..c3ce8f93740 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -2315,6 +2315,7 @@ static void __devexit snd_vt1724_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "ICE1724", + .owner = THIS_MODULE, .id_table = snd_vt1724_ids, .probe = snd_vt1724_probe, .remove = __devexit_p(snd_vt1724_remove), diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 5975cd58054..1a96198a17a 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2864,6 +2864,7 @@ static void __devexit snd_intel8x0_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "Intel ICH", + .owner = THIS_MODULE, .id_table = snd_intel8x0_ids, .probe = snd_intel8x0_probe, .remove = __devexit_p(snd_intel8x0_remove), diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 38493d77528..9e2060d56c2 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -1326,6 +1326,7 @@ static void __devexit snd_intel8x0m_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "Intel ICH Modem", + .owner = THIS_MODULE, .id_table = snd_intel8x0m_ids, .probe = snd_intel8x0m_probe, .remove = __devexit_p(snd_intel8x0m_remove), diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 5f61536f112..09f9cbe116a 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -2534,6 +2534,7 @@ static void __devexit snd_korg1212_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "korg1212", + .owner = THIS_MODULE, .id_table = snd_korg1212_ids, .probe = snd_korg1212_probe, .remove = __devexit_p(snd_korg1212_remove), diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 635531c2aa0..2693b6f731f 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -2861,6 +2861,7 @@ static void __devexit snd_m3_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "Maestro3", + .owner = THIS_MODULE, .id_table = snd_m3_ids, .probe = snd_m3_probe, .remove = __devexit_p(snd_m3_remove), diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 2636d507bdf..1a62c7f6c52 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1424,6 +1424,7 @@ static void __devexit snd_mixart_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "Digigram miXart", + .owner = THIS_MODULE, .id_table = snd_mixart_ids, .probe = snd_mixart_probe, .remove = __devexit_p(snd_mixart_remove), diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index b44d56c2dd3..5c55a3b1d12 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1668,6 +1668,7 @@ static void __devexit snd_nm256_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "NeoMagic 256", + .owner = THIS_MODULE, .id_table = snd_nm256_ids, .probe = snd_nm256_probe, .remove = __devexit_p(snd_nm256_remove), diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index a511de5a385..3daeecb9eb0 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -2012,6 +2012,7 @@ static void __devexit snd_rme32_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "RME Digi32", + .owner = THIS_MODULE, .id_table = snd_rme32_ids, .probe = snd_rme32_probe, .remove = __devexit_p(snd_rme32_remove), diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 6653c21bfa0..9983b66dc56 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -2413,6 +2413,7 @@ static void __devexit snd_rme96_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "RME Digi96", + .owner = THIS_MODULE, .id_table = snd_rme96_ids, .probe = snd_rme96_probe, .remove = __devexit_p(snd_rme96_remove), diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index e456ccaaaf6..52525eb198c 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -5216,6 +5216,7 @@ static void __devexit snd_hdsp_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "RME Hammerfall DSP", + .owner = THIS_MODULE, .id_table = snd_hdsp_ids, .probe = snd_hdsp_probe, .remove = __devexit_p(snd_hdsp_remove), diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 7c67c028691..fc3f3283ff3 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -3640,6 +3640,7 @@ static void __devexit snd_hdspm_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "RME Hammerfall DSP MADI", + .owner = THIS_MODULE, .id_table = snd_hdspm_ids, .probe = snd_hdspm_probe, .remove = __devexit_p(snd_hdspm_remove), diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index da317e8c085..b600f45e183 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -2654,6 +2654,7 @@ static void __devexit snd_rme9652_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "RME Digi9652 (Hammerfall)", + .owner = THIS_MODULE, .id_table = snd_rme9652_ids, .probe = snd_rme9652_probe, .remove = __devexit_p(snd_rme9652_remove), diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 57c8ff5f526..1f6c2bfd43f 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -1508,6 +1508,7 @@ static void __devexit snd_sonic_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "S3 SonicVibes", + .owner = THIS_MODULE, .id_table = snd_sonic_ids, .probe = snd_sonic_probe, .remove = __devexit_p(snd_sonic_remove), diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c index 940d531575c..a8ca8e17853 100644 --- a/sound/pci/trident/trident.c +++ b/sound/pci/trident/trident.c @@ -177,6 +177,7 @@ static void __devexit snd_trident_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "Trident4DWaveAudio", + .owner = THIS_MODULE, .id_table = snd_trident_ids, .probe = snd_trident_probe, .remove = __devexit_p(snd_trident_remove), diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index a58f88a552a..6db7de6b971 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2343,6 +2343,7 @@ static void __devexit snd_via82xx_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "VIA 82xx Audio", + .owner = THIS_MODULE, .id_table = snd_via82xx_ids, .probe = snd_via82xx_probe, .remove = __devexit_p(snd_via82xx_remove), diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index e36f538d02f..7eac6f6ac73 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -1207,6 +1207,7 @@ static void __devexit snd_via82xx_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "VIA 82xx Modem", + .owner = THIS_MODULE, .id_table = snd_via82xx_modem_ids, .probe = snd_via82xx_probe, .remove = __devexit_p(snd_via82xx_remove), diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index dca6bd2c758..2a7ad9dec02 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -252,6 +252,7 @@ static void __devexit snd_vx222_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "Digigram VX222", + .owner = THIS_MODULE, .id_table = snd_vx222_ids, .probe = snd_vx222_probe, .remove = __devexit_p(snd_vx222_remove), diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 5b5b624b47d..2e69abe51aa 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c @@ -352,6 +352,7 @@ static void __devexit snd_card_ymfpci_remove(struct pci_dev *pci) static struct pci_driver driver = { .name = "Yamaha DS-XG PCI", + .owner = THIS_MODULE, .id_table = snd_ymfpci_ids, .probe = snd_card_ymfpci_probe, .remove = __devexit_p(snd_card_ymfpci_remove), -- cgit v1.2.3 From ff4a964ee3f47c344efd9218dca0f14b9eff8877 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 12 Sep 2005 11:14:05 +0200 Subject: [ALSA] version 1.0.10rc1 --- include/sound/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sound/version.h b/include/sound/version.h index 8d19bfabb7e..ee32af20dba 100644 --- a/include/sound/version.h +++ b/include/sound/version.h @@ -1,3 +1,3 @@ /* include/version.h. Generated by configure. */ #define CONFIG_SND_VERSION "1.0.10rc1" -#define CONFIG_SND_DATE " (Tue Aug 30 05:31:08 2005 UTC)" +#define CONFIG_SND_DATE " (Mon Sep 12 08:13:09 2005 UTC)" -- cgit v1.2.3 From 676e1a2c1e7499eee8e7a81e577b4b6ba71ffb25 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 12 Sep 2005 14:51:00 +0200 Subject: [ALSA] [PATCH] Add missing sound PCI IDs to pci_ids.h Added missing PCI IDs for sound drivers to pci_ids.h. Signed-off-by: Takashi Iwai --- include/linux/pci_ids.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index ee0ab7a5f91..31da85f4ab6 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -447,6 +447,10 @@ #define PCI_DEVICE_ID_CIRRUS_7542 0x1200 #define PCI_DEVICE_ID_CIRRUS_7543 0x1202 #define PCI_DEVICE_ID_CIRRUS_7541 0x1204 +#define PCI_DEVICE_ID_CIRRUS_4610 0x6001 +#define PCI_DEVICE_ID_CIRRUS_4612 0x6003 +#define PCI_DEVICE_ID_CIRRUS_4615 0x6004 +#define PCI_DEVICE_ID_CIRRUS_4281 0x6005 #define PCI_VENDOR_ID_IBM 0x1014 #define PCI_DEVICE_ID_IBM_FIRE_CORAL 0x000a @@ -682,7 +686,9 @@ #define PCI_DEVICE_ID_SI_6326 0x6326 #define PCI_DEVICE_ID_SI_7001 0x7001 #define PCI_DEVICE_ID_SI_7012 0x7012 +#define PCI_DEVICE_ID_SI_7013 0x7013 #define PCI_DEVICE_ID_SI_7016 0x7016 +#define PCI_DEVICE_ID_SI_7018 0x7018 #define PCI_VENDOR_ID_HP 0x103c #define PCI_DEVICE_ID_HP_VISUALIZE_EG 0x1005 @@ -991,6 +997,7 @@ #define PCI_DEVICE_ID_BROOKTREE_849A 0x0351 #define PCI_DEVICE_ID_BROOKTREE_878_1 0x036e #define PCI_DEVICE_ID_BROOKTREE_878 0x0878 +#define PCI_DEVICE_ID_BROOKTREE_879 0x0879 #define PCI_DEVICE_ID_BROOKTREE_8474 0x8474 #define PCI_VENDOR_ID_SIERRA 0x10a8 @@ -1109,6 +1116,9 @@ #define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2160 0x0004 #define PCI_DEVICE_ID_NEOMAGIC_MAGICMEDIA_256AV 0x0005 #define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZVPLUS 0x0083 +#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005 +#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006 +#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016 #define PCI_VENDOR_ID_ASP 0x10cd #define PCI_DEVICE_ID_ASP_ABP940 0x1200 @@ -1155,10 +1165,13 @@ #define PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS 0x0064 #define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE 0x0065 #define PCI_DEVICE_ID_NVIDIA_NVENET_2 0x0066 +#define PCI_DEVICE_ID_NVIDIA_MCP2_MODEM 0x0069 #define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a #define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS 0x0084 #define PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE 0x0085 #define PCI_DEVICE_ID_NVIDIA_NVENET_4 0x0086 +#define PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM 0x0089 +#define PCI_DEVICE_ID_NVIDIA_CK8_AUDIO 0x008a #define PCI_DEVICE_ID_NVIDIA_NVENET_5 0x008c #define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA 0x008e #define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0 @@ -1173,6 +1186,7 @@ #define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4 #define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5 #define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6 +#define PCI_DEVICE_ID_NVIDIA_MCP3_MODEM 0x00d9 #define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da #define PCI_DEVICE_ID_NVIDIA_NVENET_7 0x00df #define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1 @@ -1180,6 +1194,7 @@ #define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS 0x00e4 #define PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE 0x00e5 #define PCI_DEVICE_ID_NVIDIA_NVENET_6 0x00e6 +#define PCI_DEVICE_ID_NVIDIA_CK8S_AUDIO 0x00ea #define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2 0x00ee #define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100 #define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101 @@ -1230,6 +1245,7 @@ #define PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO 0x01b1 #define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01b4 #define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE 0x01bc +#define PCI_DEVICE_ID_NVIDIA_MCP1_MODEM 0x01c1 #define PCI_DEVICE_ID_NVIDIA_NVENET_1 0x01c3 #define PCI_DEVICE_ID_NVIDIA_NFORCE2 0x01e0 #define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200 @@ -1334,6 +1350,13 @@ #define PCI_DEVICE_ID_REALTEK_8169 0x8169 #define PCI_VENDOR_ID_XILINX 0x10ee +#define PCI_DEVICE_ID_RME_DIGI96 0x3fc0 +#define PCI_DEVICE_ID_RME_DIGI96_8 0x3fc1 +#define PCI_DEVICE_ID_RME_DIGI96_8_PRO 0x3fc2 +#define PCI_DEVICE_IDRME__DIGI96_8_PAD_OR_PST 0x3fc3 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL 0x3fc4 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5 +#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6 #define PCI_DEVICE_ID_TURBOPAM 0x4020 #define PCI_VENDOR_ID_TRUEVISION 0x10fa @@ -1809,6 +1832,14 @@ #define PCI_DEVICE_ID_ESS_ESS1968 0x1968 #define PCI_DEVICE_ID_ESS_AUDIOPCI 0x1969 #define PCI_DEVICE_ID_ESS_ESS1978 0x1978 +#define PCI_DEVICE_ID_ESS_ALLEGRO_1 0x1988 +#define PCI_DEVICE_ID_ESS_ALLEGRO 0x1989 +#define PCI_DEVICE_ID_ESS_CANYON3D_2LE 0x1990 +#define PCI_DEVICE_ID_ESS_CANYON3D_2 0x1992 +#define PCI_DEVICE_ID_ESS_MAESTRO3 0x1998 +#define PCI_DEVICE_ID_ESS_MAESTRO3_1 0x1999 +#define PCI_DEVICE_ID_ESS_MAESTRO3_HW 0x199a +#define PCI_DEVICE_ID_ESS_MAESTRO3_2 0x199b #define PCI_VENDOR_ID_SATSAGEM 0x1267 #define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016 @@ -1968,6 +1999,9 @@ #define PCI_DEVICE_ID_LMC_SSI 0x0005 #define PCI_DEVICE_ID_LMC_T1 0x0006 +#define PCI_VENDOR_ID_MARIAN 0x1382 +#define PCI_DEVICE_ID_MARIAN_PRODIF_PLUS 0x2048 + #define PCI_VENDOR_ID_NETGEAR 0x1385 #define PCI_DEVICE_ID_NETGEAR_GA620 0x620a #define PCI_DEVICE_ID_NETGEAR_GA622 0x622a @@ -2056,6 +2090,10 @@ #define PCI_VENDOR_ID_TIMEDIA 0x1409 #define PCI_DEVICE_ID_TIMEDIA_1889 0x7168 +#define PCI_VENDOR_ID_ICE 0x1412 +#define PCI_DEVICE_ID_ICE_1712 0x1712 +#define PCI_DEVICE_ID_VT1724 0x1724 + #define PCI_VENDOR_ID_OXSEMI 0x1415 #define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403 #define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501 @@ -2536,6 +2574,7 @@ #define PCI_DEVICE_ID_INTEL_82443BX_1 0x7191 #define PCI_DEVICE_ID_INTEL_82443BX_2 0x7192 #define PCI_DEVICE_ID_INTEL_440MX 0x7195 +#define PCI_DEVICE_ID_INTEL_440MX_6 0x7196 #define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198 #define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199 #define PCI_DEVICE_ID_INTEL_82443MX_2 0x719a @@ -2642,6 +2681,11 @@ #define PCI_VENDOR_ID_TTTECH 0x0357 #define PCI_DEVICE_ID_TTTECH_MC322 0x000A +#define PCI_VENDOR_ID_XILINX_RME 0xea60 +#define PCI_DEVICE_ID_RME_DIGI32 0x9896 +#define PCI_DEVICE_ID_RME_DIGI32_PRO 0x9897 +#define PCI_DEVICE_ID_RME_DIGI32_8 0x9898 + #define PCI_VENDOR_ID_ARK 0xedd8 #define PCI_DEVICE_ID_ARK_STING 0xa091 #define PCI_DEVICE_ID_ARK_STINGARK 0xa099 -- cgit v1.2.3 From 21d9e30ed020d24336cc3bee2a4e04da232ed554 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 13 Sep 2005 01:32:25 +0200 Subject: [Bluetooth] Add support for extended inquiry responses This patch adds the handling of the extended inquiry responses and inserts them into the inquiry cache. Signed-off-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 11 +++++++++++ net/bluetooth/hci_event.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 371e7d3f2e6..fa2d12b0579 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -463,6 +463,17 @@ struct inquiry_info_with_rssi_and_pscan_mode { __s8 rssi; } __attribute__ ((packed)); +#define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2F +struct extended_inquiry_info { + bdaddr_t bdaddr; + __u8 pscan_rep_mode; + __u8 pscan_period_mode; + __u8 dev_class[3]; + __u16 clock_offset; + __s8 rssi; + __u8 data[240]; +} __attribute__ ((packed)); + #define HCI_EV_CONN_COMPLETE 0x03 struct hci_ev_conn_complete { __u8 status; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index d6da0939216..b61b4e8e36f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -558,6 +558,35 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct hci_dev_unlock(hdev); } +/* Extended Inquiry Result */ +static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) +{ + struct inquiry_data data; + struct extended_inquiry_info *info = (struct extended_inquiry_info *) (skb->data + 1); + int num_rsp = *((__u8 *) skb->data); + + BT_DBG("%s num_rsp %d", hdev->name, num_rsp); + + if (!num_rsp) + return; + + hci_dev_lock(hdev); + + for (; num_rsp; num_rsp--) { + bacpy(&data.bdaddr, &info->bdaddr); + data.pscan_rep_mode = info->pscan_rep_mode; + data.pscan_period_mode = info->pscan_period_mode; + data.pscan_mode = 0x00; + memcpy(data.dev_class, info->dev_class, 3); + data.clock_offset = info->clock_offset; + data.rssi = info->rssi; + info++; + hci_inquiry_cache_update(hdev, &data); + } + + hci_dev_unlock(hdev); +} + /* Connect Request */ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) { @@ -940,6 +969,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) hci_inquiry_result_with_rssi_evt(hdev, skb); break; + case HCI_EV_EXTENDED_INQUIRY_RESULT: + hci_extended_inquiry_result_evt(hdev, skb); + break; + case HCI_EV_CONN_REQUEST: hci_conn_request_evt(hdev, skb); break; -- cgit v1.2.3 From 354d28d5f8546e115ebaae9311897f0bc4b6a8d4 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 13 Sep 2005 01:32:31 +0200 Subject: [Bluetooth] Prevent RFCOMM connections through the RAW socket This patch adds additional checks to prevent RFCOMM connections be established through the RAW socket interface. Signed-off-by: Marcel Holtmann --- net/bluetooth/rfcomm/sock.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 90e19eb6d3c..f49e7e938bf 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -363,6 +363,11 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr goto done; } + if (sk->sk_type != SOCK_STREAM) { + err = -EINVAL; + goto done; + } + write_lock_bh(&rfcomm_sk_list.lock); if (sa->rc_channel && __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr)) { @@ -393,13 +398,17 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a if (addr->sa_family != AF_BLUETOOTH || alen < sizeof(struct sockaddr_rc)) return -EINVAL; - if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) - return -EBADFD; + lock_sock(sk); - if (sk->sk_type != SOCK_STREAM) - return -EINVAL; + if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) { + err = -EBADFD; + goto done; + } - lock_sock(sk); + if (sk->sk_type != SOCK_STREAM) { + err = -EINVAL; + goto done; + } sk->sk_state = BT_CONNECT; bacpy(&bt_sk(sk)->dst, &sa->rc_bdaddr); @@ -410,6 +419,7 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a err = bt_sock_wait_state(sk, BT_CONNECTED, sock_sndtimeo(sk, flags & O_NONBLOCK)); +done: release_sock(sk); return err; } @@ -428,6 +438,11 @@ static int rfcomm_sock_listen(struct socket *sock, int backlog) goto done; } + if (sk->sk_type != SOCK_STREAM) { + err = -EINVAL; + goto done; + } + if (!rfcomm_pi(sk)->channel) { bdaddr_t *src = &bt_sk(sk)->src; u8 channel; @@ -472,6 +487,11 @@ static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int f goto done; } + if (sk->sk_type != SOCK_STREAM) { + err = -EINVAL; + goto done; + } + timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); BT_DBG("sk %p timeo %ld", sk, timeo); -- cgit v1.2.3 From 0915e8865fe4684dc82f043ac7036f34bf89f52a Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 13 Sep 2005 01:32:37 +0200 Subject: [Bluetooth] Add ignore parameters to the HCI USB driver This patch adds the module parameters ignore_csr and ignore_sniffer to the HCI USB driver. This allows an easier use of CSR ROM chips that need an additional initialization routine and the Frontline sniffers. Signed-off-by: Marcel Holtmann --- drivers/bluetooth/hci_usb.c | 19 ++++++++++++++++++- drivers/bluetooth/hci_usb.h | 5 +++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c index 67d96b5cbb9..57c48bbf6fe 100644 --- a/drivers/bluetooth/hci_usb.c +++ b/drivers/bluetooth/hci_usb.c @@ -65,13 +65,15 @@ #endif static int ignore = 0; +static int ignore_csr = 0; +static int ignore_sniffer = 0; static int reset = 0; #ifdef CONFIG_BT_HCIUSB_SCO static int isoc = 2; #endif -#define VERSION "2.8" +#define VERSION "2.9" static struct usb_driver hci_usb_driver; @@ -98,6 +100,9 @@ static struct usb_device_id bluetooth_ids[] = { MODULE_DEVICE_TABLE (usb, bluetooth_ids); static struct usb_device_id blacklist_ids[] = { + /* CSR BlueCore devices */ + { USB_DEVICE(0x0a12, 0x0001), .driver_info = HCI_CSR }, + /* Broadcom BCM2033 without firmware */ { USB_DEVICE(0x0a5c, 0x2033), .driver_info = HCI_IGNORE }, @@ -836,6 +841,12 @@ static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id if (ignore || id->driver_info & HCI_IGNORE) return -ENODEV; + if (ignore_csr && id->driver_info & HCI_CSR) + return -ENODEV; + + if (ignore_sniffer && id->driver_info & HCI_SNIFFER) + return -ENODEV; + if (intf->cur_altsetting->desc.bInterfaceNumber > 0) return -ENODEV; @@ -1061,6 +1072,12 @@ module_exit(hci_usb_exit); module_param(ignore, bool, 0644); MODULE_PARM_DESC(ignore, "Ignore devices from the matching table"); +module_param(ignore_csr, bool, 0644); +MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001"); + +module_param(ignore_sniffer, bool, 0644); +MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002"); + module_param(reset, bool, 0644); MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); diff --git a/drivers/bluetooth/hci_usb.h b/drivers/bluetooth/hci_usb.h index 29936b43d4f..37100a6ea1a 100644 --- a/drivers/bluetooth/hci_usb.h +++ b/drivers/bluetooth/hci_usb.h @@ -31,9 +31,10 @@ #define HCI_IGNORE 0x01 #define HCI_RESET 0x02 #define HCI_DIGIANSWER 0x04 -#define HCI_SNIFFER 0x08 -#define HCI_BROKEN_ISOC 0x10 +#define HCI_CSR 0x08 +#define HCI_SNIFFER 0x10 #define HCI_BCM92035 0x20 +#define HCI_BROKEN_ISOC 0x40 #define HCI_MAX_IFACE_NUM 3 -- cgit v1.2.3 From 1c5363153dc7ae694404e7732b4ce36eecc94ca7 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 12 Sep 2005 09:15:14 -0500 Subject: [SCSI] blacklist REPORT LUNS usage on transtec arrays They report being SCSI-3 but seem to give back rubbish to a REPORT_LUNS command. Force them to be sequentially scanned. Signed-off-by: James Bottomley --- drivers/scsi/scsi_devinfo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index 07b554affcf..64fc9e21f35 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -110,6 +110,7 @@ static struct { {"RELISYS", "Scorpio", NULL, BLIST_NOLUN}, /* responds to all lun */ {"SANKYO", "CP525", "6.64", BLIST_NOLUN}, /* causes failed REQ SENSE, extra reset */ {"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN}, + {"transtec", "T5008", "0001", BLIST_NOREPORTLUN }, {"YAMAHA", "CDR100", "1.00", BLIST_NOLUN}, /* locks up */ {"YAMAHA", "CDR102", "1.00", BLIST_NOLUN}, /* locks up */ {"YAMAHA", "CRW8424S", "1.0", BLIST_NOLUN}, /* locks up */ -- cgit v1.2.3 From 299cc3c166f7a11f6cc3b66aafbaf75c2aa0e0e2 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 13 Sep 2005 07:59:34 -0700 Subject: Fix up more strange byte writes to the PCI_ROM_ADDRESS config word It's a dword thing, and the value we write is a dword. Doing a byte write to it is nonsensical, and writes only the low byte, which only contains the enable bit. So we enable a nonsensical address (usually zero), which causes the controller no end of problems. Trivial fix, but nasty to find. Signed-off-by: Linus Torvalds --- drivers/ide/pci/cmd64x.c | 2 +- drivers/ide/pci/hpt34x.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index 3de9ab897e4..3d9c7afc869 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c @@ -608,7 +608,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha #ifdef __i386__ if (dev->resource[PCI_ROM_RESOURCE].start) { - pci_write_config_byte(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); + pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start); } #endif diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index bbde4627998..be334da7a75 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c @@ -173,7 +173,7 @@ static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev, const cha if (cmd & PCI_COMMAND_MEMORY) { if (pci_resource_start(dev, PCI_ROM_RESOURCE)) { - pci_write_config_byte(dev, PCI_ROM_ADDRESS, + pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); printk(KERN_INFO "HPT345: ROM enabled at 0x%08lx\n", dev->resource[PCI_ROM_RESOURCE].start); -- cgit v1.2.3 From 154fb614df83086ceb18a2c19908154e78d4dc98 Mon Sep 17 00:00:00 2001 From: Dave C Boutcher Date: Tue, 13 Sep 2005 10:09:02 -0500 Subject: [SCSI] ibmvscsi compatibility fix Linda Xie ever so gently pointed out that she had a patch to preserve compatibility with older SLES targets, and I told her we didn't need to push it to mainline. This patch explicitly checks the version of the IBMVSCSI target and ensures that large scatterlists are not sent to older targets. Signed-off-by: Linda Xie Signed-off-by: Dave Boutcher Signed-off-by: James Bottomley --- drivers/scsi/ibmvscsi/ibmvscsi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 5b14934ba86..ff25210b00b 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -727,6 +727,16 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct) if (hostdata->madapter_info.port_max_txu[0]) hostdata->host->max_sectors = hostdata->madapter_info.port_max_txu[0] >> 9; + + if (hostdata->madapter_info.os_type == 3 && + strcmp(hostdata->madapter_info.srp_version, "1.6a") <= 0) { + printk("ibmvscsi: host (Ver. %s) doesn't support large" + "transfers\n", + hostdata->madapter_info.srp_version); + printk("ibmvscsi: limiting scatterlists to %d\n", + MAX_INDIRECT_BUFS); + hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS; + } } } -- cgit v1.2.3 From 4aed0644d684428e811bb6944f032b460a3ab165 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Tue, 13 Sep 2005 01:25:01 -0700 Subject: [PATCH] drivers/base/*: use kzalloc instead of kmalloc+memset Fixes a bunch of memset bugs too. Signed-off-by: Lion Vollnhals Signed-off-by: Jiri Slaby Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/base/attribute_container.c | 5 +++-- drivers/base/class.c | 10 ++++------ drivers/base/firmware_class.c | 9 +++------ drivers/base/map.c | 3 +-- drivers/base/platform.c | 3 +-- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index 373e7b728fa..6b2eb6f39b4 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c @@ -152,12 +152,13 @@ attribute_container_add_device(struct device *dev, if (!cont->match(cont, dev)) continue; - ic = kmalloc(sizeof(struct internal_container), GFP_KERNEL); + + ic = kzalloc(sizeof(*ic), GFP_KERNEL); if (!ic) { dev_printk(KERN_ERR, dev, "failed to allocate class container\n"); continue; } - memset(ic, 0, sizeof(struct internal_container)); + ic->cont = cont; class_device_initialize(&ic->classdev); ic->classdev.dev = get_device(dev); diff --git a/drivers/base/class.c b/drivers/base/class.c index d164c32a97a..3b112e3542f 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -189,12 +189,11 @@ struct class *class_create(struct module *owner, char *name) struct class *cls; int retval; - cls = kmalloc(sizeof(struct class), GFP_KERNEL); + cls = kzalloc(sizeof(*cls), GFP_KERNEL); if (!cls) { retval = -ENOMEM; goto error; } - memset(cls, 0x00, sizeof(struct class)); cls->name = name; cls->owner = owner; @@ -500,13 +499,13 @@ int class_device_add(struct class_device *class_dev) /* add the needed attributes to this device */ if (MAJOR(class_dev->devt)) { struct class_device_attribute *attr; - attr = kmalloc(sizeof(*attr), GFP_KERNEL); + attr = kzalloc(sizeof(*attr), GFP_KERNEL); if (!attr) { error = -ENOMEM; kobject_del(&class_dev->kobj); goto register_done; } - memset(attr, sizeof(*attr), 0x00); + attr->attr.name = "dev"; attr->attr.mode = S_IRUGO; attr->attr.owner = parent->owner; @@ -577,12 +576,11 @@ struct class_device *class_device_create(struct class *cls, dev_t devt, if (cls == NULL || IS_ERR(cls)) goto error; - class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL); + class_dev = kzalloc(sizeof(*class_dev), GFP_KERNEL); if (!class_dev) { retval = -ENOMEM; goto error; } - memset(class_dev, 0x00, sizeof(struct class_device)); class_dev->devt = devt; class_dev->dev = device; diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 5bfa2e9a7c2..4acb2c5733c 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -301,9 +301,9 @@ fw_register_class_device(struct class_device **class_dev_p, const char *fw_name, struct device *device) { int retval; - struct firmware_priv *fw_priv = kmalloc(sizeof (struct firmware_priv), + struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv), GFP_KERNEL); - struct class_device *class_dev = kmalloc(sizeof (struct class_device), + struct class_device *class_dev = kzalloc(sizeof(*class_dev), GFP_KERNEL); *class_dev_p = NULL; @@ -313,8 +313,6 @@ fw_register_class_device(struct class_device **class_dev_p, retval = -ENOMEM; goto error_kfree; } - memset(fw_priv, 0, sizeof (*fw_priv)); - memset(class_dev, 0, sizeof (*class_dev)); init_completion(&fw_priv->completion); fw_priv->attr_data = firmware_attr_data_tmpl; @@ -402,14 +400,13 @@ _request_firmware(const struct firmware **firmware_p, const char *name, if (!firmware_p) return -EINVAL; - *firmware_p = firmware = kmalloc(sizeof (struct firmware), GFP_KERNEL); + *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); if (!firmware) { printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", __FUNCTION__); retval = -ENOMEM; goto out; } - memset(firmware, 0, sizeof (*firmware)); retval = fw_setup_class_device(firmware, &class_dev, name, device, hotplug); diff --git a/drivers/base/map.c b/drivers/base/map.c index 2f455d86793..b449dae6f0d 100644 --- a/drivers/base/map.c +++ b/drivers/base/map.c @@ -135,7 +135,7 @@ retry: struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem) { struct kobj_map *p = kmalloc(sizeof(struct kobj_map), GFP_KERNEL); - struct probe *base = kmalloc(sizeof(struct probe), GFP_KERNEL); + struct probe *base = kzalloc(sizeof(*base), GFP_KERNEL); int i; if ((p == NULL) || (base == NULL)) { @@ -144,7 +144,6 @@ struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem) return NULL; } - memset(base, 0, sizeof(struct probe)); base->dev = 1; base->range = ~0; base->get = base_probe; diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 3a5f4c99179..361e204209e 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -225,13 +225,12 @@ struct platform_device *platform_device_register_simple(char *name, unsigned int struct platform_object *pobj; int retval; - pobj = kmalloc(sizeof(struct platform_object) + sizeof(struct resource) * num, GFP_KERNEL); + pobj = kzalloc(sizeof(*pobj) + sizeof(struct resource) * num, GFP_KERNEL); if (!pobj) { retval = -ENOMEM; goto error; } - memset(pobj, 0, sizeof(*pobj)); pobj->pdev.name = name; pobj->pdev.id = id; pobj->pdev.dev.release = platform_device_release_simple; -- cgit v1.2.3 From db84502b0229ed3075ca74b7d34eb8c609de3200 Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Tue, 13 Sep 2005 01:25:02 -0700 Subject: [PATCH] fbdev Kconfig fix Fix compile error if CONFIG_FB_I810_I2C is 'y' and CONFIG_I2C = 'm'. Signed-off-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 615874e03ce..31ee13eef7a 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -753,7 +753,8 @@ config FB_I810_GTF config FB_I810_I2C bool "Enable DDC Support" - depends on FB_I810 && I2C && FB_I810_GTF + depends on FB_I810 && FB_I810_GTF + select I2C select I2C_ALGOBIT help -- cgit v1.2.3 From c352ec8ab87b065cd2edda171811f49ac7d0d5cd Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Tue, 13 Sep 2005 01:25:03 -0700 Subject: [PATCH] pcmcia: warn on IOCTL usage More visible user information of scheduled feature removal. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/pcmcia_ioctl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 39ba6406fd5..80969f7e7a0 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -376,6 +376,7 @@ static int ds_open(struct inode *inode, struct file *file) socket_t i = iminor(inode); struct pcmcia_socket *s; user_info_t *user; + static int warning_printed = 0; ds_dbg(0, "ds_open(socket %d)\n", i); @@ -407,6 +408,17 @@ static int ds_open(struct inode *inode, struct file *file) s->user = user; file->private_data = user; + if (!warning_printed) { + printk(KERN_INFO "pcmcia: Detected deprecated PCMCIA ioctl " + "usage.\n"); + printk(KERN_INFO "pcmcia: This interface will soon be removed from " + "the kernel; please expect breakage unless you upgrade " + "to new tools.\n"); + printk(KERN_INFO "pcmcia: see http://www.kernel.org/pub/linux/" + "utils/kernel/pcmcia/pcmcia.html for details.\n"); + warning_printed = 1; + } + if (s->pcmcia_state.present) queue_event(user, CS_EVENT_CARD_INSERTION); return 0; -- cgit v1.2.3 From d7d7634c0f021d7d7ed781680d2c88940fc5fee8 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 13 Sep 2005 01:25:04 -0700 Subject: [PATCH] ide: clean up the garbage in eighty_ninty_three Replace the foot long pile of festering garbage in eighty_ninty_three with some actual clean code. All the ifdefs are fixed and havent changed since 2.4 Acked-by: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/ide-iops.c | 41 ++++++----------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index b443b04a4c5..0b0aa4f5162 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -601,44 +601,15 @@ EXPORT_SYMBOL(ide_wait_stat); */ u8 eighty_ninty_three (ide_drive_t *drive) { -#if 0 - if (!HWIF(drive)->udma_four) + if(HWIF(drive)->udma_four == 0) + return 0; + if (!(drive->id->hw_config & 0x6000)) return 0; - - if (drive->id->major_rev_num) { - int hssbd = 0; - int i; - /* - * Determine highest Supported SPEC - */ - for (i=1; i<=15; i++) - if (drive->id->major_rev_num & (1<id->hw_config & 0x4000) && -#endif /* CONFIG_IDEDMA_IVB */ - (drive->id->hw_config & 0x6000)) ? 1 : 0); - -#else - - return ((u8) ((HWIF(drive)->udma_four) && #ifndef CONFIG_IDEDMA_IVB - (drive->id->hw_config & 0x4000) && + if(!(drive->id->hw_config & 0x4000)) + return 0; #endif /* CONFIG_IDEDMA_IVB */ - (drive->id->hw_config & 0x6000)) ? 1 : 0); -#endif + return 1; } EXPORT_SYMBOL(eighty_ninty_three); -- cgit v1.2.3 From f39a4aa5ea579bcdcfbb9661ee77817bc4945562 Mon Sep 17 00:00:00 2001 From: Komuro Date: Tue, 13 Sep 2005 01:25:05 -0700 Subject: [PATCH] pcmcia: add another orinoco_cs id Add new id to orinoco_cs (corega PCCB-11). Signed-off-by: Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/wireless/orinoco_cs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index d1fb1bab8aa..bedd7f9f23e 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -629,6 +629,7 @@ static struct pcmcia_device_id orinoco_cs_ids[] = { PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90), PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584), PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9), + PCMCIA_DEVICE_PROD_ID12("corega_K.K.", "Wireless_LAN_PCCB-11", 0x29e33311, 0xee7a27ae), PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac), PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab), PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3), -- cgit v1.2.3 From 7979aca38b78ffe6a65ef309f26721c527104eaf Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 13 Sep 2005 01:25:07 -0700 Subject: [PATCH] i2c-keywest warning fix Unused variable. Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/i2c/busses/i2c-keywest.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index 37b49c2daf5..eff5896ce86 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c @@ -611,7 +611,6 @@ create_iface(struct device_node *np, struct device *dev) for (i=0; ichannels[i]; - u8 addr; sprintf(chan->adapter.name, "%s %d", np->parent->name, i); chan->iface = iface; -- cgit v1.2.3 From 8d0986e289a4b018fec87fcc49538945fb401f37 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 13 Sep 2005 01:25:07 -0700 Subject: [PATCH] vm: kswapd cleanup: use pgdat Use the pgdat pointer we've already defined in wakeup_kswapd Signed-off-by: Con Kolivas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index a740778f688..0ea71e887bb 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1258,9 +1258,9 @@ void wakeup_kswapd(struct zone *zone, int order) pgdat->kswapd_max_order = order; if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) return; - if (!waitqueue_active(&zone->zone_pgdat->kswapd_wait)) + if (!waitqueue_active(&pgdat->kswapd_wait)) return; - wake_up_interruptible(&zone->zone_pgdat->kswapd_wait); + wake_up_interruptible(&pgdat->kswapd_wait); } #ifdef CONFIG_PM -- cgit v1.2.3 From 5b952b3c143660b6436fcb299b249cefde61c18d Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Tue, 13 Sep 2005 01:25:08 -0700 Subject: [PATCH] Fix MPOL_F_VERIFY There was a pretty bad bug in there that the code would always check the full VMA, not the range the user requested. When the VMA to be checked was merged with the previous VMA this could lead to spurious failures. Signed-off-by: "Andi Kleen" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/mempolicy.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index afa06e184d8..9033f0859aa 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -333,8 +333,13 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end, if (prev && prev->vm_end < vma->vm_start) return ERR_PTR(-EFAULT); if ((flags & MPOL_MF_STRICT) && !is_vm_hugetlb_page(vma)) { + unsigned long endvma = vma->vm_end; + if (endvma > end) + endvma = end; + if (vma->vm_start > start) + start = vma->vm_start; err = check_pgd_range(vma->vm_mm, - vma->vm_start, vma->vm_end, nodes); + start, endvma, nodes); if (err) { first = ERR_PTR(err); break; -- cgit v1.2.3 From 6a00cbfcf8ffdd719cb5a27e1a0a9779665d1e23 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 13 Sep 2005 01:25:09 -0700 Subject: [PATCH] ppc32: discard *.exit.text and *.exit.data sections Discard *.exit.text sections on runtime. We cannot do this on link time because of the way BUG macros are implemented. If "__exit function" calls one of those macros, __bug_table section will reference this function. This is similar to ".altinstructions" situation on i386. *.exit.data seems to be OK in this respect and is discarded on link time. Signed-off-by: Eugene Surovegin Signed-off-by: Tom Rini Acked-by: Paul Mackerras Cc: Benjamin Herrenschmidt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/kernel/vmlinux.lds.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/ppc/kernel/vmlinux.lds.S b/arch/ppc/kernel/vmlinux.lds.S index 9353584fb71..17d2db7e537 100644 --- a/arch/ppc/kernel/vmlinux.lds.S +++ b/arch/ppc/kernel/vmlinux.lds.S @@ -96,6 +96,9 @@ SECTIONS *(.init.text) _einittext = .; } + /* .exit.text is discarded at runtime, not link time, + to deal with references from __bug_table */ + .exit.text : { *(.exit.text) } .init.data : { *(.init.data); __vtop_table_begin = .; @@ -190,5 +193,6 @@ SECTIONS /* Sections to be discarded. */ /DISCARD/ : { *(.exitcall.exit) + *(.exit.data) } } -- cgit v1.2.3 From 873d3469db66ea08e94b0d04a96b1a4507684824 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Tue, 13 Sep 2005 01:25:10 -0700 Subject: [PATCH] ppc32: remove use of asm/segment.h Removed ppc32 architecture specific users of asm/segment.h and asm-ppc/segment.h itself Signed-off-by: Kumar Gala Signed-off-by: Paul Mackerras Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/kernel/temp.c | 1 - arch/ppc/kernel/time.c | 1 - arch/ppc/platforms/chrp_time.c | 1 - arch/ppc/syslib/prep_nvram.c | 1 - include/asm-ppc/segment.h | 1 - 5 files changed, 5 deletions(-) delete mode 100644 include/asm-ppc/segment.h diff --git a/arch/ppc/kernel/temp.c b/arch/ppc/kernel/temp.c index fe8bb634ead..26bd8ea35a4 100644 --- a/arch/ppc/kernel/temp.c +++ b/arch/ppc/kernel/temp.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/arch/ppc/kernel/time.c b/arch/ppc/kernel/time.c index a3c5281a5d2..22d7fd1e0ae 100644 --- a/arch/ppc/kernel/time.c +++ b/arch/ppc/kernel/time.c @@ -58,7 +58,6 @@ #include #include -#include #include #include #include diff --git a/arch/ppc/platforms/chrp_time.c b/arch/ppc/platforms/chrp_time.c index 4864a7de3da..6037ce7796f 100644 --- a/arch/ppc/platforms/chrp_time.c +++ b/arch/ppc/platforms/chrp_time.c @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/arch/ppc/syslib/prep_nvram.c b/arch/ppc/syslib/prep_nvram.c index 2bcf8a16d1c..8599850ca77 100644 --- a/arch/ppc/syslib/prep_nvram.c +++ b/arch/ppc/syslib/prep_nvram.c @@ -15,7 +15,6 @@ #include #include -#include #include #include #include diff --git a/include/asm-ppc/segment.h b/include/asm-ppc/segment.h deleted file mode 100644 index 0f2f7428d43..00000000000 --- a/include/asm-ppc/segment.h +++ /dev/null @@ -1 +0,0 @@ -#include -- cgit v1.2.3 From a1a5b3d93ca45613ec1d920fdb131b69b6553882 Mon Sep 17 00:00:00 2001 From: Peter Staubach Date: Tue, 13 Sep 2005 01:25:12 -0700 Subject: [PATCH] open returns ENFILE but creates file anyway When open(O_CREAT) is called and the error, ENFILE, is returned, the file may be created anyway. This is counter intuitive, against the SUS V3 specification, and may cause applications to misbehave if they are not coded correctly to handle this semantic. The SUS V3 specification explicitly states "No files shall be created or modified if the function returns -1.". The error, ENFILE, is used to indicate the system wide open file table is full and no more file structs can be allocated. This is due to an ordering problem. The entry in the directory is created before the file struct is allocated. If the allocation for the file struct fails, then the system call must return an error, but the directory entry was already created and can not be safely removed. The solution to this situation is relatively easy. The file struct should be allocated before the directory entry is created. If the allocation fails, then the error can be returned directly. If the creation of the directory entry fails, then the file struct can be easily freed. Signed-off-by: Peter Staubach Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/open.c | 98 ++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/fs/open.c b/fs/open.c index 2fac58c5191..f0d90cf0495 100644 --- a/fs/open.c +++ b/fs/open.c @@ -738,52 +738,15 @@ asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group) return error; } -/* - * Note that while the flag value (low two bits) for sys_open means: - * 00 - read-only - * 01 - write-only - * 10 - read-write - * 11 - special - * it is changed into - * 00 - no permissions needed - * 01 - read-permission - * 10 - write-permission - * 11 - read-write - * for the internal routines (ie open_namei()/follow_link() etc). 00 is - * used by symlinks. - */ -struct file *filp_open(const char * filename, int flags, int mode) -{ - int namei_flags, error; - struct nameidata nd; - - namei_flags = flags; - if ((namei_flags+1) & O_ACCMODE) - namei_flags++; - if (namei_flags & O_TRUNC) - namei_flags |= 2; - - error = open_namei(filename, namei_flags, mode, &nd); - if (!error) - return dentry_open(nd.dentry, nd.mnt, flags); - - return ERR_PTR(error); -} - -EXPORT_SYMBOL(filp_open); - -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) +static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, + int flags, struct file *f) { - struct file * f; struct inode *inode; int error; - error = -ENFILE; - f = get_empty_filp(); - if (!f) - goto cleanup_dentry; f->f_flags = flags; - f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE; + f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | + FMODE_PREAD | FMODE_PWRITE; inode = dentry->d_inode; if (f->f_mode & FMODE_WRITE) { error = get_write_access(inode); @@ -828,12 +791,63 @@ cleanup_all: f->f_vfsmnt = NULL; cleanup_file: put_filp(f); -cleanup_dentry: dput(dentry); mntput(mnt); return ERR_PTR(error); } +/* + * Note that while the flag value (low two bits) for sys_open means: + * 00 - read-only + * 01 - write-only + * 10 - read-write + * 11 - special + * it is changed into + * 00 - no permissions needed + * 01 - read-permission + * 10 - write-permission + * 11 - read-write + * for the internal routines (ie open_namei()/follow_link() etc). 00 is + * used by symlinks. + */ +struct file *filp_open(const char * filename, int flags, int mode) +{ + int namei_flags, error; + struct nameidata nd; + struct file *f; + + namei_flags = flags; + if ((namei_flags+1) & O_ACCMODE) + namei_flags++; + if (namei_flags & O_TRUNC) + namei_flags |= 2; + + error = -ENFILE; + f = get_empty_filp(); + if (f == NULL) + return ERR_PTR(error); + + error = open_namei(filename, namei_flags, mode, &nd); + if (!error) + return __dentry_open(nd.dentry, nd.mnt, flags, f); + + put_filp(f); + return ERR_PTR(error); +} +EXPORT_SYMBOL(filp_open); + +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) +{ + int error; + struct file *f; + + error = -ENFILE; + f = get_empty_filp(); + if (f == NULL) + return ERR_PTR(error); + + return __dentry_open(dentry, mnt, flags, f); +} EXPORT_SYMBOL(dentry_open); /* -- cgit v1.2.3 From 0f3d2bd54f8fb178f516fc6903366e16e20f7428 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Tue, 13 Sep 2005 01:25:12 -0700 Subject: [PATCH] free initrd mem adjustment Besides freeing initrd memory, also clear out the now dangling pointers to it, to make sure accidental late use attempts can be detected. Signed-off-by: Jan Beulich Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- init/initramfs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 02c5ce64990..0c5d9a3f951 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -466,6 +466,14 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only) extern char __initramfs_start[], __initramfs_end[]; #ifdef CONFIG_BLK_DEV_INITRD #include + +static void __init free_initrd(void) +{ + free_initrd_mem(initrd_start, initrd_end); + initrd_start = 0; + initrd_end = 0; +} + #endif void __init populate_rootfs(void) @@ -484,7 +492,7 @@ void __init populate_rootfs(void) printk(" it is\n"); unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start, 0); - free_initrd_mem(initrd_start, initrd_end); + free_initrd(); return; } printk("it isn't (%s); looks like an initrd\n", err); @@ -493,7 +501,7 @@ void __init populate_rootfs(void) sys_write(fd, (char *)initrd_start, initrd_end - initrd_start); sys_close(fd); - free_initrd_mem(initrd_start, initrd_end); + free_initrd(); } } #endif -- cgit v1.2.3 From 921717a2a1cde78c9b2aa971c16510d63efe7320 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Tue, 13 Sep 2005 01:25:13 -0700 Subject: [PATCH] Make BUILD_BUG_ON fail at compile time. Force a compiler error instead of a link error, because they are easier to track down. Idea stolen from code by Jan Beulich If the argument to BUILD_BUG_ON evaluates to non-zero the compiler will do: t.c:6: error: size of array `type name' is negative (surprised that gcc doesn't have an extension for this) Signed-off-by: "Andi Kleen" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/kernel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 687ba8c9973..4367ce4db52 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -307,8 +307,8 @@ struct sysinfo { char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ }; -extern void BUILD_BUG(void); -#define BUILD_BUG_ON(condition) do { if (condition) BUILD_BUG(); } while(0) +/* Force a compilation error if condition is false */ +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) #ifdef CONFIG_SYSCTL extern int randomize_va_space; -- cgit v1.2.3 From 498d0c5711094b0e1fd93f5355d270ccebdec706 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 13 Sep 2005 01:25:14 -0700 Subject: [PATCH] set_current_state() commentary Explain the mysteries of set_current_state(). Quoth Linus: The scheduler itself never needs the memory barrier at all. The barrier is needed only if the user itself ends up testing some other thing afterwards, ie if you have set_process_state(TASK_INTERRUPTIBLE); if (still_need_to_sleep()) schedule(); then the "still_need_to_sleep()" thing may test flags and wakeup events, and then you _may_ want to (and often do) make sure that the write of TASK_INTERRUPTIBLE is serialized wrt the reads of any wakeup data (since the wakeup may have happened on another CPU). So the comment is somewhat wrong. We don't really _care_ whether the state propagates out to other CPU's since all of our actions are purely local, and there is nothing we do that is conditional on any other CPU: we're going to sleep unconditionally, and the scheduler only cares about _our_ state, not about somebody elses state. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/sched.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 38c8654aaa9..49e617fa0f6 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -121,6 +121,17 @@ extern unsigned long nr_iowait(void); #define set_task_state(tsk, state_value) \ set_mb((tsk)->state, (state_value)) +/* + * set_current_state() includes a barrier so that the write of current->state + * is correctly serialised wrt the caller's subsequent test of whether to + * actually sleep: + * + * set_current_state(TASK_UNINTERRUPTIBLE); + * if (do_i_need_to_sleep()) + * schedule(); + * + * If the caller does not need such serialisation then use __set_current_state() + */ #define __set_current_state(state_value) \ do { current->state = (state_value); } while (0) #define set_current_state(state_value) \ -- cgit v1.2.3 From 8a1c17574a01555e5d3fdf56d8d72969904c91ca Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 13 Sep 2005 01:25:15 -0700 Subject: [PATCH] schedule_timeout_[un]interruptible() speedup These functions don't need schedule_timeout()'s barrier. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/timer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/timer.c b/kernel/timer.c index f4152fcd9f8..3ba10fa35b6 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1151,19 +1151,22 @@ fastcall signed long __sched schedule_timeout(signed long timeout) out: return timeout < 0 ? 0 : timeout; } - EXPORT_SYMBOL(schedule_timeout); +/* + * We can use __set_current_state() here because schedule_timeout() calls + * schedule() unconditionally. + */ signed long __sched schedule_timeout_interruptible(signed long timeout) { - set_current_state(TASK_INTERRUPTIBLE); + __set_current_state(TASK_INTERRUPTIBLE); return schedule_timeout(timeout); } EXPORT_SYMBOL(schedule_timeout_interruptible); signed long __sched schedule_timeout_uninterruptible(signed long timeout) { - set_current_state(TASK_UNINTERRUPTIBLE); + __set_current_state(TASK_UNINTERRUPTIBLE); return schedule_timeout(timeout); } EXPORT_SYMBOL(schedule_timeout_uninterruptible); -- cgit v1.2.3 From fb911ee849756fc6c609dddded92d9207ff3fb29 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Tue, 13 Sep 2005 01:25:15 -0700 Subject: [PATCH] Remove unnecessary check_region references in comments Remove check_region references from comments and printk statements so that searching for real users of this deprecated function gets easier. Signed-off-by: Peter Osterlund Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/amiserial.c | 4 ---- drivers/isdn/sc/init.c | 4 ++-- drivers/media/radio/radio-aimslab.c | 2 +- drivers/media/radio/radio-aztech.c | 2 +- drivers/media/radio/radio-cadet.c | 2 +- drivers/media/radio/radio-gemtek.c | 2 +- drivers/media/radio/radio-rtrack2.c | 2 +- drivers/media/radio/radio-sf16fmi.c | 2 +- drivers/media/radio/radio-sf16fmr2.c | 2 +- drivers/media/radio/radio-terratec.c | 2 +- drivers/media/radio/radio-typhoon.c | 2 +- drivers/media/radio/radio-zoltrix.c | 2 +- drivers/net/arcnet/com90io.c | 4 ++-- drivers/sbus/char/display7seg.c | 2 +- drivers/tc/zs.c | 2 +- 15 files changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c index 2a36561eec6..a124f8c5d06 100644 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c @@ -2053,10 +2053,6 @@ static int __init rs_init(void) state->icount.rx = state->icount.tx = 0; state->icount.frame = state->icount.parity = 0; state->icount.overrun = state->icount.brk = 0; - /* - if(state->port && check_region(state->port,REGION_LENGTH(state))) - continue; - */ printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n", state->line); diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c index 40b0df04ed9..1ebed041672 100644 --- a/drivers/isdn/sc/init.c +++ b/drivers/isdn/sc/init.c @@ -87,7 +87,7 @@ static int __init sc_init(void) */ for (i = 0 ; i < MAX_IO_REGS - 1 ; i++) { if(!request_region(io[b] + i * 0x400, 1, "sc test")) { - pr_debug("check_region for 0x%x failed\n", io[b] + i * 0x400); + pr_debug("request_region for 0x%x failed\n", io[b] + i * 0x400); io[b] = 0; break; } else @@ -181,7 +181,7 @@ static int __init sc_init(void) for (i = SRAM_MIN ; i < SRAM_MAX ; i += SRAM_PAGESIZE) { pr_debug("Checking RAM address 0x%x...\n", i); if(request_region(i, SRAM_PAGESIZE, "sc test")) { - pr_debug(" check_region succeeded\n"); + pr_debug(" request_region succeeded\n"); model = identify_board(i, io[b]); release_region(i, SRAM_PAGESIZE); if (model >= 0) { diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c index 8b4ad70dd1b..877c770558e 100644 --- a/drivers/media/radio/radio-aimslab.c +++ b/drivers/media/radio/radio-aimslab.c @@ -29,7 +29,7 @@ #include /* Modules */ #include /* Initdata */ -#include /* check_region, request_region */ +#include /* request_region */ #include /* udelay */ #include /* outb, outb_p */ #include /* copy to/from user */ diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c index 013c835ed91..5319a9c9a97 100644 --- a/drivers/media/radio/radio-aztech.c +++ b/drivers/media/radio/radio-aztech.c @@ -26,7 +26,7 @@ #include /* Modules */ #include /* Initdata */ -#include /* check_region, request_region */ +#include /* request_region */ #include /* udelay */ #include /* outb, outb_p */ #include /* copy to/from user */ diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c index 53d399b6652..022913da8c5 100644 --- a/drivers/media/radio/radio-cadet.c +++ b/drivers/media/radio/radio-cadet.c @@ -29,7 +29,7 @@ #include /* Modules */ #include /* Initdata */ -#include /* check_region, request_region */ +#include /* request_region */ #include /* udelay */ #include /* outb, outb_p */ #include /* copy to/from user */ diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c index 202bfe6819b..6418f03b9ce 100644 --- a/drivers/media/radio/radio-gemtek.c +++ b/drivers/media/radio/radio-gemtek.c @@ -17,7 +17,7 @@ #include /* Modules */ #include /* Initdata */ -#include /* check_region, request_region */ +#include /* request_region */ #include /* udelay */ #include /* outb, outb_p */ #include /* copy to/from user */ diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c index c00245d4d24..b2256d675b4 100644 --- a/drivers/media/radio/radio-rtrack2.c +++ b/drivers/media/radio/radio-rtrack2.c @@ -10,7 +10,7 @@ #include /* Modules */ #include /* Initdata */ -#include /* check_region, request_region */ +#include /* request_region */ #include /* udelay */ #include /* outb, outb_p */ #include /* copy to/from user */ diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index 3a464a09221..6f03ce4dd7b 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c @@ -18,7 +18,7 @@ #include /* __setup */ #include /* Modules */ #include /* Initdata */ -#include /* check_region, request_region */ +#include /* request_region */ #include /* udelay */ #include /* kernel radio structs */ #include diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c index 0732efda6a9..71971e9bb34 100644 --- a/drivers/media/radio/radio-sf16fmr2.c +++ b/drivers/media/radio/radio-sf16fmr2.c @@ -14,7 +14,7 @@ #include /* Modules */ #include /* Initdata */ -#include /* check_region, request_region */ +#include /* request_region */ #include /* udelay */ #include /* outb, outb_p */ #include /* copy to/from user */ diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c index 248d67fde03..b03573c6840 100644 --- a/drivers/media/radio/radio-terratec.c +++ b/drivers/media/radio/radio-terratec.c @@ -25,7 +25,7 @@ #include /* Modules */ #include /* Initdata */ -#include /* check_region, request_region */ +#include /* request_region */ #include /* udelay */ #include /* outb, outb_p */ #include /* copy to/from user */ diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c index d7da901ebe9..f304f3c1476 100644 --- a/drivers/media/radio/radio-typhoon.c +++ b/drivers/media/radio/radio-typhoon.c @@ -31,7 +31,7 @@ #include /* Modules */ #include /* Initdata */ -#include /* check_region, request_region */ +#include /* request_region */ #include /* radio card status report */ #include /* outb, outb_p */ #include /* copy to/from user */ diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c index 342f92df4ab..4c6d6fb4903 100644 --- a/drivers/media/radio/radio-zoltrix.c +++ b/drivers/media/radio/radio-zoltrix.c @@ -28,7 +28,7 @@ #include /* Modules */ #include /* Initdata */ -#include /* check_region, request_region */ +#include /* request_region */ #include /* udelay, msleep */ #include /* outb, outb_p */ #include /* copy to/from user */ diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c index 52c77cbe8c6..1f030273541 100644 --- a/drivers/net/arcnet/com90io.c +++ b/drivers/net/arcnet/com90io.c @@ -160,7 +160,7 @@ static int __init com90io_probe(struct net_device *dev) return -ENODEV; } if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com90io probe")) { - BUGMSG(D_INIT_REASONS, "IO check_region %x-%x failed.\n", + BUGMSG(D_INIT_REASONS, "IO request_region %x-%x failed.\n", ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1); return -ENXIO; } @@ -242,7 +242,7 @@ static int __init com90io_found(struct net_device *dev) BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq); return -ENODEV; } - /* Reserve the I/O region - guaranteed to work by check_region */ + /* Reserve the I/O region */ if (!request_region(dev->base_addr, ARCNET_TOTAL_SIZE, "arcnet (COM90xx-IO)")) { free_irq(dev->irq, dev); return -EBUSY; diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c index dbad7f35eb0..24ed5893b4f 100644 --- a/drivers/sbus/char/display7seg.c +++ b/drivers/sbus/char/display7seg.c @@ -14,7 +14,7 @@ #include #include #include -#include /* request_region, check_region */ +#include /* request_region */ #include #include /* EBus device */ #include /* OpenProm Library */ diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c index 4382ee60b6a..6bed8713897 100644 --- a/drivers/tc/zs.c +++ b/drivers/tc/zs.c @@ -1683,7 +1683,7 @@ static void __init probe_sccs(void) #ifndef CONFIG_SERIAL_DEC_CONSOLE /* * We're called early and memory managment isn't up, yet. - * Thus check_region would fail. + * Thus request_region would fail. */ if (!request_region((unsigned long) zs_channels[n_channels].control, -- cgit v1.2.3 From 9f1583339a6f52c0c26441d39a0deff8246800f7 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 13 Sep 2005 01:25:16 -0700 Subject: [PATCH] use add_taint() for setting tainted bit flags Use the add_taint() interface for setting tainted bit flags instead of doing it manually. Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/smpboot.c | 2 +- arch/x86_64/kernel/mce.c | 2 +- kernel/module.c | 11 ++++++----- mm/page_alloc.c | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index c70cd2a0830..5f0a95d76a4 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c @@ -202,7 +202,7 @@ static void __devinit smp_store_cpu_info(int id) goto valid_k7; /* If we get here, it's not a certified SMP capable AMD system. */ - tainted |= TAINT_UNSAFE_SMP; + add_taint(TAINT_UNSAFE_SMP); } valid_k7: diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c index 969365c0771..08203b07f4b 100644 --- a/arch/x86_64/kernel/mce.c +++ b/arch/x86_64/kernel/mce.c @@ -217,7 +217,7 @@ void do_machine_check(struct pt_regs * regs, long error_code) panicm_found = 1; } - tainted |= TAINT_MACHINE_CHECK; + add_taint(TAINT_MACHINE_CHECK); } /* Never do anything final in the polling timer */ diff --git a/kernel/module.c b/kernel/module.c index 4b39d3793c7..ff5c500ab62 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -498,7 +499,7 @@ static inline int try_force(unsigned int flags) { int ret = (flags & O_TRUNC); if (ret) - tainted |= TAINT_FORCED_MODULE; + add_taint(TAINT_FORCED_MODULE); return ret; } #else @@ -897,7 +898,7 @@ static int check_version(Elf_Shdr *sechdrs, if (!(tainted & TAINT_FORCED_MODULE)) { printk("%s: no version for \"%s\" found: kernel tainted.\n", mod->name, symname); - tainted |= TAINT_FORCED_MODULE; + add_taint(TAINT_FORCED_MODULE); } return 1; } @@ -1352,7 +1353,7 @@ static void set_license(struct module *mod, const char *license) if (!mod->license_gplok && !(tainted & TAINT_PROPRIETARY_MODULE)) { printk(KERN_WARNING "%s: module license '%s' taints kernel.\n", mod->name, license); - tainted |= TAINT_PROPRIETARY_MODULE; + add_taint(TAINT_PROPRIETARY_MODULE); } } @@ -1610,7 +1611,7 @@ static struct module *load_module(void __user *umod, modmagic = get_modinfo(sechdrs, infoindex, "vermagic"); /* This is allowed: modprobe --force will invalidate it. */ if (!modmagic) { - tainted |= TAINT_FORCED_MODULE; + add_taint(TAINT_FORCED_MODULE); printk(KERN_WARNING "%s: no version magic, tainting kernel.\n", mod->name); } else if (!same_magic(modmagic, vermagic)) { @@ -1739,7 +1740,7 @@ static struct module *load_module(void __user *umod, (mod->num_gpl_syms && !gplcrcindex)) { printk(KERN_WARNING "%s: No versions for exported symbols." " Tainting kernel.\n", mod->name); - tainted |= TAINT_FORCED_MODULE; + add_taint(TAINT_FORCED_MODULE); } #endif diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c5823c395f7..ae2903339e7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -117,7 +118,7 @@ static void bad_page(const char *function, struct page *page) set_page_count(page, 0); reset_page_mapcount(page); page->mapping = NULL; - tainted |= TAINT_BAD_PAGE; + add_taint(TAINT_BAD_PAGE); } #ifndef CONFIG_HUGETLB_PAGE -- cgit v1.2.3 From 9f03783ce5d851e4b98dfaf3e9eb177870f6c75d Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Tue, 13 Sep 2005 01:25:17 -0700 Subject: [PATCH] reiserfs: use mark_inode_dirty instead of reiserfs_update_sd reiserfs should use mark_inode_dirty during reiserfs_file_write and reiserfs_commit_write. This makes sure the inode is properly flagged as dirty, which is used during O_SYNC to decide when to trigger log commits. This patch also removes the O_SYNC check from reiserfs_commit_write, since that gets dealt with properly at higher layers once we start using mark_inode_dirty. Thanks to Hifumi Hisashi for catching this. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/reiserfs/file.c | 11 ++++++----- fs/reiserfs/inode.c | 16 +++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index c9f178fb494..c20babd6216 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c @@ -667,7 +667,7 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl if (th->t_trans_id) { int err; // update any changes we made to blk count - reiserfs_update_sd(th, inode); + mark_inode_dirty(inode); err = journal_end(th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3 + 1 + @@ -855,17 +855,18 @@ static int reiserfs_submit_file_region_for_write(struct reiserfs_transaction_han if (th->t_trans_id) { reiserfs_write_lock(inode->i_sb); - reiserfs_update_sd(th, inode); // And update on-disk metadata + // this sets the proper flags for O_SYNC to trigger a commit + mark_inode_dirty(inode); reiserfs_write_unlock(inode->i_sb); } else - inode->i_sb->s_op->dirty_inode(inode); + mark_inode_dirty(inode); sd_update = 1; } if (th->t_trans_id) { reiserfs_write_lock(inode->i_sb); if (!sd_update) - reiserfs_update_sd(th, inode); + mark_inode_dirty(inode); status = journal_end(th, th->t_super, th->t_blocks_allocated); if (status) retval = status; @@ -1320,7 +1321,7 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t return err; } reiserfs_update_inode_transaction(inode); - reiserfs_update_sd(&th, inode); + mark_inode_dirty(inode); err = journal_end(&th, inode->i_sb, 1); if (err) { reiserfs_write_unlock(inode->i_sb); diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 1a8a1bf2154..d76ee6c4f9b 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c @@ -2639,6 +2639,12 @@ static int reiserfs_commit_write(struct file *f, struct page *page, } reiserfs_update_inode_transaction(inode); inode->i_size = pos; + /* + * this will just nest into our transaction. It's important + * to use mark_inode_dirty so the inode gets pushed around on the + * dirty lists, and so that O_SYNC works as expected + */ + mark_inode_dirty(inode); reiserfs_update_sd(&myth, inode); update_sd = 1; ret = journal_end(&myth, inode->i_sb, 1); @@ -2649,21 +2655,13 @@ static int reiserfs_commit_write(struct file *f, struct page *page, if (th) { reiserfs_write_lock(inode->i_sb); if (!update_sd) - reiserfs_update_sd(th, inode); + mark_inode_dirty(inode); ret = reiserfs_end_persistent_transaction(th); reiserfs_write_unlock(inode->i_sb); if (ret) goto out; } - /* we test for O_SYNC here so we can commit the transaction - ** for any packed tails the file might have had - */ - if (f && (f->f_flags & O_SYNC)) { - reiserfs_write_lock(inode->i_sb); - ret = reiserfs_commit_for_inode(inode); - reiserfs_write_unlock(inode->i_sb); - } out: return ret; -- cgit v1.2.3 From 8fbc33680c191f4e74c937c8289685d6caaadea6 Mon Sep 17 00:00:00 2001 From: Michal Piotrowski Date: Tue, 13 Sep 2005 01:25:18 -0700 Subject: [PATCH] dontdiff: add asm_offsets We seem to use both asm-offsets.* and asm_offsets.* Signed-off-by: Michal K. K. Piotrowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/dontdiff | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/dontdiff b/Documentation/dontdiff index 96bea278bbf..24adfe9af3c 100644 --- a/Documentation/dontdiff +++ b/Documentation/dontdiff @@ -55,6 +55,7 @@ aic7*seq.h* aicasm aicdb.h* asm +asm-offsets.* asm_offsets.* autoconf.h* bbootsect -- cgit v1.2.3 From 9dc7a86e85593c834bb930f5d5aba3a19ee7a350 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 13 Sep 2005 01:25:19 -0700 Subject: [PATCH] cciss: new controller pci/subsystem ids This patch adds new PCI and subsystem ID's that finally made the spec. It also include a name change for one controller. I know there's a lot of duplicat names but the fw folks wanted this for the different implementations. Even though the same ASIC is used it may be embedded on some platforms, standup card in others, and a mezzanine in other servers. Signed-off-by: Mike Miller Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/cciss.txt | 4 +++- drivers/block/cciss.c | 33 ++++++++++++++++++++++++--------- include/linux/pci_ids.h | 4 +++- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Documentation/cciss.txt b/Documentation/cciss.txt index c8f9a73111d..68a711fb82c 100644 --- a/Documentation/cciss.txt +++ b/Documentation/cciss.txt @@ -17,7 +17,9 @@ This driver is known to work with the following cards: * SA P600 * SA P800 * SA E400 - * SA E300 + * SA P400i + * SA E200 + * SA E200i If nodes are not already created in the /dev/cciss directory, run as root: diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 28f2c177a54..4a49d797212 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -47,14 +47,14 @@ #include #define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) -#define DRIVER_NAME "HP CISS Driver (v 2.6.6)" -#define DRIVER_VERSION CCISS_DRIVER_VERSION(2,6,6) +#define DRIVER_NAME "HP CISS Driver (v 2.6.8)" +#define DRIVER_VERSION CCISS_DRIVER_VERSION(2,6,8) /* Embedded module documentation macros - see modules.h */ MODULE_AUTHOR("Hewlett-Packard Company"); -MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 2.6.6"); +MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 2.6.8"); MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400" - " SA6i P600 P800 E400 E300"); + " SA6i P600 P800 P400 P400i E200 E200i"); MODULE_LICENSE("GPL"); #include "cciss_cmd.h" @@ -83,12 +83,22 @@ static const struct pci_device_id cciss_pci_device_id[] = { 0x0E11, 0x4091, 0, 0, 0}, { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSA, 0x103C, 0x3225, 0, 0, 0}, - { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSB, + { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103c, 0x3223, 0, 0, 0}, { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, - 0x103c, 0x3231, 0, 0, 0}, + 0x103c, 0x3234, 0, 0, 0}, { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, - 0x103c, 0x3233, 0, 0, 0}, + 0x103c, 0x3235, 0, 0, 0}, + { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, + 0x103c, 0x3211, 0, 0, 0}, + { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, + 0x103c, 0x3212, 0, 0, 0}, + { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, + 0x103c, 0x3213, 0, 0, 0}, + { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, + 0x103c, 0x3214, 0, 0, 0}, + { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, + 0x103c, 0x3215, 0, 0, 0}, {0,} }; MODULE_DEVICE_TABLE(pci, cciss_pci_device_id); @@ -111,8 +121,13 @@ static struct board_type products[] = { { 0x40910E11, "Smart Array 6i", &SA5_access}, { 0x3225103C, "Smart Array P600", &SA5_access}, { 0x3223103C, "Smart Array P800", &SA5_access}, - { 0x3231103C, "Smart Array E400", &SA5_access}, - { 0x3233103C, "Smart Array E300", &SA5_access}, + { 0x3234103C, "Smart Array P400", &SA5_access}, + { 0x3235103C, "Smart Array P400i", &SA5_access}, + { 0x3211103C, "Smart Array E200i", &SA5_access}, + { 0x3212103C, "Smart Array E200", &SA5_access}, + { 0x3213103C, "Smart Array E200i", &SA5_access}, + { 0x3214103C, "Smart Array E200i", &SA5_access}, + { 0x3215103C, "Smart Array E200i", &SA5_access}, }; /* How long to wait (in millesconds) for board to go into simple mode */ diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index ee0ab7a5f91..7fcb44bc9af 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -713,10 +713,12 @@ #define PCI_DEVICE_ID_HP_DIVA_EVEREST 0x1282 #define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290 #define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301 +#define PCI_DEVICE_ID_HP_CISS 0x3210 #define PCI_DEVICE_ID_HP_CISSA 0x3220 #define PCI_DEVICE_ID_HP_CISSB 0x3222 -#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031 #define PCI_DEVICE_ID_HP_CISSC 0x3230 +#define PCI_DEVICE_ID_HP_CISSD 0x3238 +#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031 #define PCI_VENDOR_ID_PCTECH 0x1042 #define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000 -- cgit v1.2.3 From 1f8ef3806c40e74733f45f436d44b3d8e9a2fa48 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 13 Sep 2005 01:25:21 -0700 Subject: [PATCH] cciss: busy_initializing flag This patch adds a flag called busy_initializing. If there are multiple controllers in a server AND the HP agents are running it's possible the agents may try to poll a card that is still initializing if the driver is removed and then added again. Signed-off-by: Don Brace Signed-off-by: Mike Miller Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/cciss.c | 8 ++++++++ drivers/block/cciss.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 4a49d797212..8bcd6c498c6 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -468,6 +468,9 @@ static int cciss_open(struct inode *inode, struct file *filep) printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name); #endif /* CCISS_DEBUG */ + if (host->busy_initializing) + return -EBUSY; + /* * Root is allowed to open raw volume zero even if it's not configured * so array config can still work. Root is also allowed to open any @@ -2742,6 +2745,9 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, i = alloc_cciss_hba(); if(i < 0) return (-1); + + hba[i]->busy_initializing = 1; + if (cciss_pci_init(hba[i], pdev) != 0) goto clean1; @@ -2864,6 +2870,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, add_disk(disk); } + hba[i]->busy_initializing = 0; return(1); clean4: @@ -2884,6 +2891,7 @@ clean2: clean1: release_io_mem(hba[i]); free_hba(i); + hba[i]->busy_initializing = 0; return(-1); } diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h index 566587d0a50..11ee83504b3 100644 --- a/drivers/block/cciss.h +++ b/drivers/block/cciss.h @@ -83,6 +83,7 @@ struct ctlr_info int nr_allocs; int nr_frees; int busy_configuring; + int busy_initializing; /* This element holds the zero based queue number of the last * queue to be started. It is used for fairness. -- cgit v1.2.3 From ddd474420a0b0dfeda38b6b5f83c7af751235cc3 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 13 Sep 2005 01:25:22 -0700 Subject: [PATCH] cciss: new disk register/deregister routines This patch removes a couple of functions dealing with configuration and replaces them with new functions. This implementation fixes some bugs associated with the ACUXE. It also allows a logical volume to be removed from the middle without deleting all volumes behind it. If a user has 5 logical volumes and decides he wants to reconfigure volume number 3, he can now do that without removing volumes 4 & 5 first. This code has been tested in our labs against all application software. Signed-off-by: Chase Maupin Signed-off-by: Mike Miller Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/cciss.c | 515 ++++++++++++++++++++++++++++++++------------------ drivers/block/cciss.h | 8 +- 2 files changed, 333 insertions(+), 190 deletions(-) diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 8bcd6c498c6..3c6a6a21d54 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -155,15 +155,24 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, static int revalidate_allvol(ctlr_info_t *host); static int cciss_revalidate(struct gendisk *disk); -static int deregister_disk(struct gendisk *disk); -static int register_new_disk(ctlr_info_t *h); +static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk); +static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, int clear_all); +static void cciss_read_capacity(int ctlr, int logvol, ReadCapdata_struct *buf, + int withirq, unsigned int *total_size, unsigned int *block_size); +static void cciss_geometry_inquiry(int ctlr, int logvol, + int withirq, unsigned int total_size, + unsigned int block_size, InquiryData_struct *inq_buff, + drive_info_struct *drv); static void cciss_getgeometry(int cntl_num); static void start_io( ctlr_info_t *h); static int sendcmd( __u8 cmd, int ctlr, void *buff, size_t size, unsigned int use_unit_num, unsigned int log_unit, __u8 page_code, unsigned char *scsi3addr, int cmd_type); +static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, + unsigned int use_unit_num, unsigned int log_unit, __u8 page_code, + int cmd_type); #ifdef CONFIG_PROC_FS static int cciss_proc_get_info(char *buffer, char **start, off_t offset, @@ -280,7 +289,7 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset, for(i=0; i<=h->highest_lun; i++) { drv = &h->drv[i]; - if (drv->block_size == 0) + if (drv->heads == 0) continue; vol_sz = drv->nr_blocks; @@ -471,6 +480,8 @@ static int cciss_open(struct inode *inode, struct file *filep) if (host->busy_initializing) return -EBUSY; + if (host->busy_initializing || drv->busy_configuring) + return -EBUSY; /* * Root is allowed to open raw volume zero even if it's not configured * so array config can still work. Root is also allowed to open any @@ -814,10 +825,10 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, return(0); } case CCISS_DEREGDISK: - return deregister_disk(disk); + return rebuild_lun_table(host, disk); case CCISS_REGNEWD: - return register_new_disk(host); + return rebuild_lun_table(host, NULL); case CCISS_PASSTHRU: { @@ -1161,48 +1172,323 @@ static int revalidate_allvol(ctlr_info_t *host) return 0; } -static int deregister_disk(struct gendisk *disk) +/* This function will check the usage_count of the drive to be updated/added. + * If the usage_count is zero then the drive information will be updated and + * the disk will be re-registered with the kernel. If not then it will be + * left alone for the next reboot. The exception to this is disk 0 which + * will always be left registered with the kernel since it is also the + * controller node. Any changes to disk 0 will show up on the next + * reboot. +*/ +static void cciss_update_drive_info(int ctlr, int drv_index) + { + ctlr_info_t *h = hba[ctlr]; + struct gendisk *disk; + ReadCapdata_struct *size_buff = NULL; + InquiryData_struct *inq_buff = NULL; + unsigned int block_size; + unsigned int total_size; + unsigned long flags = 0; + int ret = 0; + + /* if the disk already exists then deregister it before proceeding*/ + if (h->drv[drv_index].raid_level != -1){ + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); + h->drv[drv_index].busy_configuring = 1; + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + ret = deregister_disk(h->gendisk[drv_index], + &h->drv[drv_index], 0); + h->drv[drv_index].busy_configuring = 0; + } + + /* If the disk is in use return */ + if (ret) + return; + + + /* Get information about the disk and modify the driver sturcture */ + size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL); + if (size_buff == NULL) + goto mem_msg; + inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL); + if (inq_buff == NULL) + goto mem_msg; + + cciss_read_capacity(ctlr, drv_index, size_buff, 1, + &total_size, &block_size); + cciss_geometry_inquiry(ctlr, drv_index, 1, total_size, block_size, + inq_buff, &h->drv[drv_index]); + + ++h->num_luns; + disk = h->gendisk[drv_index]; + set_capacity(disk, h->drv[drv_index].nr_blocks); + + + /* if it's the controller it's already added */ + if (drv_index){ + disk->queue = blk_init_queue(do_cciss_request, &h->lock); + + /* Set up queue information */ + disk->queue->backing_dev_info.ra_pages = READ_AHEAD; + blk_queue_bounce_limit(disk->queue, hba[ctlr]->pdev->dma_mask); + + /* This is a hardware imposed limit. */ + blk_queue_max_hw_segments(disk->queue, MAXSGENTRIES); + + /* This is a limit in the driver and could be eliminated. */ + blk_queue_max_phys_segments(disk->queue, MAXSGENTRIES); + + blk_queue_max_sectors(disk->queue, 512); + + disk->queue->queuedata = hba[ctlr]; + + blk_queue_hardsect_size(disk->queue, + hba[ctlr]->drv[drv_index].block_size); + + h->drv[drv_index].queue = disk->queue; + add_disk(disk); + } + +freeret: + kfree(size_buff); + kfree(inq_buff); + return; +mem_msg: + printk(KERN_ERR "cciss: out of memory\n"); + goto freeret; +} + +/* This function will find the first index of the controllers drive array + * that has a -1 for the raid_level and will return that index. This is + * where new drives will be added. If the index to be returned is greater + * than the highest_lun index for the controller then highest_lun is set + * to this new index. If there are no available indexes then -1 is returned. +*/ +static int cciss_find_free_drive_index(int ctlr) +{ + int i; + + for (i=0; i < CISS_MAX_LUN; i++){ + if (hba[ctlr]->drv[i].raid_level == -1){ + if (i > hba[ctlr]->highest_lun) + hba[ctlr]->highest_lun = i; + return i; + } + } + return -1; +} + +/* This function will add and remove logical drives from the Logical + * drive array of the controller and maintain persistancy of ordering + * so that mount points are preserved until the next reboot. This allows + * for the removal of logical drives in the middle of the drive array + * without a re-ordering of those drives. + * INPUT + * h = The controller to perform the operations on + * del_disk = The disk to remove if specified. If the value given + * is NULL then no disk is removed. +*/ +static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk) { + int ctlr = h->ctlr; + int num_luns; + ReportLunData_struct *ld_buff = NULL; + drive_info_struct *drv = NULL; + int return_code; + int listlength = 0; + int i; + int drv_found; + int drv_index = 0; + __u32 lunid = 0; unsigned long flags; + + /* Set busy_configuring flag for this operation */ + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); + if (h->num_luns >= CISS_MAX_LUN){ + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + return -EINVAL; + } + + if (h->busy_configuring){ + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + return -EBUSY; + } + h->busy_configuring = 1; + + /* if del_disk is NULL then we are being called to add a new disk + * and update the logical drive table. If it is not NULL then + * we will check if the disk is in use or not. + */ + if (del_disk != NULL){ + drv = get_drv(del_disk); + drv->busy_configuring = 1; + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + return_code = deregister_disk(del_disk, drv, 1); + drv->busy_configuring = 0; + h->busy_configuring = 0; + return return_code; + } else { + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + if (!capable(CAP_SYS_RAWIO)) + return -EPERM; + + ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL); + if (ld_buff == NULL) + goto mem_msg; + + return_code = sendcmd_withirq(CISS_REPORT_LOG, ctlr, ld_buff, + sizeof(ReportLunData_struct), 0, 0, 0, + TYPE_CMD); + + if (return_code == IO_OK){ + listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[0])) << 24; + listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[1])) << 16; + listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[2])) << 8; + listlength |= 0xff & (unsigned int)(ld_buff->LUNListLength[3]); + } else{ /* reading number of logical volumes failed */ + printk(KERN_WARNING "cciss: report logical volume" + " command failed\n"); + listlength = 0; + goto freeret; + } + + num_luns = listlength / 8; /* 8 bytes per entry */ + if (num_luns > CISS_MAX_LUN){ + num_luns = CISS_MAX_LUN; + printk(KERN_WARNING "cciss: more luns configured" + " on controller than can be handled by" + " this driver.\n"); + } + + /* Compare controller drive array to drivers drive array. + * Check for updates in the drive information and any new drives + * on the controller. + */ + for (i=0; i < num_luns; i++){ + int j; + + drv_found = 0; + + lunid = (0xff & + (unsigned int)(ld_buff->LUN[i][3])) << 24; + lunid |= (0xff & + (unsigned int)(ld_buff->LUN[i][2])) << 16; + lunid |= (0xff & + (unsigned int)(ld_buff->LUN[i][1])) << 8; + lunid |= 0xff & + (unsigned int)(ld_buff->LUN[i][0]); + + /* Find if the LUN is already in the drive array + * of the controller. If so then update its info + * if not is use. If it does not exist then find + * the first free index and add it. + */ + for (j=0; j <= h->highest_lun; j++){ + if (h->drv[j].LunID == lunid){ + drv_index = j; + drv_found = 1; + } + } + + /* check if the drive was found already in the array */ + if (!drv_found){ + drv_index = cciss_find_free_drive_index(ctlr); + if (drv_index == -1) + goto freeret; + + } + h->drv[drv_index].LunID = lunid; + cciss_update_drive_info(ctlr, drv_index); + } /* end for */ + } /* end else */ + +freeret: + kfree(ld_buff); + h->busy_configuring = 0; + /* We return -1 here to tell the ACU that we have registered/updated + * all of the drives that we can and to keep it from calling us + * additional times. + */ + return -1; +mem_msg: + printk(KERN_ERR "cciss: out of memory\n"); + goto freeret; +} + +/* This function will deregister the disk and it's queue from the + * kernel. It must be called with the controller lock held and the + * drv structures busy_configuring flag set. It's parameters are: + * + * disk = This is the disk to be deregistered + * drv = This is the drive_info_struct associated with the disk to be + * deregistered. It contains information about the disk used + * by the driver. + * clear_all = This flag determines whether or not the disk information + * is going to be completely cleared out and the highest_lun + * reset. Sometimes we want to clear out information about + * the disk in preperation for re-adding it. In this case + * the highest_lun should be left unchanged and the LunID + * should not be cleared. +*/ +static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, + int clear_all) +{ ctlr_info_t *h = get_host(disk); - drive_info_struct *drv = get_drv(disk); - int ctlr = h->ctlr; if (!capable(CAP_SYS_RAWIO)) return -EPERM; - spin_lock_irqsave(CCISS_LOCK(ctlr), flags); /* make sure logical volume is NOT is use */ - if( drv->usage_count > 1) { - spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + if(clear_all || (h->gendisk[0] == disk)) { + if (drv->usage_count > 1) return -EBUSY; } - drv->usage_count++; - spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + else + if( drv->usage_count > 0 ) + return -EBUSY; - /* invalidate the devices and deregister the disk */ - if (disk->flags & GENHD_FL_UP) + /* invalidate the devices and deregister the disk. If it is disk + * zero do not deregister it but just zero out it's values. This + * allows us to delete disk zero but keep the controller registered. + */ + if (h->gendisk[0] != disk){ + if (disk->flags & GENHD_FL_UP){ + blk_cleanup_queue(disk->queue); del_gendisk(disk); + drv->queue = NULL; + } + } + + --h->num_luns; + /* zero out the disk size info */ + drv->nr_blocks = 0; + drv->block_size = 0; + drv->heads = 0; + drv->sectors = 0; + drv->cylinders = 0; + drv->raid_level = -1; /* This can be used as a flag variable to + * indicate that this element of the drive + * array is free. + */ + + if (clear_all){ /* check to see if it was the last disk */ if (drv == h->drv + h->highest_lun) { /* if so, find the new hightest lun */ int i, newhighest =-1; for(i=0; ihighest_lun; i++) { /* if the disk has size > 0, it is available */ - if (h->drv[i].nr_blocks) + if (h->drv[i].heads) newhighest = i; } h->highest_lun = newhighest; - } - --h->num_luns; - /* zero out the disk size info */ - drv->nr_blocks = 0; - drv->block_size = 0; - drv->cylinders = 0; + drv->LunID = 0; + } return(0); } + static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_t size, unsigned int use_unit_num, /* 0: address the controller, @@ -1513,164 +1799,6 @@ cciss_read_capacity(int ctlr, int logvol, ReadCapdata_struct *buf, return; } -static int register_new_disk(ctlr_info_t *h) -{ - struct gendisk *disk; - int ctlr = h->ctlr; - int i; - int num_luns; - int logvol; - int new_lun_found = 0; - int new_lun_index = 0; - int free_index_found = 0; - int free_index = 0; - ReportLunData_struct *ld_buff = NULL; - ReadCapdata_struct *size_buff = NULL; - InquiryData_struct *inq_buff = NULL; - int return_code; - int listlength = 0; - __u32 lunid = 0; - unsigned int block_size; - unsigned int total_size; - - if (!capable(CAP_SYS_RAWIO)) - return -EPERM; - /* if we have no space in our disk array left to add anything */ - if( h->num_luns >= CISS_MAX_LUN) - return -EINVAL; - - ld_buff = kmalloc(sizeof(ReportLunData_struct), GFP_KERNEL); - if (ld_buff == NULL) - goto mem_msg; - memset(ld_buff, 0, sizeof(ReportLunData_struct)); - size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL); - if (size_buff == NULL) - goto mem_msg; - inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL); - if (inq_buff == NULL) - goto mem_msg; - - return_code = sendcmd_withirq(CISS_REPORT_LOG, ctlr, ld_buff, - sizeof(ReportLunData_struct), 0, 0, 0, TYPE_CMD); - - if( return_code == IO_OK) - { - - // printk("LUN Data\n--------------------------\n"); - - listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[0])) << 24; - listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[1])) << 16; - listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[2])) << 8; - listlength |= 0xff & (unsigned int)(ld_buff->LUNListLength[3]); - } else /* reading number of logical volumes failed */ - { - printk(KERN_WARNING "cciss: report logical volume" - " command failed\n"); - listlength = 0; - goto free_err; - } - num_luns = listlength / 8; // 8 bytes pre entry - if (num_luns > CISS_MAX_LUN) - { - num_luns = CISS_MAX_LUN; - } -#ifdef CCISS_DEBUG - printk(KERN_DEBUG "Length = %x %x %x %x = %d\n", ld_buff->LUNListLength[0], - ld_buff->LUNListLength[1], ld_buff->LUNListLength[2], - ld_buff->LUNListLength[3], num_luns); -#endif - for(i=0; i< num_luns; i++) - { - int j; - int lunID_found = 0; - - lunid = (0xff & (unsigned int)(ld_buff->LUN[i][3])) << 24; - lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][2])) << 16; - lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][1])) << 8; - lunid |= 0xff & (unsigned int)(ld_buff->LUN[i][0]); - - /* check to see if this is a new lun */ - for(j=0; j <= h->highest_lun; j++) - { -#ifdef CCISS_DEBUG - printk("Checking %d %x against %x\n", j,h->drv[j].LunID, - lunid); -#endif /* CCISS_DEBUG */ - if (h->drv[j].LunID == lunid) - { - lunID_found = 1; - break; - } - - } - if( lunID_found == 1) - continue; - else - { /* It is the new lun we have been looking for */ -#ifdef CCISS_DEBUG - printk("new lun found at %d\n", i); -#endif /* CCISS_DEBUG */ - new_lun_index = i; - new_lun_found = 1; - break; - } - } - if (!new_lun_found) - { - printk(KERN_WARNING "cciss: New Logical Volume not found\n"); - goto free_err; - } - /* Now find the free index */ - for(i=0; i drv[i].LunID == 0) - { -#ifdef CCISS_DEBUG - printk("free index found at %d\n", i); -#endif /* CCISS_DEBUG */ - free_index_found = 1; - free_index = i; - break; - } - } - if (!free_index_found) - { - printk(KERN_WARNING "cciss: unable to find free slot for disk\n"); - goto free_err; - } - - logvol = free_index; - h->drv[logvol].LunID = lunid; - /* there could be gaps in lun numbers, track hightest */ - if(h->highest_lun < lunid) - h->highest_lun = logvol; - cciss_read_capacity(ctlr, logvol, size_buff, 1, - &total_size, &block_size); - cciss_geometry_inquiry(ctlr, logvol, 1, total_size, block_size, - inq_buff, &h->drv[logvol]); - h->drv[logvol].usage_count = 0; - ++h->num_luns; - /* setup partitions per disk */ - disk = h->gendisk[logvol]; - set_capacity(disk, h->drv[logvol].nr_blocks); - /* if it's the controller it's already added */ - if(logvol) - add_disk(disk); -freeret: - kfree(ld_buff); - kfree(size_buff); - kfree(inq_buff); - return (logvol); -mem_msg: - printk(KERN_ERR "cciss: out of memory\n"); -free_err: - logvol = -1; - goto freeret; -} - static int cciss_revalidate(struct gendisk *disk) { ctlr_info_t *h = get_host(disk); @@ -2652,12 +2780,16 @@ static void cciss_getgeometry(int cntl_num) #endif /* CCISS_DEBUG */ hba[cntl_num]->highest_lun = hba[cntl_num]->num_luns-1; - for(i=0; i< hba[cntl_num]->num_luns; i++) +// for(i=0; i< hba[cntl_num]->num_luns; i++) + for(i=0; i < CISS_MAX_LUN; i++) { - - lunid = (0xff & (unsigned int)(ld_buff->LUN[i][3])) << 24; - lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][2])) << 16; - lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][1])) << 8; + if (i < hba[cntl_num]->num_luns){ + lunid = (0xff & (unsigned int)(ld_buff->LUN[i][3])) + << 24; + lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][2])) + << 16; + lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][1])) + << 8; lunid |= 0xff & (unsigned int)(ld_buff->LUN[i][0]); hba[cntl_num]->drv[i].LunID = lunid; @@ -2665,13 +2797,18 @@ static void cciss_getgeometry(int cntl_num) #ifdef CCISS_DEBUG printk(KERN_DEBUG "LUN[%d]: %x %x %x %x = %x\n", i, - ld_buff->LUN[i][0], ld_buff->LUN[i][1],ld_buff->LUN[i][2], - ld_buff->LUN[i][3], hba[cntl_num]->drv[i].LunID); + ld_buff->LUN[i][0], ld_buff->LUN[i][1], + ld_buff->LUN[i][2], ld_buff->LUN[i][3], + hba[cntl_num]->drv[i].LunID); #endif /* CCISS_DEBUG */ cciss_read_capacity(cntl_num, i, size_buff, 0, &total_size, &block_size); - cciss_geometry_inquiry(cntl_num, i, 0, total_size, block_size, - inq_buff, &hba[cntl_num]->drv[i]); + cciss_geometry_inquiry(cntl_num, i, 0, total_size, + block_size, inq_buff, &hba[cntl_num]->drv[i]); + } else { + /* initialize raid_level to indicate a free space */ + hba[cntl_num]->drv[i].raid_level = -1; + } } kfree(ld_buff); kfree(size_buff); diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h index 11ee83504b3..dec27a96112 100644 --- a/drivers/block/cciss.h +++ b/drivers/block/cciss.h @@ -35,7 +35,13 @@ typedef struct _drive_info_struct int heads; int sectors; int cylinders; - int raid_level; + int raid_level; /* set to -1 to indicate that + * the drive is not in use/configured + */ + int busy_configuring; /*This is set when the drive is being removed + *to prevent it from being opened or it's queue + *from being started. + */ } drive_info_struct; struct ctlr_info -- cgit v1.2.3 From 33079b21978f478865068ee6a3c5807b6c6ecdbe Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 13 Sep 2005 01:25:22 -0700 Subject: [PATCH] cciss: direct lookup for command completions This patch changes the way we complete commands. In the old method when we got a completion we searched our command list from the top until we find it. This method uses a tag associated with each command (not SCSI command tagging) to index us directly to the completed command. This helps performance. Signed-off-by: Don Brace Signed-off-by: Mike Miller Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/cciss.c | 70 ++++++++++++++++++++++++++++++++++++++++++---- drivers/block/cciss.h | 1 + drivers/block/cciss_cmd.h | 8 ++++-- drivers/block/cciss_scsi.c | 1 + 4 files changed, 73 insertions(+), 7 deletions(-) diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 3c6a6a21d54..a12b95eef18 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -174,6 +174,8 @@ static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, unsigned int use_unit_num, unsigned int log_unit, __u8 page_code, int cmd_type); +static void fail_all_cmds(unsigned long ctlr); + #ifdef CONFIG_PROC_FS static int cciss_proc_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data); @@ -387,6 +389,8 @@ static CommandList_struct * cmd_alloc(ctlr_info_t *h, int get_from_pool) return NULL; memset(c, 0, sizeof(CommandList_struct)); + c->cmdindex = -1; + c->err_info = (ErrorInfo_struct *)pci_alloc_consistent( h->pdev, sizeof(ErrorInfo_struct), &err_dma_handle); @@ -417,6 +421,8 @@ static CommandList_struct * cmd_alloc(ctlr_info_t *h, int get_from_pool) err_dma_handle = h->errinfo_pool_dhandle + i*sizeof(ErrorInfo_struct); h->nr_allocs++; + + c->cmdindex = i; } c->busaddr = (__u32) cmd_dma_handle; @@ -2257,7 +2263,11 @@ queue: /* fill in the request */ drv = creq->rq_disk->private_data; c->Header.ReplyQueue = 0; // unused in simple mode - c->Header.Tag.lower = c->busaddr; // use the physical address the cmd block for tag + /* got command from pool, so use the command block index instead */ + /* for direct lookups. */ + /* The first 2 bits are reserved for controller error reporting. */ + c->Header.Tag.lower = (c->cmdindex << 3); + c->Header.Tag.lower |= 0x04; /* flag for direct lookup. */ c->Header.LUN.LogDev.VolId= drv->LunID; c->Header.LUN.LogDev.Mode = 1; c->Request.CDBLen = 10; // 12 byte commands not in FW yet; @@ -2332,7 +2342,7 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs) ctlr_info_t *h = dev_id; CommandList_struct *c; unsigned long flags; - __u32 a, a1; + __u32 a, a1, a2; int j; int start_queue = h->next_to_run; @@ -2350,10 +2360,21 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs) while((a = h->access.command_completed(h)) != FIFO_EMPTY) { a1 = a; + if ((a & 0x04)) { + a2 = (a >> 3); + if (a2 >= NR_CMDS) { + printk(KERN_WARNING "cciss: controller cciss%d failed, stopping.\n", h->ctlr); + fail_all_cmds(h->ctlr); + return IRQ_HANDLED; + } + + c = h->cmd_pool + a2; + a = c->busaddr; + + } else { a &= ~3; - if ((c = h->cmpQ) == NULL) - { - printk(KERN_WARNING "cciss: Completion of %08lx ignored\n", (unsigned long)a1); + if ((c = h->cmpQ) == NULL) { + printk(KERN_WARNING "cciss: Completion of %08x ignored\n", a1); continue; } while(c->busaddr != a) { @@ -2361,6 +2382,7 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs) if (c == h->cmpQ) break; } + } /* * If we've found the command, take it off the * completion Q and free it @@ -3124,5 +3146,43 @@ static void __exit cciss_cleanup(void) remove_proc_entry("cciss", proc_root_driver); } +static void fail_all_cmds(unsigned long ctlr) +{ + /* If we get here, the board is apparently dead. */ + ctlr_info_t *h = hba[ctlr]; + CommandList_struct *c; + unsigned long flags; + + printk(KERN_WARNING "cciss%d: controller not responding.\n", h->ctlr); + h->alive = 0; /* the controller apparently died... */ + + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); + + pci_disable_device(h->pdev); /* Make sure it is really dead. */ + + /* move everything off the request queue onto the completed queue */ + while( (c = h->reqQ) != NULL ) { + removeQ(&(h->reqQ), c); + h->Qdepth--; + addQ (&(h->cmpQ), c); + } + + /* Now, fail everything on the completed queue with a HW error */ + while( (c = h->cmpQ) != NULL ) { + removeQ(&h->cmpQ, c); + c->err_info->CommandStatus = CMD_HARDWARE_ERR; + if (c->cmd_type == CMD_RWREQ) { + complete_command(h, c, 0); + } else if (c->cmd_type == CMD_IOCTL_PEND) + complete(c->waiting); +#ifdef CONFIG_CISS_SCSI_TAPE + else if (c->cmd_type == CMD_SCSI) + complete_scsi_command(c, 0, 0); +#endif + } + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); + return; +} + module_init(cciss_init); module_exit(cciss_cleanup); diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h index dec27a96112..ef277baee9f 100644 --- a/drivers/block/cciss.h +++ b/drivers/block/cciss.h @@ -101,6 +101,7 @@ struct ctlr_info #ifdef CONFIG_CISS_SCSI_TAPE void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ #endif + unsigned char alive; }; /* Defining the diffent access_menthods */ diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h index a88a8881762..53fea549ba8 100644 --- a/drivers/block/cciss_cmd.h +++ b/drivers/block/cciss_cmd.h @@ -226,6 +226,10 @@ typedef struct _ErrorInfo_struct { #define CMD_MSG_DONE 0x04 #define CMD_MSG_TIMEOUT 0x05 +/* This structure needs to be divisible by 8 for new + * indexing method. + */ +#define PADSIZE (sizeof(long) - 4) typedef struct _CommandList_struct { CommandListHeader_struct Header; RequestBlock_struct Request; @@ -236,14 +240,14 @@ typedef struct _CommandList_struct { ErrorInfo_struct * err_info; /* pointer to the allocated mem */ int ctlr; int cmd_type; + long cmdindex; struct _CommandList_struct *prev; struct _CommandList_struct *next; struct request * rq; struct completion *waiting; int retry_count; -#ifdef CONFIG_CISS_SCSI_TAPE void * scsi_cmd; -#endif + char pad[PADSIZE]; } CommandList_struct; //Configuration Table Structure diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index f16e3caed58..df4afacc75d 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -93,6 +93,7 @@ struct cciss_scsi_cmd_stack_elem_t { CommandList_struct cmd; ErrorInfo_struct Err; __u32 busaddr; + __u32 pad; }; #pragma pack() -- cgit v1.2.3 From 6a445d3ba6b90ce13a843ad5d1a0867388b08096 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 13 Sep 2005 01:25:23 -0700 Subject: [PATCH] cciss: bug fix in cciss_remove_one This patch fixes a bug in cciss_remove_one. A set of braces was missing for the if statement causing an Oops on driver unload. Signed-off-by: Mike Miller Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/cciss.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index a12b95eef18..49f05410a11 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -3095,9 +3095,10 @@ static void __devexit cciss_remove_one (struct pci_dev *pdev) /* remove it from the disk list */ for (j = 0; j < NWD; j++) { struct gendisk *disk = hba[i]->gendisk[j]; - if (disk->flags & GENHD_FL_UP) - blk_cleanup_queue(disk->queue); + if (disk->flags & GENHD_FL_UP) { del_gendisk(disk); + blk_cleanup_queue(disk->queue); + } } pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), -- cgit v1.2.3 From bb2a37bf4131d64b76dcdb126e3ff5bf371b1842 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 13 Sep 2005 01:25:24 -0700 Subject: [PATCH] cciss: fix for DMA brokeness The CCISS driver seems to loose track of DMA mappings created by it's fill_cmd() routine. Neither callers of this routine are extracting the DMA address created in order to do the unmap. Instead, they simply try to unmap 0x0. It's easy to see this problem on an x86_64 system when using the "swiotlb=force" boot option. In this case, the driver is leaking resources of the swiotlb and not causing a sync of the bounce buffer. Signed-off-by: Alex Williamson Signed-off-by: Mike Miller Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/cciss.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 49f05410a11..c56f995aada 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -1730,8 +1730,10 @@ case CMD_HARDWARE_ERR: } } /* unlock the buffers from DMA */ + buff_dma_handle.val32.lower = c->SG[0].Addr.lower; + buff_dma_handle.val32.upper = c->SG[0].Addr.upper; pci_unmap_single( h->pdev, (dma_addr_t) buff_dma_handle.val, - size, PCI_DMA_BIDIRECTIONAL); + c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); cmd_free(h, c, 0); return(return_status); @@ -2011,8 +2013,10 @@ resend_cmd1: cleanup1: /* unlock the data buffer from DMA */ + buff_dma_handle.val32.lower = c->SG[0].Addr.lower; + buff_dma_handle.val32.upper = c->SG[0].Addr.upper; pci_unmap_single(info_p->pdev, (dma_addr_t) buff_dma_handle.val, - size, PCI_DMA_BIDIRECTIONAL); + c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); cmd_free(info_p, c, 1); return (status); } -- cgit v1.2.3 From 47922d068e90ed34c1336cdd39912d51e190f8a5 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 13 Sep 2005 01:25:25 -0700 Subject: [PATCH] cciss: One Button Disaster Recovery support This patch adds support for "One Button Disaster Recovery" devices to the cciss driver. (OBDR devices are tape drives which can pretend to be cd-rom devices temporarily. Once booted the device can be reverted to a tape drive and data recovery operations can be automatically begun.) This is an enhancement request by a vendor/partner working on One Button Disaster Recovery. Signed-off-by: Stephen M. Cameron Signed-off-by: Mike Miller Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/cciss_scsi.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index df4afacc75d..efc0bea7693 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -878,7 +878,7 @@ cciss_scsi_interpret_error(CommandList_struct *cp) static int cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr, - InquiryData_struct *buf) + unsigned char *buf, unsigned char bufsize) { int rc; CommandList_struct *cp; @@ -901,11 +901,10 @@ cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr, cdb[1] = 0; cdb[2] = 0; cdb[3] = 0; - cdb[4] = sizeof(*buf) & 0xff; + cdb[4] = bufsize; cdb[5] = 0; rc = cciss_scsi_do_simple_cmd(c, cp, scsi3addr, cdb, - 6, (unsigned char *) buf, - sizeof(*buf), XFER_READ); + 6, buf, bufsize, XFER_READ); if (rc != 0) return rc; /* something went wrong */ @@ -1001,9 +1000,10 @@ cciss_update_non_disk_devices(int cntl_num, int hostno) that though. */ - +#define OBDR_TAPE_INQ_SIZE 49 +#define OBDR_TAPE_SIG "$DR-10" ReportLunData_struct *ld_buff; - InquiryData_struct *inq_buff; + unsigned char *inq_buff; unsigned char scsi3addr[8]; ctlr_info_t *c; __u32 num_luns=0; @@ -1021,7 +1021,7 @@ cciss_update_non_disk_devices(int cntl_num, int hostno) return; } memset(ld_buff, 0, reportlunsize); - inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL); + inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL); if (inq_buff == NULL) { printk(KERN_ERR "cciss: out of memory\n"); kfree(ld_buff); @@ -1052,19 +1052,36 @@ cciss_update_non_disk_devices(int cntl_num, int hostno) /* for each physical lun, do an inquiry */ if (ld_buff->LUN[i][3] & 0xC0) continue; - memset(inq_buff, 0, sizeof(InquiryData_struct)); + memset(inq_buff, 0, OBDR_TAPE_INQ_SIZE); memcpy(&scsi3addr[0], &ld_buff->LUN[i][0], 8); - if (cciss_scsi_do_inquiry(hba[cntl_num], - scsi3addr, inq_buff) != 0) - { + if (cciss_scsi_do_inquiry(hba[cntl_num], scsi3addr, inq_buff, + (unsigned char) OBDR_TAPE_INQ_SIZE) != 0) { /* Inquiry failed (msg printed already) */ devtype = 0; /* so we will skip this device. */ } else /* what kind of device is this? */ - devtype = (inq_buff->data_byte[0] & 0x1f); + devtype = (inq_buff[0] & 0x1f); switch (devtype) { + case 0x05: /* CD-ROM */ { + + /* We don't *really* support actual CD-ROM devices, + * just this "One Button Disaster Recovery" tape drive + * which temporarily pretends to be a CD-ROM drive. + * So we check that the device is really an OBDR tape + * device by checking for "$DR-10" in bytes 43-48 of + * the inquiry data. + */ + char obdr_sig[7]; + + strncpy(obdr_sig, &inq_buff[43], 6); + obdr_sig[6] = '\0'; + if (strncmp(obdr_sig, OBDR_TAPE_SIG, 6) != 0) + /* Not OBDR device, ignore it. */ + break; + } + /* fall through . . . */ case 0x01: /* sequential access, (tape) */ case 0x08: /* medium changer */ if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) { -- cgit v1.2.3 From b9f0bd0895c040f69a0440286b64725f74f5b387 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 13 Sep 2005 01:25:26 -0700 Subject: [PATCH] cciss: SCSI tape info for /proc Add SCSI host and device info not elsewhere available to /proc/scsi/cciss/* Namely, connect cciss device instance with scsi host number, and give scsi host number, bus, target, lun, devicetype, and 8-byte cciss LUNID for each tapedrive/medium changer attached to a controller For instance: # cat /proc/scsi/cciss/2 cciss0: SCSI host: 2 c2b0t0l0 01 0x0000000000000001 Signed-off-by: Stephen M. Cameron Signed-off-by: Mike Miller Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/cciss_scsi.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index efc0bea7693..e183a3ef783 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -1144,6 +1144,7 @@ cciss_scsi_proc_info(struct Scsi_Host *sh, int buflen, datalen; ctlr_info_t *ci; + int i; int cntl_num; @@ -1154,8 +1155,28 @@ cciss_scsi_proc_info(struct Scsi_Host *sh, cntl_num = ci->ctlr; /* Get our index into the hba[] array */ if (func == 0) { /* User is reading from /proc/scsi/ciss*?/?* */ - buflen = sprintf(buffer, "hostnum=%d\n", sh->host_no); - + buflen = sprintf(buffer, "cciss%d: SCSI host: %d\n", + cntl_num, sh->host_no); + + /* this information is needed by apps to know which cciss + device corresponds to which scsi host number without + having to open a scsi target device node. The device + information is not a duplicate of /proc/scsi/scsi because + the two may be out of sync due to scsi hotplug, rather + this info is for an app to be able to use to know how to + get them back in sync. */ + + for (i=0;ihost_no, sd->bus, sd->target, sd->lun, + sd->devtype, + sd->scsi3addr[0], sd->scsi3addr[1], + sd->scsi3addr[2], sd->scsi3addr[3], + sd->scsi3addr[4], sd->scsi3addr[5], + sd->scsi3addr[6], sd->scsi3addr[7]); + } datalen = buflen - offset; if (datalen < 0) { /* they're reading past EOF. */ datalen = 0; @@ -1417,7 +1438,7 @@ cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len) CPQ_TAPE_LOCK(ctlr, flags); size = sprintf(buffer + *len, - " Sequential access devices: %d\n\n", + "Sequential access devices: %d\n\n", ccissscsi[ctlr].ndevices); CPQ_TAPE_UNLOCK(ctlr, flags); *pos += size; *len += size; -- cgit v1.2.3 From d0272e78eee4dc53c887fd132e9035daf037d423 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Tue, 13 Sep 2005 01:25:27 -0700 Subject: [PATCH] pktcdvd: fix bogus BUG_ON In the packet writing driver, if the drive reports a packet size larger than the driver can handle, bail out safely instead of triggering a BUG_ON. Signed-off-by: Peter Osterlund Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/pktcdvd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 7b838342f0a..58d01c82079 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -946,7 +946,6 @@ try_next_bio: pd->current_sector = zone + pd->settings.size; pkt->sector = zone; pkt->frames = pd->settings.size >> 2; - BUG_ON(pkt->frames > PACKET_MAX_SIZE); pkt->write_size = 0; /* @@ -1636,6 +1635,10 @@ static int pkt_probe_settings(struct pktcdvd_device *pd) printk("pktcdvd: detected zero packet size!\n"); pd->settings.size = 128; } + if (pd->settings.size > PACKET_MAX_SECTORS) { + printk("pktcdvd: packet size is too big\n"); + return -ENXIO; + } pd->settings.fp = ti.fp; pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1); -- cgit v1.2.3 From a676f8d092f2a3aff419cacae79c80c3b7f6c0f5 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Tue, 13 Sep 2005 01:25:27 -0700 Subject: [PATCH] pktcdvd: documentation update Update the "theory of operation" description. Signed-off-by: Peter Osterlund Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/pktcdvd.c | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 58d01c82079..aacf5cfccad 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -5,29 +5,41 @@ * May be copied or modified under the terms of the GNU General Public * License. See linux/COPYING for more information. * - * Packet writing layer for ATAPI and SCSI CD-R, CD-RW, DVD-R, and - * DVD-RW devices (aka an exercise in block layer masturbation) + * Packet writing layer for ATAPI and SCSI CD-RW, DVD+RW, DVD-RW and + * DVD-RAM devices. * + * Theory of operation: * - * TODO: (circa order of when I will fix it) - * - Only able to write on CD-RW media right now. - * - check host application code on media and set it in write page - * - interface for UDF <-> packet to negotiate a new location when a write - * fails. - * - handle OPC, especially for -RW media + * At the lowest level, there is the standard driver for the CD/DVD device, + * typically ide-cd.c or sr.c. This driver can handle read and write requests, + * but it doesn't know anything about the special restrictions that apply to + * packet writing. One restriction is that write requests must be aligned to + * packet boundaries on the physical media, and the size of a write request + * must be equal to the packet size. Another restriction is that a + * GPCMD_FLUSH_CACHE command has to be issued to the drive before a read + * command, if the previous command was a write. * - * Theory of operation: + * The purpose of the packet writing driver is to hide these restrictions from + * higher layers, such as file systems, and present a block device that can be + * randomly read and written using 2kB-sized blocks. + * + * The lowest layer in the packet writing driver is the packet I/O scheduler. + * Its data is defined by the struct packet_iosched and includes two bio + * queues with pending read and write requests. These queues are processed + * by the pkt_iosched_process_queue() function. The write requests in this + * queue are already properly aligned and sized. This layer is responsible for + * issuing the flush cache commands and scheduling the I/O in a good order. * - * We use a custom make_request_fn function that forwards reads directly to - * the underlying CD device. Write requests are either attached directly to - * a live packet_data object, or simply stored sequentially in a list for - * later processing by the kcdrwd kernel thread. This driver doesn't use - * any elevator functionally as defined by the elevator_s struct, but the - * underlying CD device uses a standard elevator. + * The next layer transforms unaligned write requests to aligned writes. This + * transformation requires reading missing pieces of data from the underlying + * block device, assembling the pieces to full packets and queuing them to the + * packet I/O scheduler. * - * This strategy makes it possible to do very late merging of IO requests. - * A new bio sent to pkt_make_request can be merged with a live packet_data - * object even if the object is in the data gathering state. + * At the top layer there is a custom make_request_fn function that forwards + * read requests directly to the iosched queue and puts write requests in the + * unaligned write queue. A kernel thread performs the necessary read + * gathering to convert the unaligned writes to aligned writes and then feeds + * them to the packet I/O scheduler. * *************************************************************************/ -- cgit v1.2.3 From 06e7ab53f4a1e8bbf66c3985968468949d74d006 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Tue, 13 Sep 2005 01:25:28 -0700 Subject: [PATCH] pktcdvd: more accurate I/O accounting In the /proc statistics, only count writes that upper layers have requested. Don't count additional writes created inside the packet driver to satisfy the requirement to only write full packets. Signed-off-by: Peter Osterlund Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/pktcdvd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index aacf5cfccad..109db859112 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -736,12 +736,6 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt) atomic_set(&pkt->io_wait, 0); atomic_set(&pkt->io_errors, 0); - if (pkt->cache_valid) { - VPRINTK("pkt_gather_data: zone %llx cached\n", - (unsigned long long)pkt->sector); - goto out_account; - } - /* * Figure out which frames we need to read before we can write. */ @@ -750,6 +744,7 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt) for (bio = pkt->orig_bios; bio; bio = bio->bi_next) { int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9); int num_frames = bio->bi_size / CD_FRAMESIZE; + pd->stats.secs_w += num_frames * (CD_FRAMESIZE >> 9); BUG_ON(first_frame < 0); BUG_ON(first_frame + num_frames > pkt->frames); for (f = first_frame; f < first_frame + num_frames; f++) @@ -757,6 +752,12 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt) } spin_unlock(&pkt->lock); + if (pkt->cache_valid) { + VPRINTK("pkt_gather_data: zone %llx cached\n", + (unsigned long long)pkt->sector); + goto out_account; + } + /* * Schedule reads for missing parts of the packet. */ @@ -790,7 +791,6 @@ out_account: frames_read, (unsigned long long)pkt->sector); pd->stats.pkt_started++; pd->stats.secs_rg += frames_read * (CD_FRAMESIZE >> 9); - pd->stats.secs_w += pd->settings.size; } /* -- cgit v1.2.3 From 1107d2e0352769b9bde6a4877c295b9309cdb877 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Tue, 13 Sep 2005 01:25:29 -0700 Subject: [PATCH] pktcdvd: use kcalloc and kzalloc Use kcalloc and kzalloc in pktcdvd. Signed-off-by: Peter Osterlund Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/pktcdvd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 109db859112..b443fe5eebe 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -112,10 +112,9 @@ static struct bio *pkt_bio_alloc(int nr_iovecs) goto no_bio; bio_init(bio); - bvl = kmalloc(nr_iovecs * sizeof(struct bio_vec), GFP_KERNEL); + bvl = kcalloc(nr_iovecs, sizeof(struct bio_vec), GFP_KERNEL); if (!bvl) goto no_bvl; - memset(bvl, 0, nr_iovecs * sizeof(struct bio_vec)); bio->bi_max_vecs = nr_iovecs; bio->bi_io_vec = bvl; @@ -137,10 +136,9 @@ static struct packet_data *pkt_alloc_packet_data(void) int i; struct packet_data *pkt; - pkt = kmalloc(sizeof(struct packet_data), GFP_KERNEL); + pkt = kzalloc(sizeof(struct packet_data), GFP_KERNEL); if (!pkt) goto no_pkt; - memset(pkt, 0, sizeof(struct packet_data)); pkt->w_bio = pkt_bio_alloc(PACKET_MAX_SIZE); if (!pkt->w_bio) @@ -2492,10 +2490,9 @@ static int pkt_setup_dev(struct pkt_ctrl_command *ctrl_cmd) return -EBUSY; } - pd = kmalloc(sizeof(struct pktcdvd_device), GFP_KERNEL); + pd = kzalloc(sizeof(struct pktcdvd_device), GFP_KERNEL); if (!pd) return ret; - memset(pd, 0, sizeof(struct pktcdvd_device)); pd->rb_pool = mempool_create(PKT_RB_POOL_SIZE, pkt_rb_alloc, pkt_rb_free, NULL); if (!pd->rb_pool) -- cgit v1.2.3 From 610827dee82731c7be5a135d750d194ac56881a9 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Tue, 13 Sep 2005 01:25:29 -0700 Subject: [PATCH] pktcdvd: BUG_ON cleanups Remove some redundant BUG_ON() statements in pktcdvd and move one run-time check to compile-time. Signed-off-by: Peter Osterlund Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/pktcdvd.c | 9 +++------ include/linux/pktcdvd.h | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index b443fe5eebe..7e22a58926b 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -669,7 +669,6 @@ static void pkt_make_local_copy(struct packet_data *pkt, struct page **pages, in } offs += CD_FRAMESIZE; if (offs >= PAGE_SIZE) { - BUG_ON(offs > PAGE_SIZE); offs = 0; p++; } @@ -804,10 +803,11 @@ static struct packet_data *pkt_get_packet_data(struct pktcdvd_device *pd, int zo list_del_init(&pkt->list); if (pkt->sector != zone) pkt->cache_valid = 0; - break; + return pkt; } } - return pkt; + BUG(); + return NULL; } static void pkt_put_packet_data(struct pktcdvd_device *pd, struct packet_data *pkt) @@ -951,7 +951,6 @@ try_next_bio: } pkt = pkt_get_packet_data(pd, zone); - BUG_ON(!pkt); pd->current_sector = zone + pd->settings.size; pkt->sector = zone; @@ -2211,7 +2210,6 @@ static int pkt_make_request(request_queue_t *q, struct bio *bio) * No matching packet found. Store the bio in the work queue. */ node = mempool_alloc(pd->rb_pool, GFP_NOIO); - BUG_ON(!node); node->bio = bio; spin_lock(&pd->lock); BUG_ON(pd->bio_queue_size < 0); @@ -2419,7 +2417,6 @@ static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode)); - BUG_ON(!pd); switch (cmd) { /* diff --git a/include/linux/pktcdvd.h b/include/linux/pktcdvd.h index 4b32bce9a28..2c177e4c8f2 100644 --- a/include/linux/pktcdvd.h +++ b/include/linux/pktcdvd.h @@ -166,6 +166,9 @@ struct packet_iosched /* * 32 buffers of 2048 bytes */ +#if (PAGE_SIZE % CD_FRAMESIZE) != 0 +#error "PAGE_SIZE must be a multiple of CD_FRAMESIZE" +#endif #define PACKET_MAX_SIZE 32 #define PAGES_PER_PACKET (PACKET_MAX_SIZE * CD_FRAMESIZE / PAGE_SIZE) #define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9) -- cgit v1.2.3 From 50a5de44821352354a3ee804e2c7cbfee5a81c06 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 13 Sep 2005 01:25:30 -0700 Subject: [PATCH] SharpSL: Abstract c7x0 specifics from Corgi SSP Sharp's newer range of Zaurus clamshell handhelds, the cxx00's are similar to the c7x0 series yet different. This patch series abstracts the differences and generates a set of common drivers that support both series of devices. It then adds machine support for Spitz (SL-C3000) and Borzoi (SL-C3100). Hooks for Akita (SL-C1000) differences are also added. The I2C driver for its IO expander is the only missing piece. This patch: Separate out the Sharp Zaurus c7x0 series specific code from corgi_ssp.c so that other models such as the cxx00's can share it. Create sharpsl.h which will be used to abstract machine/model specifics. This enables the driver to be used by the Zaurus cxx00 series. Signed-Off-by: Richard Purdie Cc: Vojtech Pavlik Cc: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/arm/mach-pxa/corgi.c | 13 ++++++++ arch/arm/mach-pxa/corgi_ssp.c | 66 ++++++++++++++++++++++---------------- arch/arm/mach-pxa/sharpsl.h | 15 +++++++++ include/asm-arm/arch-pxa/corgi.h | 12 ------- include/asm-arm/arch-pxa/sharpsl.h | 12 +++++++ 5 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 arch/arm/mach-pxa/sharpsl.h create mode 100644 include/asm-arm/arch-pxa/sharpsl.h diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c index 07b5dd45356..3678d1e0e82 100644 --- a/arch/arm/mach-pxa/corgi.c +++ b/arch/arm/mach-pxa/corgi.c @@ -41,6 +41,7 @@ #include #include "generic.h" +#include "sharpsl.h" /* @@ -94,6 +95,16 @@ struct platform_device corgissp_device = { .id = -1, }; +struct corgissp_machinfo corgi_ssp_machinfo = { + .port = 1, + .cs_lcdcon = CORGI_GPIO_LCDCON_CS, + .cs_ads7846 = CORGI_GPIO_ADS7846_CS, + .cs_max1111 = CORGI_GPIO_MAX1111_CS, + .clk_lcdcon = 76, + .clk_ads7846 = 2, + .clk_max1111 = 8, +}; + /* * Corgi Backlight Device @@ -225,6 +236,8 @@ static struct platform_device *devices[] __initdata = { static void __init corgi_init(void) { + corgi_ssp_set_machinfo(&corgi_ssp_machinfo); + pxa_gpio_mode(CORGI_GPIO_USB_PULLUP | GPIO_OUT); pxa_set_udc_info(&udc_info); pxa_set_mci_info(&corgi_mci_platform_data); diff --git a/arch/arm/mach-pxa/corgi_ssp.c b/arch/arm/mach-pxa/corgi_ssp.c index 366a9bde3d8..0ef42828705 100644 --- a/arch/arm/mach-pxa/corgi_ssp.c +++ b/arch/arm/mach-pxa/corgi_ssp.c @@ -1,7 +1,7 @@ /* * SSP control code for Sharp Corgi devices * - * Copyright (c) 2004 Richard Purdie + * Copyright (c) 2004-2005 Richard Purdie * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -17,14 +17,16 @@ #include #include #include +#include #include -#include #include +#include "sharpsl.h" static DEFINE_SPINLOCK(corgi_ssp_lock); static struct ssp_dev corgi_ssp_dev; static struct ssp_state corgi_ssp_state; +static struct corgissp_machinfo *ssp_machinfo; /* * There are three devices connected to the SSP interface: @@ -48,12 +50,12 @@ unsigned long corgi_ssp_ads7846_putget(ulong data) unsigned long ret,flag; spin_lock_irqsave(&corgi_ssp_lock, flag); - GPCR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); + GPCR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); ssp_write_word(&corgi_ssp_dev,data); ret = ssp_read_word(&corgi_ssp_dev); - GPSR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); + GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); spin_unlock_irqrestore(&corgi_ssp_lock, flag); return ret; @@ -66,12 +68,12 @@ unsigned long corgi_ssp_ads7846_putget(ulong data) void corgi_ssp_ads7846_lock(void) { spin_lock(&corgi_ssp_lock); - GPCR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); + GPCR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); } void corgi_ssp_ads7846_unlock(void) { - GPSR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); + GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); spin_unlock(&corgi_ssp_lock); } @@ -97,23 +99,27 @@ EXPORT_SYMBOL(corgi_ssp_ads7846_get); */ unsigned long corgi_ssp_dac_put(ulong data) { - unsigned long flag; + unsigned long flag, sscr1 = SSCR1_SPH; spin_lock_irqsave(&corgi_ssp_lock, flag); - GPCR0 = GPIO_bit(CORGI_GPIO_LCDCON_CS); + + if (machine_is_spitz() || machine_is_akita() || machine_is_borzoi()) + sscr1 = 0; ssp_disable(&corgi_ssp_dev); - ssp_config(&corgi_ssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), SSCR1_SPH, 0, SSCR0_SerClkDiv(76)); + ssp_config(&corgi_ssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), sscr1, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_lcdcon)); ssp_enable(&corgi_ssp_dev); + GPCR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon); ssp_write_word(&corgi_ssp_dev,data); /* Read null data back from device to prevent SSP overflow */ ssp_read_word(&corgi_ssp_dev); + GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon); ssp_disable(&corgi_ssp_dev); - ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(2)); + ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_ads7846)); ssp_enable(&corgi_ssp_dev); - GPSR0 = GPIO_bit(CORGI_GPIO_LCDCON_CS); + spin_unlock_irqrestore(&corgi_ssp_lock, flag); return 0; @@ -141,9 +147,9 @@ int corgi_ssp_max1111_get(ulong data) int voltage,voltage1,voltage2; spin_lock_irqsave(&corgi_ssp_lock, flag); - GPCR0 = GPIO_bit(CORGI_GPIO_MAX1111_CS); + GPCR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111); ssp_disable(&corgi_ssp_dev); - ssp_config(&corgi_ssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), 0, 0, SSCR0_SerClkDiv(8)); + ssp_config(&corgi_ssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_max1111)); ssp_enable(&corgi_ssp_dev); udelay(1); @@ -161,9 +167,9 @@ int corgi_ssp_max1111_get(ulong data) voltage2=ssp_read_word(&corgi_ssp_dev); ssp_disable(&corgi_ssp_dev); - ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(2)); + ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_ads7846)); ssp_enable(&corgi_ssp_dev); - GPSR0 = GPIO_bit(CORGI_GPIO_MAX1111_CS); + GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111); spin_unlock_irqrestore(&corgi_ssp_lock, flag); if (voltage1 & 0xc0 || voltage2 & 0x3f) @@ -179,25 +185,31 @@ EXPORT_SYMBOL(corgi_ssp_max1111_get); /* * Support Routines */ -int __init corgi_ssp_probe(struct device *dev) + +void __init corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo) +{ + ssp_machinfo = machinfo; +} + +static int __init corgi_ssp_probe(struct device *dev) { int ret; /* Chip Select - Disable All */ - GPDR0 |= GPIO_bit(CORGI_GPIO_LCDCON_CS); /* output */ - GPSR0 = GPIO_bit(CORGI_GPIO_LCDCON_CS); /* High - Disable LCD Control/Timing Gen */ - GPDR0 |= GPIO_bit(CORGI_GPIO_MAX1111_CS); /* output */ - GPSR0 = GPIO_bit(CORGI_GPIO_MAX1111_CS); /* High - Disable MAX1111*/ - GPDR0 |= GPIO_bit(CORGI_GPIO_ADS7846_CS); /* output */ - GPSR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); /* High - Disable ADS7846*/ + GPDR(ssp_machinfo->cs_lcdcon) |= GPIO_bit(ssp_machinfo->cs_lcdcon); /* output */ + GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon); /* High - Disable LCD Control/Timing Gen */ + GPDR(ssp_machinfo->cs_max1111) |= GPIO_bit(ssp_machinfo->cs_max1111); /* output */ + GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111); /* High - Disable MAX1111*/ + GPDR(ssp_machinfo->cs_ads7846) |= GPIO_bit(ssp_machinfo->cs_ads7846); /* output */ + GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); /* High - Disable ADS7846*/ - ret=ssp_init(&corgi_ssp_dev,1); + ret = ssp_init(&corgi_ssp_dev,ssp_machinfo->port); if (ret) printk(KERN_ERR "Unable to register SSP handler!\n"); else { ssp_disable(&corgi_ssp_dev); - ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(2)); + ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_ads7846)); ssp_enable(&corgi_ssp_dev); } @@ -222,9 +234,9 @@ static int corgi_ssp_suspend(struct device *dev, pm_message_t state, u32 level) static int corgi_ssp_resume(struct device *dev, u32 level) { if (level == RESUME_POWER_ON) { - GPSR0 = GPIO_bit(CORGI_GPIO_LCDCON_CS); /* High - Disable LCD Control/Timing Gen */ - GPSR0 = GPIO_bit(CORGI_GPIO_MAX1111_CS); /* High - Disable MAX1111*/ - GPSR0 = GPIO_bit(CORGI_GPIO_ADS7846_CS); /* High - Disable ADS7846*/ + GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon); /* High - Disable LCD Control/Timing Gen */ + GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111); /* High - Disable MAX1111*/ + GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); /* High - Disable ADS7846*/ ssp_restore_state(&corgi_ssp_dev,&corgi_ssp_state); ssp_enable(&corgi_ssp_dev); } diff --git a/arch/arm/mach-pxa/sharpsl.h b/arch/arm/mach-pxa/sharpsl.h new file mode 100644 index 00000000000..672262ee9d2 --- /dev/null +++ b/arch/arm/mach-pxa/sharpsl.h @@ -0,0 +1,15 @@ +/* + * SharpSL SSP Driver + */ + +struct corgissp_machinfo { + int port; + int cs_lcdcon; + int cs_ads7846; + int cs_max1111; + int clk_lcdcon; + int clk_ads7846; + int clk_max1111; +}; + +void corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo); diff --git a/include/asm-arm/arch-pxa/corgi.h b/include/asm-arm/arch-pxa/corgi.h index 4b7aa0b8391..e554caa0d18 100644 --- a/include/asm-arm/arch-pxa/corgi.h +++ b/include/asm-arm/arch-pxa/corgi.h @@ -106,17 +106,5 @@ extern struct platform_device corgiscoop_device; extern struct platform_device corgissp_device; extern struct platform_device corgifb_device; -/* - * External Functions - */ -extern unsigned long corgi_ssp_ads7846_putget(unsigned long); -extern unsigned long corgi_ssp_ads7846_get(void); -extern void corgi_ssp_ads7846_put(unsigned long data); -extern void corgi_ssp_ads7846_lock(void); -extern void corgi_ssp_ads7846_unlock(void); -extern void corgi_ssp_lcdtg_send (unsigned char adrs, unsigned char data); -extern void corgi_ssp_blduty_set(int duty); -extern int corgi_ssp_max1111_get(unsigned long data); - #endif /* __ASM_ARCH_CORGI_H */ diff --git a/include/asm-arm/arch-pxa/sharpsl.h b/include/asm-arm/arch-pxa/sharpsl.h new file mode 100644 index 00000000000..5ce6d05631e --- /dev/null +++ b/include/asm-arm/arch-pxa/sharpsl.h @@ -0,0 +1,12 @@ +/* + * SharpSL SSP Driver + */ + +unsigned long corgi_ssp_ads7846_putget(unsigned long); +unsigned long corgi_ssp_ads7846_get(void); +void corgi_ssp_ads7846_put(unsigned long data); +void corgi_ssp_ads7846_lock(void); +void corgi_ssp_ads7846_unlock(void); +void corgi_ssp_lcdtg_send (unsigned char adrs, unsigned char data); +void corgi_ssp_blduty_set(int duty); +int corgi_ssp_max1111_get(unsigned long data); -- cgit v1.2.3 From 9fc7896b62b48714fafecf9266d9dc14c1cd6e33 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 13 Sep 2005 01:25:32 -0700 Subject: [PATCH] SharpSL: Add cxx00 support to the Corgi LCD driver The same LCD is present on both the Sharp Zaurus c7x0 series and the cxx00 but with different framebuffer drivers (w100fb vs. pxafb). This patch adds support for the cxx00 series to the LCD driver. It also adds some LCD to touchscreen interface logic needed by the touchscreen driver to prevent interference problems, the idea being to keep all the ugly code in one place leaving the drivers themselves clean. sharpsl.h is used to provide the abstraction. Signed-Off-by: Richard Purdie Cc: Vojtech Pavlik Cc: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/arm/mach-pxa/corgi_lcd.c | 132 +++++++++++++++++++++++++++++++++---- arch/arm/mach-pxa/sharpsl.h | 11 ++++ include/asm-arm/arch-pxa/sharpsl.h | 10 +++ 3 files changed, 139 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-pxa/corgi_lcd.c b/arch/arm/mach-pxa/corgi_lcd.c index deac29c0029..bfe5efc11b8 100644 --- a/arch/arm/mach-pxa/corgi_lcd.c +++ b/arch/arm/mach-pxa/corgi_lcd.c @@ -1,10 +1,14 @@ /* * linux/drivers/video/w100fb.c * - * Corgi LCD Specific Code for ATI Imageon w100 (Wallaby) + * Corgi/Spitz LCD Specific Code * * Copyright (C) 2005 Richard Purdie * + * Connectivity: + * Corgi - LCD to ATI Imageon w100 (Wallaby) + * Spitz - LCD to PXA Framebuffer + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. @@ -14,9 +18,17 @@ #include #include #include +#include +#include +#include #include +#include +#include +#include +#include +#include #include -#include