All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: William Breathitt Gray <vilhelm.gray@gmail.com>, wim@iguana.be
Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] watchdog: Add watchdog timer support for the WinSystems EBC-C384
Date: Sat, 23 Jan 2016 12:01:38 -0800	[thread overview]
Message-ID: <56A3DC22.90508@roeck-us.net> (raw)
In-Reply-To: <56A39C63.9080905@gmail.com>

On 01/23/2016 07:29 AM, William Breathitt Gray wrote:
> On 01/21/2016 10:42 PM, Guenter Roeck wrote:
>> This implies that setting the timeout would start the watchdog,
>> which is inappropriate (the timeout can be set while the watchdog
>> is stopped).
>>
>> Also, setting the timeout sets both the resolution _and_ the timeout,
>> which is probably unnecessary when starting or pinging the watchdog.
>
> Help me understand the functionality of the watchdog operations briefly
> since I'm relatively new to the interface. Is it proper to say that the
> start callback starts (and in my case also pings) the watchdog based on
> the value of the previously configured timeout member, while the
> set_timeout callback merely sets the timeout member itself to the
> correct value in seconds accordingly to the watchdog timer's resolution?
>
Correct. In your case it may be sufficient to just set the 'timeout' variable
to a valid timeout (ie one supported by the hardware).

>>> +    const unsigned base = 0x564;
>>> +    const unsigned extent = 5;
>>> +    const char *const name = dev_name(dev);
>>
>> What is the value of those const variables ? Why not just use dev_name() and defines ?
>>
>>> +    int err;
>>> +
>>
>> Is there a means to detect if this is the correct system ? DMI, maybe ?
>> Blindly instantiating the driver seems to be a bit risky and should be avoided
>> if possible.
>
> Unfortunately, the watchdog timer hardware lacks probing capabilities;
> the documentation for the motherboard indicates that the watchdog timer
> is exposed over an ISA-style I/O-mapped port address. In other words,
> the watchdog timer is non-hotpluggable.
>
So how about DMI ? This is a PC, after all, so it should be possible
to identify the hardware with DMI. We should have _something_ available
to identify the hardware.

> I agree that carrying around the constant values in the private data
> structure is somewhat unnecessary, so I'll give them global scope over
> the file. I'm hesitant to lose the type-safety of C variables; is there
> a reason to prefer preprocessor defines over const-qualified variables?
>
It is the common and established approach to use defines (you use a define
for WATCHDOG_TIMEOUT as well). The type-safety argument doesn't really apply;
to me it is similar to the argument for Yoda programming. The compiler
will happily complain if you use an integer define as pointer, or a string
as integer.

Defines are used all over the kernel, and work perfectly fine. I don't see
a need to change that. Worse, it makes life more difficult for reviewers.

>>> +    err = watchdog_init_timeout(&wdt->wdd, timeout, dev);
>>> +    if (err)
>>> +        goto err_init_timeout;
>>
>> A more tolerant implementation would set the default timeout.
>
> Should I remove the timeout module parameter entirely, and simply
> initialize the watchdog_device timeout member to the default timeout I
> want (e.g. wdt->wdd.timeout = 60)? Would I still need to call
> watchdog_init_timeout in that case?
>
I didn't want to suggest that. One option would be to set
wdt->wdd.timeout = 60 and ignore the return value from watchdog_init_timeout,
like most watchdog drivers. Another would be something like

	wdt->wdd.timeout = WATCHDOG_TIMEOUT;
	if (watchdog_init_timeout(&wdt->wdd, timeout, dev))
		dev_warn(dev, "Invalid timeout %d, using default\n", timeout);

You can also abort, as you currently do, I just think it is a bit strict.

>> Have you considered using module_platform_driver_probe() ?
>
> For some reason, I was under the impression that I must allocate a
> platform_device before calling platform_driver_probe. I'll try
> module_platform_driver_probe since that would indeed be far simpler if
> the platform_device setup code is unnecessary.
>
Ah yes, my mistake. The idea is that another driver (usually a platform
driver, or architecture initialization code) would instantiate the device.
Sorry for the noise.

>> No MODULE_ALIAS ?
>
> Since the watchdog timer hardware is non-hotpluggable, I'm not sure I
> should add a MODULE_ALIAS for autoloading the module.
>
Not sure I understand what that has to do with hotplug. Almost all
of the 39 watchdog drivers defining MODULE_ALIAS are not hot-pluggable.
Ok, let's see if it comes back to bite us ;-).

Guenter


      reply	other threads:[~2016-01-23 20:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-22  1:11 [PATCH] watchdog: Add watchdog timer support for the WinSystems EBC-C384 William Breathitt Gray
2016-01-22  3:42 ` Guenter Roeck
2016-01-23 15:29   ` William Breathitt Gray
2016-01-23 20:01     ` Guenter Roeck [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=56A3DC22.90508@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=vilhelm.gray@gmail.com \
    --cc=wim@iguana.be \
    /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.