Skip to contentSkip to conversation

ASoC: wm5102: Use put_unaligned_be16

PATCH In review Vaishali Thakkar 3 participants 10 messages Dec 26, 2014 – Jan 7, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: wm5102: Use put_unaligned_be16

This patch introduces the use of function put_unaligned_be16.

This is done using Coccinelle and semantic patch used is as follows:

@a@
typedef u16, __be16, uint16_t;
{u16,__be16,uint16_t} e16;
identifier tmp;
expression ptr;
expression y,e;
type T;
@@

- tmp = cpu_to_be16(y);

<+... when != tmp
(
- memcpy(ptr, (T)&tmp, \(2\|sizeof(u16)\|sizeof(__be16)\|sizeof(uint16_t)\|sizeof(e16)\));
+ put_unaligned_be16(y,ptr);
|
- memcpy(ptr, (T)&tmp, ...);
+ put_unaligned_be16(y,ptr);
)
...+>
? tmp = e

@@ type T; identifier a.tmp; @@

- T tmp;
...when != tmp

---
 sound/soc/codecs/wm5102.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
sound/soc/codecs/wm5102.c +4 -3
index f602349..fec21f9 100644
@@ -28,6 +28,7 @@
 
 #include <linux/mfd/arizona/core.h>
 #include <linux/mfd/arizona/registers.h>
+#include <asm/unaligned.h>
 
 #include "arizona.h"
 #include "wm5102.h"
@@ -617,11 +618,11 @@ static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
 {
 	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
 	struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
-	uint16_t data;
 
 	mutex_lock(&codec->mutex);
-	data = cpu_to_be16(arizona->dac_comp_coeff);
-	memcpy(ucontrol->value.bytes.data, &data, sizeof(data));
+
+	put_unaligned_be16(arizona->dac_comp_coeff,
+			   ucontrol->value.bytes.data);
 	mutex_unlock(&codec->mutex);
 
 	return 0;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 64 lines · Vaishali Thakkar

This patch introduces the use of function put_unaligned_be16.

This is done using Coccinelle and semantic patch used is as follows:

@a@
typedef u16, __be16, uint16_t;
{u16,__be16,uint16_t} e16;
identifier tmp;
expression ptr;
expression y,e;
type T;
@@

- tmp = cpu_to_be16(y);

<+... when != tmp
(
- memcpy(ptr, (T)&tmp, \(2\|sizeof(u16)\|sizeof(__be16)\|sizeof(uint16_t)\|sizeof(e16)\));
+ put_unaligned_be16(y,ptr);
|
- memcpy(ptr, (T)&tmp, ...);
+ put_unaligned_be16(y,ptr);
)
...+>
? tmp = e

@@ type T; identifier a.tmp; @@

- T tmp;
...when != tmp

---
 sound/soc/codecs/wm5102.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
sound/soc/codecs/wm5102.c +4 -4
index f602349..fec21f9 100644
@@ -28,6 +28,7 @@
 
 #include <linux/mfd/arizona/core.h>
 #include <linux/mfd/arizona/registers.h>
+#include <asm/unaligned.h>
 
 #include "arizona.h"
 #include "wm5102.h"
@@ -617,11 +618,11 @@ static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
-       uint16_t data;
 
        mutex_lock(&codec->mutex);
-       data = cpu_to_be16(arizona->dac_comp_coeff);
-       memcpy(ucontrol->value.bytes.data, &data, sizeof(data));
+
+       put_unaligned_be16(arizona->dac_comp_coeff,
+                          ucontrol->value.bytes.data);
        mutex_unlock(&codec->mutex);
 
        return 0;
--
Quoted 2 lines

1.9.1

Hello...Can someone please review my patch so that I can have idea about I am on a right way or not??
I think this is missed by developers.

Thank You.

Signature · 1 line
Vaishali
maintainer
#2 lore raw
Quoted 7 lines · Vaishali Thakkar
Quoted 1 line · Vaishali Thakkar

This patch introduces the use of function put_unaligned_be16.

Hello...Can someone please review my patch so that I can have idea about I am on a right way or not??
I think this is missed by developers.

You sent this on the 26th, two days later on the 28th you're demanding a review and complaining that we've missed this with a top posted quote. Even during a normal working period this would not be a reasnoable demand (a couple of weeks is normally a good *lower* limit, people have vacations and other things to do), and right now we're in the middle of the time of year when people from western societies typically take vacation.

This is not a good way to get people to pay attention, and since I don't want to create the impression that it works I'd not be expecting a quick response...

#3 lore raw
Quoted 9 lines · Mark Brown
Quoted 7 lines · Vaishali Thakkar
Quoted 1 line · Vaishali Thakkar

This patch introduces the use of function put_unaligned_be16.

Hello...Can someone please review my patch so that I can have idea about I am on a right way or not??
I think this is missed by developers.

Quoted 7 lines

You sent this on the 26th, two days later on the 28th you're demanding a review and complaining that we've missed this with a top posted quote. Even during a normal working period this would not be a reasnoable demand (a couple of weeks is normally a good *lower* limit, people have vacations and other things to do), and right now we're in the middle of the time of year when people from western societies typically take vacation.

I am really very sorry for this. Actually I am a newbie. I mainly worked during opw-application period and there we used to work with staging directory only. This is my first time, I am working with other parts of kernel. So, I had kind of feeling that I might have done something wrong that's why I am not getting any comments. But I think its my fault. I may need to understand workflow of community properly and I apologizes for that.

Quoted 3 lines

This is not a good way to get people to pay attention, and since I don't want to create the impression that it works I'd not be expecting a quick response...

I agree. This is definitely not a good way and thanks for your reply. I get to know about my mistake. I will be more careful next time.

Sorry Again

Signature · 1 line
Vaishali
maintainer
#4 lore raw
Quoted 10 lines · Vaishali Thakkar
Quoted 7 lines · Mark Brown

You sent this on the 26th, two days later on the 28th you're demanding a review and complaining that we've missed this with a top posted quote. Even during a normal working period this would not be a reasnoable demand (a couple of weeks is normally a good *lower* limit, people have vacations and other things to do), and right now we're in the middle of the time of year when people from western societies typically take vacation.

Quoted 7 lines

I am really very sorry for this. Actually I am a newbie. I mainly worked during opw-application period and there we used to work with staging directory only. This is my first time, I am working with other parts of kernel. So, I had kind of feeling that I might have done something wrong that's why I am not getting any comments. But I think its my fault. I may need to understand workflow of community properly and I apologizes for that.

Basically you should be allowing something measured in weeks to get a response rather than days unless there's some ultra critical issue - people might be busy, on vacation or whatever. Different parts of the kernel will have different working patterns and rules of thumb but in general be patient, try to leave it for a few weeks before doing anything unless you realise that there's some problem (eg, you forgot to CC someone or you spot a mistake yourself in which case do a new version fixing that mistake). If it's just been a week or two people might just be busy.

#5 lore raw
Quoted 5 lines · Mark Brown
Quoted 3 lines · Vaishali Thakkar
Quoted 1 line · Mark Brown

You sent this on the 26th, two days later on the 28th you're

demanding a

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

review and complaining that we've missed this with a top posted quote. Even during a normal working period this would not be a reasnoable demand (a couple of weeks is normally a good *lower* limit, people

have

Quoted 1 line
Quoted 1 line
Quoted 1 line

vacations and other things to do), and right now we're in the middle

of

Quoted 11 lines
Quoted 10 lines
Quoted 2 lines

the time of year when people from western societies typically take vacation.

I am really very sorry for this. Actually I am a newbie. I mainly worked during opw-application period and there we used to work with staging directory only. This is my first time, I am working with other parts of kernel. So, I had kind of feeling that I might have done something wrong that's why I am not getting any comments. But I think its my fault. I may need to understand workflow of community properly and I apologizes for that.

Quoted 9 lines

Basically you should be allowing something measured in weeks to get a response rather than days unless there's some ultra critical issue - people might be busy, on vacation or whatever. Different parts of the kernel will have different working patterns and rules of thumb but in general be patient, try to leave it for a few weeks before doing anything unless you realise that there's some problem (eg, you forgot to CC someone or you spot a mistake yourself in which case do a new version fixing that mistake). If it's just been a week or two people might just be busy.

Ok. I got your point. This makes sense. Ill keep these things in my mind and will follow it.
Also, thanks for your reply.It makes me realize my mistake and got to learn about common working pattern of kernel community. :-)

Acked-by on v1 1/1
#6 lore raw
In reply to Vaishali Thakkar
Quoted 26 lines · Vaishali Thakkar

This patch introduces the use of function put_unaligned_be16.

This is done using Coccinelle and semantic patch used is as follows:

@a@
typedef u16, __be16, uint16_t;
{u16,__be16,uint16_t} e16;
identifier tmp;
expression ptr;
expression y,e;
type T;
@@

- tmp = cpu_to_be16(y);

<+... when != tmp
(
- memcpy(ptr, (T)&tmp, \(2\|sizeof(u16)\|sizeof(__be16)\|sizeof(uint16_t)\|sizeof(e16)\));
+ put_unaligned_be16(y,ptr);
|
- memcpy(ptr, (T)&tmp, ...);
+ put_unaligned_be16(y,ptr);
)
...+>
? tmp = e

Quoted 7 lines

@@ type T; identifier a.tmp; @@

- T tmp;
...when != tmp

---

CCing [email protected] would be handy though.

Thanks,
Charles

#7 lore raw
Quoted 32 lines · Charles Keepax
Quoted 31 lines · Vaishali Thakkar

This patch introduces the use of function put_unaligned_be16.

This is done using Coccinelle and semantic patch used is as follows:

@a@
typedef u16, __be16, uint16_t;
{u16,__be16,uint16_t} e16;
identifier tmp;
expression ptr;
expression y,e;
type T;
@@

- tmp = cpu_to_be16(y);

<+... when != tmp
(
- memcpy(ptr, (T)&tmp, \(2\|sizeof(u16)\|sizeof(__be16)\|sizeof(uint16_t)\|sizeof(e16)\));
+ put_unaligned_be16(y,ptr);
|
- memcpy(ptr, (T)&tmp, ...);
+ put_unaligned_be16(y,ptr);
)
...+>
? tmp = e

@@ type T; identifier a.tmp; @@

- T tmp;
...when != tmp

Quoted 6 lines
Quoted 2 lines

---

CCing [email protected] would be handy though.

Ok. Will keep this in mind while sending patches of audio drivers.

Do I need to send this patch again with CC??

Quoted 2 lines

Thanks,
Charles

Signature · 1 line
Vaishali
#8 lore raw
Quoted 7 lines · Vaishali Thakkar
Quoted 5 lines · Charles Keepax
Quoted 3 lines · Vaishali Thakkar

This patch introduces the use of function put_unaligned_be16.

---

Quoted 7 lines
Quoted 3 lines

CCing [email protected] would be handy though.

Ok. Will keep this in mind while sending patches of audio drivers.

Do I need to send this patch again with CC??

No its fine I have already acked it now.

Thanks,
Charles

maintainer
#9 lore raw
In reply to Vaishali Thakkar
Quoted 3 lines · Vaishali Thakkar

This patch introduces the use of function put_unaligned_be16.

This is done using Coccinelle and semantic patch used is as follows:

This doesn't apply against current code (-next, or my git tree), please check and resend.