From patchwork Wed Feb 11 10:37:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 5811941 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4FFD99F30C for ; Wed, 11 Feb 2015 10:41:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6354720212 for ; Wed, 11 Feb 2015 10:41:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1E49E20109 for ; Wed, 11 Feb 2015 10:41:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 526C42650C5; Wed, 11 Feb 2015 11:41:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id DC4C0261A84; Wed, 11 Feb 2015 11:37:59 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C7BF8261A76; Wed, 11 Feb 2015 11:37:56 +0100 (CET) Received: from smtp303.phy.lolipop.jp (smtp303.phy.lolipop.jp [210.157.22.87]) by alsa0.perex.cz (Postfix) with ESMTP id 387072605FF for ; Wed, 11 Feb 2015 11:37:42 +0100 (CET) Received: from smtp303.phy.lolipop.lan (HELO smtp303.phy.lolipop.jp) (172.17.1.87) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp303.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Wed, 11 Feb 2015 19:37:36 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp303.phy.lolipop.jp (LOLIPOP-Fsecure); Wed, 11 Feb 2015 19:37:33 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 11 Feb 2015 19:37:30 +0900 Message-Id: <1423651052-19593-7-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423651052-19593-1-git-send-email-o-takashi@sakamocchi.jp> References: <1423651052-19593-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 6/8] ALSA: control: fix over 80 characters lines X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This commit arranges lines over 80 characters, just related to this patchset. Signed-off-by: Takashi Sakamoto --- sound/core/control.c | 58 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/sound/core/control.c b/sound/core/control.c index 15af804..c18ac04 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -205,6 +205,7 @@ static struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, unsigned int access) { struct snd_kcontrol *kctl; + unsigned int size; unsigned int i; if (snd_BUG_ON(!control || !control->count)) @@ -213,7 +214,9 @@ static struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, if (control->count > MAX_CONTROL_COUNT) return NULL; - kctl = kzalloc(sizeof(*kctl) + sizeof(struct snd_kcontrol_volatile) * control->count, GFP_KERNEL); + size = sizeof(*kctl); + size += sizeof(struct snd_kcontrol_volatile) * control->count; + kctl = kzalloc(size, GFP_KERNEL); if (kctl == NULL) { pr_err("ALSA: Cannot allocate control instance\n"); return NULL; @@ -314,11 +317,12 @@ static int snd_ctl_find_hole(struct snd_card *card, unsigned int count) unsigned int iter = 100000; while (snd_ctl_remove_numid_conflict(card, count)) { - if (--iter == 0) { - /* this situation is very unlikely */ - dev_err(card->dev, "unable to allocate new control numid\n"); - return -ENOMEM; - } + if (--iter != 0) + continue; + + /* this situation is very unlikely */ + dev_err(card->dev, "unable to allocate new control numid\n"); + return -ENOMEM; } return 0; } @@ -355,12 +359,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) down_write(&card->controls_rwsem); if (snd_ctl_find_id(card, &id)) { up_write(&card->controls_rwsem); - dev_err(card->dev, "control %i:%i:%i:%s:%i is already present\n", - id.iface, - id.device, - id.subdevice, - id.name, - id.index); + dev_err(card->dev, + "control %i:%i:%i:%s:%i is already present\n", + id.iface, id.device, id.subdevice, id.name, id.index); err = -EBUSY; goto error; } @@ -638,14 +639,16 @@ EXPORT_SYMBOL(snd_ctl_rename_id); * Return: The pointer of the instance if found, or %NULL if not. * */ -struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid) +struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, + unsigned int numid) { struct snd_kcontrol *kctl; if (snd_BUG_ON(!card || !numid)) return NULL; list_for_each_entry(kctl, &card->controls, list) { - if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid) + if (kctl->id.numid <= numid && + kctl->id.numid + kctl->count > numid) return kctl; } return NULL; @@ -1010,7 +1013,8 @@ struct user_element { unsigned int elem_data_size; /* size of element data in bytes */ void *tlv_data; /* TLV data */ unsigned long tlv_data_size; /* TLV data size */ - void *priv_data; /* private data (like strings for enumerated type) */ + /* private data (like strings for enumerated type) */ + void *priv_data; }; static int snd_ctl_elem_user_info(struct snd_kcontrol *kcontrol, @@ -1062,7 +1066,7 @@ static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol, struct user_element *ue = kcontrol->private_data; mutex_lock(&ue->card->user_ctl_lock); - change = memcmp(&ucontrol->value, ue->elem_data, ue->elem_data_size) != 0; + change = !!memcmp(&ucontrol->value, ue->elem_data, ue->elem_data_size); if (change) memcpy(ue->elem_data, &ucontrol->value, ue->elem_data_size); mutex_unlock(&ue->card->user_ctl_lock); @@ -1272,7 +1276,8 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, } static int snd_ctl_elem_add_user(struct snd_ctl_file *file, - struct snd_ctl_elem_info __user *_info, int replace) + struct snd_ctl_elem_info __user *_info, + int replace) { struct snd_ctl_elem_info info; if (copy_from_user(&info, _info, sizeof(info))) @@ -1373,7 +1378,8 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file, return err; } -static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +static long snd_ctl_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) { struct snd_ctl_file *ctl; struct snd_card *card; @@ -1518,7 +1524,8 @@ static unsigned int snd_ctl_poll(struct file *file, poll_table * wait) * register the device-specific control-ioctls. * called from each device manager like pcm.c, hwdep.c, etc. */ -static int _snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn, struct list_head *lists) +static int _snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn, + struct list_head *lists) { struct snd_kctl_ioctl *pn; @@ -1793,6 +1800,8 @@ EXPORT_SYMBOL(snd_ctl_boolean_stereo_info); int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels, unsigned int items, const char *const names[]) { + const char *name; + info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; info->count = channels; info->value.enumerated.items = items; @@ -1800,11 +1809,12 @@ int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels, return 0; if (info->value.enumerated.item >= items) info->value.enumerated.item = items - 1; - WARN(strlen(names[info->value.enumerated.item]) >= sizeof(info->value.enumerated.name), - "ALSA: too long item name '%s'\n", - names[info->value.enumerated.item]); - strlcpy(info->value.enumerated.name, - names[info->value.enumerated.item], + + name = names[info->value.enumerated.item]; + WARN(strlen(name) >= sizeof(info->value.enumerated.name), + "ALSA: too long item name '%s'\n", name); + + strlcpy(info->value.enumerated.name, name, sizeof(info->value.enumerated.name)); return 0; }