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 via email to