public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: Takashi Iwai <tiwai@suse.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Shuah Khan <shuah@kernel.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v2.5 2/3] firmware: Add support for loading compressed files
Date: Wed, 19 Jun 2019 23:26:47 +0000	[thread overview]
Message-ID: <20190619232646.GE19023@42.do-not-panic.com> (raw)
In-Reply-To: <20190611122626.28059-3-tiwai@suse.de>

Sorry for the late review... Ah!

On Tue, Jun 11, 2019 at 02:26:25PM +0200, Takashi Iwai wrote:
> @@ -354,7 +454,12 @@ module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644);
>  MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path");
>  
>  static int
> -fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv)
> +fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv,
> +			   const char *suffix,
> +			   int (*decompress)(struct device *dev,
> +					     struct fw_priv *fw_priv,
> +					     size_t in_size,
> +					     const void *in_buffer))

I *think* this could be cleaner, I'll elaborate below.

> @@ -645,7 +768,13 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
>  	if (ret <= 0) /* error or already assigned */
>  		goto out;
>  
> -	ret = fw_get_filesystem_firmware(device, fw->priv);
> +	ret = fw_get_filesystem_firmware(device, fw->priv, "", NULL);
> +#ifdef CONFIG_FW_LOADER_COMPRESS
> +	if (ret == -ENOENT)
> +		ret = fw_get_filesystem_firmware(device, fw->priv, ".xz",
> +						 fw_decompress_xz);
> +#endif

Hrm, and let more #ifdef'ery.

And so if someone wants to add bzip, we'd add yet-another if else on the
return value of this call... and yet more #ifdefs.

We already have a list of paths supported. It seems what we need instead
is a list of supported suffixes, and a respective structure which then
has its set of callbacks for posthandling.

This way, this could all be handled inside fw_get_filesystem_firmware()
neatly, and we can just strive towards avoiding #ifdef'ery.

Since I'm late to review, this could be done in the future, but I do
think something along these lines would make the code more maintainable
and extensible.

  Luis

  reply	other threads:[~2019-06-19 23:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-11 12:26 [PATCH v2.5 0/3] firmware: Add support for loading compressed files Takashi Iwai
2019-06-11 12:26 ` [PATCH v2.5 1/3] firmware: Factor out the paged buffer handling code Takashi Iwai
2019-06-11 12:26 ` [PATCH v2.5 2/3] firmware: Add support for loading compressed files Takashi Iwai
2019-06-19 23:26   ` Luis Chamberlain [this message]
2019-06-20  7:36     ` Takashi Iwai
2019-06-20  8:10       ` Greg Kroah-Hartman
2019-06-20  8:19         ` Takashi Iwai
2019-06-11 12:26 ` [PATCH v2.5 3/3] selftests: firmware: Add compressed firmware tests Takashi Iwai
2019-06-18  7:13 ` [PATCH v2.5 0/3] firmware: Add support for loading compressed files Greg Kroah-Hartman

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=20190619232646.GE19023@42.do-not-panic.com \
    --to=mcgrof@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=shuah@kernel.org \
    --cc=tiwai@suse.de \
    /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