diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-05 18:16:23 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-05 18:16:23 -0700 |
commit | c6a677c6f37bb7abc85ba7e3465e82b9f7eb1d91 (patch) | |
tree | 9d0d4bb2e150837297cddc5be7f1b4950e9ab228 /drivers/staging/speakup/kobjects.c | |
parent | e87d51ac61f88ae44fe14b34abe08566032d726b (diff) | |
parent | 11270059e8d0b6f80801fac910c4ef751ca05c4c (diff) | |
download | op-kernel-dev-c6a677c6f37bb7abc85ba7e3465e82b9f7eb1d91.zip op-kernel-dev-c6a677c6f37bb7abc85ba7e3465e82b9f7eb1d91.tar.gz |
Merge tag 'staging-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging/IIO updates from Greg KH:
"Here is the big staging tree update for 4.12-rc1.
It's a big one, adding about 350k new lines of crap^Wcode, mostly all
in a big dump of media drivers from Intel. But there's other new
drivers in here as well, yet-another-wifi driver, new IIO drivers, and
a new crypto accelerator.
We also deleted a bunch of stuff, mostly in patch cleanups, but also
the Android ION code has shrunk a lot, and the Android low memory
killer driver was finally deleted, much to the celebration of the -mm
developers.
All of these have been in linux-next with a few build issues that will
show up when you merge to your tree"
Merge conflicts in the new rtl8723bs driver (due to the wifi changes
this merge window) handled as per linux-next, courtesy of Stephen
Rothwell.
* tag 'staging-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1182 commits)
staging: fsl-mc/dpio: add cpu <--> LE conversion for dpaa2_fd
staging: ks7010: remove line continuations in quoted strings
staging: vt6656: use tabs instead of spaces
staging: android: ion: Fix unnecessary initialization of static variable
staging: media: atomisp: fix range checking on clk_num
staging: media: atomisp: fix misspelled word in comment
staging: media: atomisp: kmap() can't fail
staging: atomisp: remove #ifdef for runtime PM functions
staging: atomisp: satm include directory is gone
atomisp: remove some more unused files
atomisp: remove hmm_load/store/clear indirections
atomisp: kill off mmgr_free
atomisp: clean up the hmm init/cleanup indirections
atomisp: handle allocation calls before init in the hmm layer
staging: fsl-dpaa2/eth: Add maintainer for Ethernet driver
staging: fsl-dpaa2/eth: Add TODO file
staging: fsl-dpaa2/eth: Add trace points
staging: fsl-dpaa2/eth: Add driver specific stats
staging: fsl-dpaa2/eth: Add ethtool support
staging: fsl-dpaa2/eth: Add Freescale DPAA2 Ethernet driver
...
Diffstat (limited to 'drivers/staging/speakup/kobjects.c')
-rw-r--r-- | drivers/staging/speakup/kobjects.c | 96 |
1 files changed, 50 insertions, 46 deletions
diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index 4e7ebc3..ca85476 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -26,7 +26,7 @@ * This is called when a user reads the characters or chartab sys file. */ static ssize_t chars_chartab_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) + struct kobj_attribute *attr, char *buf) { int i; int len = 0; @@ -79,7 +79,7 @@ static ssize_t chars_chartab_show(struct kobject *kobj, * character descriptions or chartab entries. */ static void report_char_chartab_status(int reset, int received, int used, - int rejected, int do_characters) + int rejected, int do_characters) { static char const *object_type[] = { "character class entries", @@ -92,8 +92,8 @@ static void report_char_chartab_status(int reset, int received, int used, pr_info("%s reset to defaults\n", object_type[do_characters]); } else if (received) { len = snprintf(buf, sizeof(buf), - " updated %d of %d %s\n", - used, received, object_type[do_characters]); + " updated %d of %d %s\n", + used, received, object_type[do_characters]); if (rejected) snprintf(buf + (len - 1), sizeof(buf) - (len - 1), " with %d reject%s\n", @@ -106,9 +106,10 @@ static void report_char_chartab_status(int reset, int received, int used, * This is called when a user changes the characters or chartab parameters. */ static ssize_t chars_chartab_store(struct kobject *kobj, - struct kobj_attribute *attr, const char *buf, size_t count) + struct kobj_attribute *attr, + const char *buf, size_t count) { - char *cp = (char *) buf; + char *cp = (char *)buf; char *end = cp + count; /* the null at the end of the buffer */ char *linefeed = NULL; char keyword[MAX_DESC_LEN + 1]; @@ -129,7 +130,6 @@ static ssize_t chars_chartab_store(struct kobject *kobj, spin_lock_irqsave(&speakup_info.spinlock, flags); while (cp < end) { - while ((cp < end) && (*cp == ' ' || *cp == '\t')) cp++; @@ -214,7 +214,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj, spin_unlock_irqrestore(&speakup_info.spinlock, flags); report_char_chartab_status(reset, received, used, rejected, - do_characters); + do_characters); return retval; } @@ -222,7 +222,7 @@ static ssize_t chars_chartab_store(struct kobject *kobj, * This is called when a user reads the keymap parameter. */ static ssize_t keymap_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) + char *buf) { char *cp = buf; int i; @@ -258,7 +258,7 @@ static ssize_t keymap_show(struct kobject *kobj, struct kobj_attribute *attr, * This is called when a user changes the keymap parameter. */ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { int i; ssize_t ret = count; @@ -292,9 +292,9 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, i *= (int)cp1[-1] + 1; i += 2; /* 0 and last map ver */ if (cp1[-3] != KEY_MAP_VER || cp1[-1] > 10 || - i+SHIFT_TBL_SIZE+4 >= sizeof(spk_key_buf)) { + i + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf)) { pr_warn("i %d %d %d %d\n", i, - (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); + (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); kfree(in_buff); spin_unlock_irqrestore(&speakup_info.spinlock, flags); return -EINVAL; @@ -308,7 +308,7 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, if (i != 0 || cp1[-1] != KEY_MAP_VER || cp1[-2] != 0) { ret = -EINVAL; pr_warn("end %d %d %d %d\n", i, - (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); + (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); } else { if (spk_set_key_info(in_buff, spk_key_buf)) { spk_set_key_info(spk_key_defaults, spk_key_buf); @@ -325,7 +325,7 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, * This is called when a user changes the value of the silent parameter. */ static ssize_t silent_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { int len; struct vc_data *vc = vc_cons[fg_console].d; @@ -344,7 +344,7 @@ static ssize_t silent_store(struct kobject *kobj, struct kobj_attribute *attr, return -EINVAL; } spin_lock_irqsave(&speakup_info.spinlock, flags); - if (ch&2) { + if (ch & 2) { shut = 1; spk_do_flush(); } else { @@ -364,7 +364,7 @@ static ssize_t silent_store(struct kobject *kobj, struct kobj_attribute *attr, * This is called when a user reads the synth setting. */ static ssize_t synth_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) + char *buf) { int rv; @@ -379,7 +379,7 @@ static ssize_t synth_show(struct kobject *kobj, struct kobj_attribute *attr, * This is called when a user requests to change synthesizers. */ static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { int len; char new_synth_name[10]; @@ -392,7 +392,7 @@ static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, len--; new_synth_name[len] = '\0'; spk_strlwr(new_synth_name); - if ((synth != NULL) && (!strcmp(new_synth_name, synth->name))) { + if (synth && !strcmp(new_synth_name, synth->name)) { pr_warn("%s already in use\n", new_synth_name); } else if (synth_init(new_synth_name) != 0) { pr_warn("failed to init synth %s\n", new_synth_name); @@ -405,7 +405,8 @@ static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, * This is called when text is sent to the synth via the synth_direct file. */ static ssize_t synth_direct_store(struct kobject *kobj, - struct kobj_attribute *attr, const char *buf, size_t count) + struct kobj_attribute *attr, + const char *buf, size_t count) { u_char tmp[256]; int len; @@ -435,7 +436,7 @@ static ssize_t synth_direct_store(struct kobject *kobj, * This function is called when a user reads the version. */ static ssize_t version_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) + char *buf) { char *cp; @@ -451,7 +452,7 @@ static ssize_t version_show(struct kobject *kobj, struct kobj_attribute *attr, * This is called when a user reads the punctuation settings. */ static ssize_t punc_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) + char *buf) { int i; char *cp = buf; @@ -471,27 +472,27 @@ static ssize_t punc_show(struct kobject *kobj, struct kobj_attribute *attr, var = spk_get_punc_var(p_header->var_id); if (!var) { pr_warn("var is null, p_header->var_id is %i\n", - p_header->var_id); + p_header->var_id); return -EINVAL; } spin_lock_irqsave(&speakup_info.spinlock, flags); - pb = (struct st_bits_data *) &spk_punc_info[var->value]; + pb = (struct st_bits_data *)&spk_punc_info[var->value]; mask = pb->mask; for (i = 33; i < 128; i++) { - if (!(spk_chartab[i]&mask)) + if (!(spk_chartab[i] & mask)) continue; *cp++ = (char)i; } spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return cp-buf; + return cp - buf; } /* * This is called when a user changes the punctuation settings. */ static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { int x; struct st_var_header *p_header; @@ -513,7 +514,7 @@ static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr, var = spk_get_punc_var(p_header->var_id); if (!var) { pr_warn("var is null, p_header->var_id is %i\n", - p_header->var_id); + p_header->var_id); return -EINVAL; } @@ -538,7 +539,7 @@ static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr, * This function is called when a user reads one of the variable parameters. */ ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) + char *buf) { int rv = 0; struct st_var_header *param; @@ -553,7 +554,7 @@ ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, return -EINVAL; spin_lock_irqsave(&speakup_info.spinlock, flags); - var = (struct var_t *) param->data; + var = (struct var_t *)param->data; switch (param->var_type) { case VAR_NUM: case VAR_TIME: @@ -575,14 +576,14 @@ ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, *cp1++ = '"'; *cp1++ = '\n'; *cp1 = '\0'; - rv = cp1-buf; + rv = cp1 - buf; } else { rv = sprintf(buf, "\"\"\n"); } break; default: rv = sprintf(buf, "Bad parameter %s, type %i\n", - param->name, param->var_type); + param->name, param->var_type); break; } spin_unlock_irqrestore(&speakup_info.spinlock, flags); @@ -594,7 +595,7 @@ EXPORT_SYMBOL_GPL(spk_var_show); * Used to reset either default_pitch or default_vol. */ static inline void spk_reset_default_value(char *header_name, - int *synth_default_value, int idx) + int *synth_default_value, int idx) { struct st_var_header *param; @@ -614,7 +615,7 @@ static inline void spk_reset_default_value(char *header_name, * variable parameters. */ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { struct st_var_header *param; int ret; @@ -663,9 +664,9 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, var_data = param->data; value = var_data->u.n.value; spk_reset_default_value("pitch", synth->default_pitch, - value); + value); spk_reset_default_value("vol", synth->default_vol, - value); + value); } break; case VAR_STRING: @@ -680,7 +681,7 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, ret = spk_set_string_var(cp, param, len); if (ret == -E2BIG) pr_warn("value too long for %s\n", - param->name); + param->name); break; default: pr_warn("%s unknown type %d\n", @@ -700,7 +701,7 @@ EXPORT_SYMBOL_GPL(spk_var_store); */ static ssize_t message_show_helper(char *buf, enum msg_index_t first, - enum msg_index_t last) + enum msg_index_t last) { size_t bufsize = PAGE_SIZE; char *buf_pointer = buf; @@ -713,7 +714,7 @@ static ssize_t message_show_helper(char *buf, enum msg_index_t first, if (bufsize <= 1) break; printed = scnprintf(buf_pointer, bufsize, "%d\t%s\n", - index, spk_msg_get(cursor)); + index, spk_msg_get(cursor)); buf_pointer += printed; bufsize -= printed; } @@ -722,7 +723,7 @@ static ssize_t message_show_helper(char *buf, enum msg_index_t first, } static void report_msg_status(int reset, int received, int used, - int rejected, char *groupname) + int rejected, char *groupname) { int len; char buf[160]; @@ -743,9 +744,9 @@ static void report_msg_status(int reset, int received, int used, } static ssize_t message_store_helper(const char *buf, size_t count, - struct msg_group_t *group) + struct msg_group_t *group) { - char *cp = (char *) buf; + char *cp = (char *)buf; char *end = cp + count; char *linefeed = NULL; char *temp = NULL; @@ -762,7 +763,6 @@ static ssize_t message_store_helper(const char *buf, size_t count, enum msg_index_t curmessage; while (cp < end) { - while ((cp < end) && (*cp == ' ' || *cp == '\t')) cp++; @@ -828,13 +828,15 @@ static ssize_t message_store_helper(const char *buf, size_t count, } static ssize_t message_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) + struct kobj_attribute *attr, char *buf) { ssize_t retval = 0; struct msg_group_t *group = spk_find_msg_group(attr->attr.name); unsigned long flags; - BUG_ON(!group); + if (WARN_ON(!group)) + return -EINVAL; + spin_lock_irqsave(&speakup_info.spinlock, flags); retval = message_show_helper(buf, group->start, group->end); spin_unlock_irqrestore(&speakup_info.spinlock, flags); @@ -842,11 +844,13 @@ static ssize_t message_show(struct kobject *kobj, } static ssize_t message_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { struct msg_group_t *group = spk_find_msg_group(attr->attr.name); - BUG_ON(!group); + if (WARN_ON(!group)) + return -EINVAL; + return message_store_helper(buf, count, group); } |