Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: sh-pfc: Use u32 to store register data

As PFC registers are either 8, 16, or 32 bits wide, use u32 (mostly
replacing unsigned long) to store (parts of) register values and masks.

Switch the shadow register operations from {set,clear}_bit() to plain C
bit operations, as the former can operate on long data only.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Geert Uytterhoeven and committed by
Linus Walleij
fc88936a cbd159ed

+21 -22
+13 -12
drivers/pinctrl/sh-pfc/core.c
··· 144 144 return 1; 145 145 } 146 146 147 - unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg, 148 - unsigned long reg_width) 147 + u32 sh_pfc_read_raw_reg(void __iomem *mapped_reg, unsigned long reg_width) 149 148 { 150 149 switch (reg_width) { 151 150 case 8: ··· 160 161 } 161 162 162 163 void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned long reg_width, 163 - unsigned long data) 164 + u32 data) 164 165 { 165 166 switch (reg_width) { 166 167 case 8: ··· 180 181 static void sh_pfc_config_reg_helper(struct sh_pfc *pfc, 181 182 const struct pinmux_cfg_reg *crp, 182 183 unsigned long in_pos, 183 - void __iomem **mapped_regp, 184 - unsigned long *maskp, 184 + void __iomem **mapped_regp, u32 *maskp, 185 185 unsigned long *posp) 186 186 { 187 187 unsigned int k; ··· 200 202 201 203 static void sh_pfc_write_config_reg(struct sh_pfc *pfc, 202 204 const struct pinmux_cfg_reg *crp, 203 - unsigned long field, unsigned long value) 205 + unsigned long field, u32 value) 204 206 { 205 207 void __iomem *mapped_reg; 206 - unsigned long mask, pos, data; 208 + unsigned long pos; 209 + u32 mask, data; 207 210 208 211 sh_pfc_config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos); 209 212 210 - dev_dbg(pfc->dev, "write_reg addr = %lx, value = %ld, field = %ld, " 213 + dev_dbg(pfc->dev, "write_reg addr = %lx, value = 0x%x, field = %ld, " 211 214 "r_width = %ld, f_width = %ld\n", 212 215 crp->reg, value, field, crp->reg_width, crp->field_width); 213 216 ··· 229 230 230 231 static int sh_pfc_get_config_reg(struct sh_pfc *pfc, u16 enum_id, 231 232 const struct pinmux_cfg_reg **crp, int *fieldp, 232 - int *valuep) 233 + u32 *valuep) 233 234 { 234 235 const struct pinmux_cfg_reg *config_reg; 235 - unsigned long r_width, f_width, curr_width, ncomb; 236 - unsigned int k, m, n, pos, bit_pos; 236 + unsigned long r_width, f_width, curr_width; 237 + unsigned int k, m, pos, bit_pos; 238 + u32 ncomb, n; 237 239 238 240 k = 0; 239 241 while (1) { ··· 300 300 const struct pinmux_cfg_reg *cr = NULL; 301 301 u16 enum_id; 302 302 const struct pinmux_range *range; 303 - int in_range, pos, field, value; 303 + int in_range, pos, field; 304 + u32 value; 304 305 int ret; 305 306 306 307 switch (pinmux_type) {
+2 -3
drivers/pinctrl/sh-pfc/core.h
··· 57 57 int sh_pfc_register_pinctrl(struct sh_pfc *pfc); 58 58 int sh_pfc_unregister_pinctrl(struct sh_pfc *pfc); 59 59 60 - unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg, 61 - unsigned long reg_width); 60 + u32 sh_pfc_read_raw_reg(void __iomem *mapped_reg, unsigned long reg_width); 62 61 void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned long reg_width, 63 - unsigned long data); 62 + u32 data); 64 63 65 64 int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin); 66 65 int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type);
+6 -7
drivers/pinctrl/sh-pfc/gpio.c
··· 21 21 22 22 struct sh_pfc_gpio_data_reg { 23 23 const struct pinmux_data_reg *info; 24 - unsigned long shadow; 24 + u32 shadow; 25 25 }; 26 26 27 27 struct sh_pfc_gpio_pin { ··· 59 59 *bit = gpio_pin->dbit; 60 60 } 61 61 62 - static unsigned long gpio_read_data_reg(struct sh_pfc_chip *chip, 63 - const struct pinmux_data_reg *dreg) 62 + static u32 gpio_read_data_reg(struct sh_pfc_chip *chip, 63 + const struct pinmux_data_reg *dreg) 64 64 { 65 65 void __iomem *mem = dreg->reg - chip->mem->phys + chip->mem->virt; 66 66 ··· 68 68 } 69 69 70 70 static void gpio_write_data_reg(struct sh_pfc_chip *chip, 71 - const struct pinmux_data_reg *dreg, 72 - unsigned long value) 71 + const struct pinmux_data_reg *dreg, u32 value) 73 72 { 74 73 void __iomem *mem = dreg->reg - chip->mem->phys + chip->mem->virt; 75 74 ··· 161 162 pos = reg->info->reg_width - (bit + 1); 162 163 163 164 if (value) 164 - set_bit(pos, &reg->shadow); 165 + reg->shadow |= BIT(pos); 165 166 else 166 - clear_bit(pos, &reg->shadow); 167 + reg->shadow &= ~BIT(pos); 167 168 168 169 gpio_write_data_reg(chip, reg->info, reg->shadow); 169 170 }