Re: [PATCH 13/21] can: introduce CAN midlayer private and allocate it automatically

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

 



On 9/4/19 6:15 AM, Oliver Hartkopp wrote:
> 
> On 28/08/2019 08.52, Marc Kleine-Budde wrote:
>> This patch introduces the CAN midlayer private structure ("struct
>> can_ml_priv") which should be used to hold protocol specific per device
>> data structures. For now it's only member is "struct can_dev_rcv_lists".
> 
>> diff --git a/include/linux/can/can-ml.h b/include/linux/can/can-ml.h
>> new file mode 100644
>> index 000000000000..2786b04251ea
>> --- /dev/null
>> +++ b/include/linux/can/can-ml.h
>> @@ -0,0 +1,23 @@
> 
> Dual license (GPLv2 / BSD) SPDX identifier missing here
> /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */

I've copied the header from af_can.h.

> 
>> +/*
>> + * Copyright (C) 2017 Pengutronix, Marc Kleine-Budde <kernel@xxxxxxxxxxxxxx>
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public License
>> + * version 2, as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + */
>> +#ifndef CAN_ML_H
>> +#define CAN_ML_H
>> +
>> +#include "../../net/can/af_can.h"
> 
> Arg!
> 
> Move
> 
> /* per device receive filters linked at dev->ml_priv */
> struct can_dev_rcv_lists {
> 	struct hlist_head rx[RX_MAX];
> 	struct hlist_head rx_sff[CAN_SFF_RCV_ARRAY_SZ];
> 	struct hlist_head rx_eff[CAN_EFF_RCV_ARRAY_SZ];
> 	int entries;
> };
> 
> from af_can.h here.

done
> I always tried to separate the CAN network layer from the CAN driver 
> stuff. But this "deep include" smells fishy.
> 
> I applied these changes on my tree (on top of all your patches):

Squashed into patch 13.

> diff --git a/include/linux/can/can-ml.h b/include/linux/can/can-ml.h
> index 9861946fe4ae..6bda2efcd570 100644
> --- a/include/linux/can/can-ml.h
> +++ b/include/linux/can/can-ml.h
> @@ -14,7 +14,22 @@
>   #ifndef CAN_ML_H
>   #define CAN_ML_H
> 
> -#include "../../net/can/af_can.h"
> +#include <linux/can.h>
> +#include <linux/list.h>
> +
> +#define CAN_SFF_RCV_ARRAY_SZ (1 << CAN_SFF_ID_BITS)
> +#define CAN_EFF_RCV_HASH_BITS 10
> +#define CAN_EFF_RCV_ARRAY_SZ (1 << CAN_EFF_RCV_HASH_BITS)
> +
> +enum { RX_ERR, RX_ALL, RX_FIL, RX_INV, RX_MAX };
> +
> +/* per device receive filters linked at dev->ml_priv */
> +struct can_dev_rcv_lists {
> +	struct hlist_head rx[RX_MAX];
> +	struct hlist_head rx_sff[CAN_SFF_RCV_ARRAY_SZ];
> +	struct hlist_head rx_eff[CAN_EFF_RCV_ARRAY_SZ];
> +	int entries;
> +};
> 
>   struct can_ml_priv {
>   	struct can_dev_rcv_lists dev_rcv_lists;
> diff --git a/net/can/af_can.h b/net/can/af_can.h
> index 56a31a99bc6e..7c2d9161e224 100644
> --- a/net/can/af_can.h
> +++ b/net/can/af_can.h
> @@ -60,20 +60,6 @@ struct receiver {
>   	struct rcu_head rcu;
>   };
> 
> -#define CAN_SFF_RCV_ARRAY_SZ (1 << CAN_SFF_ID_BITS)
> -#define CAN_EFF_RCV_HASH_BITS 10
> -#define CAN_EFF_RCV_ARRAY_SZ (1 << CAN_EFF_RCV_HASH_BITS)
> -
> -enum { RX_ERR, RX_ALL, RX_FIL, RX_INV, RX_MAX };
> -
> -/* per device receive filters linked at dev->ml_priv */
> -struct can_dev_rcv_lists {
> -	struct hlist_head rx[RX_MAX];
> -	struct hlist_head rx_sff[CAN_SFF_RCV_ARRAY_SZ];
> -	struct hlist_head rx_eff[CAN_EFF_RCV_ARRAY_SZ];
> -	int entries;
> -};
> -
>   /* statistic structures */
> 
>   /* can be reset e.g. by can_init_stats() */
> diff --git a/net/can/proc.c b/net/can/proc.c
> index 560fa3c132bf..d3697105daec 100644
> --- a/net/can/proc.c
> +++ b/net/can/proc.c
> @@ -46,6 +46,7 @@
>   #include <linux/rcupdate.h>
>   #include <linux/if_arp.h>
>   #include <linux/can/core.h>
> +#include <linux/can/can-ml.h>
> 
>   #include "af_can.h"
> 
> 
> Signed-off-by: Oliver Hartkopp <socketcan@xxxxxxxxxxxx> attribution is 
> welcome in can-ml.h

added

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux