OSDN Git Service

staging/greybus: eliminate use of NAME_SIZE for strings
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Sun, 21 Feb 2021 15:42:59 +0000 (21:12 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Mar 2021 08:25:33 +0000 (09:25 +0100)
Instead, depend on the size of the destination buffer for easier
refactoring.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20210221154258.119503-1-memxor@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/greybus/audio_module.c
drivers/staging/greybus/audio_topology.c

index 0f9fdc0..12c376c 100644 (file)
@@ -260,7 +260,7 @@ static int gb_audio_probe(struct gb_bundle *bundle,
        INIT_LIST_HEAD(&gbmodule->widget_ctl_list);
        INIT_LIST_HEAD(&gbmodule->jack_list);
        gbmodule->dev = dev;
-       snprintf(gbmodule->name, NAME_SIZE, "%s.%s", dev->driver->name,
+       snprintf(gbmodule->name, sizeof(gbmodule->name), "%s.%s", dev->driver->name,
                 dev_name(dev));
        greybus_set_drvdata(bundle, gbmodule);
 
@@ -342,7 +342,7 @@ static int gb_audio_probe(struct gb_bundle *bundle,
        /* inform above layer for uevent */
        dev_dbg(dev, "Inform set_event:%d to above layer\n", 1);
        /* prepare for the audio manager */
-       strscpy(desc.name, gbmodule->name, GB_AUDIO_MANAGER_MODULE_NAME_LEN);
+       strscpy(desc.name, gbmodule->name, sizeof(desc.name));
        desc.vid = 2; /* todo */
        desc.pid = 3; /* todo */
        desc.intf_id = gbmodule->dev_id;
index e816e4d..1fc7727 100644 (file)
@@ -200,7 +200,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,
                        return -EINVAL;
                name = gbaudio_map_controlid(module, data->ctl_id,
                                             uinfo->value.enumerated.item);
-               strscpy(uinfo->value.enumerated.name, name, NAME_SIZE);
+               strscpy(uinfo->value.enumerated.name, name, sizeof(uinfo->value.enumerated.name));
                break;
        default:
                dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n",
@@ -363,7 +363,7 @@ static int gbcodec_mixer_dapm_ctl_info(struct snd_kcontrol *kcontrol,
        platform_min = le32_to_cpu(info->value.integer.min);
 
        if (platform_max == 1 &&
-           !strnstr(kcontrol->id.name, " Volume", NAME_SIZE))
+           !strnstr(kcontrol->id.name, " Volume", sizeof(kcontrol->id.name)))
                uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
        else
                uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -1047,8 +1047,8 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
        }
 
        /* Prefix dev_id to widget control_name */
-       strscpy(temp_name, w->name, NAME_SIZE);
-       snprintf(w->name, NAME_SIZE, "GB %d %s", module->dev_id, temp_name);
+       strscpy(temp_name, w->name, sizeof(temp_name));
+       snprintf(w->name, sizeof(w->name), "GB %d %s", module->dev_id, temp_name);
 
        switch (w->type) {
        case snd_soc_dapm_spk:
@@ -1169,8 +1169,8 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module,
                }
                control->id = curr->id;
                /* Prefix dev_id to widget_name */
-               strscpy(temp_name, curr->name, NAME_SIZE);
-               snprintf(curr->name, NAME_SIZE, "GB %d %s", module->dev_id,
+               strscpy(temp_name, curr->name, sizeof(temp_name));
+               snprintf(curr->name, sizeof(curr->name), "GB %d %s", module->dev_id,
                         temp_name);
                control->name = curr->name;
                if (curr->info.type == GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED) {