2 * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
4 * This source file is released under GPL v2 license (no other versions).
5 * See the COPYING file included in the main directory of this source
6 * distribution for the license terms and conditions.
11 * This file contains the implementation of hardware access methord.
18 #include "cthardware.h"
21 #include <linux/bug.h>
23 int create_hw_obj(struct pci_dev
*pci
, enum CHIPTYP chip_type
,
24 enum CTCARDS model
, struct hw
**rhw
)
30 err
= create_20k1_hw_obj(rhw
);
33 err
= create_20k2_hw_obj(rhw
);
43 (*rhw
)->chip_type
= chip_type
;
44 (*rhw
)->model
= model
;
49 int destroy_hw_obj(struct hw
*hw
)
53 switch (hw
->pci
->device
) {
54 case 0x0005: /* 20k1 device */
55 err
= destroy_20k1_hw_obj(hw
);
57 case 0x000B: /* 20k2 device */
58 err
= destroy_20k2_hw_obj(hw
);
68 unsigned int get_field(unsigned int data
, unsigned int field
)
74 /* @field should always be greater than 0 */
75 for (i
= 0; !(field
& (1 << i
)); )
78 return (data
& field
) >> i
;
81 void set_field(unsigned int *data
, unsigned int field
, unsigned int value
)
87 /* @field should always be greater than 0 */
88 for (i
= 0; !(field
& (1 << i
)); )
91 *data
= (*data
& (~field
)) | ((value
<< i
) & field
);