lkml.org 
[lkml]   [2023]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC net-next v1 2/2] net: dsa: microchip: ksz9477: Add drive strength configuration
> +static const struct ksz9477_drive_strength ksz9477_drive_strengths[] = {
> + { SW_DRIVE_STRENGTH_2MA, 2000 },
> + { SW_DRIVE_STRENGTH_4MA, 4000 },
> + { SW_DRIVE_STRENGTH_8MA, 8000 },
> + { SW_DRIVE_STRENGTH_12MA, 12000 },
> + { SW_DRIVE_STRENGTH_16MA, 16000 },
> + { SW_DRIVE_STRENGTH_20MA, 20000 },
> + { SW_DRIVE_STRENGTH_24MA, 24000 },
> + { SW_DRIVE_STRENGTH_28MA, 28000 },

These SW_DRIVE_STRENGTH_ values appear in both ksz8795_reg.h and
ksz9477_reg.h. Can the code be made common?

> +static u32 ksz9477_drive_strength_to_reg(u32 milliamp)
> +{
> + size_t array_size = ARRAY_SIZE(ksz9477_drive_strengths);
> + int i;
> +
> + for (i = 0; i < array_size; i++) {
> + if (ksz9477_drive_strengths[i].milliamp >= milliamp)
> + return ksz9477_drive_strengths[i].reg_val;

Normally an exact match is used, not the nearest value.


Andrew

---
pw-bot: cr

\
 
 \ /
  Last update: 2023-09-05 18:20    [W:0.040 / U:1.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site