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

media: ccs-pll: Switch from standard integer types to kernel ones

The preferred integer types in the kernel are the Linux specific ones,
switch from standard C types to u32 and alike.

The patch has been produced with the following Coccinelle spatch, with few
alignment adjustments:

@@
typedef uint32_t;
typedef u32;
@@
- uint32_t
+ u32

@@
typedef uint16_t;
typedef u16;
@@
- uint16_t
+ u16

@@
typedef uint8_t;
typedef u8;
@@
- uint8_t
+ u8

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Sakari Ailus and committed by
Mauro Carvalho Chehab
8a75e8dc 81499d33

+100 -100
+57 -57
drivers/media/i2c/ccs-pll.c
··· 17 17 #include "ccs-pll.h" 18 18 19 19 /* Return an even number or one. */ 20 - static inline uint32_t clk_div_even(uint32_t a) 20 + static inline u32 clk_div_even(u32 a) 21 21 { 22 - return max_t(uint32_t, 1, a & ~1); 22 + return max_t(u32, 1, a & ~1); 23 23 } 24 24 25 25 /* Return an even number or one. */ 26 - static inline uint32_t clk_div_even_up(uint32_t a) 26 + static inline u32 clk_div_even_up(u32 a) 27 27 { 28 28 if (a == 1) 29 29 return 1; 30 30 return (a + 1) & ~1; 31 31 } 32 32 33 - static inline uint32_t is_one_or_even(uint32_t a) 33 + static inline u32 is_one_or_even(u32 a) 34 34 { 35 35 if (a == 1) 36 36 return 1; ··· 40 40 return 1; 41 41 } 42 42 43 - static inline uint32_t one_or_more(uint32_t a) 43 + static inline u32 one_or_more(u32 a) 44 44 { 45 45 return a ?: 1; 46 46 } 47 47 48 - static int bounds_check(struct device *dev, uint32_t val, 49 - uint32_t min, uint32_t max, const char *prefix, 48 + static int bounds_check(struct device *dev, u32 val, 49 + u32 min, u32 max, const char *prefix, 50 50 char *str) 51 51 { 52 52 if (val >= min && val <= max) ··· 138 138 pll->flags & PLL_FL(OP_PIX_DDR) ? " op-pix-ddr" : ""); 139 139 } 140 140 141 - static uint32_t op_sys_ddr(uint32_t flags) 141 + static u32 op_sys_ddr(u32 flags) 142 142 { 143 143 return flags & CCS_PLL_FLAG_OP_SYS_DDR ? 1 : 0; 144 144 } 145 145 146 - static uint32_t op_pix_ddr(uint32_t flags) 146 + static u32 op_pix_ddr(u32 flags) 147 147 { 148 148 return flags & CCS_PLL_FLAG_OP_PIX_DDR ? 1 : 0; 149 149 } ··· 250 250 static void 251 251 ccs_pll_find_vt_sys_div(struct device *dev, const struct ccs_pll_limits *lim, 252 252 struct ccs_pll *pll, struct ccs_pll_branch_fr *pll_fr, 253 - uint16_t min_vt_div, uint16_t max_vt_div, 254 - uint16_t *min_sys_div, uint16_t *max_sys_div) 253 + u16 min_vt_div, u16 max_vt_div, 254 + u16 *min_sys_div, u16 *max_sys_div) 255 255 { 256 256 /* 257 257 * Find limits for sys_clk_div. Not all values are possible with all ··· 259 259 */ 260 260 *min_sys_div = lim->vt_bk.min_sys_clk_div; 261 261 dev_dbg(dev, "min_sys_div: %u\n", *min_sys_div); 262 - *min_sys_div = max_t(uint16_t, *min_sys_div, 262 + *min_sys_div = max_t(u16, *min_sys_div, 263 263 DIV_ROUND_UP(min_vt_div, 264 264 lim->vt_bk.max_pix_clk_div)); 265 265 dev_dbg(dev, "min_sys_div: max_vt_pix_clk_div: %u\n", *min_sys_div); 266 - *min_sys_div = max_t(uint16_t, *min_sys_div, 266 + *min_sys_div = max_t(u16, *min_sys_div, 267 267 pll_fr->pll_op_clk_freq_hz 268 268 / lim->vt_bk.max_sys_clk_freq_hz); 269 269 dev_dbg(dev, "min_sys_div: max_pll_op_clk_freq_hz: %u\n", *min_sys_div); ··· 272 272 273 273 *max_sys_div = lim->vt_bk.max_sys_clk_div; 274 274 dev_dbg(dev, "max_sys_div: %u\n", *max_sys_div); 275 - *max_sys_div = min_t(uint16_t, *max_sys_div, 275 + *max_sys_div = min_t(u16, *max_sys_div, 276 276 DIV_ROUND_UP(max_vt_div, 277 277 lim->vt_bk.min_pix_clk_div)); 278 278 dev_dbg(dev, "max_sys_div: min_vt_pix_clk_div: %u\n", *max_sys_div); 279 - *max_sys_div = min_t(uint16_t, *max_sys_div, 279 + *max_sys_div = min_t(u16, *max_sys_div, 280 280 DIV_ROUND_UP(pll_fr->pll_op_clk_freq_hz, 281 281 lim->vt_bk.min_pix_clk_freq_hz)); 282 282 dev_dbg(dev, "max_sys_div: min_vt_pix_clk_freq_hz: %u\n", *max_sys_div); ··· 289 289 static inline int 290 290 __ccs_pll_calculate_vt_tree(struct device *dev, 291 291 const struct ccs_pll_limits *lim, 292 - struct ccs_pll *pll, uint32_t mul, uint32_t div) 292 + struct ccs_pll *pll, u32 mul, u32 div) 293 293 { 294 294 const struct ccs_pll_branch_limits_fr *lim_fr = &lim->vt_fr; 295 295 const struct ccs_pll_branch_limits_bk *lim_bk = &lim->vt_bk; 296 296 struct ccs_pll_branch_fr *pll_fr = &pll->vt_fr; 297 297 struct ccs_pll_branch_bk *pll_bk = &pll->vt_bk; 298 - uint32_t more_mul; 299 - uint16_t best_pix_div = SHRT_MAX >> 1, best_div; 300 - uint16_t vt_div, min_sys_div, max_sys_div, sys_div; 298 + u32 more_mul; 299 + u16 best_pix_div = SHRT_MAX >> 1, best_div; 300 + u16 vt_div, min_sys_div, max_sys_div, sys_div; 301 301 302 302 pll_fr->pll_ip_clk_freq_hz = 303 303 pll->ext_clk_freq_hz / pll_fr->pre_pll_clk_div; ··· 331 331 332 332 for (sys_div = min_sys_div; sys_div <= max_sys_div; 333 333 sys_div += 2 - (sys_div & 1)) { 334 - uint16_t pix_div; 334 + u16 pix_div; 335 335 336 336 if (vt_div % sys_div) 337 337 continue; ··· 379 379 { 380 380 const struct ccs_pll_branch_limits_fr *lim_fr = &lim->vt_fr; 381 381 struct ccs_pll_branch_fr *pll_fr = &pll->vt_fr; 382 - uint16_t min_pre_pll_clk_div = lim_fr->min_pre_pll_clk_div; 383 - uint16_t max_pre_pll_clk_div = lim_fr->max_pre_pll_clk_div; 384 - uint32_t pre_mul, pre_div; 382 + u16 min_pre_pll_clk_div = lim_fr->min_pre_pll_clk_div; 383 + u16 max_pre_pll_clk_div = lim_fr->max_pre_pll_clk_div; 384 + u32 pre_mul, pre_div; 385 385 386 386 pre_div = gcd(pll->pixel_rate_csi, 387 387 pll->ext_clk_freq_hz * pll->vt_lanes); ··· 390 390 391 391 /* Make sure PLL input frequency is within limits */ 392 392 max_pre_pll_clk_div = 393 - min_t(uint16_t, max_pre_pll_clk_div, 393 + min_t(u16, max_pre_pll_clk_div, 394 394 DIV_ROUND_UP(pll->ext_clk_freq_hz, 395 395 lim_fr->min_pll_ip_clk_freq_hz)); 396 396 397 - min_pre_pll_clk_div = max_t(uint16_t, min_pre_pll_clk_div, 397 + min_pre_pll_clk_div = max_t(u16, min_pre_pll_clk_div, 398 398 pll->ext_clk_freq_hz / 399 399 lim_fr->max_pll_ip_clk_freq_hz); 400 400 ··· 406 406 pll_fr->pre_pll_clk_div += 407 407 (pll->flags & CCS_PLL_FLAG_EXT_IP_PLL_DIVIDER) ? 1 : 408 408 2 - (pll_fr->pre_pll_clk_div & 1)) { 409 - uint32_t mul, div; 409 + u32 mul, div; 410 410 int rval; 411 411 412 412 div = gcd(pre_mul * pll_fr->pre_pll_clk_div, pre_div); ··· 440 440 const struct ccs_pll_branch_limits_bk *op_lim_bk, 441 441 struct ccs_pll *pll, struct ccs_pll_branch_fr *pll_fr, 442 442 struct ccs_pll_branch_bk *op_pll_bk, bool cphy, 443 - uint32_t phy_const) 443 + u32 phy_const) 444 444 { 445 - uint16_t sys_div; 446 - uint16_t best_pix_div = SHRT_MAX >> 1; 447 - uint16_t vt_op_binning_div; 448 - uint16_t min_vt_div, max_vt_div, vt_div; 449 - uint16_t min_sys_div, max_sys_div; 445 + u16 sys_div; 446 + u16 best_pix_div = SHRT_MAX >> 1; 447 + u16 vt_op_binning_div; 448 + u16 min_vt_div, max_vt_div, vt_div; 449 + u16 min_sys_div, max_sys_div; 450 450 451 451 if (pll->flags & CCS_PLL_FLAG_NO_OP_CLOCKS) 452 452 goto out_calc_pixel_rate; ··· 500 500 501 501 /* Find smallest and biggest allowed vt divisor. */ 502 502 dev_dbg(dev, "min_vt_div: %u\n", min_vt_div); 503 - min_vt_div = max_t(uint16_t, min_vt_div, 503 + min_vt_div = max_t(u16, min_vt_div, 504 504 DIV_ROUND_UP(pll_fr->pll_op_clk_freq_hz, 505 505 lim->vt_bk.max_pix_clk_freq_hz)); 506 506 dev_dbg(dev, "min_vt_div: max_vt_pix_clk_freq_hz: %u\n", 507 507 min_vt_div); 508 - min_vt_div = max_t(uint16_t, min_vt_div, lim->vt_bk.min_pix_clk_div 509 - * lim->vt_bk.min_sys_clk_div); 508 + min_vt_div = max_t(u16, min_vt_div, lim->vt_bk.min_pix_clk_div 509 + * lim->vt_bk.min_sys_clk_div); 510 510 dev_dbg(dev, "min_vt_div: min_vt_clk_div: %u\n", min_vt_div); 511 511 512 512 max_vt_div = lim->vt_bk.max_sys_clk_div * lim->vt_bk.max_pix_clk_div; 513 513 dev_dbg(dev, "max_vt_div: %u\n", max_vt_div); 514 - max_vt_div = min_t(uint16_t, max_vt_div, 514 + max_vt_div = min_t(u16, max_vt_div, 515 515 DIV_ROUND_UP(pll_fr->pll_op_clk_freq_hz, 516 516 lim->vt_bk.min_pix_clk_freq_hz)); 517 517 dev_dbg(dev, "max_vt_div: min_vt_pix_clk_freq_hz: %u\n", ··· 526 526 * divisor. 527 527 */ 528 528 for (vt_div = min_vt_div; vt_div <= max_vt_div; vt_div++) { 529 - uint16_t __max_sys_div = vt_div & 1 ? 1 : max_sys_div; 529 + u16 __max_sys_div = vt_div & 1 ? 1 : max_sys_div; 530 530 531 531 for (sys_div = min_sys_div; sys_div <= __max_sys_div; 532 532 sys_div += 2 - (sys_div & 1)) { 533 - uint16_t pix_div; 534 - uint16_t rounded_div; 533 + u16 pix_div; 534 + u16 rounded_div; 535 535 536 536 pix_div = DIV_ROUND_UP(vt_div, sys_div); 537 537 ··· 588 588 const struct ccs_pll_branch_limits_fr *op_lim_fr, 589 589 const struct ccs_pll_branch_limits_bk *op_lim_bk, 590 590 struct ccs_pll *pll, struct ccs_pll_branch_fr *op_pll_fr, 591 - struct ccs_pll_branch_bk *op_pll_bk, uint32_t mul, 592 - uint32_t div, uint32_t op_sys_clk_freq_hz_sdr, uint32_t l, 593 - bool cphy, uint32_t phy_const) 591 + struct ccs_pll_branch_bk *op_pll_bk, u32 mul, 592 + u32 div, u32 op_sys_clk_freq_hz_sdr, u32 l, 593 + bool cphy, u32 phy_const) 594 594 { 595 595 /* 596 596 * Higher multipliers (and divisors) are often required than ··· 598 598 * There are limits for all values in the clock tree. These 599 599 * are the minimum and maximum multiplier for mul. 600 600 */ 601 - uint32_t more_mul_min, more_mul_max; 602 - uint32_t more_mul_factor; 603 - uint32_t i; 601 + u32 more_mul_min, more_mul_max; 602 + u32 more_mul_factor; 603 + u32 i; 604 604 605 605 /* 606 606 * Get pre_pll_clk_div so that our pll_op_clk_freq_hz won't be ··· 614 614 more_mul_max); 615 615 /* Don't go above max pll op frequency. */ 616 616 more_mul_max = 617 - min_t(uint32_t, 617 + min_t(u32, 618 618 more_mul_max, 619 619 op_lim_fr->max_pll_op_clk_freq_hz 620 620 / (pll->ext_clk_freq_hz / ··· 706 706 struct ccs_pll_branch_fr *op_pll_fr; 707 707 struct ccs_pll_branch_bk *op_pll_bk; 708 708 bool cphy = pll->bus_type == CCS_PLL_BUS_TYPE_CSI2_CPHY; 709 - uint32_t phy_const = cphy ? CPHY_CONST : DPHY_CONST; 710 - uint32_t op_sys_clk_freq_hz_sdr; 711 - uint16_t min_op_pre_pll_clk_div; 712 - uint16_t max_op_pre_pll_clk_div; 713 - uint32_t mul, div; 714 - uint32_t l = (!pll->op_bits_per_lane || 715 - pll->op_bits_per_lane >= pll->bits_per_pixel) ? 1 : 2; 716 - uint32_t i; 709 + u32 phy_const = cphy ? CPHY_CONST : DPHY_CONST; 710 + u32 op_sys_clk_freq_hz_sdr; 711 + u16 min_op_pre_pll_clk_div; 712 + u16 max_op_pre_pll_clk_div; 713 + u32 mul, div; 714 + u32 l = (!pll->op_bits_per_lane || 715 + pll->op_bits_per_lane >= pll->bits_per_pixel) ? 1 : 2; 716 + u32 i; 717 717 int rval = -EINVAL; 718 718 719 719 if (!(pll->flags & CCS_PLL_FLAG_LANE_SPEED_MODEL)) { ··· 797 797 dev_dbg(dev, "min / max op_pre_pll_clk_div: %u / %u\n", 798 798 op_lim_fr->min_pre_pll_clk_div, op_lim_fr->max_pre_pll_clk_div); 799 799 max_op_pre_pll_clk_div = 800 - min_t(uint16_t, op_lim_fr->max_pre_pll_clk_div, 800 + min_t(u16, op_lim_fr->max_pre_pll_clk_div, 801 801 clk_div_even(pll->ext_clk_freq_hz / 802 802 op_lim_fr->min_pll_ip_clk_freq_hz)); 803 803 min_op_pre_pll_clk_div = 804 - max_t(uint16_t, op_lim_fr->min_pre_pll_clk_div, 804 + max_t(u16, op_lim_fr->min_pre_pll_clk_div, 805 805 clk_div_even_up( 806 806 DIV_ROUND_UP(pll->ext_clk_freq_hz, 807 807 op_lim_fr->max_pll_ip_clk_freq_hz))); ··· 815 815 dev_dbg(dev, "mul %u / div %u\n", mul, div); 816 816 817 817 min_op_pre_pll_clk_div = 818 - max_t(uint16_t, min_op_pre_pll_clk_div, 818 + max_t(u16, min_op_pre_pll_clk_div, 819 819 clk_div_even_up( 820 820 mul / 821 821 one_or_more(
+43 -43
drivers/media/i2c/ccs-pll.h
··· 44 44 * @pll_op_clk_freq_hz: PLL output clock frequency 45 45 */ 46 46 struct ccs_pll_branch_fr { 47 - uint16_t pre_pll_clk_div; 48 - uint16_t pll_multiplier; 49 - uint32_t pll_ip_clk_freq_hz; 50 - uint32_t pll_op_clk_freq_hz; 47 + u16 pre_pll_clk_div; 48 + u16 pll_multiplier; 49 + u32 pll_ip_clk_freq_hz; 50 + u32 pll_op_clk_freq_hz; 51 51 }; 52 52 53 53 /** ··· 61 61 * @pix_clk_freq_hz: Pixel clock frequency 62 62 */ 63 63 struct ccs_pll_branch_bk { 64 - uint16_t sys_clk_div; 65 - uint16_t pix_clk_div; 66 - uint32_t sys_clk_freq_hz; 67 - uint32_t pix_clk_freq_hz; 64 + u16 sys_clk_div; 65 + u16 pix_clk_div; 66 + u32 sys_clk_freq_hz; 67 + u32 pix_clk_freq_hz; 68 68 }; 69 69 70 70 /** ··· 97 97 */ 98 98 struct ccs_pll { 99 99 /* input values */ 100 - uint8_t bus_type; 101 - uint8_t op_lanes; 102 - uint8_t vt_lanes; 100 + u8 bus_type; 101 + u8 op_lanes; 102 + u8 vt_lanes; 103 103 struct { 104 - uint8_t lanes; 104 + u8 lanes; 105 105 } csi2; 106 - uint8_t binning_horizontal; 107 - uint8_t binning_vertical; 108 - uint8_t scale_m; 109 - uint8_t scale_n; 110 - uint8_t bits_per_pixel; 111 - uint8_t op_bits_per_lane; 112 - uint16_t flags; 113 - uint32_t link_freq; 114 - uint32_t ext_clk_freq_hz; 106 + u8 binning_horizontal; 107 + u8 binning_vertical; 108 + u8 scale_m; 109 + u8 scale_n; 110 + u8 bits_per_pixel; 111 + u8 op_bits_per_lane; 112 + u16 flags; 113 + u32 link_freq; 114 + u32 ext_clk_freq_hz; 115 115 116 116 /* output values */ 117 117 struct ccs_pll_branch_fr vt_fr; ··· 119 119 struct ccs_pll_branch_fr op_fr; 120 120 struct ccs_pll_branch_bk op_bk; 121 121 122 - uint32_t pixel_rate_csi; 123 - uint32_t pixel_rate_pixel_array; 122 + u32 pixel_rate_csi; 123 + u32 pixel_rate_pixel_array; 124 124 }; 125 125 126 126 /** ··· 136 136 * @max_pll_op_clk_freq_hz: Maximum PLL output clock frequency 137 137 */ 138 138 struct ccs_pll_branch_limits_fr { 139 - uint16_t min_pre_pll_clk_div; 140 - uint16_t max_pre_pll_clk_div; 141 - uint32_t min_pll_ip_clk_freq_hz; 142 - uint32_t max_pll_ip_clk_freq_hz; 143 - uint16_t min_pll_multiplier; 144 - uint16_t max_pll_multiplier; 145 - uint32_t min_pll_op_clk_freq_hz; 146 - uint32_t max_pll_op_clk_freq_hz; 139 + u16 min_pre_pll_clk_div; 140 + u16 max_pre_pll_clk_div; 141 + u32 min_pll_ip_clk_freq_hz; 142 + u32 max_pll_ip_clk_freq_hz; 143 + u16 min_pll_multiplier; 144 + u16 max_pll_multiplier; 145 + u32 min_pll_op_clk_freq_hz; 146 + u32 max_pll_op_clk_freq_hz; 147 147 }; 148 148 149 149 /** ··· 159 159 * @max_pix_clk_freq_hz: Maximum pixel clock frequency 160 160 */ 161 161 struct ccs_pll_branch_limits_bk { 162 - uint16_t min_sys_clk_div; 163 - uint16_t max_sys_clk_div; 164 - uint32_t min_sys_clk_freq_hz; 165 - uint32_t max_sys_clk_freq_hz; 166 - uint16_t min_pix_clk_div; 167 - uint16_t max_pix_clk_div; 168 - uint32_t min_pix_clk_freq_hz; 169 - uint32_t max_pix_clk_freq_hz; 162 + u16 min_sys_clk_div; 163 + u16 max_sys_clk_div; 164 + u32 min_sys_clk_freq_hz; 165 + u32 max_sys_clk_freq_hz; 166 + u16 min_pix_clk_div; 167 + u16 max_pix_clk_div; 168 + u32 min_pix_clk_freq_hz; 169 + u32 max_pix_clk_freq_hz; 170 170 }; 171 171 172 172 /** ··· 183 183 */ 184 184 struct ccs_pll_limits { 185 185 /* Strict PLL limits */ 186 - uint32_t min_ext_clk_freq_hz; 187 - uint32_t max_ext_clk_freq_hz; 186 + u32 min_ext_clk_freq_hz; 187 + u32 max_ext_clk_freq_hz; 188 188 189 189 struct ccs_pll_branch_limits_fr vt_fr; 190 190 struct ccs_pll_branch_limits_bk vt_bk; ··· 192 192 struct ccs_pll_branch_limits_bk op_bk; 193 193 194 194 /* Other relevant limits */ 195 - uint32_t min_line_length_pck_bin; 196 - uint32_t min_line_length_pck; 195 + u32 min_line_length_pck_bin; 196 + u32 min_line_length_pck; 197 197 }; 198 198 199 199 struct device;