Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1119068ybi; Sat, 8 Jun 2019 02:59:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaWlBK+FSLOs0rJFCyrjnrPqlX2hV0mEPSBPYtUX9ZtBW9rF7zwOyiA7bKuvVHrIldEBqa X-Received: by 2002:a17:902:ac85:: with SMTP id h5mr53352715plr.198.1559987954033; Sat, 08 Jun 2019 02:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559987954; cv=none; d=google.com; s=arc-20160816; b=gboLpk7TQxuY40qf3DuWMGyP5x/40msTymz5ePvtCk6t6fJavhQmGUdnxy0gYTXLMb a2QHv1CjODsu3KXQSgw9FZIpKpeMpiEssDjKyw0VBYe5Q5+HQThez5VVIXNSt4xh4sZu g7CiTtgqPxB1OpTbrMN+F0iJuwDvV2xny6kPnvtHajEL8y4EAxebrMs5xQUKIaRYMkOk Pqnm8dzbQqGvGE6NOmPN0av0lyXhCPHUZCbb+MkKLf3vpAkeYrrr5YXLGwA0yWucm9X1 W9VUfysP3rAuWF7bfbG6KjLYKMS/yzNMbbGZ1x2VOopVvT5IiuvDkR7z5Q0fznnZx8Zy zw4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date :dkim-signature; bh=IO8k7jeyiIdr3zv59ZQZDouOp0tCLQ64fYlPZZrzNHk=; b=Fs4id4XDBhrqdt9EF6JhQ45Z7zI7tP7UEsTTnSP94ndSYKQklopL2k6nmdPwaogtLT C4T51gRwp3nEHr3ZigjUM3q874AzJf1YM+QamybAyiDefK3Nu523e9MYJEBJJPv/oFtb qEmpKG94/kGvQXuKeteV+gmvzenC2kjAGOhcvb1xMlvHtmGjXd954zJQcDEJUWx4gouF 4Pq1F3uaiHzZdk4Ovm07Zdq54TvnZZK0WAFGIAiZQX/WQAAm+Vni2ecYNK6BhfK79Idb FV+n/+zwvWlgc4vguZwgpbyzpsTXB8fG6HHxqgXKoFARu9FcTOjOv0goin/61GToDHix 2WFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=F9nlhr+6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cd16si4734188plb.72.2019.06.08.02.58.55; Sat, 08 Jun 2019 02:59:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=F9nlhr+6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726777AbfFHJ5I (ORCPT + 99 others); Sat, 8 Jun 2019 05:57:08 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:56056 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbfFHJ5I (ORCPT ); Sat, 8 Jun 2019 05:57:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1559987825; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IO8k7jeyiIdr3zv59ZQZDouOp0tCLQ64fYlPZZrzNHk=; b=F9nlhr+6wcW0Fes6Ur6203SFkh1wfrkvV8qyMSJKHiLQqEcuW42aTRGPWzbGBSGsg0syUE 0m2v6v1na/QecA0u+dTw3kVXudnmg5+N9GAxdyg9r3GrtWolr0fy6zjPbUUF2rgTJJjct5 +zDacUXICPjtmChxFR9030qOGwQHhJc= Date: Sat, 08 Jun 2019 11:57:01 +0200 From: Paul Cercueil Subject: Re: [PATCH v2 4/4] watchdog: jz4740: Make probe function __init_or_module To: Christophe Leroy Cc: Guenter Roeck , Wim Van Sebroeck , od@zcrc.me, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: <1559987821.1815.0@crapouillou.net> In-Reply-To: <0dc0fd0a-54fc-5d70-af78-1874b5ece418@c-s.fr> References: <20190607162429.17915-1-paul@crapouillou.net> <20190607162429.17915-5-paul@crapouillou.net> <0dc0fd0a-54fc-5d70-af78-1874b5ece418@c-s.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christophe, Le sam. 8 juin 2019 =E0 9:51, Christophe Leroy =20 a =E9crit : > Hi Paul, >=20 > Le 07/06/2019 =E0 18:24, Paul Cercueil a =E9crit : >> This allows the probe function to be dropped after the kernel=20 >> finished >> its initialization, in the case where the driver was not compiled as=20 >> a >> module. >=20 > I'm not sure that's what __init_or_module flag does. >=20 > As far as I understand, this flag makes the function being dropped=20 > only when the kernel is built without modules support, ie without=20 > CONFIG_MODULES. See=20 > https://elixir.bootlin.com/linux/latest/source/include/linux/module.h#L14= 5 So it doesn't depend on the driver being built-in or compiled as a=20 module? > In addition, I'm not sure you can simply define a probe function as=20 > __init. What if someone tries to unbind and rebind the device through=20 > sysfs for instance ? Ouch. I feel stupid now. > It seems there is a special function called __platform_driver_probe()=20 > for registering devices when the probe function is to be in __init,=20 > see=20 > https://elixir.bootlin.com/linux/latest/source/drivers/base/platform.c#L6= 84 Yes, but only usable by drivers that won't defer probe, and it removes=20 the bind/unbind attributes from sysfs, so it shouldn't be used for non-critical drivers, I think. > Christophe >=20 >>=20 >> Signed-off-by: Paul Cercueil >> --- >>=20 >> Notes: >> v2: New patch >>=20 >> drivers/watchdog/jz4740_wdt.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >>=20 >> diff --git a/drivers/watchdog/jz4740_wdt.c=20 >> b/drivers/watchdog/jz4740_wdt.c >> index 7519d80c5d05..2061788c1939 100644 >> --- a/drivers/watchdog/jz4740_wdt.c >> +++ b/drivers/watchdog/jz4740_wdt.c >> @@ -157,7 +157,7 @@ static const struct of_device_id=20 >> jz4740_wdt_of_matches[] =3D { >> MODULE_DEVICE_TABLE(of, jz4740_wdt_of_matches); >> #endif >> =7F-static int jz4740_wdt_probe(struct platform_device *pdev) >> +static int __init_or_module jz4740_wdt_probe(struct platform_device=20 >> *pdev) >> { >> struct device *dev =3D &pdev->dev; >> struct jz4740_wdt_drvdata *drvdata; >>=20 =