Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753078AbbH1V6x (ORCPT ); Fri, 28 Aug 2015 17:58:53 -0400 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:24988 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752818AbbH1V6v (ORCPT ); Fri, 28 Aug 2015 17:58:51 -0400 X-IronPort-AV: E=Sophos;i="5.17,427,1437462000"; d="scan'208";a="73702759" From: Justin Chen To: CC: , , , Justin Chen Subject: [PATCH] watchdog_dev: Use device tree alias for naming watchdogs Date: Fri, 28 Aug 2015 14:58:06 -0700 Message-ID: <1440799086-14683-1-git-send-email-justinpopo6@gmail.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1674 Lines: 61 Currently there is no way to easily differentiate multiple watchdog devices. The watchdogs are named by the order they are probed. 1st probed watchdog: /dev/watchdog0 2nd probed watchdog: /dev/watchdog1 ... This change uses the alias of the watchdog device node for the name of the watchdog. aliases { watchdog0 = "/...../...." watchdog3 = "/..../....." watchdog2 = "/..../....." ... } This will translate to... /dev/watchdog0 /dev/watchdog3 /dev/watchdog2 Signed-off-by: Justin Chen --- drivers/watchdog/watchdog_dev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 6aaefba..52b1f0b 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -41,6 +41,7 @@ #include /* For handling misc devices */ #include /* For __init/__exit/... */ #include /* For copy_to_user/put_user/... */ +#include #include "watchdog_core.h" @@ -522,7 +523,13 @@ static struct miscdevice watchdog_miscdev = { int watchdog_dev_register(struct watchdog_device *watchdog) { - int err, devno; + int err, devno, ret; + + if (watchdog->parent) { + ret = of_alias_get_id(watchdog->parent->of_node, "watchdog"); + if (ret >= 0) + watchdog->id = ret; + } if (watchdog->id == 0) { old_wdd = watchdog; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/