[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a1e96682-4eb5-486e-97bf-472634642553@classfun.cn>
Date: Fri, 6 Sep 2024 21:41:30 +0800
From: Junhao Xie <bigfoot@...ssfun.cn>
To: Guenter Roeck <linux@...ck-us.net>
Cc: devicetree@...r.kernel.org, linux-hwmon@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-leds@...r.kernel.org,
linux-pm@...r.kernel.org, linux-rtc@...r.kernel.org,
linux-watchdog@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org, Jean Delvare <jdelvare@...e.com>,
Guenter Roeck <linux@...ck-us.net>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, "Conor Dooley,"
<conor+dt@...nel.org>, Pavel Machek <pavel@....cz>,
Lee Jones <lee@...nel.org>, Sebastian Reichel <sre@...nel.org>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Wim Van Sebroeck <wim@...ux-watchdog.org>, Heiko Stuebner <heiko@...ech.de>,
Chukun Pan <amadeus@....edu.cn>, Junhao Xie <bigfoot@...ssfun.cn>
Subject: Re: [PATCH 3/9] watchdog: Add Photonicat PMU watchdog driver
On 2024/9/6 19:52, Guenter Roeck wrote:
> On 9/6/24 02:36, Junhao Xie wrote:
>> This driver provides access to Photonicat PMU watchdog functionality.
>>
[...]
>> +
>> +struct pcat_watchdog {
>> + struct device *dev;
>
> I don't see what this is used for.
I used to use this for logging, but now they are gone, I will delete it.
>
[...]
>> +
>> +static int pcat_wdt_setup(struct pcat_watchdog *data, int timeout)
>> +{
>> + int ret;
>> + u8 time = 0;
>
> Unnecessary initialization.
>
>> + u8 times[3] = { 60, 60, 0 };
>> +
>> + time = MIN(255, MAX(0, timeout));
>> +
>> + ret = pcat_pmu_write_data(data->pmu, PCAT_CMD_WATCHDOG_TIMEOUT_SET,
>> + times, sizeof(times));
>
> Where does this actually send the timeout to the chip ?
>
I forgot to fill in timeout into times[2] during refactoring process, I will fix it.
>> + if (!ret)
[...]>> +
>> +static int pcat_wdt_set_timeout(struct watchdog_device *wdev, unsigned int val)
>> +{
>> + int ret = 0;
>> + struct pcat_watchdog *data = watchdog_get_drvdata(wdev);
>> +
>> + data->timeout = val;
>
> This needs to store 'timeout' in wdev. Storing it locally is unnecessary.
>
>> + if (data->started)
>> + ret = pcat_wdt_setup(data, data->timeout);
>
> This is misleading because it would permit setting the timeout to
> 0 when the watchdog isn't running, and then when the watchdog is started
> it would not really start it. The code should not use a local "started"
> variable but call watchdog_active(). It should also not accept "0"
> as a valid timeout.
>
I will fix the pcat_wdt_set_timeout.
>> +
[...]
>> +
>> + watchdog->dev = dev;
>> + watchdog->pmu = dev_get_drvdata(dev->parent);
>> + watchdog->wdd.info = &pcat_wdt_info;
>> + watchdog->wdd.ops = &pcat_wdt_ops;
>> + watchdog->wdd.timeout = 60;
>> + watchdog->wdd.max_timeout = U8_MAX;
>> + watchdog->wdd.min_timeout = 0;
>
> This effectively lets the user ... kind of ... stop the watchdog
> by setting the timeout to 0. This is not acceptable.
>
>> + watchdog->wdd.parent = dev;
>> +
>> + watchdog_stop_on_reboot(&watchdog->wdd);
>> + watchdog_set_drvdata(&watchdog->wdd, watchdog);
>> + platform_set_drvdata(pdev, watchdog);
>> +
> No watchdog_init_timeout() ?
Thanks for your correction, I will fix it.
>
>> + return devm_watchdog_register_device(dev, &watchdog->wdd);
[...]
>> +MODULE_LICENSE("GPL");
>
Thanks for your review, I will fix all problems in next version!
Best regards,
Junhao
Powered by blists - more mailing lists