Skip to content

Commit

Permalink
ALSA: ac97: Treat snd_ac97_bus_ops as const
Browse files Browse the repository at this point in the history
This is a preliminary patch to allow const for snd_ac97_bus_ops
definitions in each driver's code.  The ops reference is read-only,
hence it can be declared as const for further optimization.

There should be no functional changes by this patch.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Jan 3, 2020
1 parent 5ff16a3 commit 1926081
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions include/sound/ac97_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ struct snd_ac97_bus_ops {

struct snd_ac97_bus {
/* -- lowlevel (hardware) driver specific -- */
struct snd_ac97_bus_ops *ops;
const struct snd_ac97_bus_ops *ops;
void *private_data;
void (*private_free) (struct snd_ac97_bus *bus);
/* --- */
Expand Down Expand Up @@ -310,7 +310,8 @@ static inline int ac97_can_spdif(struct snd_ac97 * ac97)

/* functions */
/* create new AC97 bus */
int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
int snd_ac97_bus(struct snd_card *card, int num,
const struct snd_ac97_bus_ops *ops,
void *private_data, struct snd_ac97_bus **rbus);
/* create mixer controls */
int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
Expand Down
2 changes: 1 addition & 1 deletion sound/ac97_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static bool snd_ac97_check_id(struct snd_ac97 *ac97, unsigned int id,
int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id,
unsigned int id_mask)
{
struct snd_ac97_bus_ops *ops = ac97->bus->ops;
const struct snd_ac97_bus_ops *ops = ac97->bus->ops;

if (try_warm && ops->warm_reset) {
ops->warm_reset(ac97);
Expand Down
3 changes: 2 additions & 1 deletion sound/pci/ac97/ac97_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,8 @@ static int ac97_reset_wait(struct snd_ac97 *ac97, int timeout, int with_modem)
*
* Return: Zero if successful, or a negative error code on failure.
*/
int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
int snd_ac97_bus(struct snd_card *card, int num,
const struct snd_ac97_bus_ops *ops,
void *private_data, struct snd_ac97_bus **rbus)
{
int err;
Expand Down

0 comments on commit 1926081

Please sign in to comment.