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

TOMOYO Linux Cross Reference
Linux/sound/pci/asihpi/hpimsginit.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /******************************************************************************
  3 
  4     AudioScience HPI driver
  5     Copyright (C) 1997-2014  AudioScience Inc. <support@audioscience.com>
  6 
  7 
  8  Hardware Programming Interface (HPI) Utility functions.
  9 
 10  (C) Copyright AudioScience Inc. 2007
 11 *******************************************************************************/
 12 
 13 #include "hpi_internal.h"
 14 #include "hpimsginit.h"
 15 #include <linux/nospec.h>
 16 
 17 /* The actual message size for each object type */
 18 static u16 msg_size[HPI_OBJ_MAXINDEX + 1] = HPI_MESSAGE_SIZE_BY_OBJECT;
 19 /* The actual response size for each object type */
 20 static u16 res_size[HPI_OBJ_MAXINDEX + 1] = HPI_RESPONSE_SIZE_BY_OBJECT;
 21 /* Flag to enable alternate message type for SSX2 bypass. */
 22 static u16 gwSSX2_bypass;
 23 
 24 /** \internal
 25   * initialize the HPI message structure
 26   */
 27 static void hpi_init_message(struct hpi_message *phm, u16 object,
 28         u16 function)
 29 {
 30         u16 size;
 31 
 32         if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
 33                 object = array_index_nospec(object, HPI_OBJ_MAXINDEX + 1);
 34                 size = msg_size[object];
 35         } else {
 36                 size = sizeof(*phm);
 37         }
 38 
 39         memset(phm, 0, size);
 40         phm->size = size;
 41 
 42         if (gwSSX2_bypass)
 43                 phm->type = HPI_TYPE_SSX2BYPASS_MESSAGE;
 44         else
 45                 phm->type = HPI_TYPE_REQUEST;
 46         phm->object = object;
 47         phm->function = function;
 48         phm->version = 0;
 49         phm->adapter_index = HPI_ADAPTER_INDEX_INVALID;
 50         /* Expect actual adapter index to be set by caller */
 51 }
 52 
 53 /** \internal
 54   * initialize the HPI response structure
 55   */
 56 void hpi_init_response(struct hpi_response *phr, u16 object, u16 function,
 57         u16 error)
 58 {
 59         u16 size;
 60 
 61         if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
 62                 object = array_index_nospec(object, HPI_OBJ_MAXINDEX + 1);
 63                 size = res_size[object];
 64         } else {
 65                 size = sizeof(*phr);
 66         }
 67 
 68         memset(phr, 0, sizeof(*phr));
 69         phr->size = size;
 70         phr->type = HPI_TYPE_RESPONSE;
 71         phr->object = object;
 72         phr->function = function;
 73         phr->error = error;
 74         phr->specific_error = 0;
 75         phr->version = 0;
 76 }
 77 
 78 void hpi_init_message_response(struct hpi_message *phm,
 79         struct hpi_response *phr, u16 object, u16 function)
 80 {
 81         hpi_init_message(phm, object, function);
 82         /* default error return if the response is
 83            not filled in by the callee */
 84         hpi_init_response(phr, object, function,
 85                 HPI_ERROR_PROCESSING_MESSAGE);
 86 }
 87 
 88 static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size,
 89         u16 object, u16 function)
 90 {
 91         memset(phm, 0, size);
 92         if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
 93                 phm->size = size;
 94                 phm->type = HPI_TYPE_REQUEST;
 95                 phm->object = object;
 96                 phm->function = function;
 97                 phm->version = 1;
 98                 /* Expect adapter index to be set by caller */
 99         }
100 }
101 
102 void hpi_init_responseV1(struct hpi_response_header *phr, u16 size,
103         u16 object, u16 function)
104 {
105         (void)object;
106         (void)function;
107         memset(phr, 0, size);
108         phr->size = size;
109         phr->version = 1;
110         phr->type = HPI_TYPE_RESPONSE;
111         phr->error = HPI_ERROR_PROCESSING_MESSAGE;
112 }
113 
114 void hpi_init_message_responseV1(struct hpi_message_header *phm, u16 msg_size,
115         struct hpi_response_header *phr, u16 res_size, u16 object,
116         u16 function)
117 {
118         hpi_init_messageV1(phm, msg_size, object, function);
119         hpi_init_responseV1(phr, res_size, object, function);
120 }
121 

~ [ 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