[PATCH 1/3] [PATCH] staging: greybus: fix warnings about endianness detected by sparse

2020-09-24 Thread Coiby Xu
This patch fix the following warnings from sparse,

$ make C=2 drivers/staging/greybus/
drivers/staging/greybus/audio_module.c:222:25: warning: incorrect type in 
assignment (different base types)
drivers/staging/greybus/audio_module.c:222:25:expected restricted __le16 
[usertype] data_cport
drivers/staging/greybus/audio_module.c:222:25:got unsigned short [usertype] 
intf_cport_id
drivers/staging/greybus/audio_topology.c:460:40: warning: restricted __le32 
degrades to integer
drivers/staging/greybus/audio_topology.c:691:41: warning: incorrect type in 
assignment (different base types)
drivers/staging/greybus/audio_topology.c:691:41:expected unsigned int access
drivers/staging/greybus/audio_topology.c:691:41:got restricted __le32 
[usertype] access
drivers/staging/greybus/audio_topology.c:746:44: warning: incorrect type in 
assignment (different base types)
drivers/staging/greybus/audio_topology.c:746:44:expected unsigned int
drivers/staging/greybus/audio_topology.c:746:44:got restricted __le32
drivers/staging/greybus/audio_topology.c:748:52: warning: incorrect type in 
assignment (different base types)
drivers/staging/greybus/audio_topology.c:748:52:expected unsigned int
drivers/staging/greybus/audio_topology.c:748:52:got restricted __le32
drivers/staging/greybus/audio_topology.c:802:42: warning: restricted __le32 
degrades to integer
drivers/staging/greybus/audio_topology.c:805:50: warning: incorrect type in 
assignment (different base types)
drivers/staging/greybus/audio_topology.c:805:50:expected restricted __le32
drivers/staging/greybus/audio_topology.c:805:50:got unsigned int
drivers/staging/greybus/audio_topology.c:814:50: warning: restricted __le32 
degrades to integer
drivers/staging/greybus/audio_topology.c:817:58: warning: incorrect type in 
assignment (different base types)
drivers/staging/greybus/audio_topology.c:817:58:expected restricted __le32
drivers/staging/greybus/audio_topology.c:817:58:got unsigned int
drivers/staging/greybus/audio_topology.c:889:25: warning: incorrect type in 
assignment (different base types)
drivers/staging/greybus/audio_topology.c:889:25:expected unsigned int access
drivers/staging/greybus/audio_topology.c:889:25:got restricted __le32 
[usertype] access

Suggested-by: Dan Carpenter 
Reviewed-by: Dan Carpenter 
Signed-off-by: Coiby Xu 
---
 drivers/staging/greybus/audio_module.c   |  6 +++---
 drivers/staging/greybus/audio_topology.c | 18 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/greybus/audio_module.c 
b/drivers/staging/greybus/audio_module.c
index 16f60256adb2..c52c4f361b90 100644
--- a/drivers/staging/greybus/audio_module.c
+++ b/drivers/staging/greybus/audio_module.c
@@ -219,7 +219,7 @@ static int gb_audio_add_data_connection(struct 
gbaudio_module_info *gbmodule,
 
greybus_set_drvdata(bundle, gbmodule);
dai->id = 0;
-   dai->data_cport = connection->intf_cport_id;
+   dai->data_cport = cpu_to_le16(connection->intf_cport_id);
dai->connection = connection;
list_add(&dai->list, &gbmodule->data_list);
 
@@ -329,7 +329,7 @@ static int gb_audio_probe(struct gb_bundle *bundle,
if (ret) {
dev_err(dev,
"%d:Error while enabling %d:data connection\n",
-   ret, dai->data_cport);
+   ret, le16_to_cpu(dai->data_cport));
goto disable_data_connection;
}
}
@@ -451,7 +451,7 @@ static int gb_audio_resume(struct device *dev)
if (ret) {
dev_err(dev,
"%d:Error while enabling %d:data connection\n",
-   ret, dai->data_cport);
+   ret, le16_to_cpu(dai->data_cport));
return ret;
}
}
diff --git a/drivers/staging/greybus/audio_topology.c 
b/drivers/staging/greybus/audio_topology.c
index 83b38ae8908c..56bf1a4f95ad 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -466,7 +466,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol 
*kcontrol,
goto exit;
 
/* update ucontrol */
-   if (gbvalue.value.integer_value[0] != val) {
+   if (gbvalue.value.integer_value[0] != cpu_to_le32(val)) {
for (wi = 0; wi < wlist->num_widgets; wi++) {
widget = wlist->widgets[wi];
snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,
@@ -689,7 +689,7 @@ static int gbaudio_tplg_create_kcontrol(struct 
gbaudio_module_info *gb,
return -ENOMEM;
ctldata->ctl_id = ctl->id;
ctldata->data_cport = le16_to_cpu(ctl->data_cport);
-   ctldata->access = ctl->access;
+

[PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t

2020-09-24 Thread Coiby Xu
Use __8 to replace int and remove the unnecessary __bitwise type attribute.

Found by sparse,

$ make C=2 drivers/staging/greybus/
drivers/staging/greybus/audio_topology.c:185:24: warning: cast to restricted 
snd_ctl_elem_type_t
drivers/staging/greybus/audio_topology.c:679:14: warning: restricted 
snd_ctl_elem_iface_t degrades to integer
drivers/staging/greybus/audio_topology.c:906:14: warning: restricted 
snd_ctl_elem_iface_t degrades to integer

Signed-off-by: Coiby Xu 
---
 drivers/staging/greybus/audio_topology.c | 2 +-
 include/uapi/sound/asound.h  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/audio_topology.c 
b/drivers/staging/greybus/audio_topology.c
index 56bf1a4f95ad..f6023ff390c2 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -182,7 +182,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol 
*kcontrol,
/* update uinfo */
uinfo->access = data->access;
uinfo->count = data->vcount;
-   uinfo->type = (snd_ctl_elem_type_t)info->type;
+   uinfo->type = info->type;
 
switch (info->type) {
case GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN:
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index 535a7229e1d9..8e71a95644ab 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -950,7 +950,7 @@ struct snd_ctl_card_info {
unsigned char components[128];  /* card components / fine 
identification, delimited with one space (AC97 etc..) */
 };
 
-typedef int __bitwise snd_ctl_elem_type_t;
+typedef __u8 snd_ctl_elem_type_t;
 #defineSNDRV_CTL_ELEM_TYPE_NONE((__force snd_ctl_elem_type_t) 
0) /* invalid */
 #defineSNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 
1) /* boolean type */
 #defineSNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 
2) /* integer type */
@@ -960,7 +960,7 @@ typedef int __bitwise snd_ctl_elem_type_t;
 #defineSNDRV_CTL_ELEM_TYPE_INTEGER64   ((__force snd_ctl_elem_type_t) 
6) /* 64-bit integer type */
 #defineSNDRV_CTL_ELEM_TYPE_LASTSNDRV_CTL_ELEM_TYPE_INTEGER64
 
-typedef int __bitwise snd_ctl_elem_iface_t;
+typedef __u8 snd_ctl_elem_iface_t;
 #defineSNDRV_CTL_ELEM_IFACE_CARD   ((__force snd_ctl_elem_iface_t) 
0) /* global control */
 #defineSNDRV_CTL_ELEM_IFACE_HWDEP  ((__force snd_ctl_elem_iface_t) 
1) /* hardware dependent device */
 #defineSNDRV_CTL_ELEM_IFACE_MIXER  ((__force snd_ctl_elem_iface_t) 
2) /* virtual mixer device */
-- 
2.28.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging: greybus: codecs: use SNDRV_PCM_FMTBIT_S16_LE for format bitmask

2020-09-24 Thread Coiby Xu
snd_soc_pcm_stream.formats should use the bitmask SNDRV_PCM_FMTBIT_*
instead of the sequential integers SNDRV_PCM_FORMAT_* as explained by
commit e712bfca1ac1f63f622f87c2f33b57608f2a4d19
("ASoC: codecs: use SNDRV_PCM_FMTBIT_* for format bitmask").

Found by sparse,

$ make C=2 drivers/staging/greybus/
drivers/staging/greybus/audio_codec.c:691:36: warning: incorrect type in 
initializer (different base types)
drivers/staging/greybus/audio_codec.c:691:36:expected unsigned long long 
[usertype] formats
drivers/staging/greybus/audio_codec.c:691:36:got restricted 
snd_pcm_format_t [usertype]
drivers/staging/greybus/audio_codec.c:701:36: warning: incorrect type in 
initializer (different base types)
drivers/staging/greybus/audio_codec.c:701:36:expected unsigned long long 
[usertype] formats
drivers/staging/greybus/audio_codec.c:701:36:got restricted 
snd_pcm_format_t [usertype]

Signed-off-by: Coiby Xu 
---
 drivers/staging/greybus/audio_codec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/audio_codec.c 
b/drivers/staging/greybus/audio_codec.c
index 74538f8c5fa4..494aa823e998 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -688,7 +688,7 @@ static struct snd_soc_dai_driver gbaudio_dai[] = {
.playback = {
.stream_name = "I2S 0 Playback",
.rates = SNDRV_PCM_RATE_48000,
-   .formats = SNDRV_PCM_FORMAT_S16_LE,
+   .formats = SNDRV_PCM_FMTBIT_S16_LE,
.rate_max = 48000,
.rate_min = 48000,
.channels_min = 1,
@@ -698,7 +698,7 @@ static struct snd_soc_dai_driver gbaudio_dai[] = {
.capture = {
.stream_name = "I2S 0 Capture",
.rates = SNDRV_PCM_RATE_48000,
-   .formats = SNDRV_PCM_FORMAT_S16_LE,
+   .formats = SNDRV_PCM_FMTBIT_S16_LE,
.rate_max = 48000,
.rate_min = 48000,
.channels_min = 1,
-- 
2.28.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t

2020-09-24 Thread David Laight
From: Coiby Xu
> Sent: 24 September 2020 11:21
> Use __8 to replace int and remove the unnecessary __bitwise type attribute.
> 
> Found by sparse,
...
> diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
> index 535a7229e1d9..8e71a95644ab 100644
> --- a/include/uapi/sound/asound.h
> +++ b/include/uapi/sound/asound.h
> @@ -950,7 +950,7 @@ struct snd_ctl_card_info {
>   unsigned char components[128];  /* card components / fine 
> identification, delimited with one
> space (AC97 etc..) */
>  };
> 
> -typedef int __bitwise snd_ctl_elem_type_t;
> +typedef __u8 snd_ctl_elem_type_t;
>  #define  SNDRV_CTL_ELEM_TYPE_NONE((__force snd_ctl_elem_type_t) 
> 0) /* invalid */
>  #define  SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 
> 1) /* boolean type */
>  #define  SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 
> 2) /* integer type */

WTF is all that about anyway??
What is wrong with:
#define SNDRV_CTL_ELEM_TYPE_NONE0u /* invalid */

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t

2020-09-24 Thread Greg Kroah-Hartman
On Thu, Sep 24, 2020 at 06:20:39PM +0800, Coiby Xu wrote:
> Use __8 to replace int and remove the unnecessary __bitwise type attribute.
> 
> Found by sparse,
> 
> $ make C=2 drivers/staging/greybus/
> drivers/staging/greybus/audio_topology.c:185:24: warning: cast to restricted 
> snd_ctl_elem_type_t
> drivers/staging/greybus/audio_topology.c:679:14: warning: restricted 
> snd_ctl_elem_iface_t degrades to integer
> drivers/staging/greybus/audio_topology.c:906:14: warning: restricted 
> snd_ctl_elem_iface_t degrades to integer
> 
> Signed-off-by: Coiby Xu 
> ---
>  drivers/staging/greybus/audio_topology.c | 2 +-
>  include/uapi/sound/asound.h  | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/greybus/audio_topology.c 
> b/drivers/staging/greybus/audio_topology.c
> index 56bf1a4f95ad..f6023ff390c2 100644
> --- a/drivers/staging/greybus/audio_topology.c
> +++ b/drivers/staging/greybus/audio_topology.c
> @@ -182,7 +182,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol 
> *kcontrol,
>   /* update uinfo */
>   uinfo->access = data->access;
>   uinfo->count = data->vcount;
> - uinfo->type = (snd_ctl_elem_type_t)info->type;
> + uinfo->type = info->type;
>  
>   switch (info->type) {
>   case GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN:
> diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
> index 535a7229e1d9..8e71a95644ab 100644
> --- a/include/uapi/sound/asound.h
> +++ b/include/uapi/sound/asound.h
> @@ -950,7 +950,7 @@ struct snd_ctl_card_info {
>   unsigned char components[128];  /* card components / fine 
> identification, delimited with one space (AC97 etc..) */
>  };
>  
> -typedef int __bitwise snd_ctl_elem_type_t;
> +typedef __u8 snd_ctl_elem_type_t;
>  #define  SNDRV_CTL_ELEM_TYPE_NONE((__force snd_ctl_elem_type_t) 
> 0) /* invalid */
>  #define  SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 
> 1) /* boolean type */
>  #define  SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 
> 2) /* integer type */
> @@ -960,7 +960,7 @@ typedef int __bitwise snd_ctl_elem_type_t;
>  #define  SNDRV_CTL_ELEM_TYPE_INTEGER64   ((__force snd_ctl_elem_type_t) 
> 6) /* 64-bit integer type */
>  #define  SNDRV_CTL_ELEM_TYPE_LASTSNDRV_CTL_ELEM_TYPE_INTEGER64
>  
> -typedef int __bitwise snd_ctl_elem_iface_t;
> +typedef __u8 snd_ctl_elem_iface_t;
>  #define  SNDRV_CTL_ELEM_IFACE_CARD   ((__force snd_ctl_elem_iface_t) 
> 0) /* global control */
>  #define  SNDRV_CTL_ELEM_IFACE_HWDEP  ((__force snd_ctl_elem_iface_t) 
> 1) /* hardware dependent device */
>  #define  SNDRV_CTL_ELEM_IFACE_MIXER  ((__force snd_ctl_elem_iface_t) 
> 2) /* virtual mixer device */

I can't take a uapi sound header file patch along with a driver change,
these need to be independant.

And this is a userspace api, you just changed the size of an externally
facing variable, are you _SURE_ that is ok to do?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [greybus-dev] [PATCH 1/3] [PATCH] staging: greybus: fix warnings about endianness detected by sparse

2020-09-24 Thread Alex Elder
On 9/24/20 5:20 AM, Coiby Xu wrote:
> This patch fix the following warnings from sparse,

You need to address Greg's comment.

But in general this looks good.  I have one comment below, which
you can address in v2.  If you (or others) disagree with it, I'm
fine with your code as-is.  Either way, you can add this:

Reviewed-by: Alex Elder 

> $ make C=2 drivers/staging/greybus/
> drivers/staging/greybus/audio_module.c:222:25: warning: incorrect type in 
> assignment (different base types)
> drivers/staging/greybus/audio_module.c:222:25:expected restricted __le16 
> [usertype] data_cport
> drivers/staging/greybus/audio_module.c:222:25:got unsigned short 
> [usertype] intf_cport_id
> drivers/staging/greybus/audio_topology.c:460:40: warning: restricted __le32 
> degrades to integer
> drivers/staging/greybus/audio_topology.c:691:41: warning: incorrect type in 
> assignment (different base types)

. . .

> diff --git a/drivers/staging/greybus/audio_topology.c 
> b/drivers/staging/greybus/audio_topology.c
> index 83b38ae8908c..56bf1a4f95ad 100644
> --- a/drivers/staging/greybus/audio_topology.c
> +++ b/drivers/staging/greybus/audio_topology.c
> @@ -466,7 +466,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol 
> *kcontrol,
>   goto exit;
>  
>   /* update ucontrol */
> - if (gbvalue.value.integer_value[0] != val) {
> + if (gbvalue.value.integer_value[0] != cpu_to_le32(val)) {

It's equivalent, but I have a small preference to convert
the value from gbvalue into CPU byte order rather than
what you have here.

>   for (wi = 0; wi < wlist->num_widgets; wi++) {
>   widget = wlist->widgets[wi];
>   snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol,
> @@ -689,7 +689,7 @@ static int gbaudio_tplg_create_kcontrol(struct 
> gbaudio_module_info *gb,
>   return -ENOMEM;
>   ctldata->ctl_id = ctl->id;
>   ctldata->data_cport = le16_to_cpu(ctl->data_cport);
> - ctldata->access = ctl->access;
> + ctldata->access = le32_to_cpu(ctl->access);
>   ctldata->vcount = ctl->count_values;
>   ctldata->info = &ctl->info;
>   *kctl = (struct snd_kcontrol_new)
> @@ -744,10 +744,10 @@ static int gbcodec_enum_dapm_ctl_get(struct 
> snd_kcontrol *kcontrol,
>   return ret;
>   }
>  
> - ucontrol->value.enumerated.item[0] = gbvalue.value.enumerated_item[0];
> + ucontrol->value.enumerated.item[0] = 
> le32_to_cpu(gbvalue.value.enumerated_item[0]);
>   if (e->shift_l != e->shift_r)
>   ucontrol->value.enumerated.item[1] =
> - gbvalue.value.enumerated_item[1];
> + le32_to_cpu(gbvalue.value.enumerated_item[1]);
>  
>   return 0;
>  }
> @@ -801,10 +801,10 @@ static int gbcodec_enum_dapm_ctl_put(struct 
> snd_kcontrol *kcontrol,
>   mask = e->mask << e->shift_l;
>  
>   if (gbvalue.value.enumerated_item[0] !=
> - ucontrol->value.enumerated.item[0]) {
> + cpu_to_le32(ucontrol->value.enumerated.item[0])) {
>   change = 1;
>   gbvalue.value.enumerated_item[0] =
> - ucontrol->value.enumerated.item[0];
> + cpu_to_le32(ucontrol->value.enumerated.item[0]);
>   }
>  
>   if (e->shift_l != e->shift_r) {
> @@ -813,10 +813,10 @@ static int gbcodec_enum_dapm_ctl_put(struct 
> snd_kcontrol *kcontrol,
>   val |= ucontrol->value.enumerated.item[1] << e->shift_r;
>   mask |= e->mask << e->shift_r;
>   if (gbvalue.value.enumerated_item[1] !=
> - ucontrol->value.enumerated.item[1]) {
> + cpu_to_le32(ucontrol->value.enumerated.item[1])) {
>   change = 1;
>   gbvalue.value.enumerated_item[1] =
> - ucontrol->value.enumerated.item[1];
> + cpu_to_le32(ucontrol->value.enumerated.item[1]);
>   }
>   }
>  
> @@ -887,7 +887,7 @@ static int gbaudio_tplg_create_mixer_ctl(struct 
> gbaudio_module_info *gb,
>   return -ENOMEM;
>   ctldata->ctl_id = ctl->id;
>   ctldata->data_cport = le16_to_cpu(ctl->data_cport);
> - ctldata->access = ctl->access;
> + ctldata->access = le32_to_cpu(ctl->access);
>   ctldata->vcount = ctl->count_values;
>   ctldata->info = &ctl->info;
>   *kctl = (struct snd_kcontrol_new)
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [greybus-dev] [PATCH 2/3] staging: greybus: codecs: use SNDRV_PCM_FMTBIT_S16_LE for format bitmask

2020-09-24 Thread Alex Elder
On 9/24/20 5:20 AM, Coiby Xu wrote:
> snd_soc_pcm_stream.formats should use the bitmask SNDRV_PCM_FMTBIT_*
> instead of the sequential integers SNDRV_PCM_FORMAT_* as explained by
> commit e712bfca1ac1f63f622f87c2f33b57608f2a4d19
> ("ASoC: codecs: use SNDRV_PCM_FMTBIT_* for format bitmask").
> 
> Found by sparse,

Looks good.

Reviewed-by: Alex Elder 

> 
> $ make C=2 drivers/staging/greybus/
> drivers/staging/greybus/audio_codec.c:691:36: warning: incorrect type in 
> initializer (different base types)
> drivers/staging/greybus/audio_codec.c:691:36:expected unsigned long long 
> [usertype] formats
> drivers/staging/greybus/audio_codec.c:691:36:got restricted 
> snd_pcm_format_t [usertype]
> drivers/staging/greybus/audio_codec.c:701:36: warning: incorrect type in 
> initializer (different base types)
> drivers/staging/greybus/audio_codec.c:701:36:expected unsigned long long 
> [usertype] formats
> drivers/staging/greybus/audio_codec.c:701:36:got restricted 
> snd_pcm_format_t [usertype]
> 
> Signed-off-by: Coiby Xu 
> ---
>  drivers/staging/greybus/audio_codec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/greybus/audio_codec.c 
> b/drivers/staging/greybus/audio_codec.c
> index 74538f8c5fa4..494aa823e998 100644
> --- a/drivers/staging/greybus/audio_codec.c
> +++ b/drivers/staging/greybus/audio_codec.c
> @@ -688,7 +688,7 @@ static struct snd_soc_dai_driver gbaudio_dai[] = {
>   .playback = {
>   .stream_name = "I2S 0 Playback",
>   .rates = SNDRV_PCM_RATE_48000,
> - .formats = SNDRV_PCM_FORMAT_S16_LE,
> + .formats = SNDRV_PCM_FMTBIT_S16_LE,
>   .rate_max = 48000,
>   .rate_min = 48000,
>   .channels_min = 1,
> @@ -698,7 +698,7 @@ static struct snd_soc_dai_driver gbaudio_dai[] = {
>   .capture = {
>   .stream_name = "I2S 0 Capture",
>   .rates = SNDRV_PCM_RATE_48000,
> - .formats = SNDRV_PCM_FORMAT_S16_LE,
> + .formats = SNDRV_PCM_FMTBIT_S16_LE,
>   .rate_max = 48000,
>   .rate_min = 48000,
>   .channels_min = 1,
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [greybus-dev] [PATCH 3/3] [PATCH] staging: greybus: __u8 is sufficient for snd_ctl_elem_type_t and snd_ctl_elem_iface_t

2020-09-24 Thread Alex Elder
On 9/24/20 5:20 AM, Coiby Xu wrote:
> Use __8 to replace int and remove the unnecessary __bitwise type attribute.
> 
> Found by sparse,

Greg's right, don't change the public header.

You could try this in the Greybus code to eliminate the warning,
but I haven't tried it (and for all I know it's not a good idea):

uinfo->type = (__force snd_ctl_elem_type_t)info->type;

-Alex

> $ make C=2 drivers/staging/greybus/
> drivers/staging/greybus/audio_topology.c:185:24: warning: cast to restricted 
> snd_ctl_elem_type_t
> drivers/staging/greybus/audio_topology.c:679:14: warning: restricted 
> snd_ctl_elem_iface_t degrades to integer
> drivers/staging/greybus/audio_topology.c:906:14: warning: restricted 
> snd_ctl_elem_iface_t degrades to integer
> 
> Signed-off-by: Coiby Xu 
> ---
>  drivers/staging/greybus/audio_topology.c | 2 +-
>  include/uapi/sound/asound.h  | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/greybus/audio_topology.c 
> b/drivers/staging/greybus/audio_topology.c
> index 56bf1a4f95ad..f6023ff390c2 100644
> --- a/drivers/staging/greybus/audio_topology.c
> +++ b/drivers/staging/greybus/audio_topology.c
> @@ -182,7 +182,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol 
> *kcontrol,
>   /* update uinfo */
>   uinfo->access = data->access;
>   uinfo->count = data->vcount;
> - uinfo->type = (snd_ctl_elem_type_t)info->type;
> + uinfo->type = info->type;
>  
>   switch (info->type) {
>   case GB_AUDIO_CTL_ELEM_TYPE_BOOLEAN:
> diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
> index 535a7229e1d9..8e71a95644ab 100644
> --- a/include/uapi/sound/asound.h
> +++ b/include/uapi/sound/asound.h
> @@ -950,7 +950,7 @@ struct snd_ctl_card_info {
>   unsigned char components[128];  /* card components / fine 
> identification, delimited with one space (AC97 etc..) */
>  };
>  
> -typedef int __bitwise snd_ctl_elem_type_t;
> +typedef __u8 snd_ctl_elem_type_t;
>  #define  SNDRV_CTL_ELEM_TYPE_NONE((__force snd_ctl_elem_type_t) 
> 0) /* invalid */
>  #define  SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 
> 1) /* boolean type */
>  #define  SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 
> 2) /* integer type */
> @@ -960,7 +960,7 @@ typedef int __bitwise snd_ctl_elem_type_t;
>  #define  SNDRV_CTL_ELEM_TYPE_INTEGER64   ((__force snd_ctl_elem_type_t) 
> 6) /* 64-bit integer type */
>  #define  SNDRV_CTL_ELEM_TYPE_LASTSNDRV_CTL_ELEM_TYPE_INTEGER64
>  
> -typedef int __bitwise snd_ctl_elem_iface_t;
> +typedef __u8 snd_ctl_elem_iface_t;
>  #define  SNDRV_CTL_ELEM_IFACE_CARD   ((__force snd_ctl_elem_iface_t) 
> 0) /* global control */
>  #define  SNDRV_CTL_ELEM_IFACE_HWDEP  ((__force snd_ctl_elem_iface_t) 
> 1) /* hardware dependent device */
>  #define  SNDRV_CTL_ELEM_IFACE_MIXER  ((__force snd_ctl_elem_iface_t) 
> 2) /* virtual mixer device */
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Initial driver submission for pureLiFi devices

2020-09-24 Thread Greg Kroah-Hartman
On Thu, Sep 24, 2020 at 08:48:51PM +0530, Srinivasan Raju wrote:
> +PUREILIFI USB DRIVER
> +M:   pureLiFi Ltd 

I need a real person here, having aliases as maintainers results in a
lack of accountability :(

> --- /dev/null
> +++ b/drivers/staging/purelifi/TODO
> @@ -0,0 +1,5 @@
> +TODO:
> + - checkpatch.pl cleanups
> +
> +Please send any patches or complaints about this driver to pureLiFi Ltd
> +

Why not just do these fixups on your own right now and submit it to the
"real" part of the kernel?  That should take what, a day or so max?

Just sending stuff to staging because you don't want to do coding style
cleanups feels very odd.  It takes much more work and energy to do it
this way than to just do it right the first time and get it merged to
the networking subsystem, right?

So why do you want to send it to staging?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Initial driver submission for pureLiFi devices

2020-09-24 Thread Greg Kroah-Hartman
On Thu, Sep 24, 2020 at 08:48:51PM +0530, Srinivasan Raju wrote:
> +++ b/drivers/staging/purelifi/chip.c
> @@ -0,0 +1,184 @@
> +// SPDX-License-Identifier: GNU General Public License v2.0 or later

That's not a valid SPDX identifier :)



> +/* Copyright (c) 2015-2020 pureLiFi Ltd
> + * All rights reserved.
> + *
> + * Copyright (C) 2015-2020 pureLiFi 
> + * Copyright (C) 2006-2007 Daniel Drake 
> + * Copyright (C) 2005-2007 Ulrich Kunitz 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.

These paragraphs are not needed with a SPDX line above.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: Initial driver submission for pureLiFi devices

2020-09-24 Thread Srinivasan Raju
From: Srini 

This introduces the pureLiFi LiFi driver for LiFi-X, LiFi-XC
and LiFi-XL USB devices, which provide lightweight, highspeed secure and
fully networked wireless communications via light.

This driver implementation has been based on the zd1211rw driver

Driver is based on 802.11 softMAC Architecture and uses
native 802.11 for configuration and management

The driver is compiled and tested in ARM, x86 architectures and
 compiled in powerpc architecture

Signed-off-by: Srinivasan Raju 
---
 MAINTAINERS  |5 +
 drivers/staging/Kconfig  |2 +
 drivers/staging/Makefile |1 +
 drivers/staging/purelifi/Kconfig |   42 +
 drivers/staging/purelifi/Makefile|5 +
 drivers/staging/purelifi/TODO|5 +
 drivers/staging/purelifi/chip.c  |  184 ++
 drivers/staging/purelifi/chip.h  |  101 +
 drivers/staging/purelifi/def.h   |   70 +
 drivers/staging/purelifi/log.h   |   32 +
 drivers/staging/purelifi/mac.c   |  984 +
 drivers/staging/purelifi/mac.h   |  196 ++
 drivers/staging/purelifi/mac_usb_interface.h |   56 +
 drivers/staging/purelifi/usb.c   | 1948 ++
 drivers/staging/purelifi/usb.h   |  166 ++
 15 files changed, 3797 insertions(+)
 create mode 100644 drivers/staging/purelifi/Kconfig
 create mode 100644 drivers/staging/purelifi/Makefile
 create mode 100644 drivers/staging/purelifi/TODO
 create mode 100644 drivers/staging/purelifi/chip.c
 create mode 100644 drivers/staging/purelifi/chip.h
 create mode 100644 drivers/staging/purelifi/def.h
 create mode 100644 drivers/staging/purelifi/log.h
 create mode 100644 drivers/staging/purelifi/mac.c
 create mode 100644 drivers/staging/purelifi/mac.h
 create mode 100644 drivers/staging/purelifi/mac_usb_interface.h
 create mode 100644 drivers/staging/purelifi/usb.c
 create mode 100644 drivers/staging/purelifi/usb.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 924616dc19ff..0f1f865dc85b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14044,6 +14044,11 @@ T: git git://linuxtv.org/media_tree.git
 F: Documentation/admin-guide/media/pulse8-cec.rst
 F: drivers/media/cec/usb/pulse8/
 
+PUREILIFI USB DRIVER
+M: pureLiFi Ltd 
+S: Maintained
+F: drivers/staging/purelifi
+
 PVRUSB2 VIDEO4LINUX DRIVER
 M: Mike Isely 
 L: pvru...@isely.net   (subscribers-only)
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 2d0310448eba..c46c345f0b77 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -118,4 +118,6 @@ source "drivers/staging/wfx/Kconfig"
 
 source "drivers/staging/hikey9xx/Kconfig"
 
+source "drivers/staging/purelifi/Kconfig"
+
 endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 757a892ab5b9..dfe9c47ffb1a 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -49,3 +49,4 @@ obj-$(CONFIG_KPC2000) += kpc2000/
 obj-$(CONFIG_QLGE) += qlge/
 obj-$(CONFIG_WFX)  += wfx/
 obj-y  += hikey9xx/
+obj-$(CONFIG_VENDOR_PURELIFI)  += purelifi/
diff --git a/drivers/staging/purelifi/Kconfig b/drivers/staging/purelifi/Kconfig
new file mode 100644
index ..db24bdf884a3
--- /dev/null
+++ b/drivers/staging/purelifi/Kconfig
@@ -0,0 +1,42 @@
+config WLAN_VENDOR_PURELIFI
+   bool "pureLiFi devices"
+   default y
+   help
+ If you have a pureLiFi device, say Y.
+
+ Note that the answer to this question doesn't directly affect the
+ kernel: saying N will just cause the configurator to skip all the
+ questions about these cards. If you say Y, you will be asked for
+ your specific card in the following questions.
+
+if WLAN_VENDOR_PURELIFI
+
+config PURELIFI
+
+   tristate "pureLiFi device support"
+   depends on CFG80211 && MAC80211 && USB
+   help
+  Say Y if you want to use LiFi
+
+  This driver makes the adapter appear as a normal WLAN interface
+
+  The pureLiFi device requires external STA firmware to be loaded.
+
+  To compile this driver as a module, choose M here: the
+  module will be called purelifi.
+
+config PURELIFI_AP
+
+   tristate "pureLiFi device Access Point support"
+   depends on CFG80211 && MAC80211 && USB
+   help
+  Say Y if you want to use LiFi Access-Point
+
+  This driver makes the adapter appear as a normal WLAN interface
+
+  The pureLiFi device requires external AP firmware to be loaded.
+
+  To compile this driver as a module, choose M here: the
+  module will be called purelifi.
+
+endif # WLAN_VENDOR_PURELIFI
diff --git a/drivers/staging/purelifi/Makefile 
b/drivers/staging/purelifi/Makefile
new file mode 100644
index ..a8483fbb966c
--- /dev/null
+++ b/drivers/staging/purelifi/Make

Re: [PATCH] staging: Initial driver submission for pureLiFi devices

2020-09-24 Thread Srinivasan Raju


>> --- /dev/null
>> +++ b/drivers/staging/purelifi/TODO
>> @@ -0,0 +1,5 @@
>> +TODO:
>> + - checkpatch.pl cleanups
>> +
>> +Please send any patches or complaints about this driver to pureLiFi Ltd
>> +

>Why not just do these fixups on your own right now and submit it to the
>"real" part of the kernel?  That should take what, a day or so max?
>Just sending stuff to staging because you don't want to do coding style
>cleanups feels very odd.  It takes much more work and energy to do it
>this way than to just do it right the first time and get it merged to
>the networking subsystem, right?

>So why do you want to send it to staging?

Thanks for the comments Greg, This is my first kernel patch, I was under  
the impression that the staging area is the place to start for any new "Driver" 
code
We will do the fixes and send an updated patch


Thanks
Srini
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Initial driver submission for pureLiFi devices

2020-09-24 Thread Greg Kroah-Hartman
On Thu, Sep 24, 2020 at 05:24:14PM +, Srinivasan Raju wrote:
> 
> >> --- /dev/null
> >> +++ b/drivers/staging/purelifi/TODO
> >> @@ -0,0 +1,5 @@
> >> +TODO:
> >> + - checkpatch.pl cleanups
> >> +
> >> +Please send any patches or complaints about this driver to pureLiFi Ltd
> >> +
> 
> >Why not just do these fixups on your own right now and submit it to the
> >"real" part of the kernel?  That should take what, a day or so max?
> >Just sending stuff to staging because you don't want to do coding style
> >cleanups feels very odd.  It takes much more work and energy to do it
> >this way than to just do it right the first time and get it merged to
> >the networking subsystem, right?
> 
> >So why do you want to send it to staging?
> 
> Thanks for the comments Greg, This is my first kernel patch, I was under  
> the impression that the staging area is the place to start for any new 
> "Driver" code
> We will do the fixes and send an updated patch

No, staging is for things that people do not care about and want others
to help clean up and get merged properly :)

There's nothing in the "how to submit a driver/patch" documentation that
mentions that it has to go through staging first, does it?  If so, that
needs to be changed...

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFT/RFC 37/49] staging: media: zoran: add fallthrough keyword

2020-09-24 Thread LABBE Corentin
On Mon, Sep 21, 2020 at 01:59:45PM +0300, Dan Carpenter wrote:
> On Mon, Sep 21, 2020 at 10:20:12AM +, Corentin Labbe wrote:
> > This patch adds fallthrough keyword where appropriate.
> > 
> > Signed-off-by: Corentin Labbe 
> > ---
> >  drivers/staging/media/zoran/zoran_device.c | 6 ++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/staging/media/zoran/zoran_device.c 
> > b/drivers/staging/media/zoran/zoran_device.c
> > index 9558bafdde7d..7634d94f9359 100644
> > --- a/drivers/staging/media/zoran/zoran_device.c
> > +++ b/drivers/staging/media/zoran/zoran_device.c
> > @@ -268,7 +268,9 @@ static void zr36057_adjust_vfe(struct zoran *zr, enum 
> > zoran_codec_mode mode)
> > btwrite(reg, ZR36057_VFEHCR);
> > break;
> > case BUZ_MODE_MOTION_COMPRESS:
> > +   fallthrough;
> > case BUZ_MODE_IDLE:
> > +   fallthrough;
> > default:
> 
> Hopefully, we don't need fallthrough labels for empty switch statements
> like this?
> 

I have removed this patch and nothing warn about fallthrough missing.
But this is strange, if I have added them, it is because something (checkpatch 
?) complained.

Anyway, nothing complains now, it is cleaner without them.

Thanks
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Initial driver submission for pureLiFi devices

2020-09-24 Thread Randy Dunlap
Hi,

On 9/24/20 8:18 AM, Srinivasan Raju wrote:
> diff --git a/drivers/staging/purelifi/Kconfig 
> b/drivers/staging/purelifi/Kconfig
> new file mode 100644
> index ..db24bdf884a3
> --- /dev/null
> +++ b/drivers/staging/purelifi/Kconfig
> @@ -0,0 +1,42 @@
> +config WLAN_VENDOR_PURELIFI
> + bool "pureLiFi devices"
> + default y
> + help
> +   If you have a pureLiFi device, say Y.
> +
> +   Note that the answer to this question doesn't directly affect the
> +   kernel: saying N will just cause the configurator to skip all the
> +   questions about these cards. If you say Y, you will be asked for
> +   your specific card in the following questions.
> +
> +if WLAN_VENDOR_PURELIFI
> +
> +config PURELIFI
> +
> + tristate "pureLiFi device support"
> + depends on CFG80211 && MAC80211 && USB
> + help
> +Say Y if you want to use LiFi

LiFi.
> +
> +This driver makes the adapter appear as a normal WLAN interface

 interface.

> +
> +The pureLiFi device requires external STA firmware to be loaded.
> +
> +To compile this driver as a module, choose M here: the
> +module will be called purelifi.
> +
> +config PURELIFI_AP
> +
> + tristate "pureLiFi device Access Point support"
> + depends on CFG80211 && MAC80211 && USB

>From a brief look at the Makefile, it appears that the AP cannot be built 
>alone;
i.e., I think that this needs:

depends on PURELIFI

> + help
> +Say Y if you want to use LiFi Access-Point

LiFi as an Access Point.
or
LiFi in Access Point mode.
or make something up. :)

> +
> +This driver makes the adapter appear as a normal WLAN interface

 interface.

> +
> +The pureLiFi device requires external AP firmware to be loaded.
> +
> +To compile this driver as a module, choose M here: the
> +module will be called purelifi.

Same module, not a separate one, right?

> +
> +endif # WLAN_VENDOR_PURELIFI
> diff --git a/drivers/staging/purelifi/Makefile 
> b/drivers/staging/purelifi/Makefile
> new file mode 100644
> index ..a8483fbb966c
> --- /dev/null
> +++ b/drivers/staging/purelifi/Makefile
> @@ -0,0 +1,5 @@
> +obj-$(CONFIG_PURELIFI)   := purelifi.o
> +purelifi-objs+= chip.o usb.o mac.o
> +ifeq ($(CONFIG_PURELIFI_AP),m)

Why does this check for CONFIG_PURELIFI_AP=m ?
How about if CONFIG_PURELIFI_AP=y ?

> + ccflags-y += -DTYPE_AP
> +endif

It would be more common just to check for CONFIG_PURELIFI_AP in the source
file(s) instead of adding a synonym for it.

-- 
~Randy

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Initial driver submission for pureLiFi devices

2020-09-24 Thread Dan Carpenter
On Thu, Sep 24, 2020 at 08:48:51PM +0530, Srinivasan Raju wrote:
> +
> +#include 
> +#include 
> +
> +#include "def.h"
> +#include "chip.h"
> +#include "mac.h"
> +#include "usb.h"
> +#include "log.h"
> +
> +void purelifi_chip_init(struct purelifi_chip *chip,
> + struct ieee80211_hw *hw,
> + struct usb_interface *intf
> + )

There is a bunch of really trivial messiness like this.  It should
look like:

void purelifi_chip_init(struct purelifi_chip *chip,
struct ieee80211_hw *hw,
struct usb_interface *intf)


> +{
> + memset(chip, 0, sizeof(*chip));
> + mutex_init(&chip->mutex);
> + purelifi_usb_init(&chip->usb, hw, intf);
> +}
> +
> +void purelifi_chip_clear(struct purelifi_chip *chip)
> +{
> + PURELIFI_ASSERT(!mutex_is_locked(&chip->mutex));
> + purelifi_usb_clear(&chip->usb);
> + mutex_destroy(&chip->mutex);
> + PURELIFI_MEMCLEAR(chip, sizeof(*chip));

Get rid of the PURELIFI_MEMCLEAR() macro.  The weird thing about
PURELIFI_MEMCLEAR() is that sometimes it's a no-op.  It seems
unnecessary to memset() the struct here.

I'm not a fan of all these tiny functions.  It feels like I have to
jump around a lot to understand the code.  What does "clear" mean in
this context.  Probably "release" is a better name.

> +}
> +
> +static int scnprint_mac_oui(struct purelifi_chip *chip, char *buffer,
> + size_t size)
> +{
> + u8 *addr = purelifi_mac_get_perm_addr(purelifi_chip_to_mac(chip));
> +
> + return scnprintf(buffer, size, "%02x-%02x-%02x",
> + addr[0], addr[1], addr[2]);
> +}
> +
> +/* Prints an identifier line, which will support debugging. */
> +static int scnprint_id(struct purelifi_chip *chip, char *buffer, size_t size)

This function name is too vague.  What ID is it printing?

> +{
> + int i = 0;

The initialization is not required.  "i" means "iterator".  This should
be "cnt" instead.

> +
> + i = scnprintf(buffer, size, "purelifi%s chip ", "");
> + i += purelifi_usb_scnprint_id(&chip->usb, buffer + i, size - i);
> + i += scnprintf(buffer + i, size - i, " ");
> + i += scnprint_mac_oui(chip, buffer + i, size - i);
> + i += scnprintf(buffer + i, size - i, " ");
> + return i;

This is an example of how tiny functions obfuscate the code.  It should
be written like this:

static void print_whatever(struct purelifi_chip *chip)
{
u8 *addr = purelifi_mac_get_perm_addr(purelifi_chip_to_mac(chip));
struct usb_device *udev = interface_to_usbdev(chip->usb.intf);

pr_info("purelifi chip 04hx:%04hx v%04hx %s %02x-%02x-%02x\n",
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct),
get_bcd_device(udev),
speed(udev->speed),
addr[0], addr[1], addr[2]);
}

> +}
> +
> +static void print_id(struct purelifi_chip *chip)
> +{
> + char buffer[80];
> +
> + scnprint_id(chip, buffer, sizeof(buffer));
> + buffer[sizeof(buffer) - 1] = 0;

snprintf() functions alway put a NUL terminator on the end of the string.

> + pl_dev_info(purelifi_chip_dev(chip), "%s\n", buffer);
> +}
> +
> +/* MAC address: if custom mac addresses are to be used CR_MAC_ADDR_P1 and
> + *  CR_MAC_ADDR_P2 must be overwritten
> + */
> +int purelifi_write_mac_addr(struct purelifi_chip *chip, const u8 *mac_addr)
> +{
> + int r;
> +
> + r = usb_write_req(mac_addr, ETH_ALEN, USB_REQ_MAC_WR);
> + return r;

Delete the "r" variable.

return usb_write_req(mac_addr, ETH_ALEN, USB_REQ_MAC_WR);

Again, I'm not a huge fan of one line functions for no reason. Actually,
the function is never called.  Just delete it.

> +}
> +
> +int purelifi_set_beacon_interval(struct purelifi_chip *chip, u16 interval,
> +  u8 dtim_period, int type)
> +{
> + int r;
> +
> + if (!interval || (chip->beacon_set &&
> +   chip->beacon_interval == interval)) {
> + return 0;
> + }
> +
> + chip->beacon_interval = interval;
> + chip->beacon_set = true;
> + r = usb_write_req((const u8 *)&chip->beacon_interval,
> +   sizeof(chip->beacon_interval),
> +   USB_REQ_BEACON_INTERVAL_WR);
> + return r;

Delete the "r" variable.

> +}
> +
> +static int hw_init(struct purelifi_chip *chip)
> +{
> + return purelifi_set_beacon_interval(chip, 100, 0, 0);
> +}

This is a oneline function which is only called once.  Move it inline.

> +
> +int purelifi_chip_init_hw(struct purelifi_chip *chip)
> +{
> + int r;
> +
> + r = hw_init(chip);
> + if (r)
> + goto out;

Just return directly.  The little bunny hop doesn't add anything.

> +
> + print_id(chip);
> +out:
> + return r;
> +}

Anyway, those are some ideas.

regards,
dan carpenter

___
devel mailing