[PATCH] partitions: dos: Treat all extended partition types equally

2018-01-17 Thread Andrey Smirnov
Creating logical DOS partitions with fdisk (Fedora 27, fdisk from
util-linux 2.30.2) results in extended partition of type 0x05 being
created on the device. Partitioned like this, device is succesfully
recognized by Linux, but, due to algorithm in dos_partition(), not
Barebox.

Looking closer at the actual contents of MBR shows that while marked
as "Extended partition with CHS addressing" that partition still have
all of the LBA adressed fields filled correctly.

Given the above and the fact that similar code in Linux
kernel (block/partitions/msdos.c) does not make a distinction between
types 0x0f and 0x05, port Linux's is_extended_partition() and convert
the code to treat types 0x05, 0x0f and 0x85 the same way.

Signed-off-by: Andrey Smirnov 
---
 common/partitions/dos.c | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 91b539907..488c2936f 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -21,6 +21,22 @@
 
 #include "parser.h"
 
+
+enum {
+/* These three have identical behaviour; use the second one if DOS FDISK gets
+   confused about extended/logical partitions starting past cylinder 1023. */
+   DOS_EXTENDED_PARTITION = 5,
+   LINUX_EXTENDED_PARTITION = 0x85,
+   WIN98_EXTENDED_PARTITION = 0x0f,
+};
+
+static inline int is_extended_partition(struct partition *p)
+{
+   return (p->dos_partition_type == DOS_EXTENDED_PARTITION ||
+   p->dos_partition_type == WIN98_EXTENDED_PARTITION ||
+   p->dos_partition_type == LINUX_EXTENDED_PARTITION);
+}
+
 /**
  * Guess the size of the disk, based on the partition table entries
  * @param dev device to create partitions for
@@ -212,13 +228,8 @@ static void dos_partition(void *buf, struct block_device 
*blk,
sprintf(pd->parts[n].partuuid, "%08x-%02d",
signature, i + 1);
pd->used_entries++;
-   /*
-* Partitions of type 0x05 and 0x0f (and some more)
-* contain extended partitions. Only check for type 0x0f
-* here as this is the easiest to parse and common
-* enough.
-*/
-   if (pentry.dos_partition_type == 0x0f) {
+
+   if (is_extended_partition()) {
if (!extended_partition)
extended_partition = >parts[n];
else
-- 
2.14.3


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


[PATCH] FIT: Fix error path

2018-01-17 Thread Sascha Hauer
In case of error of_unflatten_dtb() returns an ERR_PTR. Make sure
that handle->root contains NULL in this case so that we do not call
of_delete_node on the error pointer in the exit path.

Signed-off-by: Sascha Hauer 
---
 common/image-fit.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 81433e6ecf..db5d142147 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -584,6 +584,7 @@ struct fit_handle *fit_open(const char *filename, const 
char *config, bool verbo
 {
struct fit_handle *handle = NULL;
const char *desc = "(no description)";
+   struct device_node *root;
int ret;
 
handle = xzalloc(sizeof(struct fit_handle));
@@ -596,12 +597,13 @@ struct fit_handle *fit_open(const char *filename, const 
char *config, bool verbo
goto err;
}
 
-   handle->root = of_unflatten_dtb(handle->fit);
-   if (IS_ERR(handle->root)) {
-   ret = PTR_ERR(handle->root);
+   root = of_unflatten_dtb(handle->fit);
+   if (IS_ERR(root)) {
+   ret = PTR_ERR(root);
goto err;
}
 
+   handle->root = root;
handle->verify = verify;
 
of_property_read_string(handle->root, "description", );
-- 
2.11.0


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


Re: [PATCH v3 0/3] Enable DT support for AT91SAM9263EK

2018-01-17 Thread Sascha Hauer
On Mon, Jan 15, 2018 at 10:39:51PM +0100, Sam Ravnborg wrote:
> This is version 3 of a patchset to enable
> device tree support for AT91SAM9263EK.
> 
> The patchset is made on top of previous
> patches posted that move reset code to
> the board files for at91 boards.
> (Which are already part of -next)
> 
> On the quest towards getting so far several drivers was
> converted to support DT.
> These patches went in around august.
> 
> There was also issues with mach-at91 calling code
> in the board directory (dependency in the
> wrong direction).
> This was fixed in "at91: move reset .." which is
> pending (already posted).
> 
> I have failed to get the bootstrap mode to work.
> It stops somewhere - and I have not invested enough
> time to figure out where and why things goes wrong.
> bootstrap mode was also broken before these patches.
> No JTAG debugger available to help me.
> And then I have at91bootstrap that works so motivation
> was not too high.
> 
> I do not think the NAND support works either.
> The device tree introduces some nand-controller
> stuff that is not supported by barebox (at least I assume so).
> And this part I did not look further into.
> 
> Next step is to get a proprietary board up and
> running (which uses NOR flash).
> But I wanted this patchset out in the open first.
> 
> Thanks for feedback so far - especially from Andrey.
> 
>   Sam
> 
> v2 => v3
> - Squashed commit introducing support for multi image
>   with the commit to add DT support
> - Fixed init of smc

Applied, thanks

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- |

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


Re: [PATCH v2 3/7] sandbox: add i2c and spi libftdi1 bit-bang example

2018-01-17 Thread Sascha Hauer
On Mon, Jan 15, 2018 at 12:22:48AM +0300, Antony Pavlov wrote:
> Make necessary changes in sandbox_defconfig:
> enable gpio, spi, i2c and led stuff.
> 
> Usage:
> 
>   barebox$ make sandbox_defconfig
>   barebox$ sed -i "s/# CONFIG_GPIO_LIBFTDI1.*$/CONFIG_GPIO_LIBFTDI1=y/" 
> .config
> 
>   # edit arch/sandbox/dts/sandbox.dts if necessary
> 
>   barebox$ make
>   barebox$ sudo ./barebox -d arch/sandbox/dts/sandbox.dtb
> 
> Signed-off-by: Antony Pavlov 
> ---
>  arch/sandbox/configs/sandbox_defconfig | 26 -
>  arch/sandbox/dts/sandbox.dts   | 52 
> ++
>  2 files changed, 77 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/sandbox/configs/sandbox_defconfig 
> b/arch/sandbox/configs/sandbox_defconfig
> index dbaff12bfb..6b10adb8ef 100644
> --- a/arch/sandbox/configs/sandbox_defconfig
> +++ b/arch/sandbox/configs/sandbox_defconfig
> @@ -53,6 +53,11 @@ CONFIG_CMD_CRC_CMP=y
>  CONFIG_CMD_MM=y
>  CONFIG_CMD_DETECT=y
>  CONFIG_CMD_FLASH=y
> +CONFIG_CMD_GPIO=y
> +CONFIG_CMD_I2C=y
> +CONFIG_CMD_LED=y
> +CONFIG_CMD_SPI=y
> +CONFIG_CMD_LED_TRIGGER=y
>  CONFIG_CMD_2048=y
>  CONFIG_CMD_OF_NODE=y
>  CONFIG_CMD_OF_PROPERTY=y
> @@ -66,10 +71,29 @@ CONFIG_NET_NETCONSOLE=y
>  CONFIG_OFDEVICE=y
>  CONFIG_OF_BAREBOX_DRIVERS=y
>  CONFIG_DRIVER_NET_TAP=y
> -# CONFIG_SPI is not set
> +CONFIG_DRIVER_SPI_GPIO=y
> +CONFIG_I2C=y
> +CONFIG_I2C_GPIO=y
> +CONFIG_I2C_MUX=y
> +CONFIG_I2C_MUX_PCA954x=y
> +CONFIG_MTD=y
> +CONFIG_MTD_M25P80=y
>  CONFIG_VIDEO=y
>  CONFIG_FRAMEBUFFER_CONSOLE=y
> +CONFIG_LED=y
> +CONFIG_LED_GPIO=y
> +CONFIG_LED_GPIO_OF=y
> +CONFIG_LED_GPIO_RGB=y
> +CONFIG_LED_GPIO_BICOLOR=y
> +CONFIG_LED_TRIGGERS=y
> +CONFIG_EEPROM_AT25=y
> +CONFIG_EEPROM_AT24=y
> +CONFIG_GPIO_74164=y
> +CONFIG_GPIO_PCA953X=y
> +CONFIG_GPIO_SX150X=y
>  # CONFIG_PINCTRL is not set
> +CONFIG_RTC_CLASS=y
> +CONFIG_RTC_DRV_DS1307=y
>  CONFIG_FS_CRAMFS=y
>  CONFIG_FS_EXT4=y
>  CONFIG_FS_TFTP=y
> diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
> index 2595aa13fa..69568f6d7a 100644
> --- a/arch/sandbox/dts/sandbox.dts
> +++ b/arch/sandbox/dts/sandbox.dts
> @@ -1,7 +1,59 @@
>  /dts-v1/;
>  
>  #include "skeleton.dtsi"
> +#include 
>  
>  / {
> + gpio0: gpio@0 {
> + compatible = "barebox,libftdi1-gpio";
> + /* use ACBUS[7:0] */
> + gpio-controller;
> + #gpio-cells = <2>;
> + status = "okay";
> + };
>  
> + spi0 {
> + compatible = "spi-gpio";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + gpio-sck  = < 0 GPIO_ACTIVE_HIGH>;
> + gpio-mosi = < 1 GPIO_ACTIVE_HIGH>;
> + gpio-miso = < 2 GPIO_ACTIVE_HIGH>;
> + cs-gpios  = < 3 GPIO_ACTIVE_HIGH>;
> +
> + num-chipselects = <1>;
> +
> + status = "disabled";
> +
> + m25p128@0 {
> + compatible = "m25p128", "jedec,spi-nor";
> + #address-cells = <1>;
> + #size-cells = <1>;
> + reg = <0>;
> + spi-max-frequency = <100>;
> + };
> + };
> +
> + i2c0: i2c0 {
> + compatible = "i2c-gpio";
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + gpios = < 4 GPIO_ACTIVE_HIGH /* sda */
> +  5 GPIO_ACTIVE_HIGH /* scl */
> + >;
> + i2c-gpio,scl-output-only;
> +
> + status = "disabled";
> +
> + eeprom: at24@50 {
> + compatible = "atmel,24c32";
> + reg = <0x50>;
> + };
> +
> + rtc: ds1307@68 {
> + compatible = "dallas,ds1307";
> + reg = <0x68>;
> + };
> + };

Can we move this to a sandbox-libftdi-example.dtsi file which is not
included by default? The rationale is that a user has to read and
understand this file anyway and probably adopt it to his wiring (or his
wiring to this file).

And if we do that, would it be an option to move the vendor/product_id
and serial setting to the device tree aswell? Then we would have all
config in a single place and could also use multiple devices.

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- |

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


Re: [PATCH v2 0/7] sandbox: add gpio support with libftdi1

2018-01-17 Thread Sascha Hauer
Hi Antony,

On Mon, Jan 15, 2018 at 12:22:45AM +0300, Antony Pavlov wrote:
> This patch series makes it possible to use FT2232H ACBUS[7:0]
> pins as gpio pins from sandbox barebox.
> 
> There are ready-to-use FT2232H-based boards:
> 
>   * FT2232H-56Q Mini-Module 
> (http://www.ftdichip.com/Products/Modules/DevelopmentModules.htm#FT2232H-56_Mini)
>   * FT2232 breakout board 
> (http://dangerousprototypes.com/docs/FT2232_breakout_board)
> 
> The main goal of adding gpio functionality to sandbox barebox
> is using it for connecting real i2c and spi devices to sandbox barebox.

I applied the parseopt patches for now since they don't need any further
discussions.

What puzzles me a bit is that the libftdi gpio controller is
instantiated from the device tree but configured through the
commandline. It probably has to be like this since we need the
device tree for using the gpios.

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- |

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


Re: [PATCH v2 1/3] lib: parse_area_spec: don't modify *start value if parse failed

2018-01-17 Thread Peter Mamonov
On Wed, Jan 17, 2018 at 09:11:12AM +0100, Sascha Hauer wrote:
> On Mon, Jan 15, 2018 at 02:32:31PM +0300, Peter Mamonov wrote:
> > Signed-off-by: Peter Mamonov 
> > ---
> >  lib/misc.c | 14 +-
> >  1 file changed, 9 insertions(+), 5 deletions(-)
> > 
> > diff --git a/lib/misc.c b/lib/misc.c
> > index 62ddd6677..1767043d1 100644
> > --- a/lib/misc.c
> > +++ b/lib/misc.c
> > @@ -79,19 +79,19 @@ EXPORT_SYMBOL(strtoul_suffix);
> >  int parse_area_spec(const char *str, loff_t *start, loff_t *size)
> >  {
> > char *endp;
> > -   loff_t end;
> > +   loff_t end, _start;
> >  
> > if (!isdigit(*str))
> > return -1;
> >  
> > -   *start = strtoull_suffix(str, , 0);
> > +   _start = strtoull_suffix(str, , 0);
> >  
> > str = endp;
> >  
> > if (!*str) {
> > /* beginning given, but no size, assume maximum size */
> > *size = ~0;
> > -   return 0;
> > +   goto success;
> > }
> >  
> > if (*str == '-') {
> > @@ -102,15 +102,19 @@ int parse_area_spec(const char *str, loff_t *start, 
> > loff_t *size)
> > return -1;
> > }
> > *size = end - *start + 1;
> 
> Applied with two little changes: It must be _start above and in another
> case not visible in the patch. *start is not yet initialized.

Thanks for correction. Actually these changes were present in the original
patch, but I've missed them while rearranging it.

Regards,
Peter

> 
> 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- |

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


Re: [PATCH 1/2] common: state: Add property to protect existing data

2018-01-17 Thread Sascha Hauer
Sorry for replying only after reminding me. This patch is still
in my inbox as I have some problems with it. Anyway let's solve
them.

On Thu, Dec 14, 2017 at 04:51:36PM +0100, Daniel Schultz wrote:
> After an update to a newer barebox version with an enabled state
> framework, existing data in storage memories could be overwritten.
> 
> Add a new property to check in front of every write task, if the meta
> magic field only contains the magic number, zeros or ones.

What is the case you are trying to protect against? I assume partition
size changes and possibly old bootloaders with an old partitioning.
Could you explain?

Whatever solution we come up with should work for the circular backend
aswell.

What I am missing in this patch is a clear way how to overcome this
situation. For mtd it would be: erase the device and reset, but what
about devices that don't have to be erased? We might just need a -f aka
"I know what I am doing" parameter.

> 
> Signed-off-by: Daniel Schultz 
> ---
>  .../devicetree/bindings/barebox/barebox,state.rst |  3 +++
>  common/state/backend_bucket_direct.c  |  2 ++
>  common/state/backend_storage.c|  1 +
>  common/state/state.c  | 19 
> ++-
>  common/state/state.h  |  2 ++
>  5 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/barebox/barebox,state.rst 
> b/Documentation/devicetree/bindings/barebox/barebox,state.rst
> index cebb5f8..db5b041 100644
> --- a/Documentation/devicetree/bindings/barebox/barebox,state.rst
> +++ b/Documentation/devicetree/bindings/barebox/barebox,state.rst
> @@ -55,6 +55,9 @@ Optional Properties
>  * ``algo``: A HMAC algorithm used to detect manipulation of the data
>or header, sensible values follow this pattern ``hmac()``,
>e.g. ``hmac(sha256)``. Only available for the ``backend-type`` ``raw``.
> +* ``keep-previous-content``: Check if a the bucket meta magic field contains
> +  other data than the magic value. If so, the backend will not write the 
> state
> +  to prevent unconditionally overwrites of existing data.
>  
>  .. note:: For the ``backend-storage-type`` the keyword ``noncircular`` is 
> still
> supported as a fall back to an old storage format. Recommendation is to 
> not
> diff --git a/common/state/backend_bucket_direct.c 
> b/common/state/backend_bucket_direct.c
> index 958696e..9d6a337 100644
> --- a/common/state/backend_bucket_direct.c
> +++ b/common/state/backend_bucket_direct.c
> @@ -69,6 +69,8 @@ static int state_backend_bucket_direct_read(struct 
> state_backend_storage_bucket
>   if (meta.magic == direct_magic) {
>   read_len = meta.written_length;
>   } else {
> + if (meta.magic != ~0 && !!meta.magic)
> + bucket->wrong_magic = 1;

This only handles the direct backend, but not the circular backend.

>   if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
>   dev_err(direct->dev, "No meta data header found\n");
>   dev_dbg(direct->dev, "Enable backward compatibility or 
> increase stride size\n");
> diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c
> index c6ebe86..f0a169d 100644
> --- a/common/state/backend_storage.c
> +++ b/common/state/backend_storage.c
> @@ -152,6 +152,7 @@ int state_storage_read(struct state_backend_storage 
> *storage,
>* one we want to use.
>*/
>   list_for_each_entry(bucket, >buckets, bucket_list) {
> + bucket->wrong_magic = 0;
>   ret = bucket->read(bucket, >buf, >len);
>   if (ret == -EUCLEAN)
>   bucket->needs_refresh = 1;
> diff --git a/common/state/state.c b/common/state/state.c
> index 6399bd3..e110542 100644
> --- a/common/state/state.c
> +++ b/common/state/state.c
> @@ -44,6 +44,9 @@ int state_save(struct state *state)
>   void *buf;
>   ssize_t len;
>   int ret;
> + struct state_backend_storage_bucket *bucket;
> + struct state_backend_storage *storage;
> + bool has_content;
>  
>   if (!state->dirty)
>   return 0;
> @@ -55,7 +58,18 @@ int state_save(struct state *state)
>   return ret;
>   }
>  
> - ret = state_storage_write(>storage, buf, len);
> + storage = >storage;
> + if (state->keep_prev_content) {
> + has_content = 0;

has_content is only used in this if(){}, can you move its declaration
here?

> + list_for_each_entry(bucket, >buckets, bucket_list)
> + has_content |= bucket->wrong_magic;
> + if (has_content) {
> + dev_dbg(>dev, "Found content on a backend.\n");

I think dev_dbg() is a bit quiet. This really deserves a warning saying
"Found foreign content on backend, won't overwrite.\n"

> + goto out;

You should initialize 

Re: [PATCH] of: base: use root_node compatible as suggestion for a hostname

2018-01-17 Thread Sascha Hauer
On Thu, Nov 30, 2017 at 11:56:20AM +0100, Oleksij Rempel wrote:
> on some SoCs we can use generic PLL and RAM initialization. In this
> cases we create board file only to provide a host name.
> With this patch host name will be created from device tree compatible.
> For example:
>  compatible = "board_vendor,board", "chip_vendor,soc"
> the host name will be:
>  "board"
> 
> This function will not overwrite a host name which is already set by
> board or machine code.
> 
> Signed-off-by: Oleksij Rempel 
> ---

Applied, thanks

Sascha

>  common/misc.c |  7 +++
>  drivers/of/base.c | 32 
>  include/common.h  |  1 +
>  include/of.h  |  1 +
>  4 files changed, 41 insertions(+)
> 
> diff --git a/common/misc.c b/common/misc.c
> index c5d3704c82..0888f1f4f6 100644
> --- a/common/misc.c
> +++ b/common/misc.c
> @@ -187,6 +187,13 @@ const char *barebox_get_hostname(void)
>  }
>  EXPORT_SYMBOL(barebox_get_hostname);
>  
> +void barebox_set_hostname_no_overwrite(const char *__hostname)
> +{
> + if (!barebox_get_hostname())
> + barebox_set_hostname(__hostname);
> +}
> +EXPORT_SYMBOL(barebox_set_hostname_no_overwrite);
> +
>  BAREBOX_MAGICVAR_NAMED(global_hostname, global.hostname,
>   "shortname of the board. Also used as hostname for DHCP 
> requests");
>  
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index eabbf3d957..6a582177bf 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -2360,3 +2360,35 @@ int of_graph_port_is_available(struct device_node 
> *node)
>   return available;
>  }
>  EXPORT_SYMBOL(of_graph_port_is_available);
> +
> +/**
> + * of_get_machine_compatible - get first compatible string from the root 
> node.
> + *
> + * Returns the string or NULL.
> + */
> +const char *of_get_machine_compatible(void)
> +{
> + struct property *prop;
> + const char *name, *p;
> +
> + if (!root_node)
> + return NULL;
> +
> + prop = of_find_property(root_node, "compatible", NULL);
> + name = of_prop_next_string(prop, NULL);
> +
> + p = strchr(name, ',');
> + return p ? p + 1 : name;
> +}
> +EXPORT_SYMBOL(of_get_machine_compatible);
> +
> +static int of_init_hostname(void)
> +{
> + const char *name;
> +
> + name = of_get_machine_compatible();
> + barebox_set_hostname_no_overwrite(name ?: "barebox");
> +
> + return 0;
> +}
> +late_initcall(of_init_hostname);
> diff --git a/include/common.h b/include/common.h
> index dd7445e9b6..a9b8610af8 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -139,6 +139,7 @@ const char *barebox_get_model(void);
>  void barebox_set_model(const char *);
>  const char *barebox_get_hostname(void);
>  void barebox_set_hostname(const char *);
> +void barebox_set_hostname_no_overwrite(const char *);
>  
>  #if defined(CONFIG_MIPS)
>  #include 
> diff --git a/include/of.h b/include/of.h
> index 18a423241b..edcc854f7b 100644
> --- a/include/of.h
> +++ b/include/of.h
> @@ -148,6 +148,7 @@ extern struct device_node *of_copy_node(struct 
> device_node *parent,
>   const struct device_node *other);
>  extern void of_delete_node(struct device_node *node);
>  
> +extern const char *of_get_machine_compatible(void);
>  extern int of_machine_is_compatible(const char *compat);
>  extern int of_device_is_compatible(const struct device_node *device,
>   const char *compat);
> -- 
> 2.11.0
> 
> 
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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- |

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


Re: [PATCH v2 1/3] lib: parse_area_spec: don't modify *start value if parse failed

2018-01-17 Thread Sascha Hauer
On Mon, Jan 15, 2018 at 02:32:31PM +0300, Peter Mamonov wrote:
> Signed-off-by: Peter Mamonov 
> ---
>  lib/misc.c | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/misc.c b/lib/misc.c
> index 62ddd6677..1767043d1 100644
> --- a/lib/misc.c
> +++ b/lib/misc.c
> @@ -79,19 +79,19 @@ EXPORT_SYMBOL(strtoul_suffix);
>  int parse_area_spec(const char *str, loff_t *start, loff_t *size)
>  {
>   char *endp;
> - loff_t end;
> + loff_t end, _start;
>  
>   if (!isdigit(*str))
>   return -1;
>  
> - *start = strtoull_suffix(str, , 0);
> + _start = strtoull_suffix(str, , 0);
>  
>   str = endp;
>  
>   if (!*str) {
>   /* beginning given, but no size, assume maximum size */
>   *size = ~0;
> - return 0;
> + goto success;
>   }
>  
>   if (*str == '-') {
> @@ -102,15 +102,19 @@ int parse_area_spec(const char *str, loff_t *start, 
> loff_t *size)
>   return -1;
>   }
>   *size = end - *start + 1;

Applied with two little changes: It must be _start above and in another
case not visible in the patch. *start is not yet initialized.

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- |

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


Re: [PATCH] atmel_lcdfb: introduce driver data

2018-01-17 Thread Sascha Hauer
On Sat, Jan 13, 2018 at 11:21:19AM +0100, Sam Ravnborg wrote:
> Hi Sasha.
> 
> > > +
> > >  static __maybe_unused struct of_device_id atmel_lcdfb_compatible[] = {
> > > - { .compatible = "atmel,at91sam9261-lcdc", },
> > > - { .compatible = "atmel,at91sam9263-lcdc", },
> > > - { .compatible = "atmel,at91sam9g10-lcdc", },
> > > - { .compatible = "atmel,at91sam9g45-lcdc", },
> > > + { .compatible = "atmel,at91sam9261-lcdc",   .data = 
> > > _config, },
> > > + { .compatible = "atmel,at91sam9263-lcdc",   .data = 
> > > _config, },
> > > + { .compatible = "atmel,at91sam9g10-lcdc",   .data = 
> > > _config, },
> > > + { .compatible = "atmel,at91sam9g45-lcdc",   .data = 
> > > _config, },
> > >   { .compatible = "atmel,at91sam9g45es-lcdc", },
> > > - { .compatible = "atmel,at91sam9rl-lcdc", },
> > > - { .compatible = "atmel,at32ap-lcdc", },
> > > + { .compatible = "atmel,at91sam9rl-lcdc",.data = 
> > > _config, },
> > > + { .compatible = "atmel,at32ap-lcdc",.data = _config, 
> > > },
> > >   { /* sentinel */ }
> > >  };
> > 
> > Note that we can match on different platform_device_ids aswell, so you
> > could also attach driver_data to platform devices aswell. For an example
> > see drivers/serial/serial_imx.c.
> > 
> > I leave it up to you if you change this patch accordingly, I can also
> > apply it as is.
> 
> I took a look at it today.
> With these Atmel CPUs we have different behaviour of each IP block
> depending on what CPU it is included in which is why I have added
> all these _config blocks (I could have re-used a few).
> 
> So it is not that we see that for example at91sam9rl-lcdc
> is used in many CPU's.
> Adding the platform_id in this case resulted in extra code with no
> added benefit - or at least no benefit I could see.
> I had to maintain both a of_device_id table and a platform_device_id table,
> so it also looked like a duplicate.
> 
> So unless I miss something then the original patch is the best
> solution.

I see your point, so applied your original patch.

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- |

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


Re: [PATCH] net/e1000: fix driver probing in the presence of two e1000 devices

2018-01-17 Thread Sascha Hauer
On Thu, Jan 11, 2018 at 10:03:26AM +0100, Uwe Kleine-König wrote:
> The .id member of the struct device for the invm device is not
> initialized and so implicitly zero. This yields:
> 
>   register_device: already registered invm0
> 
> for the second i210 during probe.
> 
> So use the parent's id to initialize the id for invm, too, as is already
> done for the corresponding e1000-nor device.
> 
> Fixes: a74b97f009c6 ("e1000: Expose i210's iNVM as a cdev")
> Signed-off-by: Uwe Kleine-König 

Applied, thanks

Sascha

> ---
>  drivers/net/e1000/eeprom.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c
> index 23fb05ec72bc..748d8afe7922 100644
> --- a/drivers/net/e1000/eeprom.c
> +++ b/drivers/net/e1000/eeprom.c
> @@ -1504,6 +1504,7 @@ int e1000_register_invm(struct e1000_hw *hw)
>   return ret;
>  
>   strcpy(hw->invm.dev.name, "invm");
> + hw->invm.dev.id = hw->dev->id;
>   hw->invm.dev.parent = hw->dev;
>   ret = register_device(>invm.dev);
>   if (ret < 0) {
> -- 
> 2.11.0
> 
> 
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
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- |

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