lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2464980.1PKdnqcc3c@wuerfel>
Date:	Fri, 15 May 2015 16:04:41 +0200
From:	Arnd Bergmann <arnd@...db.de>
To:	fu.wei@...aro.org
Cc:	Suravee.Suthikulpanit@....com, linaro-acpi@...ts.linaro.org,
	linux-watchdog@...r.kernel.org, devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
	tekkamanninja@...il.com, graeme.gregory@...aro.org,
	al.stone@...aro.org, hanjun.guo@...aro.org, timur@...eaurora.org,
	ashwin.chaugule@...aro.org, linux@...ck-us.net,
	vgandhi@...eaurora.org, wim@...ana.be, jcm@...hat.com,
	leo.duran@....com, corbet@....net
Subject: Re: [PATCH 4/6] Watchdog: introdouce "pretimeout" into framework

On Friday 15 May 2015 19:24:48 fu.wei@...aro.org wrote:
> +static void watchdog_check_min_max_pretimeout(struct watchdog_device *wdd)
> +{
> +       /*
> +        * Check that we have valid min and max pretimeout values, if
> +        * not reset them both to 0 (=not used or unknown)
> +        */
> +       if (wdd->min_pretimeout > wdd->max_pretimeout) {
> +               pr_info("Invalid min and max pretimeout, resetting to 0!\n");
> +               wdd->min_pretimeout = 0;
> +               wdd->max_pretimeout = 0;
> +       }
> +}

I would probably just fold this function into the existing
watchdog_check_min_max_timeout() and check both normal and pre-timeout
there.

> +/**
> + * watchdog_init_pretimeout() - initialize the pretimeout field
> + * @pretimeout_parm: pretimeout module parameter
> + * @dev: Device that stores the timeout-sec property
> + *
> + * Initialize the pretimeout field of the watchdog_device struct with either
> + * the pretimeout module parameter (if it is valid value) or the timeout-sec
> + * property (only if it is a valid value and the timeout_parm is out of bounds).
> + * If none of them are valid then we keep the old value (which should normally
> + * be the default pretimeout value.
> + *
> + * A zero is returned on success and -EINVAL for failure.
> + */
> +int watchdog_init_pretimeout(struct watchdog_device *wdd,
> +                            unsigned int pretimeout_parm, struct device *dev)
> +{
> +       int ret = 0;
> +       u32 timeouts[2];
> +
> +       watchdog_check_min_max_pretimeout(wdd);
> +
> +       /* try to get the timeout module parameter first */
> +       if (!watchdog_pretimeout_invalid(wdd, pretimeout_parm) &&
> +           pretimeout_parm) {
> +               wdd->pretimeout = pretimeout_parm;
> +               return ret;
> +       }
> +       if (pretimeout_parm)
> +               ret = -EINVAL;
> +
> +       /* try to get the timeout_sec property */
> +       if (!dev || !dev->of_node)
> +               return ret;
> +       ret = of_property_read_u32_array(dev->of_node,
> +                                        "timeout-sec", timeouts, 2);
> +       if (!watchdog_pretimeout_invalid(wdd, timeouts[1]) && timeouts[1])
> +               wdd->pretimeout = timeouts[1];
> +       else
> +               ret = -EINVAL;
> +
> +       return ret;
> +}
> +EXPORT_SYMBOL_GPL(watchdog_init_pretimeout);

Same here: the function is very similar to the watchdog_init_timeout
function, and it reads the same property, so just do both here.

The easiest way for that is probably to use of_find_property()
and of_prop_next_u32() to read the two numbers.

	Arnd

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ