static int pca953x_set_direction(struct udevice *dev, unsigned offset, int dir) { struct pca953x_info *info = dev_get_platdata(dev); int bank = offset / BANK_SZ; int off = offset % BANK_SZ; u8 val; int ret; if (dir == PCA953X_DIRECTION_IN) val = info->reg_direction[bank] | (1 << off); else val = info->reg_direction[bank] & ~(1 << off); ret = pca953x_write_single(dev, PCA953X_DIRECTION, val, offset); if (ret) return ret; info->reg_direction[bank] = val; return 0; }
static int pca953x_set_value(struct udevice *dev, uint offset, int value) { struct pca953x_info *info = dev_get_platdata(dev); int bank = offset / BANK_SZ; int off = offset % BANK_SZ; u8 val; int ret; if (value) val = info->reg_output[bank] | (1 << off); else val = info->reg_output[bank] & ~(1 << off); ret = pca953x_write_single(dev, PCA953X_OUTPUT, val, offset); if (ret) return ret; info->reg_output[bank] = val; return 0; }