1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
8 * This file contains the implementation of hardware access methord.
14 #include "cthardware.h"
17 #include <linux/bug.h>
19 int create_hw_obj(struct pci_dev
*pci
, enum CHIPTYP chip_type
,
20 enum CTCARDS model
, struct hw
**rhw
)
26 err
= create_20k1_hw_obj(rhw
);
29 err
= create_20k2_hw_obj(rhw
);
39 (*rhw
)->chip_type
= chip_type
;
40 (*rhw
)->model
= model
;
45 int destroy_hw_obj(struct hw
*hw
)
49 switch (hw
->pci
->device
) {
50 case 0x0005: /* 20k1 device */
51 err
= destroy_20k1_hw_obj(hw
);
53 case 0x000B: /* 20k2 device */
54 err
= destroy_20k2_hw_obj(hw
);
64 unsigned int get_field(unsigned int data
, unsigned int field
)
70 /* @field should always be greater than 0 */
71 for (i
= 0; !(field
& (1 << i
)); )
74 return (data
& field
) >> i
;
77 void set_field(unsigned int *data
, unsigned int field
, unsigned int value
)
83 /* @field should always be greater than 0 */
84 for (i
= 0; !(field
& (1 << i
)); )
87 *data
= (*data
& (~field
)) | ((value
<< i
) & field
);