Re: [RFC net-next v1 2/2] net: dsa: microchip: ksz9477: Add drive strength configuration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux