On Tue, Sep 8, 2015 at 1:47 PM, Vivien Didelot
<vivien.dide...@savoirfairelinux.com> wrote:
> Move the switchdev_obj_vlan structure out of the switchdev_obj union.
>
> This lightens the switchdev_obj structure and allows drivers to access
> the object transaction and callback directly from a switchdev_obj_vlan.
> This is more consistent and convenient for add and dump operations.
>
> The patch updates bridge, the Rocker driver and DSA accordingly.
>
> Signed-off-by: Vivien Didelot <vivien.dide...@savoirfairelinux.com>
> ---

[cut]

> diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
> index 16c1c43..9923a97 100644
> --- a/net/switchdev/switchdev.c
> +++ b/net/switchdev/switchdev.c
> @@ -397,7 +397,7 @@ int call_switchdev_notifiers(unsigned long val, struct 
> net_device *dev,
>  EXPORT_SYMBOL_GPL(call_switchdev_notifiers);
>
>  struct switchdev_vlan_dump {
> -       struct switchdev_obj obj;
> +       struct switchdev_obj_vlan vlan; /* must be first */
>         struct sk_buff *skb;
>         u32 filter_mask;
>         u16 flags;
> @@ -439,9 +439,8 @@ static int switchdev_port_vlan_dump_put(struct net_device 
> *dev,
>  static int switchdev_port_vlan_dump_cb(struct net_device *dev,
>                                        struct switchdev_obj *obj)
>  {
> -       struct switchdev_vlan_dump *dump =
> -               container_of(obj, struct switchdev_vlan_dump, obj);
> -       struct switchdev_obj_vlan *vlan = &dump->obj.u.vlan;
> +       struct switchdev_vlan_dump *dump = (struct switchdev_vlan_dump *) obj;
> +       struct switchdev_obj_vlan *vlan = (struct switchdev_obj_vlan *) obj;

Same comment as Andrew's: use container_of() rather than casting for
both of the use-cases above.  (And don't require inner-structure to be
fist in outer structure).
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to