[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <decfef92-d22a-a56e-6805-369a0eda07ad@mellanox.com>
Date: Wed, 12 Sep 2018 15:14:27 +0300
From: Tariq Toukan <tariqt@...lanox.com>
To: zhong jiang <zhongjiang@...wei.com>, davem@...emloft.net,
claudiu.manoil@....com, saeedm@...lanox.com,
derek.chickles@...iumnetworks.com
Cc: leon@...nel.org, jdmason@...zu.us, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: ethernet: Use DIV_ROUND_UP instead of reimplementing
its function
On 11/09/2018 4:08 PM, zhong jiang wrote:
> DIV_ROUND_UP has implemented the code-opened function. Therefore, just
> replace the implementation with DIV_ROUND_UP.
>
> Signed-off-by: zhong jiang <zhongjiang@...wei.com>
> ---
> drivers/net/ethernet/broadcom/sb1250-mac.c | 2 +-
> drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 2 +-
> drivers/net/ethernet/freescale/gianfar_ethtool.c | 2 +-
> drivers/net/ethernet/ibm/emac/mal.h | 2 +-
> drivers/net/ethernet/mellanox/mlx4/alloc.c | 2 +-
> drivers/net/ethernet/mellanox/mlx4/icm.c | 2 +-
> drivers/net/ethernet/mellanox/mlx5/core/srq.c | 2 +-
> drivers/net/ethernet/neterion/s2io.c | 2 +-
> 8 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/sb1250-mac.c b/drivers/net/ethernet/broadcom/sb1250-mac.c
> index ef4a0c3..1082529 100644
> --- a/drivers/net/ethernet/broadcom/sb1250-mac.c
> +++ b/drivers/net/ethernet/broadcom/sb1250-mac.c
> @@ -156,7 +156,7 @@ enum sbmac_state {
> (d)->sbdma_dscrtable : (d)->f+1)
>
>
> -#define NUMCACHEBLKS(x) (((x)+SMP_CACHE_BYTES-1)/SMP_CACHE_BYTES)
> +#define NUMCACHEBLKS(x) DIV_ROUND_UP(x, SMP_CACHE_BYTES)
>
> #define SBMAC_MAX_TXDESCR 256
> #define SBMAC_MAX_RXDESCR 256
> diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
> index a71dbb7..b57008d 100644
> --- a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
> +++ b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
> @@ -530,7 +530,7 @@ void octeon_droq_check_oom(struct octeon_droq *droq)
> static inline u32
> octeon_droq_get_bufcount(u32 buf_size, u32 total_len)
> {
> - return ((total_len + buf_size - 1) / buf_size);
> + return DIV_ROUND_UP(total_len, buf_size);
> }
>
> static int
> diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> index 395a526..b536eb0 100644
> --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> @@ -230,7 +230,7 @@ static unsigned int gfar_usecs2ticks(struct gfar_private *priv,
>
> /* Make sure we return a number greater than 0
> * if usecs > 0 */
> - return (usecs * 1000 + count - 1) / count;
> + return DIV_ROUND_UP(usecs * 1000, count);
> }
>
> /* Convert ethernet clock ticks to microseconds */
> diff --git a/drivers/net/ethernet/ibm/emac/mal.h b/drivers/net/ethernet/ibm/emac/mal.h
> index eeade2e..e4c20f0 100644
> --- a/drivers/net/ethernet/ibm/emac/mal.h
> +++ b/drivers/net/ethernet/ibm/emac/mal.h
> @@ -136,7 +136,7 @@ static inline int mal_rx_size(int len)
>
> static inline int mal_tx_chunks(int len)
> {
> - return (len + MAL_MAX_TX_SIZE - 1) / MAL_MAX_TX_SIZE;
> + return DIV_ROUND_UP(len, MAL_MAX_TX_SIZE);
> }
>
> #define MAL_CHAN_MASK(n) (0x80000000 >> (n))
> diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c
> index 4bdf250..deef5a9 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/alloc.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c
> @@ -614,7 +614,7 @@ int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct,
> int i;
>
> buf->direct.buf = NULL;
> - buf->nbufs = (size + PAGE_SIZE - 1) / PAGE_SIZE;
> + buf->nbufs = DIV_ROUND_UP(size, PAGE_SIZE);
> buf->npages = buf->nbufs;
> buf->page_shift = PAGE_SHIFT;
> buf->page_list = kcalloc(buf->nbufs, sizeof(*buf->page_list),
> diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c
> index 7262c63..4b43511 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/icm.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/icm.c
> @@ -406,7 +406,7 @@ int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table,
> obj_per_chunk = MLX4_TABLE_CHUNK_SIZE / obj_size;
> if (WARN_ON(!obj_per_chunk))
> return -EINVAL;
> - num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk;
> + num_icm = DIV_ROUND_UP(nobj, obj_per_chunk);
>
> table->icm = kvcalloc(num_icm, sizeof(*table->icm), GFP_KERNEL);
> if (!table->icm)
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/srq.c b/drivers/net/ethernet/mellanox/mlx5/core/srq.c
> index 23cc337..7e20666 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/srq.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/srq.c
> @@ -73,7 +73,7 @@ static int get_pas_size(struct mlx5_srq_attr *in)
> u32 rq_sz = 1 << (log_srq_size + 4 + log_rq_stride);
> u32 page_size = 1 << log_page_size;
> u32 rq_sz_po = rq_sz + (page_offset * po_quanta);
> - u32 rq_num_pas = (rq_sz_po + page_size - 1) / page_size;
> + u32 rq_num_pas = DIV_ROUND_UP(rq_sz_po, page_size);
>
> return rq_num_pas * sizeof(u64);
> }
> diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c
> index b8983e7..f980f10 100644
> --- a/drivers/net/ethernet/neterion/s2io.c
> +++ b/drivers/net/ethernet/neterion/s2io.c
> @@ -491,7 +491,7 @@ static void do_s2io_copy_mac_addr(struct s2io_nic *sp, int offset, u64 mac_addr)
> };
>
> /* A simplifier macro used both by init and free shared_mem Fns(). */
> -#define TXD_MEM_PAGE_CNT(len, per_each) ((len+per_each - 1) / per_each)
> +#define TXD_MEM_PAGE_CNT(len, per_each) DIV_ROUND_UP(len, per_each)
>
> /* netqueue manipulation helper functions */
> static inline void s2io_stop_all_tx_queue(struct s2io_nic *sp)
>
For the Mellanox parts:
Acked-by: Tariq Toukan <tariqt@...lanox.com>
Powered by blists - more mailing lists