diff mbox

ASoC: wm5102: Use put_unaligned_be16

Message ID 20141226044457.GA12777@vaishali-Ideapad-Z570 (mailing list archive)
State New, archived
Headers show

Commit Message

Vaishali Thakkar Dec. 26, 2014, 4:44 a.m. UTC
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

Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
---
 sound/soc/codecs/wm5102.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Vaishali Thakkar Dec. 28, 2014, 11:05 a.m. UTC | #1
On Fri, Dec 26, 2014 at 10:14 AM, Vaishali Thakkar
<vthakkar1994@gmail.com> wrote:
> 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
>
> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
> ---
>  sound/soc/codecs/wm5102.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
> index f602349..fec21f9 100644
> --- a/sound/soc/codecs/wm5102.c
> +++ b/sound/soc/codecs/wm5102.c
> @@ -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;
> --
> 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.
Mark Brown Dec. 29, 2014, 3:53 p.m. UTC | #2
On Sun, Dec 28, 2014 at 04:35:00PM +0530, Vaishali Thakkar wrote:
> On Fri, Dec 26, 2014 at 10:14 AM, Vaishali Thakkar
> <vthakkar1994@gmail.com> wrote:
> > 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...
Vaishali Thakkar Dec. 29, 2014, 4:30 p.m. UTC | #3
On Mon, Dec 29, 2014 at 9:23 PM, Mark Brown <broonie@kernel.org> wrote:
> On Sun, Dec 28, 2014 at 04:35:00PM +0530, Vaishali Thakkar wrote:
>> On Fri, Dec 26, 2014 at 10:14 AM, Vaishali Thakkar
>> <vthakkar1994@gmail.com> wrote:
>> > 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.

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.

> 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
Mark Brown Dec. 29, 2014, 4:57 p.m. UTC | #4
On Mon, Dec 29, 2014 at 10:00:13PM +0530, Vaishali Thakkar wrote:
> On Mon, Dec 29, 2014 at 9:23 PM, Mark Brown <broonie@kernel.org> wrote:

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

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.
Vaishali Thakkar Dec. 29, 2014, 5:19 p.m. UTC | #5
On Dec 29, 2014 10:27 PM, "Mark Brown" <broonie@kernel.org> wrote:
>
> On Mon, Dec 29, 2014 at 10:00:13PM +0530, Vaishali Thakkar wrote:
> > On Mon, Dec 29, 2014 at 9:23 PM, Mark Brown <broonie@kernel.org> wrote:
>
> > > 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.
>
> 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. :-)
Charles Keepax Jan. 7, 2015, 10:01 a.m. UTC | #6
On Fri, Dec 26, 2014 at 10:14:57AM +0530, Vaishali Thakkar wrote:
> 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
> 
> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

CCing patches@opensource.wolfsonmicro.com would be handy though.

Thanks,
Charles
Vaishali Thakkar Jan. 7, 2015, 3:24 p.m. UTC | #7
On Wed, Jan 7, 2015 at 3:31 PM, Charles Keepax
<ckeepax@opensource.wolfsonmicro.com> wrote:
> On Fri, Dec 26, 2014 at 10:14:57AM +0530, Vaishali Thakkar wrote:
>> 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
>>
>> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
>> ---
>
> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
>
> CCing patches@opensource.wolfsonmicro.com 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??

> Thanks,
> Charles
Charles Keepax Jan. 7, 2015, 4:47 p.m. UTC | #8
On Wed, Jan 07, 2015 at 08:54:58PM +0530, Vaishali Thakkar wrote:
> On Wed, Jan 7, 2015 at 3:31 PM, Charles Keepax
> <ckeepax@opensource.wolfsonmicro.com> wrote:
> > On Fri, Dec 26, 2014 at 10:14:57AM +0530, Vaishali Thakkar wrote:
> >> This patch introduces the use of function put_unaligned_be16.
> >> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
> >> ---
> >
> > Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> >
> > CCing patches@opensource.wolfsonmicro.com 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
Mark Brown Jan. 7, 2015, 5:45 p.m. UTC | #9
On Fri, Dec 26, 2014 at 10:14:57AM +0530, Vaishali Thakkar wrote:
> 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.
diff mbox

Patch

diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index f602349..fec21f9 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -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;