Re: [RFC PATCH 06/13] driver core: firmware loader: always let firmware_bufown the pages buffer

From: Stephen Boyd
Date: Wed Jul 25 2012 - 03:55:31 EST


Mostly trivia.

On 7/24/2012 10:00 AM, Ming Lei wrote:
> +
> +static int fw_lookup_and_alloate_buf(const char *fw_name,

allocate?

> + struct firmware_cache *fwc,
> + struct firmware_buf **buf)
> +{
> + struct firmware_buf *tmp;
> +
> + spin_lock(&fwc->lock);
> + list_for_each_entry(tmp, &fwc->head, list)
> + if (!strcmp(tmp->fw_id, fw_name)) {
> + kref_get(&tmp->ref);
> + spin_unlock(&fwc->lock);
> + *buf = tmp;
> + return 1;
> + }
> +
> + tmp = __allocate_fw_buf(fw_name, fwc);
> + if (tmp)
> + list_add(&tmp->list, &fwc->head);
> + spin_unlock(&fwc->lock);
> +
> + *buf = tmp;
> +
> + return tmp ? 0 : -1;

-ENOMEM instead of -1?

> +
> +static void fw_cache_init(void)

__init?

> +{
> + spin_lock_init(&fw_cache.lock);
> + INIT_LIST_HEAD(&fw_cache.head);
> +}
> +
[...]
> uevent, nowait);
>
> -/* transfer the ownership of pages to firmware */
> -static void fw_set_page_data(struct firmware_buf *buf)
> -{
> - struct firmware *fw = buf->fw;
> + if (IS_ERR(fw_priv) || ret == -1) {
> + kfree(firmware);
> + *firmware_p = NULL;
> + return ERR_PTR(-ENOMEM);

This would have to check for < 0 and return ERR_PTR(ret) instead.

--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/