Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp375782pxu; Thu, 7 Jan 2021 07:15:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJx713nULv4Ca7M0XFT4OvAGN5uNpNjsCqUDJW2Om0ZoM1K1/y+CF9t8p+Gj8/RLMLYBkqXY X-Received: by 2002:a17:906:4985:: with SMTP id p5mr6672516eju.513.1610032536066; Thu, 07 Jan 2021 07:15:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610032536; cv=none; d=google.com; s=arc-20160816; b=kdqLFB0miKa8PQJTlYTwbSzLTYR1VDnFqMzWSQ0wLShvOjiddtm7ghjTvATpukjRAu c5MItJpNf5D+L0f+AxS7aJWiJi6pH9aZZTTNci03COsvp4lfg3DX3/AAHjymmeXOYSxw JDF/XKY/gfWyWmfDo/xpBzl0iPEp3SOFeDsSTjg3tRNorL2425l2yYmLhv1KK3gWkmDr dPSpAxKsHb6ZUkC+8HC/tfGV8xybgRw212XPYORteen9dVPW+JyguD4Xrs/0N3DvKYU2 1Y2n2UyRB5RWGqmfBET2e0ZvzT3a+7PuJCJSYJcxgixECkL8W7npvs5QwvG41OYkBFf4 Fmlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :dkim-signature; bh=oS6XTzxTGJynF/v+3oQRJMAaz6k+ys04IiLQqnxFN1Q=; b=L42Azmp3pHrJzjmbEL0+USqodcty2I9STVcNwjD37pxJlUc4wW87zE70eMIMbWhTLi yoxOqsHY23XQI/OwQct7RSByXiDkF6qbai44La5awm+SMThurXK1dgwvDzVWhO9CYumN ePKN+xpJ9SoRG3hznEwngi9K/wG5CyzztMtiWooRA0JCsWepoqhmqI3yBcru0qJERDln +AwXrunt8jfpATbiV4udrmlmEJ3XHmUVK4U/TicYkAxiLs6XeI4Ypu5bC0iBU/I6I5/h L04cIhcbGaS8paezQwH6m38GvqwAYIyy8laqgUCPX/hsYCr6zqLRfmqm7cLp8VRbSUzR QX4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fzEwgL1s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si2307979edm.451.2021.01.07.07.15.11; Thu, 07 Jan 2021 07:15:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fzEwgL1s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728282AbhAGPM4 (ORCPT + 99 others); Thu, 7 Jan 2021 10:12:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726503AbhAGPMz (ORCPT ); Thu, 7 Jan 2021 10:12:55 -0500 Received: from mail-oo1-xc2d.google.com (mail-oo1-xc2d.google.com [IPv6:2607:f8b0:4864:20::c2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4442BC0612F5; Thu, 7 Jan 2021 07:12:15 -0800 (PST) Received: by mail-oo1-xc2d.google.com with SMTP id q6so1634883ooo.8; Thu, 07 Jan 2021 07:12:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=oS6XTzxTGJynF/v+3oQRJMAaz6k+ys04IiLQqnxFN1Q=; b=fzEwgL1st6Mf4afnR79dA+JA4m41foeuxy8zJ9pdLFnTAyuBA+EG4QiC/8/f6G2HF5 BAOgcsArSfR80+V63bd11/RYYkJF33ZIlr1UbSEh/VIqaPFZLZ5yc9R2foCuVqpB0yHd htCDX4lP/8rVgG7qgbTrfeCgS8bK+GsjjRF8SjAiG6tb036z6fkqk6gh5f1k5EHvjxzj +rLVKLWvpx9UJ/4DitY91j/sGrjoJKLpfv39EKb/b/16LovbP7PkpiD71+b1PlGOxB4p srAw3gQpB+9zGJn3HdtMhFLbdihPgbb1ezIw0SiJ/UC1bjmHYZZWwh1kNqVOGuUKaT3r EsJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=oS6XTzxTGJynF/v+3oQRJMAaz6k+ys04IiLQqnxFN1Q=; b=hoExi/ndiGS8kzJCl7b1lL3sc1d7b/4mT509Qzno1Lwl4/qv9dZKRMm4kSpQy9eDl3 a5Bt9TldC/JZqbndcPGettdeau8Pimi02db3PeBHSJUSq/nYXrwwhJV5A90dGk2+uNwr PdOD7EQaP4G+rxnGyxASmjQsKvfuciqdIQFR5yIRdnrUCex3Nj74umq0mB4SliEHIN5q zxEaLQy172WCX9PNJ7HOTQOhS2y1q9NanLntfK3m9Jc9hVBM+qyCq/3UEa9MaxFOhBYf kMs+F7dmN6hAiZjHiwxYp2U5++gsrq/9aadXPcO/LtCAPvAmZYAFrDKg7ukR6XwKDQIU R6sg== X-Gm-Message-State: AOAM532ySiKGruVACOEIQ6pUylzgPBKJdbaNu1mRksTYOfI+u8IZmu6y +WFtgg2wFKMXM1uQzcGt0rtmoG1iaTI= X-Received: by 2002:a4a:901a:: with SMTP id i26mr1416333oog.42.1610032334378; Thu, 07 Jan 2021 07:12:14 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id r8sm1176479oth.20.2021.01.07.07.12.12 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Jan 2021 07:12:13 -0800 (PST) Sender: Guenter Roeck Date: Thu, 7 Jan 2021 07:12:11 -0800 From: Guenter Roeck To: Matti Vaittinen Cc: mazziesaccount@gmail.com, Wim Van Sebroeck , linux-power@fi.rohmeurope.com, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] watchdog: bd70528: don't crash if WDG is confiured with BD71828 Message-ID: <20210107151211.GA13040@roeck-us.net> References: <671ac57ad53ab1614da7fe9a3d0f78bdb5b51fda.1610001365.git.matti.vaittinen@fi.rohmeurope.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <671ac57ad53ab1614da7fe9a3d0f78bdb5b51fda.1610001365.git.matti.vaittinen@fi.rohmeurope.com> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 07, 2021 at 08:37:03AM +0200, Matti Vaittinen wrote: > If config for BD70528 watchdog is enabled when BD71828 or BD71815 > are used the RTC module will issue call to BD70528 watchdog with > NULL data. Ignore this call and don't crash. > > Signed-off-by: Matti Vaittinen I really think this should be handled in the calling code. Also, I am curious how this is supposed to work. The code is called with ret = bd70528_wdt_set(r->parent, new_state & BD70528_WDT_STATE_BIT, old_state); from bd70528_set_rtc_based_timers(). That same function subsequently calls bd70528_set_elapsed_tmr() with the same parameter, and that parameter is dereferenced in bd70528_set_elapsed_tmr() without checking. Conceptually, it should not be necessary to determine at compile-time which of the chips is in the system. It should be posible to compile a single kernel which supports all chips. Guenter > --- > drivers/watchdog/bd70528_wdt.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/watchdog/bd70528_wdt.c b/drivers/watchdog/bd70528_wdt.c > index 0170b37e6674..fde242b8a4a6 100644 > --- a/drivers/watchdog/bd70528_wdt.c > +++ b/drivers/watchdog/bd70528_wdt.c > @@ -49,6 +49,21 @@ int bd70528_wdt_set(struct rohm_regmap_dev *data, int enable, int *old_state) > u8 wd_ctrl_arr[3] = { WD_CTRL_MAGIC1, WD_CTRL_MAGIC2, 0 }; > u8 *wd_ctrl = &wd_ctrl_arr[2]; > > + /* > + * BD71828 and BD71815 use same RTC driver as BD70528. > + * BD71815 and BD71828 do not need MFD data as they do not share > + * RTC counter with watchdog. The BD70528 watchdog should not be > + * compiled in with BD71815 or BD71828 and the stub implementation > + * for the bd70528_wdt_set should be provided instead. > + * > + * If one compiles this watchdog with BD71828 or BD71815 - the call > + * from RTC may get here and the data pointer is NULL. In that case, > + * warn and go out. > + */ > + if (!data) { > + pr_warn("BD70528_WATCHDOG misconfigured\n"); > + return 0; > + } > ret = regmap_read(bd70528->chip.regmap, BD70528_REG_WDT_CTRL, &tmp); > if (ret) > return ret; > > base-commit: 2c85ebc57b3e1817b6ce1a6b703928e113a90442 > -- > 2.25.4 > > > -- > Matti Vaittinen, Linux device drivers > ROHM Semiconductors, Finland SWDC > Kiviharjunlenkki 1E > 90220 OULU > FINLAND > > ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ > Simon says - in Latin please. > ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ > Thanks to Simon Glass for the translation =]