From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
alsa-devel@alsa-project.org
Cc: vkoul@kernel.org, broonie@kernel.org, tiwai@suse.com,
lgirdwood@gmail.com
Subject: Re: [PATCH 4/7] ASoC: Intel: Skylake: Shield against no-NHLT configurations
Date: Mon, 9 Mar 2020 18:38:48 +0100 [thread overview]
Message-ID: <740bc65e-afe9-cefe-4a31-d19cc9d83c56@intel.com> (raw)
In-Reply-To: <d38dbb00-734f-7de9-ce0c-2ee06cec11d6@linux.intel.com>
On 2020-03-09 18:01, Pierre-Louis Bossart wrote:
> On 3/9/20 8:03 AM, Cezary Rojewski wrote:
>> On 2020-03-06 22:03, Pierre-Louis Bossart wrote:
>>>
>>>
>>>> - intel_nhlt_free(skl->nhlt);
>>>> + if (skl->nhlt)
>>>> + intel_nhlt_free(skl->nhlt);
>>>
>>> we could alternatively move the test in intel_nhlt_free, which seems
>>> like a more robust thing to do?
>>
>> Depends. In general kernel-internal API trusts its caller and
>> appending 'ifs' everywhere would unnecessarily slow entire kernel
>> down. While intel_nhlt_free is called rarely, I'd still argue caller
>> should be sane about its invocation.
>>
>> 'if' in skl_probe could be avoided had the function's structure been
>> better. 'if' in skl_remove is just fine, though.
>>
>> Let's leave it as is.
>
> it's also used in SOF:
>
> sound/soc/sof/intel/hda.c: intel_nhlt_free(nhlt);
>
> that's why I suggested to factor the test so that both users don't need
> to add the if.
I understand, and my explanation still applies.
SOF's intel_nhlt_free usage is great example actually. Caller is sane
about its doings as it should be. Internal API needs not to suffer from
callers irresponsibility.
PCM does not call ::free() if ::open() fails, same as device-driver
model does not care about ::remove() if ::probe() fails.
Czarek
next prev parent reply other threads:[~2020-03-09 17:40 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 14:53 [PATCH 0/7] ASoC: Intel: Skylake: Fix HDaudio and Dmic Cezary Rojewski
2020-03-05 14:53 ` [PATCH 1/7] ASoC: Intel: Skylake: Remove superfluous chip initialization Cezary Rojewski
2020-03-06 20:52 ` Pierre-Louis Bossart
2020-03-09 13:57 ` Cezary Rojewski
2020-03-09 16:48 ` Pierre-Louis Bossart
2020-03-09 17:43 ` Cezary Rojewski
2020-03-09 18:41 ` Pierre-Louis Bossart
2020-03-10 17:45 ` Applied "ASoC: Intel: Skylake: Remove superfluous chip initialization" to the asoc tree Mark Brown
2020-03-05 14:53 ` [PATCH 2/7] ASoC: Intel: Skylake: Select hda configuration permissively Cezary Rojewski
2020-03-06 20:57 ` Pierre-Louis Bossart
2020-03-09 13:47 ` Cezary Rojewski
2020-03-09 17:03 ` Pierre-Louis Bossart
2020-03-10 9:30 ` Cezary Rojewski
2020-03-10 17:45 ` Applied "ASoC: Intel: Skylake: Select hda configuration permissively" to the asoc tree Mark Brown
2020-03-05 14:53 ` [PATCH 3/7] ASoC: Intel: Skylake: Enable codec wakeup during chip init Cezary Rojewski
2020-03-10 17:44 ` Applied "ASoC: Intel: Skylake: Enable codec wakeup during chip init" to the asoc tree Mark Brown
2020-03-05 14:53 ` [PATCH 4/7] ASoC: Intel: Skylake: Shield against no-NHLT configurations Cezary Rojewski
2020-03-06 21:03 ` Pierre-Louis Bossart
2020-03-09 13:03 ` Cezary Rojewski
2020-03-09 17:01 ` Pierre-Louis Bossart
2020-03-09 17:38 ` Cezary Rojewski [this message]
2020-03-09 18:40 ` Pierre-Louis Bossart
2020-03-10 17:44 ` Applied "ASoC: Intel: Skylake: Shield against no-NHLT configurations" to the asoc tree Mark Brown
2020-03-05 14:53 ` [PATCH 5/7] ASoC: Intel: skl_hda_dsp: Enable Dmic configuration Cezary Rojewski
2020-03-06 14:46 ` Kai Vehmanen
2020-03-06 15:49 ` Pierre-Louis Bossart
2020-03-06 19:05 ` Cezary Rojewski
2020-03-06 19:49 ` Pierre-Louis Bossart
2020-03-06 19:58 ` Cezary Rojewski
2020-03-05 14:53 ` [PATCH 6/7] ASoC: Intel: Allow for ROM init retry on CNL platforms Cezary Rojewski
2020-03-10 17:44 ` Applied "ASoC: Intel: Allow for ROM init retry on CNL platforms" to the asoc tree Mark Brown
2020-03-05 14:53 ` [PATCH 7/7] ASoC: Intel: Skylake: Await purge request ack on CNL Cezary Rojewski
2020-03-10 17:44 ` Applied "ASoC: Intel: Skylake: Await purge request ack on CNL" to the asoc tree Mark Brown
2020-03-06 20:48 ` [PATCH 0/7] ASoC: Intel: Skylake: Fix HDaudio and Dmic Pierre-Louis Bossart
2020-03-09 11:38 ` Mark Brown
2020-03-09 14:02 ` Cezary Rojewski
2020-03-09 16:54 ` Mark Brown
2020-03-09 17:48 ` Cezary Rojewski
2020-03-09 17:52 ` Mark Brown
2020-03-10 16:03 ` Pierre-Louis Bossart
[not found] ` <2dc38392-760b-a5fc-fa00-98530729f2d3@intel.com>
2020-03-11 16:56 ` Mark Brown
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=740bc65e-afe9-cefe-4a31-d19cc9d83c56@intel.com \
--to=cezary.rojewski@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=tiwai@suse.com \
--cc=vkoul@kernel.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).