Re: [RFC PATCH v2 net-next 6/8] net: mscc: ocelot: expose ocelot wm functions

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

 



On Sat, Jul 10, 2021 at 12:26:00PM -0700, Colin Foster wrote:
> diff --git a/drivers/net/ethernet/mscc/ocelot_wm.c b/drivers/net/ethernet/mscc/ocelot_wm.c
> new file mode 100644
> index 000000000000..f9a11a6a059d
> --- /dev/null
> +++ b/drivers/net/ethernet/mscc/ocelot_wm.c
> @@ -0,0 +1,40 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +/*
> + * Microsemi Ocelot Switch driver
> + *
> + * Copyright (c) 2017 Microsemi Corporation
> + */
> +
> +#include "ocelot.h"
> +
> +/* Watermark encode
> + * Bit 8:   Unit; 0:1, 1:16
> + * Bit 7-0: Value to be multiplied with unit
> + */
> +u16 ocelot_wm_enc(u16 value)
> +{
> +	WARN_ON(value >= 16 * BIT(8));
> +
> +	if (value >= BIT(8))
> +		return BIT(8) | (value / 16);
> +
> +	return value;
> +}
> +EXPORT_SYMBOL(ocelot_wm_enc);
> +
> +u16 ocelot_wm_dec(u16 wm)
> +{
> +	if (wm & BIT(8))
> +		return (wm & GENMASK(7, 0)) * 16;
> +
> +	return wm;
> +}
> +EXPORT_SYMBOL(ocelot_wm_dec);
> +
> +void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse)
> +{
> +	*inuse = (val & GENMASK(23, 12)) >> 12;
> +	*maxuse = val & GENMASK(11, 0);
> +}
> +EXPORT_SYMBOL(ocelot_wm_stat);
> +

Do not use blank lines at the end of files, 'git am' will complain that
the patches are whitespace damaged.



[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