diff mbox series

[U-Boot,09/14] dfu: add callback for flush and initiated operation

Message ID 20190913141930.15784-10-patrick.delaunay@st.com
State Changes Requested
Delegated to: Lukasz Majewski
Headers show
Series dfu: update dfu stack and add MTD backend | expand

Commit Message

Patrick DELAUNAY Sept. 13, 2019, 2:19 p.m. UTC
Add weak callback to allow board specific behavior
- flush
- initiated

This patch prepare usage of DFU back end for communication with
STM32CubeProgrammer on stm32mp1 platform with stm32prog command.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 drivers/dfu/dfu.c | 19 +++++++++++++++++++
 include/dfu.h     |  2 ++
 2 files changed, 21 insertions(+)

Comments

Lukasz Majewski Sept. 17, 2019, 10:44 a.m. UTC | #1
Hi Patrick,

> Add weak callback to allow board specific behavior
> - flush
> - initiated
> 
> This patch prepare usage of DFU back end for communication with
> STM32CubeProgrammer on stm32mp1 platform with stm32prog command.

As I've said previously - please add this use case and info to
./doc/README.dtu.

> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> 
>  drivers/dfu/dfu.c | 19 +++++++++++++++++++
>  include/dfu.h     |  2 ++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> index 2697235c24..f12c5afc66 100644
> --- a/drivers/dfu/dfu.c
> +++ b/drivers/dfu/dfu.c
> @@ -22,6 +22,22 @@ static int dfu_alt_num;
>  static int alt_num_cnt;
>  static struct hash_algo *dfu_hash_algo;
>  
> +/*
> + * The purpose of the dfu_flush_callback() function is to
> + * provide callback for dfu user
> + */
> +__weak void dfu_flush_callback(struct dfu_entity *dfu)
> +{
> +}
> +
> +/*
> + * The purpose of the dfu_flush_callback() function is to
> + * provide callback for dfu user

Please update this repeated comment.

> + */
> +__weak void dfu_initiated_callback(struct dfu_entity *dfu)
> +{
> +}
> +
>  /*
>   * The purpose of the dfu_usb_get_reset() function is to
>   * provide information if after USB_DETACH request
> @@ -263,6 +279,7 @@ int dfu_transaction_initiate(struct dfu_entity
> *dfu, bool read) }
>  
>  	dfu->inited = 1;
> +	dfu_initiated_callback(dfu);
>  
>  	return 0;
>  }
> @@ -282,6 +299,8 @@ int dfu_flush(struct dfu_entity *dfu, void *buf,
> int size, int blk_seq_num) printf("\nDFU complete %s: 0x%08x\n",
> dfu_hash_algo->name, dfu->crc);
>  
> +	dfu_flush_callback(dfu);
> +
>  	dfu_transaction_cleanup(dfu);
>  
>  	return ret;
> diff --git a/include/dfu.h b/include/dfu.h
> index 4de7d35914..5d85cc35ef 100644
> --- a/include/dfu.h
> +++ b/include/dfu.h
> @@ -182,6 +182,8 @@ bool dfu_usb_get_reset(void);
>  int dfu_read(struct dfu_entity *de, void *buf, int size, int
> blk_seq_num); int dfu_write(struct dfu_entity *de, void *buf, int
> size, int blk_seq_num); int dfu_flush(struct dfu_entity *de, void
> *buf, int size, int blk_seq_num); +void dfu_flush_callback(struct
> dfu_entity *dfu); +void dfu_initiated_callback(struct dfu_entity
> *dfu); 
>  /*
>   * dfu_defer_flush - pointer to store dfu_entity for deferred
> flashing.



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Patrick DELAUNAY Sept. 17, 2019, 12:52 p.m. UTC | #2
Hi,

> From: Lukasz Majewski <lukma@denx.de>
> Sent: mardi 17 septembre 2019 12:45
> 
> Hi Patrick,
> 
> > Add weak callback to allow board specific behavior
> > - flush
> > - initiated
> >
> > This patch prepare usage of DFU back end for communication with
> > STM32CubeProgrammer on stm32mp1 platform with stm32prog command.
> 
> As I've said previously - please add this use case and info to ./doc/README.dtu.

Yes

> 
> >
> > Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> > ---
> >
> >  drivers/dfu/dfu.c | 19 +++++++++++++++++++
> >  include/dfu.h     |  2 ++
> >  2 files changed, 21 insertions(+)
> >
> > diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index
> > 2697235c24..f12c5afc66 100644
> > --- a/drivers/dfu/dfu.c
> > +++ b/drivers/dfu/dfu.c
> > @@ -22,6 +22,22 @@ static int dfu_alt_num;  static int alt_num_cnt;
> > static struct hash_algo *dfu_hash_algo;
> >
> > +/*
> > + * The purpose of the dfu_flush_callback() function is to
> > + * provide callback for dfu user
> > + */
> > +__weak void dfu_flush_callback(struct dfu_entity *dfu) { }
> > +
> > +/*
> > + * The purpose of the dfu_flush_callback() function is to
> > + * provide callback for dfu user
> 
> Please update this repeated comment.

Yes, in V2

> 
> > + */
> > +__weak void dfu_initiated_callback(struct dfu_entity *dfu)
> > +{
> > +}
> > +
> >  /*
> >   * The purpose of the dfu_usb_get_reset() function is to
> >   * provide information if after USB_DETACH request
> > @@ -263,6 +279,7 @@ int dfu_transaction_initiate(struct dfu_entity
> > *dfu, bool read) }
> >
> >  	dfu->inited = 1;
> > +	dfu_initiated_callback(dfu);
> >
> >  	return 0;
> >  }
> > @@ -282,6 +299,8 @@ int dfu_flush(struct dfu_entity *dfu, void *buf,
> > int size, int blk_seq_num) printf("\nDFU complete %s: 0x%08x\n",
> > dfu_hash_algo->name, dfu->crc);
> >
> > +	dfu_flush_callback(dfu);
> > +
> >  	dfu_transaction_cleanup(dfu);
> >
> >  	return ret;
> > diff --git a/include/dfu.h b/include/dfu.h
> > index 4de7d35914..5d85cc35ef 100644
> > --- a/include/dfu.h
> > +++ b/include/dfu.h
> > @@ -182,6 +182,8 @@ bool dfu_usb_get_reset(void);
> >  int dfu_read(struct dfu_entity *de, void *buf, int size, int
> > blk_seq_num); int dfu_write(struct dfu_entity *de, void *buf, int
> > size, int blk_seq_num); int dfu_flush(struct dfu_entity *de, void
> > *buf, int size, int blk_seq_num); +void dfu_flush_callback(struct
> > dfu_entity *dfu); +void dfu_initiated_callback(struct dfu_entity
> > *dfu);
> >  /*
> >   * dfu_defer_flush - pointer to store dfu_entity for deferred
> > flashing.
> 
> 
> 
> Best regards,
> 
> Lukasz Majewski
> 
> --

Best regards
Patrick
diff mbox series

Patch

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 2697235c24..f12c5afc66 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -22,6 +22,22 @@  static int dfu_alt_num;
 static int alt_num_cnt;
 static struct hash_algo *dfu_hash_algo;
 
+/*
+ * The purpose of the dfu_flush_callback() function is to
+ * provide callback for dfu user
+ */
+__weak void dfu_flush_callback(struct dfu_entity *dfu)
+{
+}
+
+/*
+ * The purpose of the dfu_flush_callback() function is to
+ * provide callback for dfu user
+ */
+__weak void dfu_initiated_callback(struct dfu_entity *dfu)
+{
+}
+
 /*
  * The purpose of the dfu_usb_get_reset() function is to
  * provide information if after USB_DETACH request
@@ -263,6 +279,7 @@  int dfu_transaction_initiate(struct dfu_entity *dfu, bool read)
 	}
 
 	dfu->inited = 1;
+	dfu_initiated_callback(dfu);
 
 	return 0;
 }
@@ -282,6 +299,8 @@  int dfu_flush(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
 		printf("\nDFU complete %s: 0x%08x\n", dfu_hash_algo->name,
 		       dfu->crc);
 
+	dfu_flush_callback(dfu);
+
 	dfu_transaction_cleanup(dfu);
 
 	return ret;
diff --git a/include/dfu.h b/include/dfu.h
index 4de7d35914..5d85cc35ef 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -182,6 +182,8 @@  bool dfu_usb_get_reset(void);
 int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
 int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
 int dfu_flush(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
+void dfu_flush_callback(struct dfu_entity *dfu);
+void dfu_initiated_callback(struct dfu_entity *dfu);
 
 /*
  * dfu_defer_flush - pointer to store dfu_entity for deferred flashing.