mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/4 v2] introduce bootcount support
@ 2013-09-21  6:45 Jean-Christophe PLAGNIOL-VILLARD
  2013-09-21  6:46 ` [PATCH 1/4] misc: add bootcount framework Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-21  6:45 UTC (permalink / raw)
  To: barebox

Hi,

	v2:
	move count params to framework

	add basic register driver

	when you want to detect boot faillure you need to count the number of
	boot and if the linux boot correctly it will clear it

The following changes since commit fe4117357f8f304a08b957eded8ede9db8dafdcf:

  Add missing dependency ENV_HANDLING for OF_BAREBOX_DRIVER option (2013-09-18 10:24:29 +0200)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/bootcount

for you to fetch changes up to aca14c8908c1e33aa9b3d7847765ebf04d963d54:

  animeo_ip: add bootcount support (2013-09-21 14:38:41 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (4):
      misc: add bootcount framework
      bootcount: add simple register support
      bootcount: add somfy bootcount support
      animeo_ip: add bootcount support

 arch/arm/boards/animeo_ip/init.c     |   2 ++
 arch/arm/configs/animeo_ip_defconfig |   2 ++
 drivers/misc/Kconfig                 |   2 ++
 drivers/misc/Makefile                |   1 +
 drivers/misc/bootcount/Kconfig       |  22 +++++++++++++++++
 drivers/misc/bootcount/Makefile      |   3 +++
 drivers/misc/bootcount/core.c        |  54 +++++++++++++++++++++++++++++++++++++++++
 drivers/misc/bootcount/register.c    | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/bootcount/somfy.c       | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/bootcount.h                  |  31 ++++++++++++++++++++++++
 10 files changed, 352 insertions(+)
 create mode 100644 drivers/misc/bootcount/Kconfig
 create mode 100644 drivers/misc/bootcount/Makefile
 create mode 100644 drivers/misc/bootcount/core.c
 create mode 100644 drivers/misc/bootcount/register.c
 create mode 100644 drivers/misc/bootcount/somfy.c
 create mode 100644 include/bootcount.h

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] misc: add bootcount framework
  2013-09-21  6:45 [PATCH 0/4 v2] introduce bootcount support Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-21  6:46 ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-21  6:46   ` [PATCH 2/4] bootcount: add simple register support Jean-Christophe PLAGNIOL-VILLARD
                     ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-21  6:46 UTC (permalink / raw)
  To: barebox

The bootcount is always how many time the system start.
To determine since when, this will depend on the driver implementation
and your hardware feature.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/misc/Kconfig            |  2 ++
 drivers/misc/Makefile           |  1 +
 drivers/misc/bootcount/Kconfig  | 12 +++++++++
 drivers/misc/bootcount/Makefile |  1 +
 drivers/misc/bootcount/core.c   | 54 +++++++++++++++++++++++++++++++++++++++++
 include/bootcount.h             | 31 +++++++++++++++++++++++
 6 files changed, 101 insertions(+)
 create mode 100644 drivers/misc/bootcount/Kconfig
 create mode 100644 drivers/misc/bootcount/Makefile
 create mode 100644 drivers/misc/bootcount/core.c
 create mode 100644 include/bootcount.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 606490b..2532444 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -15,4 +15,6 @@ config JTAG
 	help
 	  Controls JTAG chains connected to I/O pins
 
+source "drivers/misc/bootcount/Kconfig"
+
 endif # MISC_DEVICES
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b085577..6d94db0 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_JTAG)		+= jtag.o
+obj-$(CONFIG_BOOTCOUNT)		+= bootcount/
diff --git a/drivers/misc/bootcount/Kconfig b/drivers/misc/bootcount/Kconfig
new file mode 100644
index 0000000..77a1140
--- /dev/null
+++ b/drivers/misc/bootcount/Kconfig
@@ -0,0 +1,12 @@
+#
+# Boot Count devices
+#
+
+menuconfig BOOTCOUNT
+	bool "Boot Count"
+	help
+	  Add support for boot count devices
+
+if BOOTCOUNT
+
+endif # BOOTCOUNT
diff --git a/drivers/misc/bootcount/Makefile b/drivers/misc/bootcount/Makefile
new file mode 100644
index 0000000..3c02ba1
--- /dev/null
+++ b/drivers/misc/bootcount/Makefile
@@ -0,0 +1 @@
+obj-y		+= core.o
diff --git a/drivers/misc/bootcount/core.c b/drivers/misc/bootcount/core.c
new file mode 100644
index 0000000..91274b3
--- /dev/null
+++ b/drivers/misc/bootcount/core.c
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+static struct device_d bootcount_device = {
+	.name = "bootcount",
+	.id = DEVICE_ID_SINGLE,
+};
+
+static int bootcount_count_set(struct param_d *p, void *priv)
+{
+	struct bootcount_driver *bd = priv;
+
+	bd->set(bd);
+
+	return 0;
+}
+
+int register_bootcount(struct bootcount_driver *drv)
+{
+	if (bd)
+		return -EBUSY;
+
+	bootcount_device.parent = drv->parent;
+	register_device(&bootcount_device);
+
+	bd = drv;
+
+	bd->dev = &bootcount_device;
+	dev_add_param_int(bd->dev, "count", bootcount_count_set,
+				NULL, &bd->count, "%d", bd);
+
+	return 0;
+}
+
+static int bootcount_inc(void)
+{
+	if (!bd)
+		return 0;
+
+	bd->count++;
+	bd->set(bd);
+
+	return 0;
+}
+late_initcall(bootcount_inc);
diff --git a/include/bootcount.h b/include/bootcount.h
new file mode 100644
index 0000000..2ef36b5
--- /dev/null
+++ b/include/bootcount.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPLv2 Only
+ */
+
+#ifndef __BOOTCOUNT_H__
+#define __BOOTCOUNT_H__
+
+#include <driver.h>
+
+struct bootcount_driver {
+	void (*set)(struct bootcount_driver *d);
+	void *priv;
+
+	int count;
+
+	struct device_d *dev;
+	struct device_d *parent;
+};
+
+#ifdef CONFIG_BOOTCOUNT
+int register_bootcount(struct bootcount_driver *d);
+#else
+static inline int register_bootcount(struct bootcount_driver *d)
+{
+	return 0
+}
+#endif
+
+#endif /* __BOOTCOUNT_H__ */
-- 
1.8.4.rc1


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/4] bootcount: add simple register support
  2013-09-21  6:46 ` [PATCH 1/4] misc: add bootcount framework Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-21  6:46   ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-21  6:46   ` [PATCH 3/4] bootcount: add somfy bootcount support Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-21  6:46 UTC (permalink / raw)
  To: barebox

use a register to store the boot count
if 2 ressources: one for magic, one for value
otherwise 16 upper bit for magic 16 lower for value

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/misc/bootcount/Kconfig    |   7 +++
 drivers/misc/bootcount/Makefile   |   1 +
 drivers/misc/bootcount/register.c | 107 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 115 insertions(+)
 create mode 100644 drivers/misc/bootcount/register.c

diff --git a/drivers/misc/bootcount/Kconfig b/drivers/misc/bootcount/Kconfig
index 77a1140..c028cf9 100644
--- a/drivers/misc/bootcount/Kconfig
+++ b/drivers/misc/bootcount/Kconfig
@@ -9,4 +9,11 @@ menuconfig BOOTCOUNT
 
 if BOOTCOUNT
 
+config BOOTCOUNT_REGISTER
+	tristate "Register"
+	help
+	  use a register to store the boot count
+	  if 2 ressources: one for magic, one for value
+	  otherwise 16 upper bit for magic 16 lower for value
+
 endif # BOOTCOUNT
diff --git a/drivers/misc/bootcount/Makefile b/drivers/misc/bootcount/Makefile
index 3c02ba1..cb6cb27 100644
--- a/drivers/misc/bootcount/Makefile
+++ b/drivers/misc/bootcount/Makefile
@@ -1 +1,2 @@
 obj-y		+= core.o
+obj-$(CONFIG_BOOTCOUNT_REGISTER) += register.o
diff --git a/drivers/misc/bootcount/register.c b/drivers/misc/bootcount/register.c
new file mode 100644
index 0000000..fc57f70
--- /dev/null
+++ b/drivers/misc/bootcount/register.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPLv2 Only
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <init.h>
+#include <io.h>
+#include <errno.h>
+#include <bootcount.h>
+
+#define BOOTCOUNT_MAGIC	0xb001c041
+
+struct bootcount_register {
+	struct device_d *dev;
+	void __iomem *base;
+	void __iomem *magic;
+	void (*set)(struct bootcount_register *br);
+
+	struct bootcount_driver drv;
+};
+
+static void bootcount_register_set_one(struct bootcount_register *br)
+{
+	u32 val;
+
+	val = BOOTCOUNT_MAGIC | (br->drv.count & 0xffff);
+
+	writel(val, br->base);
+}
+
+static void bootcount_register_set_two(struct bootcount_register *br)
+{
+	writel(BOOTCOUNT_MAGIC, br->magic);
+	writel(br->drv.count, br->base);
+}
+
+static void bootcount_register_parse_one(struct bootcount_register *br)
+{
+	u32 val;
+
+	val = readl(br->base);
+
+	if ((val & 0xffff0000) != (BOOTCOUNT_MAGIC& 0xffff0000))
+		return;
+
+	br->drv.count = val & 0xffff;
+}
+
+static void bootcount_register_parse_two(struct bootcount_register *br)
+{
+	u32 val;
+
+	val = readl(br->magic);
+
+	if (val != BOOTCOUNT_MAGIC)
+		return;
+
+	br->drv.count = readl(br->base);
+}
+
+static void bootcount_register_drv_set(struct bootcount_driver *d)
+{
+	struct bootcount_register *br = d->priv;
+
+	br->set(br);
+}
+
+static int bootcount_register_probe(struct device_d *dev)
+{
+	struct bootcount_register *br;
+	int ret;
+
+	br = xzalloc(sizeof(*br));
+	br->base = dev_request_mem_region(dev, 0);
+	br->magic = dev_request_mem_region(dev, 1);
+	br->dev = dev;
+
+	br->drv.priv = br;
+	br->drv.set = bootcount_register_drv_set;
+	br->drv.parent = dev;
+	if (!br->magic) {
+		bootcount_register_parse_one(br);
+		br->set = bootcount_register_set_one;
+	} else {
+		bootcount_register_parse_two(br);
+		br->set = bootcount_register_set_two;
+	}
+	ret = register_bootcount(&br->drv);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static struct driver_d bootcount_register_driver = {
+	.name = "bootcount_register",
+	.probe = bootcount_register_probe,
+};
+
+static int bootcount_register_init(void)
+{
+	return platform_driver_register(&bootcount_register_driver);
+}
+postcore_initcall(bootcount_register_init);
-- 
1.8.4.rc1


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/4] bootcount: add somfy bootcount support
  2013-09-21  6:46 ` [PATCH 1/4] misc: add bootcount framework Jean-Christophe PLAGNIOL-VILLARD
  2013-09-21  6:46   ` [PATCH 2/4] bootcount: add simple register support Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-21  6:46   ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-21  6:46   ` [PATCH 4/4] animeo_ip: add " Jean-Christophe PLAGNIOL-VILLARD
  2013-09-23  7:33   ` [PATCH 1/4] misc: add bootcount framework Sascha Hauer
  3 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-21  6:46 UTC (permalink / raw)
  To: barebox

we support different boot mode
 - normal
 - normal_forced
 - update
 - rescue
 - usb
 - network
 - test

each of them need to be checked this will allow to decide what is the next
boot mode during the boot sequence

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

diff --git a/drivers/misc/bootcount/Kconfig b/drivers/misc/bootcount/Kconfig
index c028cf9..622e561 100644
--- a/drivers/misc/bootcount/Kconfig
+++ b/drivers/misc/bootcount/Kconfig
@@ -16,4 +16,7 @@ config BOOTCOUNT_REGISTER
 	  if 2 ressources: one for magic, one for value
 	  otherwise 16 upper bit for magic 16 lower for value
 
+config SOMFY_BOOTCOUNT
+	tristate "Somfy Boot Count"
+
 endif # BOOTCOUNT
diff --git a/drivers/misc/bootcount/Makefile b/drivers/misc/bootcount/Makefile
index cb6cb27..8eb0c23 100644
--- a/drivers/misc/bootcount/Makefile
+++ b/drivers/misc/bootcount/Makefile
@@ -1,2 +1,3 @@
 obj-y		+= core.o
 obj-$(CONFIG_BOOTCOUNT_REGISTER) += register.o
+obj-$(CONFIG_SOMFY_BOOTCOUNT)	+= somfy.o
diff --git a/drivers/misc/bootcount/somfy.c b/drivers/misc/bootcount/somfy.c
new file mode 100644
index 0000000..08b3c0a
--- /dev/null
+++ b/drivers/misc/bootcount/somfy.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPLv2 Only
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <init.h>
+#include <io.h>
+#include <errno.h>
+#include <bootcount.h>
+
+#define SOMFY_BOOTCOUNT_UPDATE	(0x5550) << 16
+#define SOMFY_BOOTCOUNT_RESCUE	(0x5245) << 16
+#define SOMFY_BOOTCOUNT_USB	(0x5542) << 16
+#define SOMFY_BOOTCOUNT_NETWORK	(0x4E54) << 16
+#define SOMFY_BOOTCOUNT_TEST	(0x5445) << 16
+#define SOMFY_BOOTCOUNT_NORMAL	(0xb001) << 16
+#define SOMFY_BOOTCOUNT_NORMAL_FORCED	(0xb002) << 16
+
+static u32 somfy_boot_mode_mask[] = {
+	SOMFY_BOOTCOUNT_NORMAL,
+	SOMFY_BOOTCOUNT_NORMAL_FORCED,
+	SOMFY_BOOTCOUNT_UPDATE,
+	SOMFY_BOOTCOUNT_RESCUE,
+	SOMFY_BOOTCOUNT_USB,
+	SOMFY_BOOTCOUNT_NETWORK,
+	SOMFY_BOOTCOUNT_TEST,
+};
+
+static const char *somfy_boot_modes[] = {
+	"normal",
+	"normal_forced",
+	"update",
+	"rescue",
+	"usb",
+	"network",
+	"test",
+};
+
+struct somfy_bootcount {
+	struct device_d *dev;
+	int mode;
+	void __iomem *base;
+	struct bootcount_driver drv;
+};
+
+static void somfy_bootcount_set(struct somfy_bootcount *sb)
+{
+	u32 val;
+
+	val = somfy_boot_mode_mask[sb->mode] | (sb->drv.count & 0xffff);
+
+	writel(val, sb->base);
+}
+
+static int somfy_bootcount_mode_set(struct param_d *p, void *priv)
+{
+	struct somfy_bootcount *sb = priv;
+
+	sb->drv.count = 0;
+	somfy_bootcount_set(sb);
+
+	return 0;
+}
+
+static void somfy_bootcount_parse(struct somfy_bootcount *sb)
+{
+	u32 val;
+	int i;
+
+	val = readl(sb->base);
+
+	for (i = 0; i < ARRAY_SIZE(somfy_boot_mode_mask); i++) {
+		u32 mask = somfy_boot_mode_mask[i];
+
+		if ((val & 0xffff0000) == mask)
+			goto found;
+	}
+
+	return;
+
+found:
+	sb->mode = i;
+	sb->drv.count = val & 0xffff;
+}
+
+static void somfy_bootcount_drv_set(struct bootcount_driver *d)
+{
+	struct somfy_bootcount *sb = d->priv;
+
+	somfy_bootcount_set(sb);
+}
+
+static int somfy_bootcount_probe(struct device_d *dev)
+{
+	struct somfy_bootcount *sb;
+	int ret;
+
+	sb = xzalloc(sizeof(*sb));
+	sb->base = dev_request_mem_region(dev, 0);
+	sb->dev = dev;
+
+	sb->drv.priv = sb;
+	sb->drv.set = somfy_bootcount_drv_set;
+	sb->drv.parent = dev;
+	somfy_bootcount_parse(sb);
+	ret = register_bootcount(&sb->drv);
+	if (ret)
+		return ret;
+
+	dev_add_param_enum(sb->drv.dev, "mode", somfy_bootcount_mode_set,
+		NULL, &sb->mode, somfy_boot_modes, ARRAY_SIZE(somfy_boot_modes), sb);
+
+	return 0;
+}
+
+static struct driver_d somfy_bootcount_driver = {
+	.name = "somfy_bootcount",
+	.probe = somfy_bootcount_probe,
+};
+
+static int somfy_bootcount_init(void)
+{
+	return platform_driver_register(&somfy_bootcount_driver);
+}
+postcore_initcall(somfy_bootcount_init);
-- 
1.8.4.rc1


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/4] animeo_ip: add bootcount support
  2013-09-21  6:46 ` [PATCH 1/4] misc: add bootcount framework Jean-Christophe PLAGNIOL-VILLARD
  2013-09-21  6:46   ` [PATCH 2/4] bootcount: add simple register support Jean-Christophe PLAGNIOL-VILLARD
  2013-09-21  6:46   ` [PATCH 3/4] bootcount: add somfy bootcount support Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-21  6:46   ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-23  7:33   ` [PATCH 1/4] misc: add bootcount framework Sascha Hauer
  3 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-21  6:46 UTC (permalink / raw)
  To: barebox

As we use a backup register with a backup battery, the boot count is since
ever.

when updating to defaultenv-2 we will use it to decide what to boot

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/animeo_ip/init.c     | 2 ++
 arch/arm/configs/animeo_ip_defconfig | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c
index 56b8df2..08fef58 100644
--- a/arch/arm/boards/animeo_ip/init.c
+++ b/arch/arm/boards/animeo_ip/init.c
@@ -219,6 +219,8 @@ static int animeo_ip_devices_init(void)
 	animeo_ip_add_device_mci();
 	animeo_ip_add_device_buttons();
 	animeo_ip_add_device_led();
+	add_generic_device("somfy_bootcount", DEVICE_ID_SINGLE, NULL, AT91SAM9260_BASE_GPBR + 2 * 4,
+			4, IORESOURCE_MEM, NULL);
 
 	armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
 	/*
diff --git a/arch/arm/configs/animeo_ip_defconfig b/arch/arm/configs/animeo_ip_defconfig
index 23e7278..f4463b7 100644
--- a/arch/arm/configs/animeo_ip_defconfig
+++ b/arch/arm/configs/animeo_ip_defconfig
@@ -68,6 +68,8 @@ CONFIG_UBI=y
 CONFIG_MCI=y
 CONFIG_MCI_STARTUP=y
 CONFIG_MCI_ATMEL=y
+CONFIG_MISC_DEVICES=y
+CONFIG_SOMFY_BOOTCOUNT=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_GPIO_BICOLOR=y
-- 
1.8.4.rc1


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] misc: add bootcount framework
  2013-09-21  6:46 ` [PATCH 1/4] misc: add bootcount framework Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 preceding siblings ...)
  2013-09-21  6:46   ` [PATCH 4/4] animeo_ip: add " Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-23  7:33   ` Sascha Hauer
  2013-09-23  8:05     ` Jean-Christophe PLAGNIOL-VILLARD
  3 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2013-09-23  7:33 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Sat, Sep 21, 2013 at 08:46:04AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> The bootcount is always how many time the system start.
> To determine since when, this will depend on the driver implementation
> and your hardware feature.
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  drivers/misc/Kconfig            |  2 ++
>  drivers/misc/Makefile           |  1 +
>  drivers/misc/bootcount/Kconfig  | 12 +++++++++
>  drivers/misc/bootcount/Makefile |  1 +
>  drivers/misc/bootcount/core.c   | 54 +++++++++++++++++++++++++++++++++++++++++
>  include/bootcount.h             | 31 +++++++++++++++++++++++
>  6 files changed, 101 insertions(+)
>  create mode 100644 drivers/misc/bootcount/Kconfig
>  create mode 100644 drivers/misc/bootcount/Makefile
>  create mode 100644 drivers/misc/bootcount/core.c
>  create mode 100644 include/bootcount.h

This is getting worse. I don't get it why we need a 'framework' to
abstract a single variable. With this series we now have three
layers: a bootcount framework, a midlayer driver and a somfy specific
driver.

Can we please just do something like:

common/bootcount.c:

static int bootcount;

/*
 * Call this with your actual boot count, already increased by one
 * for the current boot.
 */
int bootcount_set(int count)
{
	if (bootcount) {
		pr_err("Bootcount already set\n");
		return -EINVAL;
	}

	bootcount = count;

	return 0;
}

static int bootcount_init(void)
{
	globalvar_add_simple_int_ro("bootcount", &bootcount, "%d");

	return 0;
}
late_initcall(bootcount_init);

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] misc: add bootcount framework
  2013-09-23  7:33   ` [PATCH 1/4] misc: add bootcount framework Sascha Hauer
@ 2013-09-23  8:05     ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-23  8:52       ` Sascha Hauer
  0 siblings, 1 reply; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-23  8:05 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 09:33 Mon 23 Sep     , Sascha Hauer wrote:
> On Sat, Sep 21, 2013 at 08:46:04AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > The bootcount is always how many time the system start.
> > To determine since when, this will depend on the driver implementation
> > and your hardware feature.
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  drivers/misc/Kconfig            |  2 ++
> >  drivers/misc/Makefile           |  1 +
> >  drivers/misc/bootcount/Kconfig  | 12 +++++++++
> >  drivers/misc/bootcount/Makefile |  1 +
> >  drivers/misc/bootcount/core.c   | 54 +++++++++++++++++++++++++++++++++++++++++
> >  include/bootcount.h             | 31 +++++++++++++++++++++++
> >  6 files changed, 101 insertions(+)
> >  create mode 100644 drivers/misc/bootcount/Kconfig
> >  create mode 100644 drivers/misc/bootcount/Makefile
> >  create mode 100644 drivers/misc/bootcount/core.c
> >  create mode 100644 include/bootcount.h
> 
> This is getting worse. I don't get it why we need a 'framework' to
> abstract a single variable. With this series we now have three
> layers: a bootcount framework, a midlayer driver and a somfy specific
> driver.
> 
> Can we please just do something like:
> 
> common/bootcount.c:
> 
> static int bootcount;
> 
> /*
>  * Call this with your actual boot count, already increased by one
>  * for the current boot.
>  */
> int bootcount_set(int count)
> {
> 	if (bootcount) {
> 		pr_err("Bootcount already set\n");
> 		return -EINVAL;
> 	}
> 
> 	bootcount = count;
> 
> 	return 0;
> }
> 
> static int bootcount_init(void)
> {
> 	globalvar_add_simple_int_ro("bootcount", &bootcount, "%d");
> 
> 	return 0;
> }
> late_initcall(bootcount_init);

no as the bootcount is way more complex for somfy

we store the boot count in one register with the boot mode

and the boot count can we reset by the shell

so it's not a RO

and I do not like to put everything on global

Brest Regards,
J.
> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] misc: add bootcount framework
  2013-09-23  8:05     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-23  8:52       ` Sascha Hauer
  0 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-09-23  8:52 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Mon, Sep 23, 2013 at 10:05:40AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 09:33 Mon 23 Sep     , Sascha Hauer wrote:
> > On Sat, Sep 21, 2013 at 08:46:04AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Can we please just do something like:
> > 
> > common/bootcount.c:
> > 
> > static int bootcount;
> > 
> > /*
> >  * Call this with your actual boot count, already increased by one
> >  * for the current boot.
> >  */
> > int bootcount_set(int count)
> > {
> > 	if (bootcount) {
> > 		pr_err("Bootcount already set\n");
> > 		return -EINVAL;
> > 	}
> > 
> > 	bootcount = count;
> > 
> > 	return 0;
> > }
> > 
> > static int bootcount_init(void)
> > {
> > 	globalvar_add_simple_int_ro("bootcount", &bootcount, "%d");
> > 
> > 	return 0;
> > }
> > late_initcall(bootcount_init);
> 
> no as the bootcount is way more complex for somfy
> 
> we store the boot count in one register with the boot mode
> 
> and the boot count can we reset by the shell
> 
> so it's not a RO

Make it rw then.

Put whatever complexity you need into your somfy code, but all that's
user visible is a single variable (visible to both C code and
userspace). We don't need a framework for this.

> 
> and I do not like to put everything on global

And I do not like creating devices which serve only as a namespace
provider for variables.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-09-23  8:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-21  6:45 [PATCH 0/4 v2] introduce bootcount support Jean-Christophe PLAGNIOL-VILLARD
2013-09-21  6:46 ` [PATCH 1/4] misc: add bootcount framework Jean-Christophe PLAGNIOL-VILLARD
2013-09-21  6:46   ` [PATCH 2/4] bootcount: add simple register support Jean-Christophe PLAGNIOL-VILLARD
2013-09-21  6:46   ` [PATCH 3/4] bootcount: add somfy bootcount support Jean-Christophe PLAGNIOL-VILLARD
2013-09-21  6:46   ` [PATCH 4/4] animeo_ip: add " Jean-Christophe PLAGNIOL-VILLARD
2013-09-23  7:33   ` [PATCH 1/4] misc: add bootcount framework Sascha Hauer
2013-09-23  8:05     ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-23  8:52       ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox