All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: David Vrabel <dvrabel@arcom.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Controller Area Network (CAN) infrastructure
Date: Fri, 3 Feb 2006 14:40:27 -0800	[thread overview]
Message-ID: <20060203224027.GA22510@kroah.com> (raw)
In-Reply-To: <43D61374.8010208@arcom.com>

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

      parent reply	other threads:[~2006-02-03 22:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-24 11:45 [RFC] Controller Area Network (CAN) infrastructure David Vrabel
2006-01-24 12:08 ` MC251x CAN controller driver example David Vrabel
2006-01-24 19:39 ` [RFC] Controller Area Network (CAN) infrastructure Stephen Hemminger
2006-02-03 22:40 ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060203224027.GA22510@kroah.com \
    --to=greg@kroah.com \
    --cc=dvrabel@arcom.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.