staticint
mlxreg_io_get_reg(void *regmap, struct mlxreg_core_data *data, u32 in_val, bool rw_flag, int regsize, u32 *regval)
{ int i, val, ret;
ret = regmap_read(regmap, data->reg, regval); if (ret) goto access_error;
/* * There are four kinds of attributes: single bit, full register's * bits, bit sequence, bits in few registers For the first kind field * mask indicates which bits are not related and field bit is set zero. * For the second kind field mask is set to zero and field bit is set * with all bits one. No special handling for such kind of attributes - * pass value as is. For the third kind, the field mask indicates which * bits are related and the field bit is set to the first bit number * (from 1 to 32) is the bit sequence. For the fourth kind - the number * of registers which should be read for getting an attribute are * specified through 'data->regnum' field.
*/ if (!data->bit) { /* Single bit. */ if (rw_flag) { /* For show: expose effective bit value as 0 or 1. */
*regval = !!(*regval & ~data->mask);
} else { /* For store: set effective bit value. */
*regval &= data->mask; if (in_val)
*regval |= ~data->mask;
}
} elseif (data->mask) { /* Bit sequence. */ if (rw_flag) { /* For show: mask and shift right. */
*regval = ror32(*regval & data->mask, (data->bit - 1));
} else { /* For store: shift to the position and mask. */
in_val = rol32(in_val, data->bit - 1) & data->mask; /* Clear relevant bits and set them to new value. */
*regval = (*regval & ~data->mask) | in_val;
}
} else { /* * Some attributes could occupied few registers in case regmap * bit size is 8 or 16. Compose such attributes from 'regnum' * registers. Such attributes contain read-only data.
*/ for (i = 1; i < data->regnum; i++) {
ret = regmap_read(regmap, data->reg + i, &val); if (ret) goto access_error;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.