diff mbox

[U-Boot,3/4] dfu: Find DFU alt setting number by passing its name

Message ID 1378819765-20159-4-git-send-email-l.majewski@samsung.com
State Superseded
Delegated to: Marek Vasut
Headers show

Commit Message

Łukasz Majewski Sept. 10, 2013, 1:29 p.m. UTC
New function - dfu_get_alt() has been added to dfu core. If proper
alt setting is present, this function returns its number
corresponding to passed name.

Change-Id: Icd75f3aa3a6f6e306c77b28cabe620e4e6a253ea
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/dfu/dfu.c |   12 ++++++++++++
 include/dfu.h     |    1 +
 2 files changed, 13 insertions(+)

Comments

Marek Vasut Sept. 10, 2013, 2:32 p.m. UTC | #1
Dear Lukasz Majewski,

> New function - dfu_get_alt() has been added to dfu core. If proper
> alt setting is present, this function returns its number
> corresponding to passed name.
> 
> Change-Id: Icd75f3aa3a6f6e306c77b28cabe620e4e6a253ea
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  drivers/dfu/dfu.c |   12 ++++++++++++
>  include/dfu.h     |    1 +
>  2 files changed, 13 insertions(+)
> 
> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> index 2f1e2af..180d083 100644
> --- a/drivers/dfu/dfu.c
> +++ b/drivers/dfu/dfu.c
> @@ -414,3 +414,15 @@ struct dfu_entity *dfu_get_entity(int alt)
> 
>  	return NULL;
>  }
> +
> +int dfu_get_alt(const char *name)
> +{
> +	struct dfu_entity *dfu;
> +
> +	list_for_each_entry(dfu, &dfu_list, list) {
> +		if (!strncmp(dfu->name, name, strlen(dfu->name)))
> +			return dfu->alt;
> +	}
> +
> +	return -ENODEV;
> +}
> diff --git a/include/dfu.h b/include/dfu.h
> index 7779710..8838f9c 100644
> --- a/include/dfu.h
> +++ b/include/dfu.h
> @@ -112,6 +112,7 @@ const char *dfu_get_layout(enum dfu_layout l);
>  struct dfu_entity *dfu_get_entity(int alt);
>  char *dfu_extract_token(char** e, int *n);
>  void dfu_trigger_reset(void);
> +int dfu_get_alt(const char *name);
>  bool dfu_reset(void);
> 
>  int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num);

Is this code used anywhere ?

Best regards,
Marek Vasut
Łukasz Majewski Sept. 10, 2013, 3:13 p.m. UTC | #2
Hi Marek,

> Dear Lukasz Majewski,
> 
> > New function - dfu_get_alt() has been added to dfu core. If proper
> > alt setting is present, this function returns its number
> > corresponding to passed name.
> > 
> > Change-Id: Icd75f3aa3a6f6e306c77b28cabe620e4e6a253ea
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  drivers/dfu/dfu.c |   12 ++++++++++++
> >  include/dfu.h     |    1 +
> >  2 files changed, 13 insertions(+)
> > 
> > diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> > index 2f1e2af..180d083 100644
> > --- a/drivers/dfu/dfu.c
> > +++ b/drivers/dfu/dfu.c
> > @@ -414,3 +414,15 @@ struct dfu_entity *dfu_get_entity(int alt)
> > 
> >  	return NULL;
> >  }
> > +
> > +int dfu_get_alt(const char *name)
> > +{
> > +	struct dfu_entity *dfu;
> > +
> > +	list_for_each_entry(dfu, &dfu_list, list) {
> > +		if (!strncmp(dfu->name, name, strlen(dfu->name)))
> > +			return dfu->alt;
> > +	}
> > +
> > +	return -ENODEV;
> > +}
> > diff --git a/include/dfu.h b/include/dfu.h
> > index 7779710..8838f9c 100644
> > --- a/include/dfu.h
> > +++ b/include/dfu.h
> > @@ -112,6 +112,7 @@ const char *dfu_get_layout(enum dfu_layout l);
> >  struct dfu_entity *dfu_get_entity(int alt);
> >  char *dfu_extract_token(char** e, int *n);
> >  void dfu_trigger_reset(void);
> > +int dfu_get_alt(const char *name);
> >  bool dfu_reset(void);
> > 
> >  int dfu_read(struct dfu_entity *de, void *buf, int size, int
> > blk_seq_num);
> 
> Is this code used anywhere ?

Hmm.... By mistake I've added part of my ongoing USB related work to
DFU fixes (as you see it is DFU related).

Since it is (for now) a dead code, please don't consider this patch.

Shall I prepare v2 without this patch or will you be so kind and
review other patches in the current patch set?



> 
> Best regards,
> Marek Vasut
Marek Vasut Sept. 10, 2013, 9:20 p.m. UTC | #3
Dear Lukasz Majewski,

> Hi Marek,
> 
> > Dear Lukasz Majewski,
> > 
> > > New function - dfu_get_alt() has been added to dfu core. If proper
> > > alt setting is present, this function returns its number
> > > corresponding to passed name.
> > > 
> > > Change-Id: Icd75f3aa3a6f6e306c77b28cabe620e4e6a253ea
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > 
> > >  drivers/dfu/dfu.c |   12 ++++++++++++
> > >  include/dfu.h     |    1 +
> > >  2 files changed, 13 insertions(+)
> > > 
> > > diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> > > index 2f1e2af..180d083 100644
> > > --- a/drivers/dfu/dfu.c
> > > +++ b/drivers/dfu/dfu.c
> > > @@ -414,3 +414,15 @@ struct dfu_entity *dfu_get_entity(int alt)
> > > 
> > >  	return NULL;
> > >  
> > >  }
> > > 
> > > +
> > > +int dfu_get_alt(const char *name)
> > > +{
> > > +	struct dfu_entity *dfu;
> > > +
> > > +	list_for_each_entry(dfu, &dfu_list, list) {
> > > +		if (!strncmp(dfu->name, name, strlen(dfu->name)))
> > > +			return dfu->alt;
> > > +	}
> > > +
> > > +	return -ENODEV;
> > > +}
> > > diff --git a/include/dfu.h b/include/dfu.h
> > > index 7779710..8838f9c 100644
> > > --- a/include/dfu.h
> > > +++ b/include/dfu.h
> > > @@ -112,6 +112,7 @@ const char *dfu_get_layout(enum dfu_layout l);
> > > 
> > >  struct dfu_entity *dfu_get_entity(int alt);
> > >  char *dfu_extract_token(char** e, int *n);
> > >  void dfu_trigger_reset(void);
> > > 
> > > +int dfu_get_alt(const char *name);
> > > 
> > >  bool dfu_reset(void);
> > >  
> > >  int dfu_read(struct dfu_entity *de, void *buf, int size, int
> > > 
> > > blk_seq_num);
> > 
> > Is this code used anywhere ?
> 
> Hmm.... By mistake I've added part of my ongoing USB related work to
> DFU fixes (as you see it is DFU related).
> 
> Since it is (for now) a dead code, please don't consider this patch.
> 
> Shall I prepare v2 without this patch or will you be so kind and
> review other patches in the current patch set?

Rest is OK, I'd like to know Heiko's opinion too before applying though.

Best regards,
Marek Vasut
Heiko Schocher Sept. 11, 2013, 4:42 a.m. UTC | #4
Hello Marek,

Am 10.09.2013 23:20, schrieb Marek Vasut:
> Dear Lukasz Majewski,
>
>> Hi Marek,
>>
>>> Dear Lukasz Majewski,
>>>
>>>> New function - dfu_get_alt() has been added to dfu core. If proper
>>>> alt setting is present, this function returns its number
>>>> corresponding to passed name.
>>>>
>>>> Change-Id: Icd75f3aa3a6f6e306c77b28cabe620e4e6a253ea
>>>> Signed-off-by: Lukasz Majewski<l.majewski@samsung.com>
>>>> ---
>>>>
>>>>   drivers/dfu/dfu.c |   12 ++++++++++++
>>>>   include/dfu.h     |    1 +
>>>>   2 files changed, 13 insertions(+)
>>>>
>>>> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
>>>> index 2f1e2af..180d083 100644
>>>> --- a/drivers/dfu/dfu.c
>>>> +++ b/drivers/dfu/dfu.c
>>>> @@ -414,3 +414,15 @@ struct dfu_entity *dfu_get_entity(int alt)
>>>>
>>>>   	return NULL;
>>>>
>>>>   }
>>>>
>>>> +
>>>> +int dfu_get_alt(const char *name)
>>>> +{
>>>> +	struct dfu_entity *dfu;
>>>> +
>>>> +	list_for_each_entry(dfu,&dfu_list, list) {
>>>> +		if (!strncmp(dfu->name, name, strlen(dfu->name)))
>>>> +			return dfu->alt;
>>>> +	}
>>>> +
>>>> +	return -ENODEV;
>>>> +}
>>>> diff --git a/include/dfu.h b/include/dfu.h
>>>> index 7779710..8838f9c 100644
>>>> --- a/include/dfu.h
>>>> +++ b/include/dfu.h
>>>> @@ -112,6 +112,7 @@ const char *dfu_get_layout(enum dfu_layout l);
>>>>
>>>>   struct dfu_entity *dfu_get_entity(int alt);
>>>>   char *dfu_extract_token(char** e, int *n);
>>>>   void dfu_trigger_reset(void);
>>>>
>>>> +int dfu_get_alt(const char *name);
>>>>
>>>>   bool dfu_reset(void);
>>>>
>>>>   int dfu_read(struct dfu_entity *de, void *buf, int size, int
>>>>
>>>> blk_seq_num);
>>>
>>> Is this code used anywhere ?
>>
>> Hmm.... By mistake I've added part of my ongoing USB related work to
>> DFU fixes (as you see it is DFU related).
>>
>> Since it is (for now) a dead code, please don't consider this patch.
>>
>> Shall I prepare v2 without this patch or will you be so kind and
>> review other patches in the current patch set?
>
> Rest is OK, I'd like to know Heiko's opinion too before applying though.

Yep, rest of the patches are OK, I tested them on the dxr2 and rut
boards. So from my side they can go in ... without this patch, as
it adds dead code. @Lukasz: Please post this patch again, if you
use this code, thanks!

bye,
Heiko
Łukasz Majewski Sept. 11, 2013, 7:16 a.m. UTC | #5
Hi Heiko, Marek,

> Hello Marek,
> 
> Am 10.09.2013 23:20, schrieb Marek Vasut:
> > Dear Lukasz Majewski,
> >
> >> Hi Marek,
> >>
> >>> Dear Lukasz Majewski,
> >>>
> >>>> New function - dfu_get_alt() has been added to dfu core. If
> >>>> proper alt setting is present, this function returns its number
> >>>> corresponding to passed name.
> >>>>
> >>>> Change-Id: Icd75f3aa3a6f6e306c77b28cabe620e4e6a253ea
> >>>> Signed-off-by: Lukasz Majewski<l.majewski@samsung.com>
> >>>> ---
> >>>>
> >>>>   drivers/dfu/dfu.c |   12 ++++++++++++
> >>>>   include/dfu.h     |    1 +
> >>>>   2 files changed, 13 insertions(+)
> >>>>
> >>>> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> >>>> index 2f1e2af..180d083 100644
> >>>> --- a/drivers/dfu/dfu.c
> >>>> +++ b/drivers/dfu/dfu.c
> >>>> @@ -414,3 +414,15 @@ struct dfu_entity *dfu_get_entity(int alt)
> >>>>
> >>>>   	return NULL;
> >>>>
> >>>>   }
> >>>>
> >>>> +
> >>>> +int dfu_get_alt(const char *name)
> >>>> +{
> >>>> +	struct dfu_entity *dfu;
> >>>> +
> >>>> +	list_for_each_entry(dfu,&dfu_list, list) {
> >>>> +		if (!strncmp(dfu->name, name,
> >>>> strlen(dfu->name)))
> >>>> +			return dfu->alt;
> >>>> +	}
> >>>> +
> >>>> +	return -ENODEV;
> >>>> +}
> >>>> diff --git a/include/dfu.h b/include/dfu.h
> >>>> index 7779710..8838f9c 100644
> >>>> --- a/include/dfu.h
> >>>> +++ b/include/dfu.h
> >>>> @@ -112,6 +112,7 @@ const char *dfu_get_layout(enum dfu_layout
> >>>> l);
> >>>>
> >>>>   struct dfu_entity *dfu_get_entity(int alt);
> >>>>   char *dfu_extract_token(char** e, int *n);
> >>>>   void dfu_trigger_reset(void);
> >>>>
> >>>> +int dfu_get_alt(const char *name);
> >>>>
> >>>>   bool dfu_reset(void);
> >>>>
> >>>>   int dfu_read(struct dfu_entity *de, void *buf, int size, int
> >>>>
> >>>> blk_seq_num);
> >>>
> >>> Is this code used anywhere ?
> >>
> >> Hmm.... By mistake I've added part of my ongoing USB related work
> >> to DFU fixes (as you see it is DFU related).
> >>
> >> Since it is (for now) a dead code, please don't consider this
> >> patch.
> >>
> >> Shall I prepare v2 without this patch or will you be so kind and
> >> review other patches in the current patch set?
> >
> > Rest is OK, I'd like to know Heiko's opinion too before applying
> > though.
> 
> Yep, rest of the patches are OK, I tested them on the dxr2 and rut
> boards. So from my side they can go in ... without this patch, as
> it adds dead code. @Lukasz: Please post this patch again, if you
> use this code, thanks!

I will, since I'm developing new USB gadget, which reuses DFU write
backend. 

> 
> bye,
> Heiko
diff mbox

Patch

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 2f1e2af..180d083 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -414,3 +414,15 @@  struct dfu_entity *dfu_get_entity(int alt)
 
 	return NULL;
 }
+
+int dfu_get_alt(const char *name)
+{
+	struct dfu_entity *dfu;
+
+	list_for_each_entry(dfu, &dfu_list, list) {
+		if (!strncmp(dfu->name, name, strlen(dfu->name)))
+			return dfu->alt;
+	}
+
+	return -ENODEV;
+}
diff --git a/include/dfu.h b/include/dfu.h
index 7779710..8838f9c 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -112,6 +112,7 @@  const char *dfu_get_layout(enum dfu_layout l);
 struct dfu_entity *dfu_get_entity(int alt);
 char *dfu_extract_token(char** e, int *n);
 void dfu_trigger_reset(void);
+int dfu_get_alt(const char *name);
 bool dfu_reset(void);
 
 int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num);