Malta/SEAD3 kernel image size patches for 3.18
Subsystems (3)
cover Malta/SEAD3 kernel image size patches for 3.18
Hi,
A few patches to reduce the size of the kernel image for Malta and SEAD3 by improving the dependencies on certain source files.
A different approach for i2c and led patches has been posted before:
http://patchwork.linux-mips.org/patch/5802/
Even though none of the original requests have been addressed, I still feel these patches do not make things any worse.
Hopefully not too late for 3.18
Markos Chandras (3):
MIPS: Malta: Do not build the malta-amon.c file if CMP is not enabled
MIPS: sead3: Build the I2C related devices if CONFIG_I2C is enabled
MIPS: sead3: Only build the led driver is LEDS_CLASS is enabled
arch/mips/mti-malta/Makefile | 3 ++- arch/mips/mti-sead3/Makefile | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.1.2
PATCH 1/3 MIPS: Malta: Do not build the malta-amon.c file if CMP is not enabled
The malta-amon.c file provides functions to access the YAMON Monitoring interface to bring up secondary VPEs in case of SMP/CMP. As a result of which, there is no need to build it if CMP is not used.
--- arch/mips/mti-malta/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/mti-malta/Makefile +2 -1
@@ -5,8 +5,9 @@ # Copyright (C) 2008 Wind River Systems, Inc. # written by Ralf Baechle <[email protected]> # -obj-y := malta-amon.o malta-display.o malta-init.o \ +obj-y := malta-display.o malta-init.o \ malta-int.o malta-memory.o malta-platform.o \ malta-reset.o malta-setup.o malta-time.o +obj-$(CONFIG_MIPS_CMP) += malta-amon.o obj-$(CONFIG_MIPS_MALTA_PM) += malta-pm.o
Signature · 1 line
2.1.2
PATCH 2/3 MIPS: sead3: Build the I2C related devices if CONFIG_I2C is enabled
In reply to Markos ChandrasThere is no point building the drivers for the i2c related devices if CONFIG_I2C is not enabled.
This also fixes a randconfig problem:
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_probe':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:345:2: error: implicit declaration of function 'i2c_add_numbered_adapter' [-Werror=implicit-function-declaration]
ret = i2c_add_numbered_adapter(&priv->adap);
^arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_remove':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:361:2: error: implicit declaration of function 'i2c_del_adapter' [-Werror=implicit-function-declaration] i2c_del_adapter(&priv->adap);
--- arch/mips/mti-sead3/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/mti-sead3/Makefile +3 -3
@@ -13,11 +13,11 @@ obj-y := sead3-lcd.o sead3-display.o sead3-init.o \ sead3-platform.o sead3-reset.o \ sead3-setup.o sead3-time.o -obj-y += sead3-i2c-dev.o sead3-i2c.o \ - sead3-pic32-i2c-drv.o sead3-pic32-bus.o \ - leds-sead3.o sead3-leds.o +obj-y += leds-sead3.o sead3-leds.o obj-$(CONFIG_EARLY_PRINTK) += sead3-console.o +obj-$(CONFIG_I2C) += sead3-i2c.o sead3-i2c-dev.o \ + sead3-pic32-bus.o lsead3-pic32-i2c-drv.o obj-$(CONFIG_USB_EHCI_HCD) += sead3-ehci.o obj-$(CONFIG_OF) += sead3.dtb.o
Signature · 1 line
2.1.2
Re: [PATCH 2/3] MIPS: sead3: Build the I2C related devices if CONFIG_I2C is enabled
Quoted 8 lines · Markos Chandras
There is no point building the drivers for the i2c related devices if
CONFIG_I2Cis not enabled.This also fixes a randconfig problem:
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_probe':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:345:2: error: implicit declaration of function 'i2c_add_numbered_adapter' [-Werror=implicit-function-declaration]
Quoted 7 lines
ret = i2c_add_numbered_adapter(&priv->adap); ^
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_remove':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:361:2: error: implicit declaration of function 'i2c_del_adapter' [-Werror=implicit-function-declaration]i2c_del_adapter(&priv->adap);
The platform devices should always be registered.
And why on earth is there an I2C drivers in arch? That should rather go to drivers/i2c/busses/.
Ralf
Re: [PATCH 2/3] MIPS: sead3: Build the I2C related devices if CONFIG_I2C is enabled
Quoted 16 lines · Ralf Baechle
Quoted 8 lines
There is no point building the drivers for the i2c related devices if
CONFIG_I2Cis not enabled.This also fixes a randconfig problem:
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_probe':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:345:2: error: implicit declaration of function 'i2c_add_numbered_adapter' [-Werror=implicit-function-declaration]Quoted 7 lines
ret = i2c_add_numbered_adapter(&priv->adap); ^
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_remove':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:361:2: error: implicit declaration of function 'i2c_del_adapter' [-Werror=implicit-function-declaration]i2c_del_adapter(&priv->adap);
Quoted 4 lines
The platform devices should always be registered.
And why on earth is there an I2C drivers in arch? That should rather go to
drivers/i2c/busses/.
It's even worse. arch/mips/mti-sead3/sead3-pic32-i2c-drv.c registers a driver - but nothing registers a platform device for it. And nobody's apparently missing a functioning driver. Nuke?
Ralf
PATCH 1/1 MIPS: SEAD3: Nuke unused sead3-pic32-i2c-drv.
A platform driver for which nothing ever registers the corresponding platform device.
This also fixes a randconfig problem:
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_probe':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:345:2: error: implicit declaration of function 'i2c_add_numbered_adapter' [-Werror=implicit-function-declaration]
ret = i2c_add_numbered_adapter(&priv->adap);
^arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_remove':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:361:2: error: implicit declaration of function 'i2c_del_adapter' [-Werror=implicit-function-declaration] i2c_del_adapter(&priv->adap);
arch/mips/mti-sead3/Makefile +1 -2
@@ -14,8 +14,7 @@ obj-y := sead3-lcd.o sead3-display.o sead3-init.o \ sead3-setup.o sead3-time.o obj-y += sead3-i2c-dev.o sead3-i2c.o \ - sead3-pic32-i2c-drv.o sead3-pic32-bus.o \ - leds-sead3.o sead3-leds.o + sead3-pic32-bus.o leds-sead3.o sead3-leds.o obj-$(CONFIG_EARLY_PRINTK) += sead3-console.o obj-$(CONFIG_USB_EHCI_HCD) += sead3-ehci.o
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c deleted +0 -423
423 lines not on this page · raw message
A message that is not in the archive (sent off-list or not yet received): 20141023181925.GA6719-6z/[email protected]
PATCH 1/1 MIPS/I2C: Move SEAD3 I2C driver to where it belongs.
Fixes the following build problem if CONFIG_I2C is disabled:
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_probe':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:345:2: error: implicit declaration of function 'i2c_add_numbered_adapter' [-Werror=implicit-function-declaration]
ret = i2c_add_numbered_adapter(&priv->adap);
^arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_remove':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:361:2: error: implicit declaration of function 'i2c_del_adapter' [-Werror=implicit-function-declaration] i2c_del_adapter(&priv->adap);
arch/mips/mti-sead3/sead3-i2c-drv.c deleted +0 -405
@@ -1,405 +0,0 @@ -/* -* This file is subject to the terms and conditions of the GNU General Public -* License. See the file "COPYING" in the main directory of this archive -* for more details. -* -* Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. -*/ -#include <linux/init.h> -#include <linux/module.h> -#include <linux/slab.h> -#include <linux/delay.h> -#include <linux/i2c.h> -#include <linux/platform_device.h> - -#define PIC32_I2CxCON 0x0000 -#define PIC32_I2CCON_ON (1<<15) -#define PIC32_I2CCON_ACKDT (1<<5) -#define PIC32_I2CCON_ACKEN (1<<4) -#define PIC32_I2CCON_RCEN (1<<3) -#define PIC32_I2CCON_PEN (1<<2) -#define PIC32_I2CCON_RSEN (1<<1) -#define PIC32_I2CCON_SEN (1<<0) -#define PIC32_I2CxCONCLR 0x0004 -#define PIC32_I2CxCONSET 0x0008 -#define PIC32_I2CxSTAT 0x0010 -#define PIC32_I2CxSTATCLR 0x0014 -#define PIC32_I2CSTAT_ACKSTAT (1<<15) -#define PIC32_I2CSTAT_TRSTAT (1<<14) -#define PIC32_I2CSTAT_BCL (1<<10) -#define PIC32_I2CSTAT_IWCOL (1<<7) -#define PIC32_I2CSTAT_I2COV (1<<6) -#define PIC32_I2CxBRG 0x0040 -#define PIC32_I2CxTRN 0x0050 -#define PIC32_I2CxRCV 0x0060 - -static DEFINE_SPINLOCK (pic32_bus_lock); - -static void __iomem *bus_xfer = (void __iomem *)0xbf000600 ; -static void __iomem *bus_status = (void __iomem *)0xbf000060 ; - -#define DELAY () udelay(100) - -static inline unsigned int ioready (void ) -{ -return readl (bus_status) &1 ; -} - -static inline void wait_ioready (void ) -{ -do { }while (!ioready ()); -} - -static inline void wait_ioclear (void ) -{ -do { }while (ioready ()); -} - -static inline void check_ioclear (void ) -{ -if (ioready ()) { -do { - (void )readl (bus_xfer); -DELAY (); - }while (ioready ()); - } -} - -static u32 pic32_bus_readl (u32 reg) -{ -unsigned long flags; -u32 status, val; - -spin_lock_irqsave (&pic32_bus_lock, flags); - -check_ioclear (); -writel ((0x01 <<24 ) | (reg &0x00ffffff ), bus_xfer); -DELAY (); -wait_ioready (); - status =readl (bus_xfer); -DELAY (); - val =readl (bus_xfer); -wait_ioclear (); - -spin_unlock_irqrestore (&pic32_bus_lock, flags); - -return val; -} - -static void pic32_bus_writel (u32 val,u32 reg) -{ -unsigned long flags; -u32 status; - -spin_lock_irqsave (&pic32_bus_lock, flags); - -check_ioclear (); -writel ((0x10 <<24 ) | (reg &0x00ffffff ), bus_xfer); -DELAY (); -writel (val, bus_xfer); -DELAY (); -wait_ioready (); - status =readl (bus_xfer); -wait_ioclear (); - -spin_unlock_irqrestore (&pic32_bus_lock, flags); -} - -struct pic32_i2c_platform_data { -u32 base; -struct i2c_adapter adap; -u32 xfer_timeout; -u32 ack_timeout; -u32 ctl_timeout; -}; - -static inline void pic32_i2c_start (struct pic32_i2c_platform_data *adap) -{ -pic32_bus_writel (PIC32_I2CCON_SEN , adap->base + PIC32_I2CxCONSET); -} - -static inline void pic32_i2c_stop (struct pic32_i2c_platform_data *adap) -{ -pic32_bus_writel (PIC32_I2CCON_PEN , adap->base + PIC32_I2CxCONSET); -} - -static inline void pic32_i2c_ack (struct pic32_i2c_platform_data *adap) -{ -pic32_bus_writel (PIC32_I2CCON_ACKDT , adap->base + PIC32_I2CxCONCLR); -pic32_bus_writel (PIC32_I2CCON_ACKEN , adap->base + PIC32_I2CxCONSET); -} - -static inline void pic32_i2c_nack (struct pic32_i2c_platform_data *adap) -{ -pic32_bus_writel (PIC32_I2CCON_ACKDT , adap->base + PIC32_I2CxCONSET); -pic32_bus_writel (PIC32_I2CCON_ACKEN , adap->base + PIC32_I2CxCONSET); -} - -static inline int pic32_i2c_idle (struct pic32_i2c_platform_data *adap) -{ -int i; - -for (i =0 ; i < adap->ctl_timeout; i++) { -if (((pic32_bus_readl (adap->base + PIC32_I2CxCON) & - (PIC32_I2CCON_ACKEN |PIC32_I2CCON_RCEN | -PIC32_I2CCON_PEN |PIC32_I2CCON_RSEN | -PIC32_I2CCON_SEN )) ==0 ) && - ((pic32_bus_readl (adap->base + PIC32_I2CxSTAT) & - (PIC32_I2CSTAT_TRSTAT )) ==0 )) -return 0 ; -udelay (1 ); - } -return -ETIMEDOUT ; -} - -static inline u32 pic32_i2c_master_write (struct pic32_i2c_platform_data *adap, -u32 byte) -{ -pic32_bus_writel (byte, adap->base + PIC32_I2CxTRN); -return pic32_bus_readl (adap->base + PIC32_I2CxSTAT) & -PIC32_I2CSTAT_IWCOL ; -} - -static inline u32 pic32_i2c_master_read (struct pic32_i2c_platform_data *adap) -{ -pic32_bus_writel (PIC32_I2CCON_RCEN , adap->base + PIC32_I2CxCONSET); -while (pic32_bus_readl (adap->base + PIC32_I2CxCON) &PIC32_I2CCON_RCEN ) - ; -pic32_bus_writel (PIC32_I2CSTAT_I2COV , adap->base + PIC32_I2CxSTATCLR); -return pic32_bus_readl (adap->base + PIC32_I2CxRCV); -} - -static int pic32_i2c_address (struct pic32_i2c_platform_data *adap, -unsigned int addr,int rd) -{ -pic32_i2c_idle (adap); -pic32_i2c_start (adap); -pic32_i2c_idle (adap); - - addr <<=1 ; -if (rd) - addr |=1 ; - -if (pic32_i2c_master_write (adap, addr)) -return -EIO ; -pic32_i2c_idle (adap); -if (pic32_bus_readl (adap->base + PIC32_I2CxSTAT) & -PIC32_I2CSTAT_ACKSTAT ) -return -EIO ; -return 0 ; -} - -static int sead3_i2c_read (struct pic32_i2c_platform_data *adap, -unsigned char *buf,unsigned int len) -{ -u32 data; -int i; - - i =0 ; -while (i < len) { - data =pic32_i2c_master_read (adap); - buf[i++] = data; -if (i < len) -pic32_i2c_ack (adap); -else -pic32_i2c_nack (adap); - } - -pic32_i2c_stop (adap); -pic32_i2c_idle (adap); -return 0 ; -} - -static int sead3_i2c_write (struct pic32_i2c_platform_data *adap, -unsigned char *buf,unsigned int len) -{ -int i; -u32 data; - - i =0 ; -while (i < len) { - data = buf[i]; -if (pic32_i2c_master_write (adap, data)) -return -EIO ; -pic32_i2c_idle (adap); -if (pic32_bus_readl (adap->base + PIC32_I2CxSTAT) & -PIC32_I2CSTAT_ACKSTAT ) -return -EIO ; - i++; - } - -pic32_i2c_stop (adap); -pic32_i2c_idle (adap); -return 0 ; -} - -static int sead3_pic32_platform_xfer (struct i2c_adapter *i2c_adap, -struct i2c_msg *msgs,int num) -{ -struct pic32_i2c_platform_data *adap = i2c_adap->algo_data; -struct i2c_msg *p; -int i, err =0 ; - -for (i =0 ; i < num; i++) { -#define __BUFSIZE 80 -int ii; -static char buf[__BUFSIZE]; -char *b = buf; - - p = &msgs[i]; - b +=sprintf (buf," [%d bytes]" , p->len); -if ((p->flags &I2C_M_RD ) ==0 ) { -for (ii =0 ; ii < p->len; ii++) { -if (b < &buf[__BUFSIZE-4 ]) { - b +=sprintf (b," %02x" , p->buf[ii]); - }else { -strcat (b,"..." ); -break ; - } - } - } - } - -for (i =0 ; !err && i < num; i++) { - p = &msgs[i]; - err =pic32_i2c_address (adap, p->addr, p->flags &I2C_M_RD ); -if (err || !p->len) -continue ; -if (p->flags &I2C_M_RD ) - err =sead3_i2c_read (adap, p->buf, p->len); -else - err =sead3_i2c_write (adap, p->buf, p->len); - } - -/* Return the number of messages processed, or the error code. */ -if (err ==0 ) - err = num; - -return err; -} - -static u32 sead3_pic32_platform_func (struct i2c_adapter *adap) -{ -return I2C_FUNC_I2C |I2C_FUNC_SMBUS_EMUL ; -} - -static const struct i2c_algorithm sead3_platform_algo = { - .master_xfer = sead3_pic32_platform_xfer, - .functionality = sead3_pic32_platform_func, -}; - -static void sead3_i2c_platform_setup (struct pic32_i2c_platform_data *priv) -{ -pic32_bus_writel (500 , priv->base + PIC32_I2CxBRG); -pic32_bus_writel (PIC32_I2CCON_ON , priv->base + PIC32_I2CxCONCLR); -pic32_bus_writel (PIC32_I2CCON_ON , priv->base + PIC32_I2CxCONSET); -pic32_bus_writel (PIC32_I2CSTAT_BCL |PIC32_I2CSTAT_IWCOL , - priv->base + PIC32_I2CxSTATCLR); -} - -static int sead3_i2c_platform_probe (struct platform_device *pdev) -{ -struct pic32_i2c_platform_data *priv; -struct resource *r; -int ret; - - r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!r) { - ret = -ENODEV ; - goto out; - } - - priv =kzalloc (sizeof (struct pic32_i2c_platform_data ),GFP_KERNEL ); -if (!priv) { - ret = -ENOMEM ; - goto out; - } - - priv->base = r->start; -if (!priv->base) { - ret = -EBUSY ; - goto out_mem; - } - - priv->xfer_timeout =200 ; - priv->ack_timeout =200 ; - priv->ctl_timeout =200 ; - - priv->adap.nr = pdev->id; - priv->adap.algo = &sead3_platform_algo; - priv->adap.algo_data = priv; - priv->adap.dev.parent = &pdev->dev; -strlcpy (priv->adap.name,"SEAD3 PIC32" ,sizeof (priv->adap.name)); - -sead3_i2c_platform_setup (priv); - - ret =i2c_add_numbered_adapter (&priv->adap); -if (ret ==0 ) { -platform_set_drvdata (pdev, priv); -return 0 ; - } - -out_mem: -kfree (priv); -out: -return ret; -} - -static int sead3_i2c_platform_remove (struct platform_device *pdev) -{ -struct pic32_i2c_platform_data *priv =platform_get_drvdata (pdev); - -platform_set_drvdata (pdev,NULL ); -i2c_del_adapter (&priv->adap); -kfree (priv); -return 0 ; -} - -#ifdef CONFIG_PM -static int sead3_i2c_platform_suspend (struct platform_device *pdev, -pm_message_t state) -{ -dev_dbg (&pdev->dev,"i2c_platform_disable\n" ); -return 0 ; -} - -static int sead3_i2c_platform_resume (struct platform_device *pdev) -{ -struct pic32_i2c_platform_data *priv =platform_get_drvdata (pdev); - -dev_dbg (&pdev->dev,"sead3_i2c_platform_setup\n" ); -sead3_i2c_platform_setup (priv); - -return 0 ; -} -#else -#define sead3_i2c_platform_suspend NULL -#define sead3_i2c_platform_resume NULL -#endif - -static struct platform_driver sead3_i2c_platform_driver = { - .driver = { - .name ="sead3-i2c" , - .owner =THIS_MODULE , - }, - .probe = sead3_i2c_platform_probe, - .remove = sead3_i2c_platform_remove, - .suspend = sead3_i2c_platform_suspend, - .resume = sead3_i2c_platform_resume, -}; - -static int __init sead3_i2c_platform_init (void ) -{ -return platform_driver_register (&sead3_i2c_platform_driver); -} -module_init (sead3_i2c_platform_init); - -static void __exit sead3_i2c_platform_exit(void) -{ -platform_driver_unregister (&sead3_i2c_platform_driver); -} -module_exit (sead3_i2c_platform_exit); - -MODULE_AUTHOR ("Chris Dearman, MIPS Technologies INC." ); -MODULE_DESCRIPTION ("SEAD3 PIC32 I2C driver" ); -MODULE_LICENSE ("GPL" );
drivers/i2c/busses/Kconfig +7 -0
@@ -724,6 +724,13 @@ config I2C_S3C2410 Say Y here to include support for I2C controller in the Samsung SoCs. +config I2C_SEAD3 + tristate "SEAD3 I2C Driver" + depends on MIPS_SEAD3 + help + Say Y here to include support for I2C controller on the + MIPS SEAD3 evaluation board. + config I2C_SH7760 tristate "Renesas SH7760 I2C Controller" depends on CPU_SUBTYPE_SH7760
drivers/i2c/busses/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_I2C_QUP) += i2c-qup.o obj-$(CONFIG_I2C_RIIC) += i2c-riic.o obj-$(CONFIG_I2C_RK3X) += i2c-rk3x.o obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o +obj-$(CONFIG_I2C_SEAD3) += i2c-sead3.o obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o obj-$(CONFIG_I2C_SH_MOBILE) += i2c-sh_mobile.o obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o
drivers/i2c/busses/i2c-sead3.c new file +405 -0
405 lines not on this page · raw message
A message that is not in the archive (sent off-list or not yet received): 20141024122656.GC12641-6z/[email protected]
Re: [PATCH] MIPS/I2C: Move SEAD3 I2C driver to where it belongs.
Quoted 5 lines · Ralf Baechle
Fixes the following build problem if
CONFIG_I2Cis disabled:
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_probe':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:345:2: error: implicit declaration of function 'i2c_add_numbered_adapter' [-Werror=implicit-function-declaration]
Quoted 8 lines
ret = i2c_add_numbered_adapter(&priv->adap); ^
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c: In function 'i2c_platform_remove':arch/mips/mti-sead3/sead3-pic32-i2c-drv.c:361:2: error: implicit declaration of function 'i2c_del_adapter' [-Werror=implicit-function-declaration]i2c_del_adapter(&priv->adap);
Uh, so this is already mainline? It has some issues.
Quoted 6 lines
Signed-off-by Ralf Baechle <[email protected]>Cc Markos Chandras <[email protected]>Cc Wolfram Sang <[email protected]>Cc Chris Dearman <[email protected]>
No diffstat?
Quoted 9 lines
drivers/i2c/busses/i2c-sead3.c new file +3
-0@@ -0,0 +1,405 @@ +/* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file "COPYING" in the main directory of this archive
drivers/i2c/busses/i2c-sead3.c line 13
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+* for more details. +* +* Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. +*/ +#include <linux/init.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/delay.h> +#include <linux/i2c.h> +#include <linux/platform_device.h>
Please sort the includes.
Quoted 28 lines
drivers/i2c/busses/i2c-sead3.c new file +28
-0+ +#define PIC32_I2CxCON 0x0000 +#define PIC32_I2CCON_ON (1<<15) +#define PIC32_I2CCON_ACKDT (1<<5) +#define PIC32_I2CCON_ACKEN (1<<4) +#define PIC32_I2CCON_RCEN (1<<3) +#define PIC32_I2CCON_PEN (1<<2) +#define PIC32_I2CCON_RSEN (1<<1) +#define PIC32_I2CCON_SEN (1<<0) +#define PIC32_I2CxCONCLR 0x0004 +#define PIC32_I2CxCONSET 0x0008 +#define PIC32_I2CxSTAT 0x0010 +#define PIC32_I2CxSTATCLR 0x0014 +#define PIC32_I2CSTAT_ACKSTAT (1<<15) +#define PIC32_I2CSTAT_TRSTAT (1<<14) +#define PIC32_I2CSTAT_BCL (1<<10) +#define PIC32_I2CSTAT_IWCOL (1<<7) +#define PIC32_I2CSTAT_I2COV (1<<6) +#define PIC32_I2CxBRG 0x0040 +#define PIC32_I2CxTRN 0x0050 +#define PIC32_I2CxRCV 0x0060 + +static DEFINE_SPINLOCK (pic32_bus_lock); + +static void __iomem *bus_xfer = (void __iomem *)0xbf000600 ; +static void __iomem *bus_status = (void __iomem *)0xbf000060 ; + +#define DELAY () udelay(100)
drivers/i2c/busses/i2c-sead3.c line 51
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+ +static inline unsigned int ioready (void ) +{ +return readl (bus_status) &1 ; +} + +static inline void wait_ioready (void ) +{ +do { }while (!ioready ()); +}
No timeout?
drivers/i2c/busses/i2c-sead3.c line 56
Quoted 5 lines
drivers/i2c/busses/i2c-sead3.c new file +5
-0+ +static inline void wait_ioclear (void ) +{ +do { }while (ioready ()); +}
ditto
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+ +static inline void check_ioclear (void ) +{ +if (ioready ()) { +do { + (void )readl (bus_xfer); +DELAY (); + }while (ioready ()); + } +}
drivers/i2c/busses/i2c-sead3.c line 76
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+ +static u32 pic32_bus_readl (u32 reg) +{ +unsigned long flags; +u32 status, val; + +spin_lock_irqsave (&pic32_bus_lock, flags); + +check_ioclear (); +writel ((0x01 <<24 ) | (reg &0x00ffffff ), bus_xfer);
Can we have names for all these magic hex-values?
Quoted 28 lines
drivers/i2c/busses/i2c-sead3.c new file +28
-0+DELAY (); +wait_ioready (); + status =readl (bus_xfer); +DELAY (); + val =readl (bus_xfer); +wait_ioclear (); + +spin_unlock_irqrestore (&pic32_bus_lock, flags); + +return val; +} + +static void pic32_bus_writel (u32 val,u32 reg) +{ +unsigned long flags; +u32 status; + +spin_lock_irqsave (&pic32_bus_lock, flags); + +check_ioclear (); +writel ((0x10 <<24 ) | (reg &0x00ffffff ), bus_xfer); +DELAY (); +writel (val, bus_xfer); +DELAY (); +wait_ioready (); + status =readl (bus_xfer); +wait_ioclear (); +
drivers/i2c/busses/i2c-sead3.c line 114
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+spin_unlock_irqrestore (&pic32_bus_lock, flags); +} + +struct pic32_i2c_platform_data { +u32 base; +struct i2c_adapter adap; +u32 xfer_timeout; +u32 ack_timeout; +u32 ctl_timeout; +};
priv goes to the platform instead of the adapter? Unusual, why is that?
Quoted 64 lines
drivers/i2c/busses/i2c-sead3.c new file +64
-0+ +static inline void pic32_i2c_start (struct pic32_i2c_platform_data *adap) +{ +pic32_bus_writel (PIC32_I2CCON_SEN , adap->base + PIC32_I2CxCONSET); +} + +static inline void pic32_i2c_stop (struct pic32_i2c_platform_data *adap) +{ +pic32_bus_writel (PIC32_I2CCON_PEN , adap->base + PIC32_I2CxCONSET); +} + +static inline void pic32_i2c_ack (struct pic32_i2c_platform_data *adap) +{ +pic32_bus_writel (PIC32_I2CCON_ACKDT , adap->base + PIC32_I2CxCONCLR); +pic32_bus_writel (PIC32_I2CCON_ACKEN , adap->base + PIC32_I2CxCONSET); +} + +static inline void pic32_i2c_nack (struct pic32_i2c_platform_data *adap) +{ +pic32_bus_writel (PIC32_I2CCON_ACKDT , adap->base + PIC32_I2CxCONSET); +pic32_bus_writel (PIC32_I2CCON_ACKEN , adap->base + PIC32_I2CxCONSET); +} + +static inline int pic32_i2c_idle (struct pic32_i2c_platform_data *adap) +{ +int i; + +for (i =0 ; i < adap->ctl_timeout; i++) { +if (((pic32_bus_readl (adap->base + PIC32_I2CxCON) & + (PIC32_I2CCON_ACKEN |PIC32_I2CCON_RCEN | +PIC32_I2CCON_PEN |PIC32_I2CCON_RSEN | +PIC32_I2CCON_SEN )) ==0 ) && + ((pic32_bus_readl (adap->base + PIC32_I2CxSTAT) & + (PIC32_I2CSTAT_TRSTAT )) ==0 )) +return 0 ; +udelay (1 ); + } +return -ETIMEDOUT ; +} + +static inline u32 pic32_i2c_master_write (struct pic32_i2c_platform_data *adap, +u32 byte) +{ +pic32_bus_writel (byte, adap->base + PIC32_I2CxTRN); +return pic32_bus_readl (adap->base + PIC32_I2CxSTAT) & +PIC32_I2CSTAT_IWCOL ; +} + +static inline u32 pic32_i2c_master_read (struct pic32_i2c_platform_data *adap) +{ +pic32_bus_writel (PIC32_I2CCON_RCEN , adap->base + PIC32_I2CxCONSET); +while (pic32_bus_readl (adap->base + PIC32_I2CxCON) &PIC32_I2CCON_RCEN ) + ; +pic32_bus_writel (PIC32_I2CSTAT_I2COV , adap->base + PIC32_I2CxSTATCLR); +return pic32_bus_readl (adap->base + PIC32_I2CxRCV); +} + +static int pic32_i2c_address (struct pic32_i2c_platform_data *adap, +unsigned int addr,int rd) +{ +pic32_i2c_idle (adap); +pic32_i2c_start (adap); +pic32_i2c_idle (adap); +
drivers/i2c/busses/i2c-sead3.c line 188
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+ addr <<=1 ; +if (rd) + addr |=1 ; + +if (pic32_i2c_master_write (adap, addr)) +return -EIO ; +pic32_i2c_idle (adap); +if (pic32_bus_readl (adap->base + PIC32_I2CxSTAT) & +PIC32_I2CSTAT_ACKSTAT ) +return -EIO ;
I'd think this is -ENXIO. Please have a look at Documentation/i2c/fault-codes for the error codes we use.
Quoted 29 lines
drivers/i2c/busses/i2c-sead3.c new file +29
-0+return 0 ; +} + +static int sead3_i2c_read (struct pic32_i2c_platform_data *adap, +unsigned char *buf,unsigned int len) +{ +u32 data; +int i; + + i =0 ; +while (i < len) { + data =pic32_i2c_master_read (adap); + buf[i++] = data; +if (i < len) +pic32_i2c_ack (adap); +else +pic32_i2c_nack (adap); + } + +pic32_i2c_stop (adap); +pic32_i2c_idle (adap); +return 0 ; +} + +static int sead3_i2c_write (struct pic32_i2c_platform_data *adap, +unsigned char *buf,unsigned int len) +{ +int i; +u32 data;
drivers/i2c/busses/i2c-sead3.c line 227
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+ + i =0 ; +while (i < len) { + data = buf[i]; +if (pic32_i2c_master_write (adap, data)) +return -EIO ; +pic32_i2c_idle (adap); +if (pic32_bus_readl (adap->base + PIC32_I2CxSTAT) & +PIC32_I2CSTAT_ACKSTAT ) +return -EIO ;
ditto
Quoted 23 lines
drivers/i2c/busses/i2c-sead3.c new file +23
-0+ i++; + } + +pic32_i2c_stop (adap); +pic32_i2c_idle (adap); +return 0 ; +} + +static int sead3_pic32_platform_xfer (struct i2c_adapter *i2c_adap, +struct i2c_msg *msgs,int num) +{ +struct pic32_i2c_platform_data *adap = i2c_adap->algo_data; +struct i2c_msg *p; +int i, err =0 ; + +for (i =0 ; i < num; i++) { +#define __BUFSIZE 80 +int ii; +static char buf[__BUFSIZE]; +char *b = buf; + + p = &msgs[i]; + b +=sprintf (buf," [%d bytes]" , p->len);
drivers/i2c/busses/i2c-sead3.c line 260
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+if ((p->flags &I2C_M_RD ) ==0 ) { +for (ii =0 ; ii < p->len; ii++) { +if (b < &buf[__BUFSIZE-4 ]) { + b +=sprintf (b," %02x" , p->buf[ii]); + }else { +strcat (b,"..." ); +break ; + } + } + }
??? Where is buf used? And we have other debugging options and support even tracing. Not needed.
drivers/i2c/busses/i2c-sead3.c line 267
Quoted 7 lines
drivers/i2c/busses/i2c-sead3.c new file +7
-0+ } + +for (i =0 ; !err && i < num; i++) { + p = &msgs[i]; + err =pic32_i2c_address (adap, p->addr, p->flags &I2C_M_RD ); +if (err || !p->len) +continue ;
So, you don't support SMBUS_QUICK? You should remove it from the functionality then. Or add support for it.
Quoted 41 lines
drivers/i2c/busses/i2c-sead3.c new file +41
-0+if (p->flags &I2C_M_RD ) + err =sead3_i2c_read (adap, p->buf, p->len); +else + err =sead3_i2c_write (adap, p->buf, p->len); + } + +/* Return the number of messages processed, or the error code. */ +if (err ==0 ) + err = num; + +return err; +} + +static u32 sead3_pic32_platform_func (struct i2c_adapter *adap) +{ +return I2C_FUNC_I2C |I2C_FUNC_SMBUS_EMUL ; +} + +static const struct i2c_algorithm sead3_platform_algo = { + .master_xfer = sead3_pic32_platform_xfer, + .functionality = sead3_pic32_platform_func, +}; + +static void sead3_i2c_platform_setup (struct pic32_i2c_platform_data *priv) +{ +pic32_bus_writel (500 , priv->base + PIC32_I2CxBRG); +pic32_bus_writel (PIC32_I2CCON_ON , priv->base + PIC32_I2CxCONCLR); +pic32_bus_writel (PIC32_I2CCON_ON , priv->base + PIC32_I2CxCONSET); +pic32_bus_writel (PIC32_I2CSTAT_BCL |PIC32_I2CSTAT_IWCOL , + priv->base + PIC32_I2CxSTATCLR); +} + +static int sead3_i2c_platform_probe (struct platform_device *pdev) +{ +struct pic32_i2c_platform_data *priv; +struct resource *r; +int ret; + + r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!r) { + ret = -ENODEV ;
drivers/i2c/busses/i2c-sead3.c line 318
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+ goto out; + } + + priv =kzalloc (sizeof (struct pic32_i2c_platform_data ),GFP_KERNEL ); +if (!priv) { + ret = -ENOMEM ; + goto out; + } + + priv->base = r->start;
OK. MIPS doesn't need ioremap?
drivers/i2c/busses/i2c-sead3.c line 326
Quoted 8 lines
drivers/i2c/busses/i2c-sead3.c new file +8
-0+if (!priv->base) { + ret = -EBUSY ; + goto out_mem; + } + + priv->xfer_timeout =200 ; + priv->ack_timeout =200 ; + priv->ctl_timeout =200 ;
Why have three if they are all the same?
drivers/i2c/busses/i2c-sead3.c line 338
Quoted 12 lines
drivers/i2c/busses/i2c-sead3.c new file +12
-0+ + priv->adap.nr = pdev->id; + priv->adap.algo = &sead3_platform_algo; + priv->adap.algo_data = priv; + priv->adap.dev.parent = &pdev->dev; +strlcpy (priv->adap.name,"SEAD3 PIC32" ,sizeof (priv->adap.name)); + +sead3_i2c_platform_setup (priv); + + ret =i2c_add_numbered_adapter (&priv->adap); +if (ret ==0 ) { +platform_set_drvdata (pdev, priv);
No, it must be set before! If I2C gets called after add_adapter and before the if, we have an OOPS.
Quoted 35 lines
drivers/i2c/busses/i2c-sead3.c new file +35
-0+return 0 ; + } + +out_mem: +kfree (priv); +out: +return ret; +} + +static int sead3_i2c_platform_remove (struct platform_device *pdev) +{ +struct pic32_i2c_platform_data *priv =platform_get_drvdata (pdev); + +platform_set_drvdata (pdev,NULL ); +i2c_del_adapter (&priv->adap); +kfree (priv); +return 0 ; +} + +#ifdef CONFIG_PM +static int sead3_i2c_platform_suspend (struct platform_device *pdev, +pm_message_t state) +{ +dev_dbg (&pdev->dev,"i2c_platform_disable\n" ); +return 0 ; +} + +static int sead3_i2c_platform_resume (struct platform_device *pdev) +{ +struct pic32_i2c_platform_data *priv =platform_get_drvdata (pdev); + +dev_dbg (&pdev->dev,"sead3_i2c_platform_setup\n" ); +sead3_i2c_platform_setup (priv); + +return 0 ;
drivers/i2c/busses/i2c-sead3.c line 383
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+} +#else +#define sead3_i2c_platform_suspend NULL +#define sead3_i2c_platform_resume NULL +#endif + +static struct platform_driver sead3_i2c_platform_driver = { + .driver = { + .name ="sead3-i2c" , + .owner =THIS_MODULE ,
Not needed.
Quoted 8 lines
drivers/i2c/busses/i2c-sead3.c new file +8
-0+ }, + .probe = sead3_i2c_platform_probe, + .remove = sead3_i2c_platform_remove, + .suspend = sead3_i2c_platform_suspend, + .resume = sead3_i2c_platform_resume, +}; + +static int __init sead3_i2c_platform_init (void )
drivers/i2c/busses/i2c-sead3.c line 401
Quoted 10 lines
drivers/i2c/busses/i2c-sead3.c new file +10
-0+{ +return platform_driver_register (&sead3_i2c_platform_driver); +} +module_init (sead3_i2c_platform_init); + +static void __exit sead3_i2c_platform_exit(void) +{ +platform_driver_unregister (&sead3_i2c_platform_driver); +} +module_exit (sead3_i2c_platform_exit);
module_platform_driver()
Quoted 4 lines
drivers/i2c/busses/i2c-sead3.c new file +4
-0+ +MODULE_AUTHOR ("Chris Dearman, MIPS Technologies INC." ); +MODULE_DESCRIPTION ("SEAD3 PIC32 I2C driver" ); +MODULE_LICENSE ("GPL" );
PATCH 3/3 MIPS: sead3: Only build the led driver if LEDS_CLASS is enabled
In reply to Markos ChandrasFixes the following randconfig problem
leds-sead3.c:(.text+0x7dc): undefined reference to led_classdev_unregister' leds-sead3.c:(.text+0x7e8): undefined reference to led_classdev_unregister'
--- arch/mips/mti-sead3/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/mips/mti-sead3/Makefile +1 -2
@@ -13,11 +13,10 @@ obj-y := sead3-lcd.o sead3-display.o sead3-init.o \ sead3-platform.o sead3-reset.o \ sead3-setup.o sead3-time.o -obj-y += leds-sead3.o sead3-leds.o - obj-$(CONFIG_EARLY_PRINTK) += sead3-console.o obj-$(CONFIG_I2C) += sead3-i2c.o sead3-i2c-dev.o \ sead3-pic32-bus.o lsead3-pic32-i2c-drv.o +obj-$(LEDS_CLASS) += leds-sead3.o sead3-leds.o obj-$(CONFIG_USB_EHCI_HCD) += sead3-ehci.o obj-$(CONFIG_OF) += sead3.dtb.o
Signature · 1 line
2.1.2
Re: [PATCH 3/3] MIPS: sead3: Only build the led driver if LEDS_CLASS is enabled
Quoted 5 lines · Markos Chandras
leds-sead3.c:(.text+0x7dc): undefined reference to
led_classdev_unregister' leds-sead3.c:(.text+0x7e8): undefined reference toled_classdev_unregister'Reviewed-by Steven J. Hill <[email protected]>Signed-off-by Markos Chandras <[email protected]>
Hmm... I think there's a whole lot more broken. Let's start with the Makefile:
-obj-y += leds-sead3.o sead3-leds.o
Very creative filenames. No way to know in what way foo-bar and bar-foo are different. But let's take a look at sead3-leds:
[...]module_init(led_init);
MODULE_AUTHOR("Chris Dearman <[email protected]>"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("LED probe driver for SEAD-3");
But although you were trying to make this a module, this better shouldn't be one, the devices should always be registered if they're there, driver enabled or not.
Anyway this should probably become a device_initcall() and all the module bits should go.
And now let's take a look at sead3-led.. oh wait, that's leds-sead3 - did I bitch about the filename before? That's a complete device driver and it blows up primarily because it lives in a directory where it shouldn't be at all.
Ralf
PATCH 1/3 MIPS: SEAD3: Fix LED device registration.
This isn't a module and shouldn't be one.
--- arch/mips/mti-sead3/sead3-leds.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/mips/mti-sead3/sead3-leds.c +2 -6
@@ -5,7 +5,7 @@* * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. */ -#include <linux/module.h> +#include <linux/init.h> #include <linux/leds.h> #include <linux/platform_device.h>
@@ -76,8 +76,4 @@ static int __init led_init(void)return platform_device_register (&fled_device); } -module_init (led_init); - -MODULE_AUTHOR ("Chris Dearman <[email protected]>" ); -MODULE_LICENSE ("GPL" ); -MODULE_DESCRIPTION ("LED probe driver for SEAD-3" ); +device_initcall (led_init);
Signature · 1 line
1.9.3
PATCH 2/3 MIPS: SEAD3: Collect LED platform device registration in a single file.
In reply to Ralf Baechle--- arch/mips/mti-sead3/leds-sead3.c | 19 +------------------ arch/mips/mti-sead3/sead3-leds.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 22 deletions(-)
arch/mips/mti-sead3/leds-sead3.c +1 -18
@@ -15,8 +15,6 @@#define DRVNAME "sead3-led" -static struct platform_device *pdev; -static void sead3_pled_set (struct led_classdev *led_cdev,enum led_brightness value) {
@@ -76,26 +74,11 @@ static struct platform_driver sead3_led_driver = {static int __init sead3_led_init (void ) { -int ret; - - ret =platform_driver_register (&sead3_led_driver); -if (ret <0 ) - goto out; - - pdev =platform_device_register_simple (DRVNAME ,-1 ,NULL ,0 ); -if (IS_ERR (pdev)) { - ret =PTR_ERR (pdev); -platform_driver_unregister (&sead3_led_driver); - goto out; - } - -out: -return ret; +return platform_driver_register (&sead3_led_driver); } static void __exit sead3_led_exit(void) { -platform_device_unregister (pdev);platform_driver_unregister (&sead3_led_driver); }
arch/mips/mti-sead3/sead3-leds.c +14 -4
@@ -70,10 +70,20 @@ static struct platform_device fled_device = { .resource = fled_resources }; -static int __init led_init (void ) +static struct platform_device sead3_led_device = { + .name ="sead3-led" , + .id =-1 , +}; + +struct platform_device *sead3_led_devices[] = { + &pled_device, + &fled_device, + &sead3_led_device, +}; + +static int __init sead3_led_init (void ) { -platform_device_register (&pled_device); -return platform_device_register (&fled_device); +return platform_add_devices (sead3_led_devices,ARRAY_SIZE (sead3_led_devices)); } -device_initcall (led_init); +device_initcall (sead3_led_init);
Signature · 1 line
1.9.3
PATCH 3/3 LED/MIPS: Move SEAD3 LED driver to where it belongs.
In reply to Ralf BaechleFixes the following randconfig problem
leds-sead3.c:(.text+0x7dc): undefined reference to led_classdev_unregister' leds-sead3.c:(.text+0x7e8): undefined reference to led_classdev_unregister'
--- arch/mips/mti-sead3/Makefile | 2 +- arch/mips/mti-sead3/leds-sead3.c | 90 ---------------------------------------- drivers/leds/Kconfig | 9 ++++ drivers/leds/Makefile | 1 + drivers/leds/leds-sead3.c | 90 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 91 deletions(-) delete mode 100644 arch/mips/mti-sead3/leds-sead3.c create mode 100644 drivers/leds/leds-sead3.c
arch/mips/mti-sead3/Makefile +1 -1
@@ -15,7 +15,7 @@ obj-y := sead3-lcd.o sead3-display.o sead3-init.o \ obj-y += sead3-i2c-dev.o sead3-i2c.o \ sead3-pic32-i2c-drv.o sead3-pic32-bus.o \ - leds-sead3.o sead3-leds.o + sead3-leds.o obj-$(CONFIG_EARLY_PRINTK) += sead3-console.o obj-$(CONFIG_USB_EHCI_HCD) += sead3-ehci.o
arch/mips/mti-sead3/leds-sead3.c deleted +0 -90
90 lines not on this page · raw message
drivers/leds/Kconfig +9 -0
@@ -477,6 +477,15 @@ config LEDS_MENF21BMC This driver can also be built as a module. If so the module will be called leds-menf21bmc. +config LEDS_SEAD3 + tristate "LED support for the MIPS SEAD 3 board" + depends on LEDS_CLASS && MIPS_SEAD3 + help + Say Y here to include support for the MEN 14F021P00 BMC LEDs. + + This driver can also be built as a module. If so the module + will be called leds-sead3. + comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" config LEDS_BLINKM
drivers/leds/Makefile +1 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o +obj-$(CONFIG_LEDS_SEAD3) += leds-sead3.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
drivers/leds/leds-sead3.c new file +90 -0
90 lines not on this page · raw message
Signature · 1 line
1.9.3
Re: [PATCH 3/3] LED/MIPS: Move SEAD3 LED driver to where it belongs.
Quoted 5 lines · Ralf Baechle
Fixes the following randconfig problem
leds-sead3.c:(.text+0x7dc): undefined reference to
led_classdev_unregister' leds-sead3.c:(.text+0x7e8): undefined reference toled_classdev_unregister'
I think you can fold these 3 patches into one patch then.
Quoted 125 lines
Signed-off-by Ralf Baechle <[email protected]>--- arch/mips/mti-sead3/Makefile | 2 +- arch/mips/mti-sead3/leds-sead3.c | 90 ---------------------------------------- drivers/leds/Kconfig | 9 ++++ drivers/leds/Makefile | 1 + drivers/leds/leds-sead3.c | 90 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 91 deletions(-) delete mode 100644 arch/mips/mti-sead3/leds-sead3.c create mode 100644 drivers/leds/leds-sead3.carch/mips/mti-sead3/Makefile +1
-1@@ -15,7 +15,7 @@ obj-y := sead3-lcd.o sead3-display.o sead3-init.o \ obj-y += sead3-i2c-dev.o sead3-i2c.o \ sead3-pic32-i2c-drv.o sead3-pic32-bus.o \ - leds-sead3.o sead3-leds.o + sead3-leds.o obj-$(CONFIG_EARLY_PRINTK) += sead3-console.o obj-$(CONFIG_USB_EHCI_HCD) += sead3-ehci.oarch/mips/mti-sead3/leds-sead3.c deleted +0
-90@@ -1,90 +0,0 @@ -/* -* This file is subject to the terms and conditions of the GNU General Public -* License. See the file "COPYING" in the main directory of this archive -* for more details. -* -* Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. -*/ -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/init.h> -#include <linux/platform_device.h> -#include <linux/leds.h> -#include <linux/err.h> -#include <linux/io.h> - -#define DRVNAME "sead3-led" - -static void sead3_pled_set (struct led_classdev *led_cdev, -enum led_brightness value) -{ -pr_debug ("sead3_pled_set\n" ); -writel (value, (void __iomem *)0xBF000210 );/* FIXME */ -} - -static void sead3_fled_set (struct led_classdev *led_cdev, -enum led_brightness value) -{ -pr_debug ("sead3_fled_set\n" ); -writel (value, (void __iomem *)0xBF000218 );/* FIXME */ -} - -static struct led_classdev sead3_pled = { - .name ="sead3::pled" , - .brightness_set = sead3_pled_set, - .flags =LED_CORE_SUSPENDRESUME , -}; - -static struct led_classdev sead3_fled = { - .name ="sead3::fled" , - .brightness_set = sead3_fled_set, - .flags =LED_CORE_SUSPENDRESUME , -}; - -static int sead3_led_probe (struct platform_device *pdev) -{ -int ret; - - ret =led_classdev_register (&pdev->dev, &sead3_pled); -if (ret <0 ) -return ret; - - ret =led_classdev_register (&pdev->dev, &sead3_fled); -if (ret <0 ) -led_classdev_unregister (&sead3_pled); - -return ret; -} - -static int sead3_led_remove (struct platform_device *pdev) -{ -led_classdev_unregister (&sead3_pled); -led_classdev_unregister (&sead3_fled); -return 0 ; -} - -static struct platform_driver sead3_led_driver = { - .probe = sead3_led_probe, - .remove = sead3_led_remove, - .driver = { - .name =DRVNAME , - .owner =THIS_MODULE , - }, -}; - -static int __init sead3_led_init (void ) -{ -return platform_driver_register (&sead3_led_driver); -} - -static void __exit sead3_led_exit(void) -{ -platform_driver_unregister (&sead3_led_driver); -} - -module_init (sead3_led_init); -module_exit (sead3_led_exit); - -MODULE_AUTHOR ("Kristian Kielhofner <[email protected]>" ); -MODULE_DESCRIPTION ("SEAD3 LED driver" ); -MODULE_LICENSE ("GPL" );drivers/leds/Kconfig +0
-0
drivers/leds/Kconfig config LEDS_MENF21BMC · line 485
Quoted 9 lines
drivers/leds/Kconfig +6
-0@@ -477,6 +477,15 @@ config LEDS_MENF21BMC This driver can also be built as a module. If so the module will be called leds-menf21bmc. +config LEDS_SEAD3 + tristate "LED support for the MIPS SEAD 3 board" + depends on LEDS_CLASS && MIPS_SEAD3 + help + Say Y here to include support for the MEN 14F021P00 BMC LEDs. +
Is this driver similar to drivers/leds/leds-menf21bmc.c? If we can reuse the code it should be better.
Quoted 29 lines
drivers/leds/Kconfig +3
-0+ This driver can also be built as a module. If so the module + will be called leds-sead3. + comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" config LEDS_BLINKMdrivers/leds/Makefile +1
-0@@ -56,6 +56,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o +obj-$(CONFIG_LEDS_SEAD3) += leds-sead3.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.odrivers/leds/leds-sead3.c new file +5
-0@@ -0,0 +1,90 @@ +/* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file "COPYING" in the main directory of this archive +* for more details. +*
drivers/leds/leds-sead3.c line 15
Quoted 10 lines
drivers/leds/leds-sead3.c new file +10
-0+* Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. +*/ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/platform_device.h> +#include <linux/leds.h> +#include <linux/err.h> +#include <linux/io.h> +
Please reorder this list in alphabetic order.
drivers/leds/leds-sead3.c line 19
Quoted 4 lines
drivers/leds/leds-sead3.c new file +4
-0+static void sead3_pled_set (struct led_classdev *led_cdev, +enum led_brightness value) +{ +pr_debug ("sead3_pled_set\n" );
Don't use pr_debug, please use dev_dbg();
drivers/leds/leds-sead3.c line 20
Quoted 1 line
drivers/leds/leds-sead3.c new file +1
-0+writel (value, (void __iomem *)0xBF000210 );/* FIXME */
Fix this, define some meaningful name of the address.
drivers/leds/leds-sead3.c line 26
Quoted 6 lines
drivers/leds/leds-sead3.c new file +6
-0+} + +static void sead3_fled_set (struct led_classdev *led_cdev, +enum led_brightness value) +{ +pr_debug ("sead3_fled_set\n" );
Don't use pr_debug, please use dev_dbg();
drivers/leds/leds-sead3.c line 27
Quoted 1 line
drivers/leds/leds-sead3.c new file +1
-0+writel (value, (void __iomem *)0xBF000218 );/* FIXME */
ditto
Quoted 4 lines
drivers/leds/leds-sead3.c new file +4
-0+} + +static struct led_classdev sead3_pled = { + .name ="sead3::pled" ,
drivers/leds/leds-sead3.c line 41
Quoted 10 lines
drivers/leds/leds-sead3.c new file +10
-0+ .brightness_set = sead3_pled_set, + .flags = LED_CORE_SUSPENDRESUME, +}; + +static struct led_classdev sead3_fled = { + .name ="sead3::fled" , + .brightness_set = sead3_fled_set, + .flags =LED_CORE_SUSPENDRESUME , +}; +
What's pled and fled? Please give more meaningful name or document it.
Quoted 35 lines
drivers/leds/leds-sead3.c new file +35
-0+static int sead3_led_probe (struct platform_device *pdev) +{ +int ret; + + ret =led_classdev_register (&pdev->dev, &sead3_pled); +if (ret <0 ) +return ret; + + ret =led_classdev_register (&pdev->dev, &sead3_fled); +if (ret <0 ) +led_classdev_unregister (&sead3_pled); + +return ret; +} + +static int sead3_led_remove (struct platform_device *pdev) +{ +led_classdev_unregister (&sead3_pled); +led_classdev_unregister (&sead3_fled); + +return 0 ; +} + +static struct platform_driver sead3_led_driver = { + .probe = sead3_led_probe, + .remove = sead3_led_remove, + .driver = { + .name ="sead3-led" , + .owner =THIS_MODULE , + }, +}; + +static int __init sead3_led_init (void ) +{ +return platform_driver_register (&sead3_led_driver);
drivers/leds/leds-sead3.c line 86
Quoted 10 lines
drivers/leds/leds-sead3.c new file +10
-0+} + +static void __exit sead3_led_exit(void) +{ +platform_driver_unregister (&sead3_led_driver); +} + +module_init (sead3_led_init); +module_exit (sead3_led_exit); +
You can use module_platform_driver() here.
Quoted 7 lines
drivers/leds/leds-sead3.c new file +4
-1+MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("SEAD3 LED driver" ); +MODULE_AUTHOR ("Kristian Kielhofner <[email protected]>" ); +MODULE_ALIAS ("platform:sead3-led" ); --1.9.3