mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/3] misc: add bootcount framework
Date: Fri, 20 Sep 2013 06:46:15 +0200	[thread overview]
Message-ID: <1379652377-20276-1-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20130920044518.GB1137@ns203013.ovh.net>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/misc/Kconfig     |  3 +++
 drivers/misc/Makefile    |  1 +
 drivers/misc/bootcount.c | 24 ++++++++++++++++++++++++
 include/bootcount.h      | 21 +++++++++++++++++++++
 4 files changed, 49 insertions(+)
 create mode 100644 drivers/misc/bootcount.c
 create mode 100644 include/bootcount.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 606490b..a972ba4 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -15,4 +15,7 @@ config JTAG
 	help
 	  Controls JTAG chains connected to I/O pins
 
+config BOOTCOUNT
+	bool
+
 endif # MISC_DEVICES
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b085577..fa668c1 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_JTAG)		+= jtag.o
+obj-$(CONFIG_BOOTCOUNT)		+= bootcount.o
diff --git a/drivers/misc/bootcount.c b/drivers/misc/bootcount.c
new file mode 100644
index 0000000..0205d00
--- /dev/null
+++ b/drivers/misc/bootcount.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPLv2 Only
+ */
+
+#include <common.h>
+#include <init.h>
+#include <bootcount.h>
+
+static struct bootcount_driver *bd;
+
+void bootcount_register(struct bootcount_driver *drv)
+{
+	bd = drv;
+}
+
+static int bootcount_inc(void)
+{
+	if (bd)
+		bd->inc(bd);
+	return 0;
+}
+late_initcall(bootcount_inc);
diff --git a/include/bootcount.h b/include/bootcount.h
new file mode 100644
index 0000000..16e61c5
--- /dev/null
+++ b/include/bootcount.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPLv2 Only
+ */
+
+#ifndef __BOOTCOUNT_H__
+#define __BOOTCOUNT_H__
+
+struct bootcount_driver {
+	void (*inc)(struct bootcount_driver *d);
+	void *priv;
+};
+
+#ifdef CONFIG_BOOTCOUNT
+void bootcount_register(struct bootcount_driver *d);
+#else
+static inline void bootcount_register(struct bootcount_driver *d) {}
+#endif
+
+#endif /* __BOOTCOUNT_H__ */
-- 
1.8.4.rc1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-09-20  4:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-20  4:45 [PATCH 0/3] introduce bootcount support Jean-Christophe PLAGNIOL-VILLARD
2013-09-20  4:46 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-09-20  4:46   ` [PATCH 2/3] misc: add somfy " Jean-Christophe PLAGNIOL-VILLARD
2013-09-20  4:46   ` [PATCH 3/3] animeo_ip: add " Jean-Christophe PLAGNIOL-VILLARD
2013-09-20  7:23   ` [PATCH 1/3] misc: add bootcount framework Sascha Hauer
2013-09-20  8:01     ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 12:39       ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379652377-20276-1-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox