~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/pci/ctxfi/cthardware.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
  4  *
  5  * @File        cthardware.c
  6  *
  7  * @Brief
  8  * This file contains the implementation of hardware access methord.
  9  *
 10  * @Author      Liu Chun
 11  * @Date        Jun 26 2008
 12  */
 13 
 14 #include "cthardware.h"
 15 #include "cthw20k1.h"
 16 #include "cthw20k2.h"
 17 #include <linux/bug.h>
 18 
 19 int create_hw_obj(struct pci_dev *pci, enum CHIPTYP chip_type,
 20                   enum CTCARDS model, struct hw **rhw)
 21 {
 22         int err;
 23 
 24         switch (chip_type) {
 25         case ATC20K1:
 26                 err = create_20k1_hw_obj(rhw);
 27                 break;
 28         case ATC20K2:
 29                 err = create_20k2_hw_obj(rhw);
 30                 break;
 31         default:
 32                 err = -ENODEV;
 33                 break;
 34         }
 35         if (err)
 36                 return err;
 37 
 38         (*rhw)->pci = pci;
 39         (*rhw)->chip_type = chip_type;
 40         (*rhw)->model = model;
 41 
 42         return 0;
 43 }
 44 
 45 int destroy_hw_obj(struct hw *hw)
 46 {
 47         int err;
 48 
 49         switch (hw->pci->device) {
 50         case 0x0005:    /* 20k1 device */
 51                 err = destroy_20k1_hw_obj(hw);
 52                 break;
 53         case 0x000B:    /* 20k2 device */
 54                 err = destroy_20k2_hw_obj(hw);
 55                 break;
 56         default:
 57                 err = -ENODEV;
 58                 break;
 59         }
 60 
 61         return err;
 62 }
 63 
 64 unsigned int get_field(unsigned int data, unsigned int field)
 65 {
 66         int i;
 67 
 68         if (WARN_ON(!field))
 69                 return 0;
 70         /* @field should always be greater than 0 */
 71         for (i = 0; !(field & (1 << i)); )
 72                 i++;
 73 
 74         return (data & field) >> i;
 75 }
 76 
 77 void set_field(unsigned int *data, unsigned int field, unsigned int value)
 78 {
 79         int i;
 80 
 81         if (WARN_ON(!field))
 82                 return;
 83         /* @field should always be greater than 0 */
 84         for (i = 0; !(field & (1 << i)); )
 85                 i++;
 86 
 87         *data = (*data & (~field)) | ((value << i) & field);
 88 }
 89 
 90 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php