mic: vop: Fix use-after-free on remove
[linux/fpc-iii.git] / drivers / firmware / google / vpd_decode.h
blobbe3d62c5ca2fb967e51f7ae292627f014ac90970
1 /*
2 * vpd_decode.h
4 * Google VPD decoding routines.
6 * Copyright 2017 Google Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License v2.0 as published by
10 * the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #ifndef __VPD_DECODE_H
19 #define __VPD_DECODE_H
21 #include <linux/types.h>
23 enum {
24 VPD_OK = 0,
25 VPD_FAIL,
28 enum {
29 VPD_TYPE_TERMINATOR = 0,
30 VPD_TYPE_STRING,
31 VPD_TYPE_INFO = 0xfe,
32 VPD_TYPE_IMPLICIT_TERMINATOR = 0xff,
35 /* Callback for vpd_decode_string to invoke. */
36 typedef int vpd_decode_callback(const u8 *key, s32 key_len,
37 const u8 *value, s32 value_len,
38 void *arg);
41 * vpd_decode_string
43 * Given the encoded string, this function invokes callback with extracted
44 * (key, value). The *consumed will be plused the number of bytes consumed in
45 * this function.
47 * The input_buf points to the first byte of the input buffer.
49 * The *consumed starts from 0, which is actually the next byte to be decoded.
50 * It can be non-zero to be used in multiple calls.
52 * If one entry is successfully decoded, sends it to callback and returns the
53 * result.
55 int vpd_decode_string(const s32 max_len, const u8 *input_buf, s32 *consumed,
56 vpd_decode_callback callback, void *callback_arg);
58 #endif /* __VPD_DECODE_H */