Messages in this thread Patch in this message | | | Date | Fri, 3 Feb 2006 14:40:27 -0800 | From | Greg KH <> | Subject | Re: [RFC] Controller Area Network (CAN) infrastructure |
| |
On Tue, Jan 24, 2006 at 11:45:56AM +0000, David Vrabel wrote: > --- /dev/null 1970-01-01 00:00:00.000000000 +0000 > +++ linux-2.6-working/drivers/can/can.c 2006-01-24 11:17:36.000000000 +0000 > @@ -0,0 +1,148 @@ > +/* > + * Controller Area Network (CAN) infrastructure. > + * > + * Copyright (C) 2006 Arcom Control Systems Ltd. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + */ > +#include <linux/types.h> > +#include <linux/init.h> > +#include <linux/kernel.h> > +#include <linux/module.h> > +#include <linux/device.h> > +#include <linux/netdevice.h> > +#include <linux/can/can.h> > + > + > +ssize_t can_bit_rate_show(struct class_device *cdev, char *buf) > +{ > + struct can_device *can = to_can_device(cdev); > + return sprintf(buf, "%d\n", can->get_bit_rate(can)); > +} > + > +ssize_t can_bit_rate_store(struct class_device *cdev, const char *buf, size_t count) > +{ > + struct can_device *can = to_can_device(cdev); > + int bit_rate; > + > + if (netif_running(&can->ndev)) > + return -EBUSY; > + > + bit_rate = simple_strtoul(buf, NULL, 0); > + can->set_bit_rate(can, bit_rate); > + > + return count; > +} > + > +CLASS_DEVICE_ATTR(bit_rate, 0644, can_bit_rate_show, can_bit_rate_store); > + > + > +static struct net_device_stats *can_get_stats(struct net_device *netdev) > +{ > + struct can_device *can = netdev->priv; > + > + return &can->stats; > +} > + > +static void can_device_release(struct class_device *cdev) > +{ > + struct can_device *can = to_can_device(cdev); > + > + class_device_remove_file(&can->cdev, &class_device_attr_bit_rate); > + > + unregister_netdev(&can->ndev); > + > + kfree(can); > +} > + > +static struct class can_device_class = { > + .name = "can", > + .owner = THIS_MODULE, > + .release = can_device_release, > +}; Can you use class_create() instead of making a static structure? It will make it easier for future driver core work.
thanks,
greg k-h - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |