ASoC: cs-amp-lib: Some bug and typo fixes
Subsystems (3)
Richard Fitzgerald
maintainercover ASoC: cs-amp-lib: Some bug and typo fixes
This series fixes bugs and a typo in cs-amp-lib.
Richard Fitzgerald (3):
ASoC: cs-amp-lib: Fix wrong sizeof() in
_cs_amp_set_efi_calibration_data()
ASoC: cs-amp-lib: Fix missing dput() after debugfs_lookup()
ASoC: cs-amp-lib: Fix typo in error message: write -> read
sound/soc/codecs/cs-amp-lib.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerPATCH 1/3 ASoC: cs-amp-lib: Fix wrong sizeof() in _cs_amp_set_efi_calibration_data()
When calculating data->count replace the incorrect sizeof(data) with use of struct_offset().
The faulty sizeof(data) was incorrectly calculating the size of the pointer instead of the size of the struct pointed to. As it happens, both values are 8 on a 64-bit CPU. In the unlikely event of using this code on a 32-bit CPU the number of available bytes would be calculated 4 larger than is actually available.
Instead of changing to sizeof(*data) it has been replaced by struct_offset() because it has better chance of detecting these sorts of typos. Also the offset of the data[] array is actually what we want to know here anyway.
--- sound/soc/codecs/cs-amp-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cs-amp-lib.c +1 -1
@@ -500,7 +500,7 @@ static int _cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, i* must be set. */ if (data->count ==0 ) - data->count = (data->size -sizeof (data)) /sizeof (data->data[0 ]); + data->count = (data->size -struct_offset (data, data)) /sizeof (data->data[0 ]);if (amp_index <0 ) {/* Is there already a slot for this target? */
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerPATCH 2/3 ASoC: cs-amp-lib: Fix missing dput() after debugfs_lookup()
In reply to Richard FitzgeraldRewrite cs_amp_create_debugfs() so that dput() will be called on a valid dentry returned from debugfs_lookup().
The pointer returned from debugfs_lookup() must be released by dput(). The pointer returned from debugfs_create_dir() does not need to be passed to dput().
--- sound/soc/codecs/cs-amp-lib.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
sound/soc/codecs/cs-amp-lib.c +10 -3
@@ -833,11 +833,18 @@ EXPORT_SYMBOL_NS_GPL(cs_amp_devm_get_vendor_specific_variant_id, "SND_SOC_CS_AMP*/ struct dentry *cs_amp_create_debugfs (struct device *dev) { -struct dentry *dir; +struct dentry *dir, *created; +/* debugfs_lookup() can return NULL or ERR_PTR on error */ dir =debugfs_lookup ("cirrus_logic" ,NULL ); -if (!dir) - dir =debugfs_create_dir ("cirrus_logic" ,NULL ); +if (!IS_ERR_OR_NULL (dir)) { + created =debugfs_create_dir (dev_name (dev), dir); +dput (dir); + +return created; + } + + dir =debugfs_create_dir ("cirrus_logic" ,NULL );return debugfs_create_dir (dev_name (dev), dir); }
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerPATCH 3/3 ASoC: cs-amp-lib: Fix typo in error message: write -> read
In reply to Richard FitzgeraldFix the error message in cs_amp_read_cal_coeff() to say "Failed to read". It was incorrectly "Failed to write", probably a copy-paste error.
--- sound/soc/codecs/cs-amp-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cs-amp-lib.c +1 -1
@@ -118,7 +118,7 @@ static int cs_amp_read_cal_coeff(struct cs_dsp *dsp, }if (ret <0 ) { -dev_err (dsp->dev,"Failed to write to '%s': %d\n" , ctl_name, ret); +dev_err (dsp->dev,"Failed to read '%s': %d\n" , ctl_name, ret);return ret; }
Signature · 1 line
2.47.3
Mark Brown
maintainerQuoted 11 lines · Richard Fitzgerald
ASoC: cs-amp-lib: Some bug and typo fixes
This series fixes bugs and a typo in cs-amp-lib.
Richard Fitzgerald (3):
ASoC: cs-amp-lib: Fix wrongsizeof()in
_cs_amp_set_efi_calibration_data()
ASoC: cs-amp-lib: Fix missingdput()afterdebugfs_lookup()
ASoC: cs-amp-lib: Fix typo in error message: write -> read[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.1
Thanks!
[1/3] ASoC: cs-amp-lib: Fix wrong sizeof() in _cs_amp_set_efi_calibration_data()
https://git.kernel.org/broonie/sound/c/67a52d3ebb5a [2/3] ASoC: cs-amp-lib: Fix missing dput() after debugfs_lookup() https://git.kernel.org/broonie/sound/c/ba28a07a9a0b [3/3] ASoC: cs-amp-lib: Fix typo in error message: write -> read https://git.kernel.org/broonie/sound/c/a68525268685
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark