mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Russell King - ARM Linux <linux@armlinux.org.uk>,
	Lee Jones <lee.jones@linaro.org>
Cc: benjamin.gaignard@st.com, kernel@stlinux.com,
	patrice.chotard@st.com, linux-kernel@vger.kernel.org,
	hans.verkuil@cisco.com, mchehab@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH] [media] cec: Handle RC capability more elegantly
Date: Tue, 4 Apr 2017 18:05:10 +0200	[thread overview]
Message-ID: <fb4bce41-69ef-227f-e177-7a6db536ff64@xs4all.nl> (raw)
In-Reply-To: <20170404153659.GC7909@n2100.armlinux.org.uk>

On 04/04/2017 05:36 PM, Russell King - ARM Linux wrote:
> On Tue, Apr 04, 2017 at 04:19:39PM +0100, Lee Jones wrote:
>> On Tue, 04 Apr 2017, Hans Verkuil wrote:
>>
>>> On 04/04/2017 04:43 PM, Lee Jones wrote:
>>>> If a user specifies the use of RC as a capability, they should
>>>> really be enabling RC Core code.  If they do not we WARN() them
>>>> of this and disable the capability for them.
>>>>
>>>> Once we know RC Core code has not been enabled, we can update
>>>> the user's capabilities and use them as a term of reference for
>>>> other RC-only calls.  This is preferable to having ugly #ifery
>>>> scattered throughout C code.
>>>>
>>>> Most of the functions are actually safe to call, since they
>>>> sensibly check for a NULL RC pointer before they attempt to
>>>> deference it.
>>>>
>>>> Signed-off-by: Lee Jones <lee.jones@linaro.org>
>>>> ---
>>>>  drivers/media/cec/cec-core.c | 19 +++++++------------
>>>>  1 file changed, 7 insertions(+), 12 deletions(-)
>>>>
>>>> diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c
>>>> index cfe414a..51be8d6 100644
>>>> --- a/drivers/media/cec/cec-core.c
>>>> +++ b/drivers/media/cec/cec-core.c
>>>> @@ -208,9 +208,13 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
>>>>  		return ERR_PTR(-EINVAL);
>>>>  	if (WARN_ON(!available_las || available_las > CEC_MAX_LOG_ADDRS))
>>>>  		return ERR_PTR(-EINVAL);
>>>> +	if (WARN_ON(caps & CEC_CAP_RC && !IS_REACHABLE(CONFIG_RC_CORE)))
>>>> +		caps &= ~CEC_CAP_RC;
>>>
>>> Don't use WARN_ON, this is not an error of any kind.
>>
>> Right, this is not an error.
>>
>> That's why we are warning the user instead of bombing out.
> 
> Please print warning using pr_warn() or dev_warn().  Using WARN_ON()
> because something is not configured is _really_ not nice behaviour.
> Consider how useful a stack trace is to the user for this situation -
> it's completely meaningless.
> 
> A message that prompts the user to enable RC_CORE would make more sense,
> and be much more informative to the user.  Maybe something like this:
> 
> +	if (caps & CEC_CAP_RC && !IS_REACHABLE(CONFIG_RC_CORE)) {
> +		pr_warn("CEC: driver %pf requests RC, please enable CONFIG_RC_CORE\n",
> +			__builtin_return_address(0));
> +		caps &= ~CEC_CAP_RC;
> +	}
> 
> It could be much more informative by using dev_warn() if we had the
> 'struct device' passed in to this function, and then we wouldn't need
> to use __builtin_return_address().
> 

I don't want to see a message logged because of this. In the current design it
is perfectly valid to compile without RC_CORE.

I think eventually this should be redesigned a bit (a separate CEC config option
that enables or disables RC support), but for now I prefer to leave this as-is
until I have a bit more experience with this.

After the CEC notifier work is in I will take another look at this.

Regards,

	Hans

  reply	other threads:[~2017-04-04 16:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 14:43 Lee Jones
2017-04-04 14:51 ` Hans Verkuil
2017-04-04 15:19   ` Lee Jones
2017-04-04 15:36     ` Russell King - ARM Linux
2017-04-04 16:05       ` Hans Verkuil [this message]
2017-04-05  9:12         ` Lee Jones
2017-04-05  9:11       ` Lee Jones
2017-04-04 15:57     ` Hans Verkuil

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=fb4bce41-69ef-227f-e177-7a6db536ff64@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=benjamin.gaignard@st.com \
    --cc=hans.verkuil@cisco.com \
    --cc=kernel@stlinux.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mchehab@kernel.org \
    --cc=patrice.chotard@st.com \
    /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

all inboxes | Powered by JetHome®