mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-02 16:44:10 +08:00
aabdedf4d2
This driver creates an abstraction for different components by casting function
pointers to slightly incompatible types for each one to get the correct
argument even when the caller does not know those types. This is a
bit unreliable and not allowed in combination with control flow integrity
(KCFI):
sound/pci/ctxfi/ctatc.c:115:25: error: cast from 'int (*)(struct hw *, struct src_mgr **)' to 'create_t' (aka 'int (*)(struct hw *, void **)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
115 | [SRC] = { .create = (create_t)src_mgr_create,
| ^~~~~~~~~~~~~~~~~~~~~~~~
sound/pci/ctxfi/ctatc.c:116:20: error: cast from 'int (*)(struct src_mgr *)' to 'destroy_t' (aka 'int (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
116 | .destroy = (destroy_t)src_mgr_destroy },
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
sound/pci/ctxfi/ctatc.c:117:27: error: cast from 'int (*)(struct hw *, struct srcimp_mgr **)' to 'create_t' (aka 'int (*)(struct hw *, void **)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
117 | [SRCIMP] = { .create = (create_t)srcimp_mgr_create,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/pci/ctxfi/ctatc.c:118:20: error: cast from 'int (*)(struct srcimp_mgr *)' to 'destroy_t' (aka 'int (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
118 | .destroy = (destroy_t)srcimp_mgr_destroy },
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Change these to always pass void pointers and move the abstraction one level
down.
Fixes: 8cc7236148
("ALSA: SB X-Fi driver merge")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20240213101303.460008-1-arnd@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
96 lines
2.7 KiB
C
96 lines
2.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
|
|
*
|
|
* @File ctamixer.h
|
|
*
|
|
* @Brief
|
|
* This file contains the definition of the Audio Mixer
|
|
* resource management object.
|
|
*
|
|
* @Author Liu Chun
|
|
* @Date May 21 2008
|
|
*/
|
|
|
|
#ifndef CTAMIXER_H
|
|
#define CTAMIXER_H
|
|
|
|
#include "ctresource.h"
|
|
#include <linux/spinlock.h>
|
|
#include <sound/core.h>
|
|
|
|
/* Define the descriptor of a summation node resource */
|
|
struct sum {
|
|
struct rsc rsc; /* Basic resource info */
|
|
unsigned char idx[8];
|
|
};
|
|
|
|
/* Define sum resource request description info */
|
|
struct sum_desc {
|
|
unsigned int msr;
|
|
};
|
|
|
|
struct sum_mgr {
|
|
struct rsc_mgr mgr; /* Basic resource manager info */
|
|
struct snd_card *card; /* pointer to this card */
|
|
spinlock_t mgr_lock;
|
|
|
|
/* request one sum resource */
|
|
int (*get_sum)(struct sum_mgr *mgr,
|
|
const struct sum_desc *desc, struct sum **rsum);
|
|
/* return one sum resource */
|
|
int (*put_sum)(struct sum_mgr *mgr, struct sum *sum);
|
|
};
|
|
|
|
/* Constructor and destructor of daio resource manager */
|
|
int sum_mgr_create(struct hw *hw, void **ptr);
|
|
int sum_mgr_destroy(void *ptr);
|
|
|
|
/* Define the descriptor of a amixer resource */
|
|
struct amixer_rsc_ops;
|
|
|
|
struct amixer {
|
|
struct rsc rsc; /* Basic resource info */
|
|
unsigned char idx[8];
|
|
struct rsc *input; /* pointer to a resource acting as source */
|
|
struct sum *sum; /* Put amixer output to this summation node */
|
|
const struct amixer_rsc_ops *ops; /* AMixer specific operations */
|
|
};
|
|
|
|
struct amixer_rsc_ops {
|
|
int (*set_input)(struct amixer *amixer, struct rsc *rsc);
|
|
int (*set_scale)(struct amixer *amixer, unsigned int scale);
|
|
int (*set_invalid_squash)(struct amixer *amixer, unsigned int iv);
|
|
int (*set_sum)(struct amixer *amixer, struct sum *sum);
|
|
int (*commit_write)(struct amixer *amixer);
|
|
/* Only for interleaved recording */
|
|
int (*commit_raw_write)(struct amixer *amixer);
|
|
int (*setup)(struct amixer *amixer, struct rsc *input,
|
|
unsigned int scale, struct sum *sum);
|
|
int (*get_scale)(struct amixer *amixer);
|
|
};
|
|
|
|
/* Define amixer resource request description info */
|
|
struct amixer_desc {
|
|
unsigned int msr;
|
|
};
|
|
|
|
struct amixer_mgr {
|
|
struct rsc_mgr mgr; /* Basic resource manager info */
|
|
struct snd_card *card; /* pointer to this card */
|
|
spinlock_t mgr_lock;
|
|
|
|
/* request one amixer resource */
|
|
int (*get_amixer)(struct amixer_mgr *mgr,
|
|
const struct amixer_desc *desc,
|
|
struct amixer **ramixer);
|
|
/* return one amixer resource */
|
|
int (*put_amixer)(struct amixer_mgr *mgr, struct amixer *amixer);
|
|
};
|
|
|
|
/* Constructor and destructor of amixer resource manager */
|
|
int amixer_mgr_create(struct hw *hw, void **ramixer_mgr);
|
|
int amixer_mgr_destroy(void *amixer_mgr);
|
|
|
|
#endif /* CTAMIXER_H */
|