*参照元 [#nbdfba83] #backlinks *説明 [#u013710e] -パス: [[linux-4.4.1/sound/soc/soc-ops.c]] -FIXME: これは何? --説明 **引数 [#k173ab85] -struct snd_soc_component *component -- --[[linux-4.4.1/snd_soc_component]] -unsigned int reg -- -unsigned int mask -- -unsigned int shift -- -unsigned int sign_bit -- -int *signed_val -- **返り値 [#cc9286ce] -int -- **参考 [#ef4d8b3f] *実装 [#w36a7940] /** * snd_soc_read_signed - Read a codec register and interprete as signed value * @component: component * @reg: Register to read * @mask: Mask to use after shifting the register value * @shift: Right shift of register value * @sign_bit: Bit that describes if a number is negative or not. * @signed_val: Pointer to where the read value should be stored * * This functions reads a codec register. The register value is shifted right * by 'shift' bits and masked with the given 'mask'. Afterwards it translates * the given registervalue into a signed integer if sign_bit is non-zero. * * Returns 0 on sucess, otherwise an error value */ static int snd_soc_read_signed(struct snd_soc_component *component, unsigned int reg, unsigned int mask, unsigned int shift, unsigned int sign_bit, int *signed_val) { int ret; unsigned int val; ret = snd_soc_component_read(component, reg, &val); if (ret < 0) return ret; - --[[linux-4.4.1/snd_soc_component_read()]] val = (val >> shift) & mask; if (!sign_bit) { *signed_val = val; return 0; } /* non-negative number */ if (!(val & BIT(sign_bit))) { *signed_val = val; return 0; } - --[[linux-4.4.1/BIT()]] ret = val; /* * The register most probably does not contain a full-sized int. * Instead we have an arbitrary number of bits in a signed * representation which has to be translated into a full-sized int. * This is done by filling up all bits above the sign-bit. */ ret |= ~((int)(BIT(sign_bit) - 1)); *signed_val = ret; return 0; } *コメント [#j2ca8cb2]