equal
deleted
inserted
replaced
115 /*****************************************************************************/ |
115 /*****************************************************************************/ |
116 |
116 |
117 /** Pre-allocates the data memory. |
117 /** Pre-allocates the data memory. |
118 * |
118 * |
119 * If the \a mem_size is already bigger than \a size, nothing is done. |
119 * If the \a mem_size is already bigger than \a size, nothing is done. |
|
120 * |
|
121 * \return 0 on success, otherwise -ENOMEM. |
120 */ |
122 */ |
121 int ec_sdo_request_alloc( |
123 int ec_sdo_request_alloc( |
122 ec_sdo_request_t *req, /**< Sdo request. */ |
124 ec_sdo_request_t *req, /**< Sdo request. */ |
123 size_t size /**< Data size to allocate. */ |
125 size_t size /**< Data size to allocate. */ |
124 ) |
126 ) |
128 |
130 |
129 ec_sdo_request_clear_data(req); |
131 ec_sdo_request_clear_data(req); |
130 |
132 |
131 if (!(req->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) { |
133 if (!(req->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) { |
132 EC_ERR("Failed to allocate %u bytes of Sdo memory.\n", size); |
134 EC_ERR("Failed to allocate %u bytes of Sdo memory.\n", size); |
133 return -1; |
135 return -ENOMEM; |
134 } |
136 } |
135 |
137 |
136 req->mem_size = size; |
138 req->mem_size = size; |
137 req->data_size = 0; |
139 req->data_size = 0; |
138 return 0; |
140 return 0; |