History log of /linux-master/drivers/staging/greybus/audio_topology.c
Revision Date Author Comments
# 4d44ea3a 28-Feb-2024 Colin Ian King <colin.i.king@gmail.com>

staging: greybus: Remove redundant variable 'mask'

The variable mask is being assigned and bit-set but it is never
being used apart from this. The variable is redundant and can
be removed.

Cleans up clang scan build warning:
drivers/staging/greybus/audio_topology.c:764:15: warning: variable 'mask'
set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Link: https://lore.kernel.org/r/20240229120541.219429-1-colin.i.king@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ba32601b 20-Mar-2023 Khadija Kamran <kamrankhadijadj@gmail.com>

staging: greybus: fix line ending with '('

Splitting function header to multiple lines because of 80 characters per
line limit, results in ending the function call line with '('.
This leads to CHECK reported by checkpatch.pl

Move the first parameter right after the '(' in the function call line.
Align the rest of the parameters to the opening parenthesis.

Signed-off-by: Khadija Kamran <kamrankhadijadj@gmail.com>
Link: https://lore.kernel.org/r/ZBhNOkQbG4ygNF98@khadija-virtual-machine
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2e819481 04-Jan-2022 Jiasheng Jiang <jiasheng@iscas.ac.cn>

staging: greybus: audio: Check null pointer

As the possible alloc failure of devm_kcalloc(), it could return null
pointer.
Therefore, 'strings' should be checked and return NULL if alloc fails to
prevent the dereference of the NULL pointer.
Also, the caller should also deal with the return value of the
gb_generate_enum_strings() and return -ENOMEM if returns NULL.
Moreover, because the memory allocated with devm_kzalloc() will be
freed automatically when the last reference to the device is dropped,
the 'gbe' in gbaudio_tplg_create_enum_kctl() and
gbaudio_tplg_create_enum_ctl() do not need to free manually.
But the 'control' in gbaudio_tplg_create_widget() and
gbaudio_tplg_process_kcontrols() has a specially error handle to
cleanup.
So it should be better to cleanup 'control' when fails.

Fixes: e65579e335da ("greybus: audio: topology: Enable enumerated control support")
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20220104150628.1987906-1-jiasheng@iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 144779ed 09-Dec-2021 Arnd Bergmann <arnd@arndb.de>

staging: greybus: fix stack size warning with UBSAN

clang warns about excessive stack usage in this driver when
UBSAN is enabled:

drivers/staging/greybus/audio_topology.c:977:12: error: stack frame size of 1836 bytes in function 'gbaudio_tplg_create_widget' [-Werror,-Wframe-larger-than=]

Rework this code to no longer use compound literals for
initializing the structure in each case, but instead keep
the common bits in a preallocated constant array and copy
them as needed.

Link: https://github.com/ClangBuiltLinux/linux/issues/1535
Link: https://lore.kernel.org/r/20210103223541.2790855-1-arnd@kernel.org/
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
[nathan: Address review comments from v1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211209195141.1165233-1-nathan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9a032e3f 19-May-2021 Rajat Asthana <thisisrast7@gmail.com>

staging: greybus: audio: Fix sparse warning.

Sparse complains that:
warning: restricted send_ctl_elem_iface_t degrades to integer.

I have looked at this code, and the code is fine as-is. Normally we
would frown on using the __force directive to silence Sparse warnings
but in this case it's fine. Case statements can't be made into __bitwise
types. We also can't change the type of "ctl->iface" either because that
is part of the user space API.

So just add a (__force int) to make the warning go away.

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rajat Asthana <thisisrast7@gmail.com>
Link: https://lore.kernel.org/r/20210519134119.848055-1-thisisrast7@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1e37da45 21-Feb-2021 Kumar Kartikeya Dwivedi <memxor@gmail.com>

staging/greybus: eliminate use of NAME_SIZE for strings

Instead, depend on the size of the destination buffer for easier
refactoring.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20210221154258.119503-1-memxor@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a6611144 31-Jan-2021 Kumar Kartikeya Dwivedi <memxor@gmail.com>

staging: greybus: Switch from strlcpy to strscpy

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d87c29 ("checkpatch: prefer strscpy to strlcpy")

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20210131172838.146706-3-memxor@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6c75a92a 02-Oct-2020 Coiby Xu <coiby.xu@gmail.com>

staging: greybus: use __force when assigning __u8 value to snd_ctl_elem_type_t

(struct gb_audio_ctl_elem_info*)->type has the type of __u8 so there is no
concern about the byte order. __force is safe to use.

Found by sparse,

$ make C=2 drivers/staging/greybus/
drivers/staging/greybus/audio_topology.c:185:24: warning: cast to restricted snd_ctl_elem_type_t

Suggested-by: Alex Elder <elder@linaro.org>
Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
Link: https://lore.kernel.org/r/20201002233057.74462-3-coiby.xu@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 50a390ad 02-Oct-2020 Coiby Xu <coiby.xu@gmail.com>

staging: greybus: fix warnings about endianness detected by sparse

This patch fix the following warnings from sparse,

$ make C=2 drivers/staging/greybus/
drivers/staging/greybus/audio_module.c:222:25: warning: incorrect type in assignment (different base types)
drivers/staging/greybus/audio_module.c:222:25: expected restricted __le16 [usertype] data_cport
drivers/staging/greybus/audio_module.c:222:25: got unsigned short [usertype] intf_cport_id
drivers/staging/greybus/audio_topology.c:460:40: warning: restricted __le32 degrades to integer
drivers/staging/greybus/audio_topology.c:691:41: warning: incorrect type in assignment (different base types)
drivers/staging/greybus/audio_topology.c:691:41: expected unsigned int access
drivers/staging/greybus/audio_topology.c:691:41: got restricted __le32 [usertype] access
drivers/staging/greybus/audio_topology.c:746:44: warning: incorrect type in assignment (different base types)
drivers/staging/greybus/audio_topology.c:746:44: expected unsigned int
drivers/staging/greybus/audio_topology.c:746:44: got restricted __le32
drivers/staging/greybus/audio_topology.c:748:52: warning: incorrect type in assignment (different base types)
drivers/staging/greybus/audio_topology.c:748:52: expected unsigned int
drivers/staging/greybus/audio_topology.c:748:52: got restricted __le32
drivers/staging/greybus/audio_topology.c:802:42: warning: restricted __le32 degrades to integer
drivers/staging/greybus/audio_topology.c:805:50: warning: incorrect type in assignment (different base types)
drivers/staging/greybus/audio_topology.c:805:50: expected restricted __le32
drivers/staging/greybus/audio_topology.c:805:50: got unsigned int
drivers/staging/greybus/audio_topology.c:814:50: warning: restricted __le32 degrades to integer
drivers/staging/greybus/audio_topology.c:817:58: warning: incorrect type in assignment (different base types)
drivers/staging/greybus/audio_topology.c:817:58: expected restricted __le32
drivers/staging/greybus/audio_topology.c:817:58: got unsigned int
drivers/staging/greybus/audio_topology.c:889:25: warning: incorrect type in assignment (different base types)
drivers/staging/greybus/audio_topology.c:889:25: expected unsigned int access
drivers/staging/greybus/audio_topology.c:889:25: got restricted __le32 [usertype] access

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
Link: https://lore.kernel.org/r/20201002233057.74462-1-coiby.xu@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1dffeb8b 14-Aug-2020 Vaibhav Agarwal <vaibhav.sr@gmail.com>

staging: greybus: audio: fix uninitialized value issue

The current implementation for gbcodec_mixer_dapm_ctl_put() uses
uninitialized gbvalue for comparison with updated value. This was found
using static analysis with coverity.

Uninitialized scalar variable (UNINIT)
11. uninit_use: Using uninitialized value
gbvalue.value.integer_value[0].
460 if (gbvalue.value.integer_value[0] != val) {

This patch fixes the issue with fetching the gbvalue before using it for
comparision.

Fixes: 6339d2322c47 ("greybus: audio: Add topology parser for GB codec")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/bc4f29eb502ccf93cd2ffd98db0e319fa7d0f247.1597408126.git.vaibhav.sr@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# dbc676e7 09-Jul-2020 Vaibhav Agarwal <vaibhav.sr@gmail.com>

drivers: staging: audio: Fix the missing header file for helper file

This patch fixes the warning reported for missing prototypes due to
missing header file. Also, it includes changes to remove
unused_but_set_variables.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Link: https://lore.kernel.org/r/6341df9b0b5985047af0bbbc8e136481ac515b25.1594290158.git.vaibhav.sr@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c4bb7dcf 09-Jul-2020 Vaibhav Agarwal <vaibhav.sr@gmail.com>

staging: greybus: audio: Resolve compilation error in topology parser

Fix compilation errors for GB Audio topology parser code with recent
kernel versions.

Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/2542330352ae1d01469a616ea45edb461615e072.1594290158.git.vaibhav.sr@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a0e0c920 25-Feb-2019 Bhanusree Pola <bhanusreemahesh@gmail.com>

Staging: greybus: Blank lines not required before '}'

Remove blank line to resolve checkpatch.pl issue:
CHECK: Blank lines aren't necessary before a close brace '}'

Signed-off-by: Bhanusree Pola <bhanusreemahesh@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8478c35a 25-Nov-2018 Cristian Sicilia <sicilia.cristian@gmail.com>

staging: greybus: Parenthesis alignment

Some parameters are aligned with parentheses.
Some parentheses was opened at end of line.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a86854d0 12-Jun-2018 Kees Cook <keescook@chromium.org>

treewide: devm_kzalloc() -> devm_kcalloc()

The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
This patch replaces cases of:

devm_kzalloc(handle, a * b, gfp)

with:
devm_kcalloc(handle, a * b, gfp)

as well as handling cases of:

devm_kzalloc(handle, a * b * c, gfp)

with:

devm_kzalloc(handle, array3_size(a, b, c), gfp)

as it's slightly less ugly than:

devm_kcalloc(handle, array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

devm_kzalloc(handle, 4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

Some manual whitespace fixes were needed in this patch, as Coccinelle
really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
expression HANDLE;
type TYPE;
expression THING, E;
@@

(
devm_kzalloc(HANDLE,
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
devm_kzalloc(HANDLE,
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression HANDLE;
expression COUNT;
typedef u8;
typedef __u8;
@@

(
devm_kzalloc(HANDLE,
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(char) * COUNT
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
expression HANDLE;
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)

// 2-factor product, only identifiers.
@@
expression HANDLE;
identifier SIZE, COUNT;
@@

- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- SIZE * COUNT
+ COUNT, SIZE
, ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression HANDLE;
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
devm_kzalloc(HANDLE,
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression HANDLE;
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
expression HANDLE;
identifier STRIDE, SIZE, COUNT;
@@

(
devm_kzalloc(HANDLE,
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression HANDLE;
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
devm_kzalloc(HANDLE,
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
devm_kzalloc(HANDLE,
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
devm_kzalloc(HANDLE,
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
devm_kzalloc(HANDLE,
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression HANDLE;
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
|
devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
|
devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
devm_kzalloc(HANDLE, C1 * C2, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- (E1) * E2
+ E1, E2
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- (E1) * (E2)
+ E1, E2
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- E1 * E2
+ E1, E2
, ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>


# ac5d6d86 22-May-2018 Colin Ian King <colin.king@canonical.com>

staging: greybus: fix spelling mistake: "Inavlid" -> "Invalid"

Trivial fix to spelling mistake in dev_err error message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 863dbc52 07-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: greybus: Remove redundant license text

Now that the SPDX tag is in all greybus files, that identifies the
license in a specific and legally-defined manner. So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text. And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# eb50fd3a 07-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: greybus: add SPDX identifiers to all greybus driver files

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/staging/greybus files files with the correct SPDX
license identifier based on the license text in the file itself. The
SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 055fb9ce 18-Jan-2017 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

staging: greybus: audio: Ensure proper byte order

Proper byte order was completely disregarded for multi byte data shared
between AP and module (and APB1). Fix this.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 84510052 18-Jan-2017 Vaibhav Agarwal <vaibhav.sr@gmail.com>

staging: greybus: audio: Avoid less than zero check for le32 variable

mixer control->info call back function checks for -ve values to rebase
min and max values. However, le32 variable is used to fetch values from
GB module FW. Thus negative value checking is not required. Fix this!!

Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8a983614 04-Jan-2017 Emmanuil Chatzipetru <chatzi.emanuel@gmail.com>

staging: greybus: audio_topology: Fix spaces between operator and string

Fix coding style issue caught by checkpatch.pl related to the following
warning:
- "CHECK: spaces preferred around that '*' (ctx:VxV) "

Signed-off-by: Emmanuil Chatzipetru <chatzi.emanuel@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 02ae32f7 06-Oct-2016 Chase Metzger <chasemetzger15@gmail.com>

drivers: staging: greybus: Fixed CHECKS for brace issues

Added braces to else statements where checkpatch complained.

Signed-off-by: Chase Metzger <chasemetzger15@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a2a87b22 04-Oct-2016 Elizabeth Ferdman <gnudevliz@gmail.com>

staging: greybus: Add blank line after declaration

Add a blank line after a declaration. Error found by checkpatch.

Signed-off-by: Elizabeth Ferdman <gnudevliz@gmail.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7224a2a5 24-Sep-2016 Vaibhav Agarwal <vaibhav.sr@gmail.com>

greybus: audio: fix uninitialized variable errors found by cppcheck

Currently, if info is null, the dev_err message is dereferencing an
uninitialized module pointer. Instead, it should use codec->dev pointer
in dev_err call and better align with other err msg in this function.

Also, ret variable might be used uninitialized in a specific case.
Avoid using it this way.

Found using static analysis with cppcheck:
Checking drivers/staging/greybus/audio_topology.c...
[drivers/staging/greybus/audio_topology.c:175]: (error) Uninitialized
variable: module
[drivers/staging/greybus/audio_topology.c:495]: (error) Uninitialized
variable: ret

Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4f1cbe2a 20-Sep-2016 Eva Rachel Retuya <eraretuya@gmail.com>

staging: greybus: audio: delete unnecessary parentheses

Eliminate unneeded parentheses around the right hand side of an assignment.
Coccinelle semantic patch used:

@@
expression e1, e2;
identifier v;
@@

(
v = (e1 == e2)
|
v = (e1 != e2)
|
v = (e1 <= e2)
|
v = (e1 >= e2)
|
v =
- (
e1
- )
)

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 847175e8 01-Sep-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Fetch jack_mask, button_mask from module's topology data

Added extra fields namely jack_mask & button_mask for each module_info.
These fields are required while registering jack & reporting jack
events.

Earlier, these were hard coded values assuming fixed capabilities say
HEADSET, LINEOUT, etc. supported by GB-codec driver. Now these are
computed dynamically based on module's jack capability shared via
topology data.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 79c222bc 01-Sep-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Remove unnecessary num_jack field from module_info

snd_jack will be registered based on real capabilities shared by
module's FW instead of parsing widgets and register it with fixed
capabilities. Remove module_info->num_jack, since it is no more
required.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 6198f892 15-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: Use valid control pointer while freeing memory

While releasing memory during error path exit, invalid memory pointer
was used for dapm_routes. Use a valid one.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 15c726ea 15-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Add check for invalid index while mapping control

While mapping control id to define DAPM routes, invalid control index
may cause kernel oops. Add extra check to validate index while mapping
names to control_id.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4ffca62a 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Update parameters for gbaudio_module_update API

Earlier, module path was enabled based on module's control switch e.g.
'SPK Amp switch'. Thus widget's name was sufficient to parse and
identify the direction. Now individual modules' path will be enabled
based on AIF widget status. So, it is required to get complete widget
details, say w->type is used to identify direction (playback/capture)
and w->sname is used to identify module's DATA connection used for
communication via greybus.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 9d3717f7 25-Jul-2016 David Lin <dtwlin@google.com>

greybus: audio: add runtime pm to enumerated control and DAPM widget

There's an issue that the userspace is not able to control both the
enumerated control and DAPM widget when audio bundle is in the SUSPEND
state. This patch fixes the issue by adding pm_runtime_get/put() calls
for the both controls.

Testing Done:
- Use tinymix to get and put both enumerated control and DAPM widget as
the followings, and observe audio bundle is able to wake up from
suspend.

$ tinymix "GB 3 PB source" 1
$ tinymix "GB 3 PB source"
GB 3 PB source: AIF1 >AIF2

$ tinymix "GB 3 AIF1_RX MUX" 2
$ tinymix "GB 3 AIF1_RX MUX"
GB 3 AIF1_RX MUX: Stereo Left >Right

Reported-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# a0de502e 16-Jul-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: audio_topology: Fix compile warning

Fix following compile warning by staticizing gb_generate_enum_strings().

greybus/audio_topology.c:134:12: warning: symbol 'gb_generate_enum_strings' was not declared. Should it be static?

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 6ba7fad4 14-Jul-2016 David Lin <dtwlin@google.com>

greybus: audio: add runtime pm support

Add runtime pm support to audio protocol device class driver.

Testing Done:
- Use white speaker module and check the interface is autosuspended when
it's idle and resumed when playback audio

Signed-off-by: David Lin <dtwlin@google.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Alex Elder <elder@linaro.org>


# e65579e3 30-Jun-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: topology: Enable enumerated control support

Added .get/.set callback and relevant changes in parser to enable
enumerated control support for kcontrols and DAPM widget controls.
Currently, it is limited to enumerated strings only.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mark.greer@animalcreek.com>
Signed-off-by: Alex Elder <elder@linaro.org>


# d4cd9daa 05-Jul-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: topology: Use csize while computing next_ptr in parser

Size of control elements vary in case of enumerated controls. As a
preparation to enable enumerated control in topology parser, this patch
uses csize while parsing controls & wsize while parsing widgets & its
control to update next pointer.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mark.greer@animalcreek.com>
Signed-off-by: Alex Elder <elder@linaro.org>


# bb296b48 30-Jun-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: added warning message in case of missing widget

Additional warning message added to notify in case above layer tries to
access widget that is already removed from the list.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mark.greer@animalcreek.com>
Signed-off-by: Alex Elder <elder@linaro.org>


# 0c15a9e0 05-Jul-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: topology: Add helper API to map controlid with widget name

This API is used by enumerated controls .get/.set callback functions to
fetch control id associated with a widget.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mark.greer@animalcreek.com>
Signed-off-by: Alex Elder <elder@linaro.org>


# 60fb3405 10-Jun-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: Remove extra blank lines

This patch removes few blank lines across the repository at places where
two blank lines were present together or when a blank line is present at
the start or end of a routine.

Note that this doesn't remove most of them from greybus_protocols.h as
they were added on purpose.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# c6722ab5 09-Jun-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Ratelimit err messages in bundle, topology driver

Earlier I have shared a patch to rate limit err messages in audio_codec
driver. However, missed to include suggestion from Mark to do similar
changes in audio bundle & topology parser as well. Doing it now.

Testing Done: Compile tested

Fixes: 4cb3d109e5fc ("audio: Ratelimit err messages")
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 02f1c12c 03-Jun-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Report warning in case module is already removed

Added warning message in find_gb_module(). This will help to identify
invalid mixer control/widget modification triggered from above layer.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 89de9a06 30-Mar-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Update device type based on widget types

Device type info shared to above HAL is currently hard coded
to SPK only. Actual device type is identifed while parsing
widget types from topology FW shared by codec module.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 64a7e2cc 29-Mar-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Added jack support to audio module

Register jack with ASoC sound card in case audio module
populates it via codec FW. Currently, only a single jack
with 4 buttons can be registered for each module.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 6da549ec 29-Mar-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Fix widget pointer update during control parsing

widget pointer was incorrectly modfied while parsing kcontrol

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 6dd67645 29-Mar-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Use single codec driver registration

We have single I2S port via APB1 for communication with all
audio modules. Thus, we should register single codec driver
and manage all individual audio modules internally within
this driver.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mark.greer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 3994e0b1 28-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: use variable 'is_connected' to maintain module state

there is race condition between _disconnect() request &
stop_trigger() in case of abrupt module removal.
And sometimes this can lead to deadlock while acquiring
codec_info->lock.
To avoid such situation, atomic variable is used to maintain
codec connected state.
During dai operations (trigger, shutdown, etc.), 'is_connected'
variable is validated to avoid unnecessary lock acquire in
case module already removed.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 796fad44 28-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: codec driver cleanup

audio codec driver is now moved to bundle driver approach.
This resolved many race conditions related to audio mgmt &
data connection init/exit sequence.
Thus, a lot of helper functions can now be safely removed.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 35e28794 27-Jan-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: audio_codec: convert to bundle driver

Convert the legacy audio management and data protocol drivers to a
bundle driver.

The Audio bundle driver can support a single management and any number
of data cports, and so we expect multiple data cports to be present for
the bundle during initialization.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 538ecb5a 13-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: cleanup unnecessary dev_err messages

Replace unnecessary dev_err msg with dev_dbg.
Same were added during development to trace topology
parser progress.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 6339d232 13-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Add topology parser for GB codec

For each GB codec module inserted, DAPM widgets, kcontrols, routes
and DAIs can be fetched through greybus in a binary chunk and parsed
locally to create & populate DAPM graph for the specific module.

It is required by each codec module to populate a minimum set of
kcontrols with fixed names to support basic audio usecase.
To support advanced features of codec module, the same can be polpulated
with existing topology parser. However, to use them for different usecase
separate mechanism (may be via MSP) is required to inform userspace about
their configuration value & enable/disable sequence.

ToDos:
Currently, support for enumerated kcontrol/dapm control is hardcoded.
Need to add complete logic within the parser.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>