All of lore.kernel.org
 help / color / mirror / Atom feed
From: miaofng <miaofng@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH]  add u-boot sja1000/can support
Date: Mon, 26 Oct 2009 13:39:25 +0800	[thread overview]
Message-ID: <200910261339124378155@gmail.com> (raw)

Hi Mike,

Thanks for your careful review. I'll resend the patch according to your remarks except below:
1)  
> +int register_candev(struct can_device *dev)
use "can" or "candev", dont mix the two

answer: register_candev is origin from register_netdev(...). CAN is something like network, it may has high level 
protocols such as open-can and etc, so i want to keep that story.

2) 
> +int sja1000_interrupt(struct can_device *dev)
u-boot is a polled architecture, not an interrupt based one.  i guess this 
driver needs rewriting to do that.

answer: no, i want to keep that structure. Then linux drivers can be ported to u-boot easily.
take an example, in sja1000, i only need to replace "_net" to "_can" at most of time. To gain this convience,
i added the wrap layer of can_core.c. In order to work in u-boot polled mode, people only need to call sja1000_interrupt periodly.
It works fine on my board.

On Saturday 24 October 2009 00:17:50 miaofng wrote:
> From 1f6aaba856fbf484c442eb33cf220774d57fba8d Mon Sep 17 00:00:00 2001
> From: miaofng <miaofng@gmail.com>
> Date: Fri, 23 Oct 2009 17:06:50 +0800
> Subject: [PATCH] [can] add u-boot sja1000/can support
this should be split into two patches -- one for the core CAN code and one for 
the sja1000-specific implementation.
it's also lacking documentation updates to the top level README or perhaps a 
standalone doc/README.can file
unconditionally calling can_init() is broken (in lib_arm/board.c).  can is 
like any other driver and can be enabled/disabled.  it needs a dedicated 
CONFIG_CAN option which would be leveraged in drviers/can/Makefile to add 
can_core.c to the build.
> --- /dev/null
> +++ b/drivers/can/can_core.c
> +#define can_debug printf
> +#define can_error printf
uhh, what ?  we already have debug() macros.  dont go creating your own brand 
new stuff.
> +#ifdef CONFIG_CMD_CAN
CONFIG_CMD_xxx is reserved for actual commands as in U_BOOT_CMD.  you arent 
implementing that, so this is wrong.  besides, it isnt needed once you use a 
proper CONFIG_CAN and add it to the top level Makefile.
> +void canif_rx(struct can_frame *cf, struct can_device *dev)
> +{
> + int len;
> +
> + //error frame?
C++ style comments are not allowed.  use normal C /* comments */.
> + if(cf->can_id&CAN_ERR_FLAG)
> + {
you need to read the style documentation.  u-boot code follows the linux 
kernel.  that means this should have been:
if (cf->can_id & CAN_ERR_FLAG) {
all of your code is horribly broken in these regards
> +int can_init(void)
> +{
> +#ifdef CONFIG_CMD_CAN
> + int index;
> + for(index = 0; index < CONFIG_CAN_DEV_MAX; index ++) can_devs[index] = 0;
use memset() like god intended.  then again, can_devs is declared static and 
in the .bss, so this init step is unnecessary.
> + board_can_init();
> +#endif
> + return 0;
> +}
these need to be weak's like all the other subsystems do it.  look at 
net/eth.c and how it does it:
- can_initialize()
- weak board_can_init()
- weak cpu_can_init()
> +int register_candev(struct can_device *dev)
use "can" or "candev", dont mix the two
> --- /dev/null
> +++ b/drivers/can/sja1000.c
> +//MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
> +//MODULE_LICENSE("Dual BSD/GPL");
> +//MODULE_DESCRIPTION(DRV_NAME "CAN netdevice driver");
dont leave crap behind -- delete it
> +int sja1000_interrupt(struct can_device *dev)
u-boot is a polled architecture, not an interrupt based one.  i guess this 
driver needs rewriting to do that.
> +int register_sja1000dev(struct can_device *dev)
can drivers should have a standard naming convention.  perhaps something like:
can_<driver>_register()
> +void unregister_sja1000dev(struct can_device *dev)
> +{
> + set_reset_mode(dev);
> + unregister_candev(dev);
> +}
do we really need an unregister framework ?  none of the other subsystems do 
and it hasnt been a problem.
> --- /dev/null
> +++ b/include/candev.h
> @@ -0,0 +1,46 @@
> +/*
> + * (C) Copyright 2009 miaofng<miaofng@gmail.com>
> + *
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * 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.
> + *
> + * 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.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +/*
> + * netdev.h - definitions an prototypes for network devices
> + */
> +
> +#ifndef _CANDEV_H_
> +#define _CANDEV_H_
clearly you've been copying & pasting code from the Linux kernel, yet you've 
been stripping out people's copyrights.  that wont fly.
-mike

             reply	other threads:[~2009-10-26  5:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-26  5:39 miaofng [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-10-24  4:17 [U-Boot] [PATCH] add u-boot sja1000/can support miaofng
2009-10-24  6:35 ` Mike Frysinger
     [not found] ` <200910261248270312273@gmail.com>
2009-10-26  7:02   ` Mike Frysinger
     [not found]   ` <200910261629132341038@gmail.com>
2009-10-26  8:41     ` Mike Frysinger
2009-10-26 13:01       ` miaofng
2009-10-26  8:18 ` Matthias Fuchs
2009-10-26 12:14 ` Wolfgang Grandegger
2009-10-26 21:56 ` Wolfgang Denk

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=200910261339124378155@gmail.com \
    --to=miaofng@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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.