From patchwork Fri Feb 8 15:12:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 219182 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id B5A512C007E for ; Sat, 9 Feb 2013 02:15:55 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0A6F34A0C7; Fri, 8 Feb 2013 16:15:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tChe2Bgl83Ql; Fri, 8 Feb 2013 16:15:42 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7B7754A0FE; Fri, 8 Feb 2013 16:14:20 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0C9D54A0EE for ; Fri, 8 Feb 2013 16:14:08 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YDB2bZa8GQ9P for ; Fri, 8 Feb 2013 16:14:05 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-wg0-f73.google.com (mail-wg0-f73.google.com [74.125.82.73]) by theia.denx.de (Postfix) with ESMTPS id B931A4A0F4 for ; Fri, 8 Feb 2013 16:13:51 +0100 (CET) Received: by mail-wg0-f73.google.com with SMTP id dq12so265558wgb.4 for ; Fri, 08 Feb 2013 07:13:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=Y4U1hQ9BLHWr6HlOxOD4UsoBOPscF0MKAYxiUC+7RIo=; b=G0LjUKBiVl6a4FCbR3bzKNN3K5/pvcvch+Lj/+5a8qmBQIs9ysh2pr/xfI+/IcaOW2 wHNv/QaK1xSCMfBiHqrAS4FnxM33JUxZcTfHEuVd2hwqUL9/vXogJ2qKb4DO7Tr4vWBr NnjoyDDSQWRfPe5fazbt/GUXN4LvA6xpyKXAe3mKzeeXURIHZpd2s55jNVRC1Rws/7W2 SS05ptLr7lxhlZpVZAPLl8sBOTKS6vR2lNHmzsmzqycRdt+z/5Xegb/pqx2/fUfY66QE 6nVB3i1O/JwwaQLe8CEzcHHldujvil41LA1VnqOiZAuN66hmlyFXwAA+VHePaFZqScQT dZyA== X-Received: by 10.14.221.196 with SMTP id r44mr5379149eep.1.1360336431496; Fri, 08 Feb 2013 07:13:51 -0800 (PST) Received: from corp2gmr1-2.eem.corp.google.com (corp2gmr1-2.eem.corp.google.com [172.25.138.117]) by gmr-mx.google.com with ESMTPS id 6si4487648eej.0.2013.02.08.07.13.51 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Fri, 08 Feb 2013 07:13:51 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by corp2gmr1-2.eem.corp.google.com (Postfix) with ESMTP id 11C0D1E41B3; Fri, 8 Feb 2013 07:13:51 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 529E3160B05; Fri, 8 Feb 2013 07:13:50 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Fri, 8 Feb 2013 07:12:03 -0800 Message-Id: <1360336339-10703-8-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1360336339-10703-1-git-send-email-sjg@chromium.org> References: <1360336339-10703-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQnYcSiABmeuf8d8XGsO1bXxAHzyoGHnJTdpT7qc+gJAgS9UkBo7YlRtuNbkba1rlSBsXE9wjJZ4S7p/YaWP/VYqB7pxa+afgXzmp+DzJgXWs9Rj1jw2RUC+BK1/2bcrMiVLWI6/b2H2sSMSUIkz81SuI11YbxfBZVn28zQ3aA0q6B08bkJQ5SA6ytLCVS6nPLY6XN91 Cc: Graeme Russ , Tom Rini , Vadim Bendebury Subject: [U-Boot] [PATCH v5 07/23] Introduce a basic initcall implementation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This library supports calling a list of functions one after the other. It is intended that we move to a more powerful initcall implementation as proposed by Graeme Russ . For now, this allows us to do the basics. Signed-off-by: Simon Glass --- Changes in v5: - Add debug() code to initcalls - Update copyright on initcalls Changes in v4: None Changes in v3: None Changes in v2: None include/initcall.h | 25 +++++++++++++++++++++++++ lib/Makefile | 1 + lib/initcall.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 include/initcall.h create mode 100644 lib/initcall.c diff --git a/include/initcall.h b/include/initcall.h new file mode 100644 index 0000000..9e54fa5 --- /dev/null +++ b/include/initcall.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +typedef int (*init_fnc_t)(void); + +int initcall_run_list(init_fnc_t init_sequence[]); diff --git a/lib/Makefile b/lib/Makefile index 86ca1a6..1bfd3ee 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -44,6 +44,7 @@ COBJS-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o COBJS-$(CONFIG_GZIP) += gunzip.o COBJS-$(CONFIG_GZIP_COMPRESSED) += gzip.o COBJS-y += hashtable.o +COBJS-y += initcall.o COBJS-$(CONFIG_LMB) += lmb.o COBJS-y += ldiv.o COBJS-$(CONFIG_MD5) += md5.o diff --git a/lib/initcall.c b/lib/initcall.c new file mode 100644 index 0000000..fc91bf6 --- /dev/null +++ b/lib/initcall.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013 The Chromium OS Authors. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include + +int initcall_run_list(init_fnc_t init_sequence[]) +{ + init_fnc_t *init_fnc_ptr; + + for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { + debug("initcall: %p\n", *init_fnc_ptr); + if ((*init_fnc_ptr)()) { + debug("initcall sequence %p failed at call %p\n", + init_sequence, *init_fnc_ptr); + return -1; + } + } + return 0; +}