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: <6ED8E3B22081A4459DAC7699F3695FB7014B22B63A@SW-EX-MBX02.diasemi.com>
Date:	Fri, 15 May 2015 08:13:27 +0000
From:	"Opensource [Steve Twiss]" <stwiss.opensource@...semi.com>
To:	Guenter Roeck <linux@...ck-us.net>,
	"Opensource [Steve Twiss]" <stwiss.opensource@...semi.com>,
	LINUXKERNEL <linux-kernel@...r.kernel.org>,
	LINUXWATCHDOG <linux-watchdog@...r.kernel.org>,
	Wim Van Sebroeck <wim@...ana.be>
CC:	Alessandro Zummo <a.zummo@...ertech.it>,
	DEVICETREE <devicetree@...r.kernel.org>,
	David Dajun Chen <david.chen@...semi.com>,
	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	Ian Campbell <ijc+devicetree@...lion.org.uk>,
	Kumar Gala <galak@...eaurora.org>,
	LINUXINPUT <linux-input@...r.kernel.org>,
	Lee Jones <lee.jones@...aro.org>,
	Liam Girdwood <lgirdwood@...il.com>,
	Mark Brown <broonie@...nel.org>,
	"Mark Rutland" <mark.rutland@....com>,
	Pawel Moll <pawel.moll@....com>,
	RTCLINUX <rtc-linux@...glegroups.com>,
	Rob Herring <robh+dt@...nel.org>,
	Samuel Ortiz <sameo@...ux.intel.com>,
	Support Opensource <Support.Opensource@...semi.com>
Subject: RE: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver

Hi Guenter,

Thank you for your comments again,
Here are my responses.

Regards,
Steve

On 15 May 2015 03:13, Guenter Roeck 
> Subject: Re: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
> 

[...]

> > +static void da9062_apply_window_protection(struct da9062_watchdog
> *wdt)
> > +{
> > +	unsigned long delay =
> msecs_to_jiffies(DA9062_RESET_PROTECTION_MS);
> > +	unsigned long timeout = wdt->j_time_stamp + delay;
> > +	unsigned long now = jiffies;
> > +	unsigned int diff_ms;
> > +
> > +	/* if time-limit has not elapsed then wait for remainder */
> > +	if (time_before(now, timeout)) {
> > +		diff_ms = jiffies_to_msecs(timeout-now);
> > +		dev_dbg(wdt->hw->dev,
> > +			"Kicked too quickly. Delaying %u msecs\n", diff_ms);
> > +		msleep(diff_ms);
> > +	}
> > +
> > +	return;
> 
> Unnecessary return statement.
> 

Deleted.

> > +static unsigned int da9062_wdt_timeout_to_sel(unsigned int secs)
> > +{
> > +	unsigned int i;
> > +
> > +	for (i = DA9062_TWDSCALE_MIN; i <= DA9062_TWDSCALE_MAX; i++) {
> > +		if (wdt_timeout[i] >= secs)
> > +			return i;
> > +	}
> > +
> > +	return DA9062_TWDSCALE_MAX;
> > +}
> > +
> > +static int da9062_reset_watchdog_timer(struct da9062_watchdog *wdt)
> > +{
> > +	int ret;
> > +
> > +	da9062_apply_window_protection(wdt);
> > +
> > +	ret = regmap_update_bits(wdt->hw->regmap,
> > +			   DA9062AA_CONTROL_F,
> > +			   DA9062AA_WATCHDOG_MASK,
> > +			   DA9062AA_WATCHDOG_MASK);
> > +
> > +	da9062_set_window_start(wdt);
> > +
> > +	return ret;
> > +}
> > +
> > +static int da9062_wdt_update_timeout_register(struct da9062_watchdog *wdt,
> > +					      unsigned int regval)
> > +{
> > +	struct da9062 *chip = wdt->hw;
> > +	int ret;
> > +
> > +	ret = da9062_reset_watchdog_timer(wdt);
> > +	if (ret) {
> > +		dev_err(chip->dev, "Failed to ping the watchdog (err = %d)\n",
> > +			ret);
> 
> I am kind of torn about all this noisiness on error. Personally I would tend to
> ask people to let user space handle it, and not be that noisy in the kernel.
> 
> Wim, any guidance ?

At the time I thought it would be a really good idea to keep a debug message in. 
But -- this has been questioned several times and so I will remove.

> > +		return ret;
> > +	}
> > +
> > +	return regmap_update_bits(chip->regmap,
> > +				  DA9062AA_CONTROL_D,
> > +				  DA9062AA_TWDSCALE_MASK,
> > +				  regval);
> 
> ... and it is inconsistent - no error message here.
> 

Removed the dev_err() defined previously and therefore this makes this return
without an error message more consistent with the earlier parts of the function.
(no change needed)

 [...]

> > +static int da9062_wdt_stop(struct watchdog_device *wdd)
> > +{
> > +	struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd);
> > +	int ret;
> > +
> > +	ret = da9062_reset_watchdog_timer(wdt);
> > +	if (ret) {
> > +		dev_err(wdt->hw->dev, "Failed to ping the watchdog (err =
> %d)\n",
> > +			ret);
> > +		return ret;
> > +	}
> > +
> > +	ret = regmap_update_bits(wdt->hw->regmap,
> > +				 DA9062AA_CONTROL_D,
> > +				 DA9062AA_TWDSCALE_MASK,
> > +				 DA9062_TWDSCALE_DISABLE);
> > +	if (ret)
> > +		dev_alert(wdt->hw->dev, "Watchdog failed to stop (err =
> %d)\n",
> > +			  ret);
> 
> .. and now we have an alert. Hmm..

.. I've replaced it with a dev_err()

> > +
> > +	return ret;
> > +}
> > +
> > +static int da9062_wdt_ping(struct watchdog_device *wdd)
> > +{
> > +	struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd);
> > +	int ret;
> > +
> > +	dev_dbg(wdt->hw->dev, "watchdog ping\n");
> > +
> 
> Is this really valuable enough to keep in the code ?
> 

Removed also.

> > +	ret = da9062_reset_watchdog_timer(wdt);
> > +	if (ret)
> > +		dev_err(wdt->hw->dev, "Failed to ping the watchdog (err =
> %d)\n",
> > +			ret);
> > +
> > +	return ret;
> > +}
> > +

[...]

> > +
> > +/* E_WDG_WARN interrupt handler */
> > +static irqreturn_t da9062_wdt_wdg_warn_irq_handler(int irq, void *data)
> > +{
> > +	struct da9062_watchdog *wdt = data;
> > +
> > +	dev_notice(wdt->hw->dev, "Watchdog timeout warning trigger.\n");
> > +	return IRQ_HANDLED;
> > +}
> > +

[...]

> > +static int da9062_wdt_probe(struct platform_device *pdev)
> > +{
> > +	int ret;
> > +	struct da9062 *chip;
> > +	struct da9062_watchdog *wdt;
> > +	int irq;
> > +
> > +	chip = dev_get_drvdata(pdev->dev.parent);
> > +	if (!chip)
> > +		return -EINVAL;
> > +
> > +	wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL);
> > +	if (!wdt)
> > +		return -ENOMEM;
> > +
> > +	wdt->hw = chip;
> > +
> > +	wdt->wdtdev.info = &da9062_watchdog_info;
> > +	wdt->wdtdev.ops = &da9062_watchdog_ops;
> > +	wdt->wdtdev.min_timeout = DA9062_WDT_MIN_TIMEOUT;
> > +	wdt->wdtdev.max_timeout = DA9062_WDT_MAX_TIMEOUT;
> > +	wdt->wdtdev.timeout = DA9062_WDG_DEFAULT_TIMEOUT;
> > +	wdt->wdtdev.status = WATCHDOG_NOWAYOUT_INIT_STATUS;
> > +
> > +	watchdog_set_drvdata(&wdt->wdtdev, wdt);
> > +	dev_set_drvdata(&pdev->dev, wdt);
> > +
> > +	irq = platform_get_irq_byname(pdev, "WDG_WARN");
> > +	if (irq < 0) {
> > +		dev_err(wdt->hw->dev, "Failed to get IRQ.\n");
> > +		ret = irq;
> > +		goto error;
> 
> Just return; the label does not serve a useful purpose. Same for the other
> goto statements below.

Agreed. This is changed now.

> Also, is the interrupt mandatory ? All it does is to display a message.
> Looks very optional to me.

It is a place holder for something more application specific. 
I could remove it, but I figured it would just get re-added when somebody takes the
driver and modifies it for their needs.

If this is a problem however, it can go.
Please advise ..

> 
> > +	}
> > +
> > +	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
> > +			   da9062_wdt_wdg_warn_irq_handler,
> > +			    IRQF_TRIGGER_LOW | IRQF_ONESHOT |
> IRQF_SHARED,
> > +			   "WDG_WARN", wdt);
> > +	if (ret) {
> > +		dev_err(wdt->hw->dev,
> > +			"Failed to request watchdog device IRQ.\n");
> > +		goto error;
> > +	}
> > +
> > +	ret = watchdog_register_device(&wdt->wdtdev);
> > +	if (ret < 0) {
> > +		dev_err(wdt->hw->dev,
> > +			"watchdog registration incomplete (%d)\n", ret);
> 
> incomplete ? Should that be "failed" ?

Sure. Changed the dev_err()

[...]

> > +static struct platform_driver da9062_wdt_driver = {
> > +	.probe = da9062_wdt_probe,
> > +	.remove = da9062_wdt_remove,
> > +	.driver = {
> > +		.name = "da9062-watchdog",
> > +	},
> > +};
> > +module_platform_driver(da9062_wdt_driver);
> > +
> > +MODULE_AUTHOR("S Twiss <stwiss.opensource@...semi.com>");
> > +MODULE_DESCRIPTION("WDT device driver for Dialog DA9062");
> > +MODULE_LICENSE("GPL");
> > +MODULE_ALIAS("platform: da9062-watchdog");
> >
> Normally I don't see a space between "platform" and the driver name.
> Does this work ?

Removed the space

Regards,
Steve
--
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