Skip to content

Commit

Permalink
ALSA: vx: Constify snd_vx_hardware and snd_vx_ops definitions
Browse files Browse the repository at this point in the history
Both snd_vx_hardware and snd_vx_ops are only referred without
modification, hence they can be constified gracefully for further
optimizations.

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 aad7ebb commit f8ae2d2
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
9 changes: 5 additions & 4 deletions include/sound/vx_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ struct vx_core {
/* ports are defined externally */

/* low-level functions */
struct snd_vx_hardware *hw;
struct snd_vx_ops *ops;
const struct snd_vx_hardware *hw;
const struct snd_vx_ops *ops;

struct mutex lock;

Expand Down Expand Up @@ -193,8 +193,9 @@ struct vx_core {
/*
* constructor
*/
struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw,
struct snd_vx_ops *ops, int extra_size);
struct vx_core *snd_vx_create(struct snd_card *card,
const struct snd_vx_hardware *hw,
const struct snd_vx_ops *ops, int extra_size);
int snd_vx_setup_firmware(struct vx_core *chip);
int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *dsp);
int snd_vx_dsp_boot(struct vx_core *chip, const struct firmware *dsp);
Expand Down
5 changes: 3 additions & 2 deletions sound/drivers/vx/vx_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,9 @@ EXPORT_SYMBOL(snd_vx_resume);
*
* return the instance pointer if successful, NULL in error.
*/
struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw,
struct snd_vx_ops *ops,
struct vx_core *snd_vx_create(struct snd_card *card,
const struct snd_vx_hardware *hw,
const struct snd_vx_ops *ops,
int extra_size)
{
struct vx_core *chip;
Expand Down
12 changes: 6 additions & 6 deletions sound/pci/vx222/vx222.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ MODULE_DEVICE_TABLE(pci, snd_vx222_ids);
static const DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0);
static const DECLARE_TLV_DB_SCALE(db_scale_akm, -7350, 50, 0);

static struct snd_vx_hardware vx222_old_hw = {
static const struct snd_vx_hardware vx222_old_hw = {

.name = "VX222/Old",
.type = VX_TYPE_BOARD,
Expand All @@ -74,7 +74,7 @@ static struct snd_vx_hardware vx222_old_hw = {
.output_level_db_scale = db_scale_old_vol,
};

static struct snd_vx_hardware vx222_v2_hw = {
static const struct snd_vx_hardware vx222_v2_hw = {

.name = "VX222/v2",
.type = VX_TYPE_V2,
Expand All @@ -86,7 +86,7 @@ static struct snd_vx_hardware vx222_v2_hw = {
.output_level_db_scale = db_scale_akm,
};

static struct snd_vx_hardware vx222_mic_hw = {
static const struct snd_vx_hardware vx222_mic_hw = {

.name = "VX222/Mic",
.type = VX_TYPE_MIC,
Expand Down Expand Up @@ -122,7 +122,7 @@ static int snd_vx222_dev_free(struct snd_device *device)


static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci,
struct snd_vx_hardware *hw,
const struct snd_vx_hardware *hw,
struct snd_vx222 **rchip)
{
struct vx_core *chip;
Expand All @@ -131,7 +131,7 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci,
static const struct snd_device_ops ops = {
.dev_free = snd_vx222_dev_free,
};
struct snd_vx_ops *vx_ops;
const struct snd_vx_ops *vx_ops;

/* enable PCI device */
if ((err = pci_enable_device(pci)) < 0)
Expand Down Expand Up @@ -180,7 +180,7 @@ static int snd_vx222_probe(struct pci_dev *pci,
{
static int dev;
struct snd_card *card;
struct snd_vx_hardware *hw;
const struct snd_vx_hardware *hw;
struct snd_vx222 *vx;
int err;

Expand Down
4 changes: 2 additions & 2 deletions sound/pci/vx222/vx222.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ struct snd_vx222 {
/* we use a lookup table with 148 values, see vx_mixer.c */
#define VX2_AKM_LEVEL_MAX 0x93

extern struct snd_vx_ops vx222_ops;
extern struct snd_vx_ops vx222_old_ops;
extern const struct snd_vx_ops vx222_ops;
extern const struct snd_vx_ops vx222_old_ops;

/* Offset of registers with base equal to portDSP. */
#define VX_RESET_DMA_REGISTER_OFFSET 0x00000008
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/vx222/vx222_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ static int vx2_add_mic_controls(struct vx_core *_chip)
/*
* callbacks
*/
struct snd_vx_ops vx222_ops = {
const struct snd_vx_ops vx222_ops = {
.in8 = vx2_inb,
.in32 = vx2_inl,
.out8 = vx2_outb,
Expand All @@ -1004,7 +1004,7 @@ struct snd_vx_ops vx222_ops = {
};

/* for old VX222 board */
struct snd_vx_ops vx222_old_ops = {
const struct snd_vx_ops vx222_old_ops = {
.in8 = vx2_inb,
.in32 = vx2_inl,
.out8 = vx2_outb,
Expand Down
2 changes: 1 addition & 1 deletion sound/pcmcia/vx/vxp_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ static void vxp_reset_board(struct vx_core *_chip, int cold_reset)
* callbacks
*/
/* exported */
struct snd_vx_ops snd_vxpocket_ops = {
const struct snd_vx_ops snd_vxpocket_ops = {
.in8 = vxp_inb,
.out8 = vxp_outb,
.test_and_ack = vxp_test_and_ack,
Expand Down
4 changes: 2 additions & 2 deletions sound/pcmcia/vx/vxpocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static int snd_vxpocket_dev_free(struct snd_device *device)

static const DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0);

static struct snd_vx_hardware vxpocket_hw = {
static const struct snd_vx_hardware vxpocket_hw = {
.name = "VXPocket",
.type = VX_TYPE_VXPOCKET,

Expand All @@ -104,7 +104,7 @@ static struct snd_vx_hardware vxpocket_hw = {
* UER, but only for the first two inputs and outputs.
*/

static struct snd_vx_hardware vxp440_hw = {
static const struct snd_vx_hardware vxp440_hw = {
.name = "VXPocket440",
.type = VX_TYPE_VXP440,

Expand Down
2 changes: 1 addition & 1 deletion sound/pcmcia/vx/vxpocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct snd_vxpocket {

#define to_vxpocket(x) container_of(x, struct snd_vxpocket, core)

extern struct snd_vx_ops snd_vxpocket_ops;
extern const struct snd_vx_ops snd_vxpocket_ops;

void vx_set_mic_boost(struct vx_core *chip, int boost);
void vx_set_mic_level(struct vx_core *chip, int level);
Expand Down

0 comments on commit f8ae2d2

Please sign in to comment.