From: Vinod Koul <vinod.koul@intel.com>
To: Hsin-Yu Chao <hychao@chromium.org>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH v4] ucm: add cset-tlv
Date: Wed, 13 Apr 2016 14:27:40 +0530 [thread overview]
Message-ID: <20160413085740.GK2274@localhost> (raw)
In-Reply-To: <1460528817-25598-1-git-send-email-hychao@chromium.org>
On Wed, Apr 13, 2016 at 02:26:57PM +0800, Hsin-Yu Chao wrote:
> + sz_read = read(fd, *res, sz);
> + if (sz_read < 0 || (size_t)sz_read != sz) {
> + err = -EIO;
> + free(*res);
> + *res = NULL;
> + }
> + /* Check if the tlv file specifies valid size. */
> + tlv = (unsigned int *)(*res);
> + if (tlv[1] + 2 * sizeof(unsigned int) != sz) {
why not use snd_ctl_tlv(), my assumption is that you are expecting a type,
length and values in the buffer
> + uc_error("Invalid tlv size");
wouldn't it help to print the size for error
> + err = -EINVAL;
> + free(*res);
> + *res = NULL;
> + }
> +
> + __fail:
I dont know about syntax expected in UCM but this label could be left
justfied :)
> + close(fd);
> + return err;
> +}
> +
> static int binary_file_parse(snd_ctl_elem_value_t *dst,
> snd_ctl_elem_info_t *info,
> const char *filepath)
> @@ -226,6 +276,7 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
> snd_ctl_elem_id_t *id;
> snd_ctl_elem_value_t *value;
> snd_ctl_elem_info_t *info;
> + char *res = NULL;
>
> snd_ctl_elem_id_malloc(&id);
> snd_ctl_elem_value_malloc(&value);
> @@ -241,23 +292,36 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
> err = -EINVAL;
> goto __fail;
> }
> - snd_ctl_elem_value_set_id(value, id);
> snd_ctl_elem_info_set_id(info, id);
> - err = snd_ctl_elem_read(ctl, value);
> - if (err < 0)
> - goto __fail;
> err = snd_ctl_elem_info(ctl, info);
> if (err < 0)
> goto __fail;
> - if (type == SEQUENCE_ELEMENT_TYPE_CSET_BIN_FILE)
> - err = binary_file_parse(value, info, pos);
> - else
> - err = snd_ctl_ascii_value_parse(ctl, value, info, pos);
> - if (err < 0)
> - goto __fail;
> - err = snd_ctl_elem_write(ctl, value);
> - if (err < 0)
> - goto __fail;
> + if (type == SEQUENCE_ELEMENT_TYPE_CSET_TLV) {
> + if (!snd_ctl_elem_info_is_tlv_writable(info)) {
> + err = -EINVAL;
> + goto __fail;
> + }
> + err = read_tlv_file(&res, pos);
> + if (err < 0)
> + goto __fail;
> + err = snd_ctl_elem_tlv_write(ctl, id, (unsigned int *)res);
if tlv_write expects unsigned int then wouldn't it be better to use
read_tlv_file() with unsigned int.
--
~Vinod
next prev parent reply other threads:[~2016-04-13 8:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-13 6:26 [PATCH v4] ucm: add cset-tlv Hsin-Yu Chao
2016-04-13 8:57 ` Vinod Koul [this message]
2016-04-13 10:02 ` Takashi Iwai
2016-04-13 10:15 ` Hsin-yu Chao
2016-04-13 10:22 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160413085740.GK2274@localhost \
--to=vinod.koul@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=hychao@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).