static int ricoh61x_gpio_get(struct gpio_chip *gc, unsigned offset) { struct ricoh61x *ricoh61x = container_of(gc, struct ricoh61x, gpio_chip); uint8_t val; int ret; ret = ricoh61x_read(ricoh61x->dev, RICOH61x_GPIO_MON_IOIN, &val); if (ret < 0) return ret; return ((val & (0x1 << offset)) != 0); }
static int ricoh61x_reg_is_enabled(struct regulator_dev *rdev) { struct ricoh61x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_ricoh61x_dev(rdev); uint8_t control; int ret; ret = ricoh61x_read(parent, ri->reg_en_reg, &control); if (ret < 0) { dev_err(&rdev->dev, "Error in reading the control register\n"); return ret; } return (((control >> ri->en_bit) & 1) == 1); }
static inline int ricoh61x_cache_regulator_register(struct device *parent, struct ricoh61x_regulator *ri) { ri->vout_reg_cache = 0; return ricoh61x_read(parent, ri->vout_reg, &ri->vout_reg_cache); }