ALSA: Constify ratden/ratnum constraints
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 28 Oct 2015 10:37:53 +0000 (11:37 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 28 Oct 2015 10:42:22 +0000 (11:42 +0100)
The ALSA core does not modify the constraints provided by a driver. Most
constraint helper functions already take a const pointer to the constraint
description, the exception at the moment being the ratden and ratnum
constraints. Make those const as well, this allows a driver to declare them
as const.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/pcm.h
sound/core/pcm_lib.c

index 4e6ad74fd8a2f7a4b38787e181e53b0e6456bf96..b0be09279943fc1a911a6071507ebdd79eed2912 100644 (file)
@@ -265,12 +265,12 @@ struct snd_ratden {
 
 struct snd_pcm_hw_constraint_ratnums {
        int nrats;
-       struct snd_ratnum *rats;
+       const struct snd_ratnum *rats;
 };
 
 struct snd_pcm_hw_constraint_ratdens {
        int nrats;
-       struct snd_ratden *rats;
+       const struct snd_ratden *rats;
 };
 
 struct snd_pcm_hw_constraint_list {
@@ -970,7 +970,7 @@ int snd_interval_list(struct snd_interval *i, unsigned int count,
 int snd_interval_ranges(struct snd_interval *i, unsigned int count,
                        const struct snd_interval *list, unsigned int mask);
 int snd_interval_ratnum(struct snd_interval *i,
-                       unsigned int rats_count, struct snd_ratnum *rats,
+                       unsigned int rats_count, const struct snd_ratnum *rats,
                        unsigned int *nump, unsigned int *denp);
 
 void _snd_pcm_hw_params_any(struct snd_pcm_hw_params *params);
@@ -1000,11 +1000,11 @@ int snd_pcm_hw_constraint_ranges(struct snd_pcm_runtime *runtime,
 int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, 
                                  unsigned int cond,
                                  snd_pcm_hw_param_t var,
-                                 struct snd_pcm_hw_constraint_ratnums *r);
+                                 const struct snd_pcm_hw_constraint_ratnums *r);
 int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, 
                                  unsigned int cond,
                                  snd_pcm_hw_param_t var,
-                                 struct snd_pcm_hw_constraint_ratdens *r);
+                                 const struct snd_pcm_hw_constraint_ratdens *r);
 int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, 
                                 unsigned int cond,
                                 unsigned int width,
index 05a3ca93c6474b3fa120f20c25403439bb469d1c..6b5a811e01a544f3379829b8ebfa3773904691bb 100644 (file)
@@ -801,7 +801,7 @@ void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k,
  * negative error code.
  */
 int snd_interval_ratnum(struct snd_interval *i,
-                       unsigned int rats_count, struct snd_ratnum *rats,
+                       unsigned int rats_count, const struct snd_ratnum *rats,
                        unsigned int *nump, unsigned int *denp)
 {
        unsigned int best_num, best_den;
@@ -920,7 +920,8 @@ EXPORT_SYMBOL(snd_interval_ratnum);
  * negative error code.
  */
 static int snd_interval_ratden(struct snd_interval *i,
-                              unsigned int rats_count, struct snd_ratden *rats,
+                              unsigned int rats_count,
+                              const struct snd_ratden *rats,
                               unsigned int *nump, unsigned int *denp)
 {
        unsigned int best_num, best_diff, best_den;
@@ -1339,7 +1340,7 @@ EXPORT_SYMBOL(snd_pcm_hw_constraint_ranges);
 static int snd_pcm_hw_rule_ratnums(struct snd_pcm_hw_params *params,
                                   struct snd_pcm_hw_rule *rule)
 {
-       struct snd_pcm_hw_constraint_ratnums *r = rule->private;
+       const struct snd_pcm_hw_constraint_ratnums *r = rule->private;
        unsigned int num = 0, den = 0;
        int err;
        err = snd_interval_ratnum(hw_param_interval(params, rule->var),
@@ -1363,10 +1364,10 @@ static int snd_pcm_hw_rule_ratnums(struct snd_pcm_hw_params *params,
 int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, 
                                  unsigned int cond,
                                  snd_pcm_hw_param_t var,
-                                 struct snd_pcm_hw_constraint_ratnums *r)
+                                 const struct snd_pcm_hw_constraint_ratnums *r)
 {
        return snd_pcm_hw_rule_add(runtime, cond, var,
-                                  snd_pcm_hw_rule_ratnums, r,
+                                  snd_pcm_hw_rule_ratnums, (void *)r,
                                   var, -1);
 }
 
@@ -1375,7 +1376,7 @@ EXPORT_SYMBOL(snd_pcm_hw_constraint_ratnums);
 static int snd_pcm_hw_rule_ratdens(struct snd_pcm_hw_params *params,
                                   struct snd_pcm_hw_rule *rule)
 {
-       struct snd_pcm_hw_constraint_ratdens *r = rule->private;
+       const struct snd_pcm_hw_constraint_ratdens *r = rule->private;
        unsigned int num = 0, den = 0;
        int err = snd_interval_ratden(hw_param_interval(params, rule->var),
                                  r->nrats, r->rats, &num, &den);
@@ -1398,10 +1399,10 @@ static int snd_pcm_hw_rule_ratdens(struct snd_pcm_hw_params *params,
 int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, 
                                  unsigned int cond,
                                  snd_pcm_hw_param_t var,
-                                 struct snd_pcm_hw_constraint_ratdens *r)
+                                 const struct snd_pcm_hw_constraint_ratdens *r)
 {
        return snd_pcm_hw_rule_add(runtime, cond, var,
-                                  snd_pcm_hw_rule_ratdens, r,
+                                  snd_pcm_hw_rule_ratdens, (void *)r,
                                   var, -1);
 }