From: Sascha Hauer <s.hauer@pengutronix.de>
To: Wolfgang Grandegger <wg@grandegger.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Marc Kleine-Budde <mkl@pengutronix.de>,
Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
Subject: Re: [PATCH v2 5/7] [PATCH 5/8] can: SJA1000 generic platform bus driver
Date: Fri, 15 May 2009 14:07:12 +0200 [thread overview]
Message-ID: <20090515120711.GE26519@pengutronix.de> (raw)
In-Reply-To: <4A0D374A.8080006@grandegger.com>
On Fri, May 15, 2009 at 11:35:06AM +0200, Wolfgang Grandegger wrote:
> Hi Sascha,
>
> Sascha Hauer wrote:
> > Hi Wolfgang,
> >
> > some comments inline.
> >
> > Sascha
> >
> > On Tue, May 12, 2009 at 11:28:02AM +0200, Wolfgang Grandegger wrote:
> >> This driver adds support for the SJA1000 chips connected to the
> >> "platform bus", which can be found on various embedded systems.
> >>
> >> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> >> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
> >> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> >> Signed-off-by: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
> >> ---
> >> drivers/net/can/Kconfig | 10 +
> >> drivers/net/can/sja1000/Makefile | 1
> >> drivers/net/can/sja1000/sja1000_platform.c | 169 +++++++++++++++++++++++++++++
> >> include/linux/can/platform/sja1000.h | 32 +++++
> >> 4 files changed, 212 insertions(+)
> >> create mode 100644 drivers/net/can/sja1000/sja1000_platform.c
> >> create mode 100644 include/linux/can/platform/sja1000.h
> >>
> >> Index: net-next-2.6/drivers/net/can/Kconfig
> >> ===================================================================
> >> --- net-next-2.6.orig/drivers/net/can/Kconfig 2009-05-12 10:47:25.747720647 +0200
> >> +++ net-next-2.6/drivers/net/can/Kconfig 2009-05-12 10:47:26.411720627 +0200
> >> @@ -41,6 +41,16 @@
> >> ---help---
> >> Driver for the SJA1000 CAN controllers from Philips or NXP
> >>
> >> +config CAN_SJA1000_PLATFORM
> >> + depends on CAN_SJA1000
> >> + tristate "Generic Platform Bus based SJA1000 driver"
> >> + ---help---
> >> + This driver adds support for the SJA1000 chips connected to
> >> + the "platform bus" (Linux abstraction for directly to the
> >> + processor attached devices). Which can be found on various
> >> + boards from Phytec (http://www.phytec.de) like the PCM027,
> >> + PCM038.
> >> +
> >> config CAN_DEBUG_DEVICES
> >> bool "CAN devices debugging messages"
> >> depends on CAN
> >> Index: net-next-2.6/drivers/net/can/sja1000/Makefile
> >> ===================================================================
> >> --- net-next-2.6.orig/drivers/net/can/sja1000/Makefile 2009-05-12 10:47:25.753720385 +0200
> >> +++ net-next-2.6/drivers/net/can/sja1000/Makefile 2009-05-12 10:47:26.412720490 +0200
> >> @@ -3,5 +3,6 @@
> >> #
> >>
> >> obj-$(CONFIG_CAN_SJA1000) += sja1000.o
> >> +obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
> >>
> >> ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
> >> Index: net-next-2.6/drivers/net/can/sja1000/sja1000_platform.c
> >> ===================================================================
> >> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> >> +++ net-next-2.6/drivers/net/can/sja1000/sja1000_platform.c 2009-05-12 10:47:26.416720502 +0200
> >> @@ -0,0 +1,169 @@
> >> +/*
> >> + * Copyright (C) 2005 Sascha Hauer, Pengutronix
> >> + * Copyright (C) 2007 Wolfgang Grandegger <wg@grandegger.com>
> >> + *
> >> + * This program is free software; you can redistribute it and/or modify
> >> + * it under the terms of the version 2 of the GNU General Public License
> >> + * 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.
> >> + *
> >> + * 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
> >> + */
> >> +
> >> +#include <linux/kernel.h>
> >> +#include <linux/module.h>
> >> +#include <linux/interrupt.h>
> >> +#include <linux/netdevice.h>
> >> +#include <linux/delay.h>
> >> +#include <linux/pci.h>
> >> +#include <linux/platform_device.h>
> >> +#include <linux/irq.h>
> >> +#include <linux/can.h>
> >> +#include <linux/can/dev.h>
> >> +#include <linux/can/platform/sja1000.h>
> >> +#include <linux/io.h>
> >> +
> >> +#include "sja1000.h"
> >> +
> >> +#define DRV_NAME "sja1000_platform"
> >> +
> >> +MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
> >> +MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
> >> +MODULE_LICENSE("GPL v2");
> >> +
> >> +static u8 sp_read_reg(const struct net_device *dev, int reg)
> >> +{
> >> + return ioread8((void __iomem *)(dev->base_addr + reg));
> >> +}
> >> +
> >> +static void sp_write_reg(const struct net_device *dev, int reg, u8 val)
> >> +{
> >> + iowrite8(val, (void __iomem *)(dev->base_addr + reg));
> >> +}
> >> +
> >> +static int sp_probe(struct platform_device *pdev)
> >> +{
> >> + int err, irq;
> >> + void __iomem *addr;
> >> + struct net_device *dev;
> >> + struct sja1000_priv *priv;
> >> + struct resource *res_mem, *res_irq;
> >> + struct sja1000_platform_data *pdata;
> >> +
> >> + pdata = pdev->dev.platform_data;
> >> + if (!pdata) {
> >> + dev_err(&pdev->dev, "No platform data provided!\n");
> >> + err = -ENODEV;
> >> + goto exit;
> >> + }
> >> +
> >> + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> + res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> >> + if (!res_mem || !res_irq) {
> >> + err = -ENODEV;
> >> + goto exit;
> >> + }
> >> +
> >> + if (!request_mem_region(res_mem->start,
> >> + res_mem->end - res_mem->start + 1,
> >> + DRV_NAME)) {
> >
> > resource_size(res_mem) please, also for the other occurrences in this
> > file
>
> OK.
>
> >> + err = -EBUSY;
> >> + goto exit;
> >> + }
> >> +
> >> + addr = ioremap_nocache(res_mem->start,
> >> + res_mem->end - res_mem->start + 1);
> >> + if (!addr) {
> >> + err = -ENOMEM;
> >> + goto exit_release;
> >> + }
> >> +
> >> + irq = res_irq->start;
> >> + if (res_irq->flags & IRQF_TRIGGER_MASK)
> >> + set_irq_type(irq, res_irq->flags & IRQF_TRIGGER_MASK);
> >
> > You shouldn't use set_irq_type on not yet requested irqs but instead
> > pass the flags to the real driver and pass them in request_irq.
>
> Why? I would require an extra member in the struct sja1000_priv.
You change a resource you do not own. What if request_irq returns with
-EBUSY? You already screwed up any other potential user.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2009-05-15 12:07 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-12 9:27 [PATCH v2 0/7] can: CAN network device driver interface and drivers Wolfgang Grandegger
2009-05-12 9:27 ` [PATCH v2 1/7] [PATCH 1/8] can: Documentation for the CAN device driver interface Wolfgang Grandegger
2009-05-12 9:27 ` [PATCH v2 2/7] [PATCH 2/8] can: Update MAINTAINERS and CREDITS file Wolfgang Grandegger
2009-05-12 9:28 ` [PATCH v2 3/7] [PATCH 3/8] can: CAN Network device driver and Netlink interface Wolfgang Grandegger
2009-05-13 6:30 ` Andrew Morton
2009-05-13 6:53 ` Andrew Morton
2009-05-13 11:37 ` Wolfgang Grandegger
2009-05-13 15:57 ` Andrew Morton
2009-05-14 9:51 ` Wolfgang Grandegger
2009-05-13 10:02 ` Oliver Hartkopp
2009-05-13 11:39 ` Wolfgang Grandegger
2009-05-13 12:08 ` Oliver Hartkopp
2009-05-13 12:23 ` Wolfgang Grandegger
2009-05-15 7:15 ` Oliver Hartkopp
2009-05-15 7:46 ` Wolfgang Grandegger
2009-05-13 21:31 ` Jonathan Corbet
2009-05-14 7:55 ` Wolfgang Grandegger
2009-05-12 9:28 ` [PATCH v2 4/7] [PATCH 4/8] can: Driver for the SJA1000 CAN controller Wolfgang Grandegger
2009-05-13 21:52 ` Jonathan Corbet
2009-05-14 9:03 ` Wolfgang Grandegger
2009-05-15 20:39 ` Jonathan Corbet
2009-05-15 21:24 ` Wolfgang Grandegger
2009-05-16 6:57 ` Wolfgang Grandegger
2009-05-20 21:31 ` Jonathan Corbet
2009-05-12 9:28 ` [PATCH v2 5/7] [PATCH 5/8] can: SJA1000 generic platform bus driver Wolfgang Grandegger
2009-05-13 22:02 ` Jonathan Corbet
2009-05-15 9:33 ` Wolfgang Grandegger
2009-05-14 6:46 ` Sascha Hauer
2009-05-15 9:35 ` Wolfgang Grandegger
2009-05-15 12:07 ` Sascha Hauer [this message]
2009-05-15 13:12 ` Wolfgang Grandegger
2009-05-12 9:28 ` [PATCH v2 6/7] [PATCH 6/8] can: SJA1000 driver for EMS PCI cards Wolfgang Grandegger
2009-05-12 9:28 ` [PATCH v2 7/7] [PATCH 7/8] can: SJA1000 driver for Kvaser " Wolfgang Grandegger
2009-05-13 22:20 ` Jonathan Corbet
2009-05-15 8:54 ` Wolfgang Grandegger
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=20090515120711.GE26519@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=oliver.hartkopp@volkswagen.de \
--cc=wg@grandegger.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).