All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@kernel.org>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Cc: loic.poulain@linaro.org, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH v2 4/4] wcn36xx: Add debugfs entry to read firmware feature strings
Date: Wed, 27 Jul 2022 14:08:30 +0300	[thread overview]
Message-ID: <877d3yq0cx.fsf@kernel.org> (raw)
In-Reply-To: <582e56e7-87d1-e6b3-ac7a-00fe07a10a14@linaro.org> (Bryan O'Donoghue's message of "Wed, 27 Jul 2022 11:41:48 +0100")

Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:

> On 27/07/2022 11:31, Kalle Valo wrote:
>> Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:
>
>>> +static ssize_t read_file_firmware_feature_caps(struct file *file,
>>> +					       char __user *user_buf,
>>> +					       size_t count, loff_t *ppos)
>>> +{
>>> +	struct wcn36xx *wcn = file->private_data;
>>> +	unsigned long page = get_zeroed_page(GFP_KERNEL);
>>> +	char *p = (char *)page;
>>> +	int i;
>>> +	int ret;
>>> +
>>> +	if (!p)
>>> +		return -ENOMEM;
>>> +
>>> +	mutex_lock(&wcn->hal_mutex);
>>> +	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
>>> +		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
>>> +			p += sprintf(p, "%s\n",
>>> +				     wcn36xx_firmware_get_cap_name(i));
>>> +		}
>>> +	}
>>> +	mutex_unlock(&wcn->hal_mutex);
>>> +
>>> +	ret = simple_read_from_buffer(user_buf, count, ppos, (char *)page,
>>> +				      (unsigned long)p - page);
>>> +
>>> +	free_page(page);
>>> +	return ret;
>>> +}
>>
>> Why not use the normal use kzalloc() and kfree()? That way you would not
>> need a separate page variable. What's the benefit from
>> get_zeroed_page()?
>
>
> TBH I did a copy/paste here from another driver... I forget which
>>
>> Also I don't see any checks for a memory allocation failure.
>>
>
> its there
>
> char *p = (char*) page;
>
> if (!p)
>     return -ENOMEM;

Ah, it's pretty evil to have the error handling so far away from the
actual call :)

> I can V2 this for kzalloc and kfree if you prefer though

Yes, please do that. We should use standard infrastructure as much as
possible.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

      reply	other threads:[~2022-07-27 11:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19 14:32 [PATCH v2 0/4] wcn36xx: Add in debugfs export of firmware feature bits Bryan O'Donoghue
2022-07-19 14:32 ` [PATCH v2 1/4] wcn36xx: Rename clunky firmware feature bit enum Bryan O'Donoghue
2022-07-20  7:14   ` Loic Poulain
2022-07-19 14:33 ` [PATCH v2 2/4] wcn36xx: Move firmware feature bit storage to dedicated firmware.c file Bryan O'Donoghue
2022-07-20  7:16   ` Loic Poulain
2022-07-19 14:33 ` [PATCH v2 3/4] wcn36xx: Move capability bitmap to string translation function to firmware.c Bryan O'Donoghue
2022-07-20  7:21   ` Loic Poulain
2022-07-19 14:33 ` [PATCH v2 4/4] wcn36xx: Add debugfs entry to read firmware feature strings Bryan O'Donoghue
2022-07-20  7:24   ` Loic Poulain
2022-07-27 10:31   ` Kalle Valo
2022-07-27 10:41     ` Bryan O'Donoghue
2022-07-27 11:08       ` Kalle Valo [this message]

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=877d3yq0cx.fsf@kernel.org \
    --to=kvalo@kernel.org \
    --cc=bryan.odonoghue@linaro.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=loic.poulain@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wcn36xx@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.