diff --git a/[refs] b/[refs] index 0e03147bd515..0ec677522c7b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c029b55af7d6b02b993e8a5add78d062da7a3940 +refs/heads/master: 3694b91a59c3bc784735574878d36652dfd623c2 diff --git a/trunk/Documentation/00-INDEX b/trunk/Documentation/00-INDEX index 8dfc6708a257..9e642c5bf526 100644 --- a/trunk/Documentation/00-INDEX +++ b/trunk/Documentation/00-INDEX @@ -232,8 +232,6 @@ memory.txt - info on typical Linux memory problems. mips/ - directory with info about Linux on MIPS architecture. -mmc/ - - directory with info about the MMC subsystem mono.txt - how to execute Mono-based .NET binaries with the help of BINFMT_MISC. mutex-design.txt diff --git a/trunk/Documentation/cpu-hotplug.txt b/trunk/Documentation/cpu-hotplug.txt index 45d5a217484f..a99d7031cdf9 100644 --- a/trunk/Documentation/cpu-hotplug.txt +++ b/trunk/Documentation/cpu-hotplug.txt @@ -2,7 +2,7 @@ Maintainers: CPU Hotplug Core: - Rusty Russell + Rusty Russell Srivatsa Vaddagiri i386: Zwane Mwaikambo diff --git a/trunk/Documentation/devices.txt b/trunk/Documentation/devices.txt index d0d1df6cb5de..f2da781705b2 100644 --- a/trunk/Documentation/devices.txt +++ b/trunk/Documentation/devices.txt @@ -445,7 +445,6 @@ Your cooperation is appreciated. 233 = /dev/kmview View-OS A process with a view 234 = /dev/btrfs-control Btrfs control device 235 = /dev/autofs Autofs control device - 236 = /dev/mapper/control Device-Mapper control device 240-254 Reserved for local use 255 Reserved for MISC_DYNAMIC_MINOR diff --git a/trunk/Documentation/i2c/instantiating-devices b/trunk/Documentation/i2c/instantiating-devices index 87da405a8597..e89490270aba 100644 --- a/trunk/Documentation/i2c/instantiating-devices +++ b/trunk/Documentation/i2c/instantiating-devices @@ -102,7 +102,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) memset(&i2c_info, 0, sizeof(struct i2c_board_info)); strlcpy(i2c_info.name, "isp1301_pnx", I2C_NAME_SIZE); isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, - normal_i2c, NULL); + normal_i2c); i2c_put_adapter(i2c_adap); (...) } diff --git a/trunk/Documentation/mmc/00-INDEX b/trunk/Documentation/mmc/00-INDEX deleted file mode 100644 index fca586f5b853..000000000000 --- a/trunk/Documentation/mmc/00-INDEX +++ /dev/null @@ -1,4 +0,0 @@ -00-INDEX - - this file -mmc-dev-attrs.txt - - info on SD and MMC device attributes diff --git a/trunk/Documentation/mmc/mmc-dev-attrs.txt b/trunk/Documentation/mmc/mmc-dev-attrs.txt deleted file mode 100644 index ff2bd685bced..000000000000 --- a/trunk/Documentation/mmc/mmc-dev-attrs.txt +++ /dev/null @@ -1,56 +0,0 @@ -SD and MMC Device Attributes -============================ - -All attributes are read-only. - - cid Card Identifaction Register - csd Card Specific Data Register - scr SD Card Configuration Register (SD only) - date Manufacturing Date (from CID Register) - fwrev Firmware/Product Revision (from CID Register) (SD and MMCv1 only) - hwrev Hardware/Product Revision (from CID Register) (SD and MMCv1 only) - manfid Manufacturer ID (from CID Register) - name Product Name (from CID Register) - oemid OEM/Application ID (from CID Register) - serial Product Serial Number (from CID Register) - erase_size Erase group size - preferred_erase_size Preferred erase size - -Note on Erase Size and Preferred Erase Size: - - "erase_size" is the minimum size, in bytes, of an erase - operation. For MMC, "erase_size" is the erase group size - reported by the card. Note that "erase_size" does not apply - to trim or secure trim operations where the minimum size is - always one 512 byte sector. For SD, "erase_size" is 512 - if the card is block-addressed, 0 otherwise. - - SD/MMC cards can erase an arbitrarily large area up to and - including the whole card. When erasing a large area it may - be desirable to do it in smaller chunks for three reasons: - 1. A single erase command will make all other I/O on - the card wait. This is not a problem if the whole card - is being erased, but erasing one partition will make - I/O for another partition on the same card wait for the - duration of the erase - which could be a several - minutes. - 2. To be able to inform the user of erase progress. - 3. The erase timeout becomes too large to be very - useful. Because the erase timeout contains a margin - which is multiplied by the size of the erase area, - the value can end up being several minutes for large - areas. - - "erase_size" is not the most efficient unit to erase - (especially for SD where it is just one sector), - hence "preferred_erase_size" provides a good chunk - size for erasing large areas. - - For MMC, "preferred_erase_size" is the high-capacity - erase size if a card specifies one, otherwise it is - based on the capacity of the card. - - For SD, "preferred_erase_size" is the allocation unit - size specified by the card. - - "preferred_erase_size" is in bytes. diff --git a/trunk/Documentation/sound/alsa/HD-Audio-Models.txt b/trunk/Documentation/sound/alsa/HD-Audio-Models.txt index ce46fa1e643e..03771d7c5dd7 100644 --- a/trunk/Documentation/sound/alsa/HD-Audio-Models.txt +++ b/trunk/Documentation/sound/alsa/HD-Audio-Models.txt @@ -83,8 +83,8 @@ ALC269 ====== basic Basic preset quanta Quanta FL1 - laptop-amic Laptops with analog-mic input - laptop-dmic Laptops with digital-mic input + eeepc-p703 ASUS Eeepc P703 P900A + eeepc-p901 ASUS Eeepc P901 S101 fujitsu FSC Amilo lifebook Fujitsu Lifebook S6420 auto auto-config reading BIOS (default) @@ -109,8 +109,6 @@ ALC662/663/272 asus-mode4 ASUS asus-mode5 ASUS asus-mode6 ASUS - asus-mode7 ASUS - asus-mode8 ASUS dell Dell with ALC272 dell-zm1 Dell ZM1 with ALC272 samsung-nc10 Samsung NC10 mini notebook @@ -297,10 +295,8 @@ Conexant 5066 ============= laptop Basic Laptop config (default) dell-laptop Dell laptops - dell-vostro Dell Vostro olpc-xo-1_5 OLPC XO 1.5 ideapad Lenovo IdeaPad U150 - thinkpad Lenovo Thinkpad STAC9200 ======== @@ -408,7 +404,6 @@ STAC92HD83* mic-ref Reference board with power management for ports dell-s14 Dell laptop hp HP laptops with (inverted) mute-LED - hp-dv7-4000 HP dv-7 4000 auto BIOS setup (default) STAC9872 @@ -421,7 +416,3 @@ Cirrus Logic CS4206/4207 mbp55 MacBook Pro 5,5 imac27 IMac 27 Inch auto BIOS setup (default) - -VIA VT17xx/VT18xx/VT20xx -======================== - auto BIOS setup (default) diff --git a/trunk/arch/arm/mach-msm/Makefile b/trunk/arch/arm/mach-msm/Makefile index 704610648a25..7ff8020d4d24 100644 --- a/trunk/arch/arm/mach-msm/Makefile +++ b/trunk/arch/arm/mach-msm/Makefile @@ -15,7 +15,7 @@ obj-$(CONFIG_ARCH_QSD8X50) += sirc.o obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o obj-$(CONFIG_MSM_SMD) += last_radio_log.o -obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o devices-msm7x00.o +obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o devices-msm7x00.o obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o diff --git a/trunk/arch/arm/mach-msm/acpuclock-arm11.c b/trunk/arch/arm/mach-msm/acpuclock-arm11.c index 7ffbd987eb5d..f060a3959a75 100644 --- a/trunk/arch/arm/mach-msm/acpuclock-arm11.c +++ b/trunk/arch/arm/mach-msm/acpuclock-arm11.c @@ -17,6 +17,7 @@ * */ +#include #include #include #include diff --git a/trunk/arch/arm/mach-msm/board-trout-gpio.c b/trunk/arch/arm/mach-msm/board-trout-gpio.c index c50f3afc3134..523d213bf79e 100644 --- a/trunk/arch/arm/mach-msm/board-trout-gpio.c +++ b/trunk/arch/arm/mach-msm/board-trout-gpio.c @@ -15,20 +15,10 @@ #include #include #include -#include #include #include "board-trout.h" -static uint8_t trout_int_mask[2] = { - [0] = 0xff, /* mask all interrupts */ - [1] = 0xff, -}; -static uint8_t trout_sleep_int_mask[] = { - [0] = 0xff, - [1] = 0xff, -}; - struct msm_gpio_chip { struct gpio_chip chip; void __iomem *reg; /* Base of register bank */ @@ -105,121 +95,16 @@ static struct msm_gpio_chip msm_gpio_banks[] = { TROUT_GPIO_BANK("VIRTUAL", 0x12, TROUT_GPIO_VIRTUAL_BASE, 0), }; -static void trout_gpio_irq_ack(unsigned int irq) -{ - int bank = TROUT_INT_TO_BANK(irq); - uint8_t mask = TROUT_INT_TO_MASK(irq); - int reg = TROUT_BANK_TO_STAT_REG(bank); - /*printk(KERN_INFO "trout_gpio_irq_ack irq %d\n", irq);*/ - writeb(mask, TROUT_CPLD_BASE + reg); -} - -static void trout_gpio_irq_mask(unsigned int irq) -{ - unsigned long flags; - uint8_t reg_val; - int bank = TROUT_INT_TO_BANK(irq); - uint8_t mask = TROUT_INT_TO_MASK(irq); - int reg = TROUT_BANK_TO_MASK_REG(bank); - - local_irq_save(flags); - reg_val = trout_int_mask[bank] |= mask; - /*printk(KERN_INFO "trout_gpio_irq_mask irq %d => %d:%02x\n", - irq, bank, reg_val);*/ - writeb(reg_val, TROUT_CPLD_BASE + reg); - local_irq_restore(flags); -} - -static void trout_gpio_irq_unmask(unsigned int irq) -{ - unsigned long flags; - uint8_t reg_val; - int bank = TROUT_INT_TO_BANK(irq); - uint8_t mask = TROUT_INT_TO_MASK(irq); - int reg = TROUT_BANK_TO_MASK_REG(bank); - - local_irq_save(flags); - reg_val = trout_int_mask[bank] &= ~mask; - /*printk(KERN_INFO "trout_gpio_irq_unmask irq %d => %d:%02x\n", - irq, bank, reg_val);*/ - writeb(reg_val, TROUT_CPLD_BASE + reg); - local_irq_restore(flags); -} - -int trout_gpio_irq_set_wake(unsigned int irq, unsigned int on) -{ - unsigned long flags; - int bank = TROUT_INT_TO_BANK(irq); - uint8_t mask = TROUT_INT_TO_MASK(irq); - - local_irq_save(flags); - if(on) - trout_sleep_int_mask[bank] &= ~mask; - else - trout_sleep_int_mask[bank] |= mask; - local_irq_restore(flags); - return 0; -} - -static void trout_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) -{ - int j, m; - unsigned v; - int bank; - int stat_reg; - int int_base = TROUT_INT_START; - uint8_t int_mask; - - for (bank = 0; bank < 2; bank++) { - stat_reg = TROUT_BANK_TO_STAT_REG(bank); - v = readb(TROUT_CPLD_BASE + stat_reg); - int_mask = trout_int_mask[bank]; - if (v & int_mask) { - writeb(v & int_mask, TROUT_CPLD_BASE + stat_reg); - printk(KERN_ERR "trout_gpio_irq_handler: got masked " - "interrupt: %d:%02x\n", bank, v & int_mask); - } - v &= ~int_mask; - while (v) { - m = v & -v; - j = fls(m) - 1; - /*printk(KERN_INFO "msm_gpio_irq_handler %d:%02x %02x b" - "it %d irq %d\n", bank, v, m, j, int_base + j);*/ - v &= ~m; - generic_handle_irq(int_base + j); - } - int_base += TROUT_INT_BANK0_COUNT; - } - desc->chip->ack(irq); -} - -static struct irq_chip trout_gpio_irq_chip = { - .name = "troutgpio", - .ack = trout_gpio_irq_ack, - .mask = trout_gpio_irq_mask, - .unmask = trout_gpio_irq_unmask, - .set_wake = trout_gpio_irq_set_wake, -}; - /* * Called from the processor-specific init to enable GPIO pin support. */ int __init trout_init_gpio(void) { int i; - for(i = TROUT_INT_START; i <= TROUT_INT_END; i++) { - set_irq_chip(i, &trout_gpio_irq_chip); - set_irq_handler(i, handle_edge_irq); - set_irq_flags(i, IRQF_VALID); - } for (i = 0; i < ARRAY_SIZE(msm_gpio_banks); i++) gpiochip_add(&msm_gpio_banks[i].chip); - set_irq_type(MSM_GPIO_TO_INT(17), IRQF_TRIGGER_HIGH); - set_irq_chained_handler(MSM_GPIO_TO_INT(17), trout_gpio_irq_handler); - set_irq_wake(MSM_GPIO_TO_INT(17), 1); - return 0; } diff --git a/trunk/arch/arm/mach-msm/board-trout-mmc.c b/trunk/arch/arm/mach-msm/board-trout-mmc.c deleted file mode 100644 index 44be8464657b..000000000000 --- a/trunk/arch/arm/mach-msm/board-trout-mmc.c +++ /dev/null @@ -1,186 +0,0 @@ -/* linux/arch/arm/mach-msm/board-trout-mmc.c -** Author: Brian Swetland -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include "devices.h" - -#include "board-trout.h" - -#include "proc_comm.h" - -#define DEBUG_SDSLOT_VDD 1 - -/* ---- COMMON ---- */ -static void config_gpio_table(uint32_t *table, int len) -{ - int n; - unsigned id; - for(n = 0; n < len; n++) { - id = table[n]; - msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0); - } -} - -/* ---- SDCARD ---- */ - -static uint32_t sdcard_on_gpio_table[] = { - PCOM_GPIO_CFG(62, 2, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA), /* CLK */ - PCOM_GPIO_CFG(63, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), /* CMD */ - PCOM_GPIO_CFG(64, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), /* DAT3 */ - PCOM_GPIO_CFG(65, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), /* DAT2 */ - PCOM_GPIO_CFG(66, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_4MA), /* DAT1 */ - PCOM_GPIO_CFG(67, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_4MA), /* DAT0 */ -}; - -static uint32_t sdcard_off_gpio_table[] = { - PCOM_GPIO_CFG(62, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* CLK */ - PCOM_GPIO_CFG(63, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* CMD */ - PCOM_GPIO_CFG(64, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* DAT3 */ - PCOM_GPIO_CFG(65, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* DAT2 */ - PCOM_GPIO_CFG(66, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* DAT1 */ - PCOM_GPIO_CFG(67, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), /* DAT0 */ -}; - -static uint opt_disable_sdcard; - -static int __init trout_disablesdcard_setup(char *str) -{ - int cal = simple_strtol(str, NULL, 0); - - opt_disable_sdcard = cal; - return 1; -} - -__setup("board_trout.disable_sdcard=", trout_disablesdcard_setup); - -static struct vreg *vreg_sdslot; /* SD slot power */ - -struct mmc_vdd_xlat { - int mask; - int level; -}; - -static struct mmc_vdd_xlat mmc_vdd_table[] = { - { MMC_VDD_165_195, 1800 }, - { MMC_VDD_20_21, 2050 }, - { MMC_VDD_21_22, 2150 }, - { MMC_VDD_22_23, 2250 }, - { MMC_VDD_23_24, 2350 }, - { MMC_VDD_24_25, 2450 }, - { MMC_VDD_25_26, 2550 }, - { MMC_VDD_26_27, 2650 }, - { MMC_VDD_27_28, 2750 }, - { MMC_VDD_28_29, 2850 }, - { MMC_VDD_29_30, 2950 }, -}; - -static unsigned int sdslot_vdd = 0xffffffff; -static unsigned int sdslot_vreg_enabled; - -static uint32_t trout_sdslot_switchvdd(struct device *dev, unsigned int vdd) -{ - int i, rc; - - BUG_ON(!vreg_sdslot); - - if (vdd == sdslot_vdd) - return 0; - - sdslot_vdd = vdd; - - if (vdd == 0) { -#if DEBUG_SDSLOT_VDD - printk("%s: Disabling SD slot power\n", __func__); -#endif - config_gpio_table(sdcard_off_gpio_table, - ARRAY_SIZE(sdcard_off_gpio_table)); - vreg_disable(vreg_sdslot); - sdslot_vreg_enabled = 0; - return 0; - } - - if (!sdslot_vreg_enabled) { - rc = vreg_enable(vreg_sdslot); - if (rc) { - printk(KERN_ERR "%s: Error enabling vreg (%d)\n", - __func__, rc); - } - config_gpio_table(sdcard_on_gpio_table, - ARRAY_SIZE(sdcard_on_gpio_table)); - sdslot_vreg_enabled = 1; - } - - for (i = 0; i < ARRAY_SIZE(mmc_vdd_table); i++) { - if (mmc_vdd_table[i].mask == (1 << vdd)) { -#if DEBUG_SDSLOT_VDD - printk("%s: Setting level to %u\n", - __func__, mmc_vdd_table[i].level); -#endif - rc = vreg_set_level(vreg_sdslot, - mmc_vdd_table[i].level); - if (rc) { - printk(KERN_ERR - "%s: Error setting vreg level (%d)\n", - __func__, rc); - } - return 0; - } - } - - printk(KERN_ERR "%s: Invalid VDD %d specified\n", __func__, vdd); - return 0; -} - -static unsigned int trout_sdslot_status(struct device *dev) -{ - unsigned int status; - - status = (unsigned int) gpio_get_value(TROUT_GPIO_SDMC_CD_N); - return (!status); -} - -#define TROUT_MMC_VDD MMC_VDD_165_195 | MMC_VDD_20_21 | MMC_VDD_21_22 \ - | MMC_VDD_22_23 | MMC_VDD_23_24 | MMC_VDD_24_25 \ - | MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 \ - | MMC_VDD_28_29 | MMC_VDD_29_30 - -static struct msm_mmc_platform_data trout_sdslot_data = { - .ocr_mask = TROUT_MMC_VDD, - .status = trout_sdslot_status, - .translate_vdd = trout_sdslot_switchvdd, -}; - -int __init trout_init_mmc(unsigned int sys_rev) -{ - sdslot_vreg_enabled = 0; - - vreg_sdslot = vreg_get(0, "gp6"); - if (IS_ERR(vreg_sdslot)) - return PTR_ERR(vreg_sdslot); - - set_irq_wake(TROUT_GPIO_TO_INT(TROUT_GPIO_SDMC_CD_N), 1); - - if (!opt_disable_sdcard) - msm_add_sdcc(2, &trout_sdslot_data, - TROUT_GPIO_TO_INT(TROUT_GPIO_SDMC_CD_N), 0); - else - printk(KERN_INFO "trout: SD-Card interface disabled\n"); - return 0; -} - diff --git a/trunk/arch/arm/mach-msm/board-trout.c b/trunk/arch/arm/mach-msm/board-trout.c index 469e0be3499d..e69a1502e4e8 100644 --- a/trunk/arch/arm/mach-msm/board-trout.c +++ b/trunk/arch/arm/mach-msm/board-trout.c @@ -30,8 +30,6 @@ #include "devices.h" #include "board-trout.h" -extern int trout_init_mmc(unsigned int); - static struct platform_device *devices[] __initdata = { &msm_device_uart3, &msm_device_smd, @@ -57,16 +55,7 @@ static void __init trout_fixup(struct machine_desc *desc, struct tag *tags, static void __init trout_init(void) { - int rc; - platform_add_devices(devices, ARRAY_SIZE(devices)); - -#ifdef CONFIG_MMC - rc = trout_init_mmc(system_rev); - if (rc) - printk(KERN_CRIT "%s: MMC init failure (%d)\n", __func__, rc); -#endif - } static struct map_desc trout_io_desc[] __initdata = { diff --git a/trunk/arch/arm/mach-msm/clock.c b/trunk/arch/arm/mach-msm/clock.c index c57210f4f06a..9cb1276ab749 100644 --- a/trunk/arch/arm/mach-msm/clock.c +++ b/trunk/arch/arm/mach-msm/clock.c @@ -14,6 +14,7 @@ * */ +#include #include #include #include diff --git a/trunk/arch/arm/mach-msm/devices-msm7x00.c b/trunk/arch/arm/mach-msm/devices-msm7x00.c index 4e8c0bcdc92d..fde9d8f69f10 100644 --- a/trunk/arch/arm/mach-msm/devices-msm7x00.c +++ b/trunk/arch/arm/mach-msm/devices-msm7x00.c @@ -322,8 +322,7 @@ static struct platform_device *msm_sdcc_devices[] __initdata = { &msm_device_sdc4, }; -int __init msm_add_sdcc(unsigned int controller, - struct msm_mmc_platform_data *plat, +int __init msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat, unsigned int stat_irq, unsigned long stat_irq_flags) { struct platform_device *pdev; diff --git a/trunk/arch/arm/mach-msm/include/mach/board.h b/trunk/arch/arm/mach-msm/include/mach/board.h index 5a79bcf50413..e302fbdc439b 100644 --- a/trunk/arch/arm/mach-msm/include/mach/board.h +++ b/trunk/arch/arm/mach-msm/include/mach/board.h @@ -18,7 +18,6 @@ #define __ASM_ARCH_MSM_BOARD_H #include -#include /* platform device data structures */ @@ -41,8 +40,5 @@ void __init msm_init_irq(void); void __init msm_init_gpio(void); void __init msm_clock_init(struct clk *clock_tbl, unsigned num_clocks); void __init msm_acpu_clock_init(struct msm_acpu_clock_platform_data *); -int __init msm_add_sdcc(unsigned int controller, - struct msm_mmc_platform_data *plat, - unsigned int stat_irq, unsigned long stat_irq_flags); #endif diff --git a/trunk/arch/arm/mach-msm/include/mach/mmc.h b/trunk/arch/arm/mach-msm/include/mach/mmc.h index d54b6b086cff..0ecf25426284 100644 --- a/trunk/arch/arm/mach-msm/include/mach/mmc.h +++ b/trunk/arch/arm/mach-msm/include/mach/mmc.h @@ -15,7 +15,7 @@ struct embedded_sdio_data { int num_funcs; }; -struct msm_mmc_platform_data { +struct mmc_platform_data { unsigned int ocr_mask; /* available voltages */ u32 (*translate_vdd)(struct device *, unsigned int); unsigned int (*status)(struct device *); diff --git a/trunk/arch/arm/mach-msm/smd.c b/trunk/arch/arm/mach-msm/smd.c index f07dc7c738f0..cf11d414b425 100644 --- a/trunk/arch/arm/mach-msm/smd.c +++ b/trunk/arch/arm/mach-msm/smd.c @@ -997,7 +997,7 @@ int smd_core_init(void) return 0; } -static int __devinit msm_smd_probe(struct platform_device *pdev) +static int __init msm_smd_probe(struct platform_device *pdev) { pr_info("smd_init()\n"); diff --git a/trunk/arch/cris/include/asm/pgtable.h b/trunk/arch/cris/include/asm/pgtable.h index f63d6fccbc6c..99ea6cd1b143 100644 --- a/trunk/arch/cris/include/asm/pgtable.h +++ b/trunk/arch/cris/include/asm/pgtable.h @@ -260,9 +260,6 @@ static inline pgd_t * pgd_offset(const struct mm_struct *mm, unsigned long addre #define pgd_ERROR(e) \ printk("%s:%d: bad pgd %p(%08lx).\n", __FILE__, __LINE__, &(e), pgd_val(e)) -#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ - remap_pfn_range(vma, vaddr, pfn, size, prot) - extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; /* defined in head.S */ diff --git a/trunk/arch/ia64/include/asm/rwsem.h b/trunk/arch/ia64/include/asm/rwsem.h index 215d5454c7d3..e8762688e8e3 100644 --- a/trunk/arch/ia64/include/asm/rwsem.h +++ b/trunk/arch/ia64/include/asm/rwsem.h @@ -40,9 +40,9 @@ struct rw_semaphore { }; #define RWSEM_UNLOCKED_VALUE __IA64_UL_CONST(0x0000000000000000) -#define RWSEM_ACTIVE_BIAS (1L) -#define RWSEM_ACTIVE_MASK (0xffffffffL) -#define RWSEM_WAITING_BIAS (-0x100000000L) +#define RWSEM_ACTIVE_BIAS __IA64_UL_CONST(0x0000000000000001) +#define RWSEM_ACTIVE_MASK __IA64_UL_CONST(0x00000000ffffffff) +#define RWSEM_WAITING_BIAS -__IA64_UL_CONST(0x0000000100000000) #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) diff --git a/trunk/arch/mn10300/boot/compressed/misc.c b/trunk/arch/mn10300/boot/compressed/misc.c index 42cbd77bd439..f673383518e4 100644 --- a/trunk/arch/mn10300/boot/compressed/misc.c +++ b/trunk/arch/mn10300/boot/compressed/misc.c @@ -167,7 +167,6 @@ static uch *high_buffer_start /* = (uch *)(((ulg)&end) + HEAP_SIZE)*/; static char *vidmem = (char *)0xb8000; static int lines, cols; -#define BOOTLOADER_INFLATE #include "../../../../lib/inflate.c" static inline void scroll(void) diff --git a/trunk/arch/mn10300/include/asm/gdb-stub.h b/trunk/arch/mn10300/include/asm/gdb-stub.h index 41ed26763964..556cce992548 100644 --- a/trunk/arch/mn10300/include/asm/gdb-stub.h +++ b/trunk/arch/mn10300/include/asm/gdb-stub.h @@ -157,25 +157,25 @@ void gdbstub_printk(const char *fmt, ...) #ifdef CONFIG_GDBSTUB_DEBUG_ENTRY #define gdbstub_entry(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__) #else -#define gdbstub_entry(FMT, ...) no_printk(FMT, ##__VA_ARGS__) +#define gdbstub_entry(FMT, ...) ({ 0; }) #endif #ifdef CONFIG_GDBSTUB_DEBUG_PROTOCOL #define gdbstub_proto(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__) #else -#define gdbstub_proto(FMT, ...) no_printk(FMT, ##__VA_ARGS__) +#define gdbstub_proto(FMT, ...) ({ 0; }) #endif #ifdef CONFIG_GDBSTUB_DEBUG_IO #define gdbstub_io(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__) #else -#define gdbstub_io(FMT, ...) no_printk(FMT, ##__VA_ARGS__) +#define gdbstub_io(FMT, ...) ({ 0; }) #endif #ifdef CONFIG_GDBSTUB_DEBUG_BREAKPOINT #define gdbstub_bkpt(FMT, ...) gdbstub_printk(FMT, ##__VA_ARGS__) #else -#define gdbstub_bkpt(FMT, ...) no_printk(FMT, ##__VA_ARGS__) +#define gdbstub_bkpt(FMT, ...) ({ 0; }) #endif #endif /* !__ASSEMBLY__ */ diff --git a/trunk/arch/mn10300/include/asm/posix_types.h b/trunk/arch/mn10300/include/asm/posix_types.h index 56ffbc158798..077567c37798 100644 --- a/trunk/arch/mn10300/include/asm/posix_types.h +++ b/trunk/arch/mn10300/include/asm/posix_types.h @@ -25,13 +25,8 @@ typedef int __kernel_pid_t; typedef unsigned short __kernel_ipc_pid_t; typedef unsigned short __kernel_uid_t; typedef unsigned short __kernel_gid_t; -#if __GNUC__ == 4 -typedef unsigned int __kernel_size_t; -typedef signed int __kernel_ssize_t; -#else typedef unsigned long __kernel_size_t; -typedef signed long __kernel_ssize_t; -#endif +typedef long __kernel_ssize_t; typedef int __kernel_ptrdiff_t; typedef long __kernel_time_t; typedef long __kernel_suseconds_t; diff --git a/trunk/arch/mn10300/kernel/mn10300-serial.c b/trunk/arch/mn10300/kernel/mn10300-serial.c index 9d49073e827a..ef34d5a0f8bd 100644 --- a/trunk/arch/mn10300/kernel/mn10300-serial.c +++ b/trunk/arch/mn10300/kernel/mn10300-serial.c @@ -44,6 +44,11 @@ static const char serial_revdate[] = "2007-11-06"; #include #include "mn10300-serial.h" +static inline __attribute__((format(printf, 1, 2))) +void no_printk(const char *fmt, ...) +{ +} + #define kenter(FMT, ...) \ printk(KERN_DEBUG "-->%s(" FMT ")\n", __func__, ##__VA_ARGS__) #define _enter(FMT, ...) \ diff --git a/trunk/arch/mn10300/kernel/rtc.c b/trunk/arch/mn10300/kernel/rtc.c index 4eef0e7224f6..815a933aafa8 100644 --- a/trunk/arch/mn10300/kernel/rtc.c +++ b/trunk/arch/mn10300/kernel/rtc.c @@ -20,6 +20,9 @@ DEFINE_SPINLOCK(rtc_lock); EXPORT_SYMBOL(rtc_lock); +/* last time the RTC got updated */ +static long last_rtc_update; + /* time for RTC to update itself in ioclks */ static unsigned long mn10300_rtc_update_period; @@ -107,7 +110,7 @@ static int set_rtc_mmss(unsigned long nowtime) int update_persistent_clock(struct timespec now) { - return set_rtc_mmss(now.tv_sec); + return set_rtc_mms(now.tv_sec); } /* diff --git a/trunk/arch/parisc/mm/ioremap.c b/trunk/arch/parisc/mm/ioremap.c index 838d0259cd27..92d496ad07c9 100644 --- a/trunk/arch/parisc/mm/ioremap.c +++ b/trunk/arch/parisc/mm/ioremap.c @@ -71,7 +71,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l */ offset = phys_addr & ~PAGE_MASK; phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr + 1) - phys_addr; + size = PAGE_ALIGN(last_addr) - phys_addr; /* * Ok, go for it.. diff --git a/trunk/arch/powerpc/platforms/83xx/mpc837x_mds.c b/trunk/arch/powerpc/platforms/83xx/mpc837x_mds.c index f9751c8905be..51df7e754698 100644 --- a/trunk/arch/powerpc/platforms/83xx/mpc837x_mds.c +++ b/trunk/arch/powerpc/platforms/83xx/mpc837x_mds.c @@ -102,7 +102,7 @@ static struct of_device_id mpc837x_ids[] = { static int __init mpc837x_declare_of_platform_devices(void) { - /* Publish platform_device */ + /* Publish of_device */ of_platform_bus_probe(NULL, mpc837x_ids, NULL); return 0; diff --git a/trunk/arch/powerpc/platforms/83xx/mpc837x_rdb.c b/trunk/arch/powerpc/platforms/83xx/mpc837x_rdb.c index 910caa6b5810..e00801c42540 100644 --- a/trunk/arch/powerpc/platforms/83xx/mpc837x_rdb.c +++ b/trunk/arch/powerpc/platforms/83xx/mpc837x_rdb.c @@ -78,7 +78,7 @@ static struct of_device_id mpc837x_ids[] = { static int __init mpc837x_declare_of_platform_devices(void) { - /* Publish platform_device */ + /* Publish of_device */ of_platform_bus_probe(NULL, mpc837x_ids, NULL); return 0; diff --git a/trunk/arch/powerpc/sysdev/fsl_rio.c b/trunk/arch/powerpc/sysdev/fsl_rio.c index 6425abe5b7db..8bd86530ee25 100644 --- a/trunk/arch/powerpc/sysdev/fsl_rio.c +++ b/trunk/arch/powerpc/sysdev/fsl_rio.c @@ -1332,7 +1332,7 @@ static inline void fsl_rio_info(struct device *dev, u32 ccsr) /** * fsl_rio_setup - Setup Freescale PowerPC RapidIO interface - * @dev: platform_device pointer + * @dev: of_device pointer * * Initializes MPC85xx RapidIO hardware interface, configures * master port with system-specific info, and registers the diff --git a/trunk/arch/score/mm/tlb-score.c b/trunk/arch/score/mm/tlb-score.c index 6fdb100244c8..4fa5aa5afecc 100644 --- a/trunk/arch/score/mm/tlb-score.c +++ b/trunk/arch/score/mm/tlb-score.c @@ -158,7 +158,7 @@ void local_flush_tlb_kernel_range(unsigned long start, unsigned long end) void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) { - if (vma && vma->vm_mm->context != 0) { + if (!vma || vma->vm_mm->context != 0) { unsigned long flags; int oldpid, newpid, idx; unsigned long vma_ASID = vma->vm_mm->context; diff --git a/trunk/arch/um/drivers/hostaudio_kern.c b/trunk/arch/um/drivers/hostaudio_kern.c index 0c46e398cd8f..68142df76608 100644 --- a/trunk/arch/um/drivers/hostaudio_kern.c +++ b/trunk/arch/um/drivers/hostaudio_kern.c @@ -187,9 +187,7 @@ static int hostaudio_open(struct inode *inode, struct file *file) int ret; #ifdef DEBUG - kparam_block_sysfs_write(dsp); printk(KERN_DEBUG "hostaudio: open called (host: %s)\n", dsp); - kparam_unblock_sysfs_write(dsp); #endif state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL); @@ -201,11 +199,9 @@ static int hostaudio_open(struct inode *inode, struct file *file) if (file->f_mode & FMODE_WRITE) w = 1; - kparam_block_sysfs_write(dsp); lock_kernel(); ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0); unlock_kernel(); - kparam_unblock_sysfs_write(dsp); if (ret < 0) { kfree(state); @@ -262,17 +258,13 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file) if (file->f_mode & FMODE_WRITE) w = 1; - kparam_block_sysfs_write(mixer); lock_kernel(); ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0); unlock_kernel(); - kparam_unblock_sysfs_write(mixer); if (ret < 0) { - kparam_block_sysfs_write(dsp); printk(KERN_ERR "hostaudio_open_mixdev failed to open '%s', " "err = %d\n", dsp, -ret); - kparam_unblock_sysfs_write(dsp); kfree(state); return ret; } @@ -328,10 +320,8 @@ MODULE_LICENSE("GPL"); static int __init hostaudio_init_module(void) { - __kernel_param_lock(); printk(KERN_INFO "UML Audio Relay (host dsp = %s, host mixer = %s)\n", dsp, mixer); - __kernel_param_unlock(); module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1); if (module_data.dev_audio < 0) { diff --git a/trunk/arch/x86/include/asm/page.h b/trunk/arch/x86/include/asm/page.h index 8ca82839288a..625c3f0e741a 100644 --- a/trunk/arch/x86/include/asm/page.h +++ b/trunk/arch/x86/include/asm/page.h @@ -37,13 +37,6 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr, #define __pa_nodebug(x) __phys_addr_nodebug((unsigned long)(x)) /* __pa_symbol should be used for C visible symbols. This seems to be the official gcc blessed way to do such arithmetic. */ -/* - * We need __phys_reloc_hide() here because gcc may assume that there is no - * overflow during __pa() calculation and can optimize it unexpectedly. - * Newer versions of gcc provide -fno-strict-overflow switch to handle this - * case properly. Once all supported versions of gcc understand it, we can - * remove this Voodoo magic stuff. (i.e. once gcc3.x is deprecated) - */ #define __pa_symbol(x) __pa(__phys_reloc_hide((unsigned long)(x))) #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) diff --git a/trunk/arch/x86/include/asm/xen/page.h b/trunk/arch/x86/include/asm/xen/page.h index bf5f7d32bd08..018a0a400799 100644 --- a/trunk/arch/x86/include/asm/xen/page.h +++ b/trunk/arch/x86/include/asm/xen/page.h @@ -112,9 +112,13 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine) */ static inline unsigned long mfn_to_local_pfn(unsigned long mfn) { + extern unsigned long max_mapnr; unsigned long pfn = mfn_to_pfn(mfn); - if (get_phys_to_machine(pfn) != mfn) - return -1; /* force !pfn_valid() */ + if ((pfn < max_mapnr) + && !xen_feature(XENFEAT_auto_translated_physmap) + && (get_phys_to_machine(pfn) != mfn)) + return max_mapnr; /* force !pfn_valid() */ + /* XXX fixme; not true with sparsemem */ return pfn; } diff --git a/trunk/arch/x86/include/asm/xen/swiotlb-xen.h b/trunk/arch/x86/include/asm/xen/swiotlb-xen.h deleted file mode 100644 index 1be1ab7d6a41..000000000000 --- a/trunk/arch/x86/include/asm/xen/swiotlb-xen.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _ASM_X86_SWIOTLB_XEN_H -#define _ASM_X86_SWIOTLB_XEN_H - -#ifdef CONFIG_SWIOTLB_XEN -extern int xen_swiotlb; -extern int __init pci_xen_swiotlb_detect(void); -extern void __init pci_xen_swiotlb_init(void); -#else -#define xen_swiotlb (0) -static inline int __init pci_xen_swiotlb_detect(void) { return 0; } -static inline void __init pci_xen_swiotlb_init(void) { } -#endif - -#endif /* _ASM_X86_SWIOTLB_XEN_H */ diff --git a/trunk/arch/x86/kernel/apic/apic.c b/trunk/arch/x86/kernel/apic/apic.c index e3b534cda49a..980508c79082 100644 --- a/trunk/arch/x86/kernel/apic/apic.c +++ b/trunk/arch/x86/kernel/apic/apic.c @@ -1606,7 +1606,7 @@ void __init init_apic_mappings(void) * acpi lapic path already maps that address in * acpi_register_lapic_address() */ - if (!acpi_lapic && !smp_found_config) + if (!acpi_lapic) set_fixmap_nocache(FIX_APIC_BASE, apic_phys); apic_printk(APIC_VERBOSE, "mapped APIC to %08lx (%08lx)\n", diff --git a/trunk/arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c b/trunk/arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c index 994230d4dc4e..a36de5bbb622 100644 --- a/trunk/arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c +++ b/trunk/arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c @@ -110,7 +110,7 @@ struct pcc_cpu { u32 output_offset; }; -static struct pcc_cpu __percpu *pcc_cpu_info; +static struct pcc_cpu *pcc_cpu_info; static int pcc_cpufreq_verify(struct cpufreq_policy *policy) { diff --git a/trunk/arch/x86/kernel/hpet.c b/trunk/arch/x86/kernel/hpet.c index 351f9c0fea1f..33dbcc4ec5ff 100644 --- a/trunk/arch/x86/kernel/hpet.c +++ b/trunk/arch/x86/kernel/hpet.c @@ -582,7 +582,7 @@ static void init_one_hpet_msi_clockevent(struct hpet_dev *hdev, int cpu) * scaled math multiplication factor for nanosecond to hpet tick * conversion. */ - hpet_freq = FSEC_PER_SEC; + hpet_freq = 1000000000000000ULL; do_div(hpet_freq, hpet_period); evt->mult = div_sc((unsigned long) hpet_freq, NSEC_PER_SEC, evt->shift); @@ -837,7 +837,7 @@ static int hpet_clocksource_register(void) * cyc/sec = FSEC_PER_SEC/hpet_period(fsec/cyc) * cyc/sec = (FSEC_PER_NSEC * NSEC_PER_SEC)/hpet_period */ - hpet_freq = FSEC_PER_SEC; + hpet_freq = FSEC_PER_NSEC * NSEC_PER_SEC; do_div(hpet_freq, hpet_period); clocksource_register_hz(&clocksource_hpet, (u32)hpet_freq); diff --git a/trunk/arch/x86/kernel/mpparse.c b/trunk/arch/x86/kernel/mpparse.c index d7b6f7fb4fec..d86dbf7e54be 100644 --- a/trunk/arch/x86/kernel/mpparse.c +++ b/trunk/arch/x86/kernel/mpparse.c @@ -274,18 +274,6 @@ static void __init smp_dump_mptable(struct mpc_table *mpc, unsigned char *mpt) void __init default_smp_read_mpc_oem(struct mpc_table *mpc) { } -static void __init smp_register_lapic_address(unsigned long address) -{ - mp_lapic_addr = address; - - set_fixmap_nocache(FIX_APIC_BASE, address); - if (boot_cpu_physical_apicid == -1U) { - boot_cpu_physical_apicid = read_apic_id(); - apic_version[boot_cpu_physical_apicid] = - GET_APIC_VERSION(apic_read(APIC_LVR)); - } -} - static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early) { char str[16]; @@ -307,10 +295,6 @@ static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early) if (early) return 1; - /* Initialize the lapic mapping */ - if (!acpi_lapic) - smp_register_lapic_address(mpc->lapic); - if (mpc->oemptr) x86_init.mpparse.smp_read_mpc_oem(mpc); diff --git a/trunk/arch/x86/kernel/pci-dma.c b/trunk/arch/x86/kernel/pci-dma.c index 9f07cfcbd3a5..4b7e3d8b01dd 100644 --- a/trunk/arch/x86/kernel/pci-dma.c +++ b/trunk/arch/x86/kernel/pci-dma.c @@ -13,7 +13,6 @@ #include #include #include -#include static int forbid_dac __read_mostly; @@ -133,7 +132,7 @@ void __init pci_iommu_alloc(void) /* free the range so iommu could get some range less than 4G */ dma32_free_bootmem(); - if (pci_xen_swiotlb_detect() || pci_swiotlb_detect()) + if (pci_swiotlb_detect()) goto out; gart_iommu_hole_init(); @@ -145,8 +144,6 @@ void __init pci_iommu_alloc(void) /* needs to be called after gart_iommu_hole_init */ amd_iommu_detect(); out: - pci_xen_swiotlb_init(); - pci_swiotlb_init(); } @@ -299,7 +296,7 @@ static int __init pci_iommu_init(void) #endif x86_init.iommu.iommu_init(); - if (swiotlb || xen_swiotlb) { + if (swiotlb) { printk(KERN_INFO "PCI-DMA: " "Using software bounce buffering for IO (SWIOTLB)\n"); swiotlb_print_info(); diff --git a/trunk/arch/x86/lib/atomic64_386_32.S b/trunk/arch/x86/lib/atomic64_386_32.S index 2cda60a06e65..4a5979aa6883 100644 --- a/trunk/arch/x86/lib/atomic64_386_32.S +++ b/trunk/arch/x86/lib/atomic64_386_32.S @@ -25,172 +25,150 @@ CFI_ADJUST_CFA_OFFSET -4 .endm -#define BEGIN(op) \ -.macro endp; \ - CFI_ENDPROC; \ -ENDPROC(atomic64_##op##_386); \ -.purgem endp; \ -.endm; \ -ENTRY(atomic64_##op##_386); \ - CFI_STARTPROC; \ - LOCK v; - -#define ENDP endp - -#define RET \ - UNLOCK v; \ +.macro BEGIN func reg +$v = \reg + +ENTRY(atomic64_\func\()_386) + CFI_STARTPROC + LOCK $v + +.macro RETURN + UNLOCK $v ret +.endm + +.macro END_ + CFI_ENDPROC +ENDPROC(atomic64_\func\()_386) +.purgem RETURN +.purgem END_ +.purgem END +.endm + +.macro END +RETURN +END_ +.endm +.endm -#define RET_ENDP \ - RET; \ - ENDP - -#define v %ecx -BEGIN(read) - movl (v), %eax - movl 4(v), %edx -RET_ENDP -#undef v - -#define v %esi -BEGIN(set) - movl %ebx, (v) - movl %ecx, 4(v) -RET_ENDP -#undef v - -#define v %esi -BEGIN(xchg) - movl (v), %eax - movl 4(v), %edx - movl %ebx, (v) - movl %ecx, 4(v) -RET_ENDP -#undef v - -#define v %ecx -BEGIN(add) - addl %eax, (v) - adcl %edx, 4(v) -RET_ENDP -#undef v - -#define v %ecx -BEGIN(add_return) - addl (v), %eax - adcl 4(v), %edx - movl %eax, (v) - movl %edx, 4(v) -RET_ENDP -#undef v - -#define v %ecx -BEGIN(sub) - subl %eax, (v) - sbbl %edx, 4(v) -RET_ENDP -#undef v - -#define v %ecx -BEGIN(sub_return) +BEGIN read %ecx + movl ($v), %eax + movl 4($v), %edx +END + +BEGIN set %esi + movl %ebx, ($v) + movl %ecx, 4($v) +END + +BEGIN xchg %esi + movl ($v), %eax + movl 4($v), %edx + movl %ebx, ($v) + movl %ecx, 4($v) +END + +BEGIN add %ecx + addl %eax, ($v) + adcl %edx, 4($v) +END + +BEGIN add_return %ecx + addl ($v), %eax + adcl 4($v), %edx + movl %eax, ($v) + movl %edx, 4($v) +END + +BEGIN sub %ecx + subl %eax, ($v) + sbbl %edx, 4($v) +END + +BEGIN sub_return %ecx negl %edx negl %eax sbbl $0, %edx - addl (v), %eax - adcl 4(v), %edx - movl %eax, (v) - movl %edx, 4(v) -RET_ENDP -#undef v - -#define v %esi -BEGIN(inc) - addl $1, (v) - adcl $0, 4(v) -RET_ENDP -#undef v - -#define v %esi -BEGIN(inc_return) - movl (v), %eax - movl 4(v), %edx + addl ($v), %eax + adcl 4($v), %edx + movl %eax, ($v) + movl %edx, 4($v) +END + +BEGIN inc %esi + addl $1, ($v) + adcl $0, 4($v) +END + +BEGIN inc_return %esi + movl ($v), %eax + movl 4($v), %edx addl $1, %eax adcl $0, %edx - movl %eax, (v) - movl %edx, 4(v) -RET_ENDP -#undef v - -#define v %esi -BEGIN(dec) - subl $1, (v) - sbbl $0, 4(v) -RET_ENDP -#undef v - -#define v %esi -BEGIN(dec_return) - movl (v), %eax - movl 4(v), %edx + movl %eax, ($v) + movl %edx, 4($v) +END + +BEGIN dec %esi + subl $1, ($v) + sbbl $0, 4($v) +END + +BEGIN dec_return %esi + movl ($v), %eax + movl 4($v), %edx subl $1, %eax sbbl $0, %edx - movl %eax, (v) - movl %edx, 4(v) -RET_ENDP -#undef v + movl %eax, ($v) + movl %edx, 4($v) +END -#define v %ecx -BEGIN(add_unless) +BEGIN add_unless %ecx addl %eax, %esi adcl %edx, %edi - addl (v), %eax - adcl 4(v), %edx + addl ($v), %eax + adcl 4($v), %edx cmpl %eax, %esi je 3f 1: - movl %eax, (v) - movl %edx, 4(v) + movl %eax, ($v) + movl %edx, 4($v) movl $1, %eax 2: - RET +RETURN 3: cmpl %edx, %edi jne 1b xorl %eax, %eax jmp 2b -ENDP -#undef v +END_ -#define v %esi -BEGIN(inc_not_zero) - movl (v), %eax - movl 4(v), %edx +BEGIN inc_not_zero %esi + movl ($v), %eax + movl 4($v), %edx testl %eax, %eax je 3f 1: addl $1, %eax adcl $0, %edx - movl %eax, (v) - movl %edx, 4(v) + movl %eax, ($v) + movl %edx, 4($v) movl $1, %eax 2: - RET +RETURN 3: testl %edx, %edx jne 1b jmp 2b -ENDP -#undef v +END_ -#define v %esi -BEGIN(dec_if_positive) - movl (v), %eax - movl 4(v), %edx +BEGIN dec_if_positive %esi + movl ($v), %eax + movl 4($v), %edx subl $1, %eax sbbl $0, %edx js 1f - movl %eax, (v) - movl %edx, 4(v) + movl %eax, ($v) + movl %edx, 4($v) 1: -RET_ENDP -#undef v +END diff --git a/trunk/arch/x86/mm/fault.c b/trunk/arch/x86/mm/fault.c index 4c4508e8a204..f62777940dfb 100644 --- a/trunk/arch/x86/mm/fault.c +++ b/trunk/arch/x86/mm/fault.c @@ -802,10 +802,8 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address, up_read(&mm->mmap_sem); /* Kernel mode? Handle exceptions or die: */ - if (!(error_code & PF_USER)) { + if (!(error_code & PF_USER)) no_context(regs, error_code, address); - return; - } /* User-space => ok to do another page fault: */ if (is_prefetch(regs, error_code, address)) diff --git a/trunk/arch/x86/xen/Makefile b/trunk/arch/x86/xen/Makefile index 779385158915..930954685980 100644 --- a/trunk/arch/x86/xen/Makefile +++ b/trunk/arch/x86/xen/Makefile @@ -18,4 +18,3 @@ obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o -obj-$(CONFIG_SWIOTLB_XEN) += pci-swiotlb-xen.o diff --git a/trunk/arch/x86/xen/enlighten.c b/trunk/arch/x86/xen/enlighten.c index 7d46c8441418..d4ff5e83621d 100644 --- a/trunk/arch/x86/xen/enlighten.c +++ b/trunk/arch/x86/xen/enlighten.c @@ -1172,10 +1172,6 @@ asmlinkage void __init xen_start_kernel(void) pgd = (pgd_t *)xen_start_info->pt_base; - if (!xen_initial_domain()) - __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD); - - __supported_pte_mask |= _PAGE_IOMAP; /* Don't do the full vcpu_info placement stuff until we have a possible map and a non-dummy shared_info. */ per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; diff --git a/trunk/arch/x86/xen/mmu.c b/trunk/arch/x86/xen/mmu.c index 42086ac406af..413b19b3d0fe 100644 --- a/trunk/arch/x86/xen/mmu.c +++ b/trunk/arch/x86/xen/mmu.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include @@ -52,19 +51,15 @@ #include #include #include -#include #include -#include #include #include -#include #include #include #include #include -#include #include #include "multicalls.h" @@ -73,13 +68,6 @@ #define MMU_UPDATE_HISTO 30 -/* - * Protects atomic reservation decrease/increase against concurrent increases. - * Also protects non-atomic updates of current_pages and driver_pages, and - * balloon lists. - */ -DEFINE_SPINLOCK(xen_reservation_lock); - #ifdef CONFIG_XEN_DEBUG_FS static struct { @@ -390,28 +378,6 @@ static bool xen_page_pinned(void *ptr) return PagePinned(page); } -static bool xen_iomap_pte(pte_t pte) -{ - return pte_flags(pte) & _PAGE_IOMAP; -} - -static void xen_set_iomap_pte(pte_t *ptep, pte_t pteval) -{ - struct multicall_space mcs; - struct mmu_update *u; - - mcs = xen_mc_entry(sizeof(*u)); - u = mcs.args; - - /* ptep might be kmapped when using 32-bit HIGHPTE */ - u->ptr = arbitrary_virt_to_machine(ptep).maddr; - u->val = pte_val_ma(pteval); - - MULTI_mmu_update(mcs.mc, mcs.args, 1, NULL, DOMID_IO); - - xen_mc_issue(PARAVIRT_LAZY_MMU); -} - static void xen_extend_mmu_update(const struct mmu_update *update) { struct multicall_space mcs; @@ -488,11 +454,6 @@ void set_pte_mfn(unsigned long vaddr, unsigned long mfn, pgprot_t flags) void xen_set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval) { - if (xen_iomap_pte(pteval)) { - xen_set_iomap_pte(ptep, pteval); - goto out; - } - ADD_STATS(set_pte_at, 1); // ADD_STATS(set_pte_at_pinned, xen_page_pinned(ptep)); ADD_STATS(set_pte_at_current, mm == current->mm); @@ -563,25 +524,8 @@ static pteval_t pte_pfn_to_mfn(pteval_t val) return val; } -static pteval_t iomap_pte(pteval_t val) -{ - if (val & _PAGE_PRESENT) { - unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT; - pteval_t flags = val & PTE_FLAGS_MASK; - - /* We assume the pte frame number is a MFN, so - just use it as-is. */ - val = ((pteval_t)pfn << PAGE_SHIFT) | flags; - } - - return val; -} - pteval_t xen_pte_val(pte_t pte) { - if (xen_initial_domain() && (pte.pte & _PAGE_IOMAP)) - return pte.pte; - return pte_mfn_to_pfn(pte.pte); } PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val); @@ -594,22 +538,7 @@ PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val); pte_t xen_make_pte(pteval_t pte) { - phys_addr_t addr = (pte & PTE_PFN_MASK); - - /* - * Unprivileged domains are allowed to do IOMAPpings for - * PCI passthrough, but not map ISA space. The ISA - * mappings are just dummy local mappings to keep other - * parts of the kernel happy. - */ - if (unlikely(pte & _PAGE_IOMAP) && - (xen_initial_domain() || addr >= ISA_END_ADDRESS)) { - pte = iomap_pte(pte); - } else { - pte &= ~_PAGE_IOMAP; - pte = pte_pfn_to_mfn(pte); - } - + pte = pte_pfn_to_mfn(pte); return native_make_pte(pte); } PV_CALLEE_SAVE_REGS_THUNK(xen_make_pte); @@ -665,11 +594,6 @@ void xen_set_pud(pud_t *ptr, pud_t val) void xen_set_pte(pte_t *ptep, pte_t pte) { - if (xen_iomap_pte(pte)) { - xen_set_iomap_pte(ptep, pte); - return; - } - ADD_STATS(pte_update, 1); // ADD_STATS(pte_update_pinned, xen_page_pinned(ptep)); ADD_STATS(pte_update_batched, paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU); @@ -686,11 +610,6 @@ void xen_set_pte(pte_t *ptep, pte_t pte) #ifdef CONFIG_X86_PAE void xen_set_pte_atomic(pte_t *ptep, pte_t pte) { - if (xen_iomap_pte(pte)) { - xen_set_iomap_pte(ptep, pte); - return; - } - set_64bit((u64 *)ptep, native_pte_val(pte)); } @@ -1017,6 +936,8 @@ static int xen_pin_page(struct mm_struct *mm, struct page *page, read-only, and can be pinned. */ static void __xen_pgd_pin(struct mm_struct *mm, pgd_t *pgd) { + vm_unmap_aliases(); + xen_mc_batch(); if (__xen_pgd_walk(mm, pgd, xen_pin_page, USER_LIMIT)) { @@ -1580,6 +1501,7 @@ static void xen_alloc_ptpage(struct mm_struct *mm, unsigned long pfn, unsigned l if (PagePinned(virt_to_page(mm->pgd))) { SetPagePinned(page); + vm_unmap_aliases(); if (!PageHighMem(page)) { make_lowmem_page_readonly(__va(PFN_PHYS((unsigned long)pfn))); if (level == PT_PTE && USE_SPLIT_PTLOCKS) @@ -1890,15 +1812,8 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot) pte = pfn_pte(phys, prot); break; - case FIX_PARAVIRT_BOOTMAP: - /* This is an MFN, but it isn't an IO mapping from the - IO domain */ - pte = mfn_pte(phys, prot); - break; - default: - /* By default, set_fixmap is used for hardware mappings */ - pte = mfn_pte(phys, __pgprot(pgprot_val(prot) | _PAGE_IOMAP)); + pte = mfn_pte(phys, prot); break; } @@ -2025,205 +1940,7 @@ void __init xen_init_mmu_ops(void) x86_init.paging.pagetable_setup_start = xen_pagetable_setup_start; x86_init.paging.pagetable_setup_done = xen_pagetable_setup_done; pv_mmu_ops = xen_mmu_ops; - - vmap_lazy_unmap = false; -} - -/* Protected by xen_reservation_lock. */ -#define MAX_CONTIG_ORDER 9 /* 2MB */ -static unsigned long discontig_frames[1< MAX_CONTIG_ORDER)) - return -ENOMEM; - - memset((void *) vstart, 0, PAGE_SIZE << order); - - spin_lock_irqsave(&xen_reservation_lock, flags); - - /* 1. Zap current PTEs, remembering MFNs. */ - xen_zap_pfn_range(vstart, order, in_frames, NULL); - - /* 2. Get a new contiguous memory extent. */ - out_frame = virt_to_pfn(vstart); - success = xen_exchange_memory(1UL << order, 0, in_frames, - 1, order, &out_frame, - address_bits); - - /* 3. Map the new extent in place of old pages. */ - if (success) - xen_remap_exchanged_ptes(vstart, order, NULL, out_frame); - else - xen_remap_exchanged_ptes(vstart, order, in_frames, 0); - - spin_unlock_irqrestore(&xen_reservation_lock, flags); - - return success ? 0 : -ENOMEM; -} -EXPORT_SYMBOL_GPL(xen_create_contiguous_region); - -void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order) -{ - unsigned long *out_frames = discontig_frames, in_frame; - unsigned long flags; - int success; - - if (xen_feature(XENFEAT_auto_translated_physmap)) - return; - - if (unlikely(order > MAX_CONTIG_ORDER)) - return; - - memset((void *) vstart, 0, PAGE_SIZE << order); - - spin_lock_irqsave(&xen_reservation_lock, flags); - - /* 1. Find start MFN of contiguous extent. */ - in_frame = virt_to_mfn(vstart); - - /* 2. Zap current PTEs. */ - xen_zap_pfn_range(vstart, order, NULL, out_frames); - - /* 3. Do the exchange for non-contiguous MFNs. */ - success = xen_exchange_memory(1, order, &in_frame, 1UL << order, - 0, out_frames, 0); - - /* 4. Map new pages in place of old pages. */ - if (success) - xen_remap_exchanged_ptes(vstart, order, out_frames, 0); - else - xen_remap_exchanged_ptes(vstart, order, NULL, in_frame); - - spin_unlock_irqrestore(&xen_reservation_lock, flags); } -EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region); #ifdef CONFIG_XEN_PVHVM static void xen_hvm_exit_mmap(struct mm_struct *mm) diff --git a/trunk/arch/x86/xen/pci-swiotlb-xen.c b/trunk/arch/x86/xen/pci-swiotlb-xen.c deleted file mode 100644 index a013ec9d0c54..000000000000 --- a/trunk/arch/x86/xen/pci-swiotlb-xen.c +++ /dev/null @@ -1,58 +0,0 @@ -/* Glue code to lib/swiotlb-xen.c */ - -#include -#include - -#include -#include - -int xen_swiotlb __read_mostly; - -static struct dma_map_ops xen_swiotlb_dma_ops = { - .mapping_error = xen_swiotlb_dma_mapping_error, - .alloc_coherent = xen_swiotlb_alloc_coherent, - .free_coherent = xen_swiotlb_free_coherent, - .sync_single_for_cpu = xen_swiotlb_sync_single_for_cpu, - .sync_single_for_device = xen_swiotlb_sync_single_for_device, - .sync_sg_for_cpu = xen_swiotlb_sync_sg_for_cpu, - .sync_sg_for_device = xen_swiotlb_sync_sg_for_device, - .map_sg = xen_swiotlb_map_sg_attrs, - .unmap_sg = xen_swiotlb_unmap_sg_attrs, - .map_page = xen_swiotlb_map_page, - .unmap_page = xen_swiotlb_unmap_page, - .dma_supported = xen_swiotlb_dma_supported, -}; - -/* - * pci_xen_swiotlb_detect - set xen_swiotlb to 1 if necessary - * - * This returns non-zero if we are forced to use xen_swiotlb (by the boot - * option). - */ -int __init pci_xen_swiotlb_detect(void) -{ - - /* If running as PV guest, either iommu=soft, or swiotlb=force will - * activate this IOMMU. If running as PV privileged, activate it - * irregardlesss. - */ - if ((xen_initial_domain() || swiotlb || swiotlb_force) && - (xen_pv_domain())) - xen_swiotlb = 1; - - /* If we are running under Xen, we MUST disable the native SWIOTLB. - * Don't worry about swiotlb_force flag activating the native, as - * the 'swiotlb' flag is the only one turning it on. */ - if (xen_pv_domain()) - swiotlb = 0; - - return xen_swiotlb; -} - -void __init pci_xen_swiotlb_init(void) -{ - if (xen_swiotlb) { - xen_swiotlb_init(1); - dma_ops = &xen_swiotlb_dma_ops; - } -} diff --git a/trunk/block/blk-core.c b/trunk/block/blk-core.c index ee1a1e7e63cc..7da630e25ae7 100644 --- a/trunk/block/blk-core.c +++ b/trunk/block/blk-core.c @@ -1514,10 +1514,7 @@ static inline void __generic_make_request(struct bio *bio) if (bio_check_eod(bio, nr_sectors)) goto end_io; - if ((bio->bi_rw & REQ_DISCARD) && - (!blk_queue_discard(q) || - ((bio->bi_rw & REQ_SECURE) && - !blk_queue_secdiscard(q)))) { + if ((bio->bi_rw & REQ_DISCARD) && !blk_queue_discard(q)) { err = -EOPNOTSUPP; goto end_io; } diff --git a/trunk/block/blk-lib.c b/trunk/block/blk-lib.c index c392029a104e..c1fc55a83ba1 100644 --- a/trunk/block/blk-lib.c +++ b/trunk/block/blk-lib.c @@ -62,12 +62,6 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, max_discard_sectors &= ~(disc_sects - 1); } - if (flags & BLKDEV_IFL_SECURE) { - if (!blk_queue_secdiscard(q)) - return -EOPNOTSUPP; - type |= DISCARD_SECURE; - } - while (nr_sects && !ret) { bio = bio_alloc(gfp_mask, 1); if (!bio) { diff --git a/trunk/block/compat_ioctl.c b/trunk/block/compat_ioctl.c index 119f07b74dc0..d53085637731 100644 --- a/trunk/block/compat_ioctl.c +++ b/trunk/block/compat_ioctl.c @@ -703,7 +703,6 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) case BLKFLSBUF: case BLKROSET: case BLKDISCARD: - case BLKSECDISCARD: /* * the ones below are implemented in blkdev_locked_ioctl, * but we call blkdev_ioctl, which gets the lock for us diff --git a/trunk/block/elevator.c b/trunk/block/elevator.c index ec585c9554d3..816a7c8d6394 100644 --- a/trunk/block/elevator.c +++ b/trunk/block/elevator.c @@ -82,12 +82,6 @@ int elv_rq_merge_ok(struct request *rq, struct bio *bio) if ((bio->bi_rw & REQ_DISCARD) != (rq->bio->bi_rw & REQ_DISCARD)) return 0; - /* - * Don't merge discard requests and secure discard requests - */ - if ((bio->bi_rw & REQ_SECURE) != (rq->bio->bi_rw & REQ_SECURE)) - return 0; - /* * different data direction or already started, don't merge */ diff --git a/trunk/block/ioctl.c b/trunk/block/ioctl.c index d8052f0dabd3..09fd7f1ef23a 100644 --- a/trunk/block/ioctl.c +++ b/trunk/block/ioctl.c @@ -114,10 +114,8 @@ static int blkdev_reread_part(struct block_device *bdev) } static int blk_ioctl_discard(struct block_device *bdev, uint64_t start, - uint64_t len, int secure) + uint64_t len) { - unsigned long flags = BLKDEV_IFL_WAIT; - if (start & 511) return -EINVAL; if (len & 511) @@ -127,9 +125,8 @@ static int blk_ioctl_discard(struct block_device *bdev, uint64_t start, if (start + len > (bdev->bd_inode->i_size >> 9)) return -EINVAL; - if (secure) - flags |= BLKDEV_IFL_SECURE; - return blkdev_issue_discard(bdev, start, len, GFP_KERNEL, flags); + return blkdev_issue_discard(bdev, start, len, GFP_KERNEL, + BLKDEV_IFL_WAIT); } static int put_ushort(unsigned long arg, unsigned short val) @@ -216,8 +213,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, set_device_ro(bdev, n); return 0; - case BLKDISCARD: - case BLKSECDISCARD: { + case BLKDISCARD: { uint64_t range[2]; if (!(mode & FMODE_WRITE)) @@ -226,8 +222,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, if (copy_from_user(range, (void __user *)arg, sizeof(range))) return -EFAULT; - return blk_ioctl_discard(bdev, range[0], range[1], - cmd == BLKSECDISCARD); + return blk_ioctl_discard(bdev, range[0], range[1]); } case HDIO_GETGEO: { diff --git a/trunk/drivers/acpi/apei/erst.c b/trunk/drivers/acpi/apei/erst.c index 18645f4e83cd..864dd46c346f 100644 --- a/trunk/drivers/acpi/apei/erst.c +++ b/trunk/drivers/acpi/apei/erst.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include "apei-internal.h" diff --git a/trunk/drivers/acpi/debug.c b/trunk/drivers/acpi/debug.c index 295dbfa2db9c..146135e7a6a1 100644 --- a/trunk/drivers/acpi/debug.c +++ b/trunk/drivers/acpi/debug.c @@ -96,8 +96,7 @@ static const struct acpi_dlevel acpi_debug_levels[] = { /* -------------------------------------------------------------------------- FS Interface (/sys) -------------------------------------------------------------------------- */ -static int param_get_debug_layer(char *buffer, const struct kernel_param *kp) -{ +static int param_get_debug_layer(char *buffer, struct kernel_param *kp) { int result = 0; int i; @@ -119,8 +118,7 @@ static int param_get_debug_layer(char *buffer, const struct kernel_param *kp) return result; } -static int param_get_debug_level(char *buffer, const struct kernel_param *kp) -{ +static int param_get_debug_level(char *buffer, struct kernel_param *kp) { int result = 0; int i; @@ -139,18 +137,8 @@ static int param_get_debug_level(char *buffer, const struct kernel_param *kp) return result; } -static struct kernel_param_ops acpi_debug_layer_ops = { - .set = param_set_uint, - .get = param_get_debug_layer, -}; - -static struct kernel_param_ops acpi_debug_level_ops = { - .set = param_set_uint, - .get = param_get_debug_level, -}; - -module_param_cb(debug_layer, &acpi_debug_layer_ops, &acpi_dbg_layer, 0644); -module_param_cb(debug_level, &acpi_debug_level_ops, &acpi_dbg_level, 0644); +module_param_call(debug_layer, param_set_uint, param_get_debug_layer, &acpi_dbg_layer, 0644); +module_param_call(debug_level, param_set_uint, param_get_debug_level, &acpi_dbg_level, 0644); static char trace_method_name[6]; module_param_string(trace_method_name, trace_method_name, 6, 0644); @@ -159,7 +147,7 @@ module_param(trace_debug_layer, uint, 0644); static unsigned int trace_debug_level; module_param(trace_debug_level, uint, 0644); -static int param_set_trace_state(const char *val, const struct kernel_param *kp) +static int param_set_trace_state(const char *val, struct kernel_param *kp) { int result = 0; @@ -193,7 +181,7 @@ static int param_set_trace_state(const char *val, const struct kernel_param *kp) return result; } -static int param_get_trace_state(char *buffer, const struct kernel_param *kp) +static int param_get_trace_state(char *buffer, struct kernel_param *kp) { if (!acpi_gbl_trace_method_name) return sprintf(buffer, "disable"); @@ -206,12 +194,8 @@ static int param_get_trace_state(char *buffer, const struct kernel_param *kp) return 0; } -static struct kernel_param_ops param_ops_trace_state = { - .set = param_set_trace_state, - .get = param_get_trace_state, -}; - -module_param_cb(trace_state, ¶m_ops_trace_state, NULL, 0644); +module_param_call(trace_state, param_set_trace_state, param_get_trace_state, + NULL, 0644); /* -------------------------------------------------------------------------- DebugFS Interface diff --git a/trunk/drivers/ata/pata_mpc52xx.c b/trunk/drivers/ata/pata_mpc52xx.c index 8cc536e49a0a..f087ab55b1df 100644 --- a/trunk/drivers/ata/pata_mpc52xx.c +++ b/trunk/drivers/ata/pata_mpc52xx.c @@ -680,7 +680,7 @@ mpc52xx_ata_remove_one(struct device *dev) /* ======================================================================== */ static int __devinit -mpc52xx_ata_probe(struct platform_device *op, const struct of_device_id *match) +mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match) { unsigned int ipb_freq; struct resource res_mem; @@ -821,7 +821,7 @@ mpc52xx_ata_probe(struct platform_device *op, const struct of_device_id *match) } static int -mpc52xx_ata_remove(struct platform_device *op) +mpc52xx_ata_remove(struct of_device *op) { struct mpc52xx_ata_priv *priv; int task_irq; @@ -848,7 +848,7 @@ mpc52xx_ata_remove(struct platform_device *op) #ifdef CONFIG_PM static int -mpc52xx_ata_suspend(struct platform_device *op, pm_message_t state) +mpc52xx_ata_suspend(struct of_device *op, pm_message_t state) { struct ata_host *host = dev_get_drvdata(&op->dev); @@ -856,7 +856,7 @@ mpc52xx_ata_suspend(struct platform_device *op, pm_message_t state) } static int -mpc52xx_ata_resume(struct platform_device *op) +mpc52xx_ata_resume(struct of_device *op) { struct ata_host *host = dev_get_drvdata(&op->dev); struct mpc52xx_ata_priv *priv = host->private_data; diff --git a/trunk/drivers/ata/pata_of_platform.c b/trunk/drivers/ata/pata_of_platform.c index 480e043ce6b8..5a1b82c08be9 100644 --- a/trunk/drivers/ata/pata_of_platform.c +++ b/trunk/drivers/ata/pata_of_platform.c @@ -14,7 +14,7 @@ #include #include -static int __devinit pata_of_platform_probe(struct platform_device *ofdev, +static int __devinit pata_of_platform_probe(struct of_device *ofdev, const struct of_device_id *match) { int ret; @@ -78,7 +78,7 @@ static int __devinit pata_of_platform_probe(struct platform_device *ofdev, reg_shift, pio_mask); } -static int __devexit pata_of_platform_remove(struct platform_device *ofdev) +static int __devexit pata_of_platform_remove(struct of_device *ofdev) { return __pata_platform_remove(&ofdev->dev); } diff --git a/trunk/drivers/ata/sata_fsl.c b/trunk/drivers/ata/sata_fsl.c index 7325f77480dc..18c986dbb7f1 100644 --- a/trunk/drivers/ata/sata_fsl.c +++ b/trunk/drivers/ata/sata_fsl.c @@ -1296,7 +1296,7 @@ static const struct ata_port_info sata_fsl_port_info[] = { }, }; -static int sata_fsl_probe(struct platform_device *ofdev, +static int sata_fsl_probe(struct of_device *ofdev, const struct of_device_id *match) { int retval = -ENXIO; @@ -1370,7 +1370,7 @@ static int sata_fsl_probe(struct platform_device *ofdev, return retval; } -static int sata_fsl_remove(struct platform_device *ofdev) +static int sata_fsl_remove(struct of_device *ofdev) { struct ata_host *host = dev_get_drvdata(&ofdev->dev); struct sata_fsl_host_priv *host_priv = host->private_data; @@ -1387,13 +1387,13 @@ static int sata_fsl_remove(struct platform_device *ofdev) } #ifdef CONFIG_PM -static int sata_fsl_suspend(struct platform_device *op, pm_message_t state) +static int sata_fsl_suspend(struct of_device *op, pm_message_t state) { struct ata_host *host = dev_get_drvdata(&op->dev); return ata_host_suspend(host, state); } -static int sata_fsl_resume(struct platform_device *op) +static int sata_fsl_resume(struct of_device *op) { struct ata_host *host = dev_get_drvdata(&op->dev); struct sata_fsl_host_priv *host_priv = host->private_data; diff --git a/trunk/drivers/atm/fore200e.c b/trunk/drivers/atm/fore200e.c index c8fc69c85a06..b7385e077717 100644 --- a/trunk/drivers/atm/fore200e.c +++ b/trunk/drivers/atm/fore200e.c @@ -674,7 +674,7 @@ static void fore200e_sba_write(u32 val, volatile u32 __iomem *addr) static u32 fore200e_sba_dma_map(struct fore200e *fore200e, void* virt_addr, int size, int direction) { - struct platform_device *op = fore200e->bus_dev; + struct of_device *op = fore200e->bus_dev; u32 dma_addr; dma_addr = dma_map_single(&op->dev, virt_addr, size, direction); @@ -687,7 +687,7 @@ static u32 fore200e_sba_dma_map(struct fore200e *fore200e, void* virt_addr, int static void fore200e_sba_dma_unmap(struct fore200e *fore200e, u32 dma_addr, int size, int direction) { - struct platform_device *op = fore200e->bus_dev; + struct of_device *op = fore200e->bus_dev; DPRINTK(3, "SBUS DVMA unmapping: dma_addr = 0x%08x, size = %d, direction = %d,\n", dma_addr, size, direction); @@ -697,7 +697,7 @@ static void fore200e_sba_dma_unmap(struct fore200e *fore200e, u32 dma_addr, int static void fore200e_sba_dma_sync_for_cpu(struct fore200e *fore200e, u32 dma_addr, int size, int direction) { - struct platform_device *op = fore200e->bus_dev; + struct of_device *op = fore200e->bus_dev; DPRINTK(3, "SBUS DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); @@ -706,7 +706,7 @@ static void fore200e_sba_dma_sync_for_cpu(struct fore200e *fore200e, u32 dma_add static void fore200e_sba_dma_sync_for_device(struct fore200e *fore200e, u32 dma_addr, int size, int direction) { - struct platform_device *op = fore200e->bus_dev; + struct of_device *op = fore200e->bus_dev; DPRINTK(3, "SBUS DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); @@ -719,7 +719,7 @@ static void fore200e_sba_dma_sync_for_device(struct fore200e *fore200e, u32 dma_ static int fore200e_sba_dma_chunk_alloc(struct fore200e *fore200e, struct chunk *chunk, int size, int nbr, int alignment) { - struct platform_device *op = fore200e->bus_dev; + struct of_device *op = fore200e->bus_dev; chunk->alloc_size = chunk->align_size = size * nbr; @@ -738,7 +738,7 @@ static int fore200e_sba_dma_chunk_alloc(struct fore200e *fore200e, struct chunk /* free a DVMA consistent chunk of memory */ static void fore200e_sba_dma_chunk_free(struct fore200e *fore200e, struct chunk *chunk) { - struct platform_device *op = fore200e->bus_dev; + struct of_device *op = fore200e->bus_dev; dma_free_coherent(&op->dev, chunk->alloc_size, chunk->alloc_addr, chunk->dma_addr); @@ -770,7 +770,7 @@ static void fore200e_sba_reset(struct fore200e *fore200e) static int __init fore200e_sba_map(struct fore200e *fore200e) { - struct platform_device *op = fore200e->bus_dev; + struct of_device *op = fore200e->bus_dev; unsigned int bursts; /* gain access to the SBA specific registers */ @@ -800,7 +800,7 @@ static int __init fore200e_sba_map(struct fore200e *fore200e) static void fore200e_sba_unmap(struct fore200e *fore200e) { - struct platform_device *op = fore200e->bus_dev; + struct of_device *op = fore200e->bus_dev; of_iounmap(&op->resource[0], fore200e->regs.sba.hcr, SBA200E_HCR_LENGTH); of_iounmap(&op->resource[1], fore200e->regs.sba.bsr, SBA200E_BSR_LENGTH); @@ -816,7 +816,7 @@ static int __init fore200e_sba_configure(struct fore200e *fore200e) static int __init fore200e_sba_prom_read(struct fore200e *fore200e, struct prom_data *prom) { - struct platform_device *op = fore200e->bus_dev; + struct of_device *op = fore200e->bus_dev; const u8 *prop; int len; @@ -840,7 +840,7 @@ static int __init fore200e_sba_prom_read(struct fore200e *fore200e, struct prom_ static int fore200e_sba_proc_read(struct fore200e *fore200e, char *page) { - struct platform_device *op = fore200e->bus_dev; + struct of_device *op = fore200e->bus_dev; const struct linux_prom_registers *regs; regs = of_get_property(op->dev.of_node, "reg", NULL); @@ -2513,7 +2513,7 @@ fore200e_load_and_start_fw(struct fore200e* fore200e) device = &((struct pci_dev *) fore200e->bus_dev)->dev; #ifdef CONFIG_SBUS else if (strcmp(fore200e->bus->model_name, "SBA-200E") == 0) - device = &((struct platform_device *) fore200e->bus_dev)->dev; + device = &((struct of_device *) fore200e->bus_dev)->dev; #endif else return err; @@ -2643,7 +2643,7 @@ fore200e_init(struct fore200e* fore200e) } #ifdef CONFIG_SBUS -static int __devinit fore200e_sba_probe(struct platform_device *op, +static int __devinit fore200e_sba_probe(struct of_device *op, const struct of_device_id *match) { const struct fore200e_bus *bus = match->data; @@ -2675,7 +2675,7 @@ static int __devinit fore200e_sba_probe(struct platform_device *op, return 0; } -static int __devexit fore200e_sba_remove(struct platform_device *op) +static int __devexit fore200e_sba_remove(struct of_device *op) { struct fore200e *fore200e = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/block/xsysace.c b/trunk/drivers/block/xsysace.c index 2982b3ee9465..b71888b909a0 100644 --- a/trunk/drivers/block/xsysace.c +++ b/trunk/drivers/block/xsysace.c @@ -1194,7 +1194,7 @@ static struct platform_driver ace_platform_driver = { #if defined(CONFIG_OF) static int __devinit -ace_of_probe(struct platform_device *op, const struct of_device_id *match) +ace_of_probe(struct of_device *op, const struct of_device_id *match) { struct resource res; resource_size_t physaddr; @@ -1226,7 +1226,7 @@ ace_of_probe(struct platform_device *op, const struct of_device_id *match) return ace_alloc(&op->dev, id ? *id : 0, physaddr, irq, bus_width); } -static int __devexit ace_of_remove(struct platform_device *op) +static int __devexit ace_of_remove(struct of_device *op) { ace_free(&op->dev); return 0; diff --git a/trunk/drivers/char/Kconfig b/trunk/drivers/char/Kconfig index 3d44ec724c17..7cfcc629a7fd 100644 --- a/trunk/drivers/char/Kconfig +++ b/trunk/drivers/char/Kconfig @@ -1002,7 +1002,7 @@ config SCx200_GPIO config PC8736x_GPIO tristate "NatSemi PC8736x GPIO Support" - depends on X86_32 + depends on X86 default SCx200_GPIO # mostly N select NSC_GPIO # needed for support routines help diff --git a/trunk/drivers/char/hvc_iucv.c b/trunk/drivers/char/hvc_iucv.c index 7b01bc609de3..5a80ad68ef22 100644 --- a/trunk/drivers/char/hvc_iucv.c +++ b/trunk/drivers/char/hvc_iucv.c @@ -1149,7 +1149,7 @@ static int hvc_iucv_setup_filter(const char *val) * Note: If it is called early in the boot process, @val is stored and * parsed later in hvc_iucv_init(). */ -static int param_set_vmidfilter(const char *val, const struct kernel_param *kp) +static int param_set_vmidfilter(const char *val, struct kernel_param *kp) { int rc; @@ -1176,7 +1176,7 @@ static int param_set_vmidfilter(const char *val, const struct kernel_param *kp) * The function stores the filter as a comma-separated list of z/VM user IDs * in @buffer. Typically, sysfs routines call this function for attr show. */ -static int param_get_vmidfilter(char *buffer, const struct kernel_param *kp) +static int param_get_vmidfilter(char *buffer, struct kernel_param *kp) { int rc; size_t index, len; @@ -1203,11 +1203,6 @@ static int param_get_vmidfilter(char *buffer, const struct kernel_param *kp) #define param_check_vmidfilter(name, p) __param_check(name, p, void) -static struct kernel_param_ops param_ops_vmidfilter = { - .set = param_set_vmidfilter, - .get = param_get_vmidfilter, -}; - /** * hvc_iucv_init() - z/VM IUCV HVC device driver initialization */ diff --git a/trunk/drivers/char/hw_random/n2-drv.c b/trunk/drivers/char/hw_random/n2-drv.c index 1acdb2509511..7a4f080f8356 100644 --- a/trunk/drivers/char/hw_random/n2-drv.c +++ b/trunk/drivers/char/hw_random/n2-drv.c @@ -619,7 +619,7 @@ static void __devinit n2rng_driver_version(void) pr_info("%s", version); } -static int __devinit n2rng_probe(struct platform_device *op, +static int __devinit n2rng_probe(struct of_device *op, const struct of_device_id *match) { int victoria_falls = (match->data != NULL); @@ -714,7 +714,7 @@ static int __devinit n2rng_probe(struct platform_device *op, return err; } -static int __devexit n2rng_remove(struct platform_device *op) +static int __devexit n2rng_remove(struct of_device *op) { struct n2rng *np = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/char/hw_random/n2rng.h b/trunk/drivers/char/hw_random/n2rng.h index 4bea07f30978..a2b81e7bfc18 100644 --- a/trunk/drivers/char/hw_random/n2rng.h +++ b/trunk/drivers/char/hw_random/n2rng.h @@ -65,7 +65,7 @@ struct n2rng_unit { }; struct n2rng { - struct platform_device *op; + struct of_device *op; unsigned long flags; #define N2RNG_FLAG_VF 0x00000001 /* Victoria Falls RNG, else N2 */ diff --git a/trunk/drivers/char/hw_random/pasemi-rng.c b/trunk/drivers/char/hw_random/pasemi-rng.c index a31c830ca8cd..261ba8f22b8b 100644 --- a/trunk/drivers/char/hw_random/pasemi-rng.c +++ b/trunk/drivers/char/hw_random/pasemi-rng.c @@ -94,7 +94,7 @@ static struct hwrng pasemi_rng = { .data_read = pasemi_rng_data_read, }; -static int __devinit rng_probe(struct platform_device *ofdev, +static int __devinit rng_probe(struct of_device *ofdev, const struct of_device_id *match) { void __iomem *rng_regs; @@ -123,7 +123,7 @@ static int __devinit rng_probe(struct platform_device *ofdev, return err; } -static int __devexit rng_remove(struct platform_device *dev) +static int __devexit rng_remove(struct of_device *dev) { void __iomem *rng_regs = (void __iomem *)pasemi_rng.priv; diff --git a/trunk/drivers/char/ipmi/ipmi_si_intf.c b/trunk/drivers/char/ipmi/ipmi_si_intf.c index 3822b4f49c84..48330e0fd488 100644 --- a/trunk/drivers/char/ipmi/ipmi_si_intf.c +++ b/trunk/drivers/char/ipmi/ipmi_si_intf.c @@ -2528,7 +2528,7 @@ static struct pci_driver ipmi_pci_driver = { #ifdef CONFIG_PPC_OF -static int __devinit ipmi_of_probe(struct platform_device *dev, +static int __devinit ipmi_of_probe(struct of_device *dev, const struct of_device_id *match) { struct smi_info *info; @@ -2607,7 +2607,7 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, return 0; } -static int __devexit ipmi_of_remove(struct platform_device *dev) +static int __devexit ipmi_of_remove(struct of_device *dev) { cleanup_one_si(dev_get_drvdata(&dev->dev)); return 0; diff --git a/trunk/drivers/char/ipmi/ipmi_watchdog.c b/trunk/drivers/char/ipmi/ipmi_watchdog.c index 654d566ca57c..82bcdb262a3a 100644 --- a/trunk/drivers/char/ipmi/ipmi_watchdog.c +++ b/trunk/drivers/char/ipmi/ipmi_watchdog.c @@ -196,7 +196,7 @@ static void ipmi_unregister_watchdog(int ipmi_intf); */ static int start_now; -static int set_param_timeout(const char *val, const struct kernel_param *kp) +static int set_param_int(const char *val, struct kernel_param *kp) { char *endp; int l; @@ -215,11 +215,10 @@ static int set_param_timeout(const char *val, const struct kernel_param *kp) return rv; } -static struct kernel_param_ops param_ops_timeout = { - .set = set_param_timeout, - .get = param_get_int, -}; -#define param_check_timeout param_check_int +static int get_param_int(char *buffer, struct kernel_param *kp) +{ + return sprintf(buffer, "%i", *((int *)kp->arg)); +} typedef int (*action_fn)(const char *intval, char *outval); @@ -228,7 +227,7 @@ static int preaction_op(const char *inval, char *outval); static int preop_op(const char *inval, char *outval); static void check_parms(void); -static int set_param_str(const char *val, const struct kernel_param *kp) +static int set_param_str(const char *val, struct kernel_param *kp) { action_fn fn = (action_fn) kp->arg; int rv = 0; @@ -252,7 +251,7 @@ static int set_param_str(const char *val, const struct kernel_param *kp) return rv; } -static int get_param_str(char *buffer, const struct kernel_param *kp) +static int get_param_str(char *buffer, struct kernel_param *kp) { action_fn fn = (action_fn) kp->arg; int rv; @@ -264,7 +263,7 @@ static int get_param_str(char *buffer, const struct kernel_param *kp) } -static int set_param_wdog_ifnum(const char *val, const struct kernel_param *kp) +static int set_param_wdog_ifnum(const char *val, struct kernel_param *kp) { int rv = param_set_int(val, kp); if (rv) @@ -277,38 +276,27 @@ static int set_param_wdog_ifnum(const char *val, const struct kernel_param *kp) return 0; } -static struct kernel_param_ops param_ops_wdog_ifnum = { - .set = set_param_wdog_ifnum, - .get = param_get_int, -}; - -#define param_check_wdog_ifnum param_check_int - -static struct kernel_param_ops param_ops_str = { - .set = set_param_str, - .get = get_param_str, -}; - -module_param(ifnum_to_use, wdog_ifnum, 0644); +module_param_call(ifnum_to_use, set_param_wdog_ifnum, get_param_int, + &ifnum_to_use, 0644); MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog " "timer. Setting to -1 defaults to the first registered " "interface"); -module_param(timeout, timeout, 0644); +module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644); MODULE_PARM_DESC(timeout, "Timeout value in seconds."); -module_param(pretimeout, timeout, 0644); +module_param_call(pretimeout, set_param_int, get_param_int, &pretimeout, 0644); MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds."); -module_param_cb(action, ¶m_ops_str, action_op, 0644); +module_param_call(action, set_param_str, get_param_str, action_op, 0644); MODULE_PARM_DESC(action, "Timeout action. One of: " "reset, none, power_cycle, power_off."); -module_param_cb(preaction, ¶m_ops_str, preaction_op, 0644); +module_param_call(preaction, set_param_str, get_param_str, preaction_op, 0644); MODULE_PARM_DESC(preaction, "Pretimeout action. One of: " "pre_none, pre_smi, pre_nmi, pre_int."); -module_param_cb(preop, ¶m_ops_str, preop_op, 0644); +module_param_call(preop, set_param_str, get_param_str, preop_op, 0644); MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: " "preop_none, preop_panic, preop_give_data."); diff --git a/trunk/drivers/char/rtc.c b/trunk/drivers/char/rtc.c index dfa8b3062fda..95acb8c880f4 100644 --- a/trunk/drivers/char/rtc.c +++ b/trunk/drivers/char/rtc.c @@ -961,7 +961,7 @@ static int __init rtc_init(void) #endif #ifdef CONFIG_SPARC32 struct device_node *ebus_dp; - struct platform_device *op; + struct of_device *op; #else void *r; #ifdef RTC_IRQ diff --git a/trunk/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/trunk/drivers/char/xilinx_hwicap/xilinx_hwicap.c index 0ed763cd2e77..ed8a9cec2a05 100644 --- a/trunk/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/trunk/drivers/char/xilinx_hwicap/xilinx_hwicap.c @@ -761,7 +761,7 @@ static struct platform_driver hwicap_platform_driver = { #if defined(CONFIG_OF) static int __devinit -hwicap_of_probe(struct platform_device *op, const struct of_device_id *match) +hwicap_of_probe(struct of_device *op, const struct of_device_id *match) { struct resource res; const unsigned int *id; @@ -798,7 +798,7 @@ hwicap_of_probe(struct platform_device *op, const struct of_device_id *match) regs); } -static int __devexit hwicap_of_remove(struct platform_device *op) +static int __devexit hwicap_of_remove(struct of_device *op) { return hwicap_remove(&op->dev); } diff --git a/trunk/drivers/crypto/amcc/crypto4xx_core.c b/trunk/drivers/crypto/amcc/crypto4xx_core.c index 2b1baee525bc..983530ba04a7 100644 --- a/trunk/drivers/crypto/amcc/crypto4xx_core.c +++ b/trunk/drivers/crypto/amcc/crypto4xx_core.c @@ -1150,7 +1150,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { /** * Module Initialization Routine */ -static int __init crypto4xx_probe(struct platform_device *ofdev, +static int __init crypto4xx_probe(struct of_device *ofdev, const struct of_device_id *match) { int rc; @@ -1258,7 +1258,7 @@ static int __init crypto4xx_probe(struct platform_device *ofdev, return rc; } -static int __exit crypto4xx_remove(struct platform_device *ofdev) +static int __exit crypto4xx_remove(struct of_device *ofdev) { struct device *dev = &ofdev->dev; struct crypto4xx_core_device *core_dev = dev_get_drvdata(dev); diff --git a/trunk/drivers/crypto/amcc/crypto4xx_core.h b/trunk/drivers/crypto/amcc/crypto4xx_core.h index bac0bdeb4b5f..da9cbe3b9fc3 100644 --- a/trunk/drivers/crypto/amcc/crypto4xx_core.h +++ b/trunk/drivers/crypto/amcc/crypto4xx_core.h @@ -104,7 +104,7 @@ struct crypto4xx_device { struct crypto4xx_core_device { struct device *device; - struct platform_device *ofdev; + struct of_device *ofdev; struct crypto4xx_device *dev; u32 int_status; u32 irq; diff --git a/trunk/drivers/crypto/n2_core.c b/trunk/drivers/crypto/n2_core.c index 88ee01510ec0..26af2dd5d831 100644 --- a/trunk/drivers/crypto/n2_core.c +++ b/trunk/drivers/crypto/n2_core.c @@ -1552,7 +1552,7 @@ static void __exit n2_unregister_algs(void) /* To map CWQ queues to interrupt sources, the hypervisor API provides * a devino. This isn't very useful to us because all of the - * interrupts listed in the device_node have been translated to + * interrupts listed in the of_device node have been translated to * Linux virtual IRQ cookie numbers. * * So we have to back-translate, going through the 'intr' and 'ino' @@ -1560,7 +1560,7 @@ static void __exit n2_unregister_algs(void) * 'interrupts' property entries, in order to to figure out which * devino goes to which already-translated IRQ. */ -static int find_devino_index(struct platform_device *dev, struct spu_mdesc_info *ip, +static int find_devino_index(struct of_device *dev, struct spu_mdesc_info *ip, unsigned long dev_ino) { const unsigned int *dev_intrs; @@ -1580,7 +1580,7 @@ static int find_devino_index(struct platform_device *dev, struct spu_mdesc_info if (!dev_intrs) return -ENODEV; - for (i = 0; i < dev->archdata.num_irqs; i++) { + for (i = 0; i < dev->num_irqs; i++) { if (dev_intrs[i] == intr) return i; } @@ -1588,7 +1588,7 @@ static int find_devino_index(struct platform_device *dev, struct spu_mdesc_info return -ENODEV; } -static int spu_map_ino(struct platform_device *dev, struct spu_mdesc_info *ip, +static int spu_map_ino(struct of_device *dev, struct spu_mdesc_info *ip, const char *irq_name, struct spu_queue *p, irq_handler_t handler) { @@ -1603,7 +1603,7 @@ static int spu_map_ino(struct platform_device *dev, struct spu_mdesc_info *ip, if (index < 0) return index; - p->irq = dev->archdata.irqs[index]; + p->irq = dev->irqs[index]; sprintf(p->irq_name, "%s-%d", irq_name, index); @@ -1736,7 +1736,7 @@ static void spu_list_destroy(struct list_head *list) * gathering cpu membership information. */ static int spu_mdesc_walk_arcs(struct mdesc_handle *mdesc, - struct platform_device *dev, + struct of_device *dev, u64 node, struct spu_queue *p, struct spu_queue **table) { @@ -1763,7 +1763,7 @@ static int spu_mdesc_walk_arcs(struct mdesc_handle *mdesc, /* Process an 'exec-unit' MDESC node of type 'cwq'. */ static int handle_exec_unit(struct spu_mdesc_info *ip, struct list_head *list, - struct platform_device *dev, struct mdesc_handle *mdesc, + struct of_device *dev, struct mdesc_handle *mdesc, u64 node, const char *iname, unsigned long q_type, irq_handler_t handler, struct spu_queue **table) { @@ -1794,7 +1794,7 @@ static int handle_exec_unit(struct spu_mdesc_info *ip, struct list_head *list, return spu_map_ino(dev, ip, iname, p, handler); } -static int spu_mdesc_scan(struct mdesc_handle *mdesc, struct platform_device *dev, +static int spu_mdesc_scan(struct mdesc_handle *mdesc, struct of_device *dev, struct spu_mdesc_info *ip, struct list_head *list, const char *exec_name, unsigned long q_type, irq_handler_t handler, struct spu_queue **table) @@ -1855,7 +1855,7 @@ static int __devinit get_irq_props(struct mdesc_handle *mdesc, u64 node, } static int __devinit grab_mdesc_irq_props(struct mdesc_handle *mdesc, - struct platform_device *dev, + struct of_device *dev, struct spu_mdesc_info *ip, const char *node_name) { @@ -2004,7 +2004,7 @@ static void __devinit n2_spu_driver_version(void) pr_info("%s", version); } -static int __devinit n2_crypto_probe(struct platform_device *dev, +static int __devinit n2_crypto_probe(struct of_device *dev, const struct of_device_id *match) { struct mdesc_handle *mdesc; @@ -2081,7 +2081,7 @@ static int __devinit n2_crypto_probe(struct platform_device *dev, return err; } -static int __devexit n2_crypto_remove(struct platform_device *dev) +static int __devexit n2_crypto_remove(struct of_device *dev) { struct n2_crypto *np = dev_get_drvdata(&dev->dev); @@ -2116,7 +2116,7 @@ static void free_ncp(struct n2_mau *mp) kfree(mp); } -static int __devinit n2_mau_probe(struct platform_device *dev, +static int __devinit n2_mau_probe(struct of_device *dev, const struct of_device_id *match) { struct mdesc_handle *mdesc; @@ -2184,7 +2184,7 @@ static int __devinit n2_mau_probe(struct platform_device *dev, return err; } -static int __devexit n2_mau_remove(struct platform_device *dev) +static int __devexit n2_mau_remove(struct of_device *dev) { struct n2_mau *mp = dev_get_drvdata(&dev->dev); diff --git a/trunk/drivers/crypto/talitos.c b/trunk/drivers/crypto/talitos.c index 4bcd825b5739..97f4af1d8a64 100644 --- a/trunk/drivers/crypto/talitos.c +++ b/trunk/drivers/crypto/talitos.c @@ -118,7 +118,7 @@ struct talitos_channel { struct talitos_private { struct device *dev; - struct platform_device *ofdev; + struct of_device *ofdev; void __iomem *reg; int irq; @@ -2308,7 +2308,7 @@ static int hw_supports(struct device *dev, __be32 desc_hdr_template) return ret; } -static int talitos_remove(struct platform_device *ofdev) +static int talitos_remove(struct of_device *ofdev) { struct device *dev = &ofdev->dev; struct talitos_private *priv = dev_get_drvdata(dev); @@ -2401,7 +2401,7 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev, return t_alg; } -static int talitos_probe(struct platform_device *ofdev, +static int talitos_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device *dev = &ofdev->dev; diff --git a/trunk/drivers/dma/fsldma.c b/trunk/drivers/dma/fsldma.c index cea08bed9cf9..f0fd6db6063c 100644 --- a/trunk/drivers/dma/fsldma.c +++ b/trunk/drivers/dma/fsldma.c @@ -1297,7 +1297,7 @@ static void fsl_dma_chan_remove(struct fsldma_chan *chan) kfree(chan); } -static int __devinit fsldma_of_probe(struct platform_device *op, +static int __devinit fsldma_of_probe(struct of_device *op, const struct of_device_id *match) { struct fsldma_device *fdev; @@ -1382,7 +1382,7 @@ static int __devinit fsldma_of_probe(struct platform_device *op, return err; } -static int fsldma_of_remove(struct platform_device *op) +static int fsldma_of_remove(struct of_device *op) { struct fsldma_device *fdev; unsigned int i; diff --git a/trunk/drivers/dma/mpc512x_dma.c b/trunk/drivers/dma/mpc512x_dma.c index 4e9cbf300594..14a8c0f1698e 100644 --- a/trunk/drivers/dma/mpc512x_dma.c +++ b/trunk/drivers/dma/mpc512x_dma.c @@ -627,7 +627,7 @@ mpc_dma_prep_memcpy(struct dma_chan *chan, dma_addr_t dst, dma_addr_t src, return &mdesc->desc; } -static int __devinit mpc_dma_probe(struct platform_device *op, +static int __devinit mpc_dma_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dn = op->dev.of_node; @@ -753,7 +753,7 @@ static int __devinit mpc_dma_probe(struct platform_device *op, return retval; } -static int __devexit mpc_dma_remove(struct platform_device *op) +static int __devexit mpc_dma_remove(struct of_device *op) { struct device *dev = &op->dev; struct mpc_dma *mdma = dev_get_drvdata(dev); diff --git a/trunk/drivers/dma/ppc4xx/adma.c b/trunk/drivers/dma/ppc4xx/adma.c index 0d58a4a4487f..7c3747902a37 100644 --- a/trunk/drivers/dma/ppc4xx/adma.c +++ b/trunk/drivers/dma/ppc4xx/adma.c @@ -4257,11 +4257,11 @@ static int ppc440spe_adma_setup_irqs(struct ppc440spe_adma_device *adev, struct ppc440spe_adma_chan *chan, int *initcode) { - struct platform_device *ofdev; + struct of_device *ofdev; struct device_node *np; int ret; - ofdev = container_of(adev->dev, struct platform_device, dev); + ofdev = container_of(adev->dev, struct of_device, dev); np = ofdev->dev.of_node; if (adev->id != PPC440SPE_XOR_ID) { adev->err_irq = irq_of_parse_and_map(np, 1); @@ -4393,7 +4393,7 @@ static void ppc440spe_adma_release_irqs(struct ppc440spe_adma_device *adev, /** * ppc440spe_adma_probe - probe the asynch device */ -static int __devinit ppc440spe_adma_probe(struct platform_device *ofdev, +static int __devinit ppc440spe_adma_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -4625,7 +4625,7 @@ static int __devinit ppc440spe_adma_probe(struct platform_device *ofdev, /** * ppc440spe_adma_remove - remove the asynch device */ -static int __devexit ppc440spe_adma_remove(struct platform_device *ofdev) +static int __devexit ppc440spe_adma_remove(struct of_device *ofdev) { struct ppc440spe_adma_device *adev = dev_get_drvdata(&ofdev->dev); struct device_node *np = ofdev->dev.of_node; diff --git a/trunk/drivers/edac/mpc85xx_edac.c b/trunk/drivers/edac/mpc85xx_edac.c index b123bb308a4a..af75e27f5224 100644 --- a/trunk/drivers/edac/mpc85xx_edac.c +++ b/trunk/drivers/edac/mpc85xx_edac.c @@ -200,7 +200,7 @@ static irqreturn_t mpc85xx_pci_isr(int irq, void *dev_id) return IRQ_HANDLED; } -static int __devinit mpc85xx_pci_err_probe(struct platform_device *op, +static int __devinit mpc85xx_pci_err_probe(struct of_device *op, const struct of_device_id *match) { struct edac_pci_ctl_info *pci; @@ -305,7 +305,7 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *op, return res; } -static int mpc85xx_pci_err_remove(struct platform_device *op) +static int mpc85xx_pci_err_remove(struct of_device *op) { struct edac_pci_ctl_info *pci = dev_get_drvdata(&op->dev); struct mpc85xx_pci_pdata *pdata = pci->pvt_info; @@ -503,7 +503,7 @@ static irqreturn_t mpc85xx_l2_isr(int irq, void *dev_id) return IRQ_HANDLED; } -static int __devinit mpc85xx_l2_err_probe(struct platform_device *op, +static int __devinit mpc85xx_l2_err_probe(struct of_device *op, const struct of_device_id *match) { struct edac_device_ctl_info *edac_dev; @@ -613,7 +613,7 @@ static int __devinit mpc85xx_l2_err_probe(struct platform_device *op, return res; } -static int mpc85xx_l2_err_remove(struct platform_device *op) +static int mpc85xx_l2_err_remove(struct of_device *op) { struct edac_device_ctl_info *edac_dev = dev_get_drvdata(&op->dev); struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; @@ -956,7 +956,7 @@ static void __devinit mpc85xx_init_csrows(struct mem_ctl_info *mci) } } -static int __devinit mpc85xx_mc_err_probe(struct platform_device *op, +static int __devinit mpc85xx_mc_err_probe(struct of_device *op, const struct of_device_id *match) { struct mem_ctl_info *mci; @@ -1088,7 +1088,7 @@ static int __devinit mpc85xx_mc_err_probe(struct platform_device *op, return res; } -static int mpc85xx_mc_err_remove(struct platform_device *op) +static int mpc85xx_mc_err_remove(struct of_device *op) { struct mem_ctl_info *mci = dev_get_drvdata(&op->dev); struct mpc85xx_mc_pdata *pdata = mci->pvt_info; diff --git a/trunk/drivers/edac/ppc4xx_edac.c b/trunk/drivers/edac/ppc4xx_edac.c index 070cea41b661..e78839e89a06 100644 --- a/trunk/drivers/edac/ppc4xx_edac.c +++ b/trunk/drivers/edac/ppc4xx_edac.c @@ -184,9 +184,9 @@ struct ppc4xx_ecc_status { /* Function Prototypes */ -static int ppc4xx_edac_probe(struct platform_device *device, +static int ppc4xx_edac_probe(struct of_device *device, const struct of_device_id *device_id); -static int ppc4xx_edac_remove(struct platform_device *device); +static int ppc4xx_edac_remove(struct of_device *device); /* Global Variables */ @@ -1014,7 +1014,7 @@ ppc4xx_edac_init_csrows(struct mem_ctl_info *mci, u32 mcopt1) */ static int __devinit ppc4xx_edac_mc_init(struct mem_ctl_info *mci, - struct platform_device *op, + struct of_device *op, const struct of_device_id *match, const dcr_host_t *dcr_host, u32 mcopt1) @@ -1108,7 +1108,7 @@ ppc4xx_edac_mc_init(struct mem_ctl_info *mci, * mapped and assigned. */ static int __devinit -ppc4xx_edac_register_irq(struct platform_device *op, struct mem_ctl_info *mci) +ppc4xx_edac_register_irq(struct of_device *op, struct mem_ctl_info *mci) { int status = 0; int ded_irq, sec_irq; @@ -1238,7 +1238,7 @@ ppc4xx_edac_map_dcrs(const struct device_node *np, dcr_host_t *dcr_host) * driver; otherwise, < 0 on error. */ static int __devinit -ppc4xx_edac_probe(struct platform_device *op, const struct of_device_id *match) +ppc4xx_edac_probe(struct of_device *op, const struct of_device_id *match) { int status = 0; u32 mcopt1, memcheck; @@ -1359,7 +1359,7 @@ ppc4xx_edac_probe(struct platform_device *op, const struct of_device_id *match) * Unconditionally returns 0. */ static int -ppc4xx_edac_remove(struct platform_device *op) +ppc4xx_edac_remove(struct of_device *op) { struct mem_ctl_info *mci = dev_get_drvdata(&op->dev); struct ppc4xx_edac_pdata *pdata = mci->pvt_info; diff --git a/trunk/drivers/gpio/Kconfig b/trunk/drivers/gpio/Kconfig index 510aa2054544..f623953b5797 100644 --- a/trunk/drivers/gpio/Kconfig +++ b/trunk/drivers/gpio/Kconfig @@ -206,13 +206,6 @@ config GPIO_SX150X 8 bits: sx1508q 16 bits: sx1509q -config GPIO_STMPE - bool "STMPE GPIOs" - depends on MFD_STMPE - help - This enables support for the GPIOs found on the STMPE I/O - Expanders. - config GPIO_TC35892 bool "TC35892 GPIOs" depends on MFD_TC35892 diff --git a/trunk/drivers/gpio/Makefile b/trunk/drivers/gpio/Makefile index fc6019d93720..a69e0609ff7f 100644 --- a/trunk/drivers/gpio/Makefile +++ b/trunk/drivers/gpio/Makefile @@ -20,7 +20,6 @@ obj-$(CONFIG_GPIO_MCP23S08) += mcp23s08.o obj-$(CONFIG_GPIO_PCA953X) += pca953x.o obj-$(CONFIG_GPIO_PCF857X) += pcf857x.o obj-$(CONFIG_GPIO_PL061) += pl061.o -obj-$(CONFIG_GPIO_STMPE) += stmpe-gpio.o obj-$(CONFIG_GPIO_TC35892) += tc35892-gpio.o obj-$(CONFIG_GPIO_TIMBERDALE) += timbgpio.o obj-$(CONFIG_GPIO_TWL4030) += twl4030-gpio.o diff --git a/trunk/drivers/gpio/stmpe-gpio.c b/trunk/drivers/gpio/stmpe-gpio.c deleted file mode 100644 index 4e1f1b9d5e67..000000000000 --- a/trunk/drivers/gpio/stmpe-gpio.c +++ /dev/null @@ -1,399 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2010 - * - * License Terms: GNU General Public License, version 2 - * Author: Rabin Vincent for ST-Ericsson - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * These registers are modified under the irq bus lock and cached to avoid - * unnecessary writes in bus_sync_unlock. - */ -enum { REG_RE, REG_FE, REG_IE }; - -#define CACHE_NR_REGS 3 -#define CACHE_NR_BANKS (STMPE_NR_GPIOS / 8) - -struct stmpe_gpio { - struct gpio_chip chip; - struct stmpe *stmpe; - struct device *dev; - struct mutex irq_lock; - - int irq_base; - - /* Caches of interrupt control registers for bus_lock */ - u8 regs[CACHE_NR_REGS][CACHE_NR_BANKS]; - u8 oldregs[CACHE_NR_REGS][CACHE_NR_BANKS]; -}; - -static inline struct stmpe_gpio *to_stmpe_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct stmpe_gpio, chip); -} - -static int stmpe_gpio_get(struct gpio_chip *chip, unsigned offset) -{ - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); - struct stmpe *stmpe = stmpe_gpio->stmpe; - u8 reg = stmpe->regs[STMPE_IDX_GPMR_LSB] - (offset / 8); - u8 mask = 1 << (offset % 8); - int ret; - - ret = stmpe_reg_read(stmpe, reg); - if (ret < 0) - return ret; - - return ret & mask; -} - -static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val) -{ - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); - struct stmpe *stmpe = stmpe_gpio->stmpe; - int which = val ? STMPE_IDX_GPSR_LSB : STMPE_IDX_GPCR_LSB; - u8 reg = stmpe->regs[which] - (offset / 8); - u8 mask = 1 << (offset % 8); - - stmpe_reg_write(stmpe, reg, mask); -} - -static int stmpe_gpio_direction_output(struct gpio_chip *chip, - unsigned offset, int val) -{ - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); - struct stmpe *stmpe = stmpe_gpio->stmpe; - u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); - u8 mask = 1 << (offset % 8); - - stmpe_gpio_set(chip, offset, val); - - return stmpe_set_bits(stmpe, reg, mask, mask); -} - -static int stmpe_gpio_direction_input(struct gpio_chip *chip, - unsigned offset) -{ - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); - struct stmpe *stmpe = stmpe_gpio->stmpe; - u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); - u8 mask = 1 << (offset % 8); - - return stmpe_set_bits(stmpe, reg, mask, 0); -} - -static int stmpe_gpio_to_irq(struct gpio_chip *chip, unsigned offset) -{ - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); - - return stmpe_gpio->irq_base + offset; -} - -static int stmpe_gpio_request(struct gpio_chip *chip, unsigned offset) -{ - struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); - struct stmpe *stmpe = stmpe_gpio->stmpe; - - return stmpe_set_altfunc(stmpe, 1 << offset, STMPE_BLOCK_GPIO); -} - -static struct gpio_chip template_chip = { - .label = "stmpe", - .owner = THIS_MODULE, - .direction_input = stmpe_gpio_direction_input, - .get = stmpe_gpio_get, - .direction_output = stmpe_gpio_direction_output, - .set = stmpe_gpio_set, - .to_irq = stmpe_gpio_to_irq, - .request = stmpe_gpio_request, - .can_sleep = 1, -}; - -static int stmpe_gpio_irq_set_type(unsigned int irq, unsigned int type) -{ - struct stmpe_gpio *stmpe_gpio = get_irq_chip_data(irq); - int offset = irq - stmpe_gpio->irq_base; - int regoffset = offset / 8; - int mask = 1 << (offset % 8); - - if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH) - return -EINVAL; - - if (type == IRQ_TYPE_EDGE_RISING) - stmpe_gpio->regs[REG_RE][regoffset] |= mask; - else - stmpe_gpio->regs[REG_RE][regoffset] &= ~mask; - - if (type == IRQ_TYPE_EDGE_FALLING) - stmpe_gpio->regs[REG_FE][regoffset] |= mask; - else - stmpe_gpio->regs[REG_FE][regoffset] &= ~mask; - - return 0; -} - -static void stmpe_gpio_irq_lock(unsigned int irq) -{ - struct stmpe_gpio *stmpe_gpio = get_irq_chip_data(irq); - - mutex_lock(&stmpe_gpio->irq_lock); -} - -static void stmpe_gpio_irq_sync_unlock(unsigned int irq) -{ - struct stmpe_gpio *stmpe_gpio = get_irq_chip_data(irq); - struct stmpe *stmpe = stmpe_gpio->stmpe; - int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); - static const u8 regmap[] = { - [REG_RE] = STMPE_IDX_GPRER_LSB, - [REG_FE] = STMPE_IDX_GPFER_LSB, - [REG_IE] = STMPE_IDX_IEGPIOR_LSB, - }; - int i, j; - - for (i = 0; i < CACHE_NR_REGS; i++) { - for (j = 0; j < num_banks; j++) { - u8 old = stmpe_gpio->oldregs[i][j]; - u8 new = stmpe_gpio->regs[i][j]; - - if (new == old) - continue; - - stmpe_gpio->oldregs[i][j] = new; - stmpe_reg_write(stmpe, stmpe->regs[regmap[i]] - j, new); - } - } - - mutex_unlock(&stmpe_gpio->irq_lock); -} - -static void stmpe_gpio_irq_mask(unsigned int irq) -{ - struct stmpe_gpio *stmpe_gpio = get_irq_chip_data(irq); - int offset = irq - stmpe_gpio->irq_base; - int regoffset = offset / 8; - int mask = 1 << (offset % 8); - - stmpe_gpio->regs[REG_IE][regoffset] &= ~mask; -} - -static void stmpe_gpio_irq_unmask(unsigned int irq) -{ - struct stmpe_gpio *stmpe_gpio = get_irq_chip_data(irq); - int offset = irq - stmpe_gpio->irq_base; - int regoffset = offset / 8; - int mask = 1 << (offset % 8); - - stmpe_gpio->regs[REG_IE][regoffset] |= mask; -} - -static struct irq_chip stmpe_gpio_irq_chip = { - .name = "stmpe-gpio", - .bus_lock = stmpe_gpio_irq_lock, - .bus_sync_unlock = stmpe_gpio_irq_sync_unlock, - .mask = stmpe_gpio_irq_mask, - .unmask = stmpe_gpio_irq_unmask, - .set_type = stmpe_gpio_irq_set_type, -}; - -static irqreturn_t stmpe_gpio_irq(int irq, void *dev) -{ - struct stmpe_gpio *stmpe_gpio = dev; - struct stmpe *stmpe = stmpe_gpio->stmpe; - u8 statmsbreg = stmpe->regs[STMPE_IDX_ISGPIOR_MSB]; - int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); - u8 status[num_banks]; - int ret; - int i; - - ret = stmpe_block_read(stmpe, statmsbreg, num_banks, status); - if (ret < 0) - return IRQ_NONE; - - for (i = 0; i < num_banks; i++) { - int bank = num_banks - i - 1; - unsigned int enabled = stmpe_gpio->regs[REG_IE][bank]; - unsigned int stat = status[i]; - - stat &= enabled; - if (!stat) - continue; - - while (stat) { - int bit = __ffs(stat); - int line = bank * 8 + bit; - - handle_nested_irq(stmpe_gpio->irq_base + line); - stat &= ~(1 << bit); - } - - stmpe_reg_write(stmpe, statmsbreg + i, status[i]); - stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_GPEDR_MSB] + i, - status[i]); - } - - return IRQ_HANDLED; -} - -static int __devinit stmpe_gpio_irq_init(struct stmpe_gpio *stmpe_gpio) -{ - int base = stmpe_gpio->irq_base; - int irq; - - for (irq = base; irq < base + stmpe_gpio->chip.ngpio; irq++) { - set_irq_chip_data(irq, stmpe_gpio); - set_irq_chip_and_handler(irq, &stmpe_gpio_irq_chip, - handle_simple_irq); - set_irq_nested_thread(irq, 1); -#ifdef CONFIG_ARM - set_irq_flags(irq, IRQF_VALID); -#else - set_irq_noprobe(irq); -#endif - } - - return 0; -} - -static void stmpe_gpio_irq_remove(struct stmpe_gpio *stmpe_gpio) -{ - int base = stmpe_gpio->irq_base; - int irq; - - for (irq = base; irq < base + stmpe_gpio->chip.ngpio; irq++) { -#ifdef CONFIG_ARM - set_irq_flags(irq, 0); -#endif - set_irq_chip_and_handler(irq, NULL, NULL); - set_irq_chip_data(irq, NULL); - } -} - -static int __devinit stmpe_gpio_probe(struct platform_device *pdev) -{ - struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); - struct stmpe_gpio_platform_data *pdata; - struct stmpe_gpio *stmpe_gpio; - int ret; - int irq; - - pdata = stmpe->pdata->gpio; - if (!pdata) - return -ENODEV; - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - - stmpe_gpio = kzalloc(sizeof(struct stmpe_gpio), GFP_KERNEL); - if (!stmpe_gpio) - return -ENOMEM; - - mutex_init(&stmpe_gpio->irq_lock); - - stmpe_gpio->dev = &pdev->dev; - stmpe_gpio->stmpe = stmpe; - - stmpe_gpio->chip = template_chip; - stmpe_gpio->chip.ngpio = stmpe->num_gpios; - stmpe_gpio->chip.dev = &pdev->dev; - stmpe_gpio->chip.base = pdata ? pdata->gpio_base : -1; - - stmpe_gpio->irq_base = stmpe->irq_base + STMPE_INT_GPIO(0); - - ret = stmpe_enable(stmpe, STMPE_BLOCK_GPIO); - if (ret) - return ret; - - ret = stmpe_gpio_irq_init(stmpe_gpio); - if (ret) - goto out_free; - - ret = request_threaded_irq(irq, NULL, stmpe_gpio_irq, IRQF_ONESHOT, - "stmpe-gpio", stmpe_gpio); - if (ret) { - dev_err(&pdev->dev, "unable to get irq: %d\n", ret); - goto out_removeirq; - } - - ret = gpiochip_add(&stmpe_gpio->chip); - if (ret) { - dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); - goto out_freeirq; - } - - if (pdata && pdata->setup) - pdata->setup(stmpe, stmpe_gpio->chip.base); - - platform_set_drvdata(pdev, stmpe_gpio); - - return 0; - -out_freeirq: - free_irq(irq, stmpe_gpio); -out_removeirq: - stmpe_gpio_irq_remove(stmpe_gpio); -out_free: - kfree(stmpe_gpio); - return ret; -} - -static int __devexit stmpe_gpio_remove(struct platform_device *pdev) -{ - struct stmpe_gpio *stmpe_gpio = platform_get_drvdata(pdev); - struct stmpe *stmpe = stmpe_gpio->stmpe; - struct stmpe_gpio_platform_data *pdata = stmpe->pdata->gpio; - int irq = platform_get_irq(pdev, 0); - int ret; - - if (pdata && pdata->remove) - pdata->remove(stmpe, stmpe_gpio->chip.base); - - ret = gpiochip_remove(&stmpe_gpio->chip); - if (ret < 0) { - dev_err(stmpe_gpio->dev, - "unable to remove gpiochip: %d\n", ret); - return ret; - } - - stmpe_disable(stmpe, STMPE_BLOCK_GPIO); - - free_irq(irq, stmpe_gpio); - stmpe_gpio_irq_remove(stmpe_gpio); - platform_set_drvdata(pdev, NULL); - kfree(stmpe_gpio); - - return 0; -} - -static struct platform_driver stmpe_gpio_driver = { - .driver.name = "stmpe-gpio", - .driver.owner = THIS_MODULE, - .probe = stmpe_gpio_probe, - .remove = __devexit_p(stmpe_gpio_remove), -}; - -static int __init stmpe_gpio_init(void) -{ - return platform_driver_register(&stmpe_gpio_driver); -} -subsys_initcall(stmpe_gpio_init); - -static void __exit stmpe_gpio_exit(void) -{ - platform_driver_unregister(&stmpe_gpio_driver); -} -module_exit(stmpe_gpio_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("STMPExxxx GPIO driver"); -MODULE_AUTHOR("Rabin Vincent "); diff --git a/trunk/drivers/gpio/wm831x-gpio.c b/trunk/drivers/gpio/wm831x-gpio.c index 309644cf4d9b..1fa449a1a4cb 100644 --- a/trunk/drivers/gpio/wm831x-gpio.c +++ b/trunk/drivers/gpio/wm831x-gpio.c @@ -108,37 +108,6 @@ static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) return wm831x->irq_base + WM831X_IRQ_GPIO_1 + offset; } -static int wm831x_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, - unsigned debounce) -{ - struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip); - struct wm831x *wm831x = wm831x_gpio->wm831x; - int reg = WM831X_GPIO1_CONTROL + offset; - int ret, fn; - - ret = wm831x_reg_read(wm831x, reg); - if (ret < 0) - return ret; - - switch (ret & WM831X_GPN_FN_MASK) { - case 0: - case 1: - break; - default: - /* Not in GPIO mode */ - return -EBUSY; - } - - if (debounce >= 32 && debounce <= 64) - fn = 0; - else if (debounce >= 4000 && debounce <= 8000) - fn = 1; - else - return -EINVAL; - - return wm831x_set_bits(wm831x, reg, WM831X_GPN_FN_MASK, fn); -} - #ifdef CONFIG_DEBUG_FS static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { @@ -239,7 +208,6 @@ static struct gpio_chip template_chip = { .direction_output = wm831x_gpio_direction_out, .set = wm831x_gpio_set, .to_irq = wm831x_gpio_to_irq, - .set_debounce = wm831x_gpio_set_debounce, .dbg_show = wm831x_gpio_dbg_show, .can_sleep = 1, }; diff --git a/trunk/drivers/gpu/drm/ati_pcigart.c b/trunk/drivers/gpu/drm/ati_pcigart.c index 1c3649242208..17be051b7aa3 100644 --- a/trunk/drivers/gpu/drm/ati_pcigart.c +++ b/trunk/drivers/gpu/drm/ati_pcigart.c @@ -152,7 +152,7 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga /* we need to support large memory configurations */ entry->busaddr[i] = pci_map_page(dev->pdev, entry->pagelist[i], 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); - if (pci_dma_mapping_error(dev->pdev, entry->busaddr[i])) { + if (entry->busaddr[i] == 0) { DRM_ERROR("unable to map PCIGART pages!\n"); drm_ati_pcigart_cleanup(dev, gart_info); address = NULL; diff --git a/trunk/drivers/gpu/drm/drm_bufs.c b/trunk/drivers/gpu/drm/drm_bufs.c index 3e257a50bf56..a5c9ce93bbcb 100644 --- a/trunk/drivers/gpu/drm/drm_bufs.c +++ b/trunk/drivers/gpu/drm/drm_bufs.c @@ -328,13 +328,14 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset, return -EINVAL; } - list = kzalloc(sizeof(*list), GFP_KERNEL); + list = kmalloc(sizeof(*list), GFP_KERNEL); if (!list) { if (map->type == _DRM_REGISTERS) iounmap(map->handle); kfree(map); return -EINVAL; } + memset(list, 0, sizeof(*list)); list->map = map; mutex_lock(&dev->struct_mutex); @@ -677,12 +678,13 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request) return -EINVAL; } - entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL); + entry->buflist = kmalloc(count * sizeof(*entry->buflist), GFP_KERNEL); if (!entry->buflist) { mutex_unlock(&dev->struct_mutex); atomic_dec(&dev->buf_alloc); return -ENOMEM; } + memset(entry->buflist, 0, count * sizeof(*entry->buflist)); entry->buf_size = size; entry->page_order = page_order; @@ -706,7 +708,7 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request) buf->file_priv = NULL; buf->dev_priv_size = dev->driver->dev_priv_size; - buf->dev_private = kzalloc(buf->dev_priv_size, GFP_KERNEL); + buf->dev_private = kmalloc(buf->dev_priv_size, GFP_KERNEL); if (!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; @@ -715,6 +717,7 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request) atomic_dec(&dev->buf_alloc); return -ENOMEM; } + memset(buf->dev_private, 0, buf->dev_priv_size); DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address); @@ -829,20 +832,22 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request) return -EINVAL; } - entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL); + entry->buflist = kmalloc(count * sizeof(*entry->buflist), GFP_KERNEL); if (!entry->buflist) { mutex_unlock(&dev->struct_mutex); atomic_dec(&dev->buf_alloc); return -ENOMEM; } + memset(entry->buflist, 0, count * sizeof(*entry->buflist)); - entry->seglist = kzalloc(count * sizeof(*entry->seglist), GFP_KERNEL); + entry->seglist = kmalloc(count * sizeof(*entry->seglist), GFP_KERNEL); if (!entry->seglist) { kfree(entry->buflist); mutex_unlock(&dev->struct_mutex); atomic_dec(&dev->buf_alloc); return -ENOMEM; } + memset(entry->seglist, 0, count * sizeof(*entry->seglist)); /* Keep the original pagelist until we know all the allocations * have succeeded @@ -906,8 +911,8 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request) buf->file_priv = NULL; buf->dev_priv_size = dev->driver->dev_priv_size; - buf->dev_private = kzalloc(buf->dev_priv_size, - GFP_KERNEL); + buf->dev_private = kmalloc(buf->dev_priv_size, + GFP_KERNEL); if (!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; @@ -918,6 +923,7 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request) atomic_dec(&dev->buf_alloc); return -ENOMEM; } + memset(buf->dev_private, 0, buf->dev_priv_size); DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address); @@ -1042,13 +1048,14 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request return -EINVAL; } - entry->buflist = kzalloc(count * sizeof(*entry->buflist), + entry->buflist = kmalloc(count * sizeof(*entry->buflist), GFP_KERNEL); if (!entry->buflist) { mutex_unlock(&dev->struct_mutex); atomic_dec(&dev->buf_alloc); return -ENOMEM; } + memset(entry->buflist, 0, count * sizeof(*entry->buflist)); entry->buf_size = size; entry->page_order = page_order; @@ -1073,7 +1080,7 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request buf->file_priv = NULL; buf->dev_priv_size = dev->driver->dev_priv_size; - buf->dev_private = kzalloc(buf->dev_priv_size, GFP_KERNEL); + buf->dev_private = kmalloc(buf->dev_priv_size, GFP_KERNEL); if (!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; @@ -1083,6 +1090,8 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request return -ENOMEM; } + memset(buf->dev_private, 0, buf->dev_priv_size); + DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address); offset += alignment; @@ -1200,13 +1209,14 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request return -EINVAL; } - entry->buflist = kzalloc(count * sizeof(*entry->buflist), + entry->buflist = kmalloc(count * sizeof(*entry->buflist), GFP_KERNEL); if (!entry->buflist) { mutex_unlock(&dev->struct_mutex); atomic_dec(&dev->buf_alloc); return -ENOMEM; } + memset(entry->buflist, 0, count * sizeof(*entry->buflist)); entry->buf_size = size; entry->page_order = page_order; @@ -1230,7 +1240,7 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request buf->file_priv = NULL; buf->dev_priv_size = dev->driver->dev_priv_size; - buf->dev_private = kzalloc(buf->dev_priv_size, GFP_KERNEL); + buf->dev_private = kmalloc(buf->dev_priv_size, GFP_KERNEL); if (!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; @@ -1239,6 +1249,7 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request atomic_dec(&dev->buf_alloc); return -ENOMEM; } + memset(buf->dev_private, 0, buf->dev_priv_size); DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address); diff --git a/trunk/drivers/gpu/drm/drm_crtc.c b/trunk/drivers/gpu/drm/drm_crtc.c index 37e0b4fa482a..4c68f76993d8 100644 --- a/trunk/drivers/gpu/drm/drm_crtc.c +++ b/trunk/drivers/gpu/drm/drm_crtc.c @@ -1682,9 +1682,9 @@ int drm_mode_addfb(struct drm_device *dev, /* TODO setup destructor callback */ fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); - if (IS_ERR(fb)) { + if (!fb) { DRM_ERROR("could not create framebuffer\n"); - ret = PTR_ERR(fb); + ret = -EINVAL; goto out; } @@ -2541,7 +2541,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev, goto out; } - crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size); + crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size); out: mutex_unlock(&dev->mode_config.mutex); diff --git a/trunk/drivers/gpu/drm/drm_crtc_helper.c b/trunk/drivers/gpu/drm/drm_crtc_helper.c index 7e31d4348340..b9e4dbfa0533 100644 --- a/trunk/drivers/gpu/drm/drm_crtc_helper.c +++ b/trunk/drivers/gpu/drm/drm_crtc_helper.c @@ -817,12 +817,12 @@ int drm_helper_resume_force_mode(struct drm_device *dev) if (encoder_funcs->dpms) (*encoder_funcs->dpms) (encoder, drm_helper_choose_encoder_dpms(encoder)); - } - crtc_funcs = crtc->helper_private; - if (crtc_funcs->dpms) - (*crtc_funcs->dpms) (crtc, - drm_helper_choose_crtc_dpms(crtc)); + crtc_funcs = crtc->helper_private; + if (crtc_funcs->dpms) + (*crtc_funcs->dpms) (crtc, + drm_helper_choose_crtc_dpms(crtc)); + } } } /* disable the unused connectors while restoring the modesetting */ diff --git a/trunk/drivers/gpu/drm/drm_edid.c b/trunk/drivers/gpu/drm/drm_edid.c index 96e963108225..dce5c4a97f8d 100644 --- a/trunk/drivers/gpu/drm/drm_edid.c +++ b/trunk/drivers/gpu/drm/drm_edid.c @@ -33,11 +33,6 @@ #include #include "drmP.h" #include "drm_edid.h" -#include "drm_edid_modes.h" - -#define version_greater(edid, maj, min) \ - (((edid)->version > (maj)) || \ - ((edid)->version == (maj) && (edid)->revision > (min))) #define EDID_EST_TIMINGS 16 #define EDID_STD_TIMINGS 8 @@ -67,13 +62,6 @@ /* use +hsync +vsync for detailed mode */ #define EDID_QUIRK_DETAILED_SYNC_PP (1 << 6) -struct detailed_mode_closure { - struct drm_connector *connector; - struct edid *edid; - bool preferred; - u32 quirks; - int modes; -}; #define LEVEL_DMT 0 #define LEVEL_GTF 1 @@ -387,6 +375,7 @@ static u32 edid_get_quirks(struct edid *edid) #define MODE_SIZE(m) ((m)->hdisplay * (m)->vdisplay) #define MODE_REFRESH_DIFF(m,r) (abs((m)->vrefresh - target_refresh)) + /** * edid_fixup_preferred - set preferred modes based on quirk list * @connector: has mode list to fix up @@ -433,6 +422,245 @@ static void edid_fixup_preferred(struct drm_connector *connector, preferred_mode->type |= DRM_MODE_TYPE_PREFERRED; } +/* + * Add the Autogenerated from the DMT spec. + * This table is copied from xfree86/modes/xf86EdidModes.c. + * But the mode with Reduced blank feature is deleted. + */ +static struct drm_display_mode drm_dmt_modes[] = { + /* 640x350@85Hz */ + { DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER, 31500, 640, 672, + 736, 832, 0, 350, 382, 385, 445, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, + /* 640x400@85Hz */ + { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 31500, 640, 672, + 736, 832, 0, 400, 401, 404, 445, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 720x400@85Hz */ + { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 756, + 828, 936, 0, 400, 401, 404, 446, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 640x480@60Hz */ + { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656, + 752, 800, 0, 480, 489, 492, 525, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, + /* 640x480@72Hz */ + { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664, + 704, 832, 0, 480, 489, 492, 520, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, + /* 640x480@75Hz */ + { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656, + 720, 840, 0, 480, 481, 484, 500, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, + /* 640x480@85Hz */ + { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 36000, 640, 696, + 752, 832, 0, 480, 481, 484, 509, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, + /* 800x600@56Hz */ + { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824, + 896, 1024, 0, 600, 601, 603, 625, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 800x600@60Hz */ + { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840, + 968, 1056, 0, 600, 601, 605, 628, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 800x600@72Hz */ + { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856, + 976, 1040, 0, 600, 637, 643, 666, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 800x600@75Hz */ + { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816, + 896, 1056, 0, 600, 601, 604, 625, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 800x600@85Hz */ + { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 56250, 800, 832, + 896, 1048, 0, 600, 601, 604, 631, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 848x480@60Hz */ + { DRM_MODE("848x480", DRM_MODE_TYPE_DRIVER, 33750, 848, 864, + 976, 1088, 0, 480, 486, 494, 517, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1024x768@43Hz, interlace */ + { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 44900, 1024, 1032, + 1208, 1264, 0, 768, 768, 772, 817, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | + DRM_MODE_FLAG_INTERLACE) }, + /* 1024x768@60Hz */ + { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048, + 1184, 1344, 0, 768, 771, 777, 806, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, + /* 1024x768@70Hz */ + { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048, + 1184, 1328, 0, 768, 771, 777, 806, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, + /* 1024x768@75Hz */ + { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78750, 1024, 1040, + 1136, 1312, 0, 768, 769, 772, 800, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1024x768@85Hz */ + { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 94500, 1024, 1072, + 1168, 1376, 0, 768, 769, 772, 808, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1152x864@75Hz */ + { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216, + 1344, 1600, 0, 864, 865, 868, 900, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1280x768@60Hz */ + { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 79500, 1280, 1344, + 1472, 1664, 0, 768, 771, 778, 798, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1280x768@75Hz */ + { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 102250, 1280, 1360, + 1488, 1696, 0, 768, 771, 778, 805, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, + /* 1280x768@85Hz */ + { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 117500, 1280, 1360, + 1496, 1712, 0, 768, 771, 778, 809, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1280x800@60Hz */ + { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 83500, 1280, 1352, + 1480, 1680, 0, 800, 803, 809, 831, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, + /* 1280x800@75Hz */ + { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 106500, 1280, 1360, + 1488, 1696, 0, 800, 803, 809, 838, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1280x800@85Hz */ + { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 122500, 1280, 1360, + 1496, 1712, 0, 800, 803, 809, 843, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1280x960@60Hz */ + { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1376, + 1488, 1800, 0, 960, 961, 964, 1000, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1280x960@85Hz */ + { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1344, + 1504, 1728, 0, 960, 961, 964, 1011, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1280x1024@60Hz */ + { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1328, + 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1280x1024@75Hz */ + { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296, + 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1280x1024@85Hz */ + { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 157500, 1280, 1344, + 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1360x768@60Hz */ + { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 85500, 1360, 1424, + 1536, 1792, 0, 768, 771, 777, 795, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1440x1050@60Hz */ + { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 121750, 1400, 1488, + 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1440x1050@75Hz */ + { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 156000, 1400, 1504, + 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1440x1050@85Hz */ + { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 179500, 1400, 1504, + 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1440x900@60Hz */ + { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 106500, 1440, 1520, + 1672, 1904, 0, 900, 903, 909, 934, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1440x900@75Hz */ + { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 136750, 1440, 1536, + 1688, 1936, 0, 900, 903, 909, 942, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1440x900@85Hz */ + { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 157000, 1440, 1544, + 1696, 1952, 0, 900, 903, 909, 948, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1600x1200@60Hz */ + { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 162000, 1600, 1664, + 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1600x1200@65Hz */ + { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 175500, 1600, 1664, + 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1600x1200@70Hz */ + { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 189000, 1600, 1664, + 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1600x1200@75Hz */ + { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 202500, 1600, 1664, + 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1600x1200@85Hz */ + { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 229500, 1600, 1664, + 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1680x1050@60Hz */ + { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 146250, 1680, 1784, + 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1680x1050@75Hz */ + { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 187000, 1680, 1800, + 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1680x1050@85Hz */ + { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 214750, 1680, 1808, + 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1792x1344@60Hz */ + { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 204750, 1792, 1920, + 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1729x1344@75Hz */ + { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 261000, 1792, 1888, + 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1853x1392@60Hz */ + { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 218250, 1856, 1952, + 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1856x1392@75Hz */ + { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 288000, 1856, 1984, + 2208, 2560, 0, 1392, 1395, 1399, 1500, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1920x1200@60Hz */ + { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 193250, 1920, 2056, + 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1920x1200@75Hz */ + { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 245250, 1920, 2056, + 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1920x1200@85Hz */ + { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 281250, 1920, 2064, + 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1920x1440@60Hz */ + { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 234000, 1920, 2048, + 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 1920x1440@75Hz */ + { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2064, + 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 2560x1600@60Hz */ + { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 348500, 2560, 2752, + 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 2560x1600@75HZ */ + { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 443250, 2560, 2768, + 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, + /* 2560x1600@85HZ */ + { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 505250, 2560, 2768, + 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, +}; +static const int drm_num_dmt_modes = + sizeof(drm_dmt_modes) / sizeof(struct drm_display_mode); + struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, int hsize, int vsize, int fresh) { @@ -456,46 +684,6 @@ EXPORT_SYMBOL(drm_mode_find_dmt); typedef void detailed_cb(struct detailed_timing *timing, void *closure); -static void -cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure) -{ - int i, n = 0; - u8 rev = ext[0x01], d = ext[0x02]; - u8 *det_base = ext + d; - - switch (rev) { - case 0: - /* can't happen */ - return; - case 1: - /* have to infer how many blocks we have, check pixel clock */ - for (i = 0; i < 6; i++) - if (det_base[18*i] || det_base[18*i+1]) - n++; - break; - default: - /* explicit count */ - n = min(ext[0x03] & 0x0f, 6); - break; - } - - for (i = 0; i < n; i++) - cb((struct detailed_timing *)(det_base + 18 * i), closure); -} - -static void -vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure) -{ - unsigned int i, n = min((int)ext[0x02], 6); - u8 *det_base = ext + 5; - - if (ext[0x01] != 1) - return; /* unknown version */ - - for (i = 0; i < n; i++) - cb((struct detailed_timing *)(det_base + 18 * i), closure); -} - static void drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure) { @@ -508,19 +696,7 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure) for (i = 0; i < EDID_DETAILED_TIMINGS; i++) cb(&(edid->detailed_timings[i]), closure); - for (i = 1; i <= raw_edid[0x7e]; i++) { - u8 *ext = raw_edid + (i * EDID_LENGTH); - switch (*ext) { - case CEA_EXT: - cea_for_each_detailed_block(ext, cb, closure); - break; - case VTB_EXT: - vtb_for_each_detailed_block(ext, cb, closure); - break; - default: - break; - } - } + /* XXX extension block walk */ } static void @@ -871,6 +1047,117 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, return mode; } +/* + * Detailed mode info for the EDID "established modes" data to use. + */ +static struct drm_display_mode edid_est_modes[] = { + { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840, + 968, 1056, 0, 600, 601, 605, 628, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@60Hz */ + { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824, + 896, 1024, 0, 600, 601, 603, 625, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@56Hz */ + { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656, + 720, 840, 0, 480, 481, 484, 500, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@75Hz */ + { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664, + 704, 832, 0, 480, 489, 491, 520, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@72Hz */ + { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 30240, 640, 704, + 768, 864, 0, 480, 483, 486, 525, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@67Hz */ + { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25200, 640, 656, + 752, 800, 0, 480, 490, 492, 525, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@60Hz */ + { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 738, + 846, 900, 0, 400, 421, 423, 449, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 720x400@88Hz */ + { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 28320, 720, 738, + 846, 900, 0, 400, 412, 414, 449, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 720x400@70Hz */ + { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296, + 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1280x1024@75Hz */ + { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78800, 1024, 1040, + 1136, 1312, 0, 768, 769, 772, 800, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1024x768@75Hz */ + { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048, + 1184, 1328, 0, 768, 771, 777, 806, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@70Hz */ + { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048, + 1184, 1344, 0, 768, 771, 777, 806, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@60Hz */ + { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER,44900, 1024, 1032, + 1208, 1264, 0, 768, 768, 776, 817, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_INTERLACE) }, /* 1024x768@43Hz */ + { DRM_MODE("832x624", DRM_MODE_TYPE_DRIVER, 57284, 832, 864, + 928, 1152, 0, 624, 625, 628, 667, 0, + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 832x624@75Hz */ + { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816, + 896, 1056, 0, 600, 601, 604, 625, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@75Hz */ + { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856, + 976, 1040, 0, 600, 637, 643, 666, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@72Hz */ + { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216, + 1344, 1600, 0, 864, 865, 868, 900, 0, + DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1152x864@75Hz */ +}; + +/** + * add_established_modes - get est. modes from EDID and add them + * @edid: EDID block to scan + * + * Each EDID block contains a bitmap of the supported "established modes" list + * (defined above). Tease them out and add them to the global modes list. + */ +static int add_established_modes(struct drm_connector *connector, struct edid *edid) +{ + struct drm_device *dev = connector->dev; + unsigned long est_bits = edid->established_timings.t1 | + (edid->established_timings.t2 << 8) | + ((edid->established_timings.mfg_rsvd & 0x80) << 9); + int i, modes = 0; + + for (i = 0; i <= EDID_EST_TIMINGS; i++) + if (est_bits & (1<standard_timings[i], + edid->revision); + if (newmode) { + drm_mode_probed_add(connector, newmode); + modes++; + } + } + + return modes; +} + static bool mode_is_rb(struct drm_display_mode *mode) { @@ -980,33 +1267,113 @@ drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid, return modes; } -static void -do_inferred_modes(struct detailed_timing *timing, void *c) +static int drm_cvt_modes(struct drm_connector *connector, + struct detailed_timing *timing) { - struct detailed_mode_closure *closure = c; - struct detailed_non_pixel *data = &timing->data.other_data; - int gtf = (closure->edid->features & DRM_EDID_FEATURE_DEFAULT_GTF); + int i, j, modes = 0; + struct drm_display_mode *newmode; + struct drm_device *dev = connector->dev; + struct cvt_timing *cvt; + const int rates[] = { 60, 85, 75, 60, 50 }; + const u8 empty[3] = { 0, 0, 0 }; - if (gtf && data->type == EDID_DETAIL_MONITOR_RANGE) - closure->modes += drm_gtf_modes_for_range(closure->connector, - closure->edid, - timing); -} + for (i = 0; i < 4; i++) { + int uninitialized_var(width), height; + cvt = &(timing->data.other_data.data.cvt[i]); -static int -add_inferred_modes(struct drm_connector *connector, struct edid *edid) -{ - struct detailed_mode_closure closure = { - connector, edid, 0, 0, 0 - }; + if (!memcmp(cvt->code, empty, 3)) + continue; - if (version_greater(edid, 1, 0)) - drm_for_each_detailed_block((u8 *)edid, do_inferred_modes, - &closure); + height = (cvt->code[0] + ((cvt->code[1] & 0xf0) << 4) + 1) * 2; + switch (cvt->code[1] & 0x0c) { + case 0x00: + width = height * 4 / 3; + break; + case 0x04: + width = height * 16 / 9; + break; + case 0x08: + width = height * 16 / 10; + break; + case 0x0c: + width = height * 15 / 9; + break; + } + + for (j = 1; j < 5; j++) { + if (cvt->code[2] & (1 << j)) { + newmode = drm_cvt_mode(dev, width, height, + rates[j], j == 0, + false, false); + if (newmode) { + drm_mode_probed_add(connector, newmode); + modes++; + } + } + } + } - return closure.modes; + return modes; } +static const struct { + short w; + short h; + short r; + short rb; +} est3_modes[] = { + /* byte 6 */ + { 640, 350, 85, 0 }, + { 640, 400, 85, 0 }, + { 720, 400, 85, 0 }, + { 640, 480, 85, 0 }, + { 848, 480, 60, 0 }, + { 800, 600, 85, 0 }, + { 1024, 768, 85, 0 }, + { 1152, 864, 75, 0 }, + /* byte 7 */ + { 1280, 768, 60, 1 }, + { 1280, 768, 60, 0 }, + { 1280, 768, 75, 0 }, + { 1280, 768, 85, 0 }, + { 1280, 960, 60, 0 }, + { 1280, 960, 85, 0 }, + { 1280, 1024, 60, 0 }, + { 1280, 1024, 85, 0 }, + /* byte 8 */ + { 1360, 768, 60, 0 }, + { 1440, 900, 60, 1 }, + { 1440, 900, 60, 0 }, + { 1440, 900, 75, 0 }, + { 1440, 900, 85, 0 }, + { 1400, 1050, 60, 1 }, + { 1400, 1050, 60, 0 }, + { 1400, 1050, 75, 0 }, + /* byte 9 */ + { 1400, 1050, 85, 0 }, + { 1680, 1050, 60, 1 }, + { 1680, 1050, 60, 0 }, + { 1680, 1050, 75, 0 }, + { 1680, 1050, 85, 0 }, + { 1600, 1200, 60, 0 }, + { 1600, 1200, 65, 0 }, + { 1600, 1200, 70, 0 }, + /* byte 10 */ + { 1600, 1200, 75, 0 }, + { 1600, 1200, 85, 0 }, + { 1792, 1344, 60, 0 }, + { 1792, 1344, 85, 0 }, + { 1856, 1392, 60, 0 }, + { 1856, 1392, 75, 0 }, + { 1920, 1200, 60, 1 }, + { 1920, 1200, 60, 0 }, + /* byte 11 */ + { 1920, 1200, 75, 0 }, + { 1920, 1200, 85, 0 }, + { 1920, 1440, 60, 0 }, + { 1920, 1440, 75, 0 }, +}; + static int drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing) { @@ -1036,63 +1403,37 @@ drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing) return modes; } -static void -do_established_modes(struct detailed_timing *timing, void *c) +static int add_detailed_modes(struct drm_connector *connector, + struct detailed_timing *timing, + struct edid *edid, u32 quirks, int preferred) { - struct detailed_mode_closure *closure = c; + int i, modes = 0; struct detailed_non_pixel *data = &timing->data.other_data; - - if (data->type == EDID_DETAIL_EST_TIMINGS) - closure->modes += drm_est3_modes(closure->connector, timing); -} - -/** - * add_established_modes - get est. modes from EDID and add them - * @edid: EDID block to scan - * - * Each EDID block contains a bitmap of the supported "established modes" list - * (defined above). Tease them out and add them to the global modes list. - */ -static int -add_established_modes(struct drm_connector *connector, struct edid *edid) -{ + int gtf = (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF); + struct drm_display_mode *newmode; struct drm_device *dev = connector->dev; - unsigned long est_bits = edid->established_timings.t1 | - (edid->established_timings.t2 << 8) | - ((edid->established_timings.mfg_rsvd & 0x80) << 9); - int i, modes = 0; - struct detailed_mode_closure closure = { - connector, edid, 0, 0, 0 - }; - for (i = 0; i <= EDID_EST_TIMINGS; i++) { - if (est_bits & (1<pixel_clock) { + newmode = drm_mode_detailed(dev, edid, timing, quirks); + if (!newmode) + return 0; - return modes + closure.modes; -} + if (preferred) + newmode->type |= DRM_MODE_TYPE_PREFERRED; -static void -do_standard_modes(struct detailed_timing *timing, void *c) -{ - struct detailed_mode_closure *closure = c; - struct detailed_non_pixel *data = &timing->data.other_data; - struct drm_connector *connector = closure->connector; - struct edid *edid = closure->edid; + drm_mode_probed_add(connector, newmode); + return 1; + } - if (data->type == EDID_DETAIL_STD_MODES) { - int i; + /* other timing types */ + switch (data->type) { + case EDID_DETAIL_MONITOR_RANGE: + if (gtf) + modes += drm_gtf_modes_for_range(connector, edid, + timing); + break; + case EDID_DETAIL_STD_MODES: + /* Six modes per detailed section */ for (i = 0; i < 6; i++) { struct std_timing *std; struct drm_display_mode *newmode; @@ -1102,169 +1443,108 @@ do_standard_modes(struct detailed_timing *timing, void *c) edid->revision); if (newmode) { drm_mode_probed_add(connector, newmode); - closure->modes++; + modes++; } } + break; + case EDID_DETAIL_CVT_3BYTE: + modes += drm_cvt_modes(connector, timing); + break; + case EDID_DETAIL_EST_TIMINGS: + modes += drm_est3_modes(connector, timing); + break; + default: + break; } + + return modes; } /** - * add_standard_modes - get std. modes from EDID and add them + * add_detailed_info - get detailed mode info from EDID data + * @connector: attached connector * @edid: EDID block to scan + * @quirks: quirks to apply * - * Standard modes can be calculated using the appropriate standard (DMT, - * GTF or CVT. Grab them from @edid and add them to the list. + * Some of the detailed timing sections may contain mode information. Grab + * it and add it to the list. */ -static int -add_standard_modes(struct drm_connector *connector, struct edid *edid) +static int add_detailed_info(struct drm_connector *connector, + struct edid *edid, u32 quirks) { int i, modes = 0; - struct detailed_mode_closure closure = { - connector, edid, 0, 0, 0 - }; - - for (i = 0; i < EDID_STD_TIMINGS; i++) { - struct drm_display_mode *newmode; - - newmode = drm_mode_std(connector, edid, - &edid->standard_timings[i], - edid->revision); - if (newmode) { - drm_mode_probed_add(connector, newmode); - modes++; - } - } - - if (version_greater(edid, 1, 0)) - drm_for_each_detailed_block((u8 *)edid, do_standard_modes, - &closure); - - /* XXX should also look for standard codes in VTB blocks */ - - return modes + closure.modes; -} -static int drm_cvt_modes(struct drm_connector *connector, - struct detailed_timing *timing) -{ - int i, j, modes = 0; - struct drm_display_mode *newmode; - struct drm_device *dev = connector->dev; - struct cvt_timing *cvt; - const int rates[] = { 60, 85, 75, 60, 50 }; - const u8 empty[3] = { 0, 0, 0 }; + for (i = 0; i < EDID_DETAILED_TIMINGS; i++) { + struct detailed_timing *timing = &edid->detailed_timings[i]; + int preferred = (i == 0); - for (i = 0; i < 4; i++) { - int uninitialized_var(width), height; - cvt = &(timing->data.other_data.data.cvt[i]); + if (preferred && edid->version == 1 && edid->revision < 4) + preferred = (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); - if (!memcmp(cvt->code, empty, 3)) + /* In 1.0, only timings are allowed */ + if (!timing->pixel_clock && edid->version == 1 && + edid->revision == 0) continue; - height = (cvt->code[0] + ((cvt->code[1] & 0xf0) << 4) + 1) * 2; - switch (cvt->code[1] & 0x0c) { - case 0x00: - width = height * 4 / 3; - break; - case 0x04: - width = height * 16 / 9; - break; - case 0x08: - width = height * 16 / 10; - break; - case 0x0c: - width = height * 15 / 9; - break; - } - - for (j = 1; j < 5; j++) { - if (cvt->code[2] & (1 << j)) { - newmode = drm_cvt_mode(dev, width, height, - rates[j], j == 0, - false, false); - if (newmode) { - drm_mode_probed_add(connector, newmode); - modes++; - } - } - } + modes += add_detailed_modes(connector, timing, edid, quirks, + preferred); } return modes; } -static void -do_cvt_mode(struct detailed_timing *timing, void *c) -{ - struct detailed_mode_closure *closure = c; - struct detailed_non_pixel *data = &timing->data.other_data; - - if (data->type == EDID_DETAIL_CVT_3BYTE) - closure->modes += drm_cvt_modes(closure->connector, timing); -} - -static int -add_cvt_modes(struct drm_connector *connector, struct edid *edid) -{ - struct detailed_mode_closure closure = { - connector, edid, 0, 0, 0 - }; - - if (version_greater(edid, 1, 2)) - drm_for_each_detailed_block((u8 *)edid, do_cvt_mode, &closure); - - /* XXX should also look for CVT codes in VTB blocks */ - - return closure.modes; -} - -static void -do_detailed_mode(struct detailed_timing *timing, void *c) +/** + * add_detailed_mode_eedid - get detailed mode info from addtional timing + * EDID block + * @connector: attached connector + * @edid: EDID block to scan(It is only to get addtional timing EDID block) + * @quirks: quirks to apply + * + * Some of the detailed timing sections may contain mode information. Grab + * it and add it to the list. + */ +static int add_detailed_info_eedid(struct drm_connector *connector, + struct edid *edid, u32 quirks) { - struct detailed_mode_closure *closure = c; - struct drm_display_mode *newmode; - - if (timing->pixel_clock) { - newmode = drm_mode_detailed(closure->connector->dev, - closure->edid, timing, - closure->quirks); - if (!newmode) - return; + int i, modes = 0; + char *edid_ext = NULL; + struct detailed_timing *timing; + int start_offset, end_offset; - if (closure->preferred) - newmode->type |= DRM_MODE_TYPE_PREFERRED; + if (edid->version == 1 && edid->revision < 3) + return 0; + if (!edid->extensions) + return 0; - drm_mode_probed_add(closure->connector, newmode); - closure->modes++; - closure->preferred = 0; + /* Find CEA extension */ + for (i = 0; i < edid->extensions; i++) { + edid_ext = (char *)edid + EDID_LENGTH * (i + 1); + if (edid_ext[0] == 0x02) + break; } -} -/* - * add_detailed_modes - Add modes from detailed timings - * @connector: attached connector - * @edid: EDID block to scan - * @quirks: quirks to apply - */ -static int -add_detailed_modes(struct drm_connector *connector, struct edid *edid, - u32 quirks) -{ - struct detailed_mode_closure closure = { - connector, - edid, - 1, - quirks, - 0 - }; + if (i == edid->extensions) + return 0; - if (closure.preferred && !version_greater(edid, 1, 3)) - closure.preferred = - (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); + /* Get the start offset of detailed timing block */ + start_offset = edid_ext[2]; + if (start_offset == 0) { + /* If the start_offset is zero, it means that neither detailed + * info nor data block exist. In such case it is also + * unnecessary to parse the detailed timing info. + */ + return 0; + } - drm_for_each_detailed_block((u8 *)edid, do_detailed_mode, &closure); + end_offset = EDID_LENGTH; + end_offset -= sizeof(struct detailed_timing); + for (i = start_offset; i < end_offset; + i += sizeof(struct detailed_timing)) { + timing = (struct detailed_timing *)(edid_ext + i); + modes += add_detailed_modes(connector, timing, edid, quirks, 0); + } - return closure.modes; + return modes; } #define HDMI_IDENTIFIER 0x000C03 @@ -1360,21 +1640,35 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid) * - established timing codes * - modes inferred from GTF or CVT range information * - * We get this pretty much right. + * We don't quite implement this yet, but we're close. * * XXX order for additional mode types in extension blocks? */ - num_modes += add_detailed_modes(connector, edid, quirks); - num_modes += add_cvt_modes(connector, edid); + num_modes += add_detailed_info(connector, edid, quirks); + num_modes += add_detailed_info_eedid(connector, edid, quirks); num_modes += add_standard_modes(connector, edid); num_modes += add_established_modes(connector, edid); - num_modes += add_inferred_modes(connector, edid); if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75)) edid_fixup_preferred(connector, quirks); + connector->display_info.serration_vsync = (edid->input & DRM_EDID_INPUT_SERRATION_VSYNC) ? 1 : 0; + connector->display_info.sync_on_green = (edid->input & DRM_EDID_INPUT_SYNC_ON_GREEN) ? 1 : 0; + connector->display_info.composite_sync = (edid->input & DRM_EDID_INPUT_COMPOSITE_SYNC) ? 1 : 0; + connector->display_info.separate_syncs = (edid->input & DRM_EDID_INPUT_SEPARATE_SYNCS) ? 1 : 0; + connector->display_info.blank_to_black = (edid->input & DRM_EDID_INPUT_BLANK_TO_BLACK) ? 1 : 0; + connector->display_info.video_level = (edid->input & DRM_EDID_INPUT_VIDEO_LEVEL) >> 5; + connector->display_info.digital = (edid->input & DRM_EDID_INPUT_DIGITAL) ? 1 : 0; connector->display_info.width_mm = edid->width_cm * 10; connector->display_info.height_mm = edid->height_cm * 10; + connector->display_info.gamma = edid->gamma; + connector->display_info.gtf_supported = (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) ? 1 : 0; + connector->display_info.standard_color = (edid->features & DRM_EDID_FEATURE_STANDARD_COLOR) ? 1 : 0; + connector->display_info.display_type = (edid->features & DRM_EDID_FEATURE_DISPLAY_TYPE) >> 3; + connector->display_info.active_off_supported = (edid->features & DRM_EDID_FEATURE_PM_ACTIVE_OFF) ? 1 : 0; + connector->display_info.suspend_supported = (edid->features & DRM_EDID_FEATURE_PM_SUSPEND) ? 1 : 0; + connector->display_info.standby_supported = (edid->features & DRM_EDID_FEATURE_PM_STANDBY) ? 1 : 0; + connector->display_info.gamma = edid->gamma; return num_modes; } diff --git a/trunk/drivers/gpu/drm/drm_edid_modes.h b/trunk/drivers/gpu/drm/drm_edid_modes.h deleted file mode 100644 index 6eb7592e152f..000000000000 --- a/trunk/drivers/gpu/drm/drm_edid_modes.h +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright (c) 2007-2008 Intel Corporation - * Jesse Barnes - * Copyright 2010 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include "drmP.h" -#include "drm_edid.h" - -/* - * Autogenerated from the DMT spec. - * This table is copied from xfree86/modes/xf86EdidModes.c. - * But the mode with Reduced blank feature is deleted. - */ -static struct drm_display_mode drm_dmt_modes[] = { - /* 640x350@85Hz */ - { DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER, 31500, 640, 672, - 736, 832, 0, 350, 382, 385, 445, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, - /* 640x400@85Hz */ - { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 31500, 640, 672, - 736, 832, 0, 400, 401, 404, 445, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 720x400@85Hz */ - { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 756, - 828, 936, 0, 400, 401, 404, 446, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 640x480@60Hz */ - { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656, - 752, 800, 0, 480, 489, 492, 525, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, - /* 640x480@72Hz */ - { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664, - 704, 832, 0, 480, 489, 492, 520, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, - /* 640x480@75Hz */ - { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656, - 720, 840, 0, 480, 481, 484, 500, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, - /* 640x480@85Hz */ - { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 36000, 640, 696, - 752, 832, 0, 480, 481, 484, 509, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, - /* 800x600@56Hz */ - { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824, - 896, 1024, 0, 600, 601, 603, 625, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 800x600@60Hz */ - { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840, - 968, 1056, 0, 600, 601, 605, 628, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 800x600@72Hz */ - { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856, - 976, 1040, 0, 600, 637, 643, 666, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 800x600@75Hz */ - { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816, - 896, 1056, 0, 600, 601, 604, 625, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 800x600@85Hz */ - { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 56250, 800, 832, - 896, 1048, 0, 600, 601, 604, 631, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 848x480@60Hz */ - { DRM_MODE("848x480", DRM_MODE_TYPE_DRIVER, 33750, 848, 864, - 976, 1088, 0, 480, 486, 494, 517, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1024x768@43Hz, interlace */ - { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 44900, 1024, 1032, - 1208, 1264, 0, 768, 768, 772, 817, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | - DRM_MODE_FLAG_INTERLACE) }, - /* 1024x768@60Hz */ - { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048, - 1184, 1344, 0, 768, 771, 777, 806, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, - /* 1024x768@70Hz */ - { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048, - 1184, 1328, 0, 768, 771, 777, 806, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, - /* 1024x768@75Hz */ - { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78750, 1024, 1040, - 1136, 1312, 0, 768, 769, 772, 800, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1024x768@85Hz */ - { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 94500, 1024, 1072, - 1168, 1376, 0, 768, 769, 772, 808, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1152x864@75Hz */ - { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216, - 1344, 1600, 0, 864, 865, 868, 900, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1280x768@60Hz */ - { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 79500, 1280, 1344, - 1472, 1664, 0, 768, 771, 778, 798, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1280x768@75Hz */ - { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 102250, 1280, 1360, - 1488, 1696, 0, 768, 771, 778, 805, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, - /* 1280x768@85Hz */ - { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 117500, 1280, 1360, - 1496, 1712, 0, 768, 771, 778, 809, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1280x800@60Hz */ - { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 83500, 1280, 1352, - 1480, 1680, 0, 800, 803, 809, 831, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, - /* 1280x800@75Hz */ - { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 106500, 1280, 1360, - 1488, 1696, 0, 800, 803, 809, 838, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1280x800@85Hz */ - { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 122500, 1280, 1360, - 1496, 1712, 0, 800, 803, 809, 843, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1280x960@60Hz */ - { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1376, - 1488, 1800, 0, 960, 961, 964, 1000, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1280x960@85Hz */ - { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1344, - 1504, 1728, 0, 960, 961, 964, 1011, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1280x1024@60Hz */ - { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1328, - 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1280x1024@75Hz */ - { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296, - 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1280x1024@85Hz */ - { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 157500, 1280, 1344, - 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1360x768@60Hz */ - { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 85500, 1360, 1424, - 1536, 1792, 0, 768, 771, 777, 795, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1440x1050@60Hz */ - { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 121750, 1400, 1488, - 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1440x1050@75Hz */ - { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 156000, 1400, 1504, - 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1440x1050@85Hz */ - { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 179500, 1400, 1504, - 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1440x900@60Hz */ - { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 106500, 1440, 1520, - 1672, 1904, 0, 900, 903, 909, 934, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1440x900@75Hz */ - { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 136750, 1440, 1536, - 1688, 1936, 0, 900, 903, 909, 942, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1440x900@85Hz */ - { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 157000, 1440, 1544, - 1696, 1952, 0, 900, 903, 909, 948, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1600x1200@60Hz */ - { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 162000, 1600, 1664, - 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1600x1200@65Hz */ - { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 175500, 1600, 1664, - 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1600x1200@70Hz */ - { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 189000, 1600, 1664, - 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1600x1200@75Hz */ - { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 202500, 1600, 1664, - 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1600x1200@85Hz */ - { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 229500, 1600, 1664, - 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1680x1050@60Hz */ - { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 146250, 1680, 1784, - 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1680x1050@75Hz */ - { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 187000, 1680, 1800, - 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1680x1050@85Hz */ - { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 214750, 1680, 1808, - 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1792x1344@60Hz */ - { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 204750, 1792, 1920, - 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1729x1344@75Hz */ - { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 261000, 1792, 1888, - 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1853x1392@60Hz */ - { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 218250, 1856, 1952, - 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1856x1392@75Hz */ - { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 288000, 1856, 1984, - 2208, 2560, 0, 1392, 1395, 1399, 1500, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1920x1200@60Hz */ - { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 193250, 1920, 2056, - 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1920x1200@75Hz */ - { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 245250, 1920, 2056, - 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1920x1200@85Hz */ - { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 281250, 1920, 2064, - 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1920x1440@60Hz */ - { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 234000, 1920, 2048, - 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 1920x1440@75Hz */ - { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2064, - 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 2560x1600@60Hz */ - { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 348500, 2560, 2752, - 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 2560x1600@75HZ */ - { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 443250, 2560, 2768, - 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, - /* 2560x1600@85HZ */ - { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 505250, 2560, 2768, - 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, -}; -static const int drm_num_dmt_modes = - sizeof(drm_dmt_modes) / sizeof(struct drm_display_mode); - -static struct drm_display_mode edid_est_modes[] = { - { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840, - 968, 1056, 0, 600, 601, 605, 628, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@60Hz */ - { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824, - 896, 1024, 0, 600, 601, 603, 625, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@56Hz */ - { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656, - 720, 840, 0, 480, 481, 484, 500, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@75Hz */ - { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664, - 704, 832, 0, 480, 489, 491, 520, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@72Hz */ - { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 30240, 640, 704, - 768, 864, 0, 480, 483, 486, 525, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@67Hz */ - { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25200, 640, 656, - 752, 800, 0, 480, 490, 492, 525, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@60Hz */ - { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 738, - 846, 900, 0, 400, 421, 423, 449, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 720x400@88Hz */ - { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 28320, 720, 738, - 846, 900, 0, 400, 412, 414, 449, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 720x400@70Hz */ - { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296, - 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1280x1024@75Hz */ - { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78800, 1024, 1040, - 1136, 1312, 0, 768, 769, 772, 800, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1024x768@75Hz */ - { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048, - 1184, 1328, 0, 768, 771, 777, 806, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@70Hz */ - { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048, - 1184, 1344, 0, 768, 771, 777, 806, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@60Hz */ - { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER,44900, 1024, 1032, - 1208, 1264, 0, 768, 768, 776, 817, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_INTERLACE) }, /* 1024x768@43Hz */ - { DRM_MODE("832x624", DRM_MODE_TYPE_DRIVER, 57284, 832, 864, - 928, 1152, 0, 624, 625, 628, 667, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 832x624@75Hz */ - { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816, - 896, 1056, 0, 600, 601, 604, 625, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@75Hz */ - { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856, - 976, 1040, 0, 600, 637, 643, 666, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@72Hz */ - { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216, - 1344, 1600, 0, 864, 865, 868, 900, 0, - DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1152x864@75Hz */ -}; - -static const struct { - short w; - short h; - short r; - short rb; -} est3_modes[] = { - /* byte 6 */ - { 640, 350, 85, 0 }, - { 640, 400, 85, 0 }, - { 720, 400, 85, 0 }, - { 640, 480, 85, 0 }, - { 848, 480, 60, 0 }, - { 800, 600, 85, 0 }, - { 1024, 768, 85, 0 }, - { 1152, 864, 75, 0 }, - /* byte 7 */ - { 1280, 768, 60, 1 }, - { 1280, 768, 60, 0 }, - { 1280, 768, 75, 0 }, - { 1280, 768, 85, 0 }, - { 1280, 960, 60, 0 }, - { 1280, 960, 85, 0 }, - { 1280, 1024, 60, 0 }, - { 1280, 1024, 85, 0 }, - /* byte 8 */ - { 1360, 768, 60, 0 }, - { 1440, 900, 60, 1 }, - { 1440, 900, 60, 0 }, - { 1440, 900, 75, 0 }, - { 1440, 900, 85, 0 }, - { 1400, 1050, 60, 1 }, - { 1400, 1050, 60, 0 }, - { 1400, 1050, 75, 0 }, - /* byte 9 */ - { 1400, 1050, 85, 0 }, - { 1680, 1050, 60, 1 }, - { 1680, 1050, 60, 0 }, - { 1680, 1050, 75, 0 }, - { 1680, 1050, 85, 0 }, - { 1600, 1200, 60, 0 }, - { 1600, 1200, 65, 0 }, - { 1600, 1200, 70, 0 }, - /* byte 10 */ - { 1600, 1200, 75, 0 }, - { 1600, 1200, 85, 0 }, - { 1792, 1344, 60, 0 }, - { 1792, 1344, 85, 0 }, - { 1856, 1392, 60, 0 }, - { 1856, 1392, 75, 0 }, - { 1920, 1200, 60, 1 }, - { 1920, 1200, 60, 0 }, - /* byte 11 */ - { 1920, 1200, 75, 0 }, - { 1920, 1200, 85, 0 }, - { 1920, 1440, 60, 0 }, - { 1920, 1440, 75, 0 }, -}; -static const int num_est3_modes = sizeof(est3_modes) / sizeof(est3_modes[0]); diff --git a/trunk/drivers/gpu/drm/drm_fops.c b/trunk/drivers/gpu/drm/drm_fops.c index 3a652a65546f..2ca8df8b6102 100644 --- a/trunk/drivers/gpu/drm/drm_fops.c +++ b/trunk/drivers/gpu/drm/drm_fops.c @@ -135,9 +135,15 @@ int drm_open(struct inode *inode, struct file *filp) retcode = drm_open_helper(inode, filp, dev); if (!retcode) { atomic_inc(&dev->counts[_DRM_STAT_OPENS]); - if (!dev->open_count++) + spin_lock(&dev->count_lock); + if (!dev->open_count++) { + spin_unlock(&dev->count_lock); retcode = drm_setup(dev); + goto out; + } + spin_unlock(&dev->count_lock); } +out: if (!retcode) { mutex_lock(&dev->struct_mutex); if (minor->type == DRM_MINOR_LEGACY) { @@ -564,14 +570,18 @@ int drm_release(struct inode *inode, struct file *filp) */ atomic_inc(&dev->counts[_DRM_STAT_CLOSES]); + spin_lock(&dev->count_lock); if (!--dev->open_count) { if (atomic_read(&dev->ioctl_count)) { DRM_ERROR("Device busy: %d\n", atomic_read(&dev->ioctl_count)); retcode = -EBUSY; - } else - retcode = drm_lastclose(dev); + goto out; + } + retcode = drm_lastclose(dev); } +out: + spin_unlock(&dev->count_lock); mutex_unlock(&drm_global_mutex); return retcode; diff --git a/trunk/drivers/gpu/drm/drm_gem.c b/trunk/drivers/gpu/drm/drm_gem.c index bf92d07510df..4f1b86714489 100644 --- a/trunk/drivers/gpu/drm/drm_gem.c +++ b/trunk/drivers/gpu/drm/drm_gem.c @@ -322,7 +322,7 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data, obj = drm_gem_object_lookup(dev, file_priv, args->handle); if (obj == NULL) - return -ENOENT; + return -EBADF; again: if (idr_pre_get(&dev->object_name_idr, GFP_KERNEL) == 0) { diff --git a/trunk/drivers/gpu/drm/drm_ioctl.c b/trunk/drivers/gpu/drm/drm_ioctl.c index 47db4df37a69..7b03b197fc00 100644 --- a/trunk/drivers/gpu/drm/drm_ioctl.c +++ b/trunk/drivers/gpu/drm/drm_ioctl.c @@ -392,7 +392,6 @@ int drm_setversion(struct drm_device *dev, void *data, struct drm_file *file_pri if (sv->drm_di_minor >= 1) { /* * Version 1.1 includes tying of DRM to specific device - * Version 1.4 has proper PCI domain support */ retcode = drm_set_busid(dev, file_priv); if (retcode) diff --git a/trunk/drivers/gpu/drm/i2c/ch7006_drv.c b/trunk/drivers/gpu/drm/i2c/ch7006_drv.c index 08792a740f18..833b35f44a77 100644 --- a/trunk/drivers/gpu/drm/i2c/ch7006_drv.c +++ b/trunk/drivers/gpu/drm/i2c/ch7006_drv.c @@ -470,7 +470,6 @@ static int ch7006_encoder_init(struct i2c_client *client, priv->hmargin = 50; priv->vmargin = 50; priv->last_dpms = -1; - priv->chip_version = ch7006_read(client, CH7006_VERSION_ID); if (ch7006_tv_norm) { for (i = 0; i < NUM_TV_NORMS; i++) { diff --git a/trunk/drivers/gpu/drm/i2c/ch7006_mode.c b/trunk/drivers/gpu/drm/i2c/ch7006_mode.c index c860f24a5afc..e447dfb63890 100644 --- a/trunk/drivers/gpu/drm/i2c/ch7006_mode.c +++ b/trunk/drivers/gpu/drm/i2c/ch7006_mode.c @@ -316,10 +316,7 @@ void ch7006_setup_power_state(struct drm_encoder *encoder) } } else { - if (priv->chip_version >= 0x20) - *power |= bitfs(CH7006_POWER_LEVEL, FULL_POWER_OFF); - else - *power |= bitfs(CH7006_POWER_LEVEL, POWER_OFF); + *power |= bitfs(CH7006_POWER_LEVEL, FULL_POWER_OFF); } } diff --git a/trunk/drivers/gpu/drm/i2c/ch7006_priv.h b/trunk/drivers/gpu/drm/i2c/ch7006_priv.h index 17667b7d57e7..1c6d2e3bd96f 100644 --- a/trunk/drivers/gpu/drm/i2c/ch7006_priv.h +++ b/trunk/drivers/gpu/drm/i2c/ch7006_priv.h @@ -95,7 +95,6 @@ struct ch7006_priv { int flicker; int scale; - int chip_version; int last_dpms; }; diff --git a/trunk/drivers/gpu/drm/i915/i915_gem.c b/trunk/drivers/gpu/drm/i915/i915_gem.c index 0758c7802e6b..2a4ed7ca8b4e 100644 --- a/trunk/drivers/gpu/drm/i915/i915_gem.c +++ b/trunk/drivers/gpu/drm/i915/i915_gem.c @@ -456,7 +456,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data, obj = drm_gem_object_lookup(dev, file_priv, args->handle); if (obj == NULL) - return -ENOENT; + return -EBADF; obj_priv = to_intel_bo(obj); /* Bounds check source. @@ -919,7 +919,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, obj = drm_gem_object_lookup(dev, file_priv, args->handle); if (obj == NULL) - return -ENOENT; + return -EBADF; obj_priv = to_intel_bo(obj); /* Bounds check destination. @@ -1002,7 +1002,7 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, obj = drm_gem_object_lookup(dev, file_priv, args->handle); if (obj == NULL) - return -ENOENT; + return -EBADF; obj_priv = to_intel_bo(obj); mutex_lock(&dev->struct_mutex); @@ -1060,7 +1060,7 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data, obj = drm_gem_object_lookup(dev, file_priv, args->handle); if (obj == NULL) { mutex_unlock(&dev->struct_mutex); - return -ENOENT; + return -EBADF; } #if WATCH_BUF @@ -1099,7 +1099,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data, obj = drm_gem_object_lookup(dev, file_priv, args->handle); if (obj == NULL) - return -ENOENT; + return -EBADF; offset = args->offset; @@ -1373,7 +1373,7 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data, obj = drm_gem_object_lookup(dev, file_priv, args->handle); if (obj == NULL) - return -ENOENT; + return -EBADF; mutex_lock(&dev->struct_mutex); @@ -3364,7 +3364,7 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj, reloc->target_handle); if (target_obj == NULL) { i915_gem_object_unpin(obj); - return -ENOENT; + return -EBADF; } target_obj_priv = to_intel_bo(target_obj); @@ -3781,7 +3781,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, exec_list[i].handle, i); /* prevent error path from reading uninitialized data */ args->buffer_count = i + 1; - ret = -ENOENT; + ret = -EBADF; goto err; } @@ -3791,7 +3791,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, object_list[i]); /* prevent error path from reading uninitialized data */ args->buffer_count = i + 1; - ret = -EINVAL; + ret = -EBADF; goto err; } obj_priv->in_execbuffer = true; @@ -4265,7 +4265,7 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data, DRM_ERROR("Bad handle in i915_gem_pin_ioctl(): %d\n", args->handle); mutex_unlock(&dev->struct_mutex); - return -ENOENT; + return -EBADF; } obj_priv = to_intel_bo(obj); @@ -4321,7 +4321,7 @@ i915_gem_unpin_ioctl(struct drm_device *dev, void *data, DRM_ERROR("Bad handle in i915_gem_unpin_ioctl(): %d\n", args->handle); mutex_unlock(&dev->struct_mutex); - return -ENOENT; + return -EBADF; } obj_priv = to_intel_bo(obj); @@ -4355,7 +4355,7 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data, if (obj == NULL) { DRM_ERROR("Bad handle in i915_gem_busy_ioctl(): %d\n", args->handle); - return -ENOENT; + return -EBADF; } mutex_lock(&dev->struct_mutex); @@ -4408,7 +4408,7 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data, if (obj == NULL) { DRM_ERROR("Bad handle in i915_gem_madvise_ioctl(): %d\n", args->handle); - return -ENOENT; + return -EBADF; } mutex_lock(&dev->struct_mutex); diff --git a/trunk/drivers/gpu/drm/i915/i915_gem_tiling.c b/trunk/drivers/gpu/drm/i915/i915_gem_tiling.c index 710eca70b323..155719e4d16f 100644 --- a/trunk/drivers/gpu/drm/i915/i915_gem_tiling.c +++ b/trunk/drivers/gpu/drm/i915/i915_gem_tiling.c @@ -275,7 +275,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data, obj = drm_gem_object_lookup(dev, file_priv, args->handle); if (obj == NULL) - return -ENOENT; + return -EINVAL; obj_priv = to_intel_bo(obj); if (!i915_tiling_ok(dev, args->stride, obj->size, args->tiling_mode)) { @@ -362,7 +362,7 @@ i915_gem_get_tiling(struct drm_device *dev, void *data, obj = drm_gem_object_lookup(dev, file_priv, args->handle); if (obj == NULL) - return -ENOENT; + return -EINVAL; obj_priv = to_intel_bo(obj); mutex_lock(&dev->struct_mutex); diff --git a/trunk/drivers/gpu/drm/i915/intel_display.c b/trunk/drivers/gpu/drm/i915/intel_display.c index 5ec10e02341b..1e5e0d379fa9 100644 --- a/trunk/drivers/gpu/drm/i915/intel_display.c +++ b/trunk/drivers/gpu/drm/i915/intel_display.c @@ -4429,12 +4429,15 @@ void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, } static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, - u16 *blue, uint32_t start, uint32_t size) + u16 *blue, uint32_t size) { - int end = (start + size > 256) ? 256 : start + size, i; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); + int i; + + if (size != 256) + return; - for (i = start; i < end; i++) { + for (i = 0; i < 256; i++) { intel_crtc->lut_r[i] = red[i] >> 8; intel_crtc->lut_g[i] = green[i] >> 8; intel_crtc->lut_b[i] = blue[i] >> 8; @@ -5409,18 +5412,18 @@ intel_user_framebuffer_create(struct drm_device *dev, obj = drm_gem_object_lookup(dev, filp, mode_cmd->handle); if (!obj) - return ERR_PTR(-ENOENT); + return NULL; intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL); if (!intel_fb) - return ERR_PTR(-ENOMEM); + return NULL; ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); if (ret) { drm_gem_object_unreference_unlocked(obj); kfree(intel_fb); - return ERR_PTR(ret); + return NULL; } return &intel_fb->base; diff --git a/trunk/drivers/gpu/drm/i915/intel_fb.c b/trunk/drivers/gpu/drm/i915/intel_fb.c index 7bdc96256bf5..a79525f434a8 100644 --- a/trunk/drivers/gpu/drm/i915/intel_fb.c +++ b/trunk/drivers/gpu/drm/i915/intel_fb.c @@ -121,9 +121,7 @@ static int intelfb_create(struct intel_fbdev *ifbdev, info->par = ifbdev; - ret = intel_framebuffer_init(dev, &ifbdev->ifb, &mode_cmd, fbo); - if (ret) - goto out_unpin; + intel_framebuffer_init(dev, &ifbdev->ifb, &mode_cmd, fbo); fb = &ifbdev->ifb.base; diff --git a/trunk/drivers/gpu/drm/nouveau/Makefile b/trunk/drivers/gpu/drm/nouveau/Makefile index e9b06e4ef2a2..2405d5ef0ca7 100644 --- a/trunk/drivers/gpu/drm/nouveau/Makefile +++ b/trunk/drivers/gpu/drm/nouveau/Makefile @@ -12,12 +12,12 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \ nouveau_dp.o \ nv04_timer.o \ nv04_mc.o nv40_mc.o nv50_mc.o \ - nv04_fb.o nv10_fb.o nv30_fb.o nv40_fb.o nv50_fb.o nvc0_fb.o \ - nv04_fifo.o nv10_fifo.o nv40_fifo.o nv50_fifo.o nvc0_fifo.o \ + nv04_fb.o nv10_fb.o nv30_fb.o nv40_fb.o nv50_fb.o \ + nv04_fifo.o nv10_fifo.o nv40_fifo.o nv50_fifo.o \ nv04_graph.o nv10_graph.o nv20_graph.o \ - nv40_graph.o nv50_graph.o nvc0_graph.o \ + nv40_graph.o nv50_graph.o \ nv40_grctx.o nv50_grctx.o \ - nv04_instmem.o nv50_instmem.o nvc0_instmem.o \ + nv04_instmem.o nv50_instmem.o \ nv50_crtc.o nv50_dac.o nv50_sor.o \ nv50_cursor.o nv50_display.o nv50_fbcon.o \ nv04_dac.o nv04_dfp.o nv04_tv.o nv17_tv.o nv17_tv_modes.o \ diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_bios.c b/trunk/drivers/gpu/drm/nouveau/nouveau_bios.c index 0b69a9628c95..7369b5e73649 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_bios.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_bios.c @@ -1927,31 +1927,6 @@ init_condition_time(struct nvbios *bios, uint16_t offset, return 3; } -static int -init_ltime(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) -{ - /* - * INIT_LTIME opcode: 0x57 ('V') - * - * offset (8 bit): opcode - * offset + 1 (16 bit): time - * - * Sleep for "time" miliseconds. - */ - - unsigned time = ROM16(bios->data[offset + 1]); - - if (!iexec->execute) - return 3; - - BIOSLOG(bios, "0x%04X: Sleeping for 0x%04X miliseconds\n", - offset, time); - - msleep(time); - - return 3; -} - static int init_zm_reg_sequence(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) @@ -2019,64 +1994,6 @@ init_sub_direct(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) return 3; } -static int -init_i2c_if(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) -{ - /* - * INIT_I2C_IF opcode: 0x5E ('^') - * - * offset (8 bit): opcode - * offset + 1 (8 bit): DCB I2C table entry index - * offset + 2 (8 bit): I2C slave address - * offset + 3 (8 bit): I2C register - * offset + 4 (8 bit): mask - * offset + 5 (8 bit): data - * - * Read the register given by "I2C register" on the device addressed - * by "I2C slave address" on the I2C bus given by "DCB I2C table - * entry index". Compare the result AND "mask" to "data". - * If they're not equal, skip subsequent opcodes until condition is - * inverted (INIT_NOT), or we hit INIT_RESUME - */ - - uint8_t i2c_index = bios->data[offset + 1]; - uint8_t i2c_address = bios->data[offset + 2] >> 1; - uint8_t reg = bios->data[offset + 3]; - uint8_t mask = bios->data[offset + 4]; - uint8_t data = bios->data[offset + 5]; - struct nouveau_i2c_chan *chan; - union i2c_smbus_data val; - int ret; - - /* no execute check by design */ - - BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X\n", - offset, i2c_index, i2c_address); - - chan = init_i2c_device_find(bios->dev, i2c_index); - if (!chan) - return -ENODEV; - - ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, - I2C_SMBUS_READ, reg, - I2C_SMBUS_BYTE_DATA, &val); - if (ret < 0) { - BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X, Value: [no device], " - "Mask: 0x%02X, Data: 0x%02X\n", - offset, reg, mask, data); - iexec->execute = 0; - return 6; - } - - BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X, Value: 0x%02X, " - "Mask: 0x%02X, Data: 0x%02X\n", - offset, reg, val.byte, mask, data); - - iexec->execute = ((val.byte & mask) == data); - - return 6; -} - static int init_copy_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) { @@ -2166,10 +2083,9 @@ peek_fb(struct drm_device *dev, struct io_mapping *fb, uint32_t val = 0; if (off < pci_resource_len(dev->pdev, 1)) { - uint32_t __iomem *p = - io_mapping_map_atomic_wc(fb, off & PAGE_MASK, KM_USER0); + uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off, KM_USER0); - val = ioread32(p + (off & ~PAGE_MASK)); + val = ioread32(p); io_mapping_unmap_atomic(p, KM_USER0); } @@ -2182,10 +2098,9 @@ poke_fb(struct drm_device *dev, struct io_mapping *fb, uint32_t off, uint32_t val) { if (off < pci_resource_len(dev->pdev, 1)) { - uint32_t __iomem *p = - io_mapping_map_atomic_wc(fb, off & PAGE_MASK, KM_USER0); + uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off, KM_USER0); - iowrite32(val, p + (off & ~PAGE_MASK)); + iowrite32(val, p); wmb(); io_mapping_unmap_atomic(p, KM_USER0); @@ -2250,7 +2165,7 @@ nv04_init_compute_mem(struct nvbios *bios) NV04_PFB_BOOT_0_RAM_AMOUNT, NV04_PFB_BOOT_0_RAM_AMOUNT_4MB); - } else if (peek_fb(dev, fb, 0) != patt) { + } else if (peek_fb(dev, fb, 0) == patt) { if (read_back_fb(dev, fb, 0x800000, patt)) bios_md32(bios, NV04_PFB_BOOT_0, NV04_PFB_BOOT_0_RAM_AMOUNT, @@ -2678,7 +2593,7 @@ init_configure_preinit(struct nvbios *bios, uint16_t offset, /* no iexec->execute check by design */ uint32_t straps = bios_rd32(bios, NV_PEXTDEV_BOOT_0); - uint8_t cr3c = ((straps << 2) & 0xf0) | (straps & 0x40) >> 6; + uint8_t cr3c = ((straps << 2) & 0xf0) | (straps & (1 << 6)); if (bios->major_version > 2) return 0; @@ -3225,7 +3140,7 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) const uint32_t nv50_gpio_ctl[2] = { 0xe100, 0xe28c }; int i; - if (dev_priv->card_type < NV_50) { + if (dev_priv->card_type != NV_50) { NV_ERROR(bios->dev, "INIT_GPIO on unsupported chipset\n"); return 1; } @@ -3575,69 +3490,6 @@ init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) return len; } -static int -init_i2c_long_if(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) -{ - /* - * INIT_I2C_LONG_IF opcode: 0x9A ('') - * - * offset (8 bit): opcode - * offset + 1 (8 bit): DCB I2C table entry index - * offset + 2 (8 bit): I2C slave address - * offset + 3 (16 bit): I2C register - * offset + 5 (8 bit): mask - * offset + 6 (8 bit): data - * - * Read the register given by "I2C register" on the device addressed - * by "I2C slave address" on the I2C bus given by "DCB I2C table - * entry index". Compare the result AND "mask" to "data". - * If they're not equal, skip subsequent opcodes until condition is - * inverted (INIT_NOT), or we hit INIT_RESUME - */ - - uint8_t i2c_index = bios->data[offset + 1]; - uint8_t i2c_address = bios->data[offset + 2] >> 1; - uint8_t reglo = bios->data[offset + 3]; - uint8_t reghi = bios->data[offset + 4]; - uint8_t mask = bios->data[offset + 5]; - uint8_t data = bios->data[offset + 6]; - struct nouveau_i2c_chan *chan; - uint8_t buf0[2] = { reghi, reglo }; - uint8_t buf1[1]; - struct i2c_msg msg[2] = { - { i2c_address, 0, 1, buf0 }, - { i2c_address, I2C_M_RD, 1, buf1 }, - }; - int ret; - - /* no execute check by design */ - - BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X\n", - offset, i2c_index, i2c_address); - - chan = init_i2c_device_find(bios->dev, i2c_index); - if (!chan) - return -ENODEV; - - - ret = i2c_transfer(&chan->adapter, msg, 2); - if (ret < 0) { - BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X:0x%02X, Value: [no device], " - "Mask: 0x%02X, Data: 0x%02X\n", - offset, reghi, reglo, mask, data); - iexec->execute = 0; - return 7; - } - - BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X:0x%02X, Value: 0x%02X, " - "Mask: 0x%02X, Data: 0x%02X\n", - offset, reghi, reglo, buf1[0], mask, data); - - iexec->execute = ((buf1[0] & mask) == data); - - return 7; -} - static struct init_tbl_entry itbl_entry[] = { /* command name , id , length , offset , mult , command handler */ /* INIT_PROG (0x31, 15, 10, 4) removed due to no example of use */ @@ -3664,11 +3516,9 @@ static struct init_tbl_entry itbl_entry[] = { { "INIT_ZM_CR" , 0x53, init_zm_cr }, { "INIT_ZM_CR_GROUP" , 0x54, init_zm_cr_group }, { "INIT_CONDITION_TIME" , 0x56, init_condition_time }, - { "INIT_LTIME" , 0x57, init_ltime }, { "INIT_ZM_REG_SEQUENCE" , 0x58, init_zm_reg_sequence }, /* INIT_INDIRECT_REG (0x5A, 7, 0, 0) removed due to no example of use */ { "INIT_SUB_DIRECT" , 0x5B, init_sub_direct }, - { "INIT_I2C_IF" , 0x5E, init_i2c_if }, { "INIT_COPY_NV_REG" , 0x5F, init_copy_nv_reg }, { "INIT_ZM_INDEX_IO" , 0x62, init_zm_index_io }, { "INIT_COMPUTE_MEM" , 0x63, init_compute_mem }, @@ -3702,7 +3552,6 @@ static struct init_tbl_entry itbl_entry[] = { { "INIT_97" , 0x97, init_97 }, { "INIT_AUXCH" , 0x98, init_auxch }, { "INIT_ZM_AUXCH" , 0x99, init_zm_auxch }, - { "INIT_I2C_LONG_IF" , 0x9A, init_i2c_long_if }, { NULL , 0 , NULL } }; @@ -4561,7 +4410,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent, bios->display.script_table_ptr, table[2], table[3], table[0] >= 0x21); if (!otable) { - NV_DEBUG_KMS(dev, "failed to match any output table\n"); + NV_ERROR(dev, "Couldn't find matching output script table\n"); return 1; } @@ -4618,7 +4467,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent, if (script) script = clkcmptable(bios, script, pxclk); if (!script) { - NV_DEBUG_KMS(dev, "clock script 0 not found\n"); + NV_ERROR(dev, "clock script 0 not found\n"); return 1; } @@ -4977,7 +4826,7 @@ int get_pll_limits(struct drm_device *dev, uint32_t limit_match, struct pll_lims pll_lim->min_p = record[12]; pll_lim->max_p = record[13]; /* where did this go to?? */ - if ((entry[0] & 0xf0) == 0x80) + if (limit_match == 0x00614100 || limit_match == 0x00614900) pll_lim->refclk = 27000; else pll_lim->refclk = 100000; @@ -6003,7 +5852,7 @@ static void fabricate_vga_output(struct dcb_table *dcb, int i2c, int heads) entry->i2c_index = i2c; entry->heads = heads; entry->location = DCB_LOC_ON_CHIP; - entry->or = 1; + /* "or" mostly unused in early gen crt modesetting, 0 is fine */ } static void fabricate_dvi_i_output(struct dcb_table *dcb, bool twoHeads) @@ -6131,13 +5980,7 @@ parse_dcb20_entry(struct drm_device *dev, struct dcb_table *dcb, } break; case OUTPUT_TMDS: - if (dcb->version >= 0x40) - entry->tmdsconf.sor.link = (conf & 0x00000030) >> 4; - else if (dcb->version >= 0x30) - entry->tmdsconf.slave_addr = (conf & 0x00000700) >> 8; - else if (dcb->version >= 0x22) - entry->tmdsconf.slave_addr = (conf & 0x00000070) >> 4; - + entry->tmdsconf.sor.link = (conf & 0x00000030) >> 4; break; case 0xe: /* weird g80 mobile type that "nv" treats as a terminator */ @@ -6427,19 +6270,6 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) dcb->i2c_table = &bios->data[i2ctabptr]; if (dcb->version >= 0x30) dcb->i2c_default_indices = dcb->i2c_table[4]; - - /* - * Parse the "management" I2C bus, used for hardware - * monitoring and some external TMDS transmitters. - */ - if (dcb->version >= 0x22) { - int idx = (dcb->version >= 0x40 ? - dcb->i2c_default_indices & 0xf : - 2); - - read_dcb_i2c_entry(dev, dcb->version, dcb->i2c_table, - idx, &dcb->i2c[idx]); - } } if (entries > DCB_MAX_NUM_ENTRIES) diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_bios.h b/trunk/drivers/gpu/drm/nouveau/nouveau_bios.h index fd14dfd3d780..024458a8d060 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_bios.h +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_bios.h @@ -131,7 +131,6 @@ struct dcb_entry { } dpconf; struct { struct sor_conf sor; - int slave_addr; } tmdsconf; }; bool i2c_upper_default; diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_bo.c b/trunk/drivers/gpu/drm/nouveau/nouveau_bo.c index 84f85183d041..3ca8343c15df 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -51,6 +51,9 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo) if (nvbo->tile) nv10_mem_expire_tiling(dev, nvbo->tile, NULL); + spin_lock(&dev_priv->ttm.bo_list_lock); + list_del(&nvbo->head); + spin_unlock(&dev_priv->ttm.bo_list_lock); kfree(nvbo); } @@ -163,6 +166,9 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan, } nvbo->channel = NULL; + spin_lock(&dev_priv->ttm.bo_list_lock); + list_add_tail(&nvbo->head, &dev_priv->ttm.bo_list); + spin_unlock(&dev_priv->ttm.bo_list_lock); *pnvbo = nvbo; return 0; } diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_connector.c b/trunk/drivers/gpu/drm/nouveau/nouveau_connector.c index b1b22baf1428..734e92635e83 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -37,6 +37,12 @@ #include "nouveau_connector.h" #include "nouveau_hw.h" +static inline struct drm_encoder_slave_funcs * +get_slave_funcs(struct nouveau_encoder *enc) +{ + return to_encoder_slave(to_drm_encoder(enc))->slave_funcs; +} + static struct nouveau_encoder * find_encoder_by_type(struct drm_connector *connector, int type) { @@ -354,7 +360,6 @@ nouveau_connector_set_property(struct drm_connector *connector, { struct nouveau_connector *nv_connector = nouveau_connector(connector); struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder; - struct drm_encoder *encoder = to_drm_encoder(nv_encoder); struct drm_device *dev = connector->dev; int ret; @@ -427,8 +432,8 @@ nouveau_connector_set_property(struct drm_connector *connector, } if (nv_encoder && nv_encoder->dcb->type == OUTPUT_TV) - return get_slave_funcs(encoder)->set_property( - encoder, connector, property, value); + return get_slave_funcs(nv_encoder)-> + set_property(to_drm_encoder(nv_encoder), connector, property, value); return -EINVAL; } @@ -540,7 +545,6 @@ nouveau_connector_get_modes(struct drm_connector *connector) struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_connector *nv_connector = nouveau_connector(connector); struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder; - struct drm_encoder *encoder = to_drm_encoder(nv_encoder); int ret = 0; /* destroy the native mode, the attached monitor could have changed. @@ -576,7 +580,8 @@ nouveau_connector_get_modes(struct drm_connector *connector) } if (nv_encoder->dcb->type == OUTPUT_TV) - ret = get_slave_funcs(encoder)->get_modes(encoder, connector); + ret = get_slave_funcs(nv_encoder)-> + get_modes(to_drm_encoder(nv_encoder), connector); if (nv_connector->dcb->type == DCB_CONNECTOR_LVDS || nv_connector->dcb->type == DCB_CONNECTOR_eDP) @@ -592,7 +597,6 @@ nouveau_connector_mode_valid(struct drm_connector *connector, struct drm_nouveau_private *dev_priv = connector->dev->dev_private; struct nouveau_connector *nv_connector = nouveau_connector(connector); struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder; - struct drm_encoder *encoder = to_drm_encoder(nv_encoder); unsigned min_clock = 25000, max_clock = min_clock; unsigned clock = mode->clock; @@ -619,7 +623,8 @@ nouveau_connector_mode_valid(struct drm_connector *connector, max_clock = 350000; break; case OUTPUT_TV: - return get_slave_funcs(encoder)->mode_valid(encoder, mode); + return get_slave_funcs(nv_encoder)-> + mode_valid(to_drm_encoder(nv_encoder), mode); case OUTPUT_DP: if (nv_encoder->dp.link_bw == DP_LINK_BW_2_7) max_clock = nv_encoder->dp.link_nr * 270000; diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_display.c b/trunk/drivers/gpu/drm/nouveau/nouveau_display.c index 2e11fd65b4dd..74e6b4ed12c0 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_display.c @@ -84,16 +84,16 @@ nouveau_user_framebuffer_create(struct drm_device *dev, gem = drm_gem_object_lookup(dev, file_priv, mode_cmd->handle); if (!gem) - return ERR_PTR(-ENOENT); + return NULL; nouveau_fb = kzalloc(sizeof(struct nouveau_framebuffer), GFP_KERNEL); if (!nouveau_fb) - return ERR_PTR(-ENOMEM); + return NULL; ret = nouveau_framebuffer_init(dev, nouveau_fb, mode_cmd, nouveau_gem_object(gem)); if (ret) { drm_gem_object_unreference(gem); - return ERR_PTR(ret); + return NULL; } return &nouveau_fb->base; diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_dp.c b/trunk/drivers/gpu/drm/nouveau/nouveau_dp.c index 8a1b188b4cd1..33742b11188b 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_dp.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_dp.c @@ -572,64 +572,47 @@ nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr, return ret ? ret : (stat & NV50_AUXCH_STAT_REPLY); } -static int -nouveau_dp_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) +int +nouveau_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, + uint8_t write_byte, uint8_t *read_byte) { - struct nouveau_i2c_chan *auxch = (struct nouveau_i2c_chan *)adap; + struct i2c_algo_dp_aux_data *algo_data = adapter->algo_data; + struct nouveau_i2c_chan *auxch = (struct nouveau_i2c_chan *)adapter; struct drm_device *dev = auxch->dev; - struct i2c_msg *msg = msgs; - int ret, mcnt = num; - - while (mcnt--) { - u8 remaining = msg->len; - u8 *ptr = msg->buf; - - while (remaining) { - u8 cnt = (remaining > 16) ? 16 : remaining; - u8 cmd; - - if (msg->flags & I2C_M_RD) - cmd = AUX_I2C_READ; - else - cmd = AUX_I2C_WRITE; - - if (mcnt || remaining > 16) - cmd |= AUX_I2C_MOT; + int ret = 0, cmd, addr = algo_data->address; + uint8_t *buf; + + if (mode == MODE_I2C_READ) { + cmd = AUX_I2C_READ; + buf = read_byte; + } else { + cmd = (mode & MODE_I2C_READ) ? AUX_I2C_READ : AUX_I2C_WRITE; + buf = &write_byte; + } - ret = nouveau_dp_auxch(auxch, cmd, msg->addr, ptr, cnt); - if (ret < 0) - return ret; + if (!(mode & MODE_I2C_STOP)) + cmd |= AUX_I2C_MOT; - switch (ret & NV50_AUXCH_STAT_REPLY_I2C) { - case NV50_AUXCH_STAT_REPLY_I2C_ACK: - break; - case NV50_AUXCH_STAT_REPLY_I2C_NACK: - return -EREMOTEIO; - case NV50_AUXCH_STAT_REPLY_I2C_DEFER: - udelay(100); - continue; - default: - NV_ERROR(dev, "bad auxch reply: 0x%08x\n", ret); - return -EREMOTEIO; - } + if (mode & MODE_I2C_START) + return 1; - ptr += cnt; - remaining -= cnt; + for (;;) { + ret = nouveau_dp_auxch(auxch, cmd, addr, buf, 1); + if (ret < 0) + return ret; + + switch (ret & NV50_AUXCH_STAT_REPLY_I2C) { + case NV50_AUXCH_STAT_REPLY_I2C_ACK: + return 1; + case NV50_AUXCH_STAT_REPLY_I2C_NACK: + return -EREMOTEIO; + case NV50_AUXCH_STAT_REPLY_I2C_DEFER: + udelay(100); + break; + default: + NV_ERROR(dev, "invalid auxch status: 0x%08x\n", ret); + return -EREMOTEIO; } - - msg++; } - - return num; -} - -static u32 -nouveau_dp_i2c_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; } -const struct i2c_algorithm nouveau_dp_i2c_algo = { - .master_xfer = nouveau_dp_i2c_xfer, - .functionality = nouveau_dp_i2c_func -}; diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_drv.h b/trunk/drivers/gpu/drm/nouveau/nouveau_drv.h index e424bf74d706..e15db15dca77 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -410,7 +410,7 @@ enum nv04_fp_display_regs { struct nv04_crtc_reg { unsigned char MiscOutReg; /* */ - uint8_t CRTC[0xa0]; + uint8_t CRTC[0x9f]; uint8_t CR58[0x10]; uint8_t Sequencer[5]; uint8_t Graphics[9]; @@ -509,7 +509,6 @@ enum nouveau_card_type { NV_30 = 0x30, NV_40 = 0x40, NV_50 = 0x50, - NV_C0 = 0xc0, }; struct drm_nouveau_private { @@ -537,6 +536,8 @@ struct drm_nouveau_private { struct drm_global_reference mem_global_ref; struct ttm_bo_global_ref bo_global_ref; struct ttm_bo_device bdev; + spinlock_t bo_list_lock; + struct list_head bo_list; atomic_t validate_sequence; } ttm; @@ -930,10 +931,6 @@ extern void nv40_fb_set_region_tiling(struct drm_device *, int, uint32_t, extern int nv50_fb_init(struct drm_device *); extern void nv50_fb_takedown(struct drm_device *); -/* nvc0_fb.c */ -extern int nvc0_fb_init(struct drm_device *); -extern void nvc0_fb_takedown(struct drm_device *); - /* nv04_fifo.c */ extern int nv04_fifo_init(struct drm_device *); extern void nv04_fifo_disable(struct drm_device *); @@ -971,20 +968,6 @@ extern void nv50_fifo_destroy_context(struct nouveau_channel *); extern int nv50_fifo_load_context(struct nouveau_channel *); extern int nv50_fifo_unload_context(struct drm_device *); -/* nvc0_fifo.c */ -extern int nvc0_fifo_init(struct drm_device *); -extern void nvc0_fifo_takedown(struct drm_device *); -extern void nvc0_fifo_disable(struct drm_device *); -extern void nvc0_fifo_enable(struct drm_device *); -extern bool nvc0_fifo_reassign(struct drm_device *, bool); -extern bool nvc0_fifo_cache_flush(struct drm_device *); -extern bool nvc0_fifo_cache_pull(struct drm_device *, bool); -extern int nvc0_fifo_channel_id(struct drm_device *); -extern int nvc0_fifo_create_context(struct nouveau_channel *); -extern void nvc0_fifo_destroy_context(struct nouveau_channel *); -extern int nvc0_fifo_load_context(struct nouveau_channel *); -extern int nvc0_fifo_unload_context(struct drm_device *); - /* nv04_graph.c */ extern struct nouveau_pgraph_object_class nv04_graph_grclass[]; extern int nv04_graph_init(struct drm_device *); @@ -1049,16 +1032,6 @@ extern int nv50_graph_unload_context(struct drm_device *); extern void nv50_graph_context_switch(struct drm_device *); extern int nv50_grctx_init(struct nouveau_grctx *); -/* nvc0_graph.c */ -extern int nvc0_graph_init(struct drm_device *); -extern void nvc0_graph_takedown(struct drm_device *); -extern void nvc0_graph_fifo_access(struct drm_device *, bool); -extern struct nouveau_channel *nvc0_graph_channel(struct drm_device *); -extern int nvc0_graph_create_context(struct nouveau_channel *); -extern void nvc0_graph_destroy_context(struct nouveau_channel *); -extern int nvc0_graph_load_context(struct nouveau_channel *); -extern int nvc0_graph_unload_context(struct drm_device *); - /* nv04_instmem.c */ extern int nv04_instmem_init(struct drm_device *); extern void nv04_instmem_takedown(struct drm_device *); @@ -1085,18 +1058,6 @@ extern void nv50_instmem_flush(struct drm_device *); extern void nv84_instmem_flush(struct drm_device *); extern void nv50_vm_flush(struct drm_device *, int engine); -/* nvc0_instmem.c */ -extern int nvc0_instmem_init(struct drm_device *); -extern void nvc0_instmem_takedown(struct drm_device *); -extern int nvc0_instmem_suspend(struct drm_device *); -extern void nvc0_instmem_resume(struct drm_device *); -extern int nvc0_instmem_populate(struct drm_device *, struct nouveau_gpuobj *, - uint32_t *size); -extern void nvc0_instmem_clear(struct drm_device *, struct nouveau_gpuobj *); -extern int nvc0_instmem_bind(struct drm_device *, struct nouveau_gpuobj *); -extern int nvc0_instmem_unbind(struct drm_device *, struct nouveau_gpuobj *); -extern void nvc0_instmem_flush(struct drm_device *); - /* nv04_mc.c */ extern int nv04_mc_init(struct drm_device *); extern void nv04_mc_takedown(struct drm_device *); diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_encoder.h b/trunk/drivers/gpu/drm/nouveau/nouveau_encoder.h index 7c82d68bc155..a1a0d48ae70c 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_encoder.h +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_encoder.h @@ -71,12 +71,6 @@ static inline struct drm_encoder *to_drm_encoder(struct nouveau_encoder *enc) return &enc->base.base; } -static inline struct drm_encoder_slave_funcs * -get_slave_funcs(struct drm_encoder *enc) -{ - return to_encoder_slave(enc)->slave_funcs; -} - struct nouveau_connector * nouveau_encoder_connector_get(struct nouveau_encoder *encoder); int nv50_sor_create(struct drm_connector *, struct dcb_entry *); diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/trunk/drivers/gpu/drm/nouveau/nouveau_fbcon.c index dbd30b2e43fd..099f637264aa 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_fbcon.c @@ -281,8 +281,6 @@ nouveau_fbcon_create(struct nouveau_fbdev *nfbdev, if (dev_priv->channel && !nouveau_nofbaccel) { switch (dev_priv->card_type) { - case NV_C0: - break; case NV_50: nv50_fbcon_accel_init(info); info->fbops = &nv50_fbcon_ops; diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_gem.c b/trunk/drivers/gpu/drm/nouveau/nouveau_gem.c index 0f417ac1b696..547f2c24c1e7 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -284,7 +284,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv, if (!gem) { NV_ERROR(dev, "Unknown handle 0x%08x\n", b->handle); validate_fini(op, NULL); - return -ENOENT; + return -EINVAL; } nvbo = gem->driver_private; @@ -759,7 +759,7 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data, gem = drm_gem_object_lookup(dev, file_priv, req->handle); if (!gem) - return -ENOENT; + return ret; nvbo = nouveau_gem_object(gem); if (nvbo->cpu_filp) { @@ -797,7 +797,7 @@ nouveau_gem_ioctl_cpu_fini(struct drm_device *dev, void *data, gem = drm_gem_object_lookup(dev, file_priv, req->handle); if (!gem) - return -ENOENT; + return ret; nvbo = nouveau_gem_object(gem); if (nvbo->cpu_filp != file_priv) @@ -822,7 +822,7 @@ nouveau_gem_ioctl_info(struct drm_device *dev, void *data, gem = drm_gem_object_lookup(dev, file_priv, req->handle); if (!gem) - return -ENOENT; + return -EINVAL; ret = nouveau_gem_info(gem, req); drm_gem_object_unreference_unlocked(gem); diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_hw.c b/trunk/drivers/gpu/drm/nouveau/nouveau_hw.c index 7b613682e400..7855b35effc3 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_hw.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_hw.c @@ -865,12 +865,8 @@ nv_save_state_ext(struct drm_device *dev, int head, rd_cio_state(dev, head, regp, NV_CIO_CRE_FF_INDEX); rd_cio_state(dev, head, regp, NV_CIO_CRE_FFLWM__INDEX); rd_cio_state(dev, head, regp, NV_CIO_CRE_21); - - if (dev_priv->card_type >= NV_30) { + if (dev_priv->card_type >= NV_30) rd_cio_state(dev, head, regp, NV_CIO_CRE_47); - rd_cio_state(dev, head, regp, 0x9f); - } - rd_cio_state(dev, head, regp, NV_CIO_CRE_49); rd_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX); rd_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR1_INDEX); @@ -975,11 +971,8 @@ nv_load_state_ext(struct drm_device *dev, int head, wr_cio_state(dev, head, regp, NV_CIO_CRE_ENH_INDEX); wr_cio_state(dev, head, regp, NV_CIO_CRE_FF_INDEX); wr_cio_state(dev, head, regp, NV_CIO_CRE_FFLWM__INDEX); - - if (dev_priv->card_type >= NV_30) { + if (dev_priv->card_type >= NV_30) wr_cio_state(dev, head, regp, NV_CIO_CRE_47); - wr_cio_state(dev, head, regp, 0x9f); - } wr_cio_state(dev, head, regp, NV_CIO_CRE_49); wr_cio_state(dev, head, regp, NV_CIO_CRE_HCUR_ADDR0_INDEX); diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_i2c.c b/trunk/drivers/gpu/drm/nouveau/nouveau_i2c.c index 0bd407ca3d42..cb0cb34440c6 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_i2c.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_i2c.c @@ -163,7 +163,7 @@ nouveau_i2c_init(struct drm_device *dev, struct dcb_i2c_entry *entry, int index) if (entry->chan) return -EEXIST; - if (dev_priv->card_type == NV_C0 && entry->read >= NV50_I2C_PORTS) { + if (dev_priv->card_type == NV_50 && entry->read >= NV50_I2C_PORTS) { NV_ERROR(dev, "unknown i2c port %d\n", entry->read); return -EINVAL; } @@ -174,26 +174,26 @@ nouveau_i2c_init(struct drm_device *dev, struct dcb_i2c_entry *entry, int index) switch (entry->port_type) { case 0: - i2c->bit.setsda = nv04_i2c_setsda; - i2c->bit.setscl = nv04_i2c_setscl; - i2c->bit.getsda = nv04_i2c_getsda; - i2c->bit.getscl = nv04_i2c_getscl; + i2c->algo.bit.setsda = nv04_i2c_setsda; + i2c->algo.bit.setscl = nv04_i2c_setscl; + i2c->algo.bit.getsda = nv04_i2c_getsda; + i2c->algo.bit.getscl = nv04_i2c_getscl; i2c->rd = entry->read; i2c->wr = entry->write; break; case 4: - i2c->bit.setsda = nv4e_i2c_setsda; - i2c->bit.setscl = nv4e_i2c_setscl; - i2c->bit.getsda = nv4e_i2c_getsda; - i2c->bit.getscl = nv4e_i2c_getscl; + i2c->algo.bit.setsda = nv4e_i2c_setsda; + i2c->algo.bit.setscl = nv4e_i2c_setscl; + i2c->algo.bit.getsda = nv4e_i2c_getsda; + i2c->algo.bit.getscl = nv4e_i2c_getscl; i2c->rd = 0x600800 + entry->read; i2c->wr = 0x600800 + entry->write; break; case 5: - i2c->bit.setsda = nv50_i2c_setsda; - i2c->bit.setscl = nv50_i2c_setscl; - i2c->bit.getsda = nv50_i2c_getsda; - i2c->bit.getscl = nv50_i2c_getscl; + i2c->algo.bit.setsda = nv50_i2c_setsda; + i2c->algo.bit.setscl = nv50_i2c_setscl; + i2c->algo.bit.getsda = nv50_i2c_getsda; + i2c->algo.bit.getscl = nv50_i2c_getscl; i2c->rd = nv50_i2c_port[entry->read]; i2c->wr = i2c->rd; break; @@ -216,14 +216,17 @@ nouveau_i2c_init(struct drm_device *dev, struct dcb_i2c_entry *entry, int index) i2c_set_adapdata(&i2c->adapter, i2c); if (entry->port_type < 6) { - i2c->adapter.algo_data = &i2c->bit; - i2c->bit.udelay = 40; - i2c->bit.timeout = usecs_to_jiffies(5000); - i2c->bit.data = i2c; + i2c->adapter.algo_data = &i2c->algo.bit; + i2c->algo.bit.udelay = 40; + i2c->algo.bit.timeout = usecs_to_jiffies(5000); + i2c->algo.bit.data = i2c; ret = i2c_bit_add_bus(&i2c->adapter); } else { - i2c->adapter.algo = &nouveau_dp_i2c_algo; - ret = i2c_add_adapter(&i2c->adapter); + i2c->adapter.algo_data = &i2c->algo.dp; + i2c->algo.dp.running = false; + i2c->algo.dp.address = 0; + i2c->algo.dp.aux_ch = nouveau_dp_i2c_aux_ch; + ret = i2c_dp_aux_add_bus(&i2c->adapter); } if (ret) { diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_i2c.h b/trunk/drivers/gpu/drm/nouveau/nouveau_i2c.h index f71cb32f7571..6dd2f8713cd1 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_i2c.h +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_i2c.h @@ -33,7 +33,10 @@ struct dcb_i2c_entry; struct nouveau_i2c_chan { struct i2c_adapter adapter; struct drm_device *dev; - struct i2c_algo_bit_data bit; + union { + struct i2c_algo_bit_data bit; + struct i2c_algo_dp_aux_data dp; + } algo; unsigned rd; unsigned wr; unsigned data; @@ -46,6 +49,7 @@ bool nouveau_probe_i2c_addr(struct nouveau_i2c_chan *i2c, int addr); int nouveau_i2c_identify(struct drm_device *dev, const char *what, struct i2c_board_info *info, int index); -extern const struct i2c_algorithm nouveau_dp_i2c_algo; +int nouveau_dp_i2c_aux_ch(struct i2c_adapter *, int mode, uint8_t write_byte, + uint8_t *read_byte); #endif /* __NOUVEAU_I2C_H__ */ diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_irq.c b/trunk/drivers/gpu/drm/nouveau/nouveau_irq.c index 794b0ee30cf6..53360f156063 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_irq.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_irq.c @@ -49,7 +49,7 @@ nouveau_irq_preinstall(struct drm_device *dev) /* Master disable */ nv_wr32(dev, NV03_PMC_INTR_EN_0, 0); - if (dev_priv->card_type >= NV_50) { + if (dev_priv->card_type == NV_50) { INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh); INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh); INIT_LIST_HEAD(&dev_priv->vbl_waiting); @@ -586,11 +586,11 @@ nouveau_pgraph_irq_handler(struct drm_device *dev) } if (status & NV_PGRAPH_INTR_CONTEXT_SWITCH) { + nouveau_pgraph_intr_context_switch(dev); + status &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH; nv_wr32(dev, NV03_PGRAPH_INTR, NV_PGRAPH_INTR_CONTEXT_SWITCH); - - nouveau_pgraph_intr_context_switch(dev); } if (status) { diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_mem.c b/trunk/drivers/gpu/drm/nouveau/nouveau_mem.c index 9689d4147686..a9f36ab256b7 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_mem.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_mem.c @@ -320,8 +320,7 @@ nouveau_mem_detect(struct drm_device *dev) if (dev_priv->card_type < NV_50) { dev_priv->vram_size = nv_rd32(dev, NV04_PFB_FIFO_DATA); dev_priv->vram_size &= NV10_PFB_FIFO_DATA_RAM_AMOUNT_MB_MASK; - } else - if (dev_priv->card_type < NV_C0) { + } else { dev_priv->vram_size = nv_rd32(dev, NV04_PFB_FIFO_DATA); dev_priv->vram_size |= (dev_priv->vram_size & 0xff) << 32; dev_priv->vram_size &= 0xffffffff00ll; @@ -329,9 +328,6 @@ nouveau_mem_detect(struct drm_device *dev) dev_priv->vram_sys_base = nv_rd32(dev, 0x100e10); dev_priv->vram_sys_base <<= 12; } - } else { - dev_priv->vram_size = nv_rd32(dev, 0x10f20c) << 20; - dev_priv->vram_size *= nv_rd32(dev, 0x121c74); } NV_INFO(dev, "Detected %dMiB VRAM\n", (int)(dev_priv->vram_size >> 20)); @@ -355,7 +351,7 @@ nouveau_mem_reset_agp(struct drm_device *dev) /* First of all, disable fast writes, otherwise if it's * already enabled in the AGP bridge and we disable the card's * AGP controller we might be locking ourselves out of it. */ - if (nv_rd32(dev, NV04_PBUS_PCI_NV_19) & PCI_AGP_COMMAND_FW) { + if (dev->agp->acquired) { struct drm_agp_info info; struct drm_agp_mode mode; @@ -363,7 +359,7 @@ nouveau_mem_reset_agp(struct drm_device *dev) if (ret) return ret; - mode.mode = info.mode & ~PCI_AGP_COMMAND_FW; + mode.mode = info.mode & ~0x10; ret = drm_agp_enable(dev, mode); if (ret) return ret; @@ -409,8 +405,6 @@ nouveau_mem_init_agp(struct drm_device *dev) } } - nouveau_mem_reset_agp(dev); - ret = drm_agp_info(dev, &info); if (ret) { NV_ERROR(dev, "Unable to get AGP info: %d\n", ret); @@ -465,6 +459,8 @@ nouveau_mem_init(struct drm_device *dev) return ret; } + INIT_LIST_HEAD(&dev_priv->ttm.bo_list); + spin_lock_init(&dev_priv->ttm.bo_list_lock); spin_lock_init(&dev_priv->tile.lock); dev_priv->fb_available_size = dev_priv->vram_size; @@ -498,6 +494,7 @@ nouveau_mem_init(struct drm_device *dev) /* GART */ #if !defined(__powerpc__) && !defined(__ia64__) if (drm_device_is_agp(dev) && dev->agp && !nouveau_noagp) { + nouveau_mem_reset_agp(dev); ret = nouveau_mem_init_agp(dev); if (ret) NV_ERROR(dev, "Error initialising AGP: %d\n", ret); diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_reg.h b/trunk/drivers/gpu/drm/nouveau/nouveau_reg.h index 21a6e453b975..9c1056cb8a90 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_reg.h +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_reg.h @@ -220,21 +220,28 @@ # define NV_PGRAPH_INTR_ERROR (1<<20) #define NV10_PGRAPH_CTX_CONTROL 0x00400144 #define NV10_PGRAPH_CTX_USER 0x00400148 -#define NV10_PGRAPH_CTX_SWITCH(i) (0x0040014C + 0x4*(i)) +#define NV10_PGRAPH_CTX_SWITCH1 0x0040014C +#define NV10_PGRAPH_CTX_SWITCH2 0x00400150 +#define NV10_PGRAPH_CTX_SWITCH3 0x00400154 +#define NV10_PGRAPH_CTX_SWITCH4 0x00400158 +#define NV10_PGRAPH_CTX_SWITCH5 0x0040015C #define NV04_PGRAPH_CTX_SWITCH1 0x00400160 -#define NV10_PGRAPH_CTX_CACHE(i, j) (0x00400160 \ - + 0x4*(i) + 0x20*(j)) +#define NV10_PGRAPH_CTX_CACHE1 0x00400160 #define NV04_PGRAPH_CTX_SWITCH2 0x00400164 #define NV04_PGRAPH_CTX_SWITCH3 0x00400168 #define NV04_PGRAPH_CTX_SWITCH4 0x0040016C #define NV04_PGRAPH_CTX_CONTROL 0x00400170 #define NV04_PGRAPH_CTX_USER 0x00400174 #define NV04_PGRAPH_CTX_CACHE1 0x00400180 +#define NV10_PGRAPH_CTX_CACHE2 0x00400180 #define NV03_PGRAPH_CTX_CONTROL 0x00400190 #define NV03_PGRAPH_CTX_USER 0x00400194 #define NV04_PGRAPH_CTX_CACHE2 0x004001A0 +#define NV10_PGRAPH_CTX_CACHE3 0x004001A0 #define NV04_PGRAPH_CTX_CACHE3 0x004001C0 +#define NV10_PGRAPH_CTX_CACHE4 0x004001C0 #define NV04_PGRAPH_CTX_CACHE4 0x004001E0 +#define NV10_PGRAPH_CTX_CACHE5 0x004001E0 #define NV40_PGRAPH_CTXCTL_0304 0x00400304 #define NV40_PGRAPH_CTXCTL_0304_XFER_CTX 0x00000001 #define NV40_PGRAPH_CTXCTL_UCODE_STAT 0x00400308 @@ -349,12 +356,9 @@ #define NV04_PGRAPH_FFINTFC_ST2 0x00400754 #define NV10_PGRAPH_RDI_DATA 0x00400754 #define NV04_PGRAPH_DMA_PITCH 0x00400760 -#define NV10_PGRAPH_FFINTFC_FIFO_PTR 0x00400760 -#define NV04_PGRAPH_DVD_COLORFMT 0x00400764 #define NV10_PGRAPH_FFINTFC_ST2 0x00400764 +#define NV04_PGRAPH_DVD_COLORFMT 0x00400764 #define NV04_PGRAPH_SCALED_FORMAT 0x00400768 -#define NV10_PGRAPH_FFINTFC_ST2_DL 0x00400768 -#define NV10_PGRAPH_FFINTFC_ST2_DH 0x0040076c #define NV10_PGRAPH_DMA_PITCH 0x00400770 #define NV10_PGRAPH_DVD_COLORFMT 0x00400774 #define NV10_PGRAPH_SCALED_FORMAT 0x00400778 diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_state.c b/trunk/drivers/gpu/drm/nouveau/nouveau_state.c index 989322be3728..ee3729e7823b 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_state.c @@ -359,54 +359,6 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) engine->gpio.set = nv50_gpio_set; engine->gpio.irq_enable = nv50_gpio_irq_enable; break; - case 0xC0: - engine->instmem.init = nvc0_instmem_init; - engine->instmem.takedown = nvc0_instmem_takedown; - engine->instmem.suspend = nvc0_instmem_suspend; - engine->instmem.resume = nvc0_instmem_resume; - engine->instmem.populate = nvc0_instmem_populate; - engine->instmem.clear = nvc0_instmem_clear; - engine->instmem.bind = nvc0_instmem_bind; - engine->instmem.unbind = nvc0_instmem_unbind; - engine->instmem.flush = nvc0_instmem_flush; - engine->mc.init = nv50_mc_init; - engine->mc.takedown = nv50_mc_takedown; - engine->timer.init = nv04_timer_init; - engine->timer.read = nv04_timer_read; - engine->timer.takedown = nv04_timer_takedown; - engine->fb.init = nvc0_fb_init; - engine->fb.takedown = nvc0_fb_takedown; - engine->graph.grclass = NULL; //nvc0_graph_grclass; - engine->graph.init = nvc0_graph_init; - engine->graph.takedown = nvc0_graph_takedown; - engine->graph.fifo_access = nvc0_graph_fifo_access; - engine->graph.channel = nvc0_graph_channel; - engine->graph.create_context = nvc0_graph_create_context; - engine->graph.destroy_context = nvc0_graph_destroy_context; - engine->graph.load_context = nvc0_graph_load_context; - engine->graph.unload_context = nvc0_graph_unload_context; - engine->fifo.channels = 128; - engine->fifo.init = nvc0_fifo_init; - engine->fifo.takedown = nvc0_fifo_takedown; - engine->fifo.disable = nvc0_fifo_disable; - engine->fifo.enable = nvc0_fifo_enable; - engine->fifo.reassign = nvc0_fifo_reassign; - engine->fifo.channel_id = nvc0_fifo_channel_id; - engine->fifo.create_context = nvc0_fifo_create_context; - engine->fifo.destroy_context = nvc0_fifo_destroy_context; - engine->fifo.load_context = nvc0_fifo_load_context; - engine->fifo.unload_context = nvc0_fifo_unload_context; - engine->display.early_init = nv50_display_early_init; - engine->display.late_takedown = nv50_display_late_takedown; - engine->display.create = nv50_display_create; - engine->display.init = nv50_display_init; - engine->display.destroy = nv50_display_destroy; - engine->gpio.init = nv50_gpio_init; - engine->gpio.takedown = nouveau_stub_takedown; - engine->gpio.get = nv50_gpio_get; - engine->gpio.set = nv50_gpio_set; - engine->gpio.irq_enable = nv50_gpio_irq_enable; - break; default: NV_ERROR(dev, "NV%02x unsupported\n", dev_priv->chipset); return 1; @@ -787,10 +739,8 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) int ret; dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL); - if (!dev_priv) { - ret = -ENOMEM; - goto err_out; - } + if (!dev_priv) + return -ENOMEM; dev->dev_private = dev_priv; dev_priv->dev = dev; @@ -800,10 +750,8 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) dev->pci_vendor, dev->pci_device, dev->pdev->class); dev_priv->wq = create_workqueue("nouveau"); - if (!dev_priv->wq) { - ret = -EINVAL; - goto err_priv; - } + if (!dev_priv->wq) + return -EINVAL; /* resource 0 is mmio regs */ /* resource 1 is linear FB */ @@ -816,8 +764,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) if (!dev_priv->mmio) { NV_ERROR(dev, "Unable to initialize the mmio mapping. " "Please report your setup to " DRIVER_EMAIL "\n"); - ret = -EINVAL; - goto err_wq; + return -EINVAL; } NV_DEBUG(dev, "regs mapped ok at 0x%llx\n", (unsigned long long)mmio_start_offs); @@ -863,13 +810,9 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) case 0xa0: dev_priv->card_type = NV_50; break; - case 0xc0: - dev_priv->card_type = NV_C0; - break; default: NV_INFO(dev, "Unsupported chipset 0x%08x\n", reg0); - ret = -EINVAL; - goto err_mmio; + return -EINVAL; } NV_INFO(dev, "Detected an NV%2x generation card (0x%08x)\n", @@ -877,7 +820,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) ret = nouveau_remove_conflicting_drivers(dev); if (ret) - goto err_mmio; + return ret; /* Map PRAMIN BAR, or on older cards, the aperture withing BAR0 */ if (dev_priv->card_type >= NV_40) { @@ -891,8 +834,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) dev_priv->ramin_size); if (!dev_priv->ramin) { NV_ERROR(dev, "Failed to PRAMIN BAR"); - ret = -ENOMEM; - goto err_mmio; + return -ENOMEM; } } else { dev_priv->ramin_size = 1 * 1024 * 1024; @@ -900,8 +842,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) dev_priv->ramin_size); if (!dev_priv->ramin) { NV_ERROR(dev, "Failed to map BAR0 PRAMIN.\n"); - ret = -ENOMEM; - goto err_mmio; + return -ENOMEM; } } @@ -916,21 +857,9 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) /* For kernel modesetting, init card now and bring up fbcon */ ret = nouveau_card_init(dev); if (ret) - goto err_ramin; + return ret; return 0; - -err_ramin: - iounmap(dev_priv->ramin); -err_mmio: - iounmap(dev_priv->mmio); -err_wq: - destroy_workqueue(dev_priv->wq); -err_priv: - kfree(dev_priv); - dev->dev_private = NULL; -err_out: - return ret; } void nouveau_lastclose(struct drm_device *dev) diff --git a/trunk/drivers/gpu/drm/nouveau/nv04_crtc.c b/trunk/drivers/gpu/drm/nouveau/nv04_crtc.c index 497df8765f28..1c20c08ce67c 100644 --- a/trunk/drivers/gpu/drm/nouveau/nv04_crtc.c +++ b/trunk/drivers/gpu/drm/nouveau/nv04_crtc.c @@ -542,9 +542,6 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) * 1 << 30 on 0x60.830), for no apparent reason */ regp->CRTC[NV_CIO_CRE_59] = off_chip_digital; - if (dev_priv->card_type >= NV_30) - regp->CRTC[0x9f] = off_chip_digital ? 0x11 : 0x1; - regp->crtc_830 = mode->crtc_vdisplay - 3; regp->crtc_834 = mode->crtc_vdisplay - 1; @@ -742,13 +739,15 @@ nv_crtc_gamma_load(struct drm_crtc *crtc) } static void -nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start, - uint32_t size) +nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t size) { - int end = (start + size > 256) ? 256 : start + size, i; struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); + int i; - for (i = start; i < end; i++) { + if (size != 256) + return; + + for (i = 0; i < 256; i++) { nv_crtc->lut.r[i] = r[i]; nv_crtc->lut.g[i] = g[i]; nv_crtc->lut.b[i] = b[i]; @@ -915,7 +914,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, gem = drm_gem_object_lookup(dev, file_priv, buffer_handle); if (!gem) - return -ENOENT; + return -EINVAL; cursor = nouveau_gem_object(gem); ret = nouveau_bo_map(cursor); diff --git a/trunk/drivers/gpu/drm/nouveau/nv04_dfp.c b/trunk/drivers/gpu/drm/nouveau/nv04_dfp.c index a5dcf7685800..3311f3a8c818 100644 --- a/trunk/drivers/gpu/drm/nouveau/nv04_dfp.c +++ b/trunk/drivers/gpu/drm/nouveau/nv04_dfp.c @@ -34,8 +34,6 @@ #include "nouveau_hw.h" #include "nvreg.h" -#include "i2c/sil164.h" - #define FP_TG_CONTROL_ON (NV_PRAMDAC_FP_TG_CONTROL_DISPEN_POS | \ NV_PRAMDAC_FP_TG_CONTROL_HSYNC_POS | \ NV_PRAMDAC_FP_TG_CONTROL_VSYNC_POS) @@ -146,36 +144,6 @@ void nv04_dfp_update_fp_control(struct drm_encoder *encoder, int mode) } } -static struct drm_encoder *get_tmds_slave(struct drm_encoder *encoder) -{ - struct drm_device *dev = encoder->dev; - struct dcb_entry *dcb = nouveau_encoder(encoder)->dcb; - struct drm_encoder *slave; - - if (dcb->type != OUTPUT_TMDS || dcb->location == DCB_LOC_ON_CHIP) - return NULL; - - /* Some BIOSes (e.g. the one in a Quadro FX1000) report several - * TMDS transmitters at the same I2C address, in the same I2C - * bus. This can still work because in that case one of them is - * always hard-wired to a reasonable configuration using straps, - * and the other one needs to be programmed. - * - * I don't think there's a way to know which is which, even the - * blob programs the one exposed via I2C for *both* heads, so - * let's do the same. - */ - list_for_each_entry(slave, &dev->mode_config.encoder_list, head) { - struct dcb_entry *slave_dcb = nouveau_encoder(slave)->dcb; - - if (slave_dcb->type == OUTPUT_TMDS && get_slave_funcs(slave) && - slave_dcb->tmdsconf.slave_addr == dcb->tmdsconf.slave_addr) - return slave; - } - - return NULL; -} - static bool nv04_dfp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) @@ -461,11 +429,6 @@ static void nv04_dfp_commit(struct drm_encoder *encoder) else NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + nv04_dac_output_offset(encoder), 0x00100000); - /* Init external transmitters */ - if (get_tmds_slave(encoder)) - get_slave_funcs(get_tmds_slave(encoder))->mode_set( - encoder, &nv_encoder->mode, &nv_encoder->mode); - helper->dpms(encoder, DRM_MODE_DPMS_ON); NV_INFO(dev, "Output %s is running on CRTC %d using output %c\n", @@ -587,42 +550,10 @@ static void nv04_dfp_destroy(struct drm_encoder *encoder) NV_DEBUG_KMS(encoder->dev, "\n"); - if (get_slave_funcs(encoder)) - get_slave_funcs(encoder)->destroy(encoder); - drm_encoder_cleanup(encoder); kfree(nv_encoder); } -static void nv04_tmds_slave_init(struct drm_encoder *encoder) -{ - struct drm_device *dev = encoder->dev; - struct dcb_entry *dcb = nouveau_encoder(encoder)->dcb; - struct nouveau_i2c_chan *i2c = nouveau_i2c_find(dev, 2); - struct i2c_board_info info[] = { - { - .type = "sil164", - .addr = (dcb->tmdsconf.slave_addr == 0x7 ? 0x3a : 0x38), - .platform_data = &(struct sil164_encoder_params) { - SIL164_INPUT_EDGE_RISING - } - }, - { } - }; - int type; - - if (!nv_gf4_disp_arch(dev) || !i2c || - get_tmds_slave(encoder)) - return; - - type = nouveau_i2c_identify(dev, "TMDS transmitter", info, 2); - if (type < 0) - return; - - drm_i2c_encoder_init(dev, to_encoder_slave(encoder), - &i2c->adapter, &info[type]); -} - static const struct drm_encoder_helper_funcs nv04_lvds_helper_funcs = { .dpms = nv04_lvds_dpms, .save = nv04_dfp_save, @@ -685,10 +616,6 @@ nv04_dfp_create(struct drm_connector *connector, struct dcb_entry *entry) encoder->possible_crtcs = entry->heads; encoder->possible_clones = 0; - if (entry->type == OUTPUT_TMDS && - entry->location != DCB_LOC_ON_CHIP) - nv04_tmds_slave_init(encoder); - drm_mode_connector_attach_encoder(connector, encoder); return 0; } diff --git a/trunk/drivers/gpu/drm/nouveau/nv04_tv.c b/trunk/drivers/gpu/drm/nouveau/nv04_tv.c index 0b5d012d7c28..94e299cef0b2 100644 --- a/trunk/drivers/gpu/drm/nouveau/nv04_tv.c +++ b/trunk/drivers/gpu/drm/nouveau/nv04_tv.c @@ -89,7 +89,7 @@ static void nv04_tv_dpms(struct drm_encoder *encoder, int mode) NVWriteRAMDAC(dev, 0, NV_PRAMDAC_PLL_COEFF_SELECT, state->pllsel); - get_slave_funcs(encoder)->dpms(encoder, mode); + to_encoder_slave(encoder)->slave_funcs->dpms(encoder, mode); } static void nv04_tv_bind(struct drm_device *dev, int head, bool bind) @@ -152,7 +152,7 @@ static void nv04_tv_mode_set(struct drm_encoder *encoder, regp->tv_vskew = 1; regp->tv_vsync_delay = 1; - get_slave_funcs(encoder)->mode_set(encoder, mode, adjusted_mode); + to_encoder_slave(encoder)->slave_funcs->mode_set(encoder, mode, adjusted_mode); } static void nv04_tv_commit(struct drm_encoder *encoder) @@ -171,7 +171,8 @@ static void nv04_tv_commit(struct drm_encoder *encoder) static void nv04_tv_destroy(struct drm_encoder *encoder) { - get_slave_funcs(encoder)->destroy(encoder); + to_encoder_slave(encoder)->slave_funcs->destroy(encoder); + drm_encoder_cleanup(encoder); kfree(encoder->helper_private); @@ -228,7 +229,7 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_entry *entry) goto fail_cleanup; /* Fill the function pointers */ - sfuncs = get_slave_funcs(encoder); + sfuncs = to_encoder_slave(encoder)->slave_funcs; *hfuncs = (struct drm_encoder_helper_funcs) { .dpms = nv04_tv_dpms, @@ -242,6 +243,7 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_entry *entry) }; /* Attach it to the specified connector. */ + sfuncs->set_config(encoder, nv04_tv_encoder_info[type].platform_data); sfuncs->create_resources(encoder, connector); drm_mode_connector_attach_encoder(connector, encoder); diff --git a/trunk/drivers/gpu/drm/nouveau/nv10_graph.c b/trunk/drivers/gpu/drm/nouveau/nv10_graph.c index b2f6a57c0cc5..fcf2cdd19493 100644 --- a/trunk/drivers/gpu/drm/nouveau/nv10_graph.c +++ b/trunk/drivers/gpu/drm/nouveau/nv10_graph.c @@ -43,51 +43,51 @@ struct pipe_state { }; static int nv10_graph_ctx_regs[] = { - NV10_PGRAPH_CTX_SWITCH(0), - NV10_PGRAPH_CTX_SWITCH(1), - NV10_PGRAPH_CTX_SWITCH(2), - NV10_PGRAPH_CTX_SWITCH(3), - NV10_PGRAPH_CTX_SWITCH(4), - NV10_PGRAPH_CTX_CACHE(0, 0), - NV10_PGRAPH_CTX_CACHE(0, 1), - NV10_PGRAPH_CTX_CACHE(0, 2), - NV10_PGRAPH_CTX_CACHE(0, 3), - NV10_PGRAPH_CTX_CACHE(0, 4), - NV10_PGRAPH_CTX_CACHE(1, 0), - NV10_PGRAPH_CTX_CACHE(1, 1), - NV10_PGRAPH_CTX_CACHE(1, 2), - NV10_PGRAPH_CTX_CACHE(1, 3), - NV10_PGRAPH_CTX_CACHE(1, 4), - NV10_PGRAPH_CTX_CACHE(2, 0), - NV10_PGRAPH_CTX_CACHE(2, 1), - NV10_PGRAPH_CTX_CACHE(2, 2), - NV10_PGRAPH_CTX_CACHE(2, 3), - NV10_PGRAPH_CTX_CACHE(2, 4), - NV10_PGRAPH_CTX_CACHE(3, 0), - NV10_PGRAPH_CTX_CACHE(3, 1), - NV10_PGRAPH_CTX_CACHE(3, 2), - NV10_PGRAPH_CTX_CACHE(3, 3), - NV10_PGRAPH_CTX_CACHE(3, 4), - NV10_PGRAPH_CTX_CACHE(4, 0), - NV10_PGRAPH_CTX_CACHE(4, 1), - NV10_PGRAPH_CTX_CACHE(4, 2), - NV10_PGRAPH_CTX_CACHE(4, 3), - NV10_PGRAPH_CTX_CACHE(4, 4), - NV10_PGRAPH_CTX_CACHE(5, 0), - NV10_PGRAPH_CTX_CACHE(5, 1), - NV10_PGRAPH_CTX_CACHE(5, 2), - NV10_PGRAPH_CTX_CACHE(5, 3), - NV10_PGRAPH_CTX_CACHE(5, 4), - NV10_PGRAPH_CTX_CACHE(6, 0), - NV10_PGRAPH_CTX_CACHE(6, 1), - NV10_PGRAPH_CTX_CACHE(6, 2), - NV10_PGRAPH_CTX_CACHE(6, 3), - NV10_PGRAPH_CTX_CACHE(6, 4), - NV10_PGRAPH_CTX_CACHE(7, 0), - NV10_PGRAPH_CTX_CACHE(7, 1), - NV10_PGRAPH_CTX_CACHE(7, 2), - NV10_PGRAPH_CTX_CACHE(7, 3), - NV10_PGRAPH_CTX_CACHE(7, 4), + NV10_PGRAPH_CTX_SWITCH1, + NV10_PGRAPH_CTX_SWITCH2, + NV10_PGRAPH_CTX_SWITCH3, + NV10_PGRAPH_CTX_SWITCH4, + NV10_PGRAPH_CTX_SWITCH5, + NV10_PGRAPH_CTX_CACHE1, /* 8 values from 0x400160 to 0x40017c */ + NV10_PGRAPH_CTX_CACHE2, /* 8 values from 0x400180 to 0x40019c */ + NV10_PGRAPH_CTX_CACHE3, /* 8 values from 0x4001a0 to 0x4001bc */ + NV10_PGRAPH_CTX_CACHE4, /* 8 values from 0x4001c0 to 0x4001dc */ + NV10_PGRAPH_CTX_CACHE5, /* 8 values from 0x4001e0 to 0x4001fc */ + 0x00400164, + 0x00400184, + 0x004001a4, + 0x004001c4, + 0x004001e4, + 0x00400168, + 0x00400188, + 0x004001a8, + 0x004001c8, + 0x004001e8, + 0x0040016c, + 0x0040018c, + 0x004001ac, + 0x004001cc, + 0x004001ec, + 0x00400170, + 0x00400190, + 0x004001b0, + 0x004001d0, + 0x004001f0, + 0x00400174, + 0x00400194, + 0x004001b4, + 0x004001d4, + 0x004001f4, + 0x00400178, + 0x00400198, + 0x004001b8, + 0x004001d8, + 0x004001f8, + 0x0040017c, + 0x0040019c, + 0x004001bc, + 0x004001dc, + 0x004001fc, NV10_PGRAPH_CTX_USER, NV04_PGRAPH_DMA_START_0, NV04_PGRAPH_DMA_START_1, @@ -653,78 +653,6 @@ static int nv17_graph_ctx_regs_find_offset(struct drm_device *dev, int reg) return -1; } -static void nv10_graph_load_dma_vtxbuf(struct nouveau_channel *chan, - uint32_t inst) -{ - struct drm_device *dev = chan->dev; - struct drm_nouveau_private *dev_priv = dev->dev_private; - struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; - uint32_t st2, st2_dl, st2_dh, fifo_ptr, fifo[0x60/4]; - uint32_t ctx_user, ctx_switch[5]; - int i, subchan = -1; - - /* NV10TCL_DMA_VTXBUF (method 0x18c) modifies hidden state - * that cannot be restored via MMIO. Do it through the FIFO - * instead. - */ - - /* Look for a celsius object */ - for (i = 0; i < 8; i++) { - int class = nv_rd32(dev, NV10_PGRAPH_CTX_CACHE(i, 0)) & 0xfff; - - if (class == 0x56 || class == 0x96 || class == 0x99) { - subchan = i; - break; - } - } - - if (subchan < 0 || !inst) - return; - - /* Save the current ctx object */ - ctx_user = nv_rd32(dev, NV10_PGRAPH_CTX_USER); - for (i = 0; i < 5; i++) - ctx_switch[i] = nv_rd32(dev, NV10_PGRAPH_CTX_SWITCH(i)); - - /* Save the FIFO state */ - st2 = nv_rd32(dev, NV10_PGRAPH_FFINTFC_ST2); - st2_dl = nv_rd32(dev, NV10_PGRAPH_FFINTFC_ST2_DL); - st2_dh = nv_rd32(dev, NV10_PGRAPH_FFINTFC_ST2_DH); - fifo_ptr = nv_rd32(dev, NV10_PGRAPH_FFINTFC_FIFO_PTR); - - for (i = 0; i < ARRAY_SIZE(fifo); i++) - fifo[i] = nv_rd32(dev, 0x4007a0 + 4 * i); - - /* Switch to the celsius subchannel */ - for (i = 0; i < 5; i++) - nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(i), - nv_rd32(dev, NV10_PGRAPH_CTX_CACHE(subchan, i))); - nv_mask(dev, NV10_PGRAPH_CTX_USER, 0xe000, subchan << 13); - - /* Inject NV10TCL_DMA_VTXBUF */ - nv_wr32(dev, NV10_PGRAPH_FFINTFC_FIFO_PTR, 0); - nv_wr32(dev, NV10_PGRAPH_FFINTFC_ST2, - 0x2c000000 | chan->id << 20 | subchan << 16 | 0x18c); - nv_wr32(dev, NV10_PGRAPH_FFINTFC_ST2_DL, inst); - nv_mask(dev, NV10_PGRAPH_CTX_CONTROL, 0, 0x10000); - pgraph->fifo_access(dev, true); - pgraph->fifo_access(dev, false); - - /* Restore the FIFO state */ - for (i = 0; i < ARRAY_SIZE(fifo); i++) - nv_wr32(dev, 0x4007a0 + 4 * i, fifo[i]); - - nv_wr32(dev, NV10_PGRAPH_FFINTFC_FIFO_PTR, fifo_ptr); - nv_wr32(dev, NV10_PGRAPH_FFINTFC_ST2, st2); - nv_wr32(dev, NV10_PGRAPH_FFINTFC_ST2_DL, st2_dl); - nv_wr32(dev, NV10_PGRAPH_FFINTFC_ST2_DH, st2_dh); - - /* Restore the current ctx object */ - for (i = 0; i < 5; i++) - nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(i), ctx_switch[i]); - nv_wr32(dev, NV10_PGRAPH_CTX_USER, ctx_user); -} - int nv10_graph_load_context(struct nouveau_channel *chan) { struct drm_device *dev = chan->dev; @@ -742,8 +670,6 @@ int nv10_graph_load_context(struct nouveau_channel *chan) } nv10_graph_load_pipe(chan); - nv10_graph_load_dma_vtxbuf(chan, (nv_rd32(dev, NV10_PGRAPH_GLOBALSTATE1) - & 0xffff)); nv_wr32(dev, NV10_PGRAPH_CTX_CONTROL, 0x10010100); tmp = nv_rd32(dev, NV10_PGRAPH_CTX_USER); @@ -930,12 +856,11 @@ int nv10_graph_init(struct drm_device *dev) for (i = 0; i < NV10_PFB_TILE__SIZE; i++) nv10_graph_set_region_tiling(dev, i, 0, 0, 0); - nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(0), 0x00000000); - nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(1), 0x00000000); - nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(2), 0x00000000); - nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(3), 0x00000000); - nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(4), 0x00000000); - nv_wr32(dev, NV10_PGRAPH_STATE, 0xFFFFFFFF); + nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH1, 0x00000000); + nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH2, 0x00000000); + nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH3, 0x00000000); + nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH4, 0x00000000); + nv_wr32(dev, NV10_PGRAPH_STATE , 0xFFFFFFFF); tmp = nv_rd32(dev, NV10_PGRAPH_CTX_USER) & 0x00ffffff; tmp |= (dev_priv->engine.fifo.channels - 1) << 24; diff --git a/trunk/drivers/gpu/drm/nouveau/nv30_fb.c b/trunk/drivers/gpu/drm/nouveau/nv30_fb.c index 4a3f2f095128..9d35c8b3b839 100644 --- a/trunk/drivers/gpu/drm/nouveau/nv30_fb.c +++ b/trunk/drivers/gpu/drm/nouveau/nv30_fb.c @@ -30,25 +30,15 @@ #include "nouveau_drm.h" static int -calc_bias(struct drm_device *dev, int k, int i, int j) -{ - struct drm_nouveau_private *dev_priv = dev->dev_private; - int b = (dev_priv->chipset > 0x30 ? - nv_rd32(dev, 0x122c + 0x10 * k + 0x4 * j) >> (4 * (i ^ 1)) : - 0) & 0xf; - - return 2 * (b & 0x8 ? b - 0x10 : b); -} - -static int -calc_ref(struct drm_device *dev, int l, int k, int i) +calc_ref(int b, int l, int i) { int j, x = 0; for (j = 0; j < 4; j++) { - int m = (l >> (8 * i) & 0xff) + calc_bias(dev, k, i, j); + int n = (b >> (8 * j) & 0xf); + int m = (l >> (8 * i) & 0xff) + 2 * (n & 0x8 ? n - 0x10 : n); - x |= (0x80 | clamp(m, 0, 0x1f)) << (8 * j); + x |= (0x80 | (m & 0x1f)) << (8 * j); } return x; @@ -73,16 +63,18 @@ nv30_fb_init(struct drm_device *dev) dev_priv->chipset == 0x35) { /* Related to ROP count */ int n = (dev_priv->chipset == 0x31 ? 2 : 4); + int b = (dev_priv->chipset > 0x30 ? + nv_rd32(dev, 0x122c) & 0xf : 0); int l = nv_rd32(dev, 0x1003d0); for (i = 0; i < n; i++) { for (j = 0; j < 3; j++) nv_wr32(dev, 0x10037c + 0xc * i + 0x4 * j, - calc_ref(dev, l, 0, j)); + calc_ref(b, l, j)); for (j = 0; j < 2; j++) nv_wr32(dev, 0x1003ac + 0x8 * i + 0x4 * j, - calc_ref(dev, l, 1, j)); + calc_ref(b, l, j)); } } diff --git a/trunk/drivers/gpu/drm/nouveau/nv50_crtc.c b/trunk/drivers/gpu/drm/nouveau/nv50_crtc.c index bfd4ca2fe7ef..5d11ea101666 100644 --- a/trunk/drivers/gpu/drm/nouveau/nv50_crtc.c +++ b/trunk/drivers/gpu/drm/nouveau/nv50_crtc.c @@ -264,16 +264,11 @@ nv50_crtc_set_scale(struct nouveau_crtc *nv_crtc, int scaling_mode, bool update) int nv50_crtc_set_clock(struct drm_device *dev, int head, int pclk) { - struct drm_nouveau_private *dev_priv = dev->dev_private; + uint32_t reg = NV50_PDISPLAY_CRTC_CLK_CTRL1(head); struct pll_lims pll; - uint32_t reg, reg1, reg2; + uint32_t reg1, reg2; int ret, N1, M1, N2, M2, P; - if (dev_priv->chipset < NV_C0) - reg = NV50_PDISPLAY_CRTC_CLK_CTRL1(head); - else - reg = 0x614140 + (head * 0x800); - ret = get_pll_limits(dev, reg, &pll); if (ret) return ret; @@ -291,8 +286,7 @@ nv50_crtc_set_clock(struct drm_device *dev, int head, int pclk) nv_wr32(dev, reg, 0x10000611); nv_wr32(dev, reg + 4, reg1 | (M1 << 16) | N1); nv_wr32(dev, reg + 8, reg2 | (P << 28) | (M2 << 16) | N2); - } else - if (dev_priv->chipset < NV_C0) { + } else { ret = nv50_calc_pll2(dev, &pll, pclk, &N1, &N2, &M1, &P); if (ret <= 0) return 0; @@ -304,17 +298,6 @@ nv50_crtc_set_clock(struct drm_device *dev, int head, int pclk) nv_wr32(dev, reg, 0x50000610); nv_wr32(dev, reg + 4, reg1 | (P << 16) | (M1 << 8) | N1); nv_wr32(dev, reg + 8, N2); - } else { - ret = nv50_calc_pll2(dev, &pll, pclk, &N1, &N2, &M1, &P); - if (ret <= 0) - return 0; - - NV_DEBUG(dev, "pclk %d out %d N %d fN 0x%04x M %d P %d\n", - pclk, ret, N1, N2, M1, P); - - nv_mask(dev, reg + 0x0c, 0x00000000, 0x00000100); - nv_wr32(dev, reg + 0x04, (P << 16) | (N1 << 8) | M1); - nv_wr32(dev, reg + 0x10, N2 << 16); } return 0; @@ -365,7 +348,7 @@ nv50_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, gem = drm_gem_object_lookup(dev, file_priv, buffer_handle); if (!gem) - return -ENOENT; + return -EINVAL; cursor = nouveau_gem_object(gem); ret = nouveau_bo_map(cursor); @@ -398,12 +381,15 @@ nv50_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) static void nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, - uint32_t start, uint32_t size) + uint32_t size) { - int end = (start + size > 256) ? 256 : start + size, i; struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); + int i; + + if (size != 256) + return; - for (i = start; i < end; i++) { + for (i = 0; i < 256; i++) { nv_crtc->lut.r[i] = r[i]; nv_crtc->lut.g[i] = g[i]; nv_crtc->lut.b[i] = b[i]; diff --git a/trunk/drivers/gpu/drm/nouveau/nv50_display.c b/trunk/drivers/gpu/drm/nouveau/nv50_display.c index 612fa6d6a0cb..f13ad0de9c8f 100644 --- a/trunk/drivers/gpu/drm/nouveau/nv50_display.c +++ b/trunk/drivers/gpu/drm/nouveau/nv50_display.c @@ -76,10 +76,7 @@ nv50_evo_dmaobj_new(struct nouveau_channel *evo, uint32_t class, uint32_t name, nv_wo32(dev, obj, 2, offset); nv_wo32(dev, obj, 3, 0x00000000); nv_wo32(dev, obj, 4, 0x00000000); - if (dev_priv->card_type < NV_C0) - nv_wo32(dev, obj, 5, 0x00010000); - else - nv_wo32(dev, obj, 5, 0x00020000); + nv_wo32(dev, obj, 5, 0x00010000); dev_priv->engine.instmem.flush(dev); return 0; diff --git a/trunk/drivers/gpu/drm/nouveau/nvc0_fb.c b/trunk/drivers/gpu/drm/nouveau/nvc0_fb.c deleted file mode 100644 index 26a996025dd2..000000000000 --- a/trunk/drivers/gpu/drm/nouveau/nvc0_fb.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: Ben Skeggs - */ - -#include "drmP.h" - -#include "nouveau_drv.h" - -int -nvc0_fb_init(struct drm_device *dev) -{ - return 0; -} - -void -nvc0_fb_takedown(struct drm_device *dev) -{ -} diff --git a/trunk/drivers/gpu/drm/nouveau/nvc0_fifo.c b/trunk/drivers/gpu/drm/nouveau/nvc0_fifo.c deleted file mode 100644 index d64375871979..000000000000 --- a/trunk/drivers/gpu/drm/nouveau/nvc0_fifo.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: Ben Skeggs - */ - -#include "drmP.h" - -#include "nouveau_drv.h" - -void -nvc0_fifo_disable(struct drm_device *dev) -{ -} - -void -nvc0_fifo_enable(struct drm_device *dev) -{ -} - -bool -nvc0_fifo_reassign(struct drm_device *dev, bool enable) -{ - return false; -} - -bool -nvc0_fifo_cache_flush(struct drm_device *dev) -{ - return true; -} - -bool -nvc0_fifo_cache_pull(struct drm_device *dev, bool enable) -{ - return false; -} - -int -nvc0_fifo_channel_id(struct drm_device *dev) -{ - return 127; -} - -int -nvc0_fifo_create_context(struct nouveau_channel *chan) -{ - return 0; -} - -void -nvc0_fifo_destroy_context(struct nouveau_channel *chan) -{ -} - -int -nvc0_fifo_load_context(struct nouveau_channel *chan) -{ - return 0; -} - -int -nvc0_fifo_unload_context(struct drm_device *dev) -{ - return 0; -} - -void -nvc0_fifo_takedown(struct drm_device *dev) -{ -} - -int -nvc0_fifo_init(struct drm_device *dev) -{ - return 0; -} - diff --git a/trunk/drivers/gpu/drm/nouveau/nvc0_graph.c b/trunk/drivers/gpu/drm/nouveau/nvc0_graph.c deleted file mode 100644 index 717a5177a8d8..000000000000 --- a/trunk/drivers/gpu/drm/nouveau/nvc0_graph.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: Ben Skeggs - */ - -#include "drmP.h" - -#include "nouveau_drv.h" - -void -nvc0_graph_fifo_access(struct drm_device *dev, bool enabled) -{ -} - -struct nouveau_channel * -nvc0_graph_channel(struct drm_device *dev) -{ - return NULL; -} - -int -nvc0_graph_create_context(struct nouveau_channel *chan) -{ - return 0; -} - -void -nvc0_graph_destroy_context(struct nouveau_channel *chan) -{ -} - -int -nvc0_graph_load_context(struct nouveau_channel *chan) -{ - return 0; -} - -int -nvc0_graph_unload_context(struct drm_device *dev) -{ - return 0; -} - -void -nvc0_graph_takedown(struct drm_device *dev) -{ -} - -int -nvc0_graph_init(struct drm_device *dev) -{ - struct drm_nouveau_private *dev_priv = dev->dev_private; - dev_priv->engine.graph.accel_blocked = true; - return 0; -} - diff --git a/trunk/drivers/gpu/drm/nouveau/nvc0_instmem.c b/trunk/drivers/gpu/drm/nouveau/nvc0_instmem.c deleted file mode 100644 index 3ab3cdc42173..000000000000 --- a/trunk/drivers/gpu/drm/nouveau/nvc0_instmem.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: Ben Skeggs - */ - -#include "drmP.h" - -#include "nouveau_drv.h" - -int -nvc0_instmem_populate(struct drm_device *dev, struct nouveau_gpuobj *gpuobj, - uint32_t *size) -{ - int ret; - - *size = ALIGN(*size, 4096); - if (*size == 0) - return -EINVAL; - - ret = nouveau_bo_new(dev, NULL, *size, 0, TTM_PL_FLAG_VRAM, 0, 0x0000, - true, false, &gpuobj->im_backing); - if (ret) { - NV_ERROR(dev, "error getting PRAMIN backing pages: %d\n", ret); - return ret; - } - - ret = nouveau_bo_pin(gpuobj->im_backing, TTM_PL_FLAG_VRAM); - if (ret) { - NV_ERROR(dev, "error pinning PRAMIN backing VRAM: %d\n", ret); - nouveau_bo_ref(NULL, &gpuobj->im_backing); - return ret; - } - - gpuobj->im_backing_start = gpuobj->im_backing->bo.mem.mm_node->start; - gpuobj->im_backing_start <<= PAGE_SHIFT; - return 0; -} - -void -nvc0_instmem_clear(struct drm_device *dev, struct nouveau_gpuobj *gpuobj) -{ - struct drm_nouveau_private *dev_priv = dev->dev_private; - - if (gpuobj && gpuobj->im_backing) { - if (gpuobj->im_bound) - dev_priv->engine.instmem.unbind(dev, gpuobj); - nouveau_bo_unpin(gpuobj->im_backing); - nouveau_bo_ref(NULL, &gpuobj->im_backing); - gpuobj->im_backing = NULL; - } -} - -int -nvc0_instmem_bind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj) -{ - struct drm_nouveau_private *dev_priv = dev->dev_private; - uint32_t pte, pte_end; - uint64_t vram; - - if (!gpuobj->im_backing || !gpuobj->im_pramin || gpuobj->im_bound) - return -EINVAL; - - NV_DEBUG(dev, "st=0x%lx sz=0x%lx\n", - gpuobj->im_pramin->start, gpuobj->im_pramin->size); - - pte = gpuobj->im_pramin->start >> 12; - pte_end = (gpuobj->im_pramin->size >> 12) + pte; - vram = gpuobj->im_backing_start; - - NV_DEBUG(dev, "pramin=0x%lx, pte=%d, pte_end=%d\n", - gpuobj->im_pramin->start, pte, pte_end); - NV_DEBUG(dev, "first vram page: 0x%08x\n", gpuobj->im_backing_start); - - while (pte < pte_end) { - nv_wr32(dev, 0x702000 + (pte * 8), (vram >> 8) | 1); - nv_wr32(dev, 0x702004 + (pte * 8), 0); - vram += 4096; - pte++; - } - dev_priv->engine.instmem.flush(dev); - - if (1) { - u32 chan = nv_rd32(dev, 0x1700) << 16; - nv_wr32(dev, 0x100cb8, (chan + 0x1000) >> 8); - nv_wr32(dev, 0x100cbc, 0x80000005); - } - - gpuobj->im_bound = 1; - return 0; -} - -int -nvc0_instmem_unbind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj) -{ - struct drm_nouveau_private *dev_priv = dev->dev_private; - uint32_t pte, pte_end; - - if (gpuobj->im_bound == 0) - return -EINVAL; - - pte = gpuobj->im_pramin->start >> 12; - pte_end = (gpuobj->im_pramin->size >> 12) + pte; - while (pte < pte_end) { - nv_wr32(dev, 0x702000 + (pte * 8), 0); - nv_wr32(dev, 0x702004 + (pte * 8), 0); - pte++; - } - dev_priv->engine.instmem.flush(dev); - - gpuobj->im_bound = 0; - return 0; -} - -void -nvc0_instmem_flush(struct drm_device *dev) -{ - nv_wr32(dev, 0x070000, 1); - if (!nv_wait(0x070000, 0x00000002, 0x00000000)) - NV_ERROR(dev, "PRAMIN flush timeout\n"); -} - -int -nvc0_instmem_suspend(struct drm_device *dev) -{ - struct drm_nouveau_private *dev_priv = dev->dev_private; - int i; - - dev_priv->susres.ramin_copy = vmalloc(65536); - if (!dev_priv->susres.ramin_copy) - return -ENOMEM; - - for (i = 0x700000; i < 0x710000; i += 4) - dev_priv->susres.ramin_copy[i/4] = nv_rd32(dev, i); - return 0; -} - -void -nvc0_instmem_resume(struct drm_device *dev) -{ - struct drm_nouveau_private *dev_priv = dev->dev_private; - u64 chan; - int i; - - chan = dev_priv->vram_size - dev_priv->ramin_rsvd_vram; - nv_wr32(dev, 0x001700, chan >> 16); - - for (i = 0x700000; i < 0x710000; i += 4) - nv_wr32(dev, i, dev_priv->susres.ramin_copy[i/4]); - vfree(dev_priv->susres.ramin_copy); - dev_priv->susres.ramin_copy = NULL; - - nv_wr32(dev, 0x001714, 0xc0000000 | (chan >> 12)); -} - -int -nvc0_instmem_init(struct drm_device *dev) -{ - struct drm_nouveau_private *dev_priv = dev->dev_private; - u64 chan, pgt3, imem, lim3 = dev_priv->ramin_size - 1; - int ret, i; - - dev_priv->ramin_rsvd_vram = 1 * 1024 * 1024; - chan = dev_priv->vram_size - dev_priv->ramin_rsvd_vram; - imem = 4096 + 4096 + 32768; - - nv_wr32(dev, 0x001700, chan >> 16); - - /* channel setup */ - nv_wr32(dev, 0x700200, lower_32_bits(chan + 0x1000)); - nv_wr32(dev, 0x700204, upper_32_bits(chan + 0x1000)); - nv_wr32(dev, 0x700208, lower_32_bits(lim3)); - nv_wr32(dev, 0x70020c, upper_32_bits(lim3)); - - /* point pgd -> pgt */ - nv_wr32(dev, 0x701000, 0); - nv_wr32(dev, 0x701004, ((chan + 0x2000) >> 8) | 1); - - /* point pgt -> physical vram for channel */ - pgt3 = 0x2000; - for (i = 0; i < dev_priv->ramin_rsvd_vram; i += 4096, pgt3 += 8) { - nv_wr32(dev, 0x700000 + pgt3, ((chan + i) >> 8) | 1); - nv_wr32(dev, 0x700004 + pgt3, 0); - } - - /* clear rest of pgt */ - for (; i < dev_priv->ramin_size; i += 4096, pgt3 += 8) { - nv_wr32(dev, 0x700000 + pgt3, 0); - nv_wr32(dev, 0x700004 + pgt3, 0); - } - - /* point bar3 at the channel */ - nv_wr32(dev, 0x001714, 0xc0000000 | (chan >> 12)); - - /* Global PRAMIN heap */ - ret = drm_mm_init(&dev_priv->ramin_heap, imem, - dev_priv->ramin_size - imem); - if (ret) { - NV_ERROR(dev, "Failed to init RAMIN heap\n"); - return -ENOMEM; - } - - /*XXX: incorrect, but needed to make hash func "work" */ - dev_priv->ramht_offset = 0x10000; - dev_priv->ramht_bits = 9; - dev_priv->ramht_size = (1 << dev_priv->ramht_bits); - return 0; -} - -void -nvc0_instmem_takedown(struct drm_device *dev) -{ -} - diff --git a/trunk/drivers/gpu/drm/radeon/r600_cp.c b/trunk/drivers/gpu/drm/radeon/r600_cp.c index 4f4cd8b286d5..68e6f4349309 100644 --- a/trunk/drivers/gpu/drm/radeon/r600_cp.c +++ b/trunk/drivers/gpu/drm/radeon/r600_cp.c @@ -200,7 +200,7 @@ int r600_page_table_init(struct drm_device *dev) entry->pagelist[i], 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); - if (pci_dma_mapping_error(dev->pdev, entry->busaddr[i])) { + if (entry->busaddr[i] == 0) { DRM_ERROR("unable to map PCIGART pages!\n"); r600_page_table_cleanup(dev, gart_info); goto done; diff --git a/trunk/drivers/gpu/drm/radeon/r600_cs.c b/trunk/drivers/gpu/drm/radeon/r600_cs.c index d8864949e387..c3ea212e0c3c 100644 --- a/trunk/drivers/gpu/drm/radeon/r600_cs.c +++ b/trunk/drivers/gpu/drm/radeon/r600_cs.c @@ -133,7 +133,6 @@ static inline int r600_bpe_from_format(u32 *bpe, u32 format) case V_038004_FMT_GB_GR: case V_038004_FMT_BG_RG: case V_038004_COLOR_INVALID: - default: *bpe = 16; return -EINVAL; } @@ -175,7 +174,7 @@ static inline int r600_cs_track_validate_cb(struct radeon_cs_parser *p, int i) dev_warn(p->dev, "FMASK or CMASK buffer are not supported by this kernel\n"); return -EINVAL; } - size = radeon_bo_size(track->cb_color_bo[i]) - track->cb_color_bo_offset[i]; + size = radeon_bo_size(track->cb_color_bo[i]); if (r600_bpe_from_format(&bpe, G_0280A0_FORMAT(track->cb_color_info[i]))) { dev_warn(p->dev, "%s:%d cb invalid format %d for %d (0x%08X)\n", __func__, __LINE__, G_0280A0_FORMAT(track->cb_color_info[i]), @@ -328,6 +327,7 @@ static int r600_cs_track_check(struct radeon_cs_parser *p) dev_warn(p->dev, "z/stencil buffer size not set\n"); return -EINVAL; } + printk_once(KERN_WARNING "You have old & broken userspace please consider updating mesa\n"); tmp = radeon_bo_size(track->db_bo) - track->db_offset; tmp = (tmp / bpe) >> 6; if (!tmp) { @@ -882,6 +882,8 @@ static inline int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx return -EINVAL; } ib[idx] = track->cb_color_base_last[tmp]; + printk_once(KERN_WARNING "You have old & broken userspace " + "please consider updating mesa & xf86-video-ati\n"); track->cb_color_frag_bo[tmp] = track->cb_color_bo[tmp]; } else { r = r600_cs_packet_next_reloc(p, &reloc); @@ -908,6 +910,8 @@ static inline int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx return -EINVAL; } ib[idx] = track->cb_color_base_last[tmp]; + printk_once(KERN_WARNING "You have old & broken userspace " + "please consider updating mesa & xf86-video-ati\n"); track->cb_color_tile_bo[tmp] = track->cb_color_bo[tmp]; } else { r = r600_cs_packet_next_reloc(p, &reloc); @@ -934,7 +938,7 @@ static inline int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx return -EINVAL; } tmp = (reg - CB_COLOR0_BASE) / 4; - track->cb_color_bo_offset[tmp] = radeon_get_ib_value(p, idx) << 8; + track->cb_color_bo_offset[tmp] = radeon_get_ib_value(p, idx); ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); track->cb_color_base_last[tmp] = ib[idx]; track->cb_color_bo[tmp] = reloc->robj; @@ -946,7 +950,7 @@ static inline int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx "0x%04X\n", reg); return -EINVAL; } - track->db_offset = radeon_get_ib_value(p, idx) << 8; + track->db_offset = radeon_get_ib_value(p, idx); ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); track->db_bo = reloc->robj; break; @@ -1051,10 +1055,10 @@ static void r600_texture_size(unsigned nfaces, unsigned blevel, unsigned nlevels } *l0_size = ALIGN((w0 * bpe), pitch_align) * h0 * d0; *mipmap_size = offset; - if (!nlevels) - *mipmap_size = *l0_size; if (!blevel) *mipmap_size -= *l0_size; + if (!nlevels) + *mipmap_size = *l0_size; } /** @@ -1161,14 +1165,14 @@ static inline int r600_check_texture_resource(struct radeon_cs_parser *p, u32 i (pitch_align * bpe), &l0_size, &mipmap_size); /* using get ib will give us the offset into the texture bo */ - word0 = radeon_get_ib_value(p, idx + 2) << 8; + word0 = radeon_get_ib_value(p, idx + 2); if ((l0_size + word0) > radeon_bo_size(texture)) { dev_warn(p->dev, "texture bo too small (%d %d %d %d -> %d have %ld)\n", w0, h0, bpe, word0, l0_size, radeon_bo_size(texture)); return -EINVAL; } /* using get ib will give us the offset into the mipmap bo */ - word0 = radeon_get_ib_value(p, idx + 3) << 8; + word0 = radeon_get_ib_value(p, idx + 3); if ((mipmap_size + word0) > radeon_bo_size(mipmap)) { dev_warn(p->dev, "mipmap bo too small (%d %d %d %d %d %d -> %d have %ld)\n", w0, h0, bpe, blevel, nlevels, word0, mipmap_size, radeon_bo_size(texture)); @@ -1362,7 +1366,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p, } for (i = 0; i < (pkt->count / 7); i++) { struct radeon_bo *texture, *mipmap; - u32 size, offset, base_offset, mip_offset; + u32 size, offset; switch (G__SQ_VTX_CONSTANT_TYPE(radeon_get_ib_value(p, idx+(i*7)+6+1))) { case SQ_TEX_VTX_VALID_TEXTURE: @@ -1372,7 +1376,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p, DRM_ERROR("bad SET_RESOURCE\n"); return -EINVAL; } - base_offset = (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); + ib[idx+1+(i*7)+2] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO) ib[idx+1+(i*7)+0] |= S_038000_TILE_MODE(V_038000_ARRAY_2D_TILED_THIN1); else if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO) @@ -1384,14 +1388,12 @@ static int r600_packet3_check(struct radeon_cs_parser *p, DRM_ERROR("bad SET_RESOURCE\n"); return -EINVAL; } - mip_offset = (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); + ib[idx+1+(i*7)+3] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); mipmap = reloc->robj; r = r600_check_texture_resource(p, idx+(i*7)+1, texture, mipmap, reloc->lobj.tiling_flags); if (r) return r; - ib[idx+1+(i*7)+2] += base_offset; - ib[idx+1+(i*7)+3] += mip_offset; break; case SQ_TEX_VTX_VALID_BUFFER: /* vtx base */ @@ -1401,11 +1403,10 @@ static int r600_packet3_check(struct radeon_cs_parser *p, return -EINVAL; } offset = radeon_get_ib_value(p, idx+1+(i*7)+0); - size = radeon_get_ib_value(p, idx+1+(i*7)+1) + 1; + size = radeon_get_ib_value(p, idx+1+(i*7)+1); if (p->rdev && (size + offset) > radeon_bo_size(reloc->robj)) { /* force size to size of the buffer */ - dev_warn(p->dev, "vbo resource seems too big (%d) for the bo (%ld)\n", - size + offset, radeon_bo_size(reloc->robj)); + dev_warn(p->dev, "vbo resource seems too big for the bo\n"); ib[idx+1+(i*7)+1] = radeon_bo_size(reloc->robj); } ib[idx+1+(i*7)+0] += (u32)((reloc->lobj.gpu_offset) & 0xffffffff); diff --git a/trunk/drivers/gpu/drm/radeon/radeon.h b/trunk/drivers/gpu/drm/radeon/radeon.h index 3dfcfa3ca425..3cd1c470b777 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon.h +++ b/trunk/drivers/gpu/drm/radeon/radeon.h @@ -1100,8 +1100,6 @@ struct radeon_device { struct notifier_block acpi_nb; /* only one userspace can use Hyperz features at a time */ struct drm_file *hyperz_filp; - /* i2c buses */ - struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS]; }; int radeon_device_init(struct radeon_device *rdev, diff --git a/trunk/drivers/gpu/drm/radeon/radeon_atombios.c b/trunk/drivers/gpu/drm/radeon/radeon_atombios.c index 6d30868744ee..3bc2bcdf5308 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_atombios.c @@ -48,8 +48,7 @@ radeon_add_atom_connector(struct drm_device *dev, struct radeon_i2c_bus_rec *i2c_bus, bool linkb, uint32_t igp_lane_info, uint16_t connector_object_id, - struct radeon_hpd *hpd, - struct radeon_router *router); + struct radeon_hpd *hpd); /* from radeon_legacy_encoder.c */ extern void @@ -115,8 +114,7 @@ static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_dev i2c.i2c_id = gpio->sucI2cId.ucAccess; - if (i2c.mask_clk_reg) - i2c.valid = true; + i2c.valid = true; break; } } @@ -125,66 +123,6 @@ static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_dev return i2c; } -void radeon_atombios_i2c_init(struct radeon_device *rdev) -{ - struct atom_context *ctx = rdev->mode_info.atom_context; - ATOM_GPIO_I2C_ASSIGMENT *gpio; - struct radeon_i2c_bus_rec i2c; - int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info); - struct _ATOM_GPIO_I2C_INFO *i2c_info; - uint16_t data_offset, size; - int i, num_indices; - char stmp[32]; - - memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec)); - - if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) { - i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset); - - num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / - sizeof(ATOM_GPIO_I2C_ASSIGMENT); - - for (i = 0; i < num_indices; i++) { - gpio = &i2c_info->asGPIO_Info[i]; - i2c.valid = false; - i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4; - i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4; - i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4; - i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4; - i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4; - i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4; - i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4; - i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4; - i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift); - i2c.mask_data_mask = (1 << gpio->ucDataMaskShift); - i2c.en_clk_mask = (1 << gpio->ucClkEnShift); - i2c.en_data_mask = (1 << gpio->ucDataEnShift); - i2c.y_clk_mask = (1 << gpio->ucClkY_Shift); - i2c.y_data_mask = (1 << gpio->ucDataY_Shift); - i2c.a_clk_mask = (1 << gpio->ucClkA_Shift); - i2c.a_data_mask = (1 << gpio->ucDataA_Shift); - - if (gpio->sucI2cId.sbfAccess.bfHW_Capable) - i2c.hw_capable = true; - else - i2c.hw_capable = false; - - if (gpio->sucI2cId.ucAccess == 0xa0) - i2c.mm_i2c = true; - else - i2c.mm_i2c = false; - - i2c.i2c_id = gpio->sucI2cId.ucAccess; - - if (i2c.mask_clk_reg) { - i2c.valid = true; - sprintf(stmp, "0x%x", i2c.i2c_id); - rdev->i2c_bus[i] = radeon_i2c_create(rdev->ddev, &i2c, stmp); - } - } - } -} - static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rdev, u8 id) { @@ -268,7 +206,6 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev, uint16_t *line_mux, struct radeon_hpd *hpd) { - struct radeon_device *rdev = dev->dev_private; /* Asus M2A-VM HDMI board lists the DVI port as HDMI */ if ((dev->pdev->device == 0x791e) && @@ -371,22 +308,13 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev, } } - /* Acer laptop reports DVI-D as DVI-I and hpd pins reversed */ + /* Acer laptop reports DVI-D as DVI-I */ if ((dev->pdev->device == 0x95c4) && (dev->pdev->subsystem_vendor == 0x1025) && (dev->pdev->subsystem_device == 0x013c)) { - struct radeon_gpio_rec gpio; - if ((*connector_type == DRM_MODE_CONNECTOR_DVII) && - (supported_device == ATOM_DEVICE_DFP1_SUPPORT)) { - gpio = radeon_lookup_gpio(rdev, 6); - *hpd = radeon_atom_get_hpd_info_from_gpio(rdev, &gpio); + (supported_device == ATOM_DEVICE_DFP1_SUPPORT)) *connector_type = DRM_MODE_CONNECTOR_DVID; - } else if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) && - (supported_device == ATOM_DEVICE_DFP1_SUPPORT)) { - gpio = radeon_lookup_gpio(rdev, 7); - *hpd = radeon_atom_get_hpd_info_from_gpio(rdev, &gpio); - } } /* XFX Pine Group device rv730 reports no VGA DDC lines @@ -471,15 +399,13 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev) u16 size, data_offset; u8 frev, crev; ATOM_CONNECTOR_OBJECT_TABLE *con_obj; - ATOM_OBJECT_TABLE *router_obj; ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj; ATOM_OBJECT_HEADER *obj_header; - int i, j, k, path_size, device_support; + int i, j, path_size, device_support; int connector_type; u16 igp_lane_info, conn_id, connector_object_id; bool linkb; struct radeon_i2c_bus_rec ddc_bus; - struct radeon_router router; struct radeon_gpio_rec gpio; struct radeon_hpd hpd; @@ -489,8 +415,6 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev) if (crev < 2) return false; - router.valid = false; - obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset); path_obj = (ATOM_DISPLAY_OBJECT_PATH_TABLE *) (ctx->bios + data_offset + @@ -498,9 +422,6 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev) con_obj = (ATOM_CONNECTOR_OBJECT_TABLE *) (ctx->bios + data_offset + le16_to_cpu(obj_header->usConnectorObjectTableOffset)); - router_obj = (ATOM_OBJECT_TABLE *) - (ctx->bios + data_offset + - le16_to_cpu(obj_header->usRouterObjectTableOffset)); device_support = le16_to_cpu(obj_header->usDeviceSupport); path_size = 0; @@ -587,86 +508,33 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev) if (connector_type == DRM_MODE_CONNECTOR_Unknown) continue; - for (j = 0; j < ((le16_to_cpu(path->usSize) - 8) / 2); j++) { - uint8_t grph_obj_id, grph_obj_num, grph_obj_type; + for (j = 0; j < ((le16_to_cpu(path->usSize) - 8) / 2); + j++) { + uint8_t enc_obj_id, enc_obj_num, enc_obj_type; - grph_obj_id = + enc_obj_id = (le16_to_cpu(path->usGraphicObjIds[j]) & OBJECT_ID_MASK) >> OBJECT_ID_SHIFT; - grph_obj_num = + enc_obj_num = (le16_to_cpu(path->usGraphicObjIds[j]) & ENUM_ID_MASK) >> ENUM_ID_SHIFT; - grph_obj_type = + enc_obj_type = (le16_to_cpu(path->usGraphicObjIds[j]) & OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT; - if (grph_obj_type == GRAPH_OBJECT_TYPE_ENCODER) { - if (grph_obj_num == 2) + /* FIXME: add support for router objects */ + if (enc_obj_type == GRAPH_OBJECT_TYPE_ENCODER) { + if (enc_obj_num == 2) linkb = true; else linkb = false; radeon_add_atom_encoder(dev, - grph_obj_id, + enc_obj_id, le16_to_cpu (path-> usDeviceTag)); - } else if (grph_obj_type == GRAPH_OBJECT_TYPE_ROUTER) { - router.valid = false; - for (k = 0; k < router_obj->ucNumberOfObjects; k++) { - u16 router_obj_id = le16_to_cpu(router_obj->asObjects[j].usObjectID); - if (le16_to_cpu(path->usGraphicObjIds[j]) == router_obj_id) { - ATOM_COMMON_RECORD_HEADER *record = (ATOM_COMMON_RECORD_HEADER *) - (ctx->bios + data_offset + - le16_to_cpu(router_obj->asObjects[k].usRecordOffset)); - ATOM_I2C_RECORD *i2c_record; - ATOM_I2C_ID_CONFIG_ACCESS *i2c_config; - ATOM_ROUTER_DDC_PATH_SELECT_RECORD *ddc_path; - ATOM_SRC_DST_TABLE_FOR_ONE_OBJECT *router_src_dst_table = - (ATOM_SRC_DST_TABLE_FOR_ONE_OBJECT *) - (ctx->bios + data_offset + - le16_to_cpu(router_obj->asObjects[k].usSrcDstTableOffset)); - int enum_id; - - router.router_id = router_obj_id; - for (enum_id = 0; enum_id < router_src_dst_table->ucNumberOfDst; - enum_id++) { - if (le16_to_cpu(path->usConnObjectId) == - le16_to_cpu(router_src_dst_table->usDstObjectID[enum_id])) - break; - } - - while (record->ucRecordType > 0 && - record->ucRecordType <= ATOM_MAX_OBJECT_RECORD_NUMBER) { - switch (record->ucRecordType) { - case ATOM_I2C_RECORD_TYPE: - i2c_record = - (ATOM_I2C_RECORD *) - record; - i2c_config = - (ATOM_I2C_ID_CONFIG_ACCESS *) - &i2c_record->sucI2cId; - router.i2c_info = - radeon_lookup_i2c_gpio(rdev, - i2c_config-> - ucAccess); - router.i2c_addr = i2c_record->ucI2CAddr >> 1; - break; - case ATOM_ROUTER_DDC_PATH_SELECT_RECORD_TYPE: - ddc_path = (ATOM_ROUTER_DDC_PATH_SELECT_RECORD *) - record; - router.valid = true; - router.mux_type = ddc_path->ucMuxType; - router.mux_control_pin = ddc_path->ucMuxControlPin; - router.mux_state = ddc_path->ucMuxState[enum_id]; - break; - } - record = (ATOM_COMMON_RECORD_HEADER *) - ((char *)record + record->ucRecordSize); - } - } - } } } @@ -746,8 +614,7 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev) connector_type, &ddc_bus, linkb, igp_lane_info, connector_object_id, - &hpd, - &router); + &hpd); } } @@ -824,9 +691,6 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct int i, j, max_device; struct bios_connector *bios_connectors; size_t bc_size = sizeof(*bios_connectors) * ATOM_MAX_SUPPORTED_DEVICE; - struct radeon_router router; - - router.valid = false; bios_connectors = kzalloc(bc_size, GFP_KERNEL); if (!bios_connectors) @@ -998,8 +862,7 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct &bios_connectors[i].ddc_bus, false, 0, connector_object_id, - &bios_connectors[i].hpd, - &router); + &bios_connectors[i].hpd); } } @@ -1658,7 +1521,7 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev) thermal_controller_names[power_info->info.ucOverdriveThermalController], power_info->info.ucOverdriveControllerAddress >> 1); i2c_bus = radeon_lookup_i2c_gpio(rdev, power_info->info.ucOverdriveI2cLine); - rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); + rdev->pm.i2c_bus = radeon_i2c_create(rdev->ddev, &i2c_bus, "Thermal"); if (rdev->pm.i2c_bus) { struct i2c_board_info info = { }; const char *name = thermal_controller_names[power_info->info. @@ -1951,7 +1814,7 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev) (controller->ucFanParameters & ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with"); i2c_bus = radeon_lookup_i2c_gpio(rdev, controller->ucI2cLine); - rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); + rdev->pm.i2c_bus = radeon_i2c_create(rdev->ddev, &i2c_bus, "Thermal"); if (rdev->pm.i2c_bus) { struct i2c_board_info info = { }; const char *name = pp_lib_thermal_controller_names[controller->ucType]; @@ -2064,11 +1927,6 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev) rdev->pm.power_state[state_index].type = POWER_STATE_TYPE_PERFORMANCE; break; - case ATOM_PPLIB_CLASSIFICATION_UI_NONE: - if (misc2 & ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE) - rdev->pm.power_state[state_index].type = - POWER_STATE_TYPE_PERFORMANCE; - break; } rdev->pm.power_state[state_index].flags = 0; if (misc & ATOM_PPLIB_SINGLE_DISPLAY_ONLY) diff --git a/trunk/drivers/gpu/drm/radeon/radeon_clocks.c b/trunk/drivers/gpu/drm/radeon/radeon_clocks.c index 14448a740ba6..f64936cc4dd9 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_clocks.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_clocks.c @@ -91,85 +91,6 @@ uint32_t radeon_legacy_get_memory_clock(struct radeon_device *rdev) return mclk; } -#ifdef CONFIG_OF -/* - * Read XTAL (ref clock), SCLK and MCLK from Open Firmware device - * tree. Hopefully, ATI OF driver is kind enough to fill these - */ -static bool __devinit radeon_read_clocks_OF(struct drm_device *dev) -{ - struct radeon_device *rdev = dev->dev_private; - struct device_node *dp = rdev->pdev->dev.of_node; - const u32 *val; - struct radeon_pll *p1pll = &rdev->clock.p1pll; - struct radeon_pll *p2pll = &rdev->clock.p2pll; - struct radeon_pll *spll = &rdev->clock.spll; - struct radeon_pll *mpll = &rdev->clock.mpll; - - if (dp == NULL) - return false; - val = of_get_property(dp, "ATY,RefCLK", NULL); - if (!val || !*val) { - printk(KERN_WARNING "radeonfb: No ATY,RefCLK property !\n"); - return false; - } - p1pll->reference_freq = p2pll->reference_freq = (*val) / 10; - p1pll->reference_div = RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; - if (p1pll->reference_div < 2) - p1pll->reference_div = 12; - p2pll->reference_div = p1pll->reference_div; - - /* These aren't in the device-tree */ - if (rdev->family >= CHIP_R420) { - p1pll->pll_in_min = 100; - p1pll->pll_in_max = 1350; - p1pll->pll_out_min = 20000; - p1pll->pll_out_max = 50000; - p2pll->pll_in_min = 100; - p2pll->pll_in_max = 1350; - p2pll->pll_out_min = 20000; - p2pll->pll_out_max = 50000; - } else { - p1pll->pll_in_min = 40; - p1pll->pll_in_max = 500; - p1pll->pll_out_min = 12500; - p1pll->pll_out_max = 35000; - p2pll->pll_in_min = 40; - p2pll->pll_in_max = 500; - p2pll->pll_out_min = 12500; - p2pll->pll_out_max = 35000; - } - - spll->reference_freq = mpll->reference_freq = p1pll->reference_freq; - spll->reference_div = mpll->reference_div = - RREG32_PLL(RADEON_M_SPLL_REF_FB_DIV) & - RADEON_M_SPLL_REF_DIV_MASK; - - val = of_get_property(dp, "ATY,SCLK", NULL); - if (val && *val) - rdev->clock.default_sclk = (*val) / 10; - else - rdev->clock.default_sclk = - radeon_legacy_get_engine_clock(rdev); - - val = of_get_property(dp, "ATY,MCLK", NULL); - if (val && *val) - rdev->clock.default_mclk = (*val) / 10; - else - rdev->clock.default_mclk = - radeon_legacy_get_memory_clock(rdev); - - DRM_INFO("Using device-tree clock info\n"); - - return true; -} -#else -static bool __devinit radeon_read_clocks_OF(struct drm_device *dev) -{ - return false; -} -#endif /* CONFIG_OF */ - void radeon_get_clock_info(struct drm_device *dev) { struct radeon_device *rdev = dev->dev_private; @@ -184,8 +105,6 @@ void radeon_get_clock_info(struct drm_device *dev) ret = radeon_atom_get_clock_info(dev); else ret = radeon_combios_get_clock_info(dev); - if (!ret) - ret = radeon_read_clocks_OF(dev); if (ret) { if (p1pll->reference_div < 2) { diff --git a/trunk/drivers/gpu/drm/radeon/radeon_combios.c b/trunk/drivers/gpu/drm/radeon/radeon_combios.c index 885dcfac1838..5e1474cde4b4 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_combios.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_combios.c @@ -480,66 +480,9 @@ radeon_combios_get_hardcoded_edid(struct radeon_device *rdev) } static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev, - enum radeon_combios_ddc ddc, - u32 clk_mask, - u32 data_mask) + int ddc_line) { struct radeon_i2c_bus_rec i2c; - int ddc_line = 0; - - /* ddc id = mask reg - * DDC_NONE_DETECTED = none - * DDC_DVI = RADEON_GPIO_DVI_DDC - * DDC_VGA = RADEON_GPIO_VGA_DDC - * DDC_LCD = RADEON_GPIOPAD_MASK - * DDC_GPIO = RADEON_MDGPIO_MASK - * r1xx/r2xx - * DDC_MONID = RADEON_GPIO_MONID - * DDC_CRT2 = RADEON_GPIO_CRT2_DDC - * r3xx - * DDC_MONID = RADEON_GPIO_MONID - * DDC_CRT2 = RADEON_GPIO_DVI_DDC - * rs3xx/rs4xx - * DDC_MONID = RADEON_GPIOPAD_MASK - * DDC_CRT2 = RADEON_GPIO_MONID - */ - switch (ddc) { - case DDC_NONE_DETECTED: - default: - ddc_line = 0; - break; - case DDC_DVI: - ddc_line = RADEON_GPIO_DVI_DDC; - break; - case DDC_VGA: - ddc_line = RADEON_GPIO_VGA_DDC; - break; - case DDC_LCD: - ddc_line = RADEON_GPIOPAD_MASK; - break; - case DDC_GPIO: - ddc_line = RADEON_MDGPIO_MASK; - break; - case DDC_MONID: - if (rdev->family == CHIP_RS300 || - rdev->family == CHIP_RS400 || - rdev->family == CHIP_RS480) - ddc_line = RADEON_GPIOPAD_MASK; - else - ddc_line = RADEON_GPIO_MONID; - break; - case DDC_CRT2: - if (rdev->family == CHIP_RS300 || - rdev->family == CHIP_RS400 || - rdev->family == CHIP_RS480) - ddc_line = RADEON_GPIO_MONID; - else if (rdev->family >= CHIP_R300) { - ddc_line = RADEON_GPIO_DVI_DDC; - ddc = DDC_DVI; - } else - ddc_line = RADEON_GPIO_CRT2_DDC; - break; - } if (ddc_line == RADEON_GPIOPAD_MASK) { i2c.mask_clk_reg = RADEON_GPIOPAD_MASK; @@ -559,26 +502,6 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde i2c.en_data_reg = RADEON_MDGPIO_EN; i2c.y_clk_reg = RADEON_MDGPIO_Y; i2c.y_data_reg = RADEON_MDGPIO_Y; - } else { - i2c.mask_clk_reg = ddc_line; - i2c.mask_data_reg = ddc_line; - i2c.a_clk_reg = ddc_line; - i2c.a_data_reg = ddc_line; - i2c.en_clk_reg = ddc_line; - i2c.en_data_reg = ddc_line; - i2c.y_clk_reg = ddc_line; - i2c.y_data_reg = ddc_line; - } - - if (clk_mask && data_mask) { - i2c.mask_clk_mask = clk_mask; - i2c.mask_data_mask = data_mask; - i2c.a_clk_mask = clk_mask; - i2c.a_data_mask = data_mask; - i2c.en_clk_mask = clk_mask; - i2c.en_data_mask = data_mask; - i2c.y_clk_mask = clk_mask; - i2c.y_data_mask = data_mask; } else { i2c.mask_clk_mask = RADEON_GPIO_EN_1; i2c.mask_data_mask = RADEON_GPIO_EN_0; @@ -588,6 +511,15 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde i2c.en_data_mask = RADEON_GPIO_EN_0; i2c.y_clk_mask = RADEON_GPIO_Y_1; i2c.y_data_mask = RADEON_GPIO_Y_0; + + i2c.mask_clk_reg = ddc_line; + i2c.mask_data_reg = ddc_line; + i2c.a_clk_reg = ddc_line; + i2c.a_data_reg = ddc_line; + i2c.en_clk_reg = ddc_line; + i2c.en_data_reg = ddc_line; + i2c.y_clk_reg = ddc_line; + i2c.y_data_reg = ddc_line; } switch (rdev->family) { @@ -667,8 +599,7 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde break; } i2c.mm_i2c = false; - - i2c.i2c_id = ddc; + i2c.i2c_id = 0; i2c.hpd = RADEON_HPD_NONE; if (ddc_line) @@ -679,62 +610,6 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde return i2c; } -void radeon_combios_i2c_init(struct radeon_device *rdev) -{ - struct drm_device *dev = rdev->ddev; - struct radeon_i2c_bus_rec i2c; - - - i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); - rdev->i2c_bus[0] = radeon_i2c_create(dev, &i2c, "DVI_DDC"); - - i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); - rdev->i2c_bus[1] = radeon_i2c_create(dev, &i2c, "VGA_DDC"); - - i2c.valid = true; - i2c.hw_capable = true; - i2c.mm_i2c = true; - i2c.i2c_id = 0xa0; - rdev->i2c_bus[2] = radeon_i2c_create(dev, &i2c, "MM_I2C"); - - if (rdev->family == CHIP_RS300 || - rdev->family == CHIP_RS400 || - rdev->family == CHIP_RS480) { - u16 offset; - u8 id, blocks, clk, data; - int i; - - i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); - rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); - - offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); - if (offset) { - blocks = RBIOS8(offset + 2); - for (i = 0; i < blocks; i++) { - id = RBIOS8(offset + 3 + (i * 5) + 0); - if (id == 136) { - clk = RBIOS8(offset + 3 + (i * 5) + 3); - data = RBIOS8(offset + 3 + (i * 5) + 4); - i2c = combios_setup_i2c_bus(rdev, DDC_MONID, - clk, data); - rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "GPIOPAD_MASK"); - break; - } - } - } - - } else if (rdev->family >= CHIP_R300) { - i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); - rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); - } else { - i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); - rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID"); - - i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); - rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "CRT2_DDC"); - } -} - bool radeon_combios_get_clock_info(struct drm_device *dev) { struct radeon_device *rdev = dev->dev_private; @@ -1372,8 +1247,8 @@ bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, struct radeon_i2c_bus_rec i2c_bus; /* default for macs */ - i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); - tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); + i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); + tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); /* XXX some macs have duallink chips */ switch (rdev->mode_info.connector_table) { @@ -1394,16 +1269,47 @@ bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder struct drm_device *dev = encoder->base.dev; struct radeon_device *rdev = dev->dev_private; uint16_t offset; - uint8_t ver; + uint8_t ver, id, blocks, clk, data; + int i; enum radeon_combios_ddc gpio; struct radeon_i2c_bus_rec i2c_bus; tmds->i2c_bus = NULL; if (rdev->flags & RADEON_IS_IGP) { - i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); - tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); - tmds->dvo_chip = DVO_SIL164; - tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ + offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE); + if (offset) { + ver = RBIOS8(offset); + DRM_INFO("GPIO Table revision: %d\n", ver); + blocks = RBIOS8(offset + 2); + for (i = 0; i < blocks; i++) { + id = RBIOS8(offset + 3 + (i * 5) + 0); + if (id == 136) { + clk = RBIOS8(offset + 3 + (i * 5) + 3); + data = RBIOS8(offset + 3 + (i * 5) + 4); + i2c_bus.valid = true; + i2c_bus.mask_clk_mask = (1 << clk); + i2c_bus.mask_data_mask = (1 << data); + i2c_bus.a_clk_mask = (1 << clk); + i2c_bus.a_data_mask = (1 << data); + i2c_bus.en_clk_mask = (1 << clk); + i2c_bus.en_data_mask = (1 << data); + i2c_bus.y_clk_mask = (1 << clk); + i2c_bus.y_data_mask = (1 << data); + i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK; + i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK; + i2c_bus.a_clk_reg = RADEON_GPIOPAD_A; + i2c_bus.a_data_reg = RADEON_GPIOPAD_A; + i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN; + i2c_bus.en_data_reg = RADEON_GPIOPAD_EN; + i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y; + i2c_bus.y_data_reg = RADEON_GPIOPAD_Y; + tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); + tmds->dvo_chip = DVO_SIL164; + tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */ + break; + } + } + } } else { offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE); if (offset) { @@ -1412,15 +1318,37 @@ bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder tmds->slave_addr = RBIOS8(offset + 4 + 2); tmds->slave_addr >>= 1; /* 7 bit addressing */ gpio = RBIOS8(offset + 4 + 3); - if (gpio == DDC_LCD) { - /* MM i2c */ + switch (gpio) { + case DDC_MONID: + i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); + tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); + break; + case DDC_DVI: + i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); + tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); + break; + case DDC_VGA: + i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); + tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); + break; + case DDC_CRT2: + /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ + if (rdev->family >= CHIP_R300) + i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); + else + i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); + tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); + break; + case DDC_LCD: /* MM i2c */ i2c_bus.valid = true; i2c_bus.hw_capable = true; i2c_bus.mm_i2c = true; - i2c_bus.i2c_id = 0xa0; - } else - i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0); - tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus); + tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO"); + break; + default: + DRM_ERROR("Unsupported gpio %d\n", gpio); + break; + } } } @@ -1502,7 +1430,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) /* these are the most common settings */ if (rdev->flags & RADEON_SINGLE_CRTC) { /* VGA - primary dac */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1517,7 +1445,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) &hpd); } else if (rdev->flags & RADEON_IS_MOBILITY) { /* LVDS */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, 0); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1532,7 +1460,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) &hpd); /* VGA - primary dac */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1547,7 +1475,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) &hpd); } else { /* DVI-I - tv dac, int tmds */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); hpd.hpd = RADEON_HPD_1; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1568,7 +1496,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) &hpd); /* VGA - primary dac */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1604,7 +1532,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) DRM_INFO("Connector Table: %d (ibook)\n", rdev->mode_info.connector_table); /* LVDS */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1616,7 +1544,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) CONNECTOR_OBJECT_ID_LVDS, &hpd); /* VGA - TV DAC */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1645,7 +1573,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) DRM_INFO("Connector Table: %d (powerbook external tmds)\n", rdev->mode_info.connector_table); /* LVDS */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1657,7 +1585,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) CONNECTOR_OBJECT_ID_LVDS, &hpd); /* DVI-I - primary dac, ext tmds */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); hpd.hpd = RADEON_HPD_2; /* ??? */ radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1694,7 +1622,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) DRM_INFO("Connector Table: %d (powerbook internal tmds)\n", rdev->mode_info.connector_table); /* LVDS */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1706,7 +1634,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) CONNECTOR_OBJECT_ID_LVDS, &hpd); /* DVI-I - primary dac, int tmds */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); hpd.hpd = RADEON_HPD_1; /* ??? */ radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1742,7 +1670,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) DRM_INFO("Connector Table: %d (powerbook vga)\n", rdev->mode_info.connector_table); /* LVDS */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1754,7 +1682,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) CONNECTOR_OBJECT_ID_LVDS, &hpd); /* VGA - primary dac */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1783,7 +1711,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) DRM_INFO("Connector Table: %d (mini external tmds)\n", rdev->mode_info.connector_table); /* DVI-I - tv dac, ext tmds */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); hpd.hpd = RADEON_HPD_2; /* ??? */ radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1820,7 +1748,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) DRM_INFO("Connector Table: %d (mini internal tmds)\n", rdev->mode_info.connector_table); /* DVI-I - tv dac, int tmds */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); hpd.hpd = RADEON_HPD_1; /* ??? */ radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1856,7 +1784,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) DRM_INFO("Connector Table: %d (imac g5 isight)\n", rdev->mode_info.connector_table); /* DVI-D - int tmds */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); hpd.hpd = RADEON_HPD_1; /* ??? */ radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1868,7 +1796,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D, &hpd); /* VGA - tv dac */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1897,7 +1825,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) DRM_INFO("Connector Table: %d (emac)\n", rdev->mode_info.connector_table); /* VGA - primary dac */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1909,7 +1837,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) CONNECTOR_OBJECT_ID_VGA, &hpd); /* VGA - tv dac */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1938,7 +1866,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) DRM_INFO("Connector Table: %d (rn50-power)\n", rdev->mode_info.connector_table); /* VGA - primary dac */ - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1949,7 +1877,7 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) DRM_MODE_CONNECTOR_VGA, &ddc_i2c, CONNECTOR_OBJECT_ID_VGA, &hpd); - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_encoder(dev, radeon_get_encoder_id(dev, @@ -1979,6 +1907,31 @@ static bool radeon_apply_legacy_quirks(struct drm_device *dev, struct radeon_i2c_bus_rec *ddc_i2c, struct radeon_hpd *hpd) { + struct radeon_device *rdev = dev->dev_private; + + /* XPRESS DDC quirks */ + if ((rdev->family == CHIP_RS400 || + rdev->family == CHIP_RS480) && + ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) + *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); + else if ((rdev->family == CHIP_RS400 || + rdev->family == CHIP_RS480) && + ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) { + *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK); + ddc_i2c->mask_clk_mask = (0x20 << 8); + ddc_i2c->mask_data_mask = 0x80; + ddc_i2c->a_clk_mask = (0x20 << 8); + ddc_i2c->a_data_mask = 0x80; + ddc_i2c->en_clk_mask = (0x20 << 8); + ddc_i2c->en_data_mask = 0x80; + ddc_i2c->y_clk_mask = (0x20 << 8); + ddc_i2c->y_data_mask = 0x80; + } + + /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */ + if ((rdev->family >= CHIP_R300) && + ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC) + *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); /* Certain IBM chipset RN50s have a BIOS reporting two VGAs, one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */ @@ -2082,7 +2035,27 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) connector = (tmp >> 12) & 0xf; ddc_type = (tmp >> 8) & 0xf; - ddc_i2c = combios_setup_i2c_bus(rdev, ddc_type, 0, 0); + switch (ddc_type) { + case DDC_MONID: + ddc_i2c = + combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID); + break; + case DDC_DVI: + ddc_i2c = + combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); + break; + case DDC_VGA: + ddc_i2c = + combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); + break; + case DDC_CRT2: + ddc_i2c = + combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC); + break; + default: + ddc_i2c.valid = false; + break; + } switch (connector) { case CONNECTOR_PROPRIETARY_LEGACY: @@ -2252,7 +2225,7 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) 0), ATOM_DEVICE_DFP1_SUPPORT); - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC); hpd.hpd = RADEON_HPD_1; radeon_add_legacy_connector(dev, 0, @@ -2272,7 +2245,7 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) ATOM_DEVICE_CRT1_SUPPORT, 1), ATOM_DEVICE_CRT1_SUPPORT); - ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0); + ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC); hpd.hpd = RADEON_HPD_NONE; radeon_add_legacy_connector(dev, 0, @@ -2305,25 +2278,70 @@ bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev) if (lcd_ddc_info) { ddc_type = RBIOS8(lcd_ddc_info + 2); switch (ddc_type) { + case DDC_MONID: + ddc_i2c = + combios_setup_i2c_bus + (rdev, RADEON_GPIO_MONID); + break; + case DDC_DVI: + ddc_i2c = + combios_setup_i2c_bus + (rdev, RADEON_GPIO_DVI_DDC); + break; + case DDC_VGA: + ddc_i2c = + combios_setup_i2c_bus + (rdev, RADEON_GPIO_VGA_DDC); + break; + case DDC_CRT2: + ddc_i2c = + combios_setup_i2c_bus + (rdev, RADEON_GPIO_CRT2_DDC); + break; case DDC_LCD: ddc_i2c = - combios_setup_i2c_bus(rdev, - DDC_LCD, - RBIOS32(lcd_ddc_info + 3), - RBIOS32(lcd_ddc_info + 7)); - radeon_i2c_add(rdev, &ddc_i2c, "LCD"); + combios_setup_i2c_bus + (rdev, RADEON_GPIOPAD_MASK); + ddc_i2c.mask_clk_mask = + RBIOS32(lcd_ddc_info + 3); + ddc_i2c.mask_data_mask = + RBIOS32(lcd_ddc_info + 7); + ddc_i2c.a_clk_mask = + RBIOS32(lcd_ddc_info + 3); + ddc_i2c.a_data_mask = + RBIOS32(lcd_ddc_info + 7); + ddc_i2c.en_clk_mask = + RBIOS32(lcd_ddc_info + 3); + ddc_i2c.en_data_mask = + RBIOS32(lcd_ddc_info + 7); + ddc_i2c.y_clk_mask = + RBIOS32(lcd_ddc_info + 3); + ddc_i2c.y_data_mask = + RBIOS32(lcd_ddc_info + 7); break; case DDC_GPIO: ddc_i2c = - combios_setup_i2c_bus(rdev, - DDC_GPIO, - RBIOS32(lcd_ddc_info + 3), - RBIOS32(lcd_ddc_info + 7)); - radeon_i2c_add(rdev, &ddc_i2c, "LCD"); + combios_setup_i2c_bus + (rdev, RADEON_MDGPIO_MASK); + ddc_i2c.mask_clk_mask = + RBIOS32(lcd_ddc_info + 3); + ddc_i2c.mask_data_mask = + RBIOS32(lcd_ddc_info + 7); + ddc_i2c.a_clk_mask = + RBIOS32(lcd_ddc_info + 3); + ddc_i2c.a_data_mask = + RBIOS32(lcd_ddc_info + 7); + ddc_i2c.en_clk_mask = + RBIOS32(lcd_ddc_info + 3); + ddc_i2c.en_data_mask = + RBIOS32(lcd_ddc_info + 7); + ddc_i2c.y_clk_mask = + RBIOS32(lcd_ddc_info + 3); + ddc_i2c.y_data_mask = + RBIOS32(lcd_ddc_info + 7); break; default: - ddc_i2c = - combios_setup_i2c_bus(rdev, ddc_type, 0, 0); + ddc_i2c.valid = false; break; } DRM_DEBUG_KMS("LCD DDC Info Table found!\n"); diff --git a/trunk/drivers/gpu/drm/radeon/radeon_connectors.c b/trunk/drivers/gpu/drm/radeon/radeon_connectors.c index 47c4b276d30c..2395c8600cf4 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_connectors.c @@ -518,6 +518,8 @@ static void radeon_connector_destroy(struct drm_connector *connector) { struct radeon_connector *radeon_connector = to_radeon_connector(connector); + if (radeon_connector->ddc_bus) + radeon_i2c_destroy(radeon_connector->ddc_bus); if (radeon_connector->edid) kfree(radeon_connector->edid); kfree(radeon_connector->con_priv); @@ -953,6 +955,8 @@ static void radeon_dp_connector_destroy(struct drm_connector *connector) struct radeon_connector *radeon_connector = to_radeon_connector(connector); struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; + if (radeon_connector->ddc_bus) + radeon_i2c_destroy(radeon_connector->ddc_bus); if (radeon_connector->edid) kfree(radeon_connector->edid); if (radeon_dig_connector->dp_i2c_bus) @@ -1040,8 +1044,7 @@ radeon_add_atom_connector(struct drm_device *dev, bool linkb, uint32_t igp_lane_info, uint16_t connector_object_id, - struct radeon_hpd *hpd, - struct radeon_router *router) + struct radeon_hpd *hpd) { struct radeon_device *rdev = dev->dev_private; struct drm_connector *connector; @@ -1066,11 +1069,6 @@ radeon_add_atom_connector(struct drm_device *dev, radeon_connector->shared_ddc = true; shared_ddc = true; } - if (radeon_connector->router_bus && router->valid && - (radeon_connector->router.router_id == router->router_id)) { - radeon_connector->shared_ddc = false; - shared_ddc = false; - } } } @@ -1085,18 +1083,12 @@ radeon_add_atom_connector(struct drm_device *dev, radeon_connector->shared_ddc = shared_ddc; radeon_connector->connector_object_id = connector_object_id; radeon_connector->hpd = *hpd; - radeon_connector->router = *router; - if (router->valid) { - radeon_connector->router_bus = radeon_i2c_lookup(rdev, &router->i2c_info); - if (!radeon_connector->router_bus) - goto failed; - } switch (connector_type) { case DRM_MODE_CONNECTOR_VGA: drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); if (i2c_bus->valid) { - radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "VGA"); if (!radeon_connector->ddc_bus) goto failed; } @@ -1112,7 +1104,7 @@ radeon_add_atom_connector(struct drm_device *dev, drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); if (i2c_bus->valid) { - radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); if (!radeon_connector->ddc_bus) goto failed; } @@ -1134,7 +1126,7 @@ radeon_add_atom_connector(struct drm_device *dev, drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); if (i2c_bus->valid) { - radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); if (!radeon_connector->ddc_bus) goto failed; } @@ -1164,7 +1156,7 @@ radeon_add_atom_connector(struct drm_device *dev, drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); if (i2c_bus->valid) { - radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "HDMI"); if (!radeon_connector->ddc_bus) goto failed; } @@ -1195,7 +1187,10 @@ radeon_add_atom_connector(struct drm_device *dev, radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); if (!radeon_dig_connector->dp_i2c_bus) goto failed; - radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); + if (connector_type == DRM_MODE_CONNECTOR_eDP) + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "eDP"); + else + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DP"); if (!radeon_connector->ddc_bus) goto failed; } @@ -1235,7 +1230,7 @@ radeon_add_atom_connector(struct drm_device *dev, drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); if (i2c_bus->valid) { - radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "LVDS"); if (!radeon_connector->ddc_bus) goto failed; } @@ -1257,6 +1252,8 @@ radeon_add_atom_connector(struct drm_device *dev, return; failed: + if (radeon_connector->ddc_bus) + radeon_i2c_destroy(radeon_connector->ddc_bus); drm_connector_cleanup(connector); kfree(connector); } @@ -1303,7 +1300,7 @@ radeon_add_legacy_connector(struct drm_device *dev, drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); if (i2c_bus->valid) { - radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "VGA"); if (!radeon_connector->ddc_bus) goto failed; } @@ -1319,7 +1316,7 @@ radeon_add_legacy_connector(struct drm_device *dev, drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); if (i2c_bus->valid) { - radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); if (!radeon_connector->ddc_bus) goto failed; } @@ -1335,7 +1332,7 @@ radeon_add_legacy_connector(struct drm_device *dev, drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); if (i2c_bus->valid) { - radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); if (!radeon_connector->ddc_bus) goto failed; } @@ -1375,7 +1372,7 @@ radeon_add_legacy_connector(struct drm_device *dev, drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); if (i2c_bus->valid) { - radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); + radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "LVDS"); if (!radeon_connector->ddc_bus) goto failed; } @@ -1396,6 +1393,8 @@ radeon_add_legacy_connector(struct drm_device *dev, return; failed: + if (radeon_connector->ddc_bus) + radeon_i2c_destroy(radeon_connector->ddc_bus); drm_connector_cleanup(connector); kfree(connector); } diff --git a/trunk/drivers/gpu/drm/radeon/radeon_cs.c b/trunk/drivers/gpu/drm/radeon/radeon_cs.c index fcc79b5d22d1..ae0fb7356e62 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_cs.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_cs.c @@ -72,7 +72,7 @@ int radeon_cs_parser_relocs(struct radeon_cs_parser *p) if (p->relocs[i].gobj == NULL) { DRM_ERROR("gem object lookup failed 0x%x\n", r->handle); - return -ENOENT; + return -EINVAL; } p->relocs_ptr[i] = &p->relocs[i]; p->relocs[i].robj = p->relocs[i].gobj->driver_private; diff --git a/trunk/drivers/gpu/drm/radeon/radeon_cursor.c b/trunk/drivers/gpu/drm/radeon/radeon_cursor.c index 5731fc9b1ae3..4eb67c0e0996 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_cursor.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_cursor.c @@ -170,7 +170,7 @@ int radeon_crtc_cursor_set(struct drm_crtc *crtc, obj = drm_gem_object_lookup(crtc->dev, file_priv, handle); if (!obj) { DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, radeon_crtc->crtc_id); - return -ENOENT; + return -EINVAL; } ret = radeon_gem_object_pin(obj, RADEON_GEM_DOMAIN_VRAM, &gpu_addr); diff --git a/trunk/drivers/gpu/drm/radeon/radeon_device.c b/trunk/drivers/gpu/drm/radeon/radeon_device.c index 4f7a170d1566..a64811a94519 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_device.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_device.c @@ -347,8 +347,7 @@ int radeon_dummy_page_init(struct radeon_device *rdev) return -ENOMEM; rdev->dummy_page.addr = pci_map_page(rdev->pdev, rdev->dummy_page.page, 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); - if (pci_dma_mapping_error(rdev->pdev, rdev->dummy_page.addr)) { - dev_err(&rdev->pdev->dev, "Failed to DMA MAP the dummy page\n"); + if (!rdev->dummy_page.addr) { __free_page(rdev->dummy_page.page); rdev->dummy_page.page = NULL; return -ENOMEM; diff --git a/trunk/drivers/gpu/drm/radeon/radeon_display.c b/trunk/drivers/gpu/drm/radeon/radeon_display.c index 5764f4d3b4f1..74dac9635d70 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_display.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_display.c @@ -161,13 +161,17 @@ void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, } static void radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, - u16 *blue, uint32_t start, uint32_t size) + u16 *blue, uint32_t size) { struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); - int end = (start + size > 256) ? 256 : start + size, i; + int i; + + if (size != 256) { + return; + } /* userspace palettes are always correct as is */ - for (i = start; i < end; i++) { + for (i = 0; i < 256; i++) { radeon_crtc->lut_r[i] = red[i] >> 6; radeon_crtc->lut_g[i] = green[i] >> 6; radeon_crtc->lut_b[i] = blue[i] >> 6; @@ -315,10 +319,6 @@ static void radeon_print_display_setup(struct drm_device *dev) radeon_connector->ddc_bus->rec.en_data_reg, radeon_connector->ddc_bus->rec.y_clk_reg, radeon_connector->ddc_bus->rec.y_data_reg); - if (radeon_connector->router_bus) - DRM_INFO(" DDC Router 0x%x/0x%x\n", - radeon_connector->router.mux_control_pin, - radeon_connector->router.mux_state); } else { if (connector->connector_type == DRM_MODE_CONNECTOR_VGA || connector->connector_type == DRM_MODE_CONNECTOR_DVII || @@ -395,10 +395,6 @@ int radeon_ddc_get_modes(struct radeon_connector *radeon_connector) struct radeon_device *rdev = dev->dev_private; int ret = 0; - /* on hw with routers, select right port */ - if (radeon_connector->router.valid) - radeon_router_select_port(radeon_connector); - if ((radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort) || (radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)) { struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; @@ -429,10 +425,6 @@ static int radeon_ddc_dump(struct drm_connector *connector) struct radeon_connector *radeon_connector = to_radeon_connector(connector); int ret = 0; - /* on hw with routers, select right port */ - if (radeon_connector->router.valid) - radeon_router_select_port(radeon_connector); - if (!radeon_connector->ddc_bus) return -1; edid = drm_get_edid(connector, &radeon_connector->ddc_bus->adapter); @@ -884,12 +876,13 @@ radeon_user_framebuffer_create(struct drm_device *dev, if (obj == NULL) { dev_err(&dev->pdev->dev, "No GEM object associated to handle 0x%08X, " "can't create framebuffer\n", mode_cmd->handle); - return ERR_PTR(-ENOENT); + return NULL; } radeon_fb = kzalloc(sizeof(*radeon_fb), GFP_KERNEL); - if (radeon_fb == NULL) - return ERR_PTR(-ENOMEM); + if (radeon_fb == NULL) { + return NULL; + } radeon_framebuffer_init(dev, radeon_fb, mode_cmd, obj); @@ -1047,9 +1040,6 @@ int radeon_modeset_init(struct radeon_device *rdev) return ret; } - /* init i2c buses */ - radeon_i2c_init(rdev); - /* check combios for a valid hardcoded EDID - Sun servers */ if (!rdev->is_atom_bios) { /* check for hardcoded EDID in BIOS */ @@ -1090,8 +1080,6 @@ void radeon_modeset_fini(struct radeon_device *rdev) drm_mode_config_cleanup(rdev->ddev); rdev->mode_info.mode_config_initialized = false; } - /* free i2c buses */ - radeon_i2c_fini(rdev); } bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc, diff --git a/trunk/drivers/gpu/drm/radeon/radeon_gem.c b/trunk/drivers/gpu/drm/radeon/radeon_gem.c index c578f265b24c..a72a3ee5d69b 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_gem.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_gem.c @@ -226,7 +226,7 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data, /* just do a BO wait for now */ gobj = drm_gem_object_lookup(dev, filp, args->handle); if (gobj == NULL) { - return -ENOENT; + return -EINVAL; } robj = gobj->driver_private; @@ -245,7 +245,7 @@ int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data, gobj = drm_gem_object_lookup(dev, filp, args->handle); if (gobj == NULL) { - return -ENOENT; + return -EINVAL; } robj = gobj->driver_private; args->addr_ptr = radeon_bo_mmap_offset(robj); @@ -264,7 +264,7 @@ int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, gobj = drm_gem_object_lookup(dev, filp, args->handle); if (gobj == NULL) { - return -ENOENT; + return -EINVAL; } robj = gobj->driver_private; r = radeon_bo_wait(robj, &cur_placement, true); @@ -294,7 +294,7 @@ int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data, gobj = drm_gem_object_lookup(dev, filp, args->handle); if (gobj == NULL) { - return -ENOENT; + return -EINVAL; } robj = gobj->driver_private; r = radeon_bo_wait(robj, NULL, false); @@ -316,7 +316,7 @@ int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data, DRM_DEBUG("%d \n", args->handle); gobj = drm_gem_object_lookup(dev, filp, args->handle); if (gobj == NULL) - return -ENOENT; + return -EINVAL; robj = gobj->driver_private; r = radeon_bo_set_tiling_flags(robj, args->tiling_flags, args->pitch); drm_gem_object_unreference_unlocked(gobj); @@ -334,7 +334,7 @@ int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data, DRM_DEBUG("\n"); gobj = drm_gem_object_lookup(dev, filp, args->handle); if (gobj == NULL) - return -ENOENT; + return -EINVAL; rbo = gobj->driver_private; r = radeon_bo_reserve(rbo, false); if (unlikely(r != 0)) diff --git a/trunk/drivers/gpu/drm/radeon/radeon_i2c.c b/trunk/drivers/gpu/drm/radeon/radeon_i2c.c index bfd2ce5f5372..5def6f5dff38 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_i2c.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_i2c.c @@ -52,10 +52,6 @@ bool radeon_ddc_probe(struct radeon_connector *radeon_connector) } }; - /* on hw with routers, select right port */ - if (radeon_connector->router.valid) - radeon_router_select_port(radeon_connector); - ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2); if (ret == 2) return true; @@ -964,59 +960,6 @@ void radeon_i2c_destroy(struct radeon_i2c_chan *i2c) kfree(i2c); } -/* Add the default buses */ -void radeon_i2c_init(struct radeon_device *rdev) -{ - if (rdev->is_atom_bios) - radeon_atombios_i2c_init(rdev); - else - radeon_combios_i2c_init(rdev); -} - -/* remove all the buses */ -void radeon_i2c_fini(struct radeon_device *rdev) -{ - int i; - - for (i = 0; i < RADEON_MAX_I2C_BUS; i++) { - if (rdev->i2c_bus[i]) { - radeon_i2c_destroy(rdev->i2c_bus[i]); - rdev->i2c_bus[i] = NULL; - } - } -} - -/* Add additional buses */ -void radeon_i2c_add(struct radeon_device *rdev, - struct radeon_i2c_bus_rec *rec, - const char *name) -{ - struct drm_device *dev = rdev->ddev; - int i; - - for (i = 0; i < RADEON_MAX_I2C_BUS; i++) { - if (!rdev->i2c_bus[i]) { - rdev->i2c_bus[i] = radeon_i2c_create(dev, rec, name); - return; - } - } -} - -/* looks up bus based on id */ -struct radeon_i2c_chan *radeon_i2c_lookup(struct radeon_device *rdev, - struct radeon_i2c_bus_rec *i2c_bus) -{ - int i; - - for (i = 0; i < RADEON_MAX_I2C_BUS; i++) { - if (rdev->i2c_bus[i] && - (rdev->i2c_bus[i]->rec.i2c_id == i2c_bus->i2c_id)) { - return rdev->i2c_bus[i]; - } - } - return NULL; -} - struct drm_encoder *radeon_best_encoder(struct drm_connector *connector) { return NULL; @@ -1077,28 +1020,3 @@ void radeon_i2c_put_byte(struct radeon_i2c_chan *i2c_bus, addr, val); } -/* router switching */ -void radeon_router_select_port(struct radeon_connector *radeon_connector) -{ - u8 val; - - if (!radeon_connector->router.valid) - return; - - radeon_i2c_get_byte(radeon_connector->router_bus, - radeon_connector->router.i2c_addr, - 0x3, &val); - val &= radeon_connector->router.mux_control_pin; - radeon_i2c_put_byte(radeon_connector->router_bus, - radeon_connector->router.i2c_addr, - 0x3, val); - radeon_i2c_get_byte(radeon_connector->router_bus, - radeon_connector->router.i2c_addr, - 0x1, &val); - val &= radeon_connector->router.mux_control_pin; - val |= radeon_connector->router.mux_state; - radeon_i2c_put_byte(radeon_connector->router_bus, - radeon_connector->router.i2c_addr, - 0x1, val); -} - diff --git a/trunk/drivers/gpu/drm/radeon/radeon_kms.c b/trunk/drivers/gpu/drm/radeon/radeon_kms.c index b1c8ace5f080..ddcd3b13f151 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_kms.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_kms.c @@ -112,9 +112,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) info = data; value_ptr = (uint32_t *)((unsigned long)info->value); - if (DRM_COPY_FROM_USER(&value, value_ptr, sizeof(value))) - return -EFAULT; - + value = *value_ptr; switch (info->request) { case RADEON_INFO_DEVICE_ID: value = dev->pci_device; @@ -162,27 +160,13 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) return -EINVAL; } case RADEON_INFO_WANT_HYPERZ: - /* The "value" here is both an input and output parameter. - * If the input value is 1, filp requests hyper-z access. - * If the input value is 0, filp revokes its hyper-z access. - * - * When returning, the value is 1 if filp owns hyper-z access, - * 0 otherwise. */ - if (value >= 2) { - DRM_DEBUG_KMS("WANT_HYPERZ: invalid value %d\n", value); - return -EINVAL; - } mutex_lock(&dev->struct_mutex); - if (value == 1) { - /* wants hyper-z */ - if (!rdev->hyperz_filp) - rdev->hyperz_filp = filp; - } else if (value == 0) { - /* revokes hyper-z */ - if (rdev->hyperz_filp == filp) - rdev->hyperz_filp = NULL; + if (rdev->hyperz_filp) + value = 0; + else { + rdev->hyperz_filp = filp; + value = 1; } - value = rdev->hyperz_filp == filp ? 1 : 0; mutex_unlock(&dev->struct_mutex); break; default: diff --git a/trunk/drivers/gpu/drm/radeon/radeon_mode.h b/trunk/drivers/gpu/drm/radeon/radeon_mode.h index 5bbc086b9267..71aea4037e90 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_mode.h +++ b/trunk/drivers/gpu/drm/radeon/radeon_mode.h @@ -82,8 +82,6 @@ enum radeon_hpd_id { RADEON_HPD_NONE = 0xff, }; -#define RADEON_MAX_I2C_BUS 16 - /* radeon gpio-based i2c * 1. "mask" reg and bits * grabs the gpio pins for software use @@ -400,16 +398,6 @@ struct radeon_hpd { struct radeon_gpio_rec gpio; }; -struct radeon_router { - bool valid; - u32 router_id; - struct radeon_i2c_bus_rec i2c_info; - u8 i2c_addr; - u8 mux_type; - u8 mux_control_pin; - u8 mux_state; -}; - struct radeon_connector { struct drm_connector base; uint32_t connector_id; @@ -425,8 +413,6 @@ struct radeon_connector { bool dac_load_detect; uint16_t connector_object_id; struct radeon_hpd hpd; - struct radeon_router router; - struct radeon_i2c_chan *router_bus; }; struct radeon_framebuffer { @@ -459,15 +445,6 @@ extern void atombios_dig_transmitter_setup(struct drm_encoder *encoder, extern int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, uint8_t write_byte, uint8_t *read_byte); -extern void radeon_i2c_init(struct radeon_device *rdev); -extern void radeon_i2c_fini(struct radeon_device *rdev); -extern void radeon_combios_i2c_init(struct radeon_device *rdev); -extern void radeon_atombios_i2c_init(struct radeon_device *rdev); -extern void radeon_i2c_add(struct radeon_device *rdev, - struct radeon_i2c_bus_rec *rec, - const char *name); -extern struct radeon_i2c_chan *radeon_i2c_lookup(struct radeon_device *rdev, - struct radeon_i2c_bus_rec *i2c_bus); extern struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev, struct radeon_i2c_bus_rec *rec, const char *name); @@ -483,7 +460,6 @@ extern void radeon_i2c_put_byte(struct radeon_i2c_chan *i2c, u8 slave_addr, u8 addr, u8 val); -extern void radeon_router_select_port(struct radeon_connector *radeon_connector); extern bool radeon_ddc_probe(struct radeon_connector *radeon_connector); extern int radeon_ddc_get_modes(struct radeon_connector *radeon_connector); diff --git a/trunk/drivers/gpu/drm/radeon/radeon_pm.c b/trunk/drivers/gpu/drm/radeon/radeon_pm.c index 58038f5cab38..95f8b3a3c43d 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_pm.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_pm.c @@ -472,9 +472,9 @@ static const struct attribute_group hwmon_attrgroup = { .attrs = hwmon_attributes, }; -static int radeon_hwmon_init(struct radeon_device *rdev) +static void radeon_hwmon_init(struct radeon_device *rdev) { - int err = 0; + int err; rdev->pm.int_hwmon_dev = NULL; @@ -483,26 +483,15 @@ static int radeon_hwmon_init(struct radeon_device *rdev) case THERMAL_TYPE_RV770: case THERMAL_TYPE_EVERGREEN: rdev->pm.int_hwmon_dev = hwmon_device_register(rdev->dev); - if (IS_ERR(rdev->pm.int_hwmon_dev)) { - err = PTR_ERR(rdev->pm.int_hwmon_dev); - dev_err(rdev->dev, - "Unable to register hwmon device: %d\n", err); - break; - } dev_set_drvdata(rdev->pm.int_hwmon_dev, rdev->ddev); err = sysfs_create_group(&rdev->pm.int_hwmon_dev->kobj, &hwmon_attrgroup); - if (err) { - dev_err(rdev->dev, - "Unable to create hwmon sysfs file: %d\n", err); - hwmon_device_unregister(rdev->dev); - } + if (err) + DRM_ERROR("Unable to create hwmon sysfs file: %d\n", err); break; default: break; } - - return err; } static void radeon_hwmon_fini(struct radeon_device *rdev) @@ -551,7 +540,6 @@ void radeon_pm_resume(struct radeon_device *rdev) int radeon_pm_init(struct radeon_device *rdev) { int ret; - /* default to profile method */ rdev->pm.pm_method = PM_METHOD_PROFILE; rdev->pm.profile = PM_PROFILE_DEFAULT; @@ -573,9 +561,7 @@ int radeon_pm_init(struct radeon_device *rdev) } /* set up the internal thermal sensor if applicable */ - ret = radeon_hwmon_init(rdev); - if (ret) - return ret; + radeon_hwmon_init(rdev); if (rdev->pm.num_power_states > 1) { /* where's the best place to put these? */ ret = device_create_file(rdev->dev, &dev_attr_power_profile); diff --git a/trunk/drivers/gpu/drm/radeon/reg_srcs/rv515 b/trunk/drivers/gpu/drm/radeon/reg_srcs/rv515 index b3f9f1d92005..8293855f5f0d 100644 --- a/trunk/drivers/gpu/drm/radeon/reg_srcs/rv515 +++ b/trunk/drivers/gpu/drm/radeon/reg_srcs/rv515 @@ -316,7 +316,6 @@ rv515 0x6d40 0x4BD0 FG_FOG_COLOR_B 0x4BD4 FG_ALPHA_FUNC 0x4BD8 FG_DEPTH_SRC -0x4BE0 FG_ALPHA_VALUE 0x4C00 US_ALU_CONST_R_0 0x4C04 US_ALU_CONST_G_0 0x4C08 US_ALU_CONST_B_0 diff --git a/trunk/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/trunk/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 64d7f47df868..437ac786277a 100644 --- a/trunk/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/trunk/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -737,7 +737,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, if (ret) { DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret); - return ERR_PTR(ret); + return NULL; } return &vfb->base; @@ -747,7 +747,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, ret = vmw_user_dmabuf_lookup(tfile, mode_cmd->handle, &bo); if (ret) { DRM_ERROR("failed to find buffer: %i\n", ret); - return ERR_PTR(-ENOENT); + return NULL; } ret = vmw_kms_new_framebuffer_dmabuf(dev_priv, bo, &vfb, @@ -758,7 +758,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, if (ret) { DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret); - return ERR_PTR(ret); + return NULL; } return &vfb->base; @@ -768,7 +768,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, /* vmw_user_surface_lookup takes one ref */ vmw_surface_unreference(&surface); - return ERR_PTR(-EINVAL); + return NULL; } static struct drm_mode_config_funcs vmw_kms_funcs = { diff --git a/trunk/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/trunk/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c index 2ff5cf78235f..cfaf690a5b2f 100644 --- a/trunk/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +++ b/trunk/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c @@ -79,7 +79,7 @@ static void vmw_ldu_crtc_restore(struct drm_crtc *crtc) static void vmw_ldu_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, - uint32_t start, uint32_t size) + uint32_t size) { } diff --git a/trunk/drivers/hwmon/ams/ams.h b/trunk/drivers/hwmon/ams/ams.h index 90f094d45450..b28d7e27a031 100644 --- a/trunk/drivers/hwmon/ams/ams.h +++ b/trunk/drivers/hwmon/ams/ams.h @@ -23,7 +23,7 @@ struct ams { /* General properties */ struct device_node *of_node; - struct platform_device *of_dev; + struct of_device *of_dev; char has_device; char vflag; u32 orient1; diff --git a/trunk/drivers/hwmon/mc13783-adc.c b/trunk/drivers/hwmon/mc13783-adc.c index d5226c9e1201..ce3c7bc81814 100644 --- a/trunk/drivers/hwmon/mc13783-adc.c +++ b/trunk/drivers/hwmon/mc13783-adc.c @@ -18,7 +18,7 @@ * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include #include #include #include @@ -144,14 +144,6 @@ static const struct attribute_group mc13783_group_ts = { .attrs = mc13783_attr_ts, }; -static int mc13783_adc_use_touchscreen(struct platform_device *pdev) -{ - struct mc13783_adc_priv *priv = platform_get_drvdata(pdev); - unsigned flags = mc13783_get_flags(priv->mc13783); - - return flags & MC13783_USE_TOUCHSCREEN; -} - static int __init mc13783_adc_probe(struct platform_device *pdev) { struct mc13783_adc_priv *priv; @@ -170,11 +162,10 @@ static int __init mc13783_adc_probe(struct platform_device *pdev) if (ret) goto out_err_create1; - if (!mc13783_adc_use_touchscreen(pdev)) { + if (!(priv->mc13783->flags & MC13783_USE_TOUCHSCREEN)) ret = sysfs_create_group(&pdev->dev.kobj, &mc13783_group_ts); if (ret) goto out_err_create2; - } priv->hwmon_dev = hwmon_device_register(&pdev->dev); if (IS_ERR(priv->hwmon_dev)) { @@ -189,7 +180,7 @@ static int __init mc13783_adc_probe(struct platform_device *pdev) out_err_register: - if (!mc13783_adc_use_touchscreen(pdev)) + if (!(priv->mc13783->flags & MC13783_USE_TOUCHSCREEN)) sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_ts); out_err_create2: @@ -208,7 +199,7 @@ static int __devexit mc13783_adc_remove(struct platform_device *pdev) hwmon_device_unregister(priv->hwmon_dev); - if (!mc13783_adc_use_touchscreen(pdev)) + if (!(priv->mc13783->flags & MC13783_USE_TOUCHSCREEN)) sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_ts); sysfs_remove_group(&pdev->dev.kobj, &mc13783_group); diff --git a/trunk/drivers/hwmon/ultra45_env.c b/trunk/drivers/hwmon/ultra45_env.c index d863e13a50b8..89643261ccdb 100644 --- a/trunk/drivers/hwmon/ultra45_env.c +++ b/trunk/drivers/hwmon/ultra45_env.c @@ -234,7 +234,7 @@ static const struct attribute_group env_group = { .attrs = env_attributes, }; -static int __devinit env_probe(struct platform_device *op, +static int __devinit env_probe(struct of_device *op, const struct of_device_id *match) { struct env *p = kzalloc(sizeof(*p), GFP_KERNEL); @@ -276,7 +276,7 @@ static int __devinit env_probe(struct platform_device *op, goto out; } -static int __devexit env_remove(struct platform_device *op) +static int __devexit env_remove(struct of_device *op) { struct env *p = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/i2c/Kconfig b/trunk/drivers/i2c/Kconfig index 30f06e956bfb..d06083fdffbb 100644 --- a/trunk/drivers/i2c/Kconfig +++ b/trunk/drivers/i2c/Kconfig @@ -47,19 +47,6 @@ config I2C_CHARDEV This support is also available as a module. If so, the module will be called i2c-dev. -config I2C_MUX - tristate "I2C bus multiplexing support" - depends on EXPERIMENTAL - help - Say Y here if you want the I2C core to support the ability to - handle multiplexed I2C bus topologies, by presenting each - multiplexed segment as a I2C adapter. - - This support is also available as a module. If so, the module - will be called i2c-mux. - -source drivers/i2c/muxes/Kconfig - config I2C_HELPER_AUTO bool "Autoselect pertinent helper modules" default y diff --git a/trunk/drivers/i2c/Makefile b/trunk/drivers/i2c/Makefile index c00fd66388f5..a7d9b4be9bb3 100644 --- a/trunk/drivers/i2c/Makefile +++ b/trunk/drivers/i2c/Makefile @@ -6,8 +6,7 @@ obj-$(CONFIG_I2C_BOARDINFO) += i2c-boardinfo.o obj-$(CONFIG_I2C) += i2c-core.o obj-$(CONFIG_I2C_SMBUS) += i2c-smbus.o obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o -obj-$(CONFIG_I2C_MUX) += i2c-mux.o -obj-y += algos/ busses/ muxes/ +obj-y += algos/ busses/ ifeq ($(CONFIG_I2C_DEBUG_CORE),y) EXTRA_CFLAGS += -DDEBUG diff --git a/trunk/drivers/i2c/busses/i2c-cpm.c b/trunk/drivers/i2c/busses/i2c-cpm.c index f7bd2613cecc..e591de1bc704 100644 --- a/trunk/drivers/i2c/busses/i2c-cpm.c +++ b/trunk/drivers/i2c/busses/i2c-cpm.c @@ -105,7 +105,7 @@ struct i2c_reg { struct cpm_i2c { char *base; - struct platform_device *ofdev; + struct of_device *ofdev; struct i2c_adapter adap; uint dp_addr; int version; /* CPM1=1, CPM2=2 */ @@ -428,7 +428,7 @@ static const struct i2c_adapter cpm_ops = { static int __devinit cpm_i2c_setup(struct cpm_i2c *cpm) { - struct platform_device *ofdev = cpm->ofdev; + struct of_device *ofdev = cpm->ofdev; const u32 *data; int len, ret, i; void __iomem *i2c_base; @@ -634,7 +634,7 @@ static void cpm_i2c_shutdown(struct cpm_i2c *cpm) cpm_muram_free(cpm->i2c_addr); } -static int __devinit cpm_i2c_probe(struct platform_device *ofdev, +static int __devinit cpm_i2c_probe(struct of_device *ofdev, const struct of_device_id *match) { int result, len; @@ -687,7 +687,7 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev, return result; } -static int __devexit cpm_i2c_remove(struct platform_device *ofdev) +static int __devexit cpm_i2c_remove(struct of_device *ofdev) { struct cpm_i2c *cpm = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/i2c/busses/i2c-ibm_iic.c b/trunk/drivers/i2c/busses/i2c-ibm_iic.c index 43ca32fddde2..1168d61418c9 100644 --- a/trunk/drivers/i2c/busses/i2c-ibm_iic.c +++ b/trunk/drivers/i2c/busses/i2c-ibm_iic.c @@ -661,7 +661,7 @@ static inline u8 iic_clckdiv(unsigned int opb) return (u8)((opb + 9) / 10 - 1); } -static int __devinit iic_request_irq(struct platform_device *ofdev, +static int __devinit iic_request_irq(struct of_device *ofdev, struct ibm_iic_private *dev) { struct device_node *np = ofdev->dev.of_node; @@ -692,7 +692,7 @@ static int __devinit iic_request_irq(struct platform_device *ofdev, /* * Register single IIC interface */ -static int __devinit iic_probe(struct platform_device *ofdev, +static int __devinit iic_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -780,7 +780,7 @@ static int __devinit iic_probe(struct platform_device *ofdev, /* * Cleanup initialized IIC interface */ -static int __devexit iic_remove(struct platform_device *ofdev) +static int __devexit iic_remove(struct of_device *ofdev) { struct ibm_iic_private *dev = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/i2c/busses/i2c-mpc.c b/trunk/drivers/i2c/busses/i2c-mpc.c index a1c419a716af..6545d1c99b61 100644 --- a/trunk/drivers/i2c/busses/i2c-mpc.c +++ b/trunk/drivers/i2c/busses/i2c-mpc.c @@ -560,7 +560,7 @@ static struct i2c_adapter mpc_ops = { .timeout = HZ, }; -static int __devinit fsl_i2c_probe(struct platform_device *op, +static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match) { struct mpc_i2c *i2c; @@ -646,7 +646,7 @@ static int __devinit fsl_i2c_probe(struct platform_device *op, return result; }; -static int __devexit fsl_i2c_remove(struct platform_device *op) +static int __devexit fsl_i2c_remove(struct of_device *op) { struct mpc_i2c *i2c = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/i2c/i2c-core.c b/trunk/drivers/i2c/i2c-core.c index 6649176de940..df937df845eb 100644 --- a/trunk/drivers/i2c/i2c-core.c +++ b/trunk/drivers/i2c/i2c-core.c @@ -20,9 +20,7 @@ /* With some changes from Kyösti Mälkki . All SMBus-related things are written by Frodo Looijaard SMBus 2.0 support by Mark Studebaker and - Jean Delvare - Mux support by Rodolfo Giometti and - Michael Lawnick */ + Jean Delvare */ #include #include @@ -425,87 +423,11 @@ static int __i2c_check_addr_busy(struct device *dev, void *addrp) return 0; } -/* walk up mux tree */ -static int i2c_check_mux_parents(struct i2c_adapter *adapter, int addr) -{ - int result; - - result = device_for_each_child(&adapter->dev, &addr, - __i2c_check_addr_busy); - - if (!result && i2c_parent_is_i2c_adapter(adapter)) - result = i2c_check_mux_parents( - to_i2c_adapter(adapter->dev.parent), addr); - - return result; -} - -/* recurse down mux tree */ -static int i2c_check_mux_children(struct device *dev, void *addrp) -{ - int result; - - if (dev->type == &i2c_adapter_type) - result = device_for_each_child(dev, addrp, - i2c_check_mux_children); - else - result = __i2c_check_addr_busy(dev, addrp); - - return result; -} - static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr) { - int result = 0; - - if (i2c_parent_is_i2c_adapter(adapter)) - result = i2c_check_mux_parents( - to_i2c_adapter(adapter->dev.parent), addr); - - if (!result) - result = device_for_each_child(&adapter->dev, &addr, - i2c_check_mux_children); - - return result; -} - -/** - * i2c_lock_adapter - Get exclusive access to an I2C bus segment - * @adapter: Target I2C bus segment - */ -void i2c_lock_adapter(struct i2c_adapter *adapter) -{ - if (i2c_parent_is_i2c_adapter(adapter)) - i2c_lock_adapter(to_i2c_adapter(adapter->dev.parent)); - else - rt_mutex_lock(&adapter->bus_lock); -} -EXPORT_SYMBOL_GPL(i2c_lock_adapter); - -/** - * i2c_trylock_adapter - Try to get exclusive access to an I2C bus segment - * @adapter: Target I2C bus segment - */ -static int i2c_trylock_adapter(struct i2c_adapter *adapter) -{ - if (i2c_parent_is_i2c_adapter(adapter)) - return i2c_trylock_adapter(to_i2c_adapter(adapter->dev.parent)); - else - return rt_mutex_trylock(&adapter->bus_lock); -} - -/** - * i2c_unlock_adapter - Release exclusive access to an I2C bus segment - * @adapter: Target I2C bus segment - */ -void i2c_unlock_adapter(struct i2c_adapter *adapter) -{ - if (i2c_parent_is_i2c_adapter(adapter)) - i2c_unlock_adapter(to_i2c_adapter(adapter->dev.parent)); - else - rt_mutex_unlock(&adapter->bus_lock); + return device_for_each_child(&adapter->dev, &addr, + __i2c_check_addr_busy); } -EXPORT_SYMBOL_GPL(i2c_unlock_adapter); /** * i2c_new_device - instantiate an i2c device @@ -711,9 +633,9 @@ i2c_sysfs_new_device(struct device *dev, struct device_attribute *attr, return -EINVAL; /* Keep track of the added device */ - mutex_lock(&adap->userspace_clients_lock); + i2c_lock_adapter(adap); list_add_tail(&client->detected, &adap->userspace_clients); - mutex_unlock(&adap->userspace_clients_lock); + i2c_unlock_adapter(adap); dev_info(dev, "%s: Instantiated device %s at 0x%02hx\n", "new_device", info.type, info.addr); @@ -752,7 +674,7 @@ i2c_sysfs_delete_device(struct device *dev, struct device_attribute *attr, /* Make sure the device was added through sysfs */ res = -ENOENT; - mutex_lock(&adap->userspace_clients_lock); + i2c_lock_adapter(adap); list_for_each_entry_safe(client, next, &adap->userspace_clients, detected) { if (client->addr == addr) { @@ -765,7 +687,7 @@ i2c_sysfs_delete_device(struct device *dev, struct device_attribute *attr, break; } } - mutex_unlock(&adap->userspace_clients_lock); + i2c_unlock_adapter(adap); if (res < 0) dev_err(dev, "%s: Can't find device in list\n", @@ -792,11 +714,10 @@ static const struct attribute_group *i2c_adapter_attr_groups[] = { NULL }; -struct device_type i2c_adapter_type = { +static struct device_type i2c_adapter_type = { .groups = i2c_adapter_attr_groups, .release = i2c_adapter_dev_release, }; -EXPORT_SYMBOL_GPL(i2c_adapter_type); #ifdef CONFIG_I2C_COMPAT static struct class_compat *i2c_adapter_compat_class; @@ -839,7 +760,7 @@ static int __process_new_adapter(struct device_driver *d, void *data) static int i2c_register_adapter(struct i2c_adapter *adap) { - int res = 0; + int res = 0, dummy; /* Can't register until after driver model init */ if (unlikely(WARN_ON(!i2c_bus_type.p))) { @@ -848,7 +769,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap) } rt_mutex_init(&adap->bus_lock); - mutex_init(&adap->userspace_clients_lock); INIT_LIST_HEAD(&adap->userspace_clients); /* Set default timeout to 1 second if not already set */ @@ -881,7 +801,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap) /* Notify drivers */ mutex_lock(&core_lock); - bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter); + dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap, + __process_new_adapter); mutex_unlock(&core_lock); return 0; @@ -1054,7 +975,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) return res; /* Remove devices instantiated from sysfs */ - mutex_lock(&adap->userspace_clients_lock); + i2c_lock_adapter(adap); list_for_each_entry_safe(client, next, &adap->userspace_clients, detected) { dev_dbg(&adap->dev, "Removing %s at 0x%x\n", client->name, @@ -1062,7 +983,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) list_del(&client->detected); i2c_unregister_device(client); } - mutex_unlock(&adap->userspace_clients_lock); + i2c_unlock_adapter(adap); /* Detach any active clients. This can't fail, thus we do not checking the returned value. */ @@ -1317,12 +1238,12 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) #endif if (in_atomic() || irqs_disabled()) { - ret = i2c_trylock_adapter(adap); + ret = rt_mutex_trylock(&adap->bus_lock); if (!ret) /* I2C activity is ongoing. */ return -EAGAIN; } else { - i2c_lock_adapter(adap); + rt_mutex_lock(&adap->bus_lock); } /* Retry automatically on arbitration loss */ @@ -1334,7 +1255,7 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if (time_after(jiffies, orig_jiffies + adap->timeout)) break; } - i2c_unlock_adapter(adap); + rt_mutex_unlock(&adap->bus_lock); return ret; } else { @@ -1429,17 +1350,13 @@ static int i2c_default_probe(struct i2c_adapter *adap, unsigned short addr) I2C_SMBUS_BYTE_DATA, &dummy); else #endif - if (!((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50) - && i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) - err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_WRITE, 0, - I2C_SMBUS_QUICK, NULL); - else if (i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE)) + if ((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50 + || !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy); - else { - dev_warn(&adap->dev, "No suitable probing method supported\n"); - err = -EOPNOTSUPP; - } + else + err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_WRITE, 0, + I2C_SMBUS_QUICK, NULL); return err >= 0; } @@ -1520,6 +1437,16 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver) if (!(adapter->class & driver->class)) goto exit_free; + /* Stop here if the bus doesn't support probing */ + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE)) { + if (address_list[0] == I2C_CLIENT_END) + goto exit_free; + + dev_warn(&adapter->dev, "Probing not supported\n"); + err = -EOPNOTSUPP; + goto exit_free; + } + for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) { dev_dbg(&adapter->dev, "found normal entry for adapter %d, " "addr 0x%02x\n", adap_id, address_list[i]); @@ -1534,23 +1461,18 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver) return err; } -int i2c_probe_func_quick_read(struct i2c_adapter *adap, unsigned short addr) -{ - return i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0, - I2C_SMBUS_QUICK, NULL) >= 0; -} -EXPORT_SYMBOL_GPL(i2c_probe_func_quick_read); - struct i2c_client * i2c_new_probed_device(struct i2c_adapter *adap, struct i2c_board_info *info, - unsigned short const *addr_list, - int (*probe)(struct i2c_adapter *, unsigned short addr)) + unsigned short const *addr_list) { int i; - if (!probe) - probe = i2c_default_probe; + /* Stop here if the bus doesn't support probing */ + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE)) { + dev_err(&adap->dev, "Probing not supported\n"); + return NULL; + } for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) { /* Check address validity */ @@ -1568,7 +1490,7 @@ i2c_new_probed_device(struct i2c_adapter *adap, } /* Test address responsiveness */ - if (probe(adap, addr_list[i])) + if (i2c_default_probe(adap, addr_list[i])) break; } @@ -2080,7 +2002,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, flags &= I2C_M_TEN | I2C_CLIENT_PEC; if (adapter->algo->smbus_xfer) { - i2c_lock_adapter(adapter); + rt_mutex_lock(&adapter->bus_lock); /* Retry automatically on arbitration loss */ orig_jiffies = jiffies; @@ -2094,7 +2016,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, orig_jiffies + adapter->timeout)) break; } - i2c_unlock_adapter(adapter); + rt_mutex_unlock(&adapter->bus_lock); } else res = i2c_smbus_xfer_emulated(adapter, addr, flags, read_write, command, protocol, data); diff --git a/trunk/drivers/i2c/i2c-dev.c b/trunk/drivers/i2c/i2c-dev.c index 5f3a52d517c3..e0694e4d86c7 100644 --- a/trunk/drivers/i2c/i2c-dev.c +++ b/trunk/drivers/i2c/i2c-dev.c @@ -167,9 +167,13 @@ static ssize_t i2cdev_write(struct file *file, const char __user *buf, if (count > 8192) count = 8192; - tmp = memdup_user(buf, count); - if (IS_ERR(tmp)) - return PTR_ERR(tmp); + tmp = kmalloc(count, GFP_KERNEL); + if (tmp == NULL) + return -ENOMEM; + if (copy_from_user(tmp, buf, count)) { + kfree(tmp); + return -EFAULT; + } pr_debug("i2c-dev: i2c-%d writing %zu bytes.\n", iminor(file->f_path.dentry->d_inode), count); @@ -189,50 +193,12 @@ static int i2cdev_check(struct device *dev, void *addrp) return dev->driver ? -EBUSY : 0; } -/* walk up mux tree */ -static int i2cdev_check_mux_parents(struct i2c_adapter *adapter, int addr) -{ - int result; - - result = device_for_each_child(&adapter->dev, &addr, i2cdev_check); - - if (!result && i2c_parent_is_i2c_adapter(adapter)) - result = i2cdev_check_mux_parents( - to_i2c_adapter(adapter->dev.parent), addr); - - return result; -} - -/* recurse down mux tree */ -static int i2cdev_check_mux_children(struct device *dev, void *addrp) -{ - int result; - - if (dev->type == &i2c_adapter_type) - result = device_for_each_child(dev, addrp, - i2cdev_check_mux_children); - else - result = i2cdev_check(dev, addrp); - - return result; -} - /* This address checking function differs from the one in i2c-core in that it considers an address with a registered device, but no driver bound to it, as NOT busy. */ static int i2cdev_check_addr(struct i2c_adapter *adapter, unsigned int addr) { - int result = 0; - - if (i2c_parent_is_i2c_adapter(adapter)) - result = i2cdev_check_mux_parents( - to_i2c_adapter(adapter->dev.parent), addr); - - if (!result) - result = device_for_each_child(&adapter->dev, &addr, - i2cdev_check_mux_children); - - return result; + return device_for_each_child(&adapter->dev, &addr, i2cdev_check); } static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client, @@ -253,7 +219,9 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client, if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) return -EINVAL; - rdwr_pa = kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), GFP_KERNEL); + rdwr_pa = (struct i2c_msg *) + kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), + GFP_KERNEL); if (!rdwr_pa) return -ENOMEM; @@ -279,9 +247,15 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client, break; } data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf; - rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len); - if (IS_ERR(rdwr_pa[i].buf)) { - res = PTR_ERR(rdwr_pa[i].buf); + rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL); + if (rdwr_pa[i].buf == NULL) { + res = -ENOMEM; + break; + } + if (copy_from_user(rdwr_pa[i].buf, data_ptrs[i], + rdwr_pa[i].len)) { + ++i; /* Needs to be kfreed too */ + res = -EFAULT; break; } } diff --git a/trunk/drivers/i2c/i2c-mux.c b/trunk/drivers/i2c/i2c-mux.c deleted file mode 100644 index d32a4843fc3a..000000000000 --- a/trunk/drivers/i2c/i2c-mux.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Multiplexed I2C bus driver. - * - * Copyright (c) 2008-2009 Rodolfo Giometti - * Copyright (c) 2008-2009 Eurotech S.p.A. - * Copyright (c) 2009-2010 NSN GmbH & Co KG - * - * Simplifies access to complex multiplexed I2C bus topologies, by presenting - * each multiplexed bus segment as an additional I2C adapter. - * Supports multi-level mux'ing (mux behind a mux). - * - * Based on: - * i2c-virt.c from Kumar Gala - * i2c-virtual.c from Ken Harrenstien, Copyright (c) 2004 Google, Inc. - * i2c-virtual.c from Brian Kuschak - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. - */ - -#include -#include -#include -#include -#include - -/* multiplexer per channel data */ -struct i2c_mux_priv { - struct i2c_adapter adap; - struct i2c_algorithm algo; - - struct i2c_adapter *parent; - void *mux_dev; /* the mux chip/device */ - u32 chan_id; /* the channel id */ - - int (*select)(struct i2c_adapter *, void *mux_dev, u32 chan_id); - int (*deselect)(struct i2c_adapter *, void *mux_dev, u32 chan_id); -}; - -static int i2c_mux_master_xfer(struct i2c_adapter *adap, - struct i2c_msg msgs[], int num) -{ - struct i2c_mux_priv *priv = adap->algo_data; - struct i2c_adapter *parent = priv->parent; - int ret; - - /* Switch to the right mux port and perform the transfer. */ - - ret = priv->select(parent, priv->mux_dev, priv->chan_id); - if (ret >= 0) - ret = parent->algo->master_xfer(parent, msgs, num); - if (priv->deselect) - priv->deselect(parent, priv->mux_dev, priv->chan_id); - - return ret; -} - -static int i2c_mux_smbus_xfer(struct i2c_adapter *adap, - u16 addr, unsigned short flags, - char read_write, u8 command, - int size, union i2c_smbus_data *data) -{ - struct i2c_mux_priv *priv = adap->algo_data; - struct i2c_adapter *parent = priv->parent; - int ret; - - /* Select the right mux port and perform the transfer. */ - - ret = priv->select(parent, priv->mux_dev, priv->chan_id); - if (ret >= 0) - ret = parent->algo->smbus_xfer(parent, addr, flags, - read_write, command, size, data); - if (priv->deselect) - priv->deselect(parent, priv->mux_dev, priv->chan_id); - - return ret; -} - -/* Return the parent's functionality */ -static u32 i2c_mux_functionality(struct i2c_adapter *adap) -{ - struct i2c_mux_priv *priv = adap->algo_data; - struct i2c_adapter *parent = priv->parent; - - return parent->algo->functionality(parent); -} - -struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, - void *mux_dev, u32 force_nr, u32 chan_id, - int (*select) (struct i2c_adapter *, - void *, u32), - int (*deselect) (struct i2c_adapter *, - void *, u32)) -{ - struct i2c_mux_priv *priv; - int ret; - - priv = kzalloc(sizeof(struct i2c_mux_priv), GFP_KERNEL); - if (!priv) - return NULL; - - /* Set up private adapter data */ - priv->parent = parent; - priv->mux_dev = mux_dev; - priv->chan_id = chan_id; - priv->select = select; - priv->deselect = deselect; - - /* Need to do algo dynamically because we don't know ahead - * of time what sort of physical adapter we'll be dealing with. - */ - if (parent->algo->master_xfer) - priv->algo.master_xfer = i2c_mux_master_xfer; - if (parent->algo->smbus_xfer) - priv->algo.smbus_xfer = i2c_mux_smbus_xfer; - priv->algo.functionality = i2c_mux_functionality; - - /* Now fill out new adapter structure */ - snprintf(priv->adap.name, sizeof(priv->adap.name), - "i2c-%d-mux (chan_id %d)", i2c_adapter_id(parent), chan_id); - priv->adap.owner = THIS_MODULE; - priv->adap.id = parent->id; - priv->adap.algo = &priv->algo; - priv->adap.algo_data = priv; - priv->adap.dev.parent = &parent->dev; - - if (force_nr) { - priv->adap.nr = force_nr; - ret = i2c_add_numbered_adapter(&priv->adap); - } else { - ret = i2c_add_adapter(&priv->adap); - } - if (ret < 0) { - dev_err(&parent->dev, - "failed to add mux-adapter (error=%d)\n", - ret); - kfree(priv); - return NULL; - } - - dev_info(&parent->dev, "Added multiplexed i2c bus %d\n", - i2c_adapter_id(&priv->adap)); - - return &priv->adap; -} -EXPORT_SYMBOL_GPL(i2c_add_mux_adapter); - -int i2c_del_mux_adapter(struct i2c_adapter *adap) -{ - struct i2c_mux_priv *priv = adap->algo_data; - int ret; - - ret = i2c_del_adapter(adap); - if (ret < 0) - return ret; - kfree(priv); - - return 0; -} -EXPORT_SYMBOL_GPL(i2c_del_mux_adapter); - -MODULE_AUTHOR("Rodolfo Giometti "); -MODULE_DESCRIPTION("I2C driver for multiplexed I2C busses"); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/i2c/muxes/Kconfig b/trunk/drivers/i2c/muxes/Kconfig deleted file mode 100644 index 4c9a99c4fcb0..000000000000 --- a/trunk/drivers/i2c/muxes/Kconfig +++ /dev/null @@ -1,18 +0,0 @@ -# -# Multiplexer I2C chip drivers configuration -# - -menu "Multiplexer I2C Chip support" - depends on I2C_MUX - -config I2C_MUX_PCA954x - tristate "Philips PCA954x I2C Mux/switches" - depends on EXPERIMENTAL - help - If you say yes here you get support for the Philips PCA954x - I2C mux/switch devices. - - This driver can also be built as a module. If so, the module - will be called pca954x. - -endmenu diff --git a/trunk/drivers/i2c/muxes/Makefile b/trunk/drivers/i2c/muxes/Makefile deleted file mode 100644 index bd83b5274815..000000000000 --- a/trunk/drivers/i2c/muxes/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# -# Makefile for multiplexer I2C chip drivers. - -obj-$(CONFIG_I2C_MUX_PCA954x) += pca954x.o - -ifeq ($(CONFIG_I2C_DEBUG_BUS),y) -EXTRA_CFLAGS += -DDEBUG -endif diff --git a/trunk/drivers/i2c/muxes/pca954x.c b/trunk/drivers/i2c/muxes/pca954x.c deleted file mode 100644 index 6f9accf3189d..000000000000 --- a/trunk/drivers/i2c/muxes/pca954x.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * I2C multiplexer - * - * Copyright (c) 2008-2009 Rodolfo Giometti - * Copyright (c) 2008-2009 Eurotech S.p.A. - * - * This module supports the PCA954x series of I2C multiplexer/switch chips - * made by Philips Semiconductors. - * This includes the: - * PCA9540, PCA9542, PCA9543, PCA9544, PCA9545, PCA9546, PCA9547 - * and PCA9548. - * - * These chips are all controlled via the I2C bus itself, and all have a - * single 8-bit register. The upstream "parent" bus fans out to two, - * four, or eight downstream busses or channels; which of these - * are selected is determined by the chip type and register contents. A - * mux can select only one sub-bus at a time; a switch can select any - * combination simultaneously. - * - * Based on: - * pca954x.c from Kumar Gala - * Copyright (C) 2006 - * - * Based on: - * pca954x.c from Ken Harrenstien - * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) - * - * Based on: - * i2c-virtual_cb.c from Brian Kuschak - * and - * pca9540.c from Jean Delvare . - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#define PCA954X_MAX_NCHANS 8 - -enum pca_type { - pca_9540, - pca_9542, - pca_9543, - pca_9544, - pca_9545, - pca_9546, - pca_9547, - pca_9548, -}; - -struct pca954x { - enum pca_type type; - struct i2c_adapter *virt_adaps[PCA954X_MAX_NCHANS]; - - u8 last_chan; /* last register value */ -}; - -struct chip_desc { - u8 nchans; - u8 enable; /* used for muxes only */ - enum muxtype { - pca954x_ismux = 0, - pca954x_isswi - } muxtype; -}; - -/* Provide specs for the PCA954x types we know about */ -static const struct chip_desc chips[] = { - [pca_9540] = { - .nchans = 2, - .enable = 0x4, - .muxtype = pca954x_ismux, - }, - [pca_9543] = { - .nchans = 2, - .muxtype = pca954x_isswi, - }, - [pca_9544] = { - .nchans = 4, - .enable = 0x4, - .muxtype = pca954x_ismux, - }, - [pca_9545] = { - .nchans = 4, - .muxtype = pca954x_isswi, - }, - [pca_9547] = { - .nchans = 8, - .enable = 0x8, - .muxtype = pca954x_ismux, - }, - [pca_9548] = { - .nchans = 8, - .muxtype = pca954x_isswi, - }, -}; - -static const struct i2c_device_id pca954x_id[] = { - { "pca9540", pca_9540 }, - { "pca9542", pca_9540 }, - { "pca9543", pca_9543 }, - { "pca9544", pca_9544 }, - { "pca9545", pca_9545 }, - { "pca9546", pca_9545 }, - { "pca9547", pca_9547 }, - { "pca9548", pca_9548 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, pca954x_id); - -/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() - for this as they will try to lock adapter a second time */ -static int pca954x_reg_write(struct i2c_adapter *adap, - struct i2c_client *client, u8 val) -{ - int ret = -ENODEV; - - if (adap->algo->master_xfer) { - struct i2c_msg msg; - char buf[1]; - - msg.addr = client->addr; - msg.flags = 0; - msg.len = 1; - buf[0] = val; - msg.buf = buf; - ret = adap->algo->master_xfer(adap, &msg, 1); - } else { - union i2c_smbus_data data; - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_WRITE, - val, I2C_SMBUS_BYTE, &data); - } - - return ret; -} - -static int pca954x_select_chan(struct i2c_adapter *adap, - void *client, u32 chan) -{ - struct pca954x *data = i2c_get_clientdata(client); - const struct chip_desc *chip = &chips[data->type]; - u8 regval; - int ret = 0; - - /* we make switches look like muxes, not sure how to be smarter */ - if (chip->muxtype == pca954x_ismux) - regval = chan | chip->enable; - else - regval = 1 << chan; - - /* Only select the channel if its different from the last channel */ - if (data->last_chan != regval) { - ret = pca954x_reg_write(adap, client, regval); - data->last_chan = regval; - } - - return ret; -} - -static int pca954x_deselect_mux(struct i2c_adapter *adap, - void *client, u32 chan) -{ - struct pca954x *data = i2c_get_clientdata(client); - - /* Deselect active channel */ - data->last_chan = 0; - return pca954x_reg_write(adap, client, data->last_chan); -} - -/* - * I2C init/probing/exit functions - */ -static int __devinit pca954x_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); - struct pca954x_platform_data *pdata = client->dev.platform_data; - int num, force; - struct pca954x *data; - int ret = -ENODEV; - - if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) - goto err; - - data = kzalloc(sizeof(struct pca954x), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto err; - } - - i2c_set_clientdata(client, data); - - /* Read the mux register at addr to verify - * that the mux is in fact present. - */ - if (i2c_smbus_read_byte(client) < 0) { - dev_warn(&client->dev, "probe failed\n"); - goto exit_free; - } - - data->type = id->driver_data; - data->last_chan = 0; /* force the first selection */ - - /* Now create an adapter for each channel */ - for (num = 0; num < chips[data->type].nchans; num++) { - force = 0; /* dynamic adap number */ - if (pdata) { - if (num < pdata->num_modes) - /* force static number */ - force = pdata->modes[num].adap_id; - else - /* discard unconfigured channels */ - break; - } - - data->virt_adaps[num] = - i2c_add_mux_adapter(adap, client, - force, num, pca954x_select_chan, - (pdata && pdata->modes[num].deselect_on_exit) - ? pca954x_deselect_mux : NULL); - - if (data->virt_adaps[num] == NULL) { - ret = -ENODEV; - dev_err(&client->dev, - "failed to register multiplexed adapter" - " %d as bus %d\n", num, force); - goto virt_reg_failed; - } - } - - dev_info(&client->dev, - "registered %d multiplexed busses for I2C %s %s\n", - num, chips[data->type].muxtype == pca954x_ismux - ? "mux" : "switch", client->name); - - return 0; - -virt_reg_failed: - for (num--; num >= 0; num--) - i2c_del_mux_adapter(data->virt_adaps[num]); -exit_free: - kfree(data); -err: - return ret; -} - -static int __devexit pca954x_remove(struct i2c_client *client) -{ - struct pca954x *data = i2c_get_clientdata(client); - const struct chip_desc *chip = &chips[data->type]; - int i, err; - - for (i = 0; i < chip->nchans; ++i) - if (data->virt_adaps[i]) { - err = i2c_del_mux_adapter(data->virt_adaps[i]); - if (err) - return err; - data->virt_adaps[i] = NULL; - } - - kfree(data); - return 0; -} - -static struct i2c_driver pca954x_driver = { - .driver = { - .name = "pca954x", - .owner = THIS_MODULE, - }, - .probe = pca954x_probe, - .remove = __devexit_p(pca954x_remove), - .id_table = pca954x_id, -}; - -static int __init pca954x_init(void) -{ - return i2c_add_driver(&pca954x_driver); -} - -static void __exit pca954x_exit(void) -{ - i2c_del_driver(&pca954x_driver); -} - -module_init(pca954x_init); -module_exit(pca954x_exit); - -MODULE_AUTHOR("Rodolfo Giometti "); -MODULE_DESCRIPTION("PCA954x I2C mux/switch driver"); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/ide/ide.c b/trunk/drivers/ide/ide.c index fa896210ed7b..3cb9c4e056ff 100644 --- a/trunk/drivers/ide/ide.c +++ b/trunk/drivers/ide/ide.c @@ -177,7 +177,7 @@ EXPORT_SYMBOL_GPL(ide_pci_clk); module_param_named(pci_clock, ide_pci_clk, int, 0); MODULE_PARM_DESC(pci_clock, "PCI bus clock frequency (in MHz)"); -static int ide_set_dev_param_mask(const char *s, const struct kernel_param *kp) +static int ide_set_dev_param_mask(const char *s, struct kernel_param *kp) { int a, b, i, j = 1; unsigned int *dev_param_mask = (unsigned int *)kp->arg; @@ -200,40 +200,34 @@ static int ide_set_dev_param_mask(const char *s, const struct kernel_param *kp) return 0; } -static struct kernel_param_ops param_ops_ide_dev_mask = { - .set = ide_set_dev_param_mask -}; - -#define param_check_ide_dev_mask(name, p) param_check_uint(name, p) - static unsigned int ide_nodma; -module_param_named(nodma, ide_nodma, ide_dev_mask, 0); +module_param_call(nodma, ide_set_dev_param_mask, NULL, &ide_nodma, 0); MODULE_PARM_DESC(nodma, "disallow DMA for a device"); static unsigned int ide_noflush; -module_param_named(noflush, ide_noflush, ide_dev_mask, 0); +module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0); MODULE_PARM_DESC(noflush, "disable flush requests for a device"); static unsigned int ide_nohpa; -module_param_named(nohpa, ide_nohpa, ide_dev_mask, 0); +module_param_call(nohpa, ide_set_dev_param_mask, NULL, &ide_nohpa, 0); MODULE_PARM_DESC(nohpa, "disable Host Protected Area for a device"); static unsigned int ide_noprobe; -module_param_named(noprobe, ide_noprobe, ide_dev_mask, 0); +module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0); MODULE_PARM_DESC(noprobe, "skip probing for a device"); static unsigned int ide_nowerr; -module_param_named(nowerr, ide_nowerr, ide_dev_mask, 0); +module_param_call(nowerr, ide_set_dev_param_mask, NULL, &ide_nowerr, 0); MODULE_PARM_DESC(nowerr, "ignore the ATA_DF bit for a device"); static unsigned int ide_cdroms; -module_param_named(cdrom, ide_cdroms, ide_dev_mask, 0); +module_param_call(cdrom, ide_set_dev_param_mask, NULL, &ide_cdroms, 0); MODULE_PARM_DESC(cdrom, "force device as a CD-ROM"); struct chs_geom { diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_classes.h b/trunk/drivers/infiniband/hw/ehca/ehca_classes.h index aaf6023a4835..0136abd50dd4 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_classes.h +++ b/trunk/drivers/infiniband/hw/ehca/ehca_classes.h @@ -112,7 +112,7 @@ struct ehca_sport { struct ehca_shca { struct ib_device ib_device; - struct platform_device *ofdev; + struct of_device *ofdev; u8 num_ports; int hw_level; struct list_head shca_list; diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_main.c b/trunk/drivers/infiniband/hw/ehca/ehca_main.c index c240e9972cb0..cfc4de7a5da4 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_main.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_main.c @@ -713,7 +713,7 @@ static struct attribute_group ehca_dev_attr_grp = { .attrs = ehca_dev_attrs }; -static int __devinit ehca_probe(struct platform_device *dev, +static int __devinit ehca_probe(struct of_device *dev, const struct of_device_id *id) { struct ehca_shca *shca; @@ -879,7 +879,7 @@ static int __devinit ehca_probe(struct platform_device *dev, return -EINVAL; } -static int __devexit ehca_remove(struct platform_device *dev) +static int __devexit ehca_remove(struct of_device *dev) { struct ehca_shca *shca = dev_get_drvdata(&dev->dev); unsigned long flags; diff --git a/trunk/drivers/input/keyboard/Kconfig b/trunk/drivers/input/keyboard/Kconfig index 9cc488d21490..b171f63fe4d7 100644 --- a/trunk/drivers/input/keyboard/Kconfig +++ b/trunk/drivers/input/keyboard/Kconfig @@ -395,16 +395,6 @@ config KEYBOARD_SH_KEYSC To compile this driver as a module, choose M here: the module will be called sh_keysc. -config KEYBOARD_STMPE - tristate "STMPE keypad support" - depends on MFD_STMPE - help - Say Y here if you want to use the keypad controller on STMPE I/O - expanders. - - To compile this driver as a module, choose M here: the module will be - called stmpe-keypad. - config KEYBOARD_DAVINCI tristate "TI DaVinci Key Scan" depends on ARCH_DAVINCI_DM365 diff --git a/trunk/drivers/input/keyboard/Makefile b/trunk/drivers/input/keyboard/Makefile index 504b591be0cd..1a66d5f1ca8b 100644 --- a/trunk/drivers/input/keyboard/Makefile +++ b/trunk/drivers/input/keyboard/Makefile @@ -35,7 +35,6 @@ obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o -obj-$(CONFIG_KEYBOARD_STMPE) += stmpe-keypad.o obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o diff --git a/trunk/drivers/input/keyboard/stmpe-keypad.c b/trunk/drivers/input/keyboard/stmpe-keypad.c deleted file mode 100644 index ab7610ca10eb..000000000000 --- a/trunk/drivers/input/keyboard/stmpe-keypad.c +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2010 - * - * License Terms: GNU General Public License, version 2 - * Author: Rabin Vincent for ST-Ericsson - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* These are at the same addresses in all STMPE variants */ -#define STMPE_KPC_COL 0x60 -#define STMPE_KPC_ROW_MSB 0x61 -#define STMPE_KPC_ROW_LSB 0x62 -#define STMPE_KPC_CTRL_MSB 0x63 -#define STMPE_KPC_CTRL_LSB 0x64 -#define STMPE_KPC_COMBI_KEY_0 0x65 -#define STMPE_KPC_COMBI_KEY_1 0x66 -#define STMPE_KPC_COMBI_KEY_2 0x67 -#define STMPE_KPC_DATA_BYTE0 0x68 -#define STMPE_KPC_DATA_BYTE1 0x69 -#define STMPE_KPC_DATA_BYTE2 0x6a -#define STMPE_KPC_DATA_BYTE3 0x6b -#define STMPE_KPC_DATA_BYTE4 0x6c - -#define STMPE_KPC_CTRL_LSB_SCAN (0x1 << 0) -#define STMPE_KPC_CTRL_LSB_DEBOUNCE (0x7f << 1) -#define STMPE_KPC_CTRL_MSB_SCAN_COUNT (0xf << 4) - -#define STMPE_KPC_ROW_MSB_ROWS 0xff - -#define STMPE_KPC_DATA_UP (0x1 << 7) -#define STMPE_KPC_DATA_ROW (0xf << 3) -#define STMPE_KPC_DATA_COL (0x7 << 0) -#define STMPE_KPC_DATA_NOKEY_MASK 0x78 - -#define STMPE_KEYPAD_MAX_DEBOUNCE 127 -#define STMPE_KEYPAD_MAX_SCAN_COUNT 15 - -#define STMPE_KEYPAD_MAX_ROWS 8 -#define STMPE_KEYPAD_MAX_COLS 8 -#define STMPE_KEYPAD_ROW_SHIFT 3 -#define STMPE_KEYPAD_KEYMAP_SIZE \ - (STMPE_KEYPAD_MAX_ROWS * STMPE_KEYPAD_MAX_COLS) - -/** - * struct stmpe_keypad_variant - model-specific attributes - * @auto_increment: whether the KPC_DATA_BYTE register address - * auto-increments on multiple read - * @num_data: number of data bytes - * @num_normal_data: number of normal keys' data bytes - * @max_cols: maximum number of columns supported - * @max_rows: maximum number of rows supported - * @col_gpios: bitmask of gpios which can be used for columns - * @row_gpios: bitmask of gpios which can be used for rows - */ -struct stmpe_keypad_variant { - bool auto_increment; - int num_data; - int num_normal_data; - int max_cols; - int max_rows; - unsigned int col_gpios; - unsigned int row_gpios; -}; - -static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { - [STMPE1601] = { - .auto_increment = true, - .num_data = 5, - .num_normal_data = 3, - .max_cols = 8, - .max_rows = 8, - .col_gpios = 0x000ff, /* GPIO 0 - 7 */ - .row_gpios = 0x0ff00, /* GPIO 8 - 15 */ - }, - [STMPE2401] = { - .auto_increment = false, - .num_data = 3, - .num_normal_data = 2, - .max_cols = 8, - .max_rows = 12, - .col_gpios = 0x0000ff, /* GPIO 0 - 7*/ - .row_gpios = 0x1fef00, /* GPIO 8-14, 16-20 */ - }, - [STMPE2403] = { - .auto_increment = true, - .num_data = 5, - .num_normal_data = 3, - .max_cols = 8, - .max_rows = 12, - .col_gpios = 0x0000ff, /* GPIO 0 - 7*/ - .row_gpios = 0x1fef00, /* GPIO 8-14, 16-20 */ - }, -}; - -struct stmpe_keypad { - struct stmpe *stmpe; - struct input_dev *input; - const struct stmpe_keypad_variant *variant; - const struct stmpe_keypad_platform_data *plat; - - unsigned int rows; - unsigned int cols; - - unsigned short keymap[STMPE_KEYPAD_KEYMAP_SIZE]; -}; - -static int stmpe_keypad_read_data(struct stmpe_keypad *keypad, u8 *data) -{ - const struct stmpe_keypad_variant *variant = keypad->variant; - struct stmpe *stmpe = keypad->stmpe; - int ret; - int i; - - if (variant->auto_increment) - return stmpe_block_read(stmpe, STMPE_KPC_DATA_BYTE0, - variant->num_data, data); - - for (i = 0; i < variant->num_data; i++) { - ret = stmpe_reg_read(stmpe, STMPE_KPC_DATA_BYTE0 + i); - if (ret < 0) - return ret; - - data[i] = ret; - } - - return 0; -} - -static irqreturn_t stmpe_keypad_irq(int irq, void *dev) -{ - struct stmpe_keypad *keypad = dev; - struct input_dev *input = keypad->input; - const struct stmpe_keypad_variant *variant = keypad->variant; - u8 fifo[variant->num_data]; - int ret; - int i; - - ret = stmpe_keypad_read_data(keypad, fifo); - if (ret < 0) - return IRQ_NONE; - - for (i = 0; i < variant->num_normal_data; i++) { - u8 data = fifo[i]; - int row = (data & STMPE_KPC_DATA_ROW) >> 3; - int col = data & STMPE_KPC_DATA_COL; - int code = MATRIX_SCAN_CODE(row, col, STMPE_KEYPAD_ROW_SHIFT); - bool up = data & STMPE_KPC_DATA_UP; - - if ((data & STMPE_KPC_DATA_NOKEY_MASK) - == STMPE_KPC_DATA_NOKEY_MASK) - continue; - - input_event(input, EV_MSC, MSC_SCAN, code); - input_report_key(input, keypad->keymap[code], !up); - input_sync(input); - } - - return IRQ_HANDLED; -} - -static int __devinit stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad) -{ - const struct stmpe_keypad_variant *variant = keypad->variant; - unsigned int col_gpios = variant->col_gpios; - unsigned int row_gpios = variant->row_gpios; - struct stmpe *stmpe = keypad->stmpe; - unsigned int pins = 0; - int i; - - /* - * Figure out which pins need to be set to the keypad alternate - * function. - * - * {cols,rows}_gpios are bitmasks of which pins on the chip can be used - * for the keypad. - * - * keypad->{cols,rows} are a bitmask of which pins (of the ones useable - * for the keypad) are used on the board. - */ - - for (i = 0; i < variant->max_cols; i++) { - int num = __ffs(col_gpios); - - if (keypad->cols & (1 << i)) - pins |= 1 << num; - - col_gpios &= ~(1 << num); - } - - for (i = 0; i < variant->max_rows; i++) { - int num = __ffs(row_gpios); - - if (keypad->rows & (1 << i)) - pins |= 1 << num; - - row_gpios &= ~(1 << num); - } - - return stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD); -} - -static int __devinit stmpe_keypad_chip_init(struct stmpe_keypad *keypad) -{ - const struct stmpe_keypad_platform_data *plat = keypad->plat; - const struct stmpe_keypad_variant *variant = keypad->variant; - struct stmpe *stmpe = keypad->stmpe; - int ret; - - if (plat->debounce_ms > STMPE_KEYPAD_MAX_DEBOUNCE) - return -EINVAL; - - if (plat->scan_count > STMPE_KEYPAD_MAX_SCAN_COUNT) - return -EINVAL; - - ret = stmpe_enable(stmpe, STMPE_BLOCK_KEYPAD); - if (ret < 0) - return ret; - - ret = stmpe_keypad_altfunc_init(keypad); - if (ret < 0) - return ret; - - ret = stmpe_reg_write(stmpe, STMPE_KPC_COL, keypad->cols); - if (ret < 0) - return ret; - - ret = stmpe_reg_write(stmpe, STMPE_KPC_ROW_LSB, keypad->rows); - if (ret < 0) - return ret; - - if (variant->max_rows > 8) { - ret = stmpe_set_bits(stmpe, STMPE_KPC_ROW_MSB, - STMPE_KPC_ROW_MSB_ROWS, - keypad->rows >> 8); - if (ret < 0) - return ret; - } - - ret = stmpe_set_bits(stmpe, STMPE_KPC_CTRL_MSB, - STMPE_KPC_CTRL_MSB_SCAN_COUNT, - plat->scan_count << 4); - if (ret < 0) - return ret; - - return stmpe_set_bits(stmpe, STMPE_KPC_CTRL_LSB, - STMPE_KPC_CTRL_LSB_SCAN | - STMPE_KPC_CTRL_LSB_DEBOUNCE, - STMPE_KPC_CTRL_LSB_SCAN | - (plat->debounce_ms << 1)); -} - -static int __devinit stmpe_keypad_probe(struct platform_device *pdev) -{ - struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); - struct stmpe_keypad_platform_data *plat; - struct stmpe_keypad *keypad; - struct input_dev *input; - int ret; - int irq; - int i; - - plat = stmpe->pdata->keypad; - if (!plat) - return -ENODEV; - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - - keypad = kzalloc(sizeof(struct stmpe_keypad), GFP_KERNEL); - if (!keypad) - return -ENOMEM; - - input = input_allocate_device(); - if (!input) { - ret = -ENOMEM; - goto out_freekeypad; - } - - input->name = "STMPE keypad"; - input->id.bustype = BUS_I2C; - input->dev.parent = &pdev->dev; - - input_set_capability(input, EV_MSC, MSC_SCAN); - - __set_bit(EV_KEY, input->evbit); - if (!plat->no_autorepeat) - __set_bit(EV_REP, input->evbit); - - input->keycode = keypad->keymap; - input->keycodesize = sizeof(keypad->keymap[0]); - input->keycodemax = ARRAY_SIZE(keypad->keymap); - - matrix_keypad_build_keymap(plat->keymap_data, STMPE_KEYPAD_ROW_SHIFT, - input->keycode, input->keybit); - - for (i = 0; i < plat->keymap_data->keymap_size; i++) { - unsigned int key = plat->keymap_data->keymap[i]; - - keypad->cols |= 1 << KEY_COL(key); - keypad->rows |= 1 << KEY_ROW(key); - } - - keypad->stmpe = stmpe; - keypad->plat = plat; - keypad->input = input; - keypad->variant = &stmpe_keypad_variants[stmpe->partnum]; - - ret = stmpe_keypad_chip_init(keypad); - if (ret < 0) - goto out_freeinput; - - ret = input_register_device(input); - if (ret) { - dev_err(&pdev->dev, - "unable to register input device: %d\n", ret); - goto out_freeinput; - } - - ret = request_threaded_irq(irq, NULL, stmpe_keypad_irq, IRQF_ONESHOT, - "stmpe-keypad", keypad); - if (ret) { - dev_err(&pdev->dev, "unable to get irq: %d\n", ret); - goto out_unregisterinput; - } - - platform_set_drvdata(pdev, keypad); - - return 0; - -out_unregisterinput: - input_unregister_device(input); - input = NULL; -out_freeinput: - input_free_device(input); -out_freekeypad: - kfree(keypad); - return ret; -} - -static int __devexit stmpe_keypad_remove(struct platform_device *pdev) -{ - struct stmpe_keypad *keypad = platform_get_drvdata(pdev); - struct stmpe *stmpe = keypad->stmpe; - int irq = platform_get_irq(pdev, 0); - - stmpe_disable(stmpe, STMPE_BLOCK_KEYPAD); - - free_irq(irq, keypad); - input_unregister_device(keypad->input); - platform_set_drvdata(pdev, NULL); - kfree(keypad); - - return 0; -} - -static struct platform_driver stmpe_keypad_driver = { - .driver.name = "stmpe-keypad", - .driver.owner = THIS_MODULE, - .probe = stmpe_keypad_probe, - .remove = __devexit_p(stmpe_keypad_remove), -}; - -static int __init stmpe_keypad_init(void) -{ - return platform_driver_register(&stmpe_keypad_driver); -} -module_init(stmpe_keypad_init); - -static void __exit stmpe_keypad_exit(void) -{ - platform_driver_unregister(&stmpe_keypad_driver); -} -module_exit(stmpe_keypad_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("STMPExxxx keypad driver"); -MODULE_AUTHOR("Rabin Vincent "); diff --git a/trunk/drivers/input/misc/ati_remote2.c b/trunk/drivers/input/misc/ati_remote2.c index 23257652b8e8..e148749b5851 100644 --- a/trunk/drivers/input/misc/ati_remote2.c +++ b/trunk/drivers/input/misc/ati_remote2.c @@ -38,8 +38,7 @@ enum { }; static int ati_remote2_set_mask(const char *val, - const struct kernel_param *kp, - unsigned int max) + struct kernel_param *kp, unsigned int max) { unsigned long mask; int ret; @@ -60,31 +59,28 @@ static int ati_remote2_set_mask(const char *val, } static int ati_remote2_set_channel_mask(const char *val, - const struct kernel_param *kp) + struct kernel_param *kp) { pr_debug("%s()\n", __func__); return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_CHANNEL_MASK); } -static int ati_remote2_get_channel_mask(char *buffer, - const struct kernel_param *kp) +static int ati_remote2_get_channel_mask(char *buffer, struct kernel_param *kp) { pr_debug("%s()\n", __func__); return sprintf(buffer, "0x%04x", *(unsigned int *)kp->arg); } -static int ati_remote2_set_mode_mask(const char *val, - const struct kernel_param *kp) +static int ati_remote2_set_mode_mask(const char *val, struct kernel_param *kp) { pr_debug("%s()\n", __func__); return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_MODE_MASK); } -static int ati_remote2_get_mode_mask(char *buffer, - const struct kernel_param *kp) +static int ati_remote2_get_mode_mask(char *buffer, struct kernel_param *kp) { pr_debug("%s()\n", __func__); @@ -93,19 +89,15 @@ static int ati_remote2_get_mode_mask(char *buffer, static unsigned int channel_mask = ATI_REMOTE2_MAX_CHANNEL_MASK; #define param_check_channel_mask(name, p) __param_check(name, p, unsigned int) -static struct kernel_param_ops param_ops_channel_mask = { - .set = ati_remote2_set_channel_mask, - .get = ati_remote2_get_channel_mask, -}; +#define param_set_channel_mask ati_remote2_set_channel_mask +#define param_get_channel_mask ati_remote2_get_channel_mask module_param(channel_mask, channel_mask, 0644); MODULE_PARM_DESC(channel_mask, "Bitmask of channels to accept <15:Channel16>...<1:Channel2><0:Channel1>"); static unsigned int mode_mask = ATI_REMOTE2_MAX_MODE_MASK; #define param_check_mode_mask(name, p) __param_check(name, p, unsigned int) -static struct kernel_param_ops param_ops_mode_mask = { - .set = ati_remote2_set_mode_mask, - .get = ati_remote2_get_mode_mask, -}; +#define param_set_mode_mask ati_remote2_set_mode_mask +#define param_get_mode_mask ati_remote2_get_mode_mask module_param(mode_mask, mode_mask, 0644); MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>"); diff --git a/trunk/drivers/input/misc/sparcspkr.c b/trunk/drivers/input/misc/sparcspkr.c index 8e130bf7d32b..f3bb92e9755f 100644 --- a/trunk/drivers/input/misc/sparcspkr.c +++ b/trunk/drivers/input/misc/sparcspkr.c @@ -173,7 +173,7 @@ static int __devinit sparcspkr_probe(struct device *dev) return 0; } -static int sparcspkr_shutdown(struct platform_device *dev) +static int sparcspkr_shutdown(struct of_device *dev) { struct sparcspkr_state *state = dev_get_drvdata(&dev->dev); struct input_dev *input_dev = state->input_dev; @@ -184,7 +184,7 @@ static int sparcspkr_shutdown(struct platform_device *dev) return 0; } -static int __devinit bbc_beep_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit bbc_beep_probe(struct of_device *op, const struct of_device_id *match) { struct sparcspkr_state *state; struct bbc_beep_info *info; @@ -231,7 +231,7 @@ static int __devinit bbc_beep_probe(struct platform_device *op, const struct of_ return err; } -static int __devexit bbc_remove(struct platform_device *op) +static int __devexit bbc_remove(struct of_device *op) { struct sparcspkr_state *state = dev_get_drvdata(&op->dev); struct input_dev *input_dev = state->input_dev; @@ -269,7 +269,7 @@ static struct of_platform_driver bbc_beep_driver = { .shutdown = sparcspkr_shutdown, }; -static int __devinit grover_beep_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit grover_beep_probe(struct of_device *op, const struct of_device_id *match) { struct sparcspkr_state *state; struct grover_beep_info *info; @@ -312,7 +312,7 @@ static int __devinit grover_beep_probe(struct platform_device *op, const struct return err; } -static int __devexit grover_remove(struct platform_device *op) +static int __devexit grover_remove(struct of_device *op) { struct sparcspkr_state *state = dev_get_drvdata(&op->dev); struct grover_beep_info *info = &state->u.grover; diff --git a/trunk/drivers/input/mouse/psmouse-base.c b/trunk/drivers/input/mouse/psmouse-base.c index 73a7af2542a8..979c50215282 100644 --- a/trunk/drivers/input/mouse/psmouse-base.c +++ b/trunk/drivers/input/mouse/psmouse-base.c @@ -39,13 +39,11 @@ MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); static unsigned int psmouse_max_proto = PSMOUSE_AUTO; -static int psmouse_set_maxproto(const char *val, const struct kernel_param *); -static int psmouse_get_maxproto(char *buffer, const struct kernel_param *kp); -static struct kernel_param_ops param_ops_proto_abbrev = { - .set = psmouse_set_maxproto, - .get = psmouse_get_maxproto, -}; +static int psmouse_set_maxproto(const char *val, struct kernel_param *kp); +static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp); #define param_check_proto_abbrev(name, p) __param_check(name, p, unsigned int) +#define param_set_proto_abbrev psmouse_set_maxproto +#define param_get_proto_abbrev psmouse_get_maxproto module_param_named(proto, psmouse_max_proto, proto_abbrev, 0644); MODULE_PARM_DESC(proto, "Highest protocol extension to probe (bare, imps, exps, any). Useful for KVM switches."); @@ -1681,7 +1679,7 @@ static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, } -static int psmouse_set_maxproto(const char *val, const struct kernel_param *kp) +static int psmouse_set_maxproto(const char *val, struct kernel_param *kp) { const struct psmouse_protocol *proto; @@ -1698,7 +1696,7 @@ static int psmouse_set_maxproto(const char *val, const struct kernel_param *kp) return 0; } -static int psmouse_get_maxproto(char *buffer, const struct kernel_param *kp) +static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp) { int type = *((unsigned int *)kp->arg); diff --git a/trunk/drivers/input/serio/i8042-sparcio.h b/trunk/drivers/input/serio/i8042-sparcio.h index c5cc4508d6df..cb2a24b94746 100644 --- a/trunk/drivers/input/serio/i8042-sparcio.h +++ b/trunk/drivers/input/serio/i8042-sparcio.h @@ -49,7 +49,7 @@ static inline void i8042_write_command(int val) #define OBP_PS2MS_NAME1 "kdmouse" #define OBP_PS2MS_NAME2 "mouse" -static int __devinit sparc_i8042_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; @@ -57,7 +57,7 @@ static int __devinit sparc_i8042_probe(struct platform_device *op, const struct while (dp) { if (!strcmp(dp->name, OBP_PS2KBD_NAME1) || !strcmp(dp->name, OBP_PS2KBD_NAME2)) { - struct platform_device *kbd = of_find_device_by_node(dp); + struct of_device *kbd = of_find_device_by_node(dp); unsigned int irq = kbd->archdata.irqs[0]; if (irq == 0xffffffff) irq = op->archdata.irqs[0]; @@ -67,7 +67,7 @@ static int __devinit sparc_i8042_probe(struct platform_device *op, const struct kbd_res = &kbd->resource[0]; } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) || !strcmp(dp->name, OBP_PS2MS_NAME2)) { - struct platform_device *ms = of_find_device_by_node(dp); + struct of_device *ms = of_find_device_by_node(dp); unsigned int irq = ms->archdata.irqs[0]; if (irq == 0xffffffff) irq = op->archdata.irqs[0]; @@ -80,7 +80,7 @@ static int __devinit sparc_i8042_probe(struct platform_device *op, const struct return 0; } -static int __devexit sparc_i8042_remove(struct platform_device *op) +static int __devexit sparc_i8042_remove(struct of_device *op) { of_iounmap(kbd_res, kbd_iobase, 8); diff --git a/trunk/drivers/input/serio/xilinx_ps2.c b/trunk/drivers/input/serio/xilinx_ps2.c index bb14449fb022..e2c028d2638f 100644 --- a/trunk/drivers/input/serio/xilinx_ps2.c +++ b/trunk/drivers/input/serio/xilinx_ps2.c @@ -232,7 +232,7 @@ static void sxps2_close(struct serio *pserio) * It returns 0, if the driver is bound to the PS/2 device, or a negative * value if there is an error. */ -static int __devinit xps2_of_probe(struct platform_device *ofdev, +static int __devinit xps2_of_probe(struct of_device *ofdev, const struct of_device_id *match) { struct resource r_irq; /* Interrupt resources */ @@ -332,7 +332,7 @@ static int __devinit xps2_of_probe(struct platform_device *ofdev, * if the driver module is being unloaded. It frees any resources allocated to * the device. */ -static int __devexit xps2_of_remove(struct platform_device *of_dev) +static int __devexit xps2_of_remove(struct of_device *of_dev) { struct device *dev = &of_dev->dev; struct xps2data *drvdata = dev_get_drvdata(dev); diff --git a/trunk/drivers/input/touchscreen/Kconfig b/trunk/drivers/input/touchscreen/Kconfig index 0069d9703fda..61f35184f76c 100644 --- a/trunk/drivers/input/touchscreen/Kconfig +++ b/trunk/drivers/input/touchscreen/Kconfig @@ -628,14 +628,4 @@ config TOUCHSCREEN_TPS6507X To compile this driver as a module, choose M here: the module will be called tps6507x_ts. -config TOUCHSCREEN_STMPE - tristate "STMicroelectronics STMPE touchscreens" - depends on MFD_STMPE - help - Say Y here if you want support for STMicroelectronics - STMPE touchscreen controllers. - - To compile this driver as a module, choose M here: the - module will be called stmpe-ts. - endif diff --git a/trunk/drivers/input/touchscreen/Makefile b/trunk/drivers/input/touchscreen/Makefile index 28217e1dcafd..bd6f30b4ff70 100644 --- a/trunk/drivers/input/touchscreen/Makefile +++ b/trunk/drivers/input/touchscreen/Makefile @@ -36,7 +36,6 @@ obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o obj-$(CONFIG_TOUCHSCREEN_QT602240) += qt602240_ts.o obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o -obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o diff --git a/trunk/drivers/input/touchscreen/stmpe-ts.c b/trunk/drivers/input/touchscreen/stmpe-ts.c deleted file mode 100644 index 656148ec0027..000000000000 --- a/trunk/drivers/input/touchscreen/stmpe-ts.c +++ /dev/null @@ -1,397 +0,0 @@ -/* STMicroelectronics STMPE811 Touchscreen Driver - * - * (C) 2010 Luotao Fu - * All rights reserved. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* Register layouts and functionalities are identical on all stmpexxx variants - * with touchscreen controller - */ -#define STMPE_REG_INT_STA 0x0B -#define STMPE_REG_ADC_CTRL1 0x20 -#define STMPE_REG_ADC_CTRL2 0x21 -#define STMPE_REG_TSC_CTRL 0x40 -#define STMPE_REG_TSC_CFG 0x41 -#define STMPE_REG_FIFO_TH 0x4A -#define STMPE_REG_FIFO_STA 0x4B -#define STMPE_REG_FIFO_SIZE 0x4C -#define STMPE_REG_TSC_DATA_XYZ 0x52 -#define STMPE_REG_TSC_FRACTION_Z 0x56 -#define STMPE_REG_TSC_I_DRIVE 0x58 - -#define OP_MOD_XYZ 0 - -#define STMPE_TSC_CTRL_TSC_EN (1<<0) - -#define STMPE_FIFO_STA_RESET (1<<0) - -#define STMPE_IRQ_TOUCH_DET 0 - -#define SAMPLE_TIME(x) ((x & 0xf) << 4) -#define MOD_12B(x) ((x & 0x1) << 3) -#define REF_SEL(x) ((x & 0x1) << 1) -#define ADC_FREQ(x) (x & 0x3) -#define AVE_CTRL(x) ((x & 0x3) << 6) -#define DET_DELAY(x) ((x & 0x7) << 3) -#define SETTLING(x) (x & 0x7) -#define FRACTION_Z(x) (x & 0x7) -#define I_DRIVE(x) (x & 0x1) -#define OP_MODE(x) ((x & 0x7) << 1) - -#define STMPE_TS_NAME "stmpe-ts" -#define XY_MASK 0xfff - -struct stmpe_touch { - struct stmpe *stmpe; - struct input_dev *idev; - struct delayed_work work; - struct device *dev; - u8 sample_time; - u8 mod_12b; - u8 ref_sel; - u8 adc_freq; - u8 ave_ctrl; - u8 touch_det_delay; - u8 settling; - u8 fraction_z; - u8 i_drive; -}; - -static int __stmpe_reset_fifo(struct stmpe *stmpe) -{ - int ret; - - ret = stmpe_set_bits(stmpe, STMPE_REG_FIFO_STA, - STMPE_FIFO_STA_RESET, STMPE_FIFO_STA_RESET); - if (ret) - return ret; - - return stmpe_set_bits(stmpe, STMPE_REG_FIFO_STA, - STMPE_FIFO_STA_RESET, 0); -} - -static void stmpe_work(struct work_struct *work) -{ - int int_sta; - u32 timeout = 40; - - struct stmpe_touch *ts = - container_of(work, struct stmpe_touch, work.work); - - int_sta = stmpe_reg_read(ts->stmpe, STMPE_REG_INT_STA); - - /* - * touch_det sometimes get desasserted or just get stuck. This appears - * to be a silicon bug, We still have to clearify this with the - * manufacture. As a workaround We release the key anyway if the - * touch_det keeps coming in after 4ms, while the FIFO contains no value - * during the whole time. - */ - while ((int_sta & (1 << STMPE_IRQ_TOUCH_DET)) && (timeout > 0)) { - timeout--; - int_sta = stmpe_reg_read(ts->stmpe, STMPE_REG_INT_STA); - udelay(100); - } - - /* reset the FIFO before we report release event */ - __stmpe_reset_fifo(ts->stmpe); - - input_report_abs(ts->idev, ABS_PRESSURE, 0); - input_sync(ts->idev); -} - -static irqreturn_t stmpe_ts_handler(int irq, void *data) -{ - u8 data_set[4]; - int x, y, z; - struct stmpe_touch *ts = data; - - /* - * Cancel scheduled polling for release if we have new value - * available. Wait if the polling is already running. - */ - cancel_delayed_work_sync(&ts->work); - - /* - * The FIFO sometimes just crashes and stops generating interrupts. This - * appears to be a silicon bug. We still have to clearify this with - * the manufacture. As a workaround we disable the TSC while we are - * collecting data and flush the FIFO after reading - */ - stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, - STMPE_TSC_CTRL_TSC_EN, 0); - - stmpe_block_read(ts->stmpe, STMPE_REG_TSC_DATA_XYZ, 4, data_set); - - x = (data_set[0] << 4) | (data_set[1] >> 4); - y = ((data_set[1] & 0xf) << 8) | data_set[2]; - z = data_set[3]; - - input_report_abs(ts->idev, ABS_X, x); - input_report_abs(ts->idev, ABS_Y, y); - input_report_abs(ts->idev, ABS_PRESSURE, z); - input_sync(ts->idev); - - /* flush the FIFO after we have read out our values. */ - __stmpe_reset_fifo(ts->stmpe); - - /* reenable the tsc */ - stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, - STMPE_TSC_CTRL_TSC_EN, STMPE_TSC_CTRL_TSC_EN); - - /* start polling for touch_det to detect release */ - schedule_delayed_work(&ts->work, HZ / 50); - - return IRQ_HANDLED; -} - -static int __devinit stmpe_init_hw(struct stmpe_touch *ts) -{ - int ret; - u8 adc_ctrl1, adc_ctrl1_mask, tsc_cfg, tsc_cfg_mask; - struct stmpe *stmpe = ts->stmpe; - struct device *dev = ts->dev; - - ret = stmpe_enable(stmpe, STMPE_BLOCK_TOUCHSCREEN | STMPE_BLOCK_ADC); - if (ret) { - dev_err(dev, "Could not enable clock for ADC and TS\n"); - return ret; - } - - adc_ctrl1 = SAMPLE_TIME(ts->sample_time) | MOD_12B(ts->mod_12b) | - REF_SEL(ts->ref_sel); - adc_ctrl1_mask = SAMPLE_TIME(0xff) | MOD_12B(0xff) | REF_SEL(0xff); - - ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL1, - adc_ctrl1_mask, adc_ctrl1); - if (ret) { - dev_err(dev, "Could not setup ADC\n"); - return ret; - } - - ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL2, - ADC_FREQ(0xff), ADC_FREQ(ts->adc_freq)); - if (ret) { - dev_err(dev, "Could not setup ADC\n"); - return ret; - } - - tsc_cfg = AVE_CTRL(ts->ave_ctrl) | DET_DELAY(ts->touch_det_delay) | - SETTLING(ts->settling); - tsc_cfg_mask = AVE_CTRL(0xff) | DET_DELAY(0xff) | SETTLING(0xff); - - ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CFG, tsc_cfg_mask, tsc_cfg); - if (ret) { - dev_err(dev, "Could not config touch\n"); - return ret; - } - - ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_FRACTION_Z, - FRACTION_Z(0xff), FRACTION_Z(ts->fraction_z)); - if (ret) { - dev_err(dev, "Could not config touch\n"); - return ret; - } - - ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_I_DRIVE, - I_DRIVE(0xff), I_DRIVE(ts->i_drive)); - if (ret) { - dev_err(dev, "Could not config touch\n"); - return ret; - } - - /* set FIFO to 1 for single point reading */ - ret = stmpe_reg_write(stmpe, STMPE_REG_FIFO_TH, 1); - if (ret) { - dev_err(dev, "Could not set FIFO\n"); - return ret; - } - - ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CTRL, - OP_MODE(0xff), OP_MODE(OP_MOD_XYZ)); - if (ret) { - dev_err(dev, "Could not set mode\n"); - return ret; - } - - return 0; -} - -static int stmpe_ts_open(struct input_dev *dev) -{ - struct stmpe_touch *ts = input_get_drvdata(dev); - int ret = 0; - - ret = __stmpe_reset_fifo(ts->stmpe); - if (ret) - return ret; - - return stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, - STMPE_TSC_CTRL_TSC_EN, STMPE_TSC_CTRL_TSC_EN); -} - -static void stmpe_ts_close(struct input_dev *dev) -{ - struct stmpe_touch *ts = input_get_drvdata(dev); - - cancel_delayed_work_sync(&ts->work); - - stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, - STMPE_TSC_CTRL_TSC_EN, 0); -} - -static int __devinit stmpe_input_probe(struct platform_device *pdev) -{ - struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); - struct stmpe_platform_data *pdata = stmpe->pdata; - struct stmpe_touch *ts; - struct input_dev *idev; - struct stmpe_ts_platform_data *ts_pdata = NULL; - int ret = 0; - int ts_irq; - - ts_irq = platform_get_irq_byname(pdev, "FIFO_TH"); - if (ts_irq < 0) - return ts_irq; - - ts = kzalloc(sizeof(*ts), GFP_KERNEL); - if (!ts) - goto err_out; - - idev = input_allocate_device(); - if (!idev) - goto err_free_ts; - - platform_set_drvdata(pdev, ts); - ts->stmpe = stmpe; - ts->idev = idev; - ts->dev = &pdev->dev; - - if (pdata) - ts_pdata = pdata->ts; - - if (ts_pdata) { - ts->sample_time = ts_pdata->sample_time; - ts->mod_12b = ts_pdata->mod_12b; - ts->ref_sel = ts_pdata->ref_sel; - ts->adc_freq = ts_pdata->adc_freq; - ts->ave_ctrl = ts_pdata->ave_ctrl; - ts->touch_det_delay = ts_pdata->touch_det_delay; - ts->settling = ts_pdata->settling; - ts->fraction_z = ts_pdata->fraction_z; - ts->i_drive = ts_pdata->i_drive; - } - - INIT_DELAYED_WORK(&ts->work, stmpe_work); - - ret = request_threaded_irq(ts_irq, NULL, stmpe_ts_handler, - IRQF_ONESHOT, STMPE_TS_NAME, ts); - if (ret) { - dev_err(&pdev->dev, "Failed to request IRQ %d\n", ts_irq); - goto err_free_input; - } - - ret = stmpe_init_hw(ts); - if (ret) - goto err_free_irq; - - idev->name = STMPE_TS_NAME; - idev->id.bustype = BUS_I2C; - idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); - idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); - - idev->open = stmpe_ts_open; - idev->close = stmpe_ts_close; - - input_set_drvdata(idev, ts); - - input_set_abs_params(idev, ABS_X, 0, XY_MASK, 0, 0); - input_set_abs_params(idev, ABS_Y, 0, XY_MASK, 0, 0); - input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0); - - ret = input_register_device(idev); - if (ret) { - dev_err(&pdev->dev, "Could not register input device\n"); - goto err_free_irq; - } - - return ret; - -err_free_irq: - free_irq(ts_irq, ts); -err_free_input: - input_free_device(idev); - platform_set_drvdata(pdev, NULL); -err_free_ts: - kfree(ts); -err_out: - return ret; -} - -static int __devexit stmpe_ts_remove(struct platform_device *pdev) -{ - struct stmpe_touch *ts = platform_get_drvdata(pdev); - unsigned int ts_irq = platform_get_irq_byname(pdev, "FIFO_TH"); - - stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN); - - free_irq(ts_irq, ts); - - platform_set_drvdata(pdev, NULL); - - input_unregister_device(ts->idev); - input_free_device(ts->idev); - - kfree(ts); - - return 0; -} - -static struct platform_driver stmpe_ts_driver = { - .driver = { - .name = STMPE_TS_NAME, - .owner = THIS_MODULE, - }, - .probe = stmpe_input_probe, - .remove = __devexit_p(stmpe_ts_remove), -}; - -static int __init stmpe_ts_init(void) -{ - return platform_driver_register(&stmpe_ts_driver); -} - -module_init(stmpe_ts_init); - -static void __exit stmpe_ts_exit(void) -{ - platform_driver_unregister(&stmpe_ts_driver); -} - -module_exit(stmpe_ts_exit); - -MODULE_AUTHOR("Luotao Fu "); -MODULE_DESCRIPTION("STMPEXXX touchscreen driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:" STMPE_TS_NAME); diff --git a/trunk/drivers/leds/leds-gpio.c b/trunk/drivers/leds/leds-gpio.c index ea57e05d08f3..cc22eeefa10b 100644 --- a/trunk/drivers/leds/leds-gpio.c +++ b/trunk/drivers/leds/leds-gpio.c @@ -224,7 +224,7 @@ struct gpio_led_of_platform_data { struct gpio_led_data led_data[]; }; -static int __devinit of_gpio_leds_probe(struct platform_device *ofdev, +static int __devinit of_gpio_leds_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node, *child; @@ -283,7 +283,7 @@ static int __devinit of_gpio_leds_probe(struct platform_device *ofdev, return ret; } -static int __devexit of_gpio_leds_remove(struct platform_device *ofdev) +static int __devexit of_gpio_leds_remove(struct of_device *ofdev) { struct gpio_led_of_platform_data *pdata = dev_get_drvdata(&ofdev->dev); int i; diff --git a/trunk/drivers/macintosh/macio_sysfs.c b/trunk/drivers/macintosh/macio_sysfs.c index 8eb40afbd0f5..6024038a5b9d 100644 --- a/trunk/drivers/macintosh/macio_sysfs.c +++ b/trunk/drivers/macintosh/macio_sysfs.c @@ -15,7 +15,7 @@ field##_show (struct device *dev, struct device_attribute *attr, \ static ssize_t compatible_show (struct device *dev, struct device_attribute *attr, char *buf) { - struct platform_device *of; + struct of_device *of; const char *compat; int cplen; int length = 0; @@ -52,9 +52,9 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, static ssize_t devspec_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct platform_device *ofdev; + struct of_device *ofdev; - ofdev = to_platform_device(dev); + ofdev = to_of_device(dev); return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name); } diff --git a/trunk/drivers/macintosh/smu.c b/trunk/drivers/macintosh/smu.c index e58c3d33e035..2506c957712e 100644 --- a/trunk/drivers/macintosh/smu.c +++ b/trunk/drivers/macintosh/smu.c @@ -75,7 +75,7 @@ struct smu_cmd_buf { struct smu_device { spinlock_t lock; struct device_node *of_node; - struct platform_device *of_dev; + struct of_device *of_dev; int doorbell; /* doorbell gpio */ u32 __iomem *db_buf; /* doorbell buffer */ struct device_node *db_node; @@ -645,7 +645,7 @@ static void smu_expose_childs(struct work_struct *unused) static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs); -static int smu_platform_probe(struct platform_device* dev, +static int smu_platform_probe(struct of_device* dev, const struct of_device_id *match) { if (!smu) @@ -695,7 +695,7 @@ static int __init smu_init_sysfs(void) device_initcall(smu_init_sysfs); -struct platform_device *smu_get_ofdev(void) +struct of_device *smu_get_ofdev(void) { if (!smu) return NULL; diff --git a/trunk/drivers/macintosh/therm_adt746x.c b/trunk/drivers/macintosh/therm_adt746x.c index d0d221332db0..c42eeb43042d 100644 --- a/trunk/drivers/macintosh/therm_adt746x.c +++ b/trunk/drivers/macintosh/therm_adt746x.c @@ -84,7 +84,7 @@ struct thermostat { static enum {ADT7460, ADT7467} therm_type; static int therm_bus, therm_address; -static struct platform_device * of_dev; +static struct of_device * of_dev; static struct thermostat* thermostat; static struct task_struct *thread_therm = NULL; diff --git a/trunk/drivers/macintosh/therm_pm72.c b/trunk/drivers/macintosh/therm_pm72.c index 44549272333c..e60605bd0ea9 100644 --- a/trunk/drivers/macintosh/therm_pm72.c +++ b/trunk/drivers/macintosh/therm_pm72.c @@ -148,7 +148,7 @@ * Driver statics */ -static struct platform_device * of_dev; +static struct of_device * of_dev; static struct i2c_adapter * u3_0; static struct i2c_adapter * u3_1; static struct i2c_adapter * k2; @@ -2210,7 +2210,7 @@ static void fcu_lookup_fans(struct device_node *fcu_node) } } -static int fcu_of_probe(struct platform_device* dev, const struct of_device_id *match) +static int fcu_of_probe(struct of_device* dev, const struct of_device_id *match) { state = state_detached; @@ -2221,7 +2221,7 @@ static int fcu_of_probe(struct platform_device* dev, const struct of_device_id * return i2c_add_driver(&therm_pm72_driver); } -static int fcu_of_remove(struct platform_device* dev) +static int fcu_of_remove(struct of_device* dev) { i2c_del_driver(&therm_pm72_driver); diff --git a/trunk/drivers/macintosh/therm_windtunnel.c b/trunk/drivers/macintosh/therm_windtunnel.c index c89f396e4c53..5c9367acf0cf 100644 --- a/trunk/drivers/macintosh/therm_windtunnel.c +++ b/trunk/drivers/macintosh/therm_windtunnel.c @@ -52,7 +52,7 @@ static struct { struct task_struct *poll_task; struct mutex lock; - struct platform_device *of_dev; + struct of_device *of_dev; struct i2c_client *thermostat; struct i2c_client *fan; @@ -322,10 +322,10 @@ do_attach( struct i2c_adapter *adapter ) memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "therm_ds1775", I2C_NAME_SIZE); - i2c_new_probed_device(adapter, &info, scan_ds1775, NULL); + i2c_new_probed_device(adapter, &info, scan_ds1775); strlcpy(info.type, "therm_adm1030", I2C_NAME_SIZE); - i2c_new_probed_device(adapter, &info, scan_adm1030, NULL); + i2c_new_probed_device(adapter, &info, scan_adm1030); if( x.thermostat && x.fan ) { x.running = 1; @@ -444,13 +444,13 @@ static struct i2c_driver g4fan_driver = { /************************************************************************/ static int -therm_of_probe( struct platform_device *dev, const struct of_device_id *match ) +therm_of_probe( struct of_device *dev, const struct of_device_id *match ) { return i2c_add_driver( &g4fan_driver ); } static int -therm_of_remove( struct platform_device *dev ) +therm_of_remove( struct of_device *dev ) { i2c_del_driver( &g4fan_driver ); return 0; diff --git a/trunk/drivers/md/dm-crypt.c b/trunk/drivers/md/dm-crypt.c index 368e8e98f705..3bdbb6115702 100644 --- a/trunk/drivers/md/dm-crypt.c +++ b/trunk/drivers/md/dm-crypt.c @@ -107,10 +107,11 @@ struct crypt_config { struct workqueue_struct *io_queue; struct workqueue_struct *crypt_queue; - char *cipher; - char *cipher_mode; - + /* + * crypto related data + */ struct crypt_iv_operations *iv_gen_ops; + char *iv_mode; union { struct iv_essiv_private essiv; struct iv_benbi_private benbi; @@ -134,6 +135,8 @@ struct crypt_config { unsigned int dmreq_start; struct ablkcipher_request *req; + char cipher[CRYPTO_MAX_ALG_NAME]; + char chainmode[CRYPTO_MAX_ALG_NAME]; struct crypto_ablkcipher *tfm; unsigned long flags; unsigned int key_size; @@ -996,135 +999,82 @@ static int crypt_wipe_key(struct crypt_config *cc) return crypto_ablkcipher_setkey(cc->tfm, cc->key, cc->key_size); } -static void crypt_dtr(struct dm_target *ti) -{ - struct crypt_config *cc = ti->private; - - ti->private = NULL; - - if (!cc) - return; - - if (cc->io_queue) - destroy_workqueue(cc->io_queue); - if (cc->crypt_queue) - destroy_workqueue(cc->crypt_queue); - - if (cc->bs) - bioset_free(cc->bs); - - if (cc->page_pool) - mempool_destroy(cc->page_pool); - if (cc->req_pool) - mempool_destroy(cc->req_pool); - if (cc->io_pool) - mempool_destroy(cc->io_pool); - - if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) - cc->iv_gen_ops->dtr(cc); - - if (cc->tfm && !IS_ERR(cc->tfm)) - crypto_free_ablkcipher(cc->tfm); - - if (cc->dev) - dm_put_device(ti, cc->dev); - - kzfree(cc->cipher); - kzfree(cc->cipher_mode); - - /* Must zero key material before freeing */ - kzfree(cc); -} - -static int crypt_ctr_cipher(struct dm_target *ti, - char *cipher_in, char *key) +/* + * Construct an encryption mapping: + * + */ +static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) { - struct crypt_config *cc = ti->private; - char *tmp, *cipher, *chainmode, *ivmode, *ivopts; - char *cipher_api = NULL; - int ret = -EINVAL; + struct crypt_config *cc; + struct crypto_ablkcipher *tfm; + char *tmp; + char *cipher; + char *chainmode; + char *ivmode; + char *ivopts; + unsigned int key_size; + unsigned long long tmpll; - /* Convert to crypto api definition? */ - if (strchr(cipher_in, '(')) { - ti->error = "Bad cipher specification"; + if (argc != 5) { + ti->error = "Not enough arguments"; return -EINVAL; } - /* - * Legacy dm-crypt cipher specification - * cipher-mode-iv:ivopts - */ - tmp = cipher_in; + tmp = argv[0]; cipher = strsep(&tmp, "-"); - - cc->cipher = kstrdup(cipher, GFP_KERNEL); - if (!cc->cipher) - goto bad_mem; - - if (tmp) { - cc->cipher_mode = kstrdup(tmp, GFP_KERNEL); - if (!cc->cipher_mode) - goto bad_mem; - } - chainmode = strsep(&tmp, "-"); ivopts = strsep(&tmp, "-"); ivmode = strsep(&ivopts, ":"); if (tmp) - DMWARN("Ignoring unexpected additional cipher options"); + DMWARN("Unexpected additional cipher options"); + + key_size = strlen(argv[1]) >> 1; + + cc = kzalloc(sizeof(*cc) + key_size * sizeof(u8), GFP_KERNEL); + if (cc == NULL) { + ti->error = + "Cannot allocate transparent encryption context"; + return -ENOMEM; + } - /* Compatibility mode for old dm-crypt mappings */ - if (!chainmode || (!strcmp(chainmode, "plain") && !ivmode)) { - kfree(cc->cipher_mode); - cc->cipher_mode = kstrdup("cbc-plain", GFP_KERNEL); + /* Compatibility mode for old dm-crypt cipher strings */ + if (!chainmode || (strcmp(chainmode, "plain") == 0 && !ivmode)) { chainmode = "cbc"; ivmode = "plain"; } if (strcmp(chainmode, "ecb") && !ivmode) { - ti->error = "IV mechanism required"; - return -EINVAL; + ti->error = "This chaining mode requires an IV mechanism"; + goto bad_cipher; } - cipher_api = kmalloc(CRYPTO_MAX_ALG_NAME, GFP_KERNEL); - if (!cipher_api) - goto bad_mem; - - ret = snprintf(cipher_api, CRYPTO_MAX_ALG_NAME, - "%s(%s)", chainmode, cipher); - if (ret < 0) { - kfree(cipher_api); - goto bad_mem; + if (snprintf(cc->cipher, CRYPTO_MAX_ALG_NAME, "%s(%s)", + chainmode, cipher) >= CRYPTO_MAX_ALG_NAME) { + ti->error = "Chain mode + cipher name is too long"; + goto bad_cipher; } - /* Allocate cipher */ - cc->tfm = crypto_alloc_ablkcipher(cipher_api, 0, 0); - if (IS_ERR(cc->tfm)) { - ret = PTR_ERR(cc->tfm); + tfm = crypto_alloc_ablkcipher(cc->cipher, 0, 0); + if (IS_ERR(tfm)) { ti->error = "Error allocating crypto tfm"; - goto bad; + goto bad_cipher; } - /* Initialize and set key */ - ret = crypt_set_key(cc, key); - if (ret < 0) { + strcpy(cc->cipher, cipher); + strcpy(cc->chainmode, chainmode); + cc->tfm = tfm; + + if (crypt_set_key(cc, argv[1]) < 0) { ti->error = "Error decoding and setting key"; - goto bad; + goto bad_ivmode; } - /* Initialize IV */ - cc->iv_size = crypto_ablkcipher_ivsize(cc->tfm); - if (cc->iv_size) - /* at least a 64 bit sector number should fit in our buffer */ - cc->iv_size = max(cc->iv_size, - (unsigned int)(sizeof(u64) / sizeof(u8))); - else if (ivmode) { - DMWARN("Selected cipher does not support IVs"); - ivmode = NULL; - } + /* + * Choose ivmode. Valid modes: "plain", "essiv:", "benbi". + * See comments at iv code + */ - /* Choose ivmode, see comments at iv code. */ if (ivmode == NULL) cc->iv_gen_ops = NULL; else if (strcmp(ivmode, "plain") == 0) @@ -1138,138 +1088,159 @@ static int crypt_ctr_cipher(struct dm_target *ti, else if (strcmp(ivmode, "null") == 0) cc->iv_gen_ops = &crypt_iv_null_ops; else { - ret = -EINVAL; ti->error = "Invalid IV mode"; - goto bad; - } - - /* Allocate IV */ - if (cc->iv_gen_ops && cc->iv_gen_ops->ctr) { - ret = cc->iv_gen_ops->ctr(cc, ti, ivopts); - if (ret < 0) { - ti->error = "Error creating IV"; - goto bad; - } - } - - /* Initialize IV (set keys for ESSIV etc) */ - if (cc->iv_gen_ops && cc->iv_gen_ops->init) { - ret = cc->iv_gen_ops->init(cc); - if (ret < 0) { - ti->error = "Error initialising IV"; - goto bad; - } + goto bad_ivmode; } - ret = 0; -bad: - kfree(cipher_api); - return ret; - -bad_mem: - ti->error = "Cannot allocate cipher strings"; - return -ENOMEM; -} + if (cc->iv_gen_ops && cc->iv_gen_ops->ctr && + cc->iv_gen_ops->ctr(cc, ti, ivopts) < 0) + goto bad_ivmode; -/* - * Construct an encryption mapping: - * - */ -static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) -{ - struct crypt_config *cc; - unsigned int key_size; - unsigned long long tmpll; - int ret; - - if (argc != 5) { - ti->error = "Not enough arguments"; - return -EINVAL; + if (cc->iv_gen_ops && cc->iv_gen_ops->init && + cc->iv_gen_ops->init(cc) < 0) { + ti->error = "Error initialising IV"; + goto bad_slab_pool; } - key_size = strlen(argv[1]) >> 1; - - cc = kzalloc(sizeof(*cc) + key_size * sizeof(u8), GFP_KERNEL); - if (!cc) { - ti->error = "Cannot allocate encryption context"; - return -ENOMEM; + cc->iv_size = crypto_ablkcipher_ivsize(tfm); + if (cc->iv_size) + /* at least a 64 bit sector number should fit in our buffer */ + cc->iv_size = max(cc->iv_size, + (unsigned int)(sizeof(u64) / sizeof(u8))); + else { + if (cc->iv_gen_ops) { + DMWARN("Selected cipher does not support IVs"); + if (cc->iv_gen_ops->dtr) + cc->iv_gen_ops->dtr(cc); + cc->iv_gen_ops = NULL; + } } - ti->private = cc; - ret = crypt_ctr_cipher(ti, argv[0], argv[1]); - if (ret < 0) - goto bad; - - ret = -ENOMEM; cc->io_pool = mempool_create_slab_pool(MIN_IOS, _crypt_io_pool); if (!cc->io_pool) { ti->error = "Cannot allocate crypt io mempool"; - goto bad; + goto bad_slab_pool; } cc->dmreq_start = sizeof(struct ablkcipher_request); - cc->dmreq_start += crypto_ablkcipher_reqsize(cc->tfm); + cc->dmreq_start += crypto_ablkcipher_reqsize(tfm); cc->dmreq_start = ALIGN(cc->dmreq_start, crypto_tfm_ctx_alignment()); - cc->dmreq_start += crypto_ablkcipher_alignmask(cc->tfm) & + cc->dmreq_start += crypto_ablkcipher_alignmask(tfm) & ~(crypto_tfm_ctx_alignment() - 1); cc->req_pool = mempool_create_kmalloc_pool(MIN_IOS, cc->dmreq_start + sizeof(struct dm_crypt_request) + cc->iv_size); if (!cc->req_pool) { ti->error = "Cannot allocate crypt request mempool"; - goto bad; + goto bad_req_pool; } cc->req = NULL; cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0); if (!cc->page_pool) { ti->error = "Cannot allocate page mempool"; - goto bad; + goto bad_page_pool; } cc->bs = bioset_create(MIN_IOS, 0); if (!cc->bs) { ti->error = "Cannot allocate crypt bioset"; - goto bad; + goto bad_bs; } - ret = -EINVAL; if (sscanf(argv[2], "%llu", &tmpll) != 1) { ti->error = "Invalid iv_offset sector"; - goto bad; + goto bad_device; } cc->iv_offset = tmpll; - if (dm_get_device(ti, argv[3], dm_table_get_mode(ti->table), &cc->dev)) { - ti->error = "Device lookup failed"; - goto bad; - } - if (sscanf(argv[4], "%llu", &tmpll) != 1) { ti->error = "Invalid device sector"; - goto bad; + goto bad_device; } cc->start = tmpll; - ret = -ENOMEM; + if (dm_get_device(ti, argv[3], dm_table_get_mode(ti->table), &cc->dev)) { + ti->error = "Device lookup failed"; + goto bad_device; + } + + if (ivmode && cc->iv_gen_ops) { + if (ivopts) + *(ivopts - 1) = ':'; + cc->iv_mode = kmalloc(strlen(ivmode) + 1, GFP_KERNEL); + if (!cc->iv_mode) { + ti->error = "Error kmallocing iv_mode string"; + goto bad_ivmode_string; + } + strcpy(cc->iv_mode, ivmode); + } else + cc->iv_mode = NULL; + cc->io_queue = create_singlethread_workqueue("kcryptd_io"); if (!cc->io_queue) { ti->error = "Couldn't create kcryptd io queue"; - goto bad; + goto bad_io_queue; } cc->crypt_queue = create_singlethread_workqueue("kcryptd"); if (!cc->crypt_queue) { ti->error = "Couldn't create kcryptd queue"; - goto bad; + goto bad_crypt_queue; } ti->num_flush_requests = 1; + ti->private = cc; return 0; -bad: - crypt_dtr(ti); - return ret; +bad_crypt_queue: + destroy_workqueue(cc->io_queue); +bad_io_queue: + kfree(cc->iv_mode); +bad_ivmode_string: + dm_put_device(ti, cc->dev); +bad_device: + bioset_free(cc->bs); +bad_bs: + mempool_destroy(cc->page_pool); +bad_page_pool: + mempool_destroy(cc->req_pool); +bad_req_pool: + mempool_destroy(cc->io_pool); +bad_slab_pool: + if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) + cc->iv_gen_ops->dtr(cc); +bad_ivmode: + crypto_free_ablkcipher(tfm); +bad_cipher: + /* Must zero key material before freeing */ + kzfree(cc); + return -EINVAL; +} + +static void crypt_dtr(struct dm_target *ti) +{ + struct crypt_config *cc = (struct crypt_config *) ti->private; + + destroy_workqueue(cc->io_queue); + destroy_workqueue(cc->crypt_queue); + + if (cc->req) + mempool_free(cc->req, cc->req_pool); + + bioset_free(cc->bs); + mempool_destroy(cc->page_pool); + mempool_destroy(cc->req_pool); + mempool_destroy(cc->io_pool); + + kfree(cc->iv_mode); + if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) + cc->iv_gen_ops->dtr(cc); + crypto_free_ablkcipher(cc->tfm); + dm_put_device(ti, cc->dev); + + /* Must zero key material before freeing */ + kzfree(cc); } static int crypt_map(struct dm_target *ti, struct bio *bio, @@ -1284,7 +1255,7 @@ static int crypt_map(struct dm_target *ti, struct bio *bio, return DM_MAPIO_REMAPPED; } - io = crypt_io_alloc(ti, bio, dm_target_offset(ti, bio->bi_sector)); + io = crypt_io_alloc(ti, bio, bio->bi_sector - ti->begin); if (bio_data_dir(io->base_bio) == READ) kcryptd_queue_io(io); @@ -1297,7 +1268,7 @@ static int crypt_map(struct dm_target *ti, struct bio *bio, static int crypt_status(struct dm_target *ti, status_type_t type, char *result, unsigned int maxlen) { - struct crypt_config *cc = ti->private; + struct crypt_config *cc = (struct crypt_config *) ti->private; unsigned int sz = 0; switch (type) { @@ -1306,10 +1277,11 @@ static int crypt_status(struct dm_target *ti, status_type_t type, break; case STATUSTYPE_TABLE: - if (cc->cipher_mode) - DMEMIT("%s-%s ", cc->cipher, cc->cipher_mode); + if (cc->iv_mode) + DMEMIT("%s-%s-%s ", cc->cipher, cc->chainmode, + cc->iv_mode); else - DMEMIT("%s ", cc->cipher); + DMEMIT("%s-%s ", cc->cipher, cc->chainmode); if (cc->key_size > 0) { if ((maxlen - sz) < ((cc->key_size << 1) + 1)) @@ -1406,7 +1378,7 @@ static int crypt_merge(struct dm_target *ti, struct bvec_merge_data *bvm, return max_size; bvm->bi_bdev = cc->dev->bdev; - bvm->bi_sector = cc->start + dm_target_offset(ti, bvm->bi_sector); + bvm->bi_sector = cc->start + bvm->bi_sector - ti->begin; return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); } diff --git a/trunk/drivers/md/dm-delay.c b/trunk/drivers/md/dm-delay.c index baa11912cc94..852052880d7a 100644 --- a/trunk/drivers/md/dm-delay.c +++ b/trunk/drivers/md/dm-delay.c @@ -198,7 +198,6 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv) atomic_set(&dc->may_delay, 1); ti->num_flush_requests = 1; - ti->num_discard_requests = 1; ti->private = dc; return 0; @@ -282,13 +281,14 @@ static int delay_map(struct dm_target *ti, struct bio *bio, bio->bi_bdev = dc->dev_write->bdev; if (bio_sectors(bio)) bio->bi_sector = dc->start_write + - dm_target_offset(ti, bio->bi_sector); + (bio->bi_sector - ti->begin); return delay_bio(dc, dc->write_delay, bio); } bio->bi_bdev = dc->dev_read->bdev; - bio->bi_sector = dc->start_read + dm_target_offset(ti, bio->bi_sector); + bio->bi_sector = dc->start_read + + (bio->bi_sector - ti->begin); return delay_bio(dc, dc->read_delay, bio); } diff --git a/trunk/drivers/md/dm-exception-store.c b/trunk/drivers/md/dm-exception-store.c index 0bdb201c2c2a..2b7907b6dd09 100644 --- a/trunk/drivers/md/dm-exception-store.c +++ b/trunk/drivers/md/dm-exception-store.c @@ -173,9 +173,7 @@ int dm_exception_store_set_chunk_size(struct dm_exception_store *store, /* Validate the chunk size against the device block size */ if (chunk_size % - (bdev_logical_block_size(dm_snap_cow(store->snap)->bdev) >> 9) || - chunk_size % - (bdev_logical_block_size(dm_snap_origin(store->snap)->bdev) >> 9)) { + (bdev_logical_block_size(dm_snap_cow(store->snap)->bdev) >> 9)) { *error = "Chunk size is not a multiple of device blocksize"; return -EINVAL; } diff --git a/trunk/drivers/md/dm-exception-store.h b/trunk/drivers/md/dm-exception-store.h index 0b2536247cf5..e8dfa06af3ba 100644 --- a/trunk/drivers/md/dm-exception-store.h +++ b/trunk/drivers/md/dm-exception-store.h @@ -126,9 +126,8 @@ struct dm_exception_store { }; /* - * Obtain the origin or cow device used by a given snapshot. + * Obtain the cow device used by a given snapshot. */ -struct dm_dev *dm_snap_origin(struct dm_snapshot *snap); struct dm_dev *dm_snap_cow(struct dm_snapshot *snap); /* diff --git a/trunk/drivers/md/dm-ioctl.c b/trunk/drivers/md/dm-ioctl.c index 3e39193e5036..d7500e1c26f2 100644 --- a/trunk/drivers/md/dm-ioctl.c +++ b/trunk/drivers/md/dm-ioctl.c @@ -249,66 +249,55 @@ static void __hash_remove(struct hash_cell *hc) static void dm_hash_remove_all(int keep_open_devices) { - int i, dev_skipped; + int i, dev_skipped, dev_removed; struct hash_cell *hc; - struct mapped_device *md; - -retry: - dev_skipped = 0; + struct list_head *tmp, *n; down_write(&_hash_lock); +retry: + dev_skipped = dev_removed = 0; for (i = 0; i < NUM_BUCKETS; i++) { - list_for_each_entry(hc, _name_buckets + i, name_list) { - md = hc->md; - dm_get(md); + list_for_each_safe (tmp, n, _name_buckets + i) { + hc = list_entry(tmp, struct hash_cell, name_list); - if (keep_open_devices && dm_lock_for_deletion(md)) { - dm_put(md); + if (keep_open_devices && + dm_lock_for_deletion(hc->md)) { dev_skipped++; continue; } - __hash_remove(hc); - - up_write(&_hash_lock); - - dm_put(md); - if (likely(keep_open_devices)) - dm_destroy(md); - else - dm_destroy_immediate(md); - - /* - * Some mapped devices may be using other mapped - * devices, so repeat until we make no further - * progress. If a new mapped device is created - * here it will also get removed. - */ - goto retry; + dev_removed = 1; } } - up_write(&_hash_lock); + /* + * Some mapped devices may be using other mapped devices, so if any + * still exist, repeat until we make no further progress. + */ + if (dev_skipped) { + if (dev_removed) + goto retry; - if (dev_skipped) DMWARN("remove_all left %d open device(s)", dev_skipped); + } + + up_write(&_hash_lock); } -static struct mapped_device *dm_hash_rename(struct dm_ioctl *param, - const char *new) +static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old, + const char *new) { char *new_name, *old_name; struct hash_cell *hc; struct dm_table *table; - struct mapped_device *md; /* * duplicate new. */ new_name = kstrdup(new, GFP_KERNEL); if (!new_name) - return ERR_PTR(-ENOMEM); + return -ENOMEM; down_write(&_hash_lock); @@ -317,24 +306,24 @@ static struct mapped_device *dm_hash_rename(struct dm_ioctl *param, */ hc = __get_name_cell(new); if (hc) { - DMWARN("asked to rename to an already-existing name %s -> %s", - param->name, new); + DMWARN("asked to rename to an already existing name %s -> %s", + old, new); dm_put(hc->md); up_write(&_hash_lock); kfree(new_name); - return ERR_PTR(-EBUSY); + return -EBUSY; } /* * Is there such a device as 'old' ? */ - hc = __get_name_cell(param->name); + hc = __get_name_cell(old); if (!hc) { - DMWARN("asked to rename a non-existent device %s -> %s", - param->name, new); + DMWARN("asked to rename a non existent device %s -> %s", + old, new); up_write(&_hash_lock); kfree(new_name); - return ERR_PTR(-ENXIO); + return -ENXIO; } /* @@ -356,14 +345,13 @@ static struct mapped_device *dm_hash_rename(struct dm_ioctl *param, dm_table_put(table); } - if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, param->event_nr)) - param->flags |= DM_UEVENT_GENERATED_FLAG; + if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, cookie)) + *flags |= DM_UEVENT_GENERATED_FLAG; - md = hc->md; + dm_put(hc->md); up_write(&_hash_lock); kfree(old_name); - - return md; + return 0; } /*----------------------------------------------------------------- @@ -585,7 +573,7 @@ static struct dm_table *dm_get_live_or_inactive_table(struct mapped_device *md, * Fills in a dm_ioctl structure, ready for sending back to * userland. */ -static void __dev_status(struct mapped_device *md, struct dm_ioctl *param) +static int __dev_status(struct mapped_device *md, struct dm_ioctl *param) { struct gendisk *disk = dm_disk(md); struct dm_table *table; @@ -629,6 +617,8 @@ static void __dev_status(struct mapped_device *md, struct dm_ioctl *param) dm_table_put(table); } } + + return 0; } static int dev_create(struct dm_ioctl *param, size_t param_size) @@ -650,17 +640,15 @@ static int dev_create(struct dm_ioctl *param, size_t param_size) r = dm_hash_insert(param->name, *param->uuid ? param->uuid : NULL, md); if (r) { dm_put(md); - dm_destroy(md); return r; } param->flags &= ~DM_INACTIVE_PRESENT_FLAG; - __dev_status(md, param); - + r = __dev_status(md, param); dm_put(md); - return 0; + return r; } /* @@ -754,7 +742,6 @@ static int dev_remove(struct dm_ioctl *param, size_t param_size) param->flags |= DM_UEVENT_GENERATED_FLAG; dm_put(md); - dm_destroy(md); return 0; } @@ -775,7 +762,6 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size) { int r; char *new_name = (char *) param + param->data_start; - struct mapped_device *md; if (new_name < param->data || invalid_str(new_name, (void *) param + param_size) || @@ -788,14 +774,10 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size) if (r) return r; - md = dm_hash_rename(param, new_name); - if (IS_ERR(md)) - return PTR_ERR(md); - - __dev_status(md, param); - dm_put(md); + param->data_size = 0; - return 0; + return dm_hash_rename(param->event_nr, ¶m->flags, param->name, + new_name); } static int dev_set_geometry(struct dm_ioctl *param, size_t param_size) @@ -836,6 +818,8 @@ static int dev_set_geometry(struct dm_ioctl *param, size_t param_size) geometry.start = indata[3]; r = dm_set_geometry(md, &geometry); + if (!r) + r = __dev_status(md, param); param->data_size = 0; @@ -859,17 +843,13 @@ static int do_suspend(struct dm_ioctl *param) if (param->flags & DM_NOFLUSH_FLAG) suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG; - if (!dm_suspended_md(md)) { + if (!dm_suspended_md(md)) r = dm_suspend(md, suspend_flags); - if (r) - goto out; - } - __dev_status(md, param); + if (!r) + r = __dev_status(md, param); -out: dm_put(md); - return r; } @@ -931,7 +911,7 @@ static int do_resume(struct dm_ioctl *param) dm_table_destroy(old_map); if (!r) - __dev_status(md, param); + r = __dev_status(md, param); dm_put(md); return r; @@ -955,16 +935,16 @@ static int dev_suspend(struct dm_ioctl *param, size_t param_size) */ static int dev_status(struct dm_ioctl *param, size_t param_size) { + int r; struct mapped_device *md; md = find_device(param); if (!md) return -ENXIO; - __dev_status(md, param); + r = __dev_status(md, param); dm_put(md); - - return 0; + return r; } /* @@ -1039,7 +1019,7 @@ static void retrieve_status(struct dm_table *table, */ static int dev_wait(struct dm_ioctl *param, size_t param_size) { - int r = 0; + int r; struct mapped_device *md; struct dm_table *table; @@ -1060,7 +1040,9 @@ static int dev_wait(struct dm_ioctl *param, size_t param_size) * changed to trigger the event, so we may as well tell * him and save an ioctl. */ - __dev_status(md, param); + r = __dev_status(md, param); + if (r) + goto out; table = dm_get_live_or_inactive_table(md, param); if (table) { @@ -1068,9 +1050,8 @@ static int dev_wait(struct dm_ioctl *param, size_t param_size) dm_table_put(table); } -out: + out: dm_put(md); - return r; } @@ -1131,9 +1112,28 @@ static int populate_table(struct dm_table *table, next = spec->next; } + r = dm_table_set_type(table); + if (r) { + DMWARN("unable to set table type"); + return r; + } + return dm_table_complete(table); } +static int table_prealloc_integrity(struct dm_table *t, + struct mapped_device *md) +{ + struct list_head *devices = dm_table_get_devices(t); + struct dm_dev_internal *dd; + + list_for_each_entry(dd, devices, list) + if (bdev_get_integrity(dd->dm_dev.bdev)) + return blk_integrity_register(dm_disk(md), NULL); + + return 0; +} + static int table_load(struct dm_ioctl *param, size_t param_size) { int r; @@ -1155,30 +1155,21 @@ static int table_load(struct dm_ioctl *param, size_t param_size) goto out; } - /* Protect md->type and md->queue against concurrent table loads. */ - dm_lock_md_type(md); - if (dm_get_md_type(md) == DM_TYPE_NONE) - /* Initial table load: acquire type of table. */ - dm_set_md_type(md, dm_table_get_type(t)); - else if (dm_get_md_type(md) != dm_table_get_type(t)) { - DMWARN("can't change device type after initial table load."); + r = table_prealloc_integrity(t, md); + if (r) { + DMERR("%s: could not register integrity profile.", + dm_device_name(md)); dm_table_destroy(t); - dm_unlock_md_type(md); - r = -EINVAL; goto out; } - /* setup md->queue to reflect md's type (may block) */ - r = dm_setup_md_queue(md); + r = dm_table_alloc_md_mempools(t); if (r) { - DMWARN("unable to set up device queue for new table."); + DMWARN("unable to allocate mempools for this table"); dm_table_destroy(t); - dm_unlock_md_type(md); goto out; } - dm_unlock_md_type(md); - /* stage inactive table */ down_write(&_hash_lock); hc = dm_get_mdptr(md); if (!hc || hc->md != md) { @@ -1195,7 +1186,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size) up_write(&_hash_lock); param->flags |= DM_INACTIVE_PRESENT_FLAG; - __dev_status(md, param); + r = __dev_status(md, param); out: dm_put(md); @@ -1205,6 +1196,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size) static int table_clear(struct dm_ioctl *param, size_t param_size) { + int r; struct hash_cell *hc; struct mapped_device *md; @@ -1224,12 +1216,11 @@ static int table_clear(struct dm_ioctl *param, size_t param_size) param->flags &= ~DM_INACTIVE_PRESENT_FLAG; - __dev_status(hc->md, param); + r = __dev_status(hc->md, param); md = hc->md; up_write(&_hash_lock); dm_put(md); - - return 0; + return r; } /* @@ -1274,6 +1265,7 @@ static void retrieve_deps(struct dm_table *table, static int table_deps(struct dm_ioctl *param, size_t param_size) { + int r = 0; struct mapped_device *md; struct dm_table *table; @@ -1281,7 +1273,9 @@ static int table_deps(struct dm_ioctl *param, size_t param_size) if (!md) return -ENXIO; - __dev_status(md, param); + r = __dev_status(md, param); + if (r) + goto out; table = dm_get_live_or_inactive_table(md, param); if (table) { @@ -1289,9 +1283,9 @@ static int table_deps(struct dm_ioctl *param, size_t param_size) dm_table_put(table); } + out: dm_put(md); - - return 0; + return r; } /* @@ -1300,6 +1294,7 @@ static int table_deps(struct dm_ioctl *param, size_t param_size) */ static int table_status(struct dm_ioctl *param, size_t param_size) { + int r; struct mapped_device *md; struct dm_table *table; @@ -1307,7 +1302,9 @@ static int table_status(struct dm_ioctl *param, size_t param_size) if (!md) return -ENXIO; - __dev_status(md, param); + r = __dev_status(md, param); + if (r) + goto out; table = dm_get_live_or_inactive_table(md, param); if (table) { @@ -1315,9 +1312,9 @@ static int table_status(struct dm_ioctl *param, size_t param_size) dm_table_put(table); } +out: dm_put(md); - - return 0; + return r; } /* @@ -1336,6 +1333,10 @@ static int target_message(struct dm_ioctl *param, size_t param_size) if (!md) return -ENXIO; + r = __dev_status(md, param); + if (r) + goto out; + if (tmsg < (struct dm_target_msg *) param->data || invalid_str(tmsg->message, (void *) param + param_size)) { DMWARN("Invalid target message parameters."); @@ -1592,22 +1593,18 @@ static long dm_compat_ctl_ioctl(struct file *file, uint command, ulong u) #endif static const struct file_operations _ctl_fops = { - .open = nonseekable_open, .unlocked_ioctl = dm_ctl_ioctl, .compat_ioctl = dm_compat_ctl_ioctl, .owner = THIS_MODULE, }; static struct miscdevice _dm_misc = { - .minor = MAPPER_CTRL_MINOR, + .minor = MISC_DYNAMIC_MINOR, .name = DM_NAME, - .nodename = DM_DIR "/" DM_CONTROL_NODE, + .nodename = "mapper/control", .fops = &_ctl_fops }; -MODULE_ALIAS_MISCDEV(MAPPER_CTRL_MINOR); -MODULE_ALIAS("devname:" DM_DIR "/" DM_CONTROL_NODE); - /* * Create misc character device and link to DM_DIR/control. */ diff --git a/trunk/drivers/md/dm-linear.c b/trunk/drivers/md/dm-linear.c index 3921e3bb43c1..9200dbf2391a 100644 --- a/trunk/drivers/md/dm-linear.c +++ b/trunk/drivers/md/dm-linear.c @@ -53,7 +53,6 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) } ti->num_flush_requests = 1; - ti->num_discard_requests = 1; ti->private = lc; return 0; @@ -74,7 +73,7 @@ static sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector) { struct linear_c *lc = ti->private; - return lc->start + dm_target_offset(ti, bi_sector); + return lc->start + (bi_sector - ti->begin); } static void linear_map_bio(struct dm_target *ti, struct bio *bio) diff --git a/trunk/drivers/md/dm-mpath.c b/trunk/drivers/md/dm-mpath.c index 487ecda90ad4..826bce7343b3 100644 --- a/trunk/drivers/md/dm-mpath.c +++ b/trunk/drivers/md/dm-mpath.c @@ -706,7 +706,6 @@ static struct priority_group *parse_priority_group(struct arg_set *as, if (as->argc < nr_params) { ti->error = "not enough path parameters"; - r = -EINVAL; goto bad; } @@ -893,7 +892,6 @@ static int multipath_ctr(struct dm_target *ti, unsigned int argc, } ti->num_flush_requests = 1; - ti->num_discard_requests = 1; return 0; @@ -1273,15 +1271,6 @@ static int do_end_io(struct multipath *m, struct request *clone, if (error == -EOPNOTSUPP) return error; - if (clone->cmd_flags & REQ_DISCARD) - /* - * Pass all discard request failures up. - * FIXME: only fail_path if the discard failed due to a - * transport problem. This requires precise understanding - * of the underlying failure (e.g. the SCSI sense). - */ - return error; - if (mpio->pgpath) fail_path(mpio->pgpath); diff --git a/trunk/drivers/md/dm-raid1.c b/trunk/drivers/md/dm-raid1.c index 7c081bcbc3cf..74136262d654 100644 --- a/trunk/drivers/md/dm-raid1.c +++ b/trunk/drivers/md/dm-raid1.c @@ -445,7 +445,7 @@ static sector_t map_sector(struct mirror *m, struct bio *bio) { if (unlikely(!bio->bi_size)) return 0; - return m->offset + dm_target_offset(m->ms->ti, bio->bi_sector); + return m->offset + (bio->bi_sector - m->ms->ti->begin); } static void map_bio(struct mirror *m, struct bio *bio) diff --git a/trunk/drivers/md/dm-snap-persistent.c b/trunk/drivers/md/dm-snap-persistent.c index cc2bdb83f9ad..c097d8a4823d 100644 --- a/trunk/drivers/md/dm-snap-persistent.c +++ b/trunk/drivers/md/dm-snap-persistent.c @@ -266,7 +266,7 @@ static int chunk_io(struct pstore *ps, void *area, chunk_t chunk, int rw, */ static chunk_t area_location(struct pstore *ps, chunk_t area) { - return NUM_SNAPSHOT_HDR_CHUNKS + ((ps->exceptions_per_area + 1) * area); + return 1 + ((ps->exceptions_per_area + 1) * area); } /* @@ -780,8 +780,8 @@ static int persistent_commit_merge(struct dm_exception_store *store, * ps->current_area does not get reduced by prepare_merge() until * after commit_merge() has removed the nr_merged previous exceptions. */ - ps->next_free = area_location(ps, ps->current_area) + - ps->current_committed + 1; + ps->next_free = (area_location(ps, ps->current_area) - 1) + + (ps->current_committed + 1) + NUM_SNAPSHOT_HDR_CHUNKS; return 0; } diff --git a/trunk/drivers/md/dm-snap.c b/trunk/drivers/md/dm-snap.c index 5974d3094d97..54853773510c 100644 --- a/trunk/drivers/md/dm-snap.c +++ b/trunk/drivers/md/dm-snap.c @@ -148,12 +148,6 @@ struct dm_snapshot { #define RUNNING_MERGE 0 #define SHUTDOWN_MERGE 1 -struct dm_dev *dm_snap_origin(struct dm_snapshot *s) -{ - return s->origin; -} -EXPORT_SYMBOL(dm_snap_origin); - struct dm_dev *dm_snap_cow(struct dm_snapshot *s) { return s->cow; @@ -1071,6 +1065,10 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) origin_mode = FMODE_WRITE; } + origin_path = argv[0]; + argv++; + argc--; + s = kmalloc(sizeof(*s), GFP_KERNEL); if (!s) { ti->error = "Cannot allocate snapshot context private " @@ -1079,16 +1077,6 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) goto bad; } - origin_path = argv[0]; - argv++; - argc--; - - r = dm_get_device(ti, origin_path, origin_mode, &s->origin); - if (r) { - ti->error = "Cannot get origin device"; - goto bad_origin; - } - cow_path = argv[0]; argv++; argc--; @@ -1109,6 +1097,12 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) argv += args_used; argc -= args_used; + r = dm_get_device(ti, origin_path, origin_mode, &s->origin); + if (r) { + ti->error = "Cannot get origin device"; + goto bad_origin; + } + s->ti = ti; s->valid = 1; s->active = 0; @@ -1218,15 +1212,15 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) dm_exception_table_exit(&s->complete, exception_cache); bad_hash_tables: + dm_put_device(ti, s->origin); + +bad_origin: dm_exception_store_destroy(s->store); bad_store: dm_put_device(ti, s->cow); bad_cow: - dm_put_device(ti, s->origin); - -bad_origin: kfree(s); bad: @@ -1320,12 +1314,12 @@ static void snapshot_dtr(struct dm_target *ti) mempool_destroy(s->pending_pool); + dm_put_device(ti, s->origin); + dm_exception_store_destroy(s->store); dm_put_device(ti, s->cow); - dm_put_device(ti, s->origin); - kfree(s); } @@ -1692,7 +1686,7 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio, chunk_t chunk; if (unlikely(bio_empty_barrier(bio))) { - if (!map_context->target_request_nr) + if (!map_context->flush_request) bio->bi_bdev = s->origin->bdev; else bio->bi_bdev = s->cow->bdev; @@ -1905,14 +1899,8 @@ static int snapshot_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn, void *data) { struct dm_snapshot *snap = ti->private; - int r; - - r = fn(ti, snap->origin, 0, ti->len, data); - - if (!r) - r = fn(ti, snap->cow, 0, get_dev_size(snap->cow->bdev), data); - return r; + return fn(ti, snap->origin, 0, ti->len, data); } @@ -2171,21 +2159,6 @@ static int origin_status(struct dm_target *ti, status_type_t type, char *result, return 0; } -static int origin_merge(struct dm_target *ti, struct bvec_merge_data *bvm, - struct bio_vec *biovec, int max_size) -{ - struct dm_dev *dev = ti->private; - struct request_queue *q = bdev_get_queue(dev->bdev); - - if (!q->merge_bvec_fn) - return max_size; - - bvm->bi_bdev = dev->bdev; - bvm->bi_sector = bvm->bi_sector; - - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); -} - static int origin_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn, void *data) { @@ -2203,7 +2176,6 @@ static struct target_type origin_target = { .map = origin_map, .resume = origin_resume, .status = origin_status, - .merge = origin_merge, .iterate_devices = origin_iterate_devices, }; diff --git a/trunk/drivers/md/dm-stripe.c b/trunk/drivers/md/dm-stripe.c index c297f6da91ea..d6e28d732b4d 100644 --- a/trunk/drivers/md/dm-stripe.c +++ b/trunk/drivers/md/dm-stripe.c @@ -25,8 +25,6 @@ struct stripe { struct stripe_c { uint32_t stripes; - int stripes_shift; - sector_t stripes_mask; /* The size of this target / num. stripes */ sector_t stripe_width; @@ -164,22 +162,16 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) /* Set pointer to dm target; used in trigger_event */ sc->ti = ti; + sc->stripes = stripes; sc->stripe_width = width; - - if (stripes & (stripes - 1)) - sc->stripes_shift = -1; - else { - sc->stripes_shift = ffs(stripes) - 1; - sc->stripes_mask = ((sector_t) stripes) - 1; - } - ti->split_io = chunk_size; ti->num_flush_requests = stripes; - ti->num_discard_requests = stripes; - sc->chunk_shift = ffs(chunk_size) - 1; sc->chunk_mask = ((sector_t) chunk_size) - 1; + for (sc->chunk_shift = 0; chunk_size; sc->chunk_shift++) + chunk_size >>= 1; + sc->chunk_shift--; /* * Get the stripe destinations. @@ -215,79 +207,26 @@ static void stripe_dtr(struct dm_target *ti) kfree(sc); } -static void stripe_map_sector(struct stripe_c *sc, sector_t sector, - uint32_t *stripe, sector_t *result) -{ - sector_t offset = dm_target_offset(sc->ti, sector); - sector_t chunk = offset >> sc->chunk_shift; - - if (sc->stripes_shift < 0) - *stripe = sector_div(chunk, sc->stripes); - else { - *stripe = chunk & sc->stripes_mask; - chunk >>= sc->stripes_shift; - } - - *result = (chunk << sc->chunk_shift) | (offset & sc->chunk_mask); -} - -static void stripe_map_range_sector(struct stripe_c *sc, sector_t sector, - uint32_t target_stripe, sector_t *result) -{ - uint32_t stripe; - - stripe_map_sector(sc, sector, &stripe, result); - if (stripe == target_stripe) - return; - *result &= ~sc->chunk_mask; /* round down */ - if (target_stripe < stripe) - *result += sc->chunk_mask + 1; /* next chunk */ -} - -static int stripe_map_discard(struct stripe_c *sc, struct bio *bio, - uint32_t target_stripe) -{ - sector_t begin, end; - - stripe_map_range_sector(sc, bio->bi_sector, target_stripe, &begin); - stripe_map_range_sector(sc, bio->bi_sector + bio_sectors(bio), - target_stripe, &end); - if (begin < end) { - bio->bi_bdev = sc->stripe[target_stripe].dev->bdev; - bio->bi_sector = begin + sc->stripe[target_stripe].physical_start; - bio->bi_size = to_bytes(end - begin); - return DM_MAPIO_REMAPPED; - } else { - /* The range doesn't map to the target stripe */ - bio_endio(bio, 0); - return DM_MAPIO_SUBMITTED; - } -} - static int stripe_map(struct dm_target *ti, struct bio *bio, union map_info *map_context) { - struct stripe_c *sc = ti->private; + struct stripe_c *sc = (struct stripe_c *) ti->private; + sector_t offset, chunk; uint32_t stripe; - unsigned target_request_nr; if (unlikely(bio_empty_barrier(bio))) { - target_request_nr = map_context->target_request_nr; - BUG_ON(target_request_nr >= sc->stripes); - bio->bi_bdev = sc->stripe[target_request_nr].dev->bdev; + BUG_ON(map_context->flush_request >= sc->stripes); + bio->bi_bdev = sc->stripe[map_context->flush_request].dev->bdev; return DM_MAPIO_REMAPPED; } - if (unlikely(bio->bi_rw & REQ_DISCARD)) { - target_request_nr = map_context->target_request_nr; - BUG_ON(target_request_nr >= sc->stripes); - return stripe_map_discard(sc, bio, target_request_nr); - } - stripe_map_sector(sc, bio->bi_sector, &stripe, &bio->bi_sector); + offset = bio->bi_sector - ti->begin; + chunk = offset >> sc->chunk_shift; + stripe = sector_div(chunk, sc->stripes); - bio->bi_sector += sc->stripe[stripe].physical_start; bio->bi_bdev = sc->stripe[stripe].dev->bdev; - + bio->bi_sector = sc->stripe[stripe].physical_start + + (chunk << sc->chunk_shift) + (offset & sc->chunk_mask); return DM_MAPIO_REMAPPED; } diff --git a/trunk/drivers/md/dm-table.c b/trunk/drivers/md/dm-table.c index f9fc07d7a4b9..9924ea23032d 100644 --- a/trunk/drivers/md/dm-table.c +++ b/trunk/drivers/md/dm-table.c @@ -54,8 +54,6 @@ struct dm_table { sector_t *highs; struct dm_target *targets; - unsigned discards_supported:1; - /* * Indicates the rw permissions for the new logical * device. This should be a combination of FMODE_READ @@ -205,7 +203,6 @@ int dm_table_create(struct dm_table **result, fmode_t mode, INIT_LIST_HEAD(&t->devices); atomic_set(&t->holders, 0); - t->discards_supported = 1; if (!num_targets) num_targets = KEYS_PER_NODE; @@ -248,7 +245,7 @@ void dm_table_destroy(struct dm_table *t) msleep(1); smp_mb(); - /* free the indexes */ + /* free the indexes (see dm_table_complete) */ if (t->depth >= 2) vfree(t->index[t->depth - 2]); @@ -773,9 +770,6 @@ int dm_table_add_target(struct dm_table *t, const char *type, t->highs[t->num_targets++] = tgt->begin + tgt->len - 1; - if (!tgt->num_discard_requests) - t->discards_supported = 0; - return 0; bad: @@ -784,7 +778,7 @@ int dm_table_add_target(struct dm_table *t, const char *type, return r; } -static int dm_table_set_type(struct dm_table *t) +int dm_table_set_type(struct dm_table *t) { unsigned i; unsigned bio_based = 0, request_based = 0; @@ -906,7 +900,7 @@ static int setup_indexes(struct dm_table *t) /* * Builds the btree to index the map. */ -static int dm_table_build_index(struct dm_table *t) +int dm_table_complete(struct dm_table *t) { int r = 0; unsigned int leaf_nodes; @@ -925,55 +919,6 @@ static int dm_table_build_index(struct dm_table *t) return r; } -/* - * Register the mapped device for blk_integrity support if - * the underlying devices support it. - */ -static int dm_table_prealloc_integrity(struct dm_table *t, struct mapped_device *md) -{ - struct list_head *devices = dm_table_get_devices(t); - struct dm_dev_internal *dd; - - list_for_each_entry(dd, devices, list) - if (bdev_get_integrity(dd->dm_dev.bdev)) - return blk_integrity_register(dm_disk(md), NULL); - - return 0; -} - -/* - * Prepares the table for use by building the indices, - * setting the type, and allocating mempools. - */ -int dm_table_complete(struct dm_table *t) -{ - int r; - - r = dm_table_set_type(t); - if (r) { - DMERR("unable to set table type"); - return r; - } - - r = dm_table_build_index(t); - if (r) { - DMERR("unable to build btrees"); - return r; - } - - r = dm_table_prealloc_integrity(t, t->md); - if (r) { - DMERR("could not register integrity profile."); - return r; - } - - r = dm_table_alloc_md_mempools(t); - if (r) - DMERR("unable to allocate mempools"); - - return r; -} - static DEFINE_MUTEX(_event_lock); void dm_table_event_callback(struct dm_table *t, void (*fn)(void *), void *context) @@ -1141,11 +1086,6 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, else queue_flag_set_unlocked(QUEUE_FLAG_CLUSTER, q); - if (!dm_table_supports_discards(t)) - queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q); - else - queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); - dm_table_set_integrity(t); /* @@ -1292,39 +1232,6 @@ struct mapped_device *dm_table_get_md(struct dm_table *t) return t->md; } -static int device_discard_capable(struct dm_target *ti, struct dm_dev *dev, - sector_t start, sector_t len, void *data) -{ - struct request_queue *q = bdev_get_queue(dev->bdev); - - return q && blk_queue_discard(q); -} - -bool dm_table_supports_discards(struct dm_table *t) -{ - struct dm_target *ti; - unsigned i = 0; - - if (!t->discards_supported) - return 0; - - /* - * Ensure that at least one underlying device supports discards. - * t->devices includes internal dm devices such as mirror logs - * so we need to use iterate_devices here, which targets - * supporting discard must provide. - */ - while (i < dm_table_get_num_targets(t)) { - ti = dm_table_get_target(t, i++); - - if (ti->type->iterate_devices && - ti->type->iterate_devices(ti, device_discard_capable, NULL)) - return 1; - } - - return 0; -} - EXPORT_SYMBOL(dm_vcalloc); EXPORT_SYMBOL(dm_get_device); EXPORT_SYMBOL(dm_put_device); diff --git a/trunk/drivers/md/dm-target.c b/trunk/drivers/md/dm-target.c index 8da366cf381c..11dea11dc0b6 100644 --- a/trunk/drivers/md/dm-target.c +++ b/trunk/drivers/md/dm-target.c @@ -113,11 +113,6 @@ void dm_unregister_target(struct target_type *tt) */ static int io_err_ctr(struct dm_target *tt, unsigned int argc, char **args) { - /* - * Return error for discards instead of -EOPNOTSUPP - */ - tt->num_discard_requests = 1; - return 0; } diff --git a/trunk/drivers/md/dm-zero.c b/trunk/drivers/md/dm-zero.c index cc2b3cb81946..bbc97030c0c2 100644 --- a/trunk/drivers/md/dm-zero.c +++ b/trunk/drivers/md/dm-zero.c @@ -22,11 +22,6 @@ static int zero_ctr(struct dm_target *ti, unsigned int argc, char **argv) return -EINVAL; } - /* - * Silently drop discards, avoiding -EOPNOTSUPP. - */ - ti->num_discard_requests = 1; - return 0; } diff --git a/trunk/drivers/md/dm.c b/trunk/drivers/md/dm.c index ac384b2a6a33..a3f21dc02bd8 100644 --- a/trunk/drivers/md/dm.c +++ b/trunk/drivers/md/dm.c @@ -20,7 +20,6 @@ #include #include #include -#include #include @@ -125,10 +124,6 @@ struct mapped_device { unsigned long flags; struct request_queue *queue; - unsigned type; - /* Protect queue and type against concurrent access. */ - struct mutex type_lock; - struct gendisk *disk; char name[16]; @@ -643,14 +638,8 @@ static void dec_pending(struct dm_io *io, int error) * There can be just one barrier request so we use * a per-device variable for error reporting. * Note that you can't touch the bio after end_io_acct - * - * We ignore -EOPNOTSUPP for empty flush reported by - * underlying devices. We assume that if the device - * doesn't support empty barriers, it doesn't need - * cache flushing commands. */ - if (!md->barrier_error && - !(bio_empty_barrier(bio) && io_error == -EOPNOTSUPP)) + if (!md->barrier_error && io_error != -EOPNOTSUPP) md->barrier_error = io_error; end_io_acct(io); free_io(md, io); @@ -1030,27 +1019,17 @@ static void end_clone_request(struct request *clone, int error) dm_complete_request(clone, error); } -/* - * Return maximum size of I/O possible at the supplied sector up to the current - * target boundary. - */ -static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti) -{ - sector_t target_offset = dm_target_offset(ti, sector); - - return ti->len - target_offset; -} - -static sector_t max_io_len(sector_t sector, struct dm_target *ti) +static sector_t max_io_len(struct mapped_device *md, + sector_t sector, struct dm_target *ti) { - sector_t len = max_io_len_target_boundary(sector, ti); + sector_t offset = sector - ti->begin; + sector_t len = ti->len - offset; /* * Does the target need to split even further ? */ if (ti->split_io) { sector_t boundary; - sector_t offset = dm_target_offset(ti, sector); boundary = ((offset + ti->split_io) & ~(ti->split_io - 1)) - offset; if (len > boundary) @@ -1192,96 +1171,36 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci, return tio; } -static void __issue_target_request(struct clone_info *ci, struct dm_target *ti, - unsigned request_nr, sector_t len) +static void __flush_target(struct clone_info *ci, struct dm_target *ti, + unsigned flush_nr) { struct dm_target_io *tio = alloc_tio(ci, ti); struct bio *clone; - tio->info.target_request_nr = request_nr; + tio->info.flush_request = flush_nr; - /* - * Discard requests require the bio's inline iovecs be initialized. - * ci->bio->bi_max_vecs is BIO_INLINE_VECS anyway, for both flush - * and discard, so no need for concern about wasted bvec allocations. - */ - clone = bio_alloc_bioset(GFP_NOIO, ci->bio->bi_max_vecs, ci->md->bs); + clone = bio_alloc_bioset(GFP_NOIO, 0, ci->md->bs); __bio_clone(clone, ci->bio); clone->bi_destructor = dm_bio_destructor; - if (len) { - clone->bi_sector = ci->sector; - clone->bi_size = to_bytes(len); - } __map_bio(ti, clone, tio); } -static void __issue_target_requests(struct clone_info *ci, struct dm_target *ti, - unsigned num_requests, sector_t len) -{ - unsigned request_nr; - - for (request_nr = 0; request_nr < num_requests; request_nr++) - __issue_target_request(ci, ti, request_nr, len); -} - static int __clone_and_map_empty_barrier(struct clone_info *ci) { - unsigned target_nr = 0; + unsigned target_nr = 0, flush_nr; struct dm_target *ti; while ((ti = dm_table_get_target(ci->map, target_nr++))) - __issue_target_requests(ci, ti, ti->num_flush_requests, 0); + for (flush_nr = 0; flush_nr < ti->num_flush_requests; + flush_nr++) + __flush_target(ci, ti, flush_nr); ci->sector_count = 0; return 0; } -/* - * Perform all io with a single clone. - */ -static void __clone_and_map_simple(struct clone_info *ci, struct dm_target *ti) -{ - struct bio *clone, *bio = ci->bio; - struct dm_target_io *tio; - - tio = alloc_tio(ci, ti); - clone = clone_bio(bio, ci->sector, ci->idx, - bio->bi_vcnt - ci->idx, ci->sector_count, - ci->md->bs); - __map_bio(ti, clone, tio); - ci->sector_count = 0; -} - -static int __clone_and_map_discard(struct clone_info *ci) -{ - struct dm_target *ti; - sector_t len; - - do { - ti = dm_table_find_target(ci->map, ci->sector); - if (!dm_target_is_valid(ti)) - return -EIO; - - /* - * Even though the device advertised discard support, - * reconfiguration might have changed that since the - * check was performed. - */ - if (!ti->num_discard_requests) - return -EOPNOTSUPP; - - len = min(ci->sector_count, max_io_len_target_boundary(ci->sector, ti)); - - __issue_target_requests(ci, ti, ti->num_discard_requests, len); - - ci->sector += len; - } while (ci->sector_count -= len); - - return 0; -} - static int __clone_and_map(struct clone_info *ci) { struct bio *clone, *bio = ci->bio; @@ -1292,21 +1211,27 @@ static int __clone_and_map(struct clone_info *ci) if (unlikely(bio_empty_barrier(bio))) return __clone_and_map_empty_barrier(ci); - if (unlikely(bio->bi_rw & REQ_DISCARD)) - return __clone_and_map_discard(ci); - ti = dm_table_find_target(ci->map, ci->sector); if (!dm_target_is_valid(ti)) return -EIO; - max = max_io_len(ci->sector, ti); + max = max_io_len(ci->md, ci->sector, ti); + + /* + * Allocate a target io object. + */ + tio = alloc_tio(ci, ti); if (ci->sector_count <= max) { /* * Optimise for the simple case where we can do all of * the remaining io with a single clone. */ - __clone_and_map_simple(ci, ti); + clone = clone_bio(bio, ci->sector, ci->idx, + bio->bi_vcnt - ci->idx, ci->sector_count, + ci->md->bs); + __map_bio(ti, clone, tio); + ci->sector_count = 0; } else if (to_sector(bio->bi_io_vec[ci->idx].bv_len) <= max) { /* @@ -1327,7 +1252,6 @@ static int __clone_and_map(struct clone_info *ci) len += bv_len; } - tio = alloc_tio(ci, ti); clone = clone_bio(bio, ci->sector, ci->idx, i - ci->idx, len, ci->md->bs); __map_bio(ti, clone, tio); @@ -1350,12 +1274,13 @@ static int __clone_and_map(struct clone_info *ci) if (!dm_target_is_valid(ti)) return -EIO; - max = max_io_len(ci->sector, ti); + max = max_io_len(ci->md, ci->sector, ti); + + tio = alloc_tio(ci, ti); } len = min(remaining, max); - tio = alloc_tio(ci, ti); clone = split_bvec(bio, ci->sector, ci->idx, bv->bv_offset + offset, len, ci->md->bs); @@ -1437,7 +1362,7 @@ static int dm_merge_bvec(struct request_queue *q, /* * Find maximum amount of I/O that won't need splitting */ - max_sectors = min(max_io_len(bvm->bi_sector, ti), + max_sectors = min(max_io_len(md, bvm->bi_sector, ti), (sector_t) BIO_MAX_SECTORS); max_size = (max_sectors << SECTOR_SHIFT) - bvm->bi_size; if (max_size < 0) @@ -1920,28 +1845,6 @@ static const struct block_device_operations dm_blk_dops; static void dm_wq_work(struct work_struct *work); static void dm_rq_barrier_work(struct work_struct *work); -static void dm_init_md_queue(struct mapped_device *md) -{ - /* - * Request-based dm devices cannot be stacked on top of bio-based dm - * devices. The type of this dm device has not been decided yet. - * The type is decided at the first table loading time. - * To prevent problematic device stacking, clear the queue flag - * for request stacking support until then. - * - * This queue is new, so no concurrency on the queue_flags. - */ - queue_flag_clear_unlocked(QUEUE_FLAG_STACKABLE, md->queue); - - md->queue->queuedata = md; - md->queue->backing_dev_info.congested_fn = dm_any_congested; - md->queue->backing_dev_info.congested_data = md; - blk_queue_make_request(md->queue, dm_request); - blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY); - md->queue->unplug_fn = dm_unplug_all; - blk_queue_merge_bvec(md->queue, dm_merge_bvec); -} - /* * Allocate and initialise a blank device with a given minor. */ @@ -1967,10 +1870,8 @@ static struct mapped_device *alloc_dev(int minor) if (r < 0) goto bad_minor; - md->type = DM_TYPE_NONE; init_rwsem(&md->io_lock); mutex_init(&md->suspend_lock); - mutex_init(&md->type_lock); spin_lock_init(&md->deferred_lock); spin_lock_init(&md->barrier_error_lock); rwlock_init(&md->map_lock); @@ -1981,11 +1882,33 @@ static struct mapped_device *alloc_dev(int minor) INIT_LIST_HEAD(&md->uevent_list); spin_lock_init(&md->uevent_lock); - md->queue = blk_alloc_queue(GFP_KERNEL); + md->queue = blk_init_queue(dm_request_fn, NULL); if (!md->queue) goto bad_queue; - dm_init_md_queue(md); + /* + * Request-based dm devices cannot be stacked on top of bio-based dm + * devices. The type of this dm device has not been decided yet, + * although we initialized the queue using blk_init_queue(). + * The type is decided at the first table loading time. + * To prevent problematic device stacking, clear the queue flag + * for request stacking support until then. + * + * This queue is new, so no concurrency on the queue_flags. + */ + queue_flag_clear_unlocked(QUEUE_FLAG_STACKABLE, md->queue); + md->saved_make_request_fn = md->queue->make_request_fn; + md->queue->queuedata = md; + md->queue->backing_dev_info.congested_fn = dm_any_congested; + md->queue->backing_dev_info.congested_data = md; + blk_queue_make_request(md->queue, dm_request); + blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY); + md->queue->unplug_fn = dm_unplug_all; + blk_queue_merge_bvec(md->queue, dm_merge_bvec); + blk_queue_softirq_done(md->queue, dm_softirq_done); + blk_queue_prep_rq(md->queue, dm_prep_fn); + blk_queue_lld_busy(md->queue, dm_lld_busy); + blk_queue_ordered(md->queue, QUEUE_ORDERED_DRAIN_FLUSH); md->disk = alloc_disk(1); if (!md->disk) @@ -2200,72 +2123,6 @@ int dm_create(int minor, struct mapped_device **result) return 0; } -/* - * Functions to manage md->type. - * All are required to hold md->type_lock. - */ -void dm_lock_md_type(struct mapped_device *md) -{ - mutex_lock(&md->type_lock); -} - -void dm_unlock_md_type(struct mapped_device *md) -{ - mutex_unlock(&md->type_lock); -} - -void dm_set_md_type(struct mapped_device *md, unsigned type) -{ - md->type = type; -} - -unsigned dm_get_md_type(struct mapped_device *md) -{ - return md->type; -} - -/* - * Fully initialize a request-based queue (->elevator, ->request_fn, etc). - */ -static int dm_init_request_based_queue(struct mapped_device *md) -{ - struct request_queue *q = NULL; - - if (md->queue->elevator) - return 1; - - /* Fully initialize the queue */ - q = blk_init_allocated_queue(md->queue, dm_request_fn, NULL); - if (!q) - return 0; - - md->queue = q; - md->saved_make_request_fn = md->queue->make_request_fn; - dm_init_md_queue(md); - blk_queue_softirq_done(md->queue, dm_softirq_done); - blk_queue_prep_rq(md->queue, dm_prep_fn); - blk_queue_lld_busy(md->queue, dm_lld_busy); - blk_queue_ordered(md->queue, QUEUE_ORDERED_DRAIN_FLUSH); - - elv_register_queue(md->queue); - - return 1; -} - -/* - * Setup the DM device's queue based on md's type - */ -int dm_setup_md_queue(struct mapped_device *md) -{ - if ((dm_get_md_type(md) == DM_TYPE_REQUEST_BASED) && - !dm_init_request_based_queue(md)) { - DMWARN("Cannot initialize queue for request-based mapped device"); - return -EINVAL; - } - - return 0; -} - static struct mapped_device *dm_find_md(dev_t dev) { struct mapped_device *md; @@ -2279,7 +2136,6 @@ static struct mapped_device *dm_find_md(dev_t dev) md = idr_find(&_minor_idr, minor); if (md && (md == MINOR_ALLOCED || (MINOR(disk_devt(dm_disk(md))) != minor) || - dm_deleting_md(md) || test_bit(DMF_FREEING, &md->flags))) { md = NULL; goto out; @@ -2314,7 +2170,6 @@ void dm_set_mdptr(struct mapped_device *md, void *ptr) void dm_get(struct mapped_device *md) { atomic_inc(&md->holders); - BUG_ON(test_bit(DMF_FREEING, &md->flags)); } const char *dm_device_name(struct mapped_device *md) @@ -2323,55 +2178,27 @@ const char *dm_device_name(struct mapped_device *md) } EXPORT_SYMBOL_GPL(dm_device_name); -static void __dm_destroy(struct mapped_device *md, bool wait) +void dm_put(struct mapped_device *md) { struct dm_table *map; - might_sleep(); - - spin_lock(&_minor_lock); - map = dm_get_live_table(md); - idr_replace(&_minor_idr, MINOR_ALLOCED, MINOR(disk_devt(dm_disk(md)))); - set_bit(DMF_FREEING, &md->flags); - spin_unlock(&_minor_lock); + BUG_ON(test_bit(DMF_FREEING, &md->flags)); - if (!dm_suspended_md(md)) { - dm_table_presuspend_targets(map); - dm_table_postsuspend_targets(map); + if (atomic_dec_and_lock(&md->holders, &_minor_lock)) { + map = dm_get_live_table(md); + idr_replace(&_minor_idr, MINOR_ALLOCED, + MINOR(disk_devt(dm_disk(md)))); + set_bit(DMF_FREEING, &md->flags); + spin_unlock(&_minor_lock); + if (!dm_suspended_md(md)) { + dm_table_presuspend_targets(map); + dm_table_postsuspend_targets(map); + } + dm_sysfs_exit(md); + dm_table_put(map); + dm_table_destroy(__unbind(md)); + free_dev(md); } - - /* - * Rare, but there may be I/O requests still going to complete, - * for example. Wait for all references to disappear. - * No one should increment the reference count of the mapped_device, - * after the mapped_device state becomes DMF_FREEING. - */ - if (wait) - while (atomic_read(&md->holders)) - msleep(1); - else if (atomic_read(&md->holders)) - DMWARN("%s: Forcibly removing mapped_device still in use! (%d users)", - dm_device_name(md), atomic_read(&md->holders)); - - dm_sysfs_exit(md); - dm_table_put(map); - dm_table_destroy(__unbind(md)); - free_dev(md); -} - -void dm_destroy(struct mapped_device *md) -{ - __dm_destroy(md, true); -} - -void dm_destroy_immediate(struct mapped_device *md) -{ - __dm_destroy(md, false); -} - -void dm_put(struct mapped_device *md) -{ - atomic_dec(&md->holders); } EXPORT_SYMBOL_GPL(dm_put); @@ -2426,12 +2253,7 @@ static void process_barrier(struct mapped_device *md, struct bio *bio) if (!bio_empty_barrier(bio)) { __split_and_process_bio(md, bio); - /* - * If the request isn't supported, don't waste time with - * the second flush. - */ - if (md->barrier_error != -EOPNOTSUPP) - dm_flush(md); + dm_flush(md); } if (md->barrier_error != DM_ENDIO_REQUEUE) @@ -2488,11 +2310,11 @@ static void dm_queue_flush(struct mapped_device *md) queue_work(md->wq, &md->work); } -static void dm_rq_set_target_request_nr(struct request *clone, unsigned request_nr) +static void dm_rq_set_flush_nr(struct request *clone, unsigned flush_nr) { struct dm_rq_target_io *tio = clone->end_io_data; - tio->info.target_request_nr = request_nr; + tio->info.flush_request = flush_nr; } /* Issue barrier requests to targets and wait for their completion. */ @@ -2510,7 +2332,7 @@ static int dm_rq_barrier(struct mapped_device *md) ti = dm_table_get_target(map, i); for (j = 0; j < ti->num_flush_requests; j++) { clone = clone_rq(md->flush_request, md, GFP_NOIO); - dm_rq_set_target_request_nr(clone, j); + dm_rq_set_flush_nr(clone, j); atomic_inc(&md->pending[rq_data_dir(clone)]); map_request(ti, clone, md); } @@ -2576,6 +2398,13 @@ struct dm_table *dm_swap_table(struct mapped_device *md, struct dm_table *table) goto out; } + /* cannot change the device type, once a table is bound */ + if (md->map && + (dm_table_get_type(md->map) != dm_table_get_type(table))) { + DMWARN("can't change the device type after a table is bound"); + goto out; + } + map = __bind(md, table, &limits); out: diff --git a/trunk/drivers/md/dm.h b/trunk/drivers/md/dm.h index 0c2dd5f4af76..bad1724d4869 100644 --- a/trunk/drivers/md/dm.h +++ b/trunk/drivers/md/dm.h @@ -59,20 +59,13 @@ void dm_table_postsuspend_targets(struct dm_table *t); int dm_table_resume_targets(struct dm_table *t); int dm_table_any_congested(struct dm_table *t, int bdi_bits); int dm_table_any_busy_target(struct dm_table *t); +int dm_table_set_type(struct dm_table *t); unsigned dm_table_get_type(struct dm_table *t); bool dm_table_request_based(struct dm_table *t); -bool dm_table_supports_discards(struct dm_table *t); int dm_table_alloc_md_mempools(struct dm_table *t); void dm_table_free_md_mempools(struct dm_table *t); struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t); -void dm_lock_md_type(struct mapped_device *md); -void dm_unlock_md_type(struct mapped_device *md); -void dm_set_md_type(struct mapped_device *md, unsigned type); -unsigned dm_get_md_type(struct mapped_device *md); - -int dm_setup_md_queue(struct mapped_device *md); - /* * To check the return value from dm_table_find_target(). */ @@ -129,11 +122,6 @@ void dm_linear_exit(void); int dm_stripe_init(void); void dm_stripe_exit(void); -/* - * mapped_device operations - */ -void dm_destroy(struct mapped_device *md); -void dm_destroy_immediate(struct mapped_device *md); int dm_open_count(struct mapped_device *md); int dm_lock_for_deletion(struct mapped_device *md); diff --git a/trunk/drivers/media/video/bt8xx/bttv-i2c.c b/trunk/drivers/media/video/bt8xx/bttv-i2c.c index 685d6597ee79..407fa61e4cda 100644 --- a/trunk/drivers/media/video/bt8xx/bttv-i2c.c +++ b/trunk/drivers/media/video/bt8xx/bttv-i2c.c @@ -411,7 +411,7 @@ void __devinit init_bttv_i2c_ir(struct bttv *btv) memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "ir_video", I2C_NAME_SIZE); - i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list, NULL); + i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list); } } diff --git a/trunk/drivers/media/video/cx18/cx18-i2c.c b/trunk/drivers/media/video/cx18/cx18-i2c.c index 73ce90c2f577..809f7d37129c 100644 --- a/trunk/drivers/media/video/cx18/cx18-i2c.c +++ b/trunk/drivers/media/video/cx18/cx18-i2c.c @@ -117,8 +117,7 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw, break; } - return i2c_new_probed_device(adap, &info, addr_list, NULL) == NULL ? - -1 : 0; + return i2c_new_probed_device(adap, &info, addr_list) == NULL ? -1 : 0; } int cx18_i2c_register(struct cx18 *cx, unsigned idx) diff --git a/trunk/drivers/media/video/cx23885/cx23885-i2c.c b/trunk/drivers/media/video/cx23885/cx23885-i2c.c index ed3d8f55029b..1a391486e551 100644 --- a/trunk/drivers/media/video/cx23885/cx23885-i2c.c +++ b/trunk/drivers/media/video/cx23885/cx23885-i2c.c @@ -364,10 +364,17 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "ir_video", I2C_NAME_SIZE); - /* Use quick read command for probe, some IR chips don't - * support writes */ - i2c_new_probed_device(&bus->i2c_adap, &info, addr_list, - i2c_probe_func_quick_read); + /* + * We can't call i2c_new_probed_device() because it uses + * quick writes for probing and the IR receiver device only + * replies to reads. + */ + if (i2c_smbus_xfer(&bus->i2c_adap, addr_list[0], 0, + I2C_SMBUS_READ, 0, I2C_SMBUS_QUICK, + NULL) >= 0) { + info.addr = addr_list[0]; + i2c_new_device(&bus->i2c_adap, &info); + } } return bus->i2c_rc; diff --git a/trunk/drivers/media/video/cx88/cx88-i2c.c b/trunk/drivers/media/video/cx88/cx88-i2c.c index 82db555b22dd..375ad53f7961 100644 --- a/trunk/drivers/media/video/cx88/cx88-i2c.c +++ b/trunk/drivers/media/video/cx88/cx88-i2c.c @@ -193,13 +193,24 @@ void cx88_i2c_init_ir(struct cx88_core *core) 0x18, 0x6b, 0x71, I2C_CLIENT_END }; + const unsigned short *addrp; memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "ir_video", I2C_NAME_SIZE); - /* Use quick read command for probe, some IR chips don't - * support writes */ - i2c_new_probed_device(&core->i2c_adap, &info, addr_list, - i2c_probe_func_quick_read); + /* + * We can't call i2c_new_probed_device() because it uses + * quick writes for probing and at least some R receiver + * devices only reply to reads. + */ + for (addrp = addr_list; *addrp != I2C_CLIENT_END; addrp++) { + if (i2c_smbus_xfer(&core->i2c_adap, *addrp, 0, + I2C_SMBUS_READ, 0, + I2C_SMBUS_QUICK, NULL) >= 0) { + info.addr = *addrp; + i2c_new_device(&core->i2c_adap, &info); + break; + } + } } } diff --git a/trunk/drivers/media/video/em28xx/em28xx-cards.c b/trunk/drivers/media/video/em28xx/em28xx-cards.c index e7efb4bffabd..ffbe544e30f4 100644 --- a/trunk/drivers/media/video/em28xx/em28xx-cards.c +++ b/trunk/drivers/media/video/em28xx/em28xx-cards.c @@ -2385,7 +2385,7 @@ void em28xx_register_i2c_ir(struct em28xx *dev) if (dev->init_data.name) info.platform_data = &dev->init_data; - i2c_new_probed_device(&dev->i2c_adap, &info, addr_list, NULL); + i2c_new_probed_device(&dev->i2c_adap, &info, addr_list); } void em28xx_card_setup(struct em28xx *dev) diff --git a/trunk/drivers/media/video/fsl-viu.c b/trunk/drivers/media/video/fsl-viu.c index 43d208f1f586..8f1c94f7e00c 100644 --- a/trunk/drivers/media/video/fsl-viu.c +++ b/trunk/drivers/media/video/fsl-viu.c @@ -1418,7 +1418,7 @@ static struct video_device viu_template = { .current_norm = V4L2_STD_NTSC_M, }; -static int __devinit viu_of_probe(struct platform_device *op, +static int __devinit viu_of_probe(struct of_device *op, const struct of_device_id *match) { struct viu_dev *viu_dev; @@ -1549,7 +1549,7 @@ static int __devinit viu_of_probe(struct platform_device *op, return ret; } -static int __devexit viu_of_remove(struct platform_device *op) +static int __devexit viu_of_remove(struct of_device *op) { struct v4l2_device *v4l2_dev = dev_get_drvdata(&op->dev); struct viu_dev *dev = container_of(v4l2_dev, struct viu_dev, v4l2_dev); @@ -1570,7 +1570,7 @@ static int __devexit viu_of_remove(struct platform_device *op) } #ifdef CONFIG_PM -static int viu_suspend(struct platform_device *op, pm_message_t state) +static int viu_suspend(struct of_device *op, pm_message_t state) { struct v4l2_device *v4l2_dev = dev_get_drvdata(&op->dev); struct viu_dev *dev = container_of(v4l2_dev, struct viu_dev, v4l2_dev); @@ -1579,7 +1579,7 @@ static int viu_suspend(struct platform_device *op, pm_message_t state) return 0; } -static int viu_resume(struct platform_device *op) +static int viu_resume(struct of_device *op) { struct v4l2_device *v4l2_dev = dev_get_drvdata(&op->dev); struct viu_dev *dev = container_of(v4l2_dev, struct viu_dev, v4l2_dev); diff --git a/trunk/drivers/media/video/ivtv/ivtv-i2c.c b/trunk/drivers/media/video/ivtv/ivtv-i2c.c index a74fa099c565..d391bbdb0b8a 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-i2c.c +++ b/trunk/drivers/media/video/ivtv/ivtv-i2c.c @@ -183,8 +183,8 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr) return -1; memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, type, I2C_NAME_SIZE); - return i2c_new_probed_device(adap, &info, addr_list, NULL) - == NULL ? -1 : 0; + return i2c_new_probed_device(adap, &info, addr_list) == NULL + ? -1 : 0; } /* Only allow one IR receiver to be registered per board */ @@ -221,8 +221,7 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr) info.platform_data = init_data; strlcpy(info.type, type, I2C_NAME_SIZE); - return i2c_new_probed_device(adap, &info, addr_list, NULL) == NULL ? - -1 : 0; + return i2c_new_probed_device(adap, &info, addr_list) == NULL ? -1 : 0; } /* Instantiate the IR receiver device using probing -- undesirable */ @@ -250,7 +249,7 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv) memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "ir_video", I2C_NAME_SIZE); - return i2c_new_probed_device(&itv->i2c_adap, &info, addr_list, NULL); + return i2c_new_probed_device(&itv->i2c_adap, &info, addr_list); } int ivtv_i2c_register(struct ivtv *itv, unsigned idx) diff --git a/trunk/drivers/media/video/v4l2-common.c b/trunk/drivers/media/video/v4l2-common.c index 8ee1179be926..3ce7c64e5789 100644 --- a/trunk/drivers/media/video/v4l2-common.c +++ b/trunk/drivers/media/video/v4l2-common.c @@ -381,8 +381,7 @@ struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, /* Create the i2c client */ if (info->addr == 0 && probe_addrs) - client = i2c_new_probed_device(adapter, info, probe_addrs, - NULL); + client = i2c_new_probed_device(adapter, info, probe_addrs); else client = i2c_new_device(adapter, info); diff --git a/trunk/drivers/memstick/core/mspro_block.c b/trunk/drivers/memstick/core/mspro_block.c index d3f1a087eced..eef78a068fd1 100644 --- a/trunk/drivers/memstick/core/mspro_block.c +++ b/trunk/drivers/memstick/core/mspro_block.c @@ -1048,7 +1048,6 @@ static int mspro_block_read_attributes(struct memstick_dev *card) snprintf(s_attr->name, sizeof(s_attr->name), "attr_x%02x", attr->entries[cnt].id); - sysfs_attr_init(&s_attr->dev_attr.attr); s_attr->dev_attr.attr.name = s_attr->name; s_attr->dev_attr.attr.mode = S_IRUGO; s_attr->dev_attr.show = mspro_block_attr_show(s_attr->id); @@ -1339,14 +1338,13 @@ static void mspro_block_remove(struct memstick_dev *card) struct mspro_block_data *msb = memstick_get_drvdata(card); unsigned long flags; + del_gendisk(msb->disk); + dev_dbg(&card->dev, "mspro block remove\n"); spin_lock_irqsave(&msb->q_lock, flags); msb->eject = 1; blk_start_queue(msb->queue); spin_unlock_irqrestore(&msb->q_lock, flags); - del_gendisk(msb->disk); - dev_dbg(&card->dev, "mspro block remove\n"); - blk_cleanup_queue(msb->queue); msb->queue = NULL; diff --git a/trunk/drivers/message/fusion/mptbase.c b/trunk/drivers/message/fusion/mptbase.c index b8f1719d7c02..c54674c482c7 100644 --- a/trunk/drivers/message/fusion/mptbase.c +++ b/trunk/drivers/message/fusion/mptbase.c @@ -110,7 +110,8 @@ MODULE_PARM_DESC(mpt_debug_level, " debug level - refer to mptdebug.h \ int mpt_fwfault_debug; EXPORT_SYMBOL(mpt_fwfault_debug); -module_param(mpt_fwfault_debug, int, 0600); +module_param_call(mpt_fwfault_debug, param_set_int, param_get_int, + &mpt_fwfault_debug, 0600); MODULE_PARM_DESC(mpt_fwfault_debug, "Enable detection of Firmware fault" " and halt Firmware on fault - (default=0)"); diff --git a/trunk/drivers/mfd/88pm860x-core.c b/trunk/drivers/mfd/88pm860x-core.c index 07933f3f7e4c..2c65a2c57294 100644 --- a/trunk/drivers/mfd/88pm860x-core.c +++ b/trunk/drivers/mfd/88pm860x-core.c @@ -74,12 +74,12 @@ static struct mfd_cell backlight_devs[] = { } static struct resource led_resources[] = { - PM8606_LED_RESOURCE(PM8606_LED1_RED, RGB1B), - PM8606_LED_RESOURCE(PM8606_LED1_GREEN, RGB1C), - PM8606_LED_RESOURCE(PM8606_LED1_BLUE, RGB1D), - PM8606_LED_RESOURCE(PM8606_LED2_RED, RGB2B), - PM8606_LED_RESOURCE(PM8606_LED2_GREEN, RGB2C), - PM8606_LED_RESOURCE(PM8606_LED2_BLUE, RGB2D), + PM8606_LED_RESOURCE(PM8606_LED1_RED, RGB2B), + PM8606_LED_RESOURCE(PM8606_LED1_GREEN, RGB2C), + PM8606_LED_RESOURCE(PM8606_LED1_BLUE, RGB2D), + PM8606_LED_RESOURCE(PM8606_LED2_RED, RGB1B), + PM8606_LED_RESOURCE(PM8606_LED2_GREEN, RGB1C), + PM8606_LED_RESOURCE(PM8606_LED2_BLUE, RGB1D), }; #define PM8606_LED_DEVS(_i) \ @@ -428,44 +428,52 @@ static int __devinit device_gpadc_init(struct pm860x_chip *chip, { struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \ : chip->companion; - int data; - int ret; + int use_gpadc = 0, data, ret; /* initialize GPADC without activating it */ - if (!pdata || !pdata->touch) - return -EINVAL; + if (pdata && pdata->touch) { + /* set GPADC MISC1 register */ + data = 0; + data |= (pdata->touch->gpadc_prebias << 1) + & PM8607_GPADC_PREBIAS_MASK; + data |= (pdata->touch->slot_cycle << 3) + & PM8607_GPADC_SLOT_CYCLE_MASK; + data |= (pdata->touch->off_scale << 5) + & PM8607_GPADC_OFF_SCALE_MASK; + data |= (pdata->touch->sw_cal << 7) + & PM8607_GPADC_SW_CAL_MASK; + if (data) { + ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data); + if (ret < 0) + goto out; + } + /* set tsi prebias time */ + if (pdata->touch->tsi_prebias) { + data = pdata->touch->tsi_prebias; + ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data); + if (ret < 0) + goto out; + } + /* set prebias & prechg time of pen detect */ + data = 0; + data |= pdata->touch->pen_prebias & PM8607_PD_PREBIAS_MASK; + data |= (pdata->touch->pen_prechg << 5) + & PM8607_PD_PRECHG_MASK; + if (data) { + ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data); + if (ret < 0) + goto out; + } - /* set GPADC MISC1 register */ - data = 0; - data |= (pdata->touch->gpadc_prebias << 1) & PM8607_GPADC_PREBIAS_MASK; - data |= (pdata->touch->slot_cycle << 3) & PM8607_GPADC_SLOT_CYCLE_MASK; - data |= (pdata->touch->off_scale << 5) & PM8607_GPADC_OFF_SCALE_MASK; - data |= (pdata->touch->sw_cal << 7) & PM8607_GPADC_SW_CAL_MASK; - if (data) { - ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data); - if (ret < 0) - goto out; - } - /* set tsi prebias time */ - if (pdata->touch->tsi_prebias) { - data = pdata->touch->tsi_prebias; - ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data); - if (ret < 0) - goto out; - } - /* set prebias & prechg time of pen detect */ - data = 0; - data |= pdata->touch->pen_prebias & PM8607_PD_PREBIAS_MASK; - data |= (pdata->touch->pen_prechg << 5) & PM8607_PD_PRECHG_MASK; - if (data) { - ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data); - if (ret < 0) - goto out; + use_gpadc = 1; } - ret = pm860x_set_bits(i2c, PM8607_GPADC_MISC1, - PM8607_GPADC_EN, PM8607_GPADC_EN); + /* turn on GPADC */ + if (use_gpadc) { + ret = pm860x_set_bits(i2c, PM8607_GPADC_MISC1, + PM8607_GPADC_EN, PM8607_GPADC_EN); + } out: return ret; } diff --git a/trunk/drivers/mfd/Kconfig b/trunk/drivers/mfd/Kconfig index db51ea1c6082..9da0e504bbe9 100644 --- a/trunk/drivers/mfd/Kconfig +++ b/trunk/drivers/mfd/Kconfig @@ -7,16 +7,7 @@ menuconfig MFD_SUPPORT depends on HAS_IOMEM default y help - Multifunction devices embed several functions (e.g. GPIOs, - touchscreens, keyboards, current regulators, power management chips, - etc...) in one single integrated circuit. They usually talk to the - main CPU through one or more IRQ lines and low speed data busses (SPI, - I2C, etc..). They appear as one single device to the main system - through the data bus and the MFD framework allows for sub devices - (a.k.a. functions) to appear as discrete platform devices. - MFDs are typically found on embedded platforms. - - This option alone does not add any kernel code. + Configure MFD device drivers. if MFD_SUPPORT @@ -186,38 +177,6 @@ config TWL4030_CODEC select MFD_CORE default n -config TWL6030_PWM - tristate "TWL6030 PWM (Pulse Width Modulator) Support" - depends on TWL4030_CORE - select HAVE_PWM - default n - help - Say yes here if you want support for TWL6030 PWM. - This is used to control charging LED brightness. - -config MFD_STMPE - bool "Support STMicroelectronics STMPE" - depends on I2C=y && GENERIC_HARDIRQS - select MFD_CORE - help - Support for the STMPE family of I/O Expanders from - STMicroelectronics. - - Currently supported devices are: - - STMPE811: GPIO, Touchscreen - STMPE1601: GPIO, Keypad - STMPE2401: GPIO, Keypad - STMPE2403: GPIO, Keypad - - This driver provides common support for accessing the device, - additional drivers must be enabled in order to use the functionality - of the device. Currently available sub drivers are: - - GPIO: stmpe-gpio - Keypad: stmpe-keypad - Touchscreen: stmpe-ts - config MFD_TC35892 bool "Support Toshiba TC35892" depends on I2C=y && GENERIC_HARDIRQS @@ -293,16 +252,6 @@ config MFD_MAX8925 accessing the device, additional drivers must be enabled in order to use the functionality of the device. -config MFD_MAX8998 - bool "Maxim Semiconductor MAX8998 PMIC Support" - depends on I2C=y - select MFD_CORE - help - Say yes here to support for Maxim Semiconductor MAX8998. This is - a Power Management IC. This driver provies common support for - accessing the device, additional drivers must be enabled in order - to use the functionality of the device. - config MFD_WM8400 tristate "Support Wolfson Microelectronics WM8400" select MFD_CORE @@ -533,28 +482,6 @@ config MFD_JANZ_CMODIO host many different types of MODULbus daughterboards, including CAN and GPIO controllers. -config MFD_JZ4740_ADC - tristate "Support for the JZ4740 SoC ADC core" - select MFD_CORE - depends on MACH_JZ4740 - help - Say yes here if you want support for the ADC unit in the JZ4740 SoC. - This driver is necessary for jz4740-battery and jz4740-hwmon driver. - -config MFD_TPS6586X - tristate "TPS6586x Power Management chips" - depends on I2C && GPIOLIB - select MFD_CORE - help - If you say yes here you get support for the TPS6586X series of - Power Management chips. - This driver provides common support for accessing the device, - additional drivers must be enabled in order to use the - functionality of the device. - - This driver can also be built as a module. If so, the module - will be called tps6586x. - endif # MFD_SUPPORT menu "Multimedia Capabilities Port drivers" diff --git a/trunk/drivers/mfd/Makefile b/trunk/drivers/mfd/Makefile index feaeeaeeddb7..fb503e77dc60 100644 --- a/trunk/drivers/mfd/Makefile +++ b/trunk/drivers/mfd/Makefile @@ -15,7 +15,6 @@ obj-$(CONFIG_HTC_I2CPLD) += htc-i2cpld.o obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o -obj-$(CONFIG_MFD_STMPE) += stmpe.o obj-$(CONFIG_MFD_TC35892) += tc35892.o obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o tmio_core.o @@ -37,7 +36,6 @@ obj-$(CONFIG_MENELAUS) += menelaus.o obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o obj-$(CONFIG_TWL4030_CODEC) += twl4030-codec.o -obj-$(CONFIG_TWL6030_PWM) += twl6030-pwm.o obj-$(CONFIG_MFD_MC13783) += mc13783-core.o @@ -58,7 +56,6 @@ obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o obj-$(CONFIG_PMIC_DA903X) += da903x.o max8925-objs := max8925-core.o max8925-i2c.o obj-$(CONFIG_MFD_MAX8925) += max8925.o -obj-$(CONFIG_MFD_MAX8998) += max8998.o pcf50633-objs := pcf50633-core.o pcf50633-irq.o obj-$(CONFIG_MFD_PCF50633) += pcf50633.o @@ -74,5 +71,3 @@ obj-$(CONFIG_PMIC_ADP5520) += adp5520.o obj-$(CONFIG_LPC_SCH) += lpc_sch.o obj-$(CONFIG_MFD_RDC321X) += rdc321x-southbridge.o obj-$(CONFIG_MFD_JANZ_CMODIO) += janz-cmodio.o -obj-$(CONFIG_MFD_JZ4740_ADC) += jz4740-adc.o -obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o diff --git a/trunk/drivers/mfd/ab3100-otp.c b/trunk/drivers/mfd/ab3100-otp.c index 8440010eb2b8..63d2b727ddbb 100644 --- a/trunk/drivers/mfd/ab3100-otp.c +++ b/trunk/drivers/mfd/ab3100-otp.c @@ -199,7 +199,7 @@ static int __init ab3100_otp_probe(struct platform_device *pdev) err = ab3100_otp_read(otp); if (err) - goto err_otp_read; + return err; dev_info(&pdev->dev, "AB3100 OTP readout registered\n"); @@ -208,21 +208,21 @@ static int __init ab3100_otp_probe(struct platform_device *pdev) err = device_create_file(&pdev->dev, &ab3100_otp_attrs[i]); if (err) - goto err_create_file; + goto out_no_sysfs; } /* debugfs entries */ err = ab3100_otp_init_debugfs(&pdev->dev, otp); if (err) - goto err_init_debugfs; + goto out_no_debugfs; return 0; -err_init_debugfs: -err_create_file: - while (--i >= 0) - device_remove_file(&pdev->dev, &ab3100_otp_attrs[i]); -err_otp_read: +out_no_sysfs: + for (i = 0; i < ARRAY_SIZE(ab3100_otp_attrs); i++) + device_remove_file(&pdev->dev, + &ab3100_otp_attrs[i]); +out_no_debugfs: kfree(otp); return err; } diff --git a/trunk/drivers/mfd/ab3550-core.c b/trunk/drivers/mfd/ab3550-core.c index 8a98739e6d9c..f54ab62e7bc6 100644 --- a/trunk/drivers/mfd/ab3550-core.c +++ b/trunk/drivers/mfd/ab3550-core.c @@ -589,16 +589,16 @@ static bool reg_read_allowed(const struct ab3550_reg_ranges *ranges, u8 reg) } /* - * The register access functionality. + * The exported register access functionality. */ -static int ab3550_get_chip_id(struct device *dev) +int ab3550_get_chip_id(struct device *dev) { struct ab3550 *ab = dev_get_drvdata(dev->parent); return (int)ab->chip_id; } -static int ab3550_mask_and_set_register_interruptible(struct device *dev, - u8 bank, u8 reg, u8 bitmask, u8 bitvalues) +int ab3550_mask_and_set_register_interruptible(struct device *dev, u8 bank, + u8 reg, u8 bitmask, u8 bitvalues) { struct ab3550 *ab; struct platform_device *pdev = to_platform_device(dev); @@ -612,15 +612,15 @@ static int ab3550_mask_and_set_register_interruptible(struct device *dev, bitmask, bitvalues); } -static int ab3550_set_register_interruptible(struct device *dev, u8 bank, - u8 reg, u8 value) +int ab3550_set_register_interruptible(struct device *dev, u8 bank, u8 reg, + u8 value) { return ab3550_mask_and_set_register_interruptible(dev, bank, reg, 0xFF, value); } -static int ab3550_get_register_interruptible(struct device *dev, u8 bank, - u8 reg, u8 *value) +int ab3550_get_register_interruptible(struct device *dev, u8 bank, u8 reg, + u8 *value) { struct ab3550 *ab; struct platform_device *pdev = to_platform_device(dev); @@ -633,7 +633,7 @@ static int ab3550_get_register_interruptible(struct device *dev, u8 bank, return get_register_interruptible(ab, bank, reg, value); } -static int ab3550_get_register_page_interruptible(struct device *dev, u8 bank, +int ab3550_get_register_page_interruptible(struct device *dev, u8 bank, u8 first_reg, u8 *regvals, u8 numregs) { struct ab3550 *ab; @@ -649,8 +649,7 @@ static int ab3550_get_register_page_interruptible(struct device *dev, u8 bank, numregs); } -static int ab3550_event_registers_startup_state_get(struct device *dev, - u8 *event) +int ab3550_event_registers_startup_state_get(struct device *dev, u8 *event) { struct ab3550 *ab; @@ -662,7 +661,7 @@ static int ab3550_event_registers_startup_state_get(struct device *dev, return 0; } -static int ab3550_startup_irq_enabled(struct device *dev, unsigned int irq) +int ab3550_startup_irq_enabled(struct device *dev, unsigned int irq) { struct ab3550 *ab; struct ab3550_platform_data *plf_data; diff --git a/trunk/drivers/mfd/ab8500-core.c b/trunk/drivers/mfd/ab8500-core.c index defa786dee34..f3d26fa9c34d 100644 --- a/trunk/drivers/mfd/ab8500-core.c +++ b/trunk/drivers/mfd/ab8500-core.c @@ -16,7 +16,6 @@ #include #include #include -#include /* * Interrupt register offsets @@ -353,7 +352,6 @@ static struct mfd_cell ab8500_devs[] = { { .name = "ab8500-audio", }, { .name = "ab8500-usb", }, { .name = "ab8500-pwm", }, - { .name = "ab8500-regulator", }, }; int __devinit ab8500_init(struct ab8500 *ab8500) @@ -413,7 +411,7 @@ int __devinit ab8500_init(struct ab8500 *ab8500) goto out_removeirq; } - ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, + ret = mfd_add_devices(ab8500->dev, -1, ab8500_devs, ARRAY_SIZE(ab8500_devs), NULL, ab8500->irq_base); if (ret) diff --git a/trunk/drivers/mfd/ab8500-spi.c b/trunk/drivers/mfd/ab8500-spi.c index e1c8b62b086d..b81d4f768ef6 100644 --- a/trunk/drivers/mfd/ab8500-spi.c +++ b/trunk/drivers/mfd/ab8500-spi.c @@ -68,12 +68,7 @@ static int ab8500_spi_read(struct ab8500 *ab8500, u16 addr) ret = spi_sync(spi, &msg); if (!ret) - /* - * Only the 8 lowermost bytes are - * defined with value, the rest may - * vary depending on chip/board noise. - */ - ret = ab8500->rx_buf[0] & 0xFFU; + ret = ab8500->rx_buf[0]; return ret; } diff --git a/trunk/drivers/mfd/abx500-core.c b/trunk/drivers/mfd/abx500-core.c index f12720dbe126..3b3b97ec32a7 100644 --- a/trunk/drivers/mfd/abx500-core.c +++ b/trunk/drivers/mfd/abx500-core.c @@ -36,7 +36,7 @@ int abx500_register_ops(struct device *dev, struct abx500_ops *ops) struct abx500_device_entry *dev_entry; dev_entry = kzalloc(sizeof(struct abx500_device_entry), GFP_KERNEL); - if (!dev_entry) { + if (IS_ERR(dev_entry)) { dev_err(dev, "register_ops kzalloc failed"); return -ENOMEM; } diff --git a/trunk/drivers/mfd/davinci_voicecodec.c b/trunk/drivers/mfd/davinci_voicecodec.c index 33c923d215c7..3e75f02e4778 100644 --- a/trunk/drivers/mfd/davinci_voicecodec.c +++ b/trunk/drivers/mfd/davinci_voicecodec.c @@ -94,8 +94,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!res) { dev_err(&pdev->dev, "no DMA resource\n"); - ret = -ENXIO; - goto fail4; + return -ENXIO; } davinci_vc->davinci_vcif.dma_tx_channel = res->start; @@ -105,8 +104,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_DMA, 1); if (!res) { dev_err(&pdev->dev, "no DMA resource\n"); - ret = -ENXIO; - goto fail4; + return -ENXIO; } davinci_vc->davinci_vcif.dma_rx_channel = res->start; diff --git a/trunk/drivers/mfd/janz-cmodio.c b/trunk/drivers/mfd/janz-cmodio.c index 36a166bcdb08..9ed630799acc 100644 --- a/trunk/drivers/mfd/janz-cmodio.c +++ b/trunk/drivers/mfd/janz-cmodio.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include diff --git a/trunk/drivers/mfd/jz4740-adc.c b/trunk/drivers/mfd/jz4740-adc.c deleted file mode 100644 index 3ad492cb6c41..000000000000 --- a/trunk/drivers/mfd/jz4740-adc.c +++ /dev/null @@ -1,394 +0,0 @@ -/* - * Copyright (C) 2009-2010, Lars-Peter Clausen - * JZ4740 SoC ADC driver - * - * 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. - * - * 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., - * 675 Mass Ave, Cambridge, MA 02139, USA. - * - * This driver synchronizes access to the JZ4740 ADC core between the - * JZ4740 battery and hwmon drivers. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - - -#define JZ_REG_ADC_ENABLE 0x00 -#define JZ_REG_ADC_CFG 0x04 -#define JZ_REG_ADC_CTRL 0x08 -#define JZ_REG_ADC_STATUS 0x0c - -#define JZ_REG_ADC_TOUCHSCREEN_BASE 0x10 -#define JZ_REG_ADC_BATTERY_BASE 0x1c -#define JZ_REG_ADC_HWMON_BASE 0x20 - -#define JZ_ADC_ENABLE_TOUCH BIT(2) -#define JZ_ADC_ENABLE_BATTERY BIT(1) -#define JZ_ADC_ENABLE_ADCIN BIT(0) - -enum { - JZ_ADC_IRQ_ADCIN = 0, - JZ_ADC_IRQ_BATTERY, - JZ_ADC_IRQ_TOUCH, - JZ_ADC_IRQ_PENUP, - JZ_ADC_IRQ_PENDOWN, -}; - -struct jz4740_adc { - struct resource *mem; - void __iomem *base; - - int irq; - int irq_base; - - struct clk *clk; - atomic_t clk_ref; - - spinlock_t lock; -}; - -static inline void jz4740_adc_irq_set_masked(struct jz4740_adc *adc, int irq, - bool masked) -{ - unsigned long flags; - uint8_t val; - - irq -= adc->irq_base; - - spin_lock_irqsave(&adc->lock, flags); - - val = readb(adc->base + JZ_REG_ADC_CTRL); - if (masked) - val |= BIT(irq); - else - val &= ~BIT(irq); - writeb(val, adc->base + JZ_REG_ADC_CTRL); - - spin_unlock_irqrestore(&adc->lock, flags); -} - -static void jz4740_adc_irq_mask(unsigned int irq) -{ - struct jz4740_adc *adc = get_irq_chip_data(irq); - jz4740_adc_irq_set_masked(adc, irq, true); -} - -static void jz4740_adc_irq_unmask(unsigned int irq) -{ - struct jz4740_adc *adc = get_irq_chip_data(irq); - jz4740_adc_irq_set_masked(adc, irq, false); -} - -static void jz4740_adc_irq_ack(unsigned int irq) -{ - struct jz4740_adc *adc = get_irq_chip_data(irq); - - irq -= adc->irq_base; - writeb(BIT(irq), adc->base + JZ_REG_ADC_STATUS); -} - -static struct irq_chip jz4740_adc_irq_chip = { - .name = "jz4740-adc", - .mask = jz4740_adc_irq_mask, - .unmask = jz4740_adc_irq_unmask, - .ack = jz4740_adc_irq_ack, -}; - -static void jz4740_adc_irq_demux(unsigned int irq, struct irq_desc *desc) -{ - struct jz4740_adc *adc = get_irq_desc_data(desc); - uint8_t status; - unsigned int i; - - status = readb(adc->base + JZ_REG_ADC_STATUS); - - for (i = 0; i < 5; ++i) { - if (status & BIT(i)) - generic_handle_irq(adc->irq_base + i); - } -} - - -/* Refcounting for the ADC clock is done in here instead of in the clock - * framework, because it is the only clock which is shared between multiple - * devices and thus is the only clock which needs refcounting */ -static inline void jz4740_adc_clk_enable(struct jz4740_adc *adc) -{ - if (atomic_inc_return(&adc->clk_ref) == 1) - clk_enable(adc->clk); -} - -static inline void jz4740_adc_clk_disable(struct jz4740_adc *adc) -{ - if (atomic_dec_return(&adc->clk_ref) == 0) - clk_disable(adc->clk); -} - -static inline void jz4740_adc_set_enabled(struct jz4740_adc *adc, int engine, - bool enabled) -{ - unsigned long flags; - uint8_t val; - - spin_lock_irqsave(&adc->lock, flags); - - val = readb(adc->base + JZ_REG_ADC_ENABLE); - if (enabled) - val |= BIT(engine); - else - val &= BIT(engine); - writeb(val, adc->base + JZ_REG_ADC_ENABLE); - - spin_unlock_irqrestore(&adc->lock, flags); -} - -static int jz4740_adc_cell_enable(struct platform_device *pdev) -{ - struct jz4740_adc *adc = dev_get_drvdata(pdev->dev.parent); - - jz4740_adc_clk_enable(adc); - jz4740_adc_set_enabled(adc, pdev->id, true); - - return 0; -} - -static int jz4740_adc_cell_disable(struct platform_device *pdev) -{ - struct jz4740_adc *adc = dev_get_drvdata(pdev->dev.parent); - - jz4740_adc_set_enabled(adc, pdev->id, false); - jz4740_adc_clk_disable(adc); - - return 0; -} - -int jz4740_adc_set_config(struct device *dev, uint32_t mask, uint32_t val) -{ - struct jz4740_adc *adc = dev_get_drvdata(dev); - unsigned long flags; - uint32_t cfg; - - if (!adc) - return -ENODEV; - - spin_lock_irqsave(&adc->lock, flags); - - cfg = readl(adc->base + JZ_REG_ADC_CFG); - - cfg &= ~mask; - cfg |= val; - - writel(cfg, adc->base + JZ_REG_ADC_CFG); - - spin_unlock_irqrestore(&adc->lock, flags); - - return 0; -} -EXPORT_SYMBOL_GPL(jz4740_adc_set_config); - -static struct resource jz4740_hwmon_resources[] = { - { - .start = JZ_ADC_IRQ_ADCIN, - .flags = IORESOURCE_IRQ, - }, - { - .start = JZ_REG_ADC_HWMON_BASE, - .end = JZ_REG_ADC_HWMON_BASE + 3, - .flags = IORESOURCE_MEM, - }, -}; - -static struct resource jz4740_battery_resources[] = { - { - .start = JZ_ADC_IRQ_BATTERY, - .flags = IORESOURCE_IRQ, - }, - { - .start = JZ_REG_ADC_BATTERY_BASE, - .end = JZ_REG_ADC_BATTERY_BASE + 3, - .flags = IORESOURCE_MEM, - }, -}; - -const struct mfd_cell jz4740_adc_cells[] = { - { - .id = 0, - .name = "jz4740-hwmon", - .num_resources = ARRAY_SIZE(jz4740_hwmon_resources), - .resources = jz4740_hwmon_resources, - .platform_data = (void *)&jz4740_adc_cells[0], - .data_size = sizeof(struct mfd_cell), - - .enable = jz4740_adc_cell_enable, - .disable = jz4740_adc_cell_disable, - }, - { - .id = 1, - .name = "jz4740-battery", - .num_resources = ARRAY_SIZE(jz4740_battery_resources), - .resources = jz4740_battery_resources, - .platform_data = (void *)&jz4740_adc_cells[1], - .data_size = sizeof(struct mfd_cell), - - .enable = jz4740_adc_cell_enable, - .disable = jz4740_adc_cell_disable, - }, -}; - -static int __devinit jz4740_adc_probe(struct platform_device *pdev) -{ - int ret; - struct jz4740_adc *adc; - struct resource *mem_base; - int irq; - - adc = kmalloc(sizeof(*adc), GFP_KERNEL); - if (!adc) { - dev_err(&pdev->dev, "Failed to allocate driver structure\n"); - return -ENOMEM; - } - - adc->irq = platform_get_irq(pdev, 0); - if (adc->irq < 0) { - ret = adc->irq; - dev_err(&pdev->dev, "Failed to get platform irq: %d\n", ret); - goto err_free; - } - - adc->irq_base = platform_get_irq(pdev, 1); - if (adc->irq_base < 0) { - ret = adc->irq_base; - dev_err(&pdev->dev, "Failed to get irq base: %d\n", ret); - goto err_free; - } - - mem_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem_base) { - ret = -ENOENT; - dev_err(&pdev->dev, "Failed to get platform mmio resource\n"); - goto err_free; - } - - /* Only request the shared registers for the MFD driver */ - adc->mem = request_mem_region(mem_base->start, JZ_REG_ADC_STATUS, - pdev->name); - if (!adc->mem) { - ret = -EBUSY; - dev_err(&pdev->dev, "Failed to request mmio memory region\n"); - goto err_free; - } - - adc->base = ioremap_nocache(adc->mem->start, resource_size(adc->mem)); - if (!adc->base) { - ret = -EBUSY; - dev_err(&pdev->dev, "Failed to ioremap mmio memory\n"); - goto err_release_mem_region; - } - - adc->clk = clk_get(&pdev->dev, "adc"); - if (IS_ERR(adc->clk)) { - ret = PTR_ERR(adc->clk); - dev_err(&pdev->dev, "Failed to get clock: %d\n", ret); - goto err_iounmap; - } - - spin_lock_init(&adc->lock); - atomic_set(&adc->clk_ref, 0); - - platform_set_drvdata(pdev, adc); - - for (irq = adc->irq_base; irq < adc->irq_base + 5; ++irq) { - set_irq_chip_data(irq, adc); - set_irq_chip_and_handler(irq, &jz4740_adc_irq_chip, - handle_level_irq); - } - - set_irq_data(adc->irq, adc); - set_irq_chained_handler(adc->irq, jz4740_adc_irq_demux); - - writeb(0x00, adc->base + JZ_REG_ADC_ENABLE); - writeb(0xff, adc->base + JZ_REG_ADC_CTRL); - - ret = mfd_add_devices(&pdev->dev, 0, jz4740_adc_cells, - ARRAY_SIZE(jz4740_adc_cells), mem_base, adc->irq_base); - if (ret < 0) - goto err_clk_put; - - return 0; - -err_clk_put: - clk_put(adc->clk); -err_iounmap: - platform_set_drvdata(pdev, NULL); - iounmap(adc->base); -err_release_mem_region: - release_mem_region(adc->mem->start, resource_size(adc->mem)); -err_free: - kfree(adc); - - return ret; -} - -static int __devexit jz4740_adc_remove(struct platform_device *pdev) -{ - struct jz4740_adc *adc = platform_get_drvdata(pdev); - - mfd_remove_devices(&pdev->dev); - - set_irq_data(adc->irq, NULL); - set_irq_chained_handler(adc->irq, NULL); - - iounmap(adc->base); - release_mem_region(adc->mem->start, resource_size(adc->mem)); - - clk_put(adc->clk); - - platform_set_drvdata(pdev, NULL); - - kfree(adc); - - return 0; -} - -struct platform_driver jz4740_adc_driver = { - .probe = jz4740_adc_probe, - .remove = __devexit_p(jz4740_adc_remove), - .driver = { - .name = "jz4740-adc", - .owner = THIS_MODULE, - }, -}; - -static int __init jz4740_adc_init(void) -{ - return platform_driver_register(&jz4740_adc_driver); -} -module_init(jz4740_adc_init); - -static void __exit jz4740_adc_exit(void) -{ - platform_driver_unregister(&jz4740_adc_driver); -} -module_exit(jz4740_adc_exit); - -MODULE_DESCRIPTION("JZ4740 SoC ADC driver"); -MODULE_AUTHOR("Lars-Peter Clausen "); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:jz4740-adc"); diff --git a/trunk/drivers/mfd/max8925-core.c b/trunk/drivers/mfd/max8925-core.c index 04028a9ee082..f621bcea3d02 100644 --- a/trunk/drivers/mfd/max8925-core.c +++ b/trunk/drivers/mfd/max8925-core.c @@ -90,24 +90,6 @@ static struct mfd_cell rtc_devs[] = { }, }; -static struct resource onkey_resources[] = { - { - .name = "max8925-onkey", - .start = MAX8925_IRQ_GPM_SW_3SEC, - .end = MAX8925_IRQ_GPM_SW_3SEC, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell onkey_devs[] = { - { - .name = "max8925-onkey", - .num_resources = 1, - .resources = &onkey_resources[0], - .id = -1, - }, -}; - #define MAX8925_REG_RESOURCE(_start, _end) \ { \ .start = MAX8925_##_start, \ @@ -614,15 +596,6 @@ int __devinit max8925_device_init(struct max8925_chip *chip, dev_err(chip->dev, "Failed to add rtc subdev\n"); goto out; } - - ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0], - ARRAY_SIZE(onkey_devs), - &onkey_resources[0], 0); - if (ret < 0) { - dev_err(chip->dev, "Failed to add onkey subdev\n"); - goto out_dev; - } - if (pdata && pdata->regulator[0]) { ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0], ARRAY_SIZE(regulator_devs), diff --git a/trunk/drivers/mfd/max8998.c b/trunk/drivers/mfd/max8998.c deleted file mode 100644 index 73e6f5c4efc9..000000000000 --- a/trunk/drivers/mfd/max8998.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * max8698.c - mfd core driver for the Maxim 8998 - * - * Copyright (C) 2009-2010 Samsung Electronics - * Kyungmin Park - * Marek Szyprowski - * - * 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 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static struct mfd_cell max8998_devs[] = { - { - .name = "max8998-pmic", - } -}; - -static int max8998_i2c_device_read(struct max8998_dev *max8998, u8 reg, u8 *dest) -{ - struct i2c_client *client = max8998->i2c_client; - int ret; - - mutex_lock(&max8998->iolock); - ret = i2c_smbus_read_byte_data(client, reg); - mutex_unlock(&max8998->iolock); - if (ret < 0) - return ret; - - ret &= 0xff; - *dest = ret; - return 0; -} - -static int max8998_i2c_device_write(struct max8998_dev *max8998, u8 reg, u8 value) -{ - struct i2c_client *client = max8998->i2c_client; - int ret; - - mutex_lock(&max8998->iolock); - ret = i2c_smbus_write_byte_data(client, reg, value); - mutex_unlock(&max8998->iolock); - return ret; -} - -static int max8998_i2c_device_update(struct max8998_dev *max8998, u8 reg, - u8 val, u8 mask) -{ - struct i2c_client *client = max8998->i2c_client; - int ret; - - mutex_lock(&max8998->iolock); - ret = i2c_smbus_read_byte_data(client, reg); - if (ret >= 0) { - u8 old_val = ret & 0xff; - u8 new_val = (val & mask) | (old_val & (~mask)); - ret = i2c_smbus_write_byte_data(client, reg, new_val); - if (ret >= 0) - ret = 0; - } - mutex_unlock(&max8998->iolock); - return ret; -} - -static int max8998_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - struct max8998_dev *max8998; - int ret = 0; - - max8998 = kzalloc(sizeof(struct max8998_dev), GFP_KERNEL); - if (max8998 == NULL) - return -ENOMEM; - - i2c_set_clientdata(i2c, max8998); - max8998->dev = &i2c->dev; - max8998->i2c_client = i2c; - max8998->dev_read = max8998_i2c_device_read; - max8998->dev_write = max8998_i2c_device_write; - max8998->dev_update = max8998_i2c_device_update; - mutex_init(&max8998->iolock); - - ret = mfd_add_devices(max8998->dev, -1, - max8998_devs, ARRAY_SIZE(max8998_devs), - NULL, 0); - if (ret < 0) - goto err; - - return ret; - -err: - mfd_remove_devices(max8998->dev); - kfree(max8998); - return ret; -} - -static int max8998_i2c_remove(struct i2c_client *i2c) -{ - struct max8998_dev *max8998 = i2c_get_clientdata(i2c); - - mfd_remove_devices(max8998->dev); - kfree(max8998); - - return 0; -} - -static const struct i2c_device_id max8998_i2c_id[] = { - { "max8998", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, max8998_i2c_id); - -static struct i2c_driver max8998_i2c_driver = { - .driver = { - .name = "max8998", - .owner = THIS_MODULE, - }, - .probe = max8998_i2c_probe, - .remove = max8998_i2c_remove, - .id_table = max8998_i2c_id, -}; - -static int __init max8998_i2c_init(void) -{ - return i2c_add_driver(&max8998_i2c_driver); -} -/* init early so consumer devices can complete system boot */ -subsys_initcall(max8998_i2c_init); - -static void __exit max8998_i2c_exit(void) -{ - i2c_del_driver(&max8998_i2c_driver); -} -module_exit(max8998_i2c_exit); - -MODULE_DESCRIPTION("MAXIM 8998 multi-function core driver"); -MODULE_AUTHOR("Kyungmin Park "); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/mfd/mc13783-core.c b/trunk/drivers/mfd/mc13783-core.c index 6df34989c1f6..fecf38a4f025 100644 --- a/trunk/drivers/mfd/mc13783-core.c +++ b/trunk/drivers/mfd/mc13783-core.c @@ -11,31 +11,9 @@ */ #include #include -#include -#include -#include #include #include -#include - -struct mc13783 { - struct spi_device *spidev; - struct mutex lock; - int irq; - int flags; - - irq_handler_t irqhandler[MC13783_NUM_IRQ]; - void *irqdata[MC13783_NUM_IRQ]; - - /* XXX these should go as platformdata to the regulator subdevice */ - struct mc13783_regulator_init_data *regulators; - int num_regulators; -}; - -#define MC13783_REG_REVISION 7 -#define MC13783_REG_ADC_0 43 -#define MC13783_REG_ADC_1 44 -#define MC13783_REG_ADC_2 45 +#include #define MC13783_IRQSTAT0 0 #define MC13783_IRQSTAT0_ADCDONEI (1 << 0) @@ -248,12 +226,6 @@ int mc13783_reg_rmw(struct mc13783 *mc13783, unsigned int offset, } EXPORT_SYMBOL(mc13783_reg_rmw); -int mc13783_get_flags(struct mc13783 *mc13783) -{ - return mc13783->flags; -} -EXPORT_SYMBOL(mc13783_get_flags); - int mc13783_irq_mask(struct mc13783 *mc13783, int irq) { int ret; diff --git a/trunk/drivers/mfd/menelaus.c b/trunk/drivers/mfd/menelaus.c index 4ba85bbdb4c1..a3fb4bcb9889 100644 --- a/trunk/drivers/mfd/menelaus.c +++ b/trunk/drivers/mfd/menelaus.c @@ -128,39 +128,6 @@ #define MENELAUS_RESERVED14_IRQ 14 /* Reserved */ #define MENELAUS_RESERVED15_IRQ 15 /* Reserved */ -/* VCORE_CTRL1 register */ -#define VCORE_CTRL1_BYP_COMP (1 << 5) -#define VCORE_CTRL1_HW_NSW (1 << 7) - -/* GPIO_CTRL register */ -#define GPIO_CTRL_SLOTSELEN (1 << 5) -#define GPIO_CTRL_SLPCTLEN (1 << 6) -#define GPIO1_DIR_INPUT (1 << 0) -#define GPIO2_DIR_INPUT (1 << 1) -#define GPIO3_DIR_INPUT (1 << 2) - -/* MCT_CTRL1 register */ -#define MCT_CTRL1_S1_CMD_OD (1 << 2) -#define MCT_CTRL1_S2_CMD_OD (1 << 3) - -/* MCT_CTRL2 register */ -#define MCT_CTRL2_VS2_SEL_D0 (1 << 0) -#define MCT_CTRL2_VS2_SEL_D1 (1 << 1) -#define MCT_CTRL2_S1CD_BUFEN (1 << 4) -#define MCT_CTRL2_S2CD_BUFEN (1 << 5) -#define MCT_CTRL2_S1CD_DBEN (1 << 6) -#define MCT_CTRL2_S2CD_BEN (1 << 7) - -/* MCT_CTRL3 register */ -#define MCT_CTRL3_SLOT1_EN (1 << 0) -#define MCT_CTRL3_SLOT2_EN (1 << 1) -#define MCT_CTRL3_S1_AUTO_EN (1 << 2) -#define MCT_CTRL3_S2_AUTO_EN (1 << 3) - -/* MCT_PIN_ST register */ -#define MCT_PIN_ST_S1_CD_ST (1 << 0) -#define MCT_PIN_ST_S2_CD_ST (1 << 1) - static void menelaus_work(struct work_struct *_menelaus); struct menelaus_chip { @@ -282,10 +249,10 @@ static void menelaus_mmc_cd_work(struct menelaus_chip *menelaus_hw) return; if (!(reg & 0x1)) - card_mask |= MCT_PIN_ST_S1_CD_ST; + card_mask |= (1 << 0); if (!(reg & 0x2)) - card_mask |= MCT_PIN_ST_S2_CD_ST; + card_mask |= (1 << 1); if (menelaus_hw->mmc_callback) menelaus_hw->mmc_callback(menelaus_hw->mmc_callback_data, @@ -310,14 +277,14 @@ int menelaus_set_mmc_opendrain(int slot, int enable) val = ret; if (slot == 1) { if (enable) - val |= MCT_CTRL1_S1_CMD_OD; + val |= 1 << 2; else - val &= ~MCT_CTRL1_S1_CMD_OD; + val &= ~(1 << 2); } else { if (enable) - val |= MCT_CTRL1_S2_CMD_OD; + val |= 1 << 3; else - val &= ~MCT_CTRL1_S2_CMD_OD; + val &= ~(1 << 3); } ret = menelaus_write_reg(MENELAUS_MCT_CTRL1, val); mutex_unlock(&the_menelaus->lock); @@ -334,11 +301,11 @@ int menelaus_set_slot_sel(int enable) ret = menelaus_read_reg(MENELAUS_GPIO_CTRL); if (ret < 0) goto out; - ret |= GPIO2_DIR_INPUT; + ret |= 0x02; if (enable) - ret |= GPIO_CTRL_SLOTSELEN; + ret |= 1 << 5; else - ret &= ~GPIO_CTRL_SLOTSELEN; + ret &= ~(1 << 5); ret = menelaus_write_reg(MENELAUS_GPIO_CTRL, ret); out: mutex_unlock(&the_menelaus->lock); @@ -363,14 +330,14 @@ int menelaus_set_mmc_slot(int slot, int enable, int power, int cd_en) val = ret; if (slot == 1) { if (cd_en) - val |= MCT_CTRL2_S1CD_BUFEN | MCT_CTRL2_S1CD_DBEN; + val |= (1 << 4) | (1 << 6); else - val &= ~(MCT_CTRL2_S1CD_BUFEN | MCT_CTRL2_S1CD_DBEN); + val &= ~((1 << 4) | (1 << 6)); } else { if (cd_en) - val |= MCT_CTRL2_S2CD_BUFEN | MCT_CTRL2_S2CD_BEN; + val |= (1 << 5) | (1 << 7); else - val &= ~(MCT_CTRL2_S2CD_BUFEN | MCT_CTRL2_S2CD_BEN); + val &= ~((1 << 5) | (1 << 7)); } ret = menelaus_write_reg(MENELAUS_MCT_CTRL2, val); if (ret < 0) @@ -382,25 +349,25 @@ int menelaus_set_mmc_slot(int slot, int enable, int power, int cd_en) val = ret; if (slot == 1) { if (enable) - val |= MCT_CTRL3_SLOT1_EN; + val |= 1 << 0; else - val &= ~MCT_CTRL3_SLOT1_EN; + val &= ~(1 << 0); } else { int b; if (enable) - val |= MCT_CTRL3_SLOT2_EN; + ret |= 1 << 1; else - val &= ~MCT_CTRL3_SLOT2_EN; + ret &= ~(1 << 1); b = menelaus_read_reg(MENELAUS_MCT_CTRL2); - b &= ~(MCT_CTRL2_VS2_SEL_D0 | MCT_CTRL2_VS2_SEL_D1); + b &= ~0x03; b |= power; ret = menelaus_write_reg(MENELAUS_MCT_CTRL2, b); if (ret < 0) goto out; } /* Disable autonomous shutdown */ - val &= ~(MCT_CTRL3_S1_AUTO_EN | MCT_CTRL3_S2_AUTO_EN); + val &= ~(0x03 << 2); ret = menelaus_write_reg(MENELAUS_MCT_CTRL3, val); out: mutex_unlock(&the_menelaus->lock); @@ -585,7 +552,7 @@ int menelaus_set_vcore_hw(unsigned int roof_mV, unsigned int floor_mV) if (!the_menelaus->vcore_hw_mode) { val = menelaus_read_reg(MENELAUS_VCORE_CTRL1); /* HW mode, turn OFF byte comparator */ - val |= (VCORE_CTRL1_HW_NSW | VCORE_CTRL1_BYP_COMP); + val |= ((1 << 7) | (1 << 5)); ret = menelaus_write_reg(MENELAUS_VCORE_CTRL1, val); the_menelaus->vcore_hw_mode = 1; } @@ -782,7 +749,7 @@ int menelaus_set_regulator_sleep(int enable, u32 val) ret = menelaus_read_reg(MENELAUS_GPIO_CTRL); if (ret < 0) goto out; - t = (GPIO_CTRL_SLPCTLEN | GPIO3_DIR_INPUT); + t = ((1 << 6) | 0x04); if (enable) ret |= t; else diff --git a/trunk/drivers/mfd/mfd-core.c b/trunk/drivers/mfd/mfd-core.c index 1823a57b7d8f..7dd76bceaae8 100644 --- a/trunk/drivers/mfd/mfd-core.c +++ b/trunk/drivers/mfd/mfd-core.c @@ -70,9 +70,7 @@ static int mfd_add_device(struct device *parent, int id, goto fail_res; } - ret = platform_device_add_resources(pdev, res, cell->num_resources); - if (ret) - goto fail_res; + platform_device_add_resources(pdev, res, cell->num_resources); ret = platform_device_add(pdev); if (ret) diff --git a/trunk/drivers/mfd/stmpe.c b/trunk/drivers/mfd/stmpe.c deleted file mode 100644 index 0754c5e91995..000000000000 --- a/trunk/drivers/mfd/stmpe.c +++ /dev/null @@ -1,985 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2010 - * - * License Terms: GNU General Public License, version 2 - * Author: Rabin Vincent for ST-Ericsson - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "stmpe.h" - -static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks) -{ - return stmpe->variant->enable(stmpe, blocks, true); -} - -static int __stmpe_disable(struct stmpe *stmpe, unsigned int blocks) -{ - return stmpe->variant->enable(stmpe, blocks, false); -} - -static int __stmpe_reg_read(struct stmpe *stmpe, u8 reg) -{ - int ret; - - ret = i2c_smbus_read_byte_data(stmpe->i2c, reg); - if (ret < 0) - dev_err(stmpe->dev, "failed to read reg %#x: %d\n", - reg, ret); - - dev_vdbg(stmpe->dev, "rd: reg %#x => data %#x\n", reg, ret); - - return ret; -} - -static int __stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 val) -{ - int ret; - - dev_vdbg(stmpe->dev, "wr: reg %#x <= %#x\n", reg, val); - - ret = i2c_smbus_write_byte_data(stmpe->i2c, reg, val); - if (ret < 0) - dev_err(stmpe->dev, "failed to write reg %#x: %d\n", - reg, ret); - - return ret; -} - -static int __stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val) -{ - int ret; - - ret = __stmpe_reg_read(stmpe, reg); - if (ret < 0) - return ret; - - ret &= ~mask; - ret |= val; - - return __stmpe_reg_write(stmpe, reg, ret); -} - -static int __stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length, - u8 *values) -{ - int ret; - - ret = i2c_smbus_read_i2c_block_data(stmpe->i2c, reg, length, values); - if (ret < 0) - dev_err(stmpe->dev, "failed to read regs %#x: %d\n", - reg, ret); - - dev_vdbg(stmpe->dev, "rd: reg %#x (%d) => ret %#x\n", reg, length, ret); - stmpe_dump_bytes("stmpe rd: ", values, length); - - return ret; -} - -static int __stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length, - const u8 *values) -{ - int ret; - - dev_vdbg(stmpe->dev, "wr: regs %#x (%d)\n", reg, length); - stmpe_dump_bytes("stmpe wr: ", values, length); - - ret = i2c_smbus_write_i2c_block_data(stmpe->i2c, reg, length, - values); - if (ret < 0) - dev_err(stmpe->dev, "failed to write regs %#x: %d\n", - reg, ret); - - return ret; -} - -/** - * stmpe_enable - enable blocks on an STMPE device - * @stmpe: Device to work on - * @blocks: Mask of blocks (enum stmpe_block values) to enable - */ -int stmpe_enable(struct stmpe *stmpe, unsigned int blocks) -{ - int ret; - - mutex_lock(&stmpe->lock); - ret = __stmpe_enable(stmpe, blocks); - mutex_unlock(&stmpe->lock); - - return ret; -} -EXPORT_SYMBOL_GPL(stmpe_enable); - -/** - * stmpe_disable - disable blocks on an STMPE device - * @stmpe: Device to work on - * @blocks: Mask of blocks (enum stmpe_block values) to enable - */ -int stmpe_disable(struct stmpe *stmpe, unsigned int blocks) -{ - int ret; - - mutex_lock(&stmpe->lock); - ret = __stmpe_disable(stmpe, blocks); - mutex_unlock(&stmpe->lock); - - return ret; -} -EXPORT_SYMBOL_GPL(stmpe_disable); - -/** - * stmpe_reg_read() - read a single STMPE register - * @stmpe: Device to read from - * @reg: Register to read - */ -int stmpe_reg_read(struct stmpe *stmpe, u8 reg) -{ - int ret; - - mutex_lock(&stmpe->lock); - ret = __stmpe_reg_read(stmpe, reg); - mutex_unlock(&stmpe->lock); - - return ret; -} -EXPORT_SYMBOL_GPL(stmpe_reg_read); - -/** - * stmpe_reg_write() - write a single STMPE register - * @stmpe: Device to write to - * @reg: Register to write - * @val: Value to write - */ -int stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 val) -{ - int ret; - - mutex_lock(&stmpe->lock); - ret = __stmpe_reg_write(stmpe, reg, val); - mutex_unlock(&stmpe->lock); - - return ret; -} -EXPORT_SYMBOL_GPL(stmpe_reg_write); - -/** - * stmpe_set_bits() - set the value of a bitfield in a STMPE register - * @stmpe: Device to write to - * @reg: Register to write - * @mask: Mask of bits to set - * @val: Value to set - */ -int stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val) -{ - int ret; - - mutex_lock(&stmpe->lock); - ret = __stmpe_set_bits(stmpe, reg, mask, val); - mutex_unlock(&stmpe->lock); - - return ret; -} -EXPORT_SYMBOL_GPL(stmpe_set_bits); - -/** - * stmpe_block_read() - read multiple STMPE registers - * @stmpe: Device to read from - * @reg: First register - * @length: Number of registers - * @values: Buffer to write to - */ -int stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length, u8 *values) -{ - int ret; - - mutex_lock(&stmpe->lock); - ret = __stmpe_block_read(stmpe, reg, length, values); - mutex_unlock(&stmpe->lock); - - return ret; -} -EXPORT_SYMBOL_GPL(stmpe_block_read); - -/** - * stmpe_block_write() - write multiple STMPE registers - * @stmpe: Device to write to - * @reg: First register - * @length: Number of registers - * @values: Values to write - */ -int stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length, - const u8 *values) -{ - int ret; - - mutex_lock(&stmpe->lock); - ret = __stmpe_block_write(stmpe, reg, length, values); - mutex_unlock(&stmpe->lock); - - return ret; -} -EXPORT_SYMBOL_GPL(stmpe_block_write); - -/** - * stmpe_set_altfunc: set the alternate function for STMPE pins - * @stmpe: Device to configure - * @pins: Bitmask of pins to affect - * @block: block to enable alternate functions for - * - * @pins is assumed to have a bit set for each of the bits whose alternate - * function is to be changed, numbered according to the GPIOXY numbers. - * - * If the GPIO module is not enabled, this function automatically enables it in - * order to perform the change. - */ -int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, enum stmpe_block block) -{ - struct stmpe_variant_info *variant = stmpe->variant; - u8 regaddr = stmpe->regs[STMPE_IDX_GPAFR_U_MSB]; - int af_bits = variant->af_bits; - int numregs = DIV_ROUND_UP(stmpe->num_gpios * af_bits, 8); - int afperreg = 8 / af_bits; - int mask = (1 << af_bits) - 1; - u8 regs[numregs]; - int af; - int ret; - - mutex_lock(&stmpe->lock); - - ret = __stmpe_enable(stmpe, STMPE_BLOCK_GPIO); - if (ret < 0) - goto out; - - ret = __stmpe_block_read(stmpe, regaddr, numregs, regs); - if (ret < 0) - goto out; - - af = variant->get_altfunc(stmpe, block); - - while (pins) { - int pin = __ffs(pins); - int regoffset = numregs - (pin / afperreg) - 1; - int pos = (pin % afperreg) * (8 / afperreg); - - regs[regoffset] &= ~(mask << pos); - regs[regoffset] |= af << pos; - - pins &= ~(1 << pin); - } - - ret = __stmpe_block_write(stmpe, regaddr, numregs, regs); - -out: - mutex_unlock(&stmpe->lock); - return ret; -} -EXPORT_SYMBOL_GPL(stmpe_set_altfunc); - -/* - * GPIO (all variants) - */ - -static struct resource stmpe_gpio_resources[] = { - /* Start and end filled dynamically */ - { - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell stmpe_gpio_cell = { - .name = "stmpe-gpio", - .resources = stmpe_gpio_resources, - .num_resources = ARRAY_SIZE(stmpe_gpio_resources), -}; - -/* - * Keypad (1601, 2401, 2403) - */ - -static struct resource stmpe_keypad_resources[] = { - { - .name = "KEYPAD", - .start = 0, - .end = 0, - .flags = IORESOURCE_IRQ, - }, - { - .name = "KEYPAD_OVER", - .start = 1, - .end = 1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell stmpe_keypad_cell = { - .name = "stmpe-keypad", - .resources = stmpe_keypad_resources, - .num_resources = ARRAY_SIZE(stmpe_keypad_resources), -}; - -/* - * Touchscreen (STMPE811) - */ - -static struct resource stmpe_ts_resources[] = { - { - .name = "TOUCH_DET", - .start = 0, - .end = 0, - .flags = IORESOURCE_IRQ, - }, - { - .name = "FIFO_TH", - .start = 1, - .end = 1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell stmpe_ts_cell = { - .name = "stmpe-ts", - .resources = stmpe_ts_resources, - .num_resources = ARRAY_SIZE(stmpe_ts_resources), -}; - -/* - * STMPE811 - */ - -static const u8 stmpe811_regs[] = { - [STMPE_IDX_CHIP_ID] = STMPE811_REG_CHIP_ID, - [STMPE_IDX_ICR_LSB] = STMPE811_REG_INT_CTRL, - [STMPE_IDX_IER_LSB] = STMPE811_REG_INT_EN, - [STMPE_IDX_ISR_MSB] = STMPE811_REG_INT_STA, - [STMPE_IDX_GPMR_LSB] = STMPE811_REG_GPIO_MP_STA, - [STMPE_IDX_GPSR_LSB] = STMPE811_REG_GPIO_SET_PIN, - [STMPE_IDX_GPCR_LSB] = STMPE811_REG_GPIO_CLR_PIN, - [STMPE_IDX_GPDR_LSB] = STMPE811_REG_GPIO_DIR, - [STMPE_IDX_GPRER_LSB] = STMPE811_REG_GPIO_RE, - [STMPE_IDX_GPFER_LSB] = STMPE811_REG_GPIO_FE, - [STMPE_IDX_GPAFR_U_MSB] = STMPE811_REG_GPIO_AF, - [STMPE_IDX_IEGPIOR_LSB] = STMPE811_REG_GPIO_INT_EN, - [STMPE_IDX_ISGPIOR_MSB] = STMPE811_REG_GPIO_INT_STA, - [STMPE_IDX_GPEDR_MSB] = STMPE811_REG_GPIO_ED, -}; - -static struct stmpe_variant_block stmpe811_blocks[] = { - { - .cell = &stmpe_gpio_cell, - .irq = STMPE811_IRQ_GPIOC, - .block = STMPE_BLOCK_GPIO, - }, - { - .cell = &stmpe_ts_cell, - .irq = STMPE811_IRQ_TOUCH_DET, - .block = STMPE_BLOCK_TOUCHSCREEN, - }, -}; - -static int stmpe811_enable(struct stmpe *stmpe, unsigned int blocks, - bool enable) -{ - unsigned int mask = 0; - - if (blocks & STMPE_BLOCK_GPIO) - mask |= STMPE811_SYS_CTRL2_GPIO_OFF; - - if (blocks & STMPE_BLOCK_ADC) - mask |= STMPE811_SYS_CTRL2_ADC_OFF; - - if (blocks & STMPE_BLOCK_TOUCHSCREEN) - mask |= STMPE811_SYS_CTRL2_TSC_OFF; - - return __stmpe_set_bits(stmpe, STMPE811_REG_SYS_CTRL2, mask, - enable ? 0 : mask); -} - -static int stmpe811_get_altfunc(struct stmpe *stmpe, enum stmpe_block block) -{ - /* 0 for touchscreen, 1 for GPIO */ - return block != STMPE_BLOCK_TOUCHSCREEN; -} - -static struct stmpe_variant_info stmpe811 = { - .name = "stmpe811", - .id_val = 0x0811, - .id_mask = 0xffff, - .num_gpios = 8, - .af_bits = 1, - .regs = stmpe811_regs, - .blocks = stmpe811_blocks, - .num_blocks = ARRAY_SIZE(stmpe811_blocks), - .num_irqs = STMPE811_NR_INTERNAL_IRQS, - .enable = stmpe811_enable, - .get_altfunc = stmpe811_get_altfunc, -}; - -/* - * STMPE1601 - */ - -static const u8 stmpe1601_regs[] = { - [STMPE_IDX_CHIP_ID] = STMPE1601_REG_CHIP_ID, - [STMPE_IDX_ICR_LSB] = STMPE1601_REG_ICR_LSB, - [STMPE_IDX_IER_LSB] = STMPE1601_REG_IER_LSB, - [STMPE_IDX_ISR_MSB] = STMPE1601_REG_ISR_MSB, - [STMPE_IDX_GPMR_LSB] = STMPE1601_REG_GPIO_MP_LSB, - [STMPE_IDX_GPSR_LSB] = STMPE1601_REG_GPIO_SET_LSB, - [STMPE_IDX_GPCR_LSB] = STMPE1601_REG_GPIO_CLR_LSB, - [STMPE_IDX_GPDR_LSB] = STMPE1601_REG_GPIO_SET_DIR_LSB, - [STMPE_IDX_GPRER_LSB] = STMPE1601_REG_GPIO_RE_LSB, - [STMPE_IDX_GPFER_LSB] = STMPE1601_REG_GPIO_FE_LSB, - [STMPE_IDX_GPAFR_U_MSB] = STMPE1601_REG_GPIO_AF_U_MSB, - [STMPE_IDX_IEGPIOR_LSB] = STMPE1601_REG_INT_EN_GPIO_MASK_LSB, - [STMPE_IDX_ISGPIOR_MSB] = STMPE1601_REG_INT_STA_GPIO_MSB, - [STMPE_IDX_GPEDR_MSB] = STMPE1601_REG_GPIO_ED_MSB, -}; - -static struct stmpe_variant_block stmpe1601_blocks[] = { - { - .cell = &stmpe_gpio_cell, - .irq = STMPE24XX_IRQ_GPIOC, - .block = STMPE_BLOCK_GPIO, - }, - { - .cell = &stmpe_keypad_cell, - .irq = STMPE24XX_IRQ_KEYPAD, - .block = STMPE_BLOCK_KEYPAD, - }, -}; - -/* supported autosleep timeout delay (in msecs) */ -static const int stmpe_autosleep_delay[] = { - 4, 16, 32, 64, 128, 256, 512, 1024, -}; - -static int stmpe_round_timeout(int timeout) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(stmpe_autosleep_delay); i++) { - if (stmpe_autosleep_delay[i] >= timeout) - return i; - } - - /* - * requests for delays longer than supported should not return the - * longest supported delay - */ - return -EINVAL; -} - -static int stmpe_autosleep(struct stmpe *stmpe, int autosleep_timeout) -{ - int ret; - - if (!stmpe->variant->enable_autosleep) - return -ENOSYS; - - mutex_lock(&stmpe->lock); - ret = stmpe->variant->enable_autosleep(stmpe, autosleep_timeout); - mutex_unlock(&stmpe->lock); - - return ret; -} - -/* - * Both stmpe 1601/2403 support same layout for autosleep - */ -static int stmpe1601_autosleep(struct stmpe *stmpe, - int autosleep_timeout) -{ - int ret, timeout; - - /* choose the best available timeout */ - timeout = stmpe_round_timeout(autosleep_timeout); - if (timeout < 0) { - dev_err(stmpe->dev, "invalid timeout\n"); - return timeout; - } - - ret = __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL2, - STMPE1601_AUTOSLEEP_TIMEOUT_MASK, - timeout); - if (ret < 0) - return ret; - - return __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL2, - STPME1601_AUTOSLEEP_ENABLE, - STPME1601_AUTOSLEEP_ENABLE); -} - -static int stmpe1601_enable(struct stmpe *stmpe, unsigned int blocks, - bool enable) -{ - unsigned int mask = 0; - - if (blocks & STMPE_BLOCK_GPIO) - mask |= STMPE1601_SYS_CTRL_ENABLE_GPIO; - - if (blocks & STMPE_BLOCK_KEYPAD) - mask |= STMPE1601_SYS_CTRL_ENABLE_KPC; - - return __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL, mask, - enable ? mask : 0); -} - -static int stmpe1601_get_altfunc(struct stmpe *stmpe, enum stmpe_block block) -{ - switch (block) { - case STMPE_BLOCK_PWM: - return 2; - - case STMPE_BLOCK_KEYPAD: - return 1; - - case STMPE_BLOCK_GPIO: - default: - return 0; - } -} - -static struct stmpe_variant_info stmpe1601 = { - .name = "stmpe1601", - .id_val = 0x0210, - .id_mask = 0xfff0, /* at least 0x0210 and 0x0212 */ - .num_gpios = 16, - .af_bits = 2, - .regs = stmpe1601_regs, - .blocks = stmpe1601_blocks, - .num_blocks = ARRAY_SIZE(stmpe1601_blocks), - .num_irqs = STMPE1601_NR_INTERNAL_IRQS, - .enable = stmpe1601_enable, - .get_altfunc = stmpe1601_get_altfunc, - .enable_autosleep = stmpe1601_autosleep, -}; - -/* - * STMPE24XX - */ - -static const u8 stmpe24xx_regs[] = { - [STMPE_IDX_CHIP_ID] = STMPE24XX_REG_CHIP_ID, - [STMPE_IDX_ICR_LSB] = STMPE24XX_REG_ICR_LSB, - [STMPE_IDX_IER_LSB] = STMPE24XX_REG_IER_LSB, - [STMPE_IDX_ISR_MSB] = STMPE24XX_REG_ISR_MSB, - [STMPE_IDX_GPMR_LSB] = STMPE24XX_REG_GPMR_LSB, - [STMPE_IDX_GPSR_LSB] = STMPE24XX_REG_GPSR_LSB, - [STMPE_IDX_GPCR_LSB] = STMPE24XX_REG_GPCR_LSB, - [STMPE_IDX_GPDR_LSB] = STMPE24XX_REG_GPDR_LSB, - [STMPE_IDX_GPRER_LSB] = STMPE24XX_REG_GPRER_LSB, - [STMPE_IDX_GPFER_LSB] = STMPE24XX_REG_GPFER_LSB, - [STMPE_IDX_GPAFR_U_MSB] = STMPE24XX_REG_GPAFR_U_MSB, - [STMPE_IDX_IEGPIOR_LSB] = STMPE24XX_REG_IEGPIOR_LSB, - [STMPE_IDX_ISGPIOR_MSB] = STMPE24XX_REG_ISGPIOR_MSB, - [STMPE_IDX_GPEDR_MSB] = STMPE24XX_REG_GPEDR_MSB, -}; - -static struct stmpe_variant_block stmpe24xx_blocks[] = { - { - .cell = &stmpe_gpio_cell, - .irq = STMPE24XX_IRQ_GPIOC, - .block = STMPE_BLOCK_GPIO, - }, - { - .cell = &stmpe_keypad_cell, - .irq = STMPE24XX_IRQ_KEYPAD, - .block = STMPE_BLOCK_KEYPAD, - }, -}; - -static int stmpe24xx_enable(struct stmpe *stmpe, unsigned int blocks, - bool enable) -{ - unsigned int mask = 0; - - if (blocks & STMPE_BLOCK_GPIO) - mask |= STMPE24XX_SYS_CTRL_ENABLE_GPIO; - - if (blocks & STMPE_BLOCK_KEYPAD) - mask |= STMPE24XX_SYS_CTRL_ENABLE_KPC; - - return __stmpe_set_bits(stmpe, STMPE24XX_REG_SYS_CTRL, mask, - enable ? mask : 0); -} - -static int stmpe24xx_get_altfunc(struct stmpe *stmpe, enum stmpe_block block) -{ - switch (block) { - case STMPE_BLOCK_ROTATOR: - return 2; - - case STMPE_BLOCK_KEYPAD: - return 1; - - case STMPE_BLOCK_GPIO: - default: - return 0; - } -} - -static struct stmpe_variant_info stmpe2401 = { - .name = "stmpe2401", - .id_val = 0x0101, - .id_mask = 0xffff, - .num_gpios = 24, - .af_bits = 2, - .regs = stmpe24xx_regs, - .blocks = stmpe24xx_blocks, - .num_blocks = ARRAY_SIZE(stmpe24xx_blocks), - .num_irqs = STMPE24XX_NR_INTERNAL_IRQS, - .enable = stmpe24xx_enable, - .get_altfunc = stmpe24xx_get_altfunc, -}; - -static struct stmpe_variant_info stmpe2403 = { - .name = "stmpe2403", - .id_val = 0x0120, - .id_mask = 0xffff, - .num_gpios = 24, - .af_bits = 2, - .regs = stmpe24xx_regs, - .blocks = stmpe24xx_blocks, - .num_blocks = ARRAY_SIZE(stmpe24xx_blocks), - .num_irqs = STMPE24XX_NR_INTERNAL_IRQS, - .enable = stmpe24xx_enable, - .get_altfunc = stmpe24xx_get_altfunc, - .enable_autosleep = stmpe1601_autosleep, /* same as stmpe1601 */ -}; - -static struct stmpe_variant_info *stmpe_variant_info[] = { - [STMPE811] = &stmpe811, - [STMPE1601] = &stmpe1601, - [STMPE2401] = &stmpe2401, - [STMPE2403] = &stmpe2403, -}; - -static irqreturn_t stmpe_irq(int irq, void *data) -{ - struct stmpe *stmpe = data; - struct stmpe_variant_info *variant = stmpe->variant; - int num = DIV_ROUND_UP(variant->num_irqs, 8); - u8 israddr = stmpe->regs[STMPE_IDX_ISR_MSB]; - u8 isr[num]; - int ret; - int i; - - ret = stmpe_block_read(stmpe, israddr, num, isr); - if (ret < 0) - return IRQ_NONE; - - for (i = 0; i < num; i++) { - int bank = num - i - 1; - u8 status = isr[i]; - u8 clear; - - status &= stmpe->ier[bank]; - if (!status) - continue; - - clear = status; - while (status) { - int bit = __ffs(status); - int line = bank * 8 + bit; - - handle_nested_irq(stmpe->irq_base + line); - status &= ~(1 << bit); - } - - stmpe_reg_write(stmpe, israddr + i, clear); - } - - return IRQ_HANDLED; -} - -static void stmpe_irq_lock(unsigned int irq) -{ - struct stmpe *stmpe = get_irq_chip_data(irq); - - mutex_lock(&stmpe->irq_lock); -} - -static void stmpe_irq_sync_unlock(unsigned int irq) -{ - struct stmpe *stmpe = get_irq_chip_data(irq); - struct stmpe_variant_info *variant = stmpe->variant; - int num = DIV_ROUND_UP(variant->num_irqs, 8); - int i; - - for (i = 0; i < num; i++) { - u8 new = stmpe->ier[i]; - u8 old = stmpe->oldier[i]; - - if (new == old) - continue; - - stmpe->oldier[i] = new; - stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_IER_LSB] - i, new); - } - - mutex_unlock(&stmpe->irq_lock); -} - -static void stmpe_irq_mask(unsigned int irq) -{ - struct stmpe *stmpe = get_irq_chip_data(irq); - int offset = irq - stmpe->irq_base; - int regoffset = offset / 8; - int mask = 1 << (offset % 8); - - stmpe->ier[regoffset] &= ~mask; -} - -static void stmpe_irq_unmask(unsigned int irq) -{ - struct stmpe *stmpe = get_irq_chip_data(irq); - int offset = irq - stmpe->irq_base; - int regoffset = offset / 8; - int mask = 1 << (offset % 8); - - stmpe->ier[regoffset] |= mask; -} - -static struct irq_chip stmpe_irq_chip = { - .name = "stmpe", - .bus_lock = stmpe_irq_lock, - .bus_sync_unlock = stmpe_irq_sync_unlock, - .mask = stmpe_irq_mask, - .unmask = stmpe_irq_unmask, -}; - -static int __devinit stmpe_irq_init(struct stmpe *stmpe) -{ - int num_irqs = stmpe->variant->num_irqs; - int base = stmpe->irq_base; - int irq; - - for (irq = base; irq < base + num_irqs; irq++) { - set_irq_chip_data(irq, stmpe); - set_irq_chip_and_handler(irq, &stmpe_irq_chip, - handle_edge_irq); - set_irq_nested_thread(irq, 1); -#ifdef CONFIG_ARM - set_irq_flags(irq, IRQF_VALID); -#else - set_irq_noprobe(irq); -#endif - } - - return 0; -} - -static void stmpe_irq_remove(struct stmpe *stmpe) -{ - int num_irqs = stmpe->variant->num_irqs; - int base = stmpe->irq_base; - int irq; - - for (irq = base; irq < base + num_irqs; irq++) { -#ifdef CONFIG_ARM - set_irq_flags(irq, 0); -#endif - set_irq_chip_and_handler(irq, NULL, NULL); - set_irq_chip_data(irq, NULL); - } -} - -static int __devinit stmpe_chip_init(struct stmpe *stmpe) -{ - unsigned int irq_trigger = stmpe->pdata->irq_trigger; - int autosleep_timeout = stmpe->pdata->autosleep_timeout; - struct stmpe_variant_info *variant = stmpe->variant; - u8 icr = STMPE_ICR_LSB_GIM; - unsigned int id; - u8 data[2]; - int ret; - - ret = stmpe_block_read(stmpe, stmpe->regs[STMPE_IDX_CHIP_ID], - ARRAY_SIZE(data), data); - if (ret < 0) - return ret; - - id = (data[0] << 8) | data[1]; - if ((id & variant->id_mask) != variant->id_val) { - dev_err(stmpe->dev, "unknown chip id: %#x\n", id); - return -EINVAL; - } - - dev_info(stmpe->dev, "%s detected, chip id: %#x\n", variant->name, id); - - /* Disable all modules -- subdrivers should enable what they need. */ - ret = stmpe_disable(stmpe, ~0); - if (ret) - return ret; - - if (irq_trigger == IRQF_TRIGGER_FALLING || - irq_trigger == IRQF_TRIGGER_RISING) - icr |= STMPE_ICR_LSB_EDGE; - - if (irq_trigger == IRQF_TRIGGER_RISING || - irq_trigger == IRQF_TRIGGER_HIGH) - icr |= STMPE_ICR_LSB_HIGH; - - if (stmpe->pdata->irq_invert_polarity) - icr ^= STMPE_ICR_LSB_HIGH; - - if (stmpe->pdata->autosleep) { - ret = stmpe_autosleep(stmpe, autosleep_timeout); - if (ret) - return ret; - } - - return stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_ICR_LSB], icr); -} - -static int __devinit stmpe_add_device(struct stmpe *stmpe, - struct mfd_cell *cell, int irq) -{ - return mfd_add_devices(stmpe->dev, stmpe->pdata->id, cell, 1, - NULL, stmpe->irq_base + irq); -} - -static int __devinit stmpe_devices_init(struct stmpe *stmpe) -{ - struct stmpe_variant_info *variant = stmpe->variant; - unsigned int platform_blocks = stmpe->pdata->blocks; - int ret = -EINVAL; - int i; - - for (i = 0; i < variant->num_blocks; i++) { - struct stmpe_variant_block *block = &variant->blocks[i]; - - if (!(platform_blocks & block->block)) - continue; - - platform_blocks &= ~block->block; - ret = stmpe_add_device(stmpe, block->cell, block->irq); - if (ret) - return ret; - } - - if (platform_blocks) - dev_warn(stmpe->dev, - "platform wants blocks (%#x) not present on variant", - platform_blocks); - - return ret; -} - -static int __devinit stmpe_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - struct stmpe_platform_data *pdata = i2c->dev.platform_data; - struct stmpe *stmpe; - int ret; - - if (!pdata) - return -EINVAL; - - stmpe = kzalloc(sizeof(struct stmpe), GFP_KERNEL); - if (!stmpe) - return -ENOMEM; - - mutex_init(&stmpe->irq_lock); - mutex_init(&stmpe->lock); - - stmpe->dev = &i2c->dev; - stmpe->i2c = i2c; - - stmpe->pdata = pdata; - stmpe->irq_base = pdata->irq_base; - - stmpe->partnum = id->driver_data; - stmpe->variant = stmpe_variant_info[stmpe->partnum]; - stmpe->regs = stmpe->variant->regs; - stmpe->num_gpios = stmpe->variant->num_gpios; - - i2c_set_clientdata(i2c, stmpe); - - ret = stmpe_chip_init(stmpe); - if (ret) - goto out_free; - - ret = stmpe_irq_init(stmpe); - if (ret) - goto out_free; - - ret = request_threaded_irq(stmpe->i2c->irq, NULL, stmpe_irq, - pdata->irq_trigger | IRQF_ONESHOT, - "stmpe", stmpe); - if (ret) { - dev_err(stmpe->dev, "failed to request IRQ: %d\n", ret); - goto out_removeirq; - } - - ret = stmpe_devices_init(stmpe); - if (ret) { - dev_err(stmpe->dev, "failed to add children\n"); - goto out_removedevs; - } - - return 0; - -out_removedevs: - mfd_remove_devices(stmpe->dev); - free_irq(stmpe->i2c->irq, stmpe); -out_removeirq: - stmpe_irq_remove(stmpe); -out_free: - kfree(stmpe); - return ret; -} - -static int __devexit stmpe_remove(struct i2c_client *client) -{ - struct stmpe *stmpe = i2c_get_clientdata(client); - - mfd_remove_devices(stmpe->dev); - - free_irq(stmpe->i2c->irq, stmpe); - stmpe_irq_remove(stmpe); - - kfree(stmpe); - - return 0; -} - -static const struct i2c_device_id stmpe_id[] = { - { "stmpe811", STMPE811 }, - { "stmpe1601", STMPE1601 }, - { "stmpe2401", STMPE2401 }, - { "stmpe2403", STMPE2403 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, stmpe_id); - -static struct i2c_driver stmpe_driver = { - .driver.name = "stmpe", - .driver.owner = THIS_MODULE, - .probe = stmpe_probe, - .remove = __devexit_p(stmpe_remove), - .id_table = stmpe_id, -}; - -static int __init stmpe_init(void) -{ - return i2c_add_driver(&stmpe_driver); -} -subsys_initcall(stmpe_init); - -static void __exit stmpe_exit(void) -{ - i2c_del_driver(&stmpe_driver); -} -module_exit(stmpe_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("STMPE MFD core driver"); -MODULE_AUTHOR("Rabin Vincent "); diff --git a/trunk/drivers/mfd/stmpe.h b/trunk/drivers/mfd/stmpe.h deleted file mode 100644 index 0dbdc4e8cd77..000000000000 --- a/trunk/drivers/mfd/stmpe.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2010 - * - * License Terms: GNU General Public License, version 2 - * Author: Rabin Vincent for ST-Ericsson - */ - -#ifndef __STMPE_H -#define __STMPE_H - -#ifdef STMPE_DUMP_BYTES -static inline void stmpe_dump_bytes(const char *str, const void *buf, - size_t len) -{ - print_hex_dump_bytes(str, DUMP_PREFIX_OFFSET, buf, len); -} -#else -static inline void stmpe_dump_bytes(const char *str, const void *buf, - size_t len) -{ -} -#endif - -/** - * struct stmpe_variant_block - information about block - * @cell: base mfd cell - * @irq: interrupt number to be added to each IORESOURCE_IRQ - * in the cell - * @block: block id; used for identification with platform data and for - * enable and altfunc callbacks - */ -struct stmpe_variant_block { - struct mfd_cell *cell; - int irq; - enum stmpe_block block; -}; - -/** - * struct stmpe_variant_info - variant-specific information - * @name: part name - * @id_val: content of CHIPID register - * @id_mask: bits valid in CHIPID register for comparison with id_val - * @num_gpios: number of GPIOS - * @af_bits: number of bits used to specify the alternate function - * @blocks: list of blocks present on this device - * @num_blocks: number of blocks present on this device - * @num_irqs: number of internal IRQs available on this device - * @enable: callback to enable the specified blocks. - * Called with the I/O lock held. - * @get_altfunc: callback to get the alternate function number for the - * specific block - * @enable_autosleep: callback to configure autosleep with specified timeout - */ -struct stmpe_variant_info { - const char *name; - u16 id_val; - u16 id_mask; - int num_gpios; - int af_bits; - const u8 *regs; - struct stmpe_variant_block *blocks; - int num_blocks; - int num_irqs; - int (*enable)(struct stmpe *stmpe, unsigned int blocks, bool enable); - int (*get_altfunc)(struct stmpe *stmpe, enum stmpe_block block); - int (*enable_autosleep)(struct stmpe *stmpe, int autosleep_timeout); -}; - -#define STMPE_ICR_LSB_HIGH (1 << 2) -#define STMPE_ICR_LSB_EDGE (1 << 1) -#define STMPE_ICR_LSB_GIM (1 << 0) - -/* - * STMPE811 - */ - -#define STMPE811_IRQ_TOUCH_DET 0 -#define STMPE811_IRQ_FIFO_TH 1 -#define STMPE811_IRQ_FIFO_OFLOW 2 -#define STMPE811_IRQ_FIFO_FULL 3 -#define STMPE811_IRQ_FIFO_EMPTY 4 -#define STMPE811_IRQ_TEMP_SENS 5 -#define STMPE811_IRQ_ADC 6 -#define STMPE811_IRQ_GPIOC 7 -#define STMPE811_NR_INTERNAL_IRQS 8 - -#define STMPE811_REG_CHIP_ID 0x00 -#define STMPE811_REG_SYS_CTRL2 0x04 -#define STMPE811_REG_INT_CTRL 0x09 -#define STMPE811_REG_INT_EN 0x0A -#define STMPE811_REG_INT_STA 0x0B -#define STMPE811_REG_GPIO_INT_EN 0x0C -#define STMPE811_REG_GPIO_INT_STA 0x0D -#define STMPE811_REG_GPIO_SET_PIN 0x10 -#define STMPE811_REG_GPIO_CLR_PIN 0x11 -#define STMPE811_REG_GPIO_MP_STA 0x12 -#define STMPE811_REG_GPIO_DIR 0x13 -#define STMPE811_REG_GPIO_ED 0x14 -#define STMPE811_REG_GPIO_RE 0x15 -#define STMPE811_REG_GPIO_FE 0x16 -#define STMPE811_REG_GPIO_AF 0x17 - -#define STMPE811_SYS_CTRL2_ADC_OFF (1 << 0) -#define STMPE811_SYS_CTRL2_TSC_OFF (1 << 1) -#define STMPE811_SYS_CTRL2_GPIO_OFF (1 << 2) -#define STMPE811_SYS_CTRL2_TS_OFF (1 << 3) - -/* - * STMPE1601 - */ - -#define STMPE1601_IRQ_GPIOC 8 -#define STMPE1601_IRQ_PWM3 7 -#define STMPE1601_IRQ_PWM2 6 -#define STMPE1601_IRQ_PWM1 5 -#define STMPE1601_IRQ_PWM0 4 -#define STMPE1601_IRQ_KEYPAD_OVER 2 -#define STMPE1601_IRQ_KEYPAD 1 -#define STMPE1601_IRQ_WAKEUP 0 -#define STMPE1601_NR_INTERNAL_IRQS 9 - -#define STMPE1601_REG_SYS_CTRL 0x02 -#define STMPE1601_REG_SYS_CTRL2 0x03 -#define STMPE1601_REG_ICR_LSB 0x11 -#define STMPE1601_REG_IER_LSB 0x13 -#define STMPE1601_REG_ISR_MSB 0x14 -#define STMPE1601_REG_CHIP_ID 0x80 -#define STMPE1601_REG_INT_EN_GPIO_MASK_LSB 0x17 -#define STMPE1601_REG_INT_STA_GPIO_MSB 0x18 -#define STMPE1601_REG_GPIO_MP_LSB 0x87 -#define STMPE1601_REG_GPIO_SET_LSB 0x83 -#define STMPE1601_REG_GPIO_CLR_LSB 0x85 -#define STMPE1601_REG_GPIO_SET_DIR_LSB 0x89 -#define STMPE1601_REG_GPIO_ED_MSB 0x8A -#define STMPE1601_REG_GPIO_RE_LSB 0x8D -#define STMPE1601_REG_GPIO_FE_LSB 0x8F -#define STMPE1601_REG_GPIO_AF_U_MSB 0x92 - -#define STMPE1601_SYS_CTRL_ENABLE_GPIO (1 << 3) -#define STMPE1601_SYS_CTRL_ENABLE_KPC (1 << 1) -#define STMPE1601_SYSCON_ENABLE_SPWM (1 << 0) - -/* The 1601/2403 share the same masks */ -#define STMPE1601_AUTOSLEEP_TIMEOUT_MASK (0x7) -#define STPME1601_AUTOSLEEP_ENABLE (1 << 3) - -/* - * STMPE24xx - */ - -#define STMPE24XX_IRQ_GPIOC 8 -#define STMPE24XX_IRQ_PWM2 7 -#define STMPE24XX_IRQ_PWM1 6 -#define STMPE24XX_IRQ_PWM0 5 -#define STMPE24XX_IRQ_ROT_OVER 4 -#define STMPE24XX_IRQ_ROT 3 -#define STMPE24XX_IRQ_KEYPAD_OVER 2 -#define STMPE24XX_IRQ_KEYPAD 1 -#define STMPE24XX_IRQ_WAKEUP 0 -#define STMPE24XX_NR_INTERNAL_IRQS 9 - -#define STMPE24XX_REG_SYS_CTRL 0x02 -#define STMPE24XX_REG_ICR_LSB 0x11 -#define STMPE24XX_REG_IER_LSB 0x13 -#define STMPE24XX_REG_ISR_MSB 0x14 -#define STMPE24XX_REG_CHIP_ID 0x80 -#define STMPE24XX_REG_IEGPIOR_LSB 0x18 -#define STMPE24XX_REG_ISGPIOR_MSB 0x19 -#define STMPE24XX_REG_GPMR_LSB 0xA5 -#define STMPE24XX_REG_GPSR_LSB 0x85 -#define STMPE24XX_REG_GPCR_LSB 0x88 -#define STMPE24XX_REG_GPDR_LSB 0x8B -#define STMPE24XX_REG_GPEDR_MSB 0x8C -#define STMPE24XX_REG_GPRER_LSB 0x91 -#define STMPE24XX_REG_GPFER_LSB 0x94 -#define STMPE24XX_REG_GPAFR_U_MSB 0x9B - -#define STMPE24XX_SYS_CTRL_ENABLE_GPIO (1 << 3) -#define STMPE24XX_SYSCON_ENABLE_PWM (1 << 2) -#define STMPE24XX_SYS_CTRL_ENABLE_KPC (1 << 1) -#define STMPE24XX_SYSCON_ENABLE_ROT (1 << 0) - -#endif diff --git a/trunk/drivers/mfd/t7l66xb.c b/trunk/drivers/mfd/t7l66xb.c index 006c121f3f0d..5041d33adf0b 100644 --- a/trunk/drivers/mfd/t7l66xb.c +++ b/trunk/drivers/mfd/t7l66xb.c @@ -350,6 +350,7 @@ static int t7l66xb_probe(struct platform_device *dev) t7l66xb->clk48m = clk_get(&dev->dev, "CLK_CK48M"); if (IS_ERR(t7l66xb->clk48m)) { ret = PTR_ERR(t7l66xb->clk48m); + clk_put(t7l66xb->clk32k); goto err_clk48m_get; } @@ -424,8 +425,6 @@ static int t7l66xb_remove(struct platform_device *dev) ret = pdata->disable(dev); clk_disable(t7l66xb->clk48m); clk_put(t7l66xb->clk48m); - clk_disable(t7l66xb->clk32k); - clk_put(t7l66xb->clk32k); t7l66xb_detach_irq(dev); iounmap(t7l66xb->scr); release_resource(&t7l66xb->rscr); diff --git a/trunk/drivers/mfd/tc6387xb.c b/trunk/drivers/mfd/tc6387xb.c index 6315f63f017d..517f9bcdeaac 100644 --- a/trunk/drivers/mfd/tc6387xb.c +++ b/trunk/drivers/mfd/tc6387xb.c @@ -137,7 +137,7 @@ static struct mfd_cell tc6387xb_cells[] = { }, }; -static int __devinit tc6387xb_probe(struct platform_device *dev) +static int tc6387xb_probe(struct platform_device *dev) { struct tc6387xb_platform_data *pdata = dev->dev.platform_data; struct resource *iomem, *rscr; @@ -201,7 +201,6 @@ static int __devinit tc6387xb_probe(struct platform_device *dev) if (!ret) return 0; - iounmap(tc6387xb->scr); err_ioremap: release_resource(&tc6387xb->rscr); err_resource: @@ -212,17 +211,14 @@ static int __devinit tc6387xb_probe(struct platform_device *dev) return ret; } -static int __devexit tc6387xb_remove(struct platform_device *dev) +static int tc6387xb_remove(struct platform_device *dev) { - struct tc6387xb *tc6387xb = platform_get_drvdata(dev); + struct clk *clk32k = platform_get_drvdata(dev); mfd_remove_devices(&dev->dev); - iounmap(tc6387xb->scr); - release_resource(&tc6387xb->rscr); - clk_disable(tc6387xb->clk32k); - clk_put(tc6387xb->clk32k); + clk_disable(clk32k); + clk_put(clk32k); platform_set_drvdata(dev, NULL); - kfree(tc6387xb); return 0; } @@ -233,7 +229,7 @@ static struct platform_driver tc6387xb_platform_driver = { .name = "tc6387xb", }, .probe = tc6387xb_probe, - .remove = __devexit_p(tc6387xb_remove), + .remove = tc6387xb_remove, .suspend = tc6387xb_suspend, .resume = tc6387xb_resume, }; diff --git a/trunk/drivers/mfd/tc6393xb.c b/trunk/drivers/mfd/tc6393xb.c index ef6c42c8917a..fcf9068810fb 100644 --- a/trunk/drivers/mfd/tc6393xb.c +++ b/trunk/drivers/mfd/tc6393xb.c @@ -732,9 +732,9 @@ static int __devinit tc6393xb_probe(struct platform_device *dev) if (tc6393xb->gpio.base != -1) temp = gpiochip_remove(&tc6393xb->gpio); tcpd->disable(dev); -err_enable: - clk_disable(tc6393xb->clk); err_clk_enable: + clk_disable(tc6393xb->clk); +err_enable: iounmap(tc6393xb->scr); err_ioremap: release_resource(&tc6393xb->rscr); diff --git a/trunk/drivers/mfd/tps6507x.c b/trunk/drivers/mfd/tps6507x.c index fc0197649281..d859dffed39f 100644 --- a/trunk/drivers/mfd/tps6507x.c +++ b/trunk/drivers/mfd/tps6507x.c @@ -89,8 +89,10 @@ static int tps6507x_i2c_probe(struct i2c_client *i2c, int ret = 0; tps6507x = kzalloc(sizeof(struct tps6507x_dev), GFP_KERNEL); - if (tps6507x == NULL) + if (tps6507x == NULL) { + kfree(i2c); return -ENOMEM; + } i2c_set_clientdata(i2c, tps6507x); tps6507x->dev = &i2c->dev; diff --git a/trunk/drivers/mfd/tps6586x.c b/trunk/drivers/mfd/tps6586x.c deleted file mode 100644 index 4cde31e6a252..000000000000 --- a/trunk/drivers/mfd/tps6586x.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Core driver for TI TPS6586x PMIC family - * - * Copyright (c) 2010 CompuLab Ltd. - * Mike Rapoport - * - * Based on da903x.c. - * Copyright (C) 2008 Compulab, Ltd. - * Mike Rapoport - * Copyright (C) 2006-2008 Marvell International Ltd. - * Eric Miao - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -/* GPIO control registers */ -#define TPS6586X_GPIOSET1 0x5d -#define TPS6586X_GPIOSET2 0x5e - -/* device id */ -#define TPS6586X_VERSIONCRC 0xcd -#define TPS658621A_VERSIONCRC 0x15 - -struct tps6586x { - struct mutex lock; - struct device *dev; - struct i2c_client *client; - - struct gpio_chip gpio; -}; - -static inline int __tps6586x_read(struct i2c_client *client, - int reg, uint8_t *val) -{ - int ret; - - ret = i2c_smbus_read_byte_data(client, reg); - if (ret < 0) { - dev_err(&client->dev, "failed reading at 0x%02x\n", reg); - return ret; - } - - *val = (uint8_t)ret; - - return 0; -} - -static inline int __tps6586x_reads(struct i2c_client *client, int reg, - int len, uint8_t *val) -{ - int ret; - - ret = i2c_smbus_read_i2c_block_data(client, reg, len, val); - if (ret < 0) { - dev_err(&client->dev, "failed reading from 0x%02x\n", reg); - return ret; - } - - return 0; -} - -static inline int __tps6586x_write(struct i2c_client *client, - int reg, uint8_t val) -{ - int ret; - - ret = i2c_smbus_write_byte_data(client, reg, val); - if (ret < 0) { - dev_err(&client->dev, "failed writing 0x%02x to 0x%02x\n", - val, reg); - return ret; - } - - return 0; -} - -static inline int __tps6586x_writes(struct i2c_client *client, int reg, - int len, uint8_t *val) -{ - int ret; - - ret = i2c_smbus_write_i2c_block_data(client, reg, len, val); - if (ret < 0) { - dev_err(&client->dev, "failed writings to 0x%02x\n", reg); - return ret; - } - - return 0; -} - -int tps6586x_write(struct device *dev, int reg, uint8_t val) -{ - return __tps6586x_write(to_i2c_client(dev), reg, val); -} -EXPORT_SYMBOL_GPL(tps6586x_write); - -int tps6586x_writes(struct device *dev, int reg, int len, uint8_t *val) -{ - return __tps6586x_writes(to_i2c_client(dev), reg, len, val); -} -EXPORT_SYMBOL_GPL(tps6586x_writes); - -int tps6586x_read(struct device *dev, int reg, uint8_t *val) -{ - return __tps6586x_read(to_i2c_client(dev), reg, val); -} -EXPORT_SYMBOL_GPL(tps6586x_read); - -int tps6586x_reads(struct device *dev, int reg, int len, uint8_t *val) -{ - return __tps6586x_reads(to_i2c_client(dev), reg, len, val); -} -EXPORT_SYMBOL_GPL(tps6586x_reads); - -int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask) -{ - struct tps6586x *tps6586x = dev_get_drvdata(dev); - uint8_t reg_val; - int ret = 0; - - mutex_lock(&tps6586x->lock); - - ret = __tps6586x_read(to_i2c_client(dev), reg, ®_val); - if (ret) - goto out; - - if ((reg_val & bit_mask) == 0) { - reg_val |= bit_mask; - ret = __tps6586x_write(to_i2c_client(dev), reg, reg_val); - } -out: - mutex_unlock(&tps6586x->lock); - return ret; -} -EXPORT_SYMBOL_GPL(tps6586x_set_bits); - -int tps6586x_clr_bits(struct device *dev, int reg, uint8_t bit_mask) -{ - struct tps6586x *tps6586x = dev_get_drvdata(dev); - uint8_t reg_val; - int ret = 0; - - mutex_lock(&tps6586x->lock); - - ret = __tps6586x_read(to_i2c_client(dev), reg, ®_val); - if (ret) - goto out; - - if (reg_val & bit_mask) { - reg_val &= ~bit_mask; - ret = __tps6586x_write(to_i2c_client(dev), reg, reg_val); - } -out: - mutex_unlock(&tps6586x->lock); - return ret; -} -EXPORT_SYMBOL_GPL(tps6586x_clr_bits); - -int tps6586x_update(struct device *dev, int reg, uint8_t val, uint8_t mask) -{ - struct tps6586x *tps6586x = dev_get_drvdata(dev); - uint8_t reg_val; - int ret = 0; - - mutex_lock(&tps6586x->lock); - - ret = __tps6586x_read(tps6586x->client, reg, ®_val); - if (ret) - goto out; - - if ((reg_val & mask) != val) { - reg_val = (reg_val & ~mask) | val; - ret = __tps6586x_write(tps6586x->client, reg, reg_val); - } -out: - mutex_unlock(&tps6586x->lock); - return ret; -} -EXPORT_SYMBOL_GPL(tps6586x_update); - -static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset) -{ - struct tps6586x *tps6586x = container_of(gc, struct tps6586x, gpio); - uint8_t val; - int ret; - - ret = __tps6586x_read(tps6586x->client, TPS6586X_GPIOSET2, &val); - if (ret) - return ret; - - return !!(val & (1 << offset)); -} - - -static void tps6586x_gpio_set(struct gpio_chip *chip, unsigned offset, - int value) -{ - struct tps6586x *tps6586x = container_of(chip, struct tps6586x, gpio); - - __tps6586x_write(tps6586x->client, TPS6586X_GPIOSET2, - value << offset); -} - -static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset, - int value) -{ - struct tps6586x *tps6586x = container_of(gc, struct tps6586x, gpio); - uint8_t val, mask; - - tps6586x_gpio_set(gc, offset, value); - - val = 0x1 << (offset * 2); - mask = 0x3 << (offset * 2); - - return tps6586x_update(tps6586x->dev, TPS6586X_GPIOSET1, val, mask); -} - -static void tps6586x_gpio_init(struct tps6586x *tps6586x, int gpio_base) -{ - int ret; - - if (!gpio_base) - return; - - tps6586x->gpio.owner = THIS_MODULE; - tps6586x->gpio.label = tps6586x->client->name; - tps6586x->gpio.dev = tps6586x->dev; - tps6586x->gpio.base = gpio_base; - tps6586x->gpio.ngpio = 4; - tps6586x->gpio.can_sleep = 1; - - /* FIXME: add handling of GPIOs as dedicated inputs */ - tps6586x->gpio.direction_output = tps6586x_gpio_output; - tps6586x->gpio.set = tps6586x_gpio_set; - tps6586x->gpio.get = tps6586x_gpio_get; - - ret = gpiochip_add(&tps6586x->gpio); - if (ret) - dev_warn(tps6586x->dev, "GPIO registration failed: %d\n", ret); -} - -static int __remove_subdev(struct device *dev, void *unused) -{ - platform_device_unregister(to_platform_device(dev)); - return 0; -} - -static int tps6586x_remove_subdevs(struct tps6586x *tps6586x) -{ - return device_for_each_child(tps6586x->dev, NULL, __remove_subdev); -} - -static int __devinit tps6586x_add_subdevs(struct tps6586x *tps6586x, - struct tps6586x_platform_data *pdata) -{ - struct tps6586x_subdev_info *subdev; - struct platform_device *pdev; - int i, ret = 0; - - for (i = 0; i < pdata->num_subdevs; i++) { - subdev = &pdata->subdevs[i]; - - pdev = platform_device_alloc(subdev->name, subdev->id); - - pdev->dev.parent = tps6586x->dev; - pdev->dev.platform_data = subdev->platform_data; - - ret = platform_device_add(pdev); - if (ret) - goto failed; - } - return 0; - -failed: - tps6586x_remove_subdevs(tps6586x); - return ret; -} - -static int __devinit tps6586x_i2c_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct tps6586x_platform_data *pdata = client->dev.platform_data; - struct tps6586x *tps6586x; - int ret; - - if (!pdata) { - dev_err(&client->dev, "tps6586x requires platform data\n"); - return -ENOTSUPP; - } - - ret = i2c_smbus_read_byte_data(client, TPS6586X_VERSIONCRC); - if (ret < 0) { - dev_err(&client->dev, "Chip ID read failed: %d\n", ret); - return -EIO; - } - - if (ret != TPS658621A_VERSIONCRC) { - dev_err(&client->dev, "Unsupported chip ID: %x\n", ret); - return -ENODEV; - } - - tps6586x = kzalloc(sizeof(struct tps6586x), GFP_KERNEL); - if (tps6586x == NULL) - return -ENOMEM; - - tps6586x->client = client; - tps6586x->dev = &client->dev; - i2c_set_clientdata(client, tps6586x); - - mutex_init(&tps6586x->lock); - - ret = tps6586x_add_subdevs(tps6586x, pdata); - if (ret) { - dev_err(&client->dev, "add devices failed: %d\n", ret); - goto err_add_devs; - } - - tps6586x_gpio_init(tps6586x, pdata->gpio_base); - - return 0; - -err_add_devs: - kfree(tps6586x); - return ret; -} - -static int __devexit tps6586x_i2c_remove(struct i2c_client *client) -{ - return 0; -} - -static const struct i2c_device_id tps6586x_id_table[] = { - { "tps6586x", 0 }, - { }, -}; -MODULE_DEVICE_TABLE(i2c, tps6586x_id_table); - -static struct i2c_driver tps6586x_driver = { - .driver = { - .name = "tps6586x", - .owner = THIS_MODULE, - }, - .probe = tps6586x_i2c_probe, - .remove = __devexit_p(tps6586x_i2c_remove), - .id_table = tps6586x_id_table, -}; - -static int __init tps6586x_init(void) -{ - return i2c_add_driver(&tps6586x_driver); -} -subsys_initcall(tps6586x_init); - -static void __exit tps6586x_exit(void) -{ - i2c_del_driver(&tps6586x_driver); -} -module_exit(tps6586x_exit); - -MODULE_DESCRIPTION("TPS6586X core driver"); -MODULE_AUTHOR("Mike Rapoport "); -MODULE_LICENSE("GPL"); - diff --git a/trunk/drivers/mfd/twl6030-pwm.c b/trunk/drivers/mfd/twl6030-pwm.c deleted file mode 100644 index 5d25bdc78424..000000000000 --- a/trunk/drivers/mfd/twl6030-pwm.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * twl6030_pwm.c - * Driver for PHOENIX (TWL6030) Pulse Width Modulator - * - * Copyright (C) 2010 Texas Instruments - * Author: Hemanth V - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 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, see . - */ - -#include -#include -#include -#include - -#define LED_PWM_CTRL1 0xF4 -#define LED_PWM_CTRL2 0xF5 - -/* Max value for CTRL1 register */ -#define PWM_CTRL1_MAX 255 - -/* Pull down disable */ -#define PWM_CTRL2_DIS_PD (1 << 6) - -/* Current control 2.5 milli Amps */ -#define PWM_CTRL2_CURR_02 (2 << 4) - -/* LED supply source */ -#define PWM_CTRL2_SRC_VAC (1 << 2) - -/* LED modes */ -#define PWM_CTRL2_MODE_HW (0 << 0) -#define PWM_CTRL2_MODE_SW (1 << 0) -#define PWM_CTRL2_MODE_DIS (2 << 0) - -#define PWM_CTRL2_MODE_MASK 0x3 - -struct pwm_device { - const char *label; - unsigned int pwm_id; -}; - -int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns) -{ - u8 duty_cycle; - int ret; - - if (pwm == NULL || period_ns == 0 || duty_ns > period_ns) - return -EINVAL; - - duty_cycle = (duty_ns * PWM_CTRL1_MAX) / period_ns; - - ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, duty_cycle, LED_PWM_CTRL1); - - if (ret < 0) { - pr_err("%s: Failed to configure PWM, Error %d\n", - pwm->label, ret); - return ret; - } - return 0; -} -EXPORT_SYMBOL(pwm_config); - -int pwm_enable(struct pwm_device *pwm) -{ - u8 val; - int ret; - - ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2); - if (ret < 0) { - pr_err("%s: Failed to enable PWM, Error %d\n", pwm->label, ret); - return ret; - } - - /* Change mode to software control */ - val &= ~PWM_CTRL2_MODE_MASK; - val |= PWM_CTRL2_MODE_SW; - - ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2); - if (ret < 0) { - pr_err("%s: Failed to enable PWM, Error %d\n", pwm->label, ret); - return ret; - } - - twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2); - return 0; -} -EXPORT_SYMBOL(pwm_enable); - -void pwm_disable(struct pwm_device *pwm) -{ - u8 val; - int ret; - - ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2); - if (ret < 0) { - pr_err("%s: Failed to disable PWM, Error %d\n", - pwm->label, ret); - return; - } - - val &= ~PWM_CTRL2_MODE_MASK; - val |= PWM_CTRL2_MODE_HW; - - ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2); - if (ret < 0) { - pr_err("%s: Failed to disable PWM, Error %d\n", - pwm->label, ret); - return; - } - return; -} -EXPORT_SYMBOL(pwm_disable); - -struct pwm_device *pwm_request(int pwm_id, const char *label) -{ - u8 val; - int ret; - struct pwm_device *pwm; - - pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL); - if (pwm == NULL) { - pr_err("%s: failed to allocate memory\n", label); - return NULL; - } - - pwm->label = label; - pwm->pwm_id = pwm_id; - - /* Configure PWM */ - val = PWM_CTRL2_DIS_PD | PWM_CTRL2_CURR_02 | PWM_CTRL2_SRC_VAC | - PWM_CTRL2_MODE_HW; - - ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2); - - if (ret < 0) { - pr_err("%s: Failed to configure PWM, Error %d\n", - pwm->label, ret); - - kfree(pwm); - return NULL; - } - - return pwm; -} -EXPORT_SYMBOL(pwm_request); - -void pwm_free(struct pwm_device *pwm) -{ - pwm_disable(pwm); - kfree(pwm); -} -EXPORT_SYMBOL(pwm_free); diff --git a/trunk/drivers/mfd/ucb1400_core.c b/trunk/drivers/mfd/ucb1400_core.c index d73f84ba0f08..dbe280153f9e 100644 --- a/trunk/drivers/mfd/ucb1400_core.c +++ b/trunk/drivers/mfd/ucb1400_core.c @@ -114,7 +114,7 @@ static int ucb1400_core_probe(struct device *dev) err3: platform_device_put(ucb->ucb1400_ts); err2: - platform_device_del(ucb->ucb1400_gpio); + platform_device_unregister(ucb->ucb1400_gpio); err1: platform_device_put(ucb->ucb1400_gpio); err0: diff --git a/trunk/drivers/mfd/wm831x-core.c b/trunk/drivers/mfd/wm831x-core.c index 1e7aaaf6cc6f..1a968f34d679 100644 --- a/trunk/drivers/mfd/wm831x-core.c +++ b/trunk/drivers/mfd/wm831x-core.c @@ -95,7 +95,6 @@ enum wm831x_parent { WM8311 = 0x8311, WM8312 = 0x8312, WM8320 = 0x8320, - WM8321 = 0x8321, }; static int wm831x_reg_locked(struct wm831x *wm831x, unsigned short reg) @@ -1534,12 +1533,6 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) dev_info(wm831x->dev, "WM8320 revision %c\n", 'A' + rev); break; - case WM8321: - parent = WM8321; - wm831x->num_gpio = 12; - dev_info(wm831x->dev, "WM8321 revision %c\n", 'A' + rev); - break; - default: dev_err(wm831x->dev, "Unknown WM831x device %04x\n", ret); ret = -EINVAL; @@ -1614,12 +1607,6 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) NULL, 0); break; - case WM8321: - ret = mfd_add_devices(wm831x->dev, -1, - wm8320_devs, ARRAY_SIZE(wm8320_devs), - NULL, 0); - break; - default: /* If this happens the bus probe function is buggy */ BUG(); @@ -1757,8 +1744,10 @@ static int wm831x_i2c_probe(struct i2c_client *i2c, struct wm831x *wm831x; wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL); - if (wm831x == NULL) + if (wm831x == NULL) { + kfree(i2c); return -ENOMEM; + } i2c_set_clientdata(i2c, wm831x); wm831x->dev = &i2c->dev; @@ -1790,7 +1779,6 @@ static const struct i2c_device_id wm831x_i2c_id[] = { { "wm8311", WM8311 }, { "wm8312", WM8312 }, { "wm8320", WM8320 }, - { "wm8321", WM8321 }, { } }; MODULE_DEVICE_TABLE(i2c, wm831x_i2c_id); diff --git a/trunk/drivers/mfd/wm8350-core.c b/trunk/drivers/mfd/wm8350-core.c index e81cc31e4202..b5807484b4c9 100644 --- a/trunk/drivers/mfd/wm8350-core.c +++ b/trunk/drivers/mfd/wm8350-core.c @@ -536,7 +536,6 @@ static int wm8350_create_cache(struct wm8350 *wm8350, int type, int mode) } out: - kfree(wm8350->reg_cache); return ret; } @@ -701,7 +700,7 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq, ret = wm8350_irq_init(wm8350, irq, pdata); if (ret < 0) - goto err_free; + goto err; if (wm8350->irq_base) { ret = request_threaded_irq(wm8350->irq_base + @@ -739,9 +738,8 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq, err_irq: wm8350_irq_exit(wm8350); -err_free: - kfree(wm8350->reg_cache); err: + kfree(wm8350->reg_cache); return ret; } EXPORT_SYMBOL_GPL(wm8350_device_init); diff --git a/trunk/drivers/mfd/wm8994-core.c b/trunk/drivers/mfd/wm8994-core.c index b3b2aaf89dbe..ec71c9368906 100644 --- a/trunk/drivers/mfd/wm8994-core.c +++ b/trunk/drivers/mfd/wm8994-core.c @@ -326,10 +326,8 @@ static int wm8994_device_init(struct wm8994 *wm8994, unsigned long id, int irq) wm8994->supplies = kzalloc(sizeof(struct regulator_bulk_data) * ARRAY_SIZE(wm8994_main_supplies), GFP_KERNEL); - if (!wm8994->supplies) { - ret = -ENOMEM; + if (!wm8994->supplies) goto err; - } for (i = 0; i < ARRAY_SIZE(wm8994_main_supplies); i++) wm8994->supplies[i].supply = wm8994_main_supplies[i]; @@ -497,8 +495,10 @@ static int wm8994_i2c_probe(struct i2c_client *i2c, struct wm8994 *wm8994; wm8994 = kzalloc(sizeof(struct wm8994), GFP_KERNEL); - if (wm8994 == NULL) + if (wm8994 == NULL) { + kfree(i2c); return -ENOMEM; + } i2c_set_clientdata(i2c, wm8994); wm8994->dev = &i2c->dev; diff --git a/trunk/drivers/misc/lkdtm.c b/trunk/drivers/misc/lkdtm.c index ef34de7a8026..5bfb2a2041b8 100644 --- a/trunk/drivers/misc/lkdtm.c +++ b/trunk/drivers/misc/lkdtm.c @@ -124,9 +124,9 @@ static int count = DEFAULT_COUNT; module_param(recur_count, int, 0644); MODULE_PARM_DESC(recur_count, " Recursion level for the stack overflow test, "\ "default is 10"); -module_param(cpoint_name, charp, 0444); +module_param(cpoint_name, charp, 0644); MODULE_PARM_DESC(cpoint_name, " Crash Point, where kernel is to be crashed"); -module_param(cpoint_type, charp, 0444); +module_param(cpoint_type, charp, 0644); MODULE_PARM_DESC(cpoint_type, " Crash Point Type, action to be taken on "\ "hitting the crash point"); module_param(cpoint_count, int, 0644); diff --git a/trunk/drivers/mmc/card/block.c b/trunk/drivers/mmc/card/block.c index d545f79f6000..8433cde29c8b 100644 --- a/trunk/drivers/mmc/card/block.c +++ b/trunk/drivers/mmc/card/block.c @@ -247,76 +247,7 @@ static u32 get_card_status(struct mmc_card *card, struct request *req) return cmd.resp[0]; } -static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) -{ - struct mmc_blk_data *md = mq->data; - struct mmc_card *card = md->queue.card; - unsigned int from, nr, arg; - int err = 0; - - mmc_claim_host(card->host); - - if (!mmc_can_erase(card)) { - err = -EOPNOTSUPP; - goto out; - } - - from = blk_rq_pos(req); - nr = blk_rq_sectors(req); - - if (mmc_can_trim(card)) - arg = MMC_TRIM_ARG; - else - arg = MMC_ERASE_ARG; - - err = mmc_erase(card, from, nr, arg); -out: - spin_lock_irq(&md->lock); - __blk_end_request(req, err, blk_rq_bytes(req)); - spin_unlock_irq(&md->lock); - - mmc_release_host(card->host); - - return err ? 0 : 1; -} - -static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, - struct request *req) -{ - struct mmc_blk_data *md = mq->data; - struct mmc_card *card = md->queue.card; - unsigned int from, nr, arg; - int err = 0; - - mmc_claim_host(card->host); - - if (!mmc_can_secure_erase_trim(card)) { - err = -EOPNOTSUPP; - goto out; - } - - from = blk_rq_pos(req); - nr = blk_rq_sectors(req); - - if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr)) - arg = MMC_SECURE_TRIM1_ARG; - else - arg = MMC_SECURE_ERASE_ARG; - - err = mmc_erase(card, from, nr, arg); - if (!err && arg == MMC_SECURE_TRIM1_ARG) - err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG); -out: - spin_lock_irq(&md->lock); - __blk_end_request(req, err, blk_rq_bytes(req)); - spin_unlock_irq(&md->lock); - - mmc_release_host(card->host); - - return err ? 0 : 1; -} - -static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req) +static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) { struct mmc_blk_data *md = mq->data; struct mmc_card *card = md->queue.card; @@ -544,17 +475,6 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req) return 0; } -static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) -{ - if (req->cmd_flags & REQ_DISCARD) { - if (req->cmd_flags & REQ_SECURE) - return mmc_blk_issue_secdiscard_rq(mq, req); - else - return mmc_blk_issue_discard_rq(mq, req); - } else { - return mmc_blk_issue_rw_rq(mq, req); - } -} static inline int mmc_blk_readonly(struct mmc_card *card) { diff --git a/trunk/drivers/mmc/card/mmc_test.c b/trunk/drivers/mmc/card/mmc_test.c index 5dd8576b5c18..445d7db2277e 100644 --- a/trunk/drivers/mmc/card/mmc_test.c +++ b/trunk/drivers/mmc/card/mmc_test.c @@ -16,7 +16,6 @@ #include #include -#include /* For nr_free_buffer_pages() */ #define RESULT_OK 0 #define RESULT_FAIL 1 @@ -26,60 +25,6 @@ #define BUFFER_ORDER 2 #define BUFFER_SIZE (PAGE_SIZE << BUFFER_ORDER) -/* - * Limit the test area size to the maximum MMC HC erase group size. Note that - * the maximum SD allocation unit size is just 4MiB. - */ -#define TEST_AREA_MAX_SIZE (128 * 1024 * 1024) - -/** - * struct mmc_test_pages - pages allocated by 'alloc_pages()'. - * @page: first page in the allocation - * @order: order of the number of pages allocated - */ -struct mmc_test_pages { - struct page *page; - unsigned int order; -}; - -/** - * struct mmc_test_mem - allocated memory. - * @arr: array of allocations - * @cnt: number of allocations - */ -struct mmc_test_mem { - struct mmc_test_pages *arr; - unsigned int cnt; -}; - -/** - * struct mmc_test_area - information for performance tests. - * @max_sz: test area size (in bytes) - * @dev_addr: address on card at which to do performance tests - * @max_segs: maximum segments in scatterlist @sg - * @blocks: number of (512 byte) blocks currently mapped by @sg - * @sg_len: length of currently mapped scatterlist @sg - * @mem: allocated memory - * @sg: scatterlist - */ -struct mmc_test_area { - unsigned long max_sz; - unsigned int dev_addr; - unsigned int max_segs; - unsigned int blocks; - unsigned int sg_len; - struct mmc_test_mem *mem; - struct scatterlist *sg; -}; - -/** - * struct mmc_test_card - test information. - * @card: card under test - * @scratch: transfer buffer - * @buffer: transfer buffer - * @highmem: buffer for highmem tests - * @area: information for performance tests - */ struct mmc_test_card { struct mmc_card *card; @@ -88,7 +33,6 @@ struct mmc_test_card { #ifdef CONFIG_HIGHMEM struct page *highmem; #endif - struct mmc_test_area area; }; /*******************************************************************/ @@ -153,12 +97,6 @@ static void mmc_test_prepare_mrq(struct mmc_test_card *test, mmc_set_data_timeout(mrq->data, test->card); } -static int mmc_test_busy(struct mmc_command *cmd) -{ - return !(cmd->resp[0] & R1_READY_FOR_DATA) || - (R1_CURRENT_STATE(cmd->resp[0]) == 7); -} - /* * Wait for the card to finish the busy state */ @@ -179,13 +117,13 @@ static int mmc_test_wait_busy(struct mmc_test_card *test) if (ret) break; - if (!busy && mmc_test_busy(&cmd)) { + if (!busy && !(cmd.resp[0] & R1_READY_FOR_DATA)) { busy = 1; printk(KERN_INFO "%s: Warning: Host did not " "wait for busy state to end.\n", mmc_hostname(test->card->host)); } - } while (mmc_test_busy(&cmd)); + } while (!(cmd.resp[0] & R1_READY_FOR_DATA)); return ret; } @@ -232,248 +170,6 @@ static int mmc_test_buffer_transfer(struct mmc_test_card *test, return 0; } -static void mmc_test_free_mem(struct mmc_test_mem *mem) -{ - if (!mem) - return; - while (mem->cnt--) - __free_pages(mem->arr[mem->cnt].page, - mem->arr[mem->cnt].order); - kfree(mem->arr); - kfree(mem); -} - -/* - * Allocate a lot of memory, preferrably max_sz but at least min_sz. In case - * there isn't much memory do not exceed 1/16th total lowmem pages. - */ -static struct mmc_test_mem *mmc_test_alloc_mem(unsigned long min_sz, - unsigned long max_sz) -{ - unsigned long max_page_cnt = DIV_ROUND_UP(max_sz, PAGE_SIZE); - unsigned long min_page_cnt = DIV_ROUND_UP(min_sz, PAGE_SIZE); - unsigned long page_cnt = 0; - unsigned long limit = nr_free_buffer_pages() >> 4; - struct mmc_test_mem *mem; - - if (max_page_cnt > limit) - max_page_cnt = limit; - if (max_page_cnt < min_page_cnt) - max_page_cnt = min_page_cnt; - - mem = kzalloc(sizeof(struct mmc_test_mem), GFP_KERNEL); - if (!mem) - return NULL; - - mem->arr = kzalloc(sizeof(struct mmc_test_pages) * max_page_cnt, - GFP_KERNEL); - if (!mem->arr) - goto out_free; - - while (max_page_cnt) { - struct page *page; - unsigned int order; - gfp_t flags = GFP_KERNEL | GFP_DMA | __GFP_NOWARN | - __GFP_NORETRY; - - order = get_order(max_page_cnt << PAGE_SHIFT); - while (1) { - page = alloc_pages(flags, order); - if (page || !order) - break; - order -= 1; - } - if (!page) { - if (page_cnt < min_page_cnt) - goto out_free; - break; - } - mem->arr[mem->cnt].page = page; - mem->arr[mem->cnt].order = order; - mem->cnt += 1; - if (max_page_cnt <= (1UL << order)) - break; - max_page_cnt -= 1UL << order; - page_cnt += 1UL << order; - } - - return mem; - -out_free: - mmc_test_free_mem(mem); - return NULL; -} - -/* - * Map memory into a scatterlist. Optionally allow the same memory to be - * mapped more than once. - */ -static int mmc_test_map_sg(struct mmc_test_mem *mem, unsigned long sz, - struct scatterlist *sglist, int repeat, - unsigned int max_segs, unsigned int *sg_len) -{ - struct scatterlist *sg = NULL; - unsigned int i; - - sg_init_table(sglist, max_segs); - - *sg_len = 0; - do { - for (i = 0; i < mem->cnt; i++) { - unsigned long len = PAGE_SIZE << mem->arr[i].order; - - if (sz < len) - len = sz; - if (sg) - sg = sg_next(sg); - else - sg = sglist; - if (!sg) - return -EINVAL; - sg_set_page(sg, mem->arr[i].page, len, 0); - sz -= len; - *sg_len += 1; - if (!sz) - break; - } - } while (sz && repeat); - - if (sz) - return -EINVAL; - - if (sg) - sg_mark_end(sg); - - return 0; -} - -/* - * Map memory into a scatterlist so that no pages are contiguous. Allow the - * same memory to be mapped more than once. - */ -static int mmc_test_map_sg_max_scatter(struct mmc_test_mem *mem, - unsigned long sz, - struct scatterlist *sglist, - unsigned int max_segs, - unsigned int *sg_len) -{ - struct scatterlist *sg = NULL; - unsigned int i = mem->cnt, cnt; - unsigned long len; - void *base, *addr, *last_addr = NULL; - - sg_init_table(sglist, max_segs); - - *sg_len = 0; - while (sz && i) { - base = page_address(mem->arr[--i].page); - cnt = 1 << mem->arr[i].order; - while (sz && cnt) { - addr = base + PAGE_SIZE * --cnt; - if (last_addr && last_addr + PAGE_SIZE == addr) - continue; - last_addr = addr; - len = PAGE_SIZE; - if (sz < len) - len = sz; - if (sg) - sg = sg_next(sg); - else - sg = sglist; - if (!sg) - return -EINVAL; - sg_set_page(sg, virt_to_page(addr), len, 0); - sz -= len; - *sg_len += 1; - } - } - - if (sg) - sg_mark_end(sg); - - return 0; -} - -/* - * Calculate transfer rate in bytes per second. - */ -static unsigned int mmc_test_rate(uint64_t bytes, struct timespec *ts) -{ - uint64_t ns; - - ns = ts->tv_sec; - ns *= 1000000000; - ns += ts->tv_nsec; - - bytes *= 1000000000; - - while (ns > UINT_MAX) { - bytes >>= 1; - ns >>= 1; - } - - if (!ns) - return 0; - - do_div(bytes, (uint32_t)ns); - - return bytes; -} - -/* - * Print the transfer rate. - */ -static void mmc_test_print_rate(struct mmc_test_card *test, uint64_t bytes, - struct timespec *ts1, struct timespec *ts2) -{ - unsigned int rate, sectors = bytes >> 9; - struct timespec ts; - - ts = timespec_sub(*ts2, *ts1); - - rate = mmc_test_rate(bytes, &ts); - - printk(KERN_INFO "%s: Transfer of %u sectors (%u%s KiB) took %lu.%09lu " - "seconds (%u kB/s, %u KiB/s)\n", - mmc_hostname(test->card->host), sectors, sectors >> 1, - (sectors == 1 ? ".5" : ""), (unsigned long)ts.tv_sec, - (unsigned long)ts.tv_nsec, rate / 1000, rate / 1024); -} - -/* - * Print the average transfer rate. - */ -static void mmc_test_print_avg_rate(struct mmc_test_card *test, uint64_t bytes, - unsigned int count, struct timespec *ts1, - struct timespec *ts2) -{ - unsigned int rate, sectors = bytes >> 9; - uint64_t tot = bytes * count; - struct timespec ts; - - ts = timespec_sub(*ts2, *ts1); - - rate = mmc_test_rate(tot, &ts); - - printk(KERN_INFO "%s: Transfer of %u x %u sectors (%u x %u%s KiB) took " - "%lu.%09lu seconds (%u kB/s, %u KiB/s)\n", - mmc_hostname(test->card->host), count, sectors, count, - sectors >> 1, (sectors == 1 ? ".5" : ""), - (unsigned long)ts.tv_sec, (unsigned long)ts.tv_nsec, - rate / 1000, rate / 1024); -} - -/* - * Return the card size in sectors. - */ -static unsigned int mmc_test_capacity(struct mmc_card *card) -{ - if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) - return card->ext_csd.sectors; - else - return card->csd.capacity << (card->csd.read_blkbits - 9); -} - /*******************************************************************/ /* Test preparation and cleanup */ /*******************************************************************/ @@ -1197,419 +893,8 @@ static int mmc_test_multi_read_high(struct mmc_test_card *test) return 0; } -#else - -static int mmc_test_no_highmem(struct mmc_test_card *test) -{ - printk(KERN_INFO "%s: Highmem not configured - test skipped\n", - mmc_hostname(test->card->host)); - return 0; -} - #endif /* CONFIG_HIGHMEM */ -/* - * Map sz bytes so that it can be transferred. - */ -static int mmc_test_area_map(struct mmc_test_card *test, unsigned long sz, - int max_scatter) -{ - struct mmc_test_area *t = &test->area; - - t->blocks = sz >> 9; - - if (max_scatter) { - return mmc_test_map_sg_max_scatter(t->mem, sz, t->sg, - t->max_segs, &t->sg_len); - } else { - return mmc_test_map_sg(t->mem, sz, t->sg, 1, t->max_segs, - &t->sg_len); - } -} - -/* - * Transfer bytes mapped by mmc_test_area_map(). - */ -static int mmc_test_area_transfer(struct mmc_test_card *test, - unsigned int dev_addr, int write) -{ - struct mmc_test_area *t = &test->area; - - return mmc_test_simple_transfer(test, t->sg, t->sg_len, dev_addr, - t->blocks, 512, write); -} - -/* - * Map and transfer bytes. - */ -static int mmc_test_area_io(struct mmc_test_card *test, unsigned long sz, - unsigned int dev_addr, int write, int max_scatter, - int timed) -{ - struct timespec ts1, ts2; - int ret; - - ret = mmc_test_area_map(test, sz, max_scatter); - if (ret) - return ret; - - if (timed) - getnstimeofday(&ts1); - - ret = mmc_test_area_transfer(test, dev_addr, write); - if (ret) - return ret; - - if (timed) - getnstimeofday(&ts2); - - if (timed) - mmc_test_print_rate(test, sz, &ts1, &ts2); - - return 0; -} - -/* - * Write the test area entirely. - */ -static int mmc_test_area_fill(struct mmc_test_card *test) -{ - return mmc_test_area_io(test, test->area.max_sz, test->area.dev_addr, - 1, 0, 0); -} - -/* - * Erase the test area entirely. - */ -static int mmc_test_area_erase(struct mmc_test_card *test) -{ - struct mmc_test_area *t = &test->area; - - if (!mmc_can_erase(test->card)) - return 0; - - return mmc_erase(test->card, t->dev_addr, test->area.max_sz >> 9, - MMC_ERASE_ARG); -} - -/* - * Cleanup struct mmc_test_area. - */ -static int mmc_test_area_cleanup(struct mmc_test_card *test) -{ - struct mmc_test_area *t = &test->area; - - kfree(t->sg); - mmc_test_free_mem(t->mem); - - return 0; -} - -/* - * Initialize an area for testing large transfers. The size of the area is the - * preferred erase size which is a good size for optimal transfer speed. Note - * that is typically 4MiB for modern cards. The test area is set to the middle - * of the card because cards may have different charateristics at the front - * (for FAT file system optimization). Optionally, the area is erased (if the - * card supports it) which may improve write performance. Optionally, the area - * is filled with data for subsequent read tests. - */ -static int mmc_test_area_init(struct mmc_test_card *test, int erase, int fill) -{ - struct mmc_test_area *t = &test->area; - unsigned long min_sz = 64 * 1024; - int ret; - - ret = mmc_test_set_blksize(test, 512); - if (ret) - return ret; - - if (test->card->pref_erase > TEST_AREA_MAX_SIZE >> 9) - t->max_sz = TEST_AREA_MAX_SIZE; - else - t->max_sz = (unsigned long)test->card->pref_erase << 9; - /* - * Try to allocate enough memory for the whole area. Less is OK - * because the same memory can be mapped into the scatterlist more than - * once. - */ - t->mem = mmc_test_alloc_mem(min_sz, t->max_sz); - if (!t->mem) - return -ENOMEM; - - t->max_segs = DIV_ROUND_UP(t->max_sz, PAGE_SIZE); - t->sg = kmalloc(sizeof(struct scatterlist) * t->max_segs, GFP_KERNEL); - if (!t->sg) { - ret = -ENOMEM; - goto out_free; - } - - t->dev_addr = mmc_test_capacity(test->card) / 2; - t->dev_addr -= t->dev_addr % (t->max_sz >> 9); - - if (erase) { - ret = mmc_test_area_erase(test); - if (ret) - goto out_free; - } - - if (fill) { - ret = mmc_test_area_fill(test); - if (ret) - goto out_free; - } - - return 0; - -out_free: - mmc_test_area_cleanup(test); - return ret; -} - -/* - * Prepare for large transfers. Do not erase the test area. - */ -static int mmc_test_area_prepare(struct mmc_test_card *test) -{ - return mmc_test_area_init(test, 0, 0); -} - -/* - * Prepare for large transfers. Do erase the test area. - */ -static int mmc_test_area_prepare_erase(struct mmc_test_card *test) -{ - return mmc_test_area_init(test, 1, 0); -} - -/* - * Prepare for large transfers. Erase and fill the test area. - */ -static int mmc_test_area_prepare_fill(struct mmc_test_card *test) -{ - return mmc_test_area_init(test, 1, 1); -} - -/* - * Test best-case performance. Best-case performance is expected from - * a single large transfer. - * - * An additional option (max_scatter) allows the measurement of the same - * transfer but with no contiguous pages in the scatter list. This tests - * the efficiency of DMA to handle scattered pages. - */ -static int mmc_test_best_performance(struct mmc_test_card *test, int write, - int max_scatter) -{ - return mmc_test_area_io(test, test->area.max_sz, test->area.dev_addr, - write, max_scatter, 1); -} - -/* - * Best-case read performance. - */ -static int mmc_test_best_read_performance(struct mmc_test_card *test) -{ - return mmc_test_best_performance(test, 0, 0); -} - -/* - * Best-case write performance. - */ -static int mmc_test_best_write_performance(struct mmc_test_card *test) -{ - return mmc_test_best_performance(test, 1, 0); -} - -/* - * Best-case read performance into scattered pages. - */ -static int mmc_test_best_read_perf_max_scatter(struct mmc_test_card *test) -{ - return mmc_test_best_performance(test, 0, 1); -} - -/* - * Best-case write performance from scattered pages. - */ -static int mmc_test_best_write_perf_max_scatter(struct mmc_test_card *test) -{ - return mmc_test_best_performance(test, 1, 1); -} - -/* - * Single read performance by transfer size. - */ -static int mmc_test_profile_read_perf(struct mmc_test_card *test) -{ - unsigned long sz; - unsigned int dev_addr; - int ret; - - for (sz = 512; sz < test->area.max_sz; sz <<= 1) { - dev_addr = test->area.dev_addr + (sz >> 9); - ret = mmc_test_area_io(test, sz, dev_addr, 0, 0, 1); - if (ret) - return ret; - } - dev_addr = test->area.dev_addr; - return mmc_test_area_io(test, sz, dev_addr, 0, 0, 1); -} - -/* - * Single write performance by transfer size. - */ -static int mmc_test_profile_write_perf(struct mmc_test_card *test) -{ - unsigned long sz; - unsigned int dev_addr; - int ret; - - ret = mmc_test_area_erase(test); - if (ret) - return ret; - for (sz = 512; sz < test->area.max_sz; sz <<= 1) { - dev_addr = test->area.dev_addr + (sz >> 9); - ret = mmc_test_area_io(test, sz, dev_addr, 1, 0, 1); - if (ret) - return ret; - } - ret = mmc_test_area_erase(test); - if (ret) - return ret; - dev_addr = test->area.dev_addr; - return mmc_test_area_io(test, sz, dev_addr, 1, 0, 1); -} - -/* - * Single trim performance by transfer size. - */ -static int mmc_test_profile_trim_perf(struct mmc_test_card *test) -{ - unsigned long sz; - unsigned int dev_addr; - struct timespec ts1, ts2; - int ret; - - if (!mmc_can_trim(test->card)) - return RESULT_UNSUP_CARD; - - if (!mmc_can_erase(test->card)) - return RESULT_UNSUP_HOST; - - for (sz = 512; sz < test->area.max_sz; sz <<= 1) { - dev_addr = test->area.dev_addr + (sz >> 9); - getnstimeofday(&ts1); - ret = mmc_erase(test->card, dev_addr, sz >> 9, MMC_TRIM_ARG); - if (ret) - return ret; - getnstimeofday(&ts2); - mmc_test_print_rate(test, sz, &ts1, &ts2); - } - dev_addr = test->area.dev_addr; - getnstimeofday(&ts1); - ret = mmc_erase(test->card, dev_addr, sz >> 9, MMC_TRIM_ARG); - if (ret) - return ret; - getnstimeofday(&ts2); - mmc_test_print_rate(test, sz, &ts1, &ts2); - return 0; -} - -/* - * Consecutive read performance by transfer size. - */ -static int mmc_test_profile_seq_read_perf(struct mmc_test_card *test) -{ - unsigned long sz; - unsigned int dev_addr, i, cnt; - struct timespec ts1, ts2; - int ret; - - for (sz = 512; sz <= test->area.max_sz; sz <<= 1) { - cnt = test->area.max_sz / sz; - dev_addr = test->area.dev_addr; - getnstimeofday(&ts1); - for (i = 0; i < cnt; i++) { - ret = mmc_test_area_io(test, sz, dev_addr, 0, 0, 0); - if (ret) - return ret; - dev_addr += (sz >> 9); - } - getnstimeofday(&ts2); - mmc_test_print_avg_rate(test, sz, cnt, &ts1, &ts2); - } - return 0; -} - -/* - * Consecutive write performance by transfer size. - */ -static int mmc_test_profile_seq_write_perf(struct mmc_test_card *test) -{ - unsigned long sz; - unsigned int dev_addr, i, cnt; - struct timespec ts1, ts2; - int ret; - - for (sz = 512; sz <= test->area.max_sz; sz <<= 1) { - ret = mmc_test_area_erase(test); - if (ret) - return ret; - cnt = test->area.max_sz / sz; - dev_addr = test->area.dev_addr; - getnstimeofday(&ts1); - for (i = 0; i < cnt; i++) { - ret = mmc_test_area_io(test, sz, dev_addr, 1, 0, 0); - if (ret) - return ret; - dev_addr += (sz >> 9); - } - getnstimeofday(&ts2); - mmc_test_print_avg_rate(test, sz, cnt, &ts1, &ts2); - } - return 0; -} - -/* - * Consecutive trim performance by transfer size. - */ -static int mmc_test_profile_seq_trim_perf(struct mmc_test_card *test) -{ - unsigned long sz; - unsigned int dev_addr, i, cnt; - struct timespec ts1, ts2; - int ret; - - if (!mmc_can_trim(test->card)) - return RESULT_UNSUP_CARD; - - if (!mmc_can_erase(test->card)) - return RESULT_UNSUP_HOST; - - for (sz = 512; sz <= test->area.max_sz; sz <<= 1) { - ret = mmc_test_area_erase(test); - if (ret) - return ret; - ret = mmc_test_area_fill(test); - if (ret) - return ret; - cnt = test->area.max_sz / sz; - dev_addr = test->area.dev_addr; - getnstimeofday(&ts1); - for (i = 0; i < cnt; i++) { - ret = mmc_erase(test->card, dev_addr, sz >> 9, - MMC_TRIM_ARG); - if (ret) - return ret; - dev_addr += (sz >> 9); - } - getnstimeofday(&ts2); - mmc_test_print_avg_rate(test, sz, cnt, &ts1, &ts2); - } - return 0; -} - static const struct mmc_test_case mmc_test_cases[] = { { .name = "Basic write (no data verification)", @@ -1755,100 +1040,8 @@ static const struct mmc_test_case mmc_test_cases[] = { .cleanup = mmc_test_cleanup, }, -#else - - { - .name = "Highmem write", - .run = mmc_test_no_highmem, - }, - - { - .name = "Highmem read", - .run = mmc_test_no_highmem, - }, - - { - .name = "Multi-block highmem write", - .run = mmc_test_no_highmem, - }, - - { - .name = "Multi-block highmem read", - .run = mmc_test_no_highmem, - }, - #endif /* CONFIG_HIGHMEM */ - { - .name = "Best-case read performance", - .prepare = mmc_test_area_prepare_fill, - .run = mmc_test_best_read_performance, - .cleanup = mmc_test_area_cleanup, - }, - - { - .name = "Best-case write performance", - .prepare = mmc_test_area_prepare_erase, - .run = mmc_test_best_write_performance, - .cleanup = mmc_test_area_cleanup, - }, - - { - .name = "Best-case read performance into scattered pages", - .prepare = mmc_test_area_prepare_fill, - .run = mmc_test_best_read_perf_max_scatter, - .cleanup = mmc_test_area_cleanup, - }, - - { - .name = "Best-case write performance from scattered pages", - .prepare = mmc_test_area_prepare_erase, - .run = mmc_test_best_write_perf_max_scatter, - .cleanup = mmc_test_area_cleanup, - }, - - { - .name = "Single read performance by transfer size", - .prepare = mmc_test_area_prepare_fill, - .run = mmc_test_profile_read_perf, - .cleanup = mmc_test_area_cleanup, - }, - - { - .name = "Single write performance by transfer size", - .prepare = mmc_test_area_prepare, - .run = mmc_test_profile_write_perf, - .cleanup = mmc_test_area_cleanup, - }, - - { - .name = "Single trim performance by transfer size", - .prepare = mmc_test_area_prepare_fill, - .run = mmc_test_profile_trim_perf, - .cleanup = mmc_test_area_cleanup, - }, - - { - .name = "Consecutive read performance by transfer size", - .prepare = mmc_test_area_prepare_fill, - .run = mmc_test_profile_seq_read_perf, - .cleanup = mmc_test_area_cleanup, - }, - - { - .name = "Consecutive write performance by transfer size", - .prepare = mmc_test_area_prepare, - .run = mmc_test_profile_seq_write_perf, - .cleanup = mmc_test_area_cleanup, - }, - - { - .name = "Consecutive trim performance by transfer size", - .prepare = mmc_test_area_prepare, - .run = mmc_test_profile_seq_trim_perf, - .cleanup = mmc_test_area_cleanup, - }, - }; static DEFINE_MUTEX(mmc_test_lock); diff --git a/trunk/drivers/mmc/card/queue.c b/trunk/drivers/mmc/card/queue.c index e876678176be..c77eb49eda0e 100644 --- a/trunk/drivers/mmc/card/queue.c +++ b/trunk/drivers/mmc/card/queue.c @@ -30,9 +30,9 @@ static int mmc_prep_request(struct request_queue *q, struct request *req) { /* - * We only like normal block requests and discards. + * We only like normal block requests. */ - if (req->cmd_type != REQ_TYPE_FS && !(req->cmd_flags & REQ_DISCARD)) { + if (req->cmd_type != REQ_TYPE_FS) { blk_dump_rq_flags(req, "MMC bad request"); return BLKPREP_KILL; } @@ -130,21 +130,6 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock blk_queue_prep_rq(mq->queue, mmc_prep_request); blk_queue_ordered(mq->queue, QUEUE_ORDERED_DRAIN); queue_flag_set_unlocked(QUEUE_FLAG_NONROT, mq->queue); - if (mmc_can_erase(card)) { - queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mq->queue); - mq->queue->limits.max_discard_sectors = UINT_MAX; - if (card->erased_byte == 0) - mq->queue->limits.discard_zeroes_data = 1; - if (!mmc_can_trim(card) && is_power_of_2(card->erase_size)) { - mq->queue->limits.discard_granularity = - card->erase_size << 9; - mq->queue->limits.discard_alignment = - card->erase_size << 9; - } - if (mmc_can_secure_erase_trim(card)) - queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, - mq->queue); - } #ifdef CONFIG_MMC_BLOCK_BOUNCE if (host->max_hw_segs == 1) { diff --git a/trunk/drivers/mmc/core/core.c b/trunk/drivers/mmc/core/core.c index 5db49b124ffa..83240faa1dc8 100644 --- a/trunk/drivers/mmc/core/core.c +++ b/trunk/drivers/mmc/core/core.c @@ -1050,352 +1050,6 @@ void mmc_detect_change(struct mmc_host *host, unsigned long delay) EXPORT_SYMBOL(mmc_detect_change); -void mmc_init_erase(struct mmc_card *card) -{ - unsigned int sz; - - if (is_power_of_2(card->erase_size)) - card->erase_shift = ffs(card->erase_size) - 1; - else - card->erase_shift = 0; - - /* - * It is possible to erase an arbitrarily large area of an SD or MMC - * card. That is not desirable because it can take a long time - * (minutes) potentially delaying more important I/O, and also the - * timeout calculations become increasingly hugely over-estimated. - * Consequently, 'pref_erase' is defined as a guide to limit erases - * to that size and alignment. - * - * For SD cards that define Allocation Unit size, limit erases to one - * Allocation Unit at a time. For MMC cards that define High Capacity - * Erase Size, whether it is switched on or not, limit to that size. - * Otherwise just have a stab at a good value. For modern cards it - * will end up being 4MiB. Note that if the value is too small, it - * can end up taking longer to erase. - */ - if (mmc_card_sd(card) && card->ssr.au) { - card->pref_erase = card->ssr.au; - card->erase_shift = ffs(card->ssr.au) - 1; - } else if (card->ext_csd.hc_erase_size) { - card->pref_erase = card->ext_csd.hc_erase_size; - } else { - sz = (card->csd.capacity << (card->csd.read_blkbits - 9)) >> 11; - if (sz < 128) - card->pref_erase = 512 * 1024 / 512; - else if (sz < 512) - card->pref_erase = 1024 * 1024 / 512; - else if (sz < 1024) - card->pref_erase = 2 * 1024 * 1024 / 512; - else - card->pref_erase = 4 * 1024 * 1024 / 512; - if (card->pref_erase < card->erase_size) - card->pref_erase = card->erase_size; - else { - sz = card->pref_erase % card->erase_size; - if (sz) - card->pref_erase += card->erase_size - sz; - } - } -} - -static void mmc_set_mmc_erase_timeout(struct mmc_card *card, - struct mmc_command *cmd, - unsigned int arg, unsigned int qty) -{ - unsigned int erase_timeout; - - if (card->ext_csd.erase_group_def & 1) { - /* High Capacity Erase Group Size uses HC timeouts */ - if (arg == MMC_TRIM_ARG) - erase_timeout = card->ext_csd.trim_timeout; - else - erase_timeout = card->ext_csd.hc_erase_timeout; - } else { - /* CSD Erase Group Size uses write timeout */ - unsigned int mult = (10 << card->csd.r2w_factor); - unsigned int timeout_clks = card->csd.tacc_clks * mult; - unsigned int timeout_us; - - /* Avoid overflow: e.g. tacc_ns=80000000 mult=1280 */ - if (card->csd.tacc_ns < 1000000) - timeout_us = (card->csd.tacc_ns * mult) / 1000; - else - timeout_us = (card->csd.tacc_ns / 1000) * mult; - - /* - * ios.clock is only a target. The real clock rate might be - * less but not that much less, so fudge it by multiplying by 2. - */ - timeout_clks <<= 1; - timeout_us += (timeout_clks * 1000) / - (card->host->ios.clock / 1000); - - erase_timeout = timeout_us / 1000; - - /* - * Theoretically, the calculation could underflow so round up - * to 1ms in that case. - */ - if (!erase_timeout) - erase_timeout = 1; - } - - /* Multiplier for secure operations */ - if (arg & MMC_SECURE_ARGS) { - if (arg == MMC_SECURE_ERASE_ARG) - erase_timeout *= card->ext_csd.sec_erase_mult; - else - erase_timeout *= card->ext_csd.sec_trim_mult; - } - - erase_timeout *= qty; - - /* - * Ensure at least a 1 second timeout for SPI as per - * 'mmc_set_data_timeout()' - */ - if (mmc_host_is_spi(card->host) && erase_timeout < 1000) - erase_timeout = 1000; - - cmd->erase_timeout = erase_timeout; -} - -static void mmc_set_sd_erase_timeout(struct mmc_card *card, - struct mmc_command *cmd, unsigned int arg, - unsigned int qty) -{ - if (card->ssr.erase_timeout) { - /* Erase timeout specified in SD Status Register (SSR) */ - cmd->erase_timeout = card->ssr.erase_timeout * qty + - card->ssr.erase_offset; - } else { - /* - * Erase timeout not specified in SD Status Register (SSR) so - * use 250ms per write block. - */ - cmd->erase_timeout = 250 * qty; - } - - /* Must not be less than 1 second */ - if (cmd->erase_timeout < 1000) - cmd->erase_timeout = 1000; -} - -static void mmc_set_erase_timeout(struct mmc_card *card, - struct mmc_command *cmd, unsigned int arg, - unsigned int qty) -{ - if (mmc_card_sd(card)) - mmc_set_sd_erase_timeout(card, cmd, arg, qty); - else - mmc_set_mmc_erase_timeout(card, cmd, arg, qty); -} - -static int mmc_do_erase(struct mmc_card *card, unsigned int from, - unsigned int to, unsigned int arg) -{ - struct mmc_command cmd; - unsigned int qty = 0; - int err; - - /* - * qty is used to calculate the erase timeout which depends on how many - * erase groups (or allocation units in SD terminology) are affected. - * We count erasing part of an erase group as one erase group. - * For SD, the allocation units are always a power of 2. For MMC, the - * erase group size is almost certainly also power of 2, but it does not - * seem to insist on that in the JEDEC standard, so we fall back to - * division in that case. SD may not specify an allocation unit size, - * in which case the timeout is based on the number of write blocks. - * - * Note that the timeout for secure trim 2 will only be correct if the - * number of erase groups specified is the same as the total of all - * preceding secure trim 1 commands. Since the power may have been - * lost since the secure trim 1 commands occurred, it is generally - * impossible to calculate the secure trim 2 timeout correctly. - */ - if (card->erase_shift) - qty += ((to >> card->erase_shift) - - (from >> card->erase_shift)) + 1; - else if (mmc_card_sd(card)) - qty += to - from + 1; - else - qty += ((to / card->erase_size) - - (from / card->erase_size)) + 1; - - if (!mmc_card_blockaddr(card)) { - from <<= 9; - to <<= 9; - } - - memset(&cmd, 0, sizeof(struct mmc_command)); - if (mmc_card_sd(card)) - cmd.opcode = SD_ERASE_WR_BLK_START; - else - cmd.opcode = MMC_ERASE_GROUP_START; - cmd.arg = from; - cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; - err = mmc_wait_for_cmd(card->host, &cmd, 0); - if (err) { - printk(KERN_ERR "mmc_erase: group start error %d, " - "status %#x\n", err, cmd.resp[0]); - err = -EINVAL; - goto out; - } - - memset(&cmd, 0, sizeof(struct mmc_command)); - if (mmc_card_sd(card)) - cmd.opcode = SD_ERASE_WR_BLK_END; - else - cmd.opcode = MMC_ERASE_GROUP_END; - cmd.arg = to; - cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; - err = mmc_wait_for_cmd(card->host, &cmd, 0); - if (err) { - printk(KERN_ERR "mmc_erase: group end error %d, status %#x\n", - err, cmd.resp[0]); - err = -EINVAL; - goto out; - } - - memset(&cmd, 0, sizeof(struct mmc_command)); - cmd.opcode = MMC_ERASE; - cmd.arg = arg; - cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; - mmc_set_erase_timeout(card, &cmd, arg, qty); - err = mmc_wait_for_cmd(card->host, &cmd, 0); - if (err) { - printk(KERN_ERR "mmc_erase: erase error %d, status %#x\n", - err, cmd.resp[0]); - err = -EIO; - goto out; - } - - if (mmc_host_is_spi(card->host)) - goto out; - - do { - memset(&cmd, 0, sizeof(struct mmc_command)); - cmd.opcode = MMC_SEND_STATUS; - cmd.arg = card->rca << 16; - cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; - /* Do not retry else we can't see errors */ - err = mmc_wait_for_cmd(card->host, &cmd, 0); - if (err || (cmd.resp[0] & 0xFDF92000)) { - printk(KERN_ERR "error %d requesting status %#x\n", - err, cmd.resp[0]); - err = -EIO; - goto out; - } - } while (!(cmd.resp[0] & R1_READY_FOR_DATA) || - R1_CURRENT_STATE(cmd.resp[0]) == 7); -out: - return err; -} - -/** - * mmc_erase - erase sectors. - * @card: card to erase - * @from: first sector to erase - * @nr: number of sectors to erase - * @arg: erase command argument (SD supports only %MMC_ERASE_ARG) - * - * Caller must claim host before calling this function. - */ -int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr, - unsigned int arg) -{ - unsigned int rem, to = from + nr; - - if (!(card->host->caps & MMC_CAP_ERASE) || - !(card->csd.cmdclass & CCC_ERASE)) - return -EOPNOTSUPP; - - if (!card->erase_size) - return -EOPNOTSUPP; - - if (mmc_card_sd(card) && arg != MMC_ERASE_ARG) - return -EOPNOTSUPP; - - if ((arg & MMC_SECURE_ARGS) && - !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN)) - return -EOPNOTSUPP; - - if ((arg & MMC_TRIM_ARGS) && - !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)) - return -EOPNOTSUPP; - - if (arg == MMC_SECURE_ERASE_ARG) { - if (from % card->erase_size || nr % card->erase_size) - return -EINVAL; - } - - if (arg == MMC_ERASE_ARG) { - rem = from % card->erase_size; - if (rem) { - rem = card->erase_size - rem; - from += rem; - if (nr > rem) - nr -= rem; - else - return 0; - } - rem = nr % card->erase_size; - if (rem) - nr -= rem; - } - - if (nr == 0) - return 0; - - to = from + nr; - - if (to <= from) - return -EINVAL; - - /* 'from' and 'to' are inclusive */ - to -= 1; - - return mmc_do_erase(card, from, to, arg); -} -EXPORT_SYMBOL(mmc_erase); - -int mmc_can_erase(struct mmc_card *card) -{ - if ((card->host->caps & MMC_CAP_ERASE) && - (card->csd.cmdclass & CCC_ERASE) && card->erase_size) - return 1; - return 0; -} -EXPORT_SYMBOL(mmc_can_erase); - -int mmc_can_trim(struct mmc_card *card) -{ - if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) - return 1; - return 0; -} -EXPORT_SYMBOL(mmc_can_trim); - -int mmc_can_secure_erase_trim(struct mmc_card *card) -{ - if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) - return 1; - return 0; -} -EXPORT_SYMBOL(mmc_can_secure_erase_trim); - -int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from, - unsigned int nr) -{ - if (!card->erase_size) - return 0; - if (from % card->erase_size || nr % card->erase_size) - return 0; - return 1; -} -EXPORT_SYMBOL(mmc_erase_group_aligned); void mmc_rescan(struct work_struct *work) { diff --git a/trunk/drivers/mmc/core/core.h b/trunk/drivers/mmc/core/core.h index 9d9eef50e5d1..a811c52a1659 100644 --- a/trunk/drivers/mmc/core/core.h +++ b/trunk/drivers/mmc/core/core.h @@ -29,8 +29,6 @@ struct mmc_bus_ops { void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops); void mmc_detach_bus(struct mmc_host *host); -void mmc_init_erase(struct mmc_card *card); - void mmc_set_chip_select(struct mmc_host *host, int mode); void mmc_set_clock(struct mmc_host *host, unsigned int hz); void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); diff --git a/trunk/drivers/mmc/core/mmc.c b/trunk/drivers/mmc/core/mmc.c index 6909a54c39be..ccba3869c029 100644 --- a/trunk/drivers/mmc/core/mmc.c +++ b/trunk/drivers/mmc/core/mmc.c @@ -108,23 +108,13 @@ static int mmc_decode_cid(struct mmc_card *card) return 0; } -static void mmc_set_erase_size(struct mmc_card *card) -{ - if (card->ext_csd.erase_group_def & 1) - card->erase_size = card->ext_csd.hc_erase_size; - else - card->erase_size = card->csd.erase_size; - - mmc_init_erase(card); -} - /* * Given a 128-bit response, decode to our card CSD structure. */ static int mmc_decode_csd(struct mmc_card *card) { struct mmc_csd *csd = &card->csd; - unsigned int e, m, a, b; + unsigned int e, m; u32 *resp = card->raw_csd; /* @@ -162,13 +152,6 @@ static int mmc_decode_csd(struct mmc_card *card) csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); csd->write_partial = UNSTUFF_BITS(resp, 21, 1); - if (csd->write_blkbits >= 9) { - a = UNSTUFF_BITS(resp, 42, 5); - b = UNSTUFF_BITS(resp, 37, 5); - csd->erase_size = (a + 1) * (b + 1); - csd->erase_size <<= csd->write_blkbits - 9; - } - return 0; } @@ -278,30 +261,8 @@ static int mmc_read_ext_csd(struct mmc_card *card) if (sa_shift > 0 && sa_shift <= 0x17) card->ext_csd.sa_timeout = 1 << ext_csd[EXT_CSD_S_A_TIMEOUT]; - card->ext_csd.erase_group_def = - ext_csd[EXT_CSD_ERASE_GROUP_DEF]; - card->ext_csd.hc_erase_timeout = 300 * - ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT]; - card->ext_csd.hc_erase_size = - ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] << 10; - } - - if (card->ext_csd.rev >= 4) { - card->ext_csd.sec_trim_mult = - ext_csd[EXT_CSD_SEC_TRIM_MULT]; - card->ext_csd.sec_erase_mult = - ext_csd[EXT_CSD_SEC_ERASE_MULT]; - card->ext_csd.sec_feature_support = - ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT]; - card->ext_csd.trim_timeout = 300 * - ext_csd[EXT_CSD_TRIM_MULT]; } - if (ext_csd[EXT_CSD_ERASED_MEM_CONT]) - card->erased_byte = 0xFF; - else - card->erased_byte = 0x0; - out: kfree(ext_csd); @@ -313,8 +274,6 @@ MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1], MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1], card->raw_csd[2], card->raw_csd[3]); MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year); -MMC_DEV_ATTR(erase_size, "%u\n", card->erase_size << 9); -MMC_DEV_ATTR(preferred_erase_size, "%u\n", card->pref_erase << 9); MMC_DEV_ATTR(fwrev, "0x%x\n", card->cid.fwrev); MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev); MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid); @@ -326,8 +285,6 @@ static struct attribute *mmc_std_attrs[] = { &dev_attr_cid.attr, &dev_attr_csd.attr, &dev_attr_date.attr, - &dev_attr_erase_size.attr, - &dev_attr_preferred_erase_size.attr, &dev_attr_fwrev.attr, &dev_attr_hwrev.attr, &dev_attr_manfid.attr, @@ -464,8 +421,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, err = mmc_read_ext_csd(card); if (err) goto free_card; - /* Erase size depends on CSD and Extended CSD */ - mmc_set_erase_size(card); } /* diff --git a/trunk/drivers/mmc/core/sd.c b/trunk/drivers/mmc/core/sd.c index 0f5241085557..e6d7d9fab446 100644 --- a/trunk/drivers/mmc/core/sd.c +++ b/trunk/drivers/mmc/core/sd.c @@ -119,13 +119,6 @@ static int mmc_decode_csd(struct mmc_card *card) csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3); csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); csd->write_partial = UNSTUFF_BITS(resp, 21, 1); - - if (UNSTUFF_BITS(resp, 46, 1)) { - csd->erase_size = 1; - } else if (csd->write_blkbits >= 9) { - csd->erase_size = UNSTUFF_BITS(resp, 39, 7) + 1; - csd->erase_size <<= csd->write_blkbits - 9; - } break; case 1: /* @@ -154,7 +147,6 @@ static int mmc_decode_csd(struct mmc_card *card) csd->r2w_factor = 4; /* Unused */ csd->write_blkbits = 9; csd->write_partial = 0; - csd->erase_size = 1; break; default: printk(KERN_ERR "%s: unrecognised CSD structure version %d\n", @@ -162,8 +154,6 @@ static int mmc_decode_csd(struct mmc_card *card) return -EINVAL; } - card->erase_size = csd->erase_size; - return 0; } @@ -189,67 +179,9 @@ static int mmc_decode_scr(struct mmc_card *card) scr->sda_vsn = UNSTUFF_BITS(resp, 56, 4); scr->bus_widths = UNSTUFF_BITS(resp, 48, 4); - if (UNSTUFF_BITS(resp, 55, 1)) - card->erased_byte = 0xFF; - else - card->erased_byte = 0x0; - return 0; } -/* - * Fetch and process SD Status register. - */ -static int mmc_read_ssr(struct mmc_card *card) -{ - unsigned int au, es, et, eo; - int err, i; - u32 *ssr; - - if (!(card->csd.cmdclass & CCC_APP_SPEC)) { - printk(KERN_WARNING "%s: card lacks mandatory SD Status " - "function.\n", mmc_hostname(card->host)); - return 0; - } - - ssr = kmalloc(64, GFP_KERNEL); - if (!ssr) - return -ENOMEM; - - err = mmc_app_sd_status(card, ssr); - if (err) { - printk(KERN_WARNING "%s: problem reading SD Status " - "register.\n", mmc_hostname(card->host)); - err = 0; - goto out; - } - - for (i = 0; i < 16; i++) - ssr[i] = be32_to_cpu(ssr[i]); - - /* - * UNSTUFF_BITS only works with four u32s so we have to offset the - * bitfield positions accordingly. - */ - au = UNSTUFF_BITS(ssr, 428 - 384, 4); - if (au > 0 || au <= 9) { - card->ssr.au = 1 << (au + 4); - es = UNSTUFF_BITS(ssr, 408 - 384, 16); - et = UNSTUFF_BITS(ssr, 402 - 384, 6); - eo = UNSTUFF_BITS(ssr, 400 - 384, 2); - if (es && et) { - card->ssr.erase_timeout = (et * 1000) / es; - card->ssr.erase_offset = eo * 1000; - } - } else { - printk(KERN_WARNING "%s: SD Status: Invalid Allocation Unit " - "size.\n", mmc_hostname(card->host)); - } -out: - kfree(ssr); - return err; -} - /* * Fetches and decodes switch information */ @@ -357,8 +289,6 @@ MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1], card->raw_csd[2], card->raw_csd[3]); MMC_DEV_ATTR(scr, "%08x%08x\n", card->raw_scr[0], card->raw_scr[1]); MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year); -MMC_DEV_ATTR(erase_size, "%u\n", card->erase_size << 9); -MMC_DEV_ATTR(preferred_erase_size, "%u\n", card->pref_erase << 9); MMC_DEV_ATTR(fwrev, "0x%x\n", card->cid.fwrev); MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev); MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid); @@ -372,8 +302,6 @@ static struct attribute *sd_std_attrs[] = { &dev_attr_csd.attr, &dev_attr_scr.attr, &dev_attr_date.attr, - &dev_attr_erase_size.attr, - &dev_attr_preferred_erase_size.attr, &dev_attr_fwrev.attr, &dev_attr_hwrev.attr, &dev_attr_manfid.attr, @@ -468,16 +396,6 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card, if (err) return err; - /* - * Fetch and process SD Status register. - */ - err = mmc_read_ssr(card); - if (err) - return err; - - /* Erase init depends on CSD and SSR */ - mmc_init_erase(card); - /* * Fetch switch information from card. */ diff --git a/trunk/drivers/mmc/core/sd_ops.c b/trunk/drivers/mmc/core/sd_ops.c index 797cdb5887fd..63772e7e7608 100644 --- a/trunk/drivers/mmc/core/sd_ops.c +++ b/trunk/drivers/mmc/core/sd_ops.c @@ -346,51 +346,3 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group, return 0; } -int mmc_app_sd_status(struct mmc_card *card, void *ssr) -{ - int err; - struct mmc_request mrq; - struct mmc_command cmd; - struct mmc_data data; - struct scatterlist sg; - - BUG_ON(!card); - BUG_ON(!card->host); - BUG_ON(!ssr); - - /* NOTE: caller guarantees ssr is heap-allocated */ - - err = mmc_app_cmd(card->host, card); - if (err) - return err; - - memset(&mrq, 0, sizeof(struct mmc_request)); - memset(&cmd, 0, sizeof(struct mmc_command)); - memset(&data, 0, sizeof(struct mmc_data)); - - mrq.cmd = &cmd; - mrq.data = &data; - - cmd.opcode = SD_APP_SD_STATUS; - cmd.arg = 0; - cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_ADTC; - - data.blksz = 64; - data.blocks = 1; - data.flags = MMC_DATA_READ; - data.sg = &sg; - data.sg_len = 1; - - sg_init_one(&sg, ssr, 64); - - mmc_set_data_timeout(&data, card); - - mmc_wait_for_req(card->host, &mrq); - - if (cmd.error) - return cmd.error; - if (data.error) - return data.error; - - return 0; -} diff --git a/trunk/drivers/mmc/core/sd_ops.h b/trunk/drivers/mmc/core/sd_ops.h index ffc2305d905f..9742d8a30664 100644 --- a/trunk/drivers/mmc/core/sd_ops.h +++ b/trunk/drivers/mmc/core/sd_ops.h @@ -19,7 +19,6 @@ int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca); int mmc_app_send_scr(struct mmc_card *card, u32 *scr); int mmc_sd_switch(struct mmc_card *card, int mode, int group, u8 value, u8 *resp); -int mmc_app_sd_status(struct mmc_card *card, void *ssr); #endif diff --git a/trunk/drivers/mmc/host/mmc_spi.c b/trunk/drivers/mmc/host/mmc_spi.c index 1145ea0792e6..7b0f3ef50f96 100644 --- a/trunk/drivers/mmc/host/mmc_spi.c +++ b/trunk/drivers/mmc/host/mmc_spi.c @@ -1536,7 +1536,6 @@ static int __devexit mmc_spi_remove(struct spi_device *spi) #if defined(CONFIG_OF) static struct of_device_id mmc_spi_of_match_table[] __devinitdata = { { .compatible = "mmc-spi-slot", }, - {}, }; #endif diff --git a/trunk/drivers/mmc/host/msm_sdcc.c b/trunk/drivers/mmc/host/msm_sdcc.c index 6824917f5c60..3bd8ff71ec22 100644 --- a/trunk/drivers/mmc/host/msm_sdcc.c +++ b/trunk/drivers/mmc/host/msm_sdcc.c @@ -1060,7 +1060,7 @@ msmsdcc_init_dma(struct msmsdcc_host *host) static int msmsdcc_probe(struct platform_device *pdev) { - struct msm_mmc_platform_data *plat = pdev->dev.platform_data; + struct mmc_platform_data *plat = pdev->dev.platform_data; struct msmsdcc_host *host; struct mmc_host *mmc; struct resource *cmd_irqres = NULL; diff --git a/trunk/drivers/mmc/host/msm_sdcc.h b/trunk/drivers/mmc/host/msm_sdcc.h index ff2b0f74f6f4..d7dedcf33b5b 100644 --- a/trunk/drivers/mmc/host/msm_sdcc.h +++ b/trunk/drivers/mmc/host/msm_sdcc.h @@ -225,7 +225,7 @@ struct msmsdcc_host { u32 pwr; u32 saved_irq0mask; /* MMCIMASK0 reg value */ - struct msm_mmc_platform_data *plat; + struct mmc_platform_data *plat; struct timer_list timer; unsigned int oldstat; diff --git a/trunk/drivers/mmc/host/omap_hsmmc.c b/trunk/drivers/mmc/host/omap_hsmmc.c index 4a8776f8afdd..dc57ef6aef4f 100644 --- a/trunk/drivers/mmc/host/omap_hsmmc.c +++ b/trunk/drivers/mmc/host/omap_hsmmc.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -79,7 +78,6 @@ #define INT_EN_MASK 0x307F0033 #define BWR_ENABLE (1 << 4) #define BRR_ENABLE (1 << 5) -#define DTO_ENABLE (1 << 20) #define INIT_STREAM (1 << 1) #define DP_SELECT (1 << 21) #define DDIR (1 << 4) @@ -525,8 +523,7 @@ static void omap_hsmmc_stop_clock(struct omap_hsmmc_host *host) dev_dbg(mmc_dev(host->mmc), "MMC Clock is not stoped\n"); } -static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host, - struct mmc_command *cmd) +static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host) { unsigned int irq_mask; @@ -535,10 +532,6 @@ static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host, else irq_mask = INT_EN_MASK; - /* Disable timeout for erases */ - if (cmd->opcode == MMC_ERASE) - irq_mask &= ~DTO_ENABLE; - OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); OMAP_HSMMC_WRITE(host->base, IE, irq_mask); @@ -789,7 +782,7 @@ omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd, mmc_hostname(host->mmc), cmd->opcode, cmd->arg); host->cmd = cmd; - omap_hsmmc_enable_irq(host, cmd); + omap_hsmmc_enable_irq(host); host->response_busy = 0; if (cmd->flags & MMC_RSP_PRESENT) { @@ -2114,7 +2107,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) mmc->max_seg_size = mmc->max_req_size; mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | - MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_ERASE; + MMC_CAP_WAIT_WHILE_BUSY; switch (mmc_slot(host).wires) { case 8: diff --git a/trunk/drivers/mmc/host/sdhci-of-core.c b/trunk/drivers/mmc/host/sdhci-of-core.c index c51b71174c1d..dd1bdd168e66 100644 --- a/trunk/drivers/mmc/host/sdhci-of-core.c +++ b/trunk/drivers/mmc/host/sdhci-of-core.c @@ -85,14 +85,14 @@ void sdhci_be32bs_writeb(struct sdhci_host *host, u8 val, int reg) #ifdef CONFIG_PM -static int sdhci_of_suspend(struct platform_device *ofdev, pm_message_t state) +static int sdhci_of_suspend(struct of_device *ofdev, pm_message_t state) { struct sdhci_host *host = dev_get_drvdata(&ofdev->dev); return mmc_suspend_host(host->mmc); } -static int sdhci_of_resume(struct platform_device *ofdev) +static int sdhci_of_resume(struct of_device *ofdev) { struct sdhci_host *host = dev_get_drvdata(&ofdev->dev); @@ -115,7 +115,7 @@ static bool __devinit sdhci_of_wp_inverted(struct device_node *np) return machine_is(mpc837x_rdb) || machine_is(mpc837x_mds); } -static int __devinit sdhci_of_probe(struct platform_device *ofdev, +static int __devinit sdhci_of_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -183,7 +183,7 @@ static int __devinit sdhci_of_probe(struct platform_device *ofdev, return ret; } -static int __devexit sdhci_of_remove(struct platform_device *ofdev) +static int __devexit sdhci_of_remove(struct of_device *ofdev) { struct sdhci_host *host = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/mtd/maps/physmap_of.c b/trunk/drivers/mtd/maps/physmap_of.c index 00af55d7afba..6ac5f9f28ac3 100644 --- a/trunk/drivers/mtd/maps/physmap_of.c +++ b/trunk/drivers/mtd/maps/physmap_of.c @@ -43,7 +43,7 @@ struct of_flash { #ifdef CONFIG_MTD_PARTITIONS #define OF_FLASH_PARTS(info) ((info)->parts) -static int parse_obsolete_partitions(struct platform_device *dev, +static int parse_obsolete_partitions(struct of_device *dev, struct of_flash *info, struct device_node *dp) { @@ -93,7 +93,7 @@ static int parse_obsolete_partitions(struct platform_device *dev, #define parse_partitions(info, dev) (0) #endif /* MTD_PARTITIONS */ -static int of_flash_remove(struct platform_device *dev) +static int of_flash_remove(struct of_device *dev) { struct of_flash *info; int i; @@ -140,7 +140,7 @@ static int of_flash_remove(struct platform_device *dev) /* Helper function to handle probing of the obsolete "direct-mapped" * compatible binding, which has an extra "probe-type" property * describing the type of flash probe necessary. */ -static struct mtd_info * __devinit obsolete_probe(struct platform_device *dev, +static struct mtd_info * __devinit obsolete_probe(struct of_device *dev, struct map_info *map) { struct device_node *dp = dev->dev.of_node; @@ -215,7 +215,7 @@ static void __devinit of_free_probes(const char **probes) } #endif -static int __devinit of_flash_probe(struct platform_device *dev, +static int __devinit of_flash_probe(struct of_device *dev, const struct of_device_id *match) { #ifdef CONFIG_MTD_PARTITIONS diff --git a/trunk/drivers/mtd/maps/sun_uflash.c b/trunk/drivers/mtd/maps/sun_uflash.c index 3582ba1f9b09..8984236a8d0a 100644 --- a/trunk/drivers/mtd/maps/sun_uflash.c +++ b/trunk/drivers/mtd/maps/sun_uflash.c @@ -48,7 +48,7 @@ struct map_info uflash_map_templ = { .bankwidth = UFLASH_BUSWIDTH, }; -int uflash_devinit(struct platform_device *op, struct device_node *dp) +int uflash_devinit(struct of_device *op, struct device_node *dp) { struct uflash_dev *up; @@ -108,7 +108,7 @@ int uflash_devinit(struct platform_device *op, struct device_node *dp) return 0; } -static int __devinit uflash_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit uflash_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; @@ -121,7 +121,7 @@ static int __devinit uflash_probe(struct platform_device *op, const struct of_de return uflash_devinit(op, dp); } -static int __devexit uflash_remove(struct platform_device *op) +static int __devexit uflash_remove(struct of_device *op) { struct uflash_dev *up = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/mtd/nand/fsl_elbc_nand.c b/trunk/drivers/mtd/nand/fsl_elbc_nand.c index 80de0bff6c3a..5084cc517944 100644 --- a/trunk/drivers/mtd/nand/fsl_elbc_nand.c +++ b/trunk/drivers/mtd/nand/fsl_elbc_nand.c @@ -958,7 +958,7 @@ static int __devinit fsl_elbc_ctrl_init(struct fsl_elbc_ctrl *ctrl) return 0; } -static int fsl_elbc_ctrl_remove(struct platform_device *ofdev) +static int fsl_elbc_ctrl_remove(struct of_device *ofdev) { struct fsl_elbc_ctrl *ctrl = dev_get_drvdata(&ofdev->dev); int i; @@ -1013,7 +1013,7 @@ static irqreturn_t fsl_elbc_ctrl_irq(int irqno, void *data) * in the chip probe function. */ -static int __devinit fsl_elbc_ctrl_probe(struct platform_device *ofdev, +static int __devinit fsl_elbc_ctrl_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *child; diff --git a/trunk/drivers/mtd/nand/fsl_upm.c b/trunk/drivers/mtd/nand/fsl_upm.c index 4eff8b25e5af..1312eda57ba6 100644 --- a/trunk/drivers/mtd/nand/fsl_upm.c +++ b/trunk/drivers/mtd/nand/fsl_upm.c @@ -217,7 +217,7 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun, return ret; } -static int __devinit fun_probe(struct platform_device *ofdev, +static int __devinit fun_probe(struct of_device *ofdev, const struct of_device_id *ofid) { struct fsl_upm_nand *fun; @@ -335,7 +335,7 @@ static int __devinit fun_probe(struct platform_device *ofdev, return ret; } -static int __devexit fun_remove(struct platform_device *ofdev) +static int __devexit fun_remove(struct of_device *ofdev) { struct fsl_upm_nand *fun = dev_get_drvdata(&ofdev->dev); int i; diff --git a/trunk/drivers/mtd/nand/mpc5121_nfc.c b/trunk/drivers/mtd/nand/mpc5121_nfc.c index df0c1da4ff49..0a130dcaa129 100644 --- a/trunk/drivers/mtd/nand/mpc5121_nfc.c +++ b/trunk/drivers/mtd/nand/mpc5121_nfc.c @@ -647,7 +647,7 @@ static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd) iounmap(prv->csreg); } -static int __devinit mpc5121_nfc_probe(struct platform_device *op, +static int __devinit mpc5121_nfc_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *rootnode, *dn = op->dev.of_node; @@ -869,7 +869,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op, return retval; } -static int __devexit mpc5121_nfc_remove(struct platform_device *op) +static int __devexit mpc5121_nfc_remove(struct of_device *op) { struct device *dev = &op->dev; struct mtd_info *mtd = dev_get_drvdata(dev); diff --git a/trunk/drivers/mtd/nand/ndfc.c b/trunk/drivers/mtd/nand/ndfc.c index 510554e6c115..98fd2bdf8be1 100644 --- a/trunk/drivers/mtd/nand/ndfc.c +++ b/trunk/drivers/mtd/nand/ndfc.c @@ -35,7 +35,7 @@ struct ndfc_controller { - struct platform_device *ofdev; + struct of_device *ofdev; void __iomem *ndfcbase; struct mtd_info mtd; struct nand_chip chip; @@ -225,7 +225,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc, return ret; } -static int __devinit ndfc_probe(struct platform_device *ofdev, +static int __devinit ndfc_probe(struct of_device *ofdev, const struct of_device_id *match) { struct ndfc_controller *ndfc = &ndfc_ctrl; @@ -277,7 +277,7 @@ static int __devinit ndfc_probe(struct platform_device *ofdev, return 0; } -static int __devexit ndfc_remove(struct platform_device *ofdev) +static int __devexit ndfc_remove(struct of_device *ofdev) { struct ndfc_controller *ndfc = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/mtd/nand/pasemi_nand.c b/trunk/drivers/mtd/nand/pasemi_nand.c index 6ddb2461d740..f02af24d033a 100644 --- a/trunk/drivers/mtd/nand/pasemi_nand.c +++ b/trunk/drivers/mtd/nand/pasemi_nand.c @@ -89,7 +89,7 @@ int pasemi_device_ready(struct mtd_info *mtd) return !!(inl(lpcctl) & LBICTRL_LPCCTL_NR); } -static int __devinit pasemi_nand_probe(struct platform_device *ofdev, +static int __devinit pasemi_nand_probe(struct of_device *ofdev, const struct of_device_id *match) { struct pci_dev *pdev; @@ -185,7 +185,7 @@ static int __devinit pasemi_nand_probe(struct platform_device *ofdev, return err; } -static int __devexit pasemi_nand_remove(struct platform_device *ofdev) +static int __devexit pasemi_nand_remove(struct of_device *ofdev) { struct nand_chip *chip; diff --git a/trunk/drivers/mtd/nand/socrates_nand.c b/trunk/drivers/mtd/nand/socrates_nand.c index a8e403eebedb..cc728b12de82 100644 --- a/trunk/drivers/mtd/nand/socrates_nand.c +++ b/trunk/drivers/mtd/nand/socrates_nand.c @@ -162,7 +162,7 @@ static const char *part_probes[] = { "cmdlinepart", NULL }; /* * Probe for the NAND device. */ -static int __devinit socrates_nand_probe(struct platform_device *ofdev, +static int __devinit socrates_nand_probe(struct of_device *ofdev, const struct of_device_id *ofid) { struct socrates_nand_host *host; @@ -276,7 +276,7 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev, /* * Remove a NAND device. */ -static int __devexit socrates_nand_remove(struct platform_device *ofdev) +static int __devexit socrates_nand_remove(struct of_device *ofdev) { struct socrates_nand_host *host = dev_get_drvdata(&ofdev->dev); struct mtd_info *mtd = &host->mtd; diff --git a/trunk/drivers/net/can/mscan/mpc5xxx_can.c b/trunk/drivers/net/can/mscan/mpc5xxx_can.c index b1bdc909090f..af753936e835 100644 --- a/trunk/drivers/net/can/mscan/mpc5xxx_can.c +++ b/trunk/drivers/net/can/mscan/mpc5xxx_can.c @@ -38,7 +38,7 @@ struct mpc5xxx_can_data { unsigned int type; - u32 (*get_clock)(struct platform_device *ofdev, const char *clock_name, + u32 (*get_clock)(struct of_device *ofdev, const char *clock_name, int *mscan_clksrc); }; @@ -48,7 +48,7 @@ static struct of_device_id __devinitdata mpc52xx_cdm_ids[] = { {} }; -static u32 __devinit mpc52xx_can_get_clock(struct platform_device *ofdev, +static u32 __devinit mpc52xx_can_get_clock(struct of_device *ofdev, const char *clock_name, int *mscan_clksrc) { @@ -101,7 +101,7 @@ static u32 __devinit mpc52xx_can_get_clock(struct platform_device *ofdev, return freq; } #else /* !CONFIG_PPC_MPC52xx */ -static u32 __devinit mpc52xx_can_get_clock(struct platform_device *ofdev, +static u32 __devinit mpc52xx_can_get_clock(struct of_device *ofdev, const char *clock_name, int *mscan_clksrc) { @@ -129,7 +129,7 @@ static struct of_device_id __devinitdata mpc512x_clock_ids[] = { {} }; -static u32 __devinit mpc512x_can_get_clock(struct platform_device *ofdev, +static u32 __devinit mpc512x_can_get_clock(struct of_device *ofdev, const char *clock_name, int *mscan_clksrc) { @@ -239,7 +239,7 @@ static u32 __devinit mpc512x_can_get_clock(struct platform_device *ofdev, return freq; } #else /* !CONFIG_PPC_MPC512x */ -static u32 __devinit mpc512x_can_get_clock(struct platform_device *ofdev, +static u32 __devinit mpc512x_can_get_clock(struct of_device *ofdev, const char *clock_name, int *mscan_clksrc) { @@ -247,7 +247,7 @@ static u32 __devinit mpc512x_can_get_clock(struct platform_device *ofdev, } #endif /* CONFIG_PPC_MPC512x */ -static int __devinit mpc5xxx_can_probe(struct platform_device *ofdev, +static int __devinit mpc5xxx_can_probe(struct of_device *ofdev, const struct of_device_id *id) { struct mpc5xxx_can_data *data = (struct mpc5xxx_can_data *)id->data; @@ -317,7 +317,7 @@ static int __devinit mpc5xxx_can_probe(struct platform_device *ofdev, return err; } -static int __devexit mpc5xxx_can_remove(struct platform_device *ofdev) +static int __devexit mpc5xxx_can_remove(struct of_device *ofdev) { struct net_device *dev = dev_get_drvdata(&ofdev->dev); struct mscan_priv *priv = netdev_priv(dev); @@ -334,7 +334,7 @@ static int __devexit mpc5xxx_can_remove(struct platform_device *ofdev) #ifdef CONFIG_PM static struct mscan_regs saved_regs; -static int mpc5xxx_can_suspend(struct platform_device *ofdev, pm_message_t state) +static int mpc5xxx_can_suspend(struct of_device *ofdev, pm_message_t state) { struct net_device *dev = dev_get_drvdata(&ofdev->dev); struct mscan_priv *priv = netdev_priv(dev); @@ -345,7 +345,7 @@ static int mpc5xxx_can_suspend(struct platform_device *ofdev, pm_message_t state return 0; } -static int mpc5xxx_can_resume(struct platform_device *ofdev) +static int mpc5xxx_can_resume(struct of_device *ofdev) { struct net_device *dev = dev_get_drvdata(&ofdev->dev); struct mscan_priv *priv = netdev_priv(dev); diff --git a/trunk/drivers/net/can/sja1000/sja1000_of_platform.c b/trunk/drivers/net/can/sja1000/sja1000_of_platform.c index 5bfccfdf3bbb..ac1a83d7c204 100644 --- a/trunk/drivers/net/can/sja1000/sja1000_of_platform.c +++ b/trunk/drivers/net/can/sja1000/sja1000_of_platform.c @@ -67,7 +67,7 @@ static void sja1000_ofp_write_reg(const struct sja1000_priv *priv, out_8(priv->reg_base + reg, val); } -static int __devexit sja1000_ofp_remove(struct platform_device *ofdev) +static int __devexit sja1000_ofp_remove(struct of_device *ofdev) { struct net_device *dev = dev_get_drvdata(&ofdev->dev); struct sja1000_priv *priv = netdev_priv(dev); @@ -87,7 +87,7 @@ static int __devexit sja1000_ofp_remove(struct platform_device *ofdev) return 0; } -static int __devinit sja1000_ofp_probe(struct platform_device *ofdev, +static int __devinit sja1000_ofp_probe(struct of_device *ofdev, const struct of_device_id *id) { struct device_node *np = ofdev->dev.of_node; diff --git a/trunk/drivers/net/ehea/ehea.h b/trunk/drivers/net/ehea/ehea.h index 99a929964e3c..0060e422f171 100644 --- a/trunk/drivers/net/ehea/ehea.h +++ b/trunk/drivers/net/ehea/ehea.h @@ -413,7 +413,7 @@ struct ehea_port_res { struct ehea_adapter { u64 handle; - struct platform_device *ofdev; + struct of_device *ofdev; struct ehea_port *port[EHEA_MAX_PORTS]; struct ehea_eq *neq; /* notification event queue */ struct tasklet_struct neq_tasklet; @@ -465,7 +465,7 @@ struct ehea_port { struct net_device *netdev; struct net_device_stats stats; struct ehea_port_res port_res[EHEA_MAX_PORT_RES]; - struct platform_device ofdev; /* Open Firmware Device */ + struct of_device ofdev; /* Open Firmware Device */ struct ehea_mc_list *mc_list; /* Multicast MAC addresses */ struct vlan_group *vgrp; struct ehea_eq *qp_eq; diff --git a/trunk/drivers/net/ehea/ehea_main.c b/trunk/drivers/net/ehea/ehea_main.c index 897719b49f96..3beba70b7dea 100644 --- a/trunk/drivers/net/ehea/ehea_main.c +++ b/trunk/drivers/net/ehea/ehea_main.c @@ -107,10 +107,10 @@ struct ehea_fw_handle_array ehea_fw_handles; struct ehea_bcmc_reg_array ehea_bcmc_regs; -static int __devinit ehea_probe_adapter(struct platform_device *dev, +static int __devinit ehea_probe_adapter(struct of_device *dev, const struct of_device_id *id); -static int __devexit ehea_remove(struct platform_device *dev); +static int __devexit ehea_remove(struct of_device *dev); static struct of_device_id ehea_device_table[] = { { @@ -3376,7 +3376,7 @@ static ssize_t ehea_remove_port(struct device *dev, static DEVICE_ATTR(probe_port, S_IWUSR, NULL, ehea_probe_port); static DEVICE_ATTR(remove_port, S_IWUSR, NULL, ehea_remove_port); -int ehea_create_device_sysfs(struct platform_device *dev) +int ehea_create_device_sysfs(struct of_device *dev) { int ret = device_create_file(&dev->dev, &dev_attr_probe_port); if (ret) @@ -3387,13 +3387,13 @@ int ehea_create_device_sysfs(struct platform_device *dev) return ret; } -void ehea_remove_device_sysfs(struct platform_device *dev) +void ehea_remove_device_sysfs(struct of_device *dev) { device_remove_file(&dev->dev, &dev_attr_probe_port); device_remove_file(&dev->dev, &dev_attr_remove_port); } -static int __devinit ehea_probe_adapter(struct platform_device *dev, +static int __devinit ehea_probe_adapter(struct of_device *dev, const struct of_device_id *id) { struct ehea_adapter *adapter; @@ -3492,7 +3492,7 @@ static int __devinit ehea_probe_adapter(struct platform_device *dev, return ret; } -static int __devexit ehea_remove(struct platform_device *dev) +static int __devexit ehea_remove(struct of_device *dev) { struct ehea_adapter *adapter = dev_get_drvdata(&dev->dev); int i; diff --git a/trunk/drivers/net/fec_mpc52xx.c b/trunk/drivers/net/fec_mpc52xx.c index e3e10b4add9c..d1a5b17b2a95 100644 --- a/trunk/drivers/net/fec_mpc52xx.c +++ b/trunk/drivers/net/fec_mpc52xx.c @@ -850,7 +850,7 @@ static const struct net_device_ops mpc52xx_fec_netdev_ops = { /* ======================================================================== */ static int __devinit -mpc52xx_fec_probe(struct platform_device *op, const struct of_device_id *match) +mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) { int rv; struct net_device *ndev; @@ -995,7 +995,7 @@ mpc52xx_fec_probe(struct platform_device *op, const struct of_device_id *match) } static int -mpc52xx_fec_remove(struct platform_device *op) +mpc52xx_fec_remove(struct of_device *op) { struct net_device *ndev; struct mpc52xx_fec_priv *priv; @@ -1025,7 +1025,7 @@ mpc52xx_fec_remove(struct platform_device *op) } #ifdef CONFIG_PM -static int mpc52xx_fec_of_suspend(struct platform_device *op, pm_message_t state) +static int mpc52xx_fec_of_suspend(struct of_device *op, pm_message_t state) { struct net_device *dev = dev_get_drvdata(&op->dev); @@ -1035,7 +1035,7 @@ static int mpc52xx_fec_of_suspend(struct platform_device *op, pm_message_t state return 0; } -static int mpc52xx_fec_of_resume(struct platform_device *op) +static int mpc52xx_fec_of_resume(struct of_device *op) { struct net_device *dev = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/net/fec_mpc52xx_phy.c b/trunk/drivers/net/fec_mpc52xx_phy.c index 0b4cb6f15984..dbaf72cbb233 100644 --- a/trunk/drivers/net/fec_mpc52xx_phy.c +++ b/trunk/drivers/net/fec_mpc52xx_phy.c @@ -61,7 +61,7 @@ static int mpc52xx_fec_mdio_write(struct mii_bus *bus, int phy_id, int reg, data | FEC_MII_WRITE_FRAME); } -static int mpc52xx_fec_mdio_probe(struct platform_device *of, +static int mpc52xx_fec_mdio_probe(struct of_device *of, const struct of_device_id *match) { struct device *dev = &of->dev; @@ -122,7 +122,7 @@ static int mpc52xx_fec_mdio_probe(struct platform_device *of, return err; } -static int mpc52xx_fec_mdio_remove(struct platform_device *of) +static int mpc52xx_fec_mdio_remove(struct of_device *of) { struct device *dev = &of->dev; struct mii_bus *bus = dev_get_drvdata(dev); diff --git a/trunk/drivers/net/fs_enet/fs_enet-main.c b/trunk/drivers/net/fs_enet/fs_enet-main.c index d6e3111959ab..f08cff9020bd 100644 --- a/trunk/drivers/net/fs_enet/fs_enet-main.c +++ b/trunk/drivers/net/fs_enet/fs_enet-main.c @@ -997,7 +997,7 @@ static const struct net_device_ops fs_enet_netdev_ops = { #endif }; -static int __devinit fs_enet_probe(struct platform_device *ofdev, +static int __devinit fs_enet_probe(struct of_device *ofdev, const struct of_device_id *match) { struct net_device *ndev; @@ -1105,7 +1105,7 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev, return ret; } -static int fs_enet_remove(struct platform_device *ofdev) +static int fs_enet_remove(struct of_device *ofdev) { struct net_device *ndev = dev_get_drvdata(&ofdev->dev); struct fs_enet_private *fep = netdev_priv(ndev); diff --git a/trunk/drivers/net/fs_enet/mac-fcc.c b/trunk/drivers/net/fs_enet/mac-fcc.c index 7a84e45487e8..48e91b6242ce 100644 --- a/trunk/drivers/net/fs_enet/mac-fcc.c +++ b/trunk/drivers/net/fs_enet/mac-fcc.c @@ -84,7 +84,7 @@ static inline int fcc_cr_cmd(struct fs_enet_private *fep, u32 op) static int do_pd_setup(struct fs_enet_private *fep) { - struct platform_device *ofdev = to_platform_device(fep->dev); + struct of_device *ofdev = to_of_device(fep->dev); struct fs_platform_info *fpi = fep->fpi; int ret = -EINVAL; diff --git a/trunk/drivers/net/fs_enet/mac-fec.c b/trunk/drivers/net/fs_enet/mac-fec.c index 61035fc5599b..7ca1642276d0 100644 --- a/trunk/drivers/net/fs_enet/mac-fec.c +++ b/trunk/drivers/net/fs_enet/mac-fec.c @@ -96,7 +96,7 @@ static int whack_reset(struct fec __iomem *fecp) static int do_pd_setup(struct fs_enet_private *fep) { - struct platform_device *ofdev = to_platform_device(fep->dev); + struct of_device *ofdev = to_of_device(fep->dev); fep->interrupt = of_irq_to_resource(ofdev->dev.of_node, 0, NULL); if (fep->interrupt == NO_IRQ) diff --git a/trunk/drivers/net/fs_enet/mac-scc.c b/trunk/drivers/net/fs_enet/mac-scc.c index 22a02a767069..a3c44544846d 100644 --- a/trunk/drivers/net/fs_enet/mac-scc.c +++ b/trunk/drivers/net/fs_enet/mac-scc.c @@ -96,7 +96,7 @@ static inline int scc_cr_cmd(struct fs_enet_private *fep, u32 op) static int do_pd_setup(struct fs_enet_private *fep) { - struct platform_device *ofdev = to_platform_device(fep->dev); + struct of_device *ofdev = to_of_device(fep->dev); fep->interrupt = of_irq_to_resource(ofdev->dev.of_node, 0, NULL); if (fep->interrupt == NO_IRQ) diff --git a/trunk/drivers/net/fs_enet/mii-bitbang.c b/trunk/drivers/net/fs_enet/mii-bitbang.c index 3cda2b515471..3607340f3da7 100644 --- a/trunk/drivers/net/fs_enet/mii-bitbang.c +++ b/trunk/drivers/net/fs_enet/mii-bitbang.c @@ -150,7 +150,7 @@ static int __devinit fs_mii_bitbang_init(struct mii_bus *bus, return 0; } -static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev, +static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, const struct of_device_id *match) { struct mii_bus *new_bus; @@ -200,7 +200,7 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev, return ret; } -static int fs_enet_mdio_remove(struct platform_device *ofdev) +static int fs_enet_mdio_remove(struct of_device *ofdev) { struct mii_bus *bus = dev_get_drvdata(&ofdev->dev); struct bb_info *bitbang = bus->priv; diff --git a/trunk/drivers/net/fs_enet/mii-fec.c b/trunk/drivers/net/fs_enet/mii-fec.c index dbb9c48623df..bddffd169b93 100644 --- a/trunk/drivers/net/fs_enet/mii-fec.c +++ b/trunk/drivers/net/fs_enet/mii-fec.c @@ -101,7 +101,7 @@ static int fs_enet_fec_mii_reset(struct mii_bus *bus) return 0; } -static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev, +static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, const struct of_device_id *match) { struct resource res; @@ -192,7 +192,7 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev, return ret; } -static int fs_enet_mdio_remove(struct platform_device *ofdev) +static int fs_enet_mdio_remove(struct of_device *ofdev) { struct mii_bus *bus = dev_get_drvdata(&ofdev->dev); struct fec_info *fec = bus->priv; diff --git a/trunk/drivers/net/fsl_pq_mdio.c b/trunk/drivers/net/fsl_pq_mdio.c index d4bf91aac25f..f53f850b6418 100644 --- a/trunk/drivers/net/fsl_pq_mdio.c +++ b/trunk/drivers/net/fsl_pq_mdio.c @@ -265,7 +265,7 @@ static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) #endif -static int fsl_pq_mdio_probe(struct platform_device *ofdev, +static int fsl_pq_mdio_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -425,7 +425,7 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev, } -static int fsl_pq_mdio_remove(struct platform_device *ofdev) +static int fsl_pq_mdio_remove(struct of_device *ofdev) { struct device *device = &ofdev->dev; struct mii_bus *bus = dev_get_drvdata(device); diff --git a/trunk/drivers/net/gianfar.c b/trunk/drivers/net/gianfar.c index 4f7c3f3ca234..a1b6301bc674 100644 --- a/trunk/drivers/net/gianfar.c +++ b/trunk/drivers/net/gianfar.c @@ -122,9 +122,9 @@ static irqreturn_t gfar_interrupt(int irq, void *dev_id); static void adjust_link(struct net_device *dev); static void init_registers(struct net_device *dev); static int init_phy(struct net_device *dev); -static int gfar_probe(struct platform_device *ofdev, +static int gfar_probe(struct of_device *ofdev, const struct of_device_id *match); -static int gfar_remove(struct platform_device *ofdev); +static int gfar_remove(struct of_device *ofdev); static void free_skb_resources(struct gfar_private *priv); static void gfar_set_multi(struct net_device *dev); static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr); @@ -605,7 +605,7 @@ static int gfar_parse_group(struct device_node *np, return 0; } -static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) +static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev) { const char *model; const char *ctype; @@ -959,7 +959,7 @@ static void gfar_detect_errata(struct gfar_private *priv) /* Set up the ethernet device structure, private data, * and anything else we need before we start */ -static int gfar_probe(struct platform_device *ofdev, +static int gfar_probe(struct of_device *ofdev, const struct of_device_id *match) { u32 tempval; @@ -1238,7 +1238,7 @@ static int gfar_probe(struct platform_device *ofdev, return err; } -static int gfar_remove(struct platform_device *ofdev) +static int gfar_remove(struct of_device *ofdev) { struct gfar_private *priv = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/net/gianfar.h b/trunk/drivers/net/gianfar.h index 68984eb88ae0..710810e2adb4 100644 --- a/trunk/drivers/net/gianfar.h +++ b/trunk/drivers/net/gianfar.h @@ -1054,7 +1054,7 @@ struct gfar_private { struct device_node *node; struct net_device *ndev; - struct platform_device *ofdev; + struct of_device *ofdev; enum gfar_errata errata; struct gfar_priv_grp gfargrp[MAXGROUPS]; diff --git a/trunk/drivers/net/greth.c b/trunk/drivers/net/greth.c index f15c64f1cd38..4d09eab3548e 100644 --- a/trunk/drivers/net/greth.c +++ b/trunk/drivers/net/greth.c @@ -1373,7 +1373,7 @@ static int greth_mdio_init(struct greth_private *greth) } /* Initialize the GRETH MAC */ -static int __devinit greth_of_probe(struct platform_device *ofdev, const struct of_device_id *match) +static int __devinit greth_of_probe(struct of_device *ofdev, const struct of_device_id *match) { struct net_device *dev; struct greth_private *greth; @@ -1412,7 +1412,7 @@ static int __devinit greth_of_probe(struct platform_device *ofdev, const struct } regs = (struct greth_regs *) greth->regs; - greth->irq = ofdev->archdata.irqs[0]; + greth->irq = ofdev->irqs[0]; dev_set_drvdata(greth->dev, dev); SET_NETDEV_DEV(dev, greth->dev); @@ -1572,7 +1572,7 @@ static int __devinit greth_of_probe(struct platform_device *ofdev, const struct return err; } -static int __devexit greth_of_remove(struct platform_device *of_dev) +static int __devexit greth_of_remove(struct of_device *of_dev) { struct net_device *ndev = dev_get_drvdata(&of_dev->dev); struct greth_private *greth = netdev_priv(ndev); diff --git a/trunk/drivers/net/greth.h b/trunk/drivers/net/greth.h index 03ad903cd676..973388d6abca 100644 --- a/trunk/drivers/net/greth.h +++ b/trunk/drivers/net/greth.h @@ -118,7 +118,7 @@ struct greth_private { int irq; - struct device *dev; /* Pointer to platform_device->dev */ + struct device *dev; /* Pointer to of_device->dev */ struct net_device *netdev; struct napi_struct napi; spinlock_t devlock; diff --git a/trunk/drivers/net/ibm_newemac/core.c b/trunk/drivers/net/ibm_newemac/core.c index 3506fd6ad726..eeec7bc2ce74 100644 --- a/trunk/drivers/net/ibm_newemac/core.c +++ b/trunk/drivers/net/ibm_newemac/core.c @@ -2245,7 +2245,7 @@ static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) struct emac_depentry { u32 phandle; struct device_node *node; - struct platform_device *ofdev; + struct of_device *ofdev; void *drvdata; }; @@ -2719,7 +2719,7 @@ static const struct net_device_ops emac_gige_netdev_ops = { .ndo_change_mtu = emac_change_mtu, }; -static int __devinit emac_probe(struct platform_device *ofdev, +static int __devinit emac_probe(struct of_device *ofdev, const struct of_device_id *match) { struct net_device *ndev; @@ -2941,7 +2941,7 @@ static int __devinit emac_probe(struct platform_device *ofdev, return err; } -static int __devexit emac_remove(struct platform_device *ofdev) +static int __devexit emac_remove(struct of_device *ofdev) { struct emac_instance *dev = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/net/ibm_newemac/core.h b/trunk/drivers/net/ibm_newemac/core.h index 9e37e3d9c51d..b1cbe6fdfc7a 100644 --- a/trunk/drivers/net/ibm_newemac/core.h +++ b/trunk/drivers/net/ibm_newemac/core.h @@ -170,12 +170,12 @@ struct emac_instance { struct net_device *ndev; struct resource rsrc_regs; struct emac_regs __iomem *emacp; - struct platform_device *ofdev; + struct of_device *ofdev; struct device_node **blist; /* bootlist entry */ /* MAL linkage */ u32 mal_ph; - struct platform_device *mal_dev; + struct of_device *mal_dev; u32 mal_rx_chan; u32 mal_tx_chan; struct mal_instance *mal; @@ -196,24 +196,24 @@ struct emac_instance { /* Shared MDIO if any */ u32 mdio_ph; - struct platform_device *mdio_dev; + struct of_device *mdio_dev; struct emac_instance *mdio_instance; struct mutex mdio_lock; /* ZMII infos if any */ u32 zmii_ph; u32 zmii_port; - struct platform_device *zmii_dev; + struct of_device *zmii_dev; /* RGMII infos if any */ u32 rgmii_ph; u32 rgmii_port; - struct platform_device *rgmii_dev; + struct of_device *rgmii_dev; /* TAH infos if any */ u32 tah_ph; u32 tah_port; - struct platform_device *tah_dev; + struct of_device *tah_dev; /* IRQs */ int wol_irq; diff --git a/trunk/drivers/net/ibm_newemac/mal.c b/trunk/drivers/net/ibm_newemac/mal.c index d5717e2123e1..fcff9e0bd382 100644 --- a/trunk/drivers/net/ibm_newemac/mal.c +++ b/trunk/drivers/net/ibm_newemac/mal.c @@ -517,7 +517,7 @@ void *mal_dump_regs(struct mal_instance *mal, void *buf) return regs + 1; } -static int __devinit mal_probe(struct platform_device *ofdev, +static int __devinit mal_probe(struct of_device *ofdev, const struct of_device_id *match) { struct mal_instance *mal; @@ -730,7 +730,7 @@ static int __devinit mal_probe(struct platform_device *ofdev, return err; } -static int __devexit mal_remove(struct platform_device *ofdev) +static int __devexit mal_remove(struct of_device *ofdev) { struct mal_instance *mal = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/net/ibm_newemac/mal.h b/trunk/drivers/net/ibm_newemac/mal.h index 66084214bf45..9ededfbf0726 100644 --- a/trunk/drivers/net/ibm_newemac/mal.h +++ b/trunk/drivers/net/ibm_newemac/mal.h @@ -210,7 +210,7 @@ struct mal_instance { dma_addr_t bd_dma; struct mal_descriptor *bd_virt; - struct platform_device *ofdev; + struct of_device *ofdev; int index; spinlock_t lock; diff --git a/trunk/drivers/net/ibm_newemac/rgmii.c b/trunk/drivers/net/ibm_newemac/rgmii.c index dd61798897ac..108919bcdf13 100644 --- a/trunk/drivers/net/ibm_newemac/rgmii.c +++ b/trunk/drivers/net/ibm_newemac/rgmii.c @@ -93,7 +93,7 @@ static inline u32 rgmii_mode_mask(int mode, int input) } } -int __devinit rgmii_attach(struct platform_device *ofdev, int input, int mode) +int __devinit rgmii_attach(struct of_device *ofdev, int input, int mode) { struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); struct rgmii_regs __iomem *p = dev->base; @@ -122,7 +122,7 @@ int __devinit rgmii_attach(struct platform_device *ofdev, int input, int mode) return 0; } -void rgmii_set_speed(struct platform_device *ofdev, int input, int speed) +void rgmii_set_speed(struct of_device *ofdev, int input, int speed) { struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); struct rgmii_regs __iomem *p = dev->base; @@ -144,7 +144,7 @@ void rgmii_set_speed(struct platform_device *ofdev, int input, int speed) mutex_unlock(&dev->lock); } -void rgmii_get_mdio(struct platform_device *ofdev, int input) +void rgmii_get_mdio(struct of_device *ofdev, int input) { struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); struct rgmii_regs __iomem *p = dev->base; @@ -165,7 +165,7 @@ void rgmii_get_mdio(struct platform_device *ofdev, int input) DBG2(dev, " fer = 0x%08x\n", fer); } -void rgmii_put_mdio(struct platform_device *ofdev, int input) +void rgmii_put_mdio(struct of_device *ofdev, int input) { struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); struct rgmii_regs __iomem *p = dev->base; @@ -186,7 +186,7 @@ void rgmii_put_mdio(struct platform_device *ofdev, int input) mutex_unlock(&dev->lock); } -void rgmii_detach(struct platform_device *ofdev, int input) +void rgmii_detach(struct of_device *ofdev, int input) { struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); struct rgmii_regs __iomem *p; @@ -206,13 +206,13 @@ void rgmii_detach(struct platform_device *ofdev, int input) mutex_unlock(&dev->lock); } -int rgmii_get_regs_len(struct platform_device *ofdev) +int rgmii_get_regs_len(struct of_device *ofdev) { return sizeof(struct emac_ethtool_regs_subhdr) + sizeof(struct rgmii_regs); } -void *rgmii_dump_regs(struct platform_device *ofdev, void *buf) +void *rgmii_dump_regs(struct of_device *ofdev, void *buf) { struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); struct emac_ethtool_regs_subhdr *hdr = buf; @@ -228,7 +228,7 @@ void *rgmii_dump_regs(struct platform_device *ofdev, void *buf) } -static int __devinit rgmii_probe(struct platform_device *ofdev, +static int __devinit rgmii_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -293,7 +293,7 @@ static int __devinit rgmii_probe(struct platform_device *ofdev, return rc; } -static int __devexit rgmii_remove(struct platform_device *ofdev) +static int __devexit rgmii_remove(struct of_device *ofdev) { struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/net/ibm_newemac/rgmii.h b/trunk/drivers/net/ibm_newemac/rgmii.h index d69799049865..c4a4b358a270 100644 --- a/trunk/drivers/net/ibm_newemac/rgmii.h +++ b/trunk/drivers/net/ibm_newemac/rgmii.h @@ -51,20 +51,20 @@ struct rgmii_instance { int users; /* OF device instance */ - struct platform_device *ofdev; + struct of_device *ofdev; }; #ifdef CONFIG_IBM_NEW_EMAC_RGMII extern int rgmii_init(void); extern void rgmii_exit(void); -extern int rgmii_attach(struct platform_device *ofdev, int input, int mode); -extern void rgmii_detach(struct platform_device *ofdev, int input); -extern void rgmii_get_mdio(struct platform_device *ofdev, int input); -extern void rgmii_put_mdio(struct platform_device *ofdev, int input); -extern void rgmii_set_speed(struct platform_device *ofdev, int input, int speed); -extern int rgmii_get_regs_len(struct platform_device *ofdev); -extern void *rgmii_dump_regs(struct platform_device *ofdev, void *buf); +extern int rgmii_attach(struct of_device *ofdev, int input, int mode); +extern void rgmii_detach(struct of_device *ofdev, int input); +extern void rgmii_get_mdio(struct of_device *ofdev, int input); +extern void rgmii_put_mdio(struct of_device *ofdev, int input); +extern void rgmii_set_speed(struct of_device *ofdev, int input, int speed); +extern int rgmii_get_regs_len(struct of_device *ofdev); +extern void *rgmii_dump_regs(struct of_device *ofdev, void *buf); #else diff --git a/trunk/drivers/net/ibm_newemac/tah.c b/trunk/drivers/net/ibm_newemac/tah.c index 299aa49490c0..044637144c43 100644 --- a/trunk/drivers/net/ibm_newemac/tah.c +++ b/trunk/drivers/net/ibm_newemac/tah.c @@ -23,7 +23,7 @@ #include "emac.h" #include "core.h" -int __devinit tah_attach(struct platform_device *ofdev, int channel) +int __devinit tah_attach(struct of_device *ofdev, int channel) { struct tah_instance *dev = dev_get_drvdata(&ofdev->dev); @@ -35,7 +35,7 @@ int __devinit tah_attach(struct platform_device *ofdev, int channel) return 0; } -void tah_detach(struct platform_device *ofdev, int channel) +void tah_detach(struct of_device *ofdev, int channel) { struct tah_instance *dev = dev_get_drvdata(&ofdev->dev); @@ -44,7 +44,7 @@ void tah_detach(struct platform_device *ofdev, int channel) mutex_unlock(&dev->lock); } -void tah_reset(struct platform_device *ofdev) +void tah_reset(struct of_device *ofdev) { struct tah_instance *dev = dev_get_drvdata(&ofdev->dev); struct tah_regs __iomem *p = dev->base; @@ -66,13 +66,13 @@ void tah_reset(struct platform_device *ofdev) TAH_MR_DIG); } -int tah_get_regs_len(struct platform_device *ofdev) +int tah_get_regs_len(struct of_device *ofdev) { return sizeof(struct emac_ethtool_regs_subhdr) + sizeof(struct tah_regs); } -void *tah_dump_regs(struct platform_device *ofdev, void *buf) +void *tah_dump_regs(struct of_device *ofdev, void *buf) { struct tah_instance *dev = dev_get_drvdata(&ofdev->dev); struct emac_ethtool_regs_subhdr *hdr = buf; @@ -87,7 +87,7 @@ void *tah_dump_regs(struct platform_device *ofdev, void *buf) return regs + 1; } -static int __devinit tah_probe(struct platform_device *ofdev, +static int __devinit tah_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -139,7 +139,7 @@ static int __devinit tah_probe(struct platform_device *ofdev, return rc; } -static int __devexit tah_remove(struct platform_device *ofdev) +static int __devexit tah_remove(struct of_device *ofdev) { struct tah_instance *dev = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/net/ibm_newemac/tah.h b/trunk/drivers/net/ibm_newemac/tah.h index 61dbeca006d1..a068b5658dad 100644 --- a/trunk/drivers/net/ibm_newemac/tah.h +++ b/trunk/drivers/net/ibm_newemac/tah.h @@ -48,7 +48,7 @@ struct tah_instance { int users; /* OF device instance */ - struct platform_device *ofdev; + struct of_device *ofdev; }; @@ -74,11 +74,11 @@ struct tah_instance { extern int tah_init(void); extern void tah_exit(void); -extern int tah_attach(struct platform_device *ofdev, int channel); -extern void tah_detach(struct platform_device *ofdev, int channel); -extern void tah_reset(struct platform_device *ofdev); -extern int tah_get_regs_len(struct platform_device *ofdev); -extern void *tah_dump_regs(struct platform_device *ofdev, void *buf); +extern int tah_attach(struct of_device *ofdev, int channel); +extern void tah_detach(struct of_device *ofdev, int channel); +extern void tah_reset(struct of_device *ofdev); +extern int tah_get_regs_len(struct of_device *ofdev); +extern void *tah_dump_regs(struct of_device *ofdev, void *buf); #else diff --git a/trunk/drivers/net/ibm_newemac/zmii.c b/trunk/drivers/net/ibm_newemac/zmii.c index 34ed6ee8ca8a..046dcd069c45 100644 --- a/trunk/drivers/net/ibm_newemac/zmii.c +++ b/trunk/drivers/net/ibm_newemac/zmii.c @@ -82,7 +82,7 @@ static inline u32 zmii_mode_mask(int mode, int input) } } -int __devinit zmii_attach(struct platform_device *ofdev, int input, int *mode) +int __devinit zmii_attach(struct of_device *ofdev, int input, int *mode) { struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); struct zmii_regs __iomem *p = dev->base; @@ -148,7 +148,7 @@ int __devinit zmii_attach(struct platform_device *ofdev, int input, int *mode) return 0; } -void zmii_get_mdio(struct platform_device *ofdev, int input) +void zmii_get_mdio(struct of_device *ofdev, int input) { struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); u32 fer; @@ -161,7 +161,7 @@ void zmii_get_mdio(struct platform_device *ofdev, int input) out_be32(&dev->base->fer, fer | ZMII_FER_MDI(input)); } -void zmii_put_mdio(struct platform_device *ofdev, int input) +void zmii_put_mdio(struct of_device *ofdev, int input) { struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); @@ -170,7 +170,7 @@ void zmii_put_mdio(struct platform_device *ofdev, int input) } -void zmii_set_speed(struct platform_device *ofdev, int input, int speed) +void zmii_set_speed(struct of_device *ofdev, int input, int speed) { struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); u32 ssr; @@ -191,7 +191,7 @@ void zmii_set_speed(struct platform_device *ofdev, int input, int speed) mutex_unlock(&dev->lock); } -void zmii_detach(struct platform_device *ofdev, int input) +void zmii_detach(struct of_device *ofdev, int input) { struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); @@ -210,13 +210,13 @@ void zmii_detach(struct platform_device *ofdev, int input) mutex_unlock(&dev->lock); } -int zmii_get_regs_len(struct platform_device *ofdev) +int zmii_get_regs_len(struct of_device *ofdev) { return sizeof(struct emac_ethtool_regs_subhdr) + sizeof(struct zmii_regs); } -void *zmii_dump_regs(struct platform_device *ofdev, void *buf) +void *zmii_dump_regs(struct of_device *ofdev, void *buf) { struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); struct emac_ethtool_regs_subhdr *hdr = buf; @@ -231,7 +231,7 @@ void *zmii_dump_regs(struct platform_device *ofdev, void *buf) return regs + 1; } -static int __devinit zmii_probe(struct platform_device *ofdev, +static int __devinit zmii_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -286,7 +286,7 @@ static int __devinit zmii_probe(struct platform_device *ofdev, return rc; } -static int __devexit zmii_remove(struct platform_device *ofdev) +static int __devexit zmii_remove(struct of_device *ofdev) { struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/net/ibm_newemac/zmii.h b/trunk/drivers/net/ibm_newemac/zmii.h index 1333fa2b2781..6c9beba0c4b6 100644 --- a/trunk/drivers/net/ibm_newemac/zmii.h +++ b/trunk/drivers/net/ibm_newemac/zmii.h @@ -48,20 +48,20 @@ struct zmii_instance { u32 fer_save; /* OF device instance */ - struct platform_device *ofdev; + struct of_device *ofdev; }; #ifdef CONFIG_IBM_NEW_EMAC_ZMII extern int zmii_init(void); extern void zmii_exit(void); -extern int zmii_attach(struct platform_device *ofdev, int input, int *mode); -extern void zmii_detach(struct platform_device *ofdev, int input); -extern void zmii_get_mdio(struct platform_device *ofdev, int input); -extern void zmii_put_mdio(struct platform_device *ofdev, int input); -extern void zmii_set_speed(struct platform_device *ofdev, int input, int speed); -extern int zmii_get_regs_len(struct platform_device *ocpdev); -extern void *zmii_dump_regs(struct platform_device *ofdev, void *buf); +extern int zmii_attach(struct of_device *ofdev, int input, int *mode); +extern void zmii_detach(struct of_device *ofdev, int input); +extern void zmii_get_mdio(struct of_device *ofdev, int input); +extern void zmii_put_mdio(struct of_device *ofdev, int input); +extern void zmii_set_speed(struct of_device *ofdev, int input, int speed); +extern int zmii_get_regs_len(struct of_device *ocpdev); +extern void *zmii_dump_regs(struct of_device *ofdev, void *buf); #else # define zmii_init() 0 diff --git a/trunk/drivers/net/ll_temac_main.c b/trunk/drivers/net/ll_temac_main.c index c7b624711f5e..4eea3f70c5cf 100644 --- a/trunk/drivers/net/ll_temac_main.c +++ b/trunk/drivers/net/ll_temac_main.c @@ -159,7 +159,7 @@ static void temac_dma_dcr_out(struct temac_local *lp, int reg, u32 value) * temac_dcr_setup - If the DMA is DCR based, then setup the address and * I/O functions */ -static int temac_dcr_setup(struct temac_local *lp, struct platform_device *op, +static int temac_dcr_setup(struct temac_local *lp, struct of_device *op, struct device_node *np) { unsigned int dcrs; @@ -184,7 +184,7 @@ static int temac_dcr_setup(struct temac_local *lp, struct platform_device *op, * temac_dcr_setup - This is a stub for when DCR is not supported, * such as with MicroBlaze */ -static int temac_dcr_setup(struct temac_local *lp, struct platform_device *op, +static int temac_dcr_setup(struct temac_local *lp, struct of_device *op, struct device_node *np) { return -1; @@ -952,7 +952,7 @@ static const struct attribute_group temac_attr_group = { }; static int __init -temac_of_probe(struct platform_device *op, const struct of_device_id *match) +temac_of_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *np; struct temac_local *lp; @@ -1094,7 +1094,7 @@ temac_of_probe(struct platform_device *op, const struct of_device_id *match) return rc; } -static int __devexit temac_of_remove(struct platform_device *op) +static int __devexit temac_of_remove(struct of_device *op) { struct net_device *ndev = dev_get_drvdata(&op->dev); struct temac_local *lp = netdev_priv(ndev); diff --git a/trunk/drivers/net/myri10ge/myri10ge.c b/trunk/drivers/net/myri10ge/myri10ge.c index fb2c0927d3cc..d771d1650d60 100644 --- a/trunk/drivers/net/myri10ge/myri10ge.c +++ b/trunk/drivers/net/myri10ge/myri10ge.c @@ -239,7 +239,6 @@ struct myri10ge_priv { int watchdog_resets; int watchdog_pause; int pause; - bool fw_name_allocated; char *fw_name; char eeprom_strings[MYRI10GE_EEPROM_STRINGS_SIZE]; char *product_code_string; @@ -272,7 +271,6 @@ MODULE_FIRMWARE("myri10ge_eth_z8e.dat"); MODULE_FIRMWARE("myri10ge_rss_ethp_z8e.dat"); MODULE_FIRMWARE("myri10ge_rss_eth_z8e.dat"); -/* Careful: must be accessed under kparam_block_sysfs_write */ static char *myri10ge_fw_name = NULL; module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name"); @@ -378,14 +376,6 @@ static inline void put_be32(__be32 val, __be32 __iomem * p) static struct net_device_stats *myri10ge_get_stats(struct net_device *dev); -static void set_fw_name(struct myri10ge_priv *mgp, char *name, bool allocated) -{ - if (mgp->fw_name_allocated) - kfree(mgp->fw_name); - mgp->fw_name = name; - mgp->fw_name_allocated = allocated; -} - static int myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, struct myri10ge_cmd *data, int atomic) @@ -757,7 +747,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp, int adopt) dev_warn(&mgp->pdev->dev, "via hotplug\n"); } - set_fw_name(mgp, "adopted", false); + mgp->fw_name = "adopted"; mgp->tx_boundary = 2048; myri10ge_dummy_rdma(mgp, 1); status = myri10ge_get_firmware_capabilities(mgp); @@ -3243,7 +3233,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) * load the optimized firmware (which assumes aligned PCIe * completions) in order to see if it works on this host. */ - set_fw_name(mgp, myri10ge_fw_aligned, false); + mgp->fw_name = myri10ge_fw_aligned; status = myri10ge_load_firmware(mgp, 1); if (status != 0) { goto abort; @@ -3271,7 +3261,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) abort: /* fall back to using the unaligned firmware */ mgp->tx_boundary = 2048; - set_fw_name(mgp, myri10ge_fw_unaligned, false); + mgp->fw_name = myri10ge_fw_unaligned; } @@ -3294,7 +3284,7 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp) dev_info(&mgp->pdev->dev, "PCIE x%d Link\n", link_width); mgp->tx_boundary = 4096; - set_fw_name(mgp, myri10ge_fw_aligned, false); + mgp->fw_name = myri10ge_fw_aligned; } else { myri10ge_firmware_probe(mgp); } @@ -3303,29 +3293,22 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp) dev_info(&mgp->pdev->dev, "Assuming aligned completions (forced)\n"); mgp->tx_boundary = 4096; - set_fw_name(mgp, myri10ge_fw_aligned, false); + mgp->fw_name = myri10ge_fw_aligned; } else { dev_info(&mgp->pdev->dev, "Assuming unaligned completions (forced)\n"); mgp->tx_boundary = 2048; - set_fw_name(mgp, myri10ge_fw_unaligned, false); + mgp->fw_name = myri10ge_fw_unaligned; } } - - kparam_block_sysfs_write(myri10ge_fw_name); if (myri10ge_fw_name != NULL) { - char *fw_name = kstrdup(myri10ge_fw_name, GFP_KERNEL); - if (fw_name) { - overridden = 1; - set_fw_name(mgp, fw_name, true); - } + overridden = 1; + mgp->fw_name = myri10ge_fw_name; } - kparam_unblock_sysfs_write(myri10ge_fw_name); - if (mgp->board_number < MYRI10GE_MAX_BOARDS && myri10ge_fw_names[mgp->board_number] != NULL && strlen(myri10ge_fw_names[mgp->board_number])) { - set_fw_name(mgp, myri10ge_fw_names[mgp->board_number], false); + mgp->fw_name = myri10ge_fw_names[mgp->board_number]; overridden = 1; } if (overridden) @@ -3677,7 +3660,6 @@ static void myri10ge_probe_slices(struct myri10ge_priv *mgp) struct myri10ge_cmd cmd; struct pci_dev *pdev = mgp->pdev; char *old_fw; - bool old_allocated; int i, status, ncpus, msix_cap; mgp->num_slices = 1; @@ -3690,23 +3672,17 @@ static void myri10ge_probe_slices(struct myri10ge_priv *mgp) /* try to load the slice aware rss firmware */ old_fw = mgp->fw_name; - old_allocated = mgp->fw_name_allocated; - /* don't free old_fw if we override it. */ - mgp->fw_name_allocated = false; - if (myri10ge_fw_name != NULL) { dev_info(&mgp->pdev->dev, "overriding rss firmware to %s\n", myri10ge_fw_name); - set_fw_name(mgp, myri10ge_fw_name, false); + mgp->fw_name = myri10ge_fw_name; } else if (old_fw == myri10ge_fw_aligned) - set_fw_name(mgp, myri10ge_fw_rss_aligned, false); + mgp->fw_name = myri10ge_fw_rss_aligned; else - set_fw_name(mgp, myri10ge_fw_rss_unaligned, false); + mgp->fw_name = myri10ge_fw_rss_unaligned; status = myri10ge_load_firmware(mgp, 0); if (status != 0) { dev_info(&pdev->dev, "Rss firmware not found\n"); - if (old_allocated) - kfree(old_fw); return; } @@ -3771,8 +3747,6 @@ static void myri10ge_probe_slices(struct myri10ge_priv *mgp) mgp->num_slices); if (status == 0) { pci_disable_msix(pdev); - if (old_allocated) - kfree(old_fw); return; } if (status > 0) @@ -3789,7 +3763,7 @@ static void myri10ge_probe_slices(struct myri10ge_priv *mgp) abort_with_fw: mgp->num_slices = 1; - set_fw_name(mgp, old_fw, old_allocated); + mgp->fw_name = old_fw; myri10ge_load_firmware(mgp, 0); } @@ -4019,7 +3993,6 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_disable_device(pdev); abort_with_netdev: - set_fw_name(mgp, NULL, false); free_netdev(netdev); return status; } @@ -4064,7 +4037,6 @@ static void myri10ge_remove(struct pci_dev *pdev) dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), mgp->cmd, mgp->cmd_bus); - set_fw_name(mgp, NULL, false); free_netdev(netdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); diff --git a/trunk/drivers/net/myri_sbus.c b/trunk/drivers/net/myri_sbus.c index 617f898ba5f0..04e552aa14ec 100644 --- a/trunk/drivers/net/myri_sbus.c +++ b/trunk/drivers/net/myri_sbus.c @@ -926,7 +926,7 @@ static const struct net_device_ops myri_ops = { .ndo_validate_addr = eth_validate_addr, }; -static int __devinit myri_sbus_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit myri_sbus_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; static unsigned version_printed; @@ -1124,7 +1124,7 @@ static int __devinit myri_sbus_probe(struct platform_device *op, const struct of return -ENODEV; } -static int __devexit myri_sbus_remove(struct platform_device *op) +static int __devexit myri_sbus_remove(struct of_device *op) { struct myri_eth *mp = dev_get_drvdata(&op->dev); struct net_device *net_dev = mp->dev; diff --git a/trunk/drivers/net/myri_sbus.h b/trunk/drivers/net/myri_sbus.h index 80a2fa5cf757..ff363e95d9cf 100644 --- a/trunk/drivers/net/myri_sbus.h +++ b/trunk/drivers/net/myri_sbus.h @@ -288,7 +288,7 @@ struct myri_eth { struct myri_eeprom eeprom; /* Local copy of EEPROM. */ unsigned int reg_size; /* Size of register space. */ unsigned int shmem_base; /* Offset to shared ram. */ - struct platform_device *myri_op; /* Our OF device struct. */ + struct of_device *myri_op; /* Our OF device struct. */ }; /* We use this to acquire receive skb's that we can DMA directly into. */ diff --git a/trunk/drivers/net/niu.c b/trunk/drivers/net/niu.c index bc695d53cdcc..404f2d552888 100644 --- a/trunk/drivers/net/niu.c +++ b/trunk/drivers/net/niu.c @@ -9103,7 +9103,7 @@ static void __devinit niu_try_msix(struct niu *np, u8 *ldg_num_map) static int __devinit niu_n2_irq_init(struct niu *np, u8 *ldg_num_map) { #ifdef CONFIG_SPARC64 - struct platform_device *op = np->op; + struct of_device *op = np->op; const u32 *int_prop; int i; @@ -9688,7 +9688,7 @@ static void __devinit niu_driver_version(void) static struct net_device * __devinit niu_alloc_and_init( struct device *gen_dev, struct pci_dev *pdev, - struct platform_device *op, const struct niu_ops *ops, + struct of_device *op, const struct niu_ops *ops, u8 port) { struct net_device *dev; @@ -10064,7 +10064,7 @@ static const struct niu_ops niu_phys_ops = { .unmap_single = niu_phys_unmap_single, }; -static int __devinit niu_of_probe(struct platform_device *op, +static int __devinit niu_of_probe(struct of_device *op, const struct of_device_id *match) { union niu_parent_id parent_id; @@ -10179,7 +10179,7 @@ static int __devinit niu_of_probe(struct platform_device *op, return err; } -static int __devexit niu_of_remove(struct platform_device *op) +static int __devexit niu_of_remove(struct of_device *op) { struct net_device *dev = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/net/phy/mdio-gpio.c b/trunk/drivers/net/phy/mdio-gpio.c index f62c7b717bc8..fc5fef2a8175 100644 --- a/trunk/drivers/net/phy/mdio-gpio.c +++ b/trunk/drivers/net/phy/mdio-gpio.c @@ -188,7 +188,7 @@ static int __devexit mdio_gpio_remove(struct platform_device *pdev) #ifdef CONFIG_OF_GPIO -static int __devinit mdio_ofgpio_probe(struct platform_device *ofdev, +static int __devinit mdio_ofgpio_probe(struct of_device *ofdev, const struct of_device_id *match) { struct mdio_gpio_platform_data *pdata; @@ -224,7 +224,7 @@ static int __devinit mdio_ofgpio_probe(struct platform_device *ofdev, return -ENODEV; } -static int __devexit mdio_ofgpio_remove(struct platform_device *ofdev) +static int __devexit mdio_ofgpio_remove(struct of_device *ofdev) { mdio_gpio_bus_destroy(&ofdev->dev); kfree(ofdev->dev.platform_data); diff --git a/trunk/drivers/net/sunbmac.c b/trunk/drivers/net/sunbmac.c index 618643e3ca3e..09c071bd6ad4 100644 --- a/trunk/drivers/net/sunbmac.c +++ b/trunk/drivers/net/sunbmac.c @@ -97,7 +97,7 @@ static int qec_global_reset(void __iomem *gregs) static void qec_init(struct bigmac *bp) { - struct platform_device *qec_op = bp->qec_op; + struct of_device *qec_op = bp->qec_op; void __iomem *gregs = bp->gregs; u8 bsizes = bp->bigmac_bursts; u32 regval; @@ -1083,8 +1083,8 @@ static const struct net_device_ops bigmac_ops = { .ndo_validate_addr = eth_validate_addr, }; -static int __devinit bigmac_ether_init(struct platform_device *op, - struct platform_device *qec_op) +static int __devinit bigmac_ether_init(struct of_device *op, + struct of_device *qec_op) { static int version_printed; struct net_device *dev; @@ -1242,25 +1242,25 @@ static int __devinit bigmac_ether_init(struct platform_device *op, /* QEC can be the parent of either QuadEthernet or a BigMAC. We want * the latter. */ -static int __devinit bigmac_sbus_probe(struct platform_device *op, +static int __devinit bigmac_sbus_probe(struct of_device *op, const struct of_device_id *match) { struct device *parent = op->dev.parent; - struct platform_device *qec_op; + struct of_device *qec_op; - qec_op = to_platform_device(parent); + qec_op = to_of_device(parent); return bigmac_ether_init(op, qec_op); } -static int __devexit bigmac_sbus_remove(struct platform_device *op) +static int __devexit bigmac_sbus_remove(struct of_device *op) { struct bigmac *bp = dev_get_drvdata(&op->dev); struct device *parent = op->dev.parent; struct net_device *net_dev = bp->dev; - struct platform_device *qec_op; + struct of_device *qec_op; - qec_op = to_platform_device(parent); + qec_op = to_of_device(parent); unregister_netdev(net_dev); diff --git a/trunk/drivers/net/sunbmac.h b/trunk/drivers/net/sunbmac.h index 8db88945b889..8840bc0b840b 100644 --- a/trunk/drivers/net/sunbmac.h +++ b/trunk/drivers/net/sunbmac.h @@ -329,8 +329,8 @@ struct bigmac { unsigned int timer_ticks; struct net_device_stats enet_stats; - struct platform_device *qec_op; - struct platform_device *bigmac_op; + struct of_device *qec_op; + struct of_device *bigmac_op; struct net_device *dev; }; diff --git a/trunk/drivers/net/sunhme.c b/trunk/drivers/net/sunhme.c index bd0df1c14955..eec443f64079 100644 --- a/trunk/drivers/net/sunhme.c +++ b/trunk/drivers/net/sunhme.c @@ -1591,7 +1591,7 @@ static int happy_meal_init(struct happy_meal *hp) */ #ifdef CONFIG_SBUS if ((hp->happy_flags & HFLAG_PCI) == 0) { - struct platform_device *op = hp->happy_dev; + struct of_device *op = hp->happy_dev; if (sbus_can_dma_64bit()) { sbus_set_sbus64(&op->dev, hp->happy_bursts); @@ -2480,7 +2480,7 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info #ifdef CONFIG_SBUS else { const struct linux_prom_registers *regs; - struct platform_device *op = hp->happy_dev; + struct of_device *op = hp->happy_dev; regs = of_get_property(op->dev.of_node, "regs", NULL); if (regs) sprintf(info->bus_info, "SBUS:%d", @@ -2515,13 +2515,13 @@ static int hme_version_printed; * * Return NULL on failure. */ -static struct quattro * __devinit quattro_sbus_find(struct platform_device *child) +static struct quattro * __devinit quattro_sbus_find(struct of_device *child) { struct device *parent = child->dev.parent; - struct platform_device *op; + struct of_device *op; struct quattro *qp; - op = to_platform_device(parent); + op = to_of_device(parent); qp = dev_get_drvdata(&op->dev); if (qp) return qp; @@ -2551,7 +2551,7 @@ static int __init quattro_sbus_register_irqs(void) struct quattro *qp; for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { - struct platform_device *op = qp->quattro_dev; + struct of_device *op = qp->quattro_dev; int err, qfe_slot, skip = 0; for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) { @@ -2580,7 +2580,7 @@ static void quattro_sbus_free_irqs(void) struct quattro *qp; for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { - struct platform_device *op = qp->quattro_dev; + struct of_device *op = qp->quattro_dev; int qfe_slot, skip = 0; for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) { @@ -2639,7 +2639,7 @@ static const struct net_device_ops hme_netdev_ops = { }; #ifdef CONFIG_SBUS -static int __devinit happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) +static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe) { struct device_node *dp = op->dev.of_node, *sbus_dp; struct quattro *qp = NULL; @@ -2648,7 +2648,7 @@ static int __devinit happy_meal_sbus_probe_one(struct platform_device *op, int i int i, qfe_slot = -1; int err = -ENODEV; - sbus_dp = op->dev.parent->of_node; + sbus_dp = to_of_device(op->dev.parent)->dev.of_node; /* We can match PCI devices too, do not accept those here. */ if (strcmp(sbus_dp->name, "sbus")) @@ -3235,7 +3235,7 @@ static void happy_meal_pci_exit(void) #endif #ifdef CONFIG_SBUS -static int __devinit hme_sbus_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit hme_sbus_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; const char *model = of_get_property(dp, "model", NULL); @@ -3247,7 +3247,7 @@ static int __devinit hme_sbus_probe(struct platform_device *op, const struct of_ return happy_meal_sbus_probe_one(op, is_qfe); } -static int __devexit hme_sbus_remove(struct platform_device *op) +static int __devexit hme_sbus_remove(struct of_device *op) { struct happy_meal *hp = dev_get_drvdata(&op->dev); struct net_device *net_dev = hp->dev; diff --git a/trunk/drivers/net/sunhme.h b/trunk/drivers/net/sunhme.h index 756b5bf3aa89..efd2ca0fcad3 100644 --- a/trunk/drivers/net/sunhme.h +++ b/trunk/drivers/net/sunhme.h @@ -407,7 +407,7 @@ struct happy_meal { void (*write_rxd)(struct happy_meal_rxd *, u32, u32); #endif - /* This is either an platform_device or a pci_dev. */ + /* This is either an of_device or a pci_dev. */ void *happy_dev; struct device *dma_dev; diff --git a/trunk/drivers/net/sunlance.c b/trunk/drivers/net/sunlance.c index 8dcb858f2168..ee364fa75634 100644 --- a/trunk/drivers/net/sunlance.c +++ b/trunk/drivers/net/sunlance.c @@ -250,7 +250,7 @@ struct lance_private { int rx_new, tx_new; int rx_old, tx_old; - struct platform_device *ledma; /* If set this points to ledma */ + struct of_device *ledma; /* If set this points to ledma */ char tpe; /* cable-selection is TPE */ char auto_select; /* cable-selection by carrier */ char burst_sizes; /* ledma SBus burst sizes */ @@ -265,8 +265,8 @@ struct lance_private { char *name; dma_addr_t init_block_dvma; struct net_device *dev; /* Backpointer */ - struct platform_device *op; - struct platform_device *lebuffer; + struct of_device *op; + struct of_device *lebuffer; struct timer_list multicast_timer; }; @@ -1272,7 +1272,7 @@ static void lance_free_hwresources(struct lance_private *lp) if (lp->lregs) of_iounmap(&lp->op->resource[0], lp->lregs, LANCE_REG_SIZE); if (lp->dregs) { - struct platform_device *ledma = lp->ledma; + struct of_device *ledma = lp->ledma; of_iounmap(&ledma->resource[0], lp->dregs, resource_size(&ledma->resource[0])); @@ -1319,9 +1319,9 @@ static const struct net_device_ops sparc_lance_ops = { .ndo_validate_addr = eth_validate_addr, }; -static int __devinit sparc_lance_probe_one(struct platform_device *op, - struct platform_device *ledma, - struct platform_device *lebuffer) +static int __devinit sparc_lance_probe_one(struct of_device *op, + struct of_device *ledma, + struct of_device *lebuffer) { struct device_node *dp = op->dev.of_node; static unsigned version_printed; @@ -1503,9 +1503,9 @@ static int __devinit sparc_lance_probe_one(struct platform_device *op, return -ENODEV; } -static int __devinit sunlance_sbus_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit sunlance_sbus_probe(struct of_device *op, const struct of_device_id *match) { - struct platform_device *parent = to_platform_device(op->dev.parent); + struct of_device *parent = to_of_device(op->dev.parent); struct device_node *parent_dp = parent->dev.of_node; int err; @@ -1519,7 +1519,7 @@ static int __devinit sunlance_sbus_probe(struct platform_device *op, const struc return err; } -static int __devexit sunlance_sbus_remove(struct platform_device *op) +static int __devexit sunlance_sbus_remove(struct of_device *op) { struct lance_private *lp = dev_get_drvdata(&op->dev); struct net_device *net_dev = lp->dev; diff --git a/trunk/drivers/net/sunqe.c b/trunk/drivers/net/sunqe.c index 72e65d4666ef..5f84a5dadedd 100644 --- a/trunk/drivers/net/sunqe.c +++ b/trunk/drivers/net/sunqe.c @@ -689,7 +689,7 @@ static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { const struct linux_prom_registers *regs; struct sunqe *qep = netdev_priv(dev); - struct platform_device *op; + struct of_device *op; strcpy(info->driver, "sunqe"); strcpy(info->version, "3.0"); @@ -720,7 +720,7 @@ static const struct ethtool_ops qe_ethtool_ops = { }; /* This is only called once at boot time for each card probed. */ -static void qec_init_once(struct sunqec *qecp, struct platform_device *op) +static void qec_init_once(struct sunqec *qecp, struct of_device *op) { u8 bsizes = qecp->qec_bursts; @@ -770,9 +770,9 @@ static u8 __devinit qec_get_burst(struct device_node *dp) return bsizes; } -static struct sunqec * __devinit get_qec(struct platform_device *child) +static struct sunqec * __devinit get_qec(struct of_device *child) { - struct platform_device *op = to_platform_device(child->dev.parent); + struct of_device *op = to_of_device(child->dev.parent); struct sunqec *qecp; qecp = dev_get_drvdata(&op->dev); @@ -836,7 +836,7 @@ static const struct net_device_ops qec_ops = { .ndo_validate_addr = eth_validate_addr, }; -static int __devinit qec_ether_init(struct platform_device *op) +static int __devinit qec_ether_init(struct of_device *op) { static unsigned version_printed; struct net_device *dev; @@ -941,12 +941,12 @@ static int __devinit qec_ether_init(struct platform_device *op) return res; } -static int __devinit qec_sbus_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit qec_sbus_probe(struct of_device *op, const struct of_device_id *match) { return qec_ether_init(op); } -static int __devexit qec_sbus_remove(struct platform_device *op) +static int __devexit qec_sbus_remove(struct of_device *op) { struct sunqe *qp = dev_get_drvdata(&op->dev); struct net_device *net_dev = qp->dev; @@ -997,7 +997,7 @@ static void __exit qec_exit(void) while (root_qec_dev) { struct sunqec *next = root_qec_dev->next_module; - struct platform_device *op = root_qec_dev->op; + struct of_device *op = root_qec_dev->op; free_irq(op->archdata.irqs[0], (void *) root_qec_dev); of_iounmap(&op->resource[0], root_qec_dev->gregs, diff --git a/trunk/drivers/net/sunqe.h b/trunk/drivers/net/sunqe.h index 581781b6b2fa..5813a7b2faa5 100644 --- a/trunk/drivers/net/sunqe.h +++ b/trunk/drivers/net/sunqe.h @@ -314,7 +314,7 @@ struct sunqec { void __iomem *gregs; /* QEC Global Registers */ struct sunqe *qes[4]; /* Each child MACE */ unsigned int qec_bursts; /* Support burst sizes */ - struct platform_device *op; /* QEC's OF device */ + struct of_device *op; /* QEC's OF device */ struct sunqec *next_module; /* List of all QECs in system */ }; @@ -342,7 +342,7 @@ struct sunqe { __u32 buffers_dvma; /* DVMA visible address. */ struct sunqec *parent; u8 mconfig; /* Base MACE mconfig value */ - struct platform_device *op; /* QE's OF device struct */ + struct of_device *op; /* QE's OF device struct */ struct net_device *dev; /* QE's netdevice struct */ int channel; /* Who am I? */ }; diff --git a/trunk/drivers/net/ucc_geth.c b/trunk/drivers/net/ucc_geth.c index a4c3f5708246..8d532f9b50d0 100644 --- a/trunk/drivers/net/ucc_geth.c +++ b/trunk/drivers/net/ucc_geth.c @@ -3601,7 +3601,7 @@ static void ucc_geth_timeout(struct net_device *dev) #ifdef CONFIG_PM -static int ucc_geth_suspend(struct platform_device *ofdev, pm_message_t state) +static int ucc_geth_suspend(struct of_device *ofdev, pm_message_t state) { struct net_device *ndev = dev_get_drvdata(&ofdev->dev); struct ucc_geth_private *ugeth = netdev_priv(ndev); @@ -3629,7 +3629,7 @@ static int ucc_geth_suspend(struct platform_device *ofdev, pm_message_t state) return 0; } -static int ucc_geth_resume(struct platform_device *ofdev) +static int ucc_geth_resume(struct of_device *ofdev) { struct net_device *ndev = dev_get_drvdata(&ofdev->dev); struct ucc_geth_private *ugeth = netdev_priv(ndev); @@ -3732,7 +3732,7 @@ static const struct net_device_ops ucc_geth_netdev_ops = { #endif }; -static int ucc_geth_probe(struct platform_device* ofdev, const struct of_device_id *match) +static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *match) { struct device *device = &ofdev->dev; struct device_node *np = ofdev->dev.of_node; @@ -3954,7 +3954,7 @@ static int ucc_geth_probe(struct platform_device* ofdev, const struct of_device_ return 0; } -static int ucc_geth_remove(struct platform_device* ofdev) +static int ucc_geth_remove(struct of_device* ofdev) { struct device *device = &ofdev->dev; struct net_device *dev = dev_get_drvdata(device); diff --git a/trunk/drivers/net/wireless/libertas/if_sdio.c b/trunk/drivers/net/wireless/libertas/if_sdio.c index ba854c70ab94..6e71346a7550 100644 --- a/trunk/drivers/net/wireless/libertas/if_sdio.c +++ b/trunk/drivers/net/wireless/libertas/if_sdio.c @@ -125,8 +125,6 @@ struct if_sdio_card { const char *helper; const char *firmware; - bool helper_allocated; - bool firmware_allocated; u8 buffer[65536]; @@ -986,34 +984,16 @@ static int if_sdio_probe(struct sdio_func *func, card->helper = if_sdio_models[i].helper; card->firmware = if_sdio_models[i].firmware; - kparam_block_sysfs_write(helper_name); if (lbs_helper_name) { - char *helper = kstrdup(lbs_helper_name, GFP_KERNEL); - if (!helper) { - kparam_unblock_sysfs_write(helper_name); - ret = -ENOMEM; - goto free; - } lbs_deb_sdio("overriding helper firmware: %s\n", lbs_helper_name); - card->helper = helper; - card->helper_allocated = true; + card->helper = lbs_helper_name; } - kparam_unblock_sysfs_write(helper_name); - kparam_block_sysfs_write(fw_name); if (lbs_fw_name) { - char *fw_name = kstrdup(lbs_fw_name, GFP_KERNEL); - if (!fw_name) { - kparam_unblock_sysfs_write(fw_name); - ret = -ENOMEM; - goto free; - } lbs_deb_sdio("overriding firmware: %s\n", lbs_fw_name); - card->firmware = fw_name; - card->firmware_allocated = true; + card->firmware = lbs_fw_name; } - kparam_unblock_sysfs_write(fw_name); sdio_claim_host(func); @@ -1147,10 +1127,6 @@ static int if_sdio_probe(struct sdio_func *func, kfree(packet); } - if (card->helper_allocated) - kfree(card->helper); - if (card->firmware_allocated) - kfree(card->firmware); kfree(card); goto out; @@ -1201,10 +1177,6 @@ static void if_sdio_remove(struct sdio_func *func) kfree(packet); } - if (card->helper_allocated) - kfree(card->helper); - if (card->firmware_allocated) - kfree(card->firmware); kfree(card); lbs_deb_leave(LBS_DEB_SDIO); diff --git a/trunk/drivers/net/wireless/libertas/if_usb.c b/trunk/drivers/net/wireless/libertas/if_usb.c index 3ff61063671a..07ece9d26c63 100644 --- a/trunk/drivers/net/wireless/libertas/if_usb.c +++ b/trunk/drivers/net/wireless/libertas/if_usb.c @@ -289,13 +289,10 @@ static int if_usb_probe(struct usb_interface *intf, } /* Upload firmware */ - kparam_block_sysfs_write(fw_name); if (__if_usb_prog_firmware(cardp, lbs_fw_name, BOOT_CMD_FW_BY_USB)) { - kparam_unblock_sysfs_write(fw_name); lbs_deb_usbd(&udev->dev, "FW upload failed\n"); goto err_prog_firmware; } - kparam_unblock_sysfs_write(fw_name); if (!(priv = lbs_add_card(cardp, &udev->dev))) goto err_prog_firmware; diff --git a/trunk/drivers/net/wireless/libertas_tf/if_usb.c b/trunk/drivers/net/wireless/libertas_tf/if_usb.c index 41a4f214ade1..b172f5d87a3b 100644 --- a/trunk/drivers/net/wireless/libertas_tf/if_usb.c +++ b/trunk/drivers/net/wireless/libertas_tf/if_usb.c @@ -811,15 +811,12 @@ static int if_usb_prog_firmware(struct if_usb_card *cardp) lbtf_deb_enter(LBTF_DEB_USB); - kparam_block_sysfs_write(fw_name); ret = request_firmware(&cardp->fw, lbtf_fw_name, &cardp->udev->dev); if (ret < 0) { pr_err("request_firmware() failed with %#x\n", ret); pr_err("firmware %s not found\n", lbtf_fw_name); - kparam_unblock_sysfs_write(fw_name); goto done; } - kparam_unblock_sysfs_write(fw_name); if (check_fwfile_format(cardp->fw->data, cardp->fw->size)) goto release_fw; diff --git a/trunk/drivers/net/xilinx_emaclite.c b/trunk/drivers/net/xilinx_emaclite.c index ecbbb688eba0..b2c2f391b29d 100644 --- a/trunk/drivers/net/xilinx_emaclite.c +++ b/trunk/drivers/net/xilinx_emaclite.c @@ -1086,7 +1086,7 @@ static void xemaclite_remove_ndev(struct net_device *ndev) * * Return: Value of the parameter if the parameter is found, or 0 otherwise */ -static bool get_bool(struct platform_device *ofdev, const char *s) +static bool get_bool(struct of_device *ofdev, const char *s) { u32 *p = (u32 *)of_get_property(ofdev->dev.of_node, s, NULL); @@ -1115,7 +1115,7 @@ static struct net_device_ops xemaclite_netdev_ops; * Return: 0, if the driver is bound to the Emaclite device, or * a negative error if there is failure. */ -static int __devinit xemaclite_of_probe(struct platform_device *ofdev, +static int __devinit xemaclite_of_probe(struct of_device *ofdev, const struct of_device_id *match) { struct resource r_irq; /* Interrupt resources */ @@ -1240,7 +1240,7 @@ static int __devinit xemaclite_of_probe(struct platform_device *ofdev, * * Return: 0, always. */ -static int __devexit xemaclite_of_remove(struct platform_device *of_dev) +static int __devexit xemaclite_of_remove(struct of_device *of_dev) { struct device *dev = &of_dev->dev; struct net_device *ndev = dev_get_drvdata(dev); diff --git a/trunk/drivers/of/device.c b/trunk/drivers/of/device.c index 92de0eb74aea..0d8a0644f540 100644 --- a/trunk/drivers/of/device.c +++ b/trunk/drivers/of/device.c @@ -14,7 +14,7 @@ * @ids: array of of device match structures to search in * @dev: the of device structure to match against * - * Used by a driver to check whether an platform_device present in the + * Used by a driver to check whether an of_device present in the * system is in its list of supported devices. */ const struct of_device_id *of_match_device(const struct of_device_id *matches, diff --git a/trunk/drivers/parport/parport_sunbpp.c b/trunk/drivers/parport/parport_sunbpp.c index 55ba118f1cf1..210a6441a066 100644 --- a/trunk/drivers/parport/parport_sunbpp.c +++ b/trunk/drivers/parport/parport_sunbpp.c @@ -286,7 +286,7 @@ static struct parport_operations parport_sunbpp_ops = .owner = THIS_MODULE, }; -static int __devinit bpp_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit bpp_probe(struct of_device *op, const struct of_device_id *match) { struct parport_operations *ops; struct bpp_regs __iomem *regs; @@ -351,7 +351,7 @@ static int __devinit bpp_probe(struct platform_device *op, const struct of_devic return err; } -static int __devexit bpp_remove(struct platform_device *op) +static int __devexit bpp_remove(struct of_device *op) { struct parport *p = dev_get_drvdata(&op->dev); struct parport_operations *ops = p->ops; diff --git a/trunk/drivers/pcmcia/electra_cf.c b/trunk/drivers/pcmcia/electra_cf.c index 546d3024b6f0..f94d8281cfb0 100644 --- a/trunk/drivers/pcmcia/electra_cf.c +++ b/trunk/drivers/pcmcia/electra_cf.c @@ -44,7 +44,7 @@ struct electra_cf_socket { unsigned present:1; unsigned active:1; - struct platform_device *ofdev; + struct of_device *ofdev; unsigned long mem_phys; void __iomem * mem_base; unsigned long mem_size; @@ -181,7 +181,7 @@ static struct pccard_operations electra_cf_ops = { .set_mem_map = electra_cf_set_mem_map, }; -static int __devinit electra_cf_probe(struct platform_device *ofdev, +static int __devinit electra_cf_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device *device = &ofdev->dev; @@ -325,7 +325,7 @@ static int __devinit electra_cf_probe(struct platform_device *ofdev, } -static int __devexit electra_cf_remove(struct platform_device *ofdev) +static int __devexit electra_cf_remove(struct of_device *ofdev) { struct device *device = &ofdev->dev; struct electra_cf_socket *cf; diff --git a/trunk/drivers/pcmcia/m8xx_pcmcia.c b/trunk/drivers/pcmcia/m8xx_pcmcia.c index f0ecad99ce81..f2f90a7d3e12 100644 --- a/trunk/drivers/pcmcia/m8xx_pcmcia.c +++ b/trunk/drivers/pcmcia/m8xx_pcmcia.c @@ -1149,7 +1149,7 @@ static struct pccard_operations m8xx_services = { .set_mem_map = m8xx_set_mem_map, }; -static int __init m8xx_probe(struct platform_device *ofdev, +static int __init m8xx_probe(struct of_device *ofdev, const struct of_device_id *match) { struct pcmcia_win *w; @@ -1249,7 +1249,7 @@ static int __init m8xx_probe(struct platform_device *ofdev, return 0; } -static int m8xx_remove(struct platform_device *ofdev) +static int m8xx_remove(struct of_device *ofdev) { u32 m, i; struct pcmcia_win *w; diff --git a/trunk/drivers/power/Kconfig b/trunk/drivers/power/Kconfig index 07343568a12e..1e5506be39b4 100644 --- a/trunk/drivers/power/Kconfig +++ b/trunk/drivers/power/Kconfig @@ -136,12 +136,6 @@ config BATTERY_Z2 help Say Y to include support for the battery on the Zipit Z2. -config BATTERY_S3C_ADC - tristate "Battery driver for Samsung ADC based monitoring" - depends on S3C_ADC - help - Say Y here to enable support for iPAQ h1930/h1940/rx1950 battery - config CHARGER_PCF50633 tristate "NXP PCF50633 MBC" depends on MFD_PCF50633 @@ -159,11 +153,4 @@ config BATTERY_JZ4740 This driver can be build as a module. If so, the module will be called jz4740-battery. -config BATTERY_INTEL_MID - tristate "Battery driver for Intel MID platforms" - depends on INTEL_SCU_IPC && SPI - help - Say Y here to enable the battery driver on Intel MID - platforms. - endif # POWER_SUPPLY diff --git a/trunk/drivers/power/Makefile b/trunk/drivers/power/Makefile index 10143aaf4ee3..cf95009d9bcd 100644 --- a/trunk/drivers/power/Makefile +++ b/trunk/drivers/power/Makefile @@ -33,7 +33,5 @@ obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o obj-$(CONFIG_BATTERY_Z2) += z2_battery.o -obj-$(CONFIG_BATTERY_S3C_ADC) += s3c_adc_battery.o obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o obj-$(CONFIG_BATTERY_JZ4740) += jz4740-battery.o -obj-$(CONFIG_BATTERY_INTEL_MID) += intel_mid_battery.o diff --git a/trunk/drivers/power/intel_mid_battery.c b/trunk/drivers/power/intel_mid_battery.c deleted file mode 100644 index c61ffec2ff10..000000000000 --- a/trunk/drivers/power/intel_mid_battery.c +++ /dev/null @@ -1,799 +0,0 @@ -/* - * intel_mid_battery.c - Intel MID PMIC Battery Driver - * - * Copyright (C) 2009 Intel Corporation - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - * 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; version 2 of the License. - * - * 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. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Author: Nithish Mahalingam - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define DRIVER_NAME "pmic_battery" - -/********************************************************************* - * Generic defines - *********************************************************************/ - -static int debug; -module_param(debug, int, 0444); -MODULE_PARM_DESC(debug, "Flag to enable PMIC Battery debug messages."); - -#define PMIC_BATT_DRV_INFO_UPDATED 1 -#define PMIC_BATT_PRESENT 1 -#define PMIC_BATT_NOT_PRESENT 0 -#define PMIC_USB_PRESENT PMIC_BATT_PRESENT -#define PMIC_USB_NOT_PRESENT PMIC_BATT_NOT_PRESENT - -/* pmic battery register related */ -#define PMIC_BATT_CHR_SCHRGINT_ADDR 0xD2 -#define PMIC_BATT_CHR_SBATOVP_MASK (1 << 1) -#define PMIC_BATT_CHR_STEMP_MASK (1 << 2) -#define PMIC_BATT_CHR_SCOMP_MASK (1 << 3) -#define PMIC_BATT_CHR_SUSBDET_MASK (1 << 4) -#define PMIC_BATT_CHR_SBATDET_MASK (1 << 5) -#define PMIC_BATT_CHR_SDCLMT_MASK (1 << 6) -#define PMIC_BATT_CHR_SUSBOVP_MASK (1 << 7) -#define PMIC_BATT_CHR_EXCPT_MASK 0xC6 -#define PMIC_BATT_ADC_ACCCHRG_MASK (1 << 31) -#define PMIC_BATT_ADC_ACCCHRGVAL_MASK 0x7FFFFFFF - -/* pmic ipc related */ -#define PMIC_BATT_CHR_IPC_FCHRG_SUBID 0x4 -#define PMIC_BATT_CHR_IPC_TCHRG_SUBID 0x6 - -/* types of battery charging */ -enum batt_charge_type { - BATT_USBOTG_500MA_CHARGE, - BATT_USBOTG_TRICKLE_CHARGE, -}; - -/* valid battery events */ -enum batt_event { - BATT_EVENT_BATOVP_EXCPT, - BATT_EVENT_USBOVP_EXCPT, - BATT_EVENT_TEMP_EXCPT, - BATT_EVENT_DCLMT_EXCPT, - BATT_EVENT_EXCPT -}; - - -/********************************************************************* - * Battery properties - *********************************************************************/ - -/* - * pmic battery info - */ -struct pmic_power_module_info { - bool is_dev_info_updated; - struct device *dev; - /* pmic battery data */ - unsigned long update_time; /* jiffies when data read */ - unsigned int usb_is_present; - unsigned int batt_is_present; - unsigned int batt_health; - unsigned int usb_health; - unsigned int batt_status; - unsigned int batt_charge_now; /* in mAS */ - unsigned int batt_prev_charge_full; /* in mAS */ - unsigned int batt_charge_rate; /* in units per second */ - - struct power_supply usb; - struct power_supply batt; - int irq; /* GPE_ID or IRQ# */ - struct workqueue_struct *monitor_wqueue; - struct delayed_work monitor_battery; - struct work_struct handler; -}; - -static unsigned int delay_time = 2000; /* in ms */ - -/* - * pmic ac properties - */ -static enum power_supply_property pmic_usb_props[] = { - POWER_SUPPLY_PROP_PRESENT, - POWER_SUPPLY_PROP_HEALTH, -}; - -/* - * pmic battery properties - */ -static enum power_supply_property pmic_battery_props[] = { - POWER_SUPPLY_PROP_STATUS, - POWER_SUPPLY_PROP_HEALTH, - POWER_SUPPLY_PROP_PRESENT, - POWER_SUPPLY_PROP_CHARGE_NOW, - POWER_SUPPLY_PROP_CHARGE_FULL, -}; - - -/* - * Glue functions for talking to the IPC - */ - -struct battery_property { - u32 capacity; /* Charger capacity */ - u8 crnt; /* Quick charge current value*/ - u8 volt; /* Fine adjustment of constant charge voltage */ - u8 prot; /* CHRGPROT register value */ - u8 prot2; /* CHRGPROT1 register value */ - u8 timer; /* Charging timer */ -}; - -#define IPCMSG_BATTERY 0xEF - -/* Battery coulomb counter accumulator commands */ -#define IPC_CMD_CC_WR 0 /* Update coulomb counter value */ -#define IPC_CMD_CC_RD 1 /* Read coulomb counter value */ -#define IPC_CMD_BATTERY_PROPERTY 2 /* Read Battery property */ - -/** - * pmic_scu_ipc_battery_cc_read - read battery cc - * @value: battery coulomb counter read - * - * Reads the battery couloumb counter value, returns 0 on success, or - * an error code - * - * This function may sleep. Locking for SCU accesses is handled for - * the caller. - */ -static int pmic_scu_ipc_battery_cc_read(u32 *value) -{ - return intel_scu_ipc_command(IPCMSG_BATTERY, IPC_CMD_CC_RD, - NULL, 0, value, 1); -} - -/** - * pmic_scu_ipc_battery_property_get - fetch properties - * @prop: battery properties - * - * Retrieve the battery properties from the power management - * - * This function may sleep. Locking for SCU accesses is handled for - * the caller. - */ -static int pmic_scu_ipc_battery_property_get(struct battery_property *prop) -{ - u32 data[3]; - u8 *p = (u8 *)&data[1]; - int err = intel_scu_ipc_command(IPC_CMD_BATTERY_PROPERTY, - IPCMSG_BATTERY, NULL, 0, data, 3); - - prop->capacity = data[0]; - prop->crnt = *p++; - prop->volt = *p++; - prop->prot = *p++; - prop->prot2 = *p++; - prop->timer = *p++; - - return err; -} - -/** - * pmic_scu_ipc_set_charger - set charger - * @charger: charger to select - * - * Switch the charging mode for the SCU - */ - -static int pmic_scu_ipc_set_charger(int charger) -{ - return intel_scu_ipc_simple_command(charger, IPCMSG_BATTERY); -} - -/** - * pmic_battery_log_event - log battery events - * @event: battery event to be logged - * Context: can sleep - * - * There are multiple battery events which may be of interest to users; - * this battery function logs the different battery events onto the - * kernel log messages. - */ -static void pmic_battery_log_event(enum batt_event event) -{ - printk(KERN_WARNING "pmic-battery: "); - switch (event) { - case BATT_EVENT_BATOVP_EXCPT: - printk(KERN_CONT "battery overvoltage condition\n"); - break; - case BATT_EVENT_USBOVP_EXCPT: - printk(KERN_CONT "usb charger overvoltage condition\n"); - break; - case BATT_EVENT_TEMP_EXCPT: - printk(KERN_CONT "high battery temperature condition\n"); - break; - case BATT_EVENT_DCLMT_EXCPT: - printk(KERN_CONT "over battery charge current condition\n"); - break; - default: - printk(KERN_CONT "charger/battery exception %d\n", event); - break; - } -} - -/** - * pmic_battery_read_status - read battery status information - * @pbi: device info structure to update the read information - * Context: can sleep - * - * PMIC power source information need to be updated based on the data read - * from the PMIC battery registers. - * - */ -static void pmic_battery_read_status(struct pmic_power_module_info *pbi) -{ - unsigned int update_time_intrvl; - unsigned int chrg_val; - u32 ccval; - u8 r8; - struct battery_property batt_prop; - int batt_present = 0; - int usb_present = 0; - int batt_exception = 0; - - /* make sure the last batt_status read happened delay_time before */ - if (pbi->update_time && time_before(jiffies, pbi->update_time + - msecs_to_jiffies(delay_time))) - return; - - update_time_intrvl = jiffies_to_msecs(jiffies - pbi->update_time); - pbi->update_time = jiffies; - - /* read coulomb counter registers and schrgint register */ - if (pmic_scu_ipc_battery_cc_read(&ccval)) { - dev_warn(pbi->dev, "%s(): ipc config cmd failed\n", - __func__); - return; - } - - if (intel_scu_ipc_ioread8(PMIC_BATT_CHR_SCHRGINT_ADDR, &r8)) { - dev_warn(pbi->dev, "%s(): ipc pmic read failed\n", - __func__); - return; - } - - /* - * set pmic_power_module_info members based on pmic register values - * read. - */ - - /* set batt_is_present */ - if (r8 & PMIC_BATT_CHR_SBATDET_MASK) { - pbi->batt_is_present = PMIC_BATT_PRESENT; - batt_present = 1; - } else { - pbi->batt_is_present = PMIC_BATT_NOT_PRESENT; - pbi->batt_health = POWER_SUPPLY_HEALTH_UNKNOWN; - pbi->batt_status = POWER_SUPPLY_STATUS_UNKNOWN; - } - - /* set batt_health */ - if (batt_present) { - if (r8 & PMIC_BATT_CHR_SBATOVP_MASK) { - pbi->batt_health = POWER_SUPPLY_HEALTH_OVERVOLTAGE; - pbi->batt_status = POWER_SUPPLY_STATUS_NOT_CHARGING; - pmic_battery_log_event(BATT_EVENT_BATOVP_EXCPT); - batt_exception = 1; - } else if (r8 & PMIC_BATT_CHR_SDCLMT_MASK) { - pbi->batt_health = POWER_SUPPLY_HEALTH_OVERVOLTAGE; - pbi->batt_status = POWER_SUPPLY_STATUS_NOT_CHARGING; - pmic_battery_log_event(BATT_EVENT_DCLMT_EXCPT); - batt_exception = 1; - } else if (r8 & PMIC_BATT_CHR_STEMP_MASK) { - pbi->batt_health = POWER_SUPPLY_HEALTH_OVERHEAT; - pbi->batt_status = POWER_SUPPLY_STATUS_NOT_CHARGING; - pmic_battery_log_event(BATT_EVENT_TEMP_EXCPT); - batt_exception = 1; - } else { - pbi->batt_health = POWER_SUPPLY_HEALTH_GOOD; - } - } - - /* set usb_is_present */ - if (r8 & PMIC_BATT_CHR_SUSBDET_MASK) { - pbi->usb_is_present = PMIC_USB_PRESENT; - usb_present = 1; - } else { - pbi->usb_is_present = PMIC_USB_NOT_PRESENT; - pbi->usb_health = POWER_SUPPLY_HEALTH_UNKNOWN; - } - - if (usb_present) { - if (r8 & PMIC_BATT_CHR_SUSBOVP_MASK) { - pbi->usb_health = POWER_SUPPLY_HEALTH_OVERVOLTAGE; - pmic_battery_log_event(BATT_EVENT_USBOVP_EXCPT); - } else { - pbi->usb_health = POWER_SUPPLY_HEALTH_GOOD; - } - } - - chrg_val = ccval & PMIC_BATT_ADC_ACCCHRGVAL_MASK; - - /* set batt_prev_charge_full to battery capacity the first time */ - if (!pbi->is_dev_info_updated) { - if (pmic_scu_ipc_battery_property_get(&batt_prop)) { - dev_warn(pbi->dev, "%s(): ipc config cmd failed\n", - __func__); - return; - } - pbi->batt_prev_charge_full = batt_prop.capacity; - } - - /* set batt_status */ - if (batt_present && !batt_exception) { - if (r8 & PMIC_BATT_CHR_SCOMP_MASK) { - pbi->batt_status = POWER_SUPPLY_STATUS_FULL; - pbi->batt_prev_charge_full = chrg_val; - } else if (ccval & PMIC_BATT_ADC_ACCCHRG_MASK) { - pbi->batt_status = POWER_SUPPLY_STATUS_DISCHARGING; - } else { - pbi->batt_status = POWER_SUPPLY_STATUS_CHARGING; - } - } - - /* set batt_charge_rate */ - if (pbi->is_dev_info_updated && batt_present && !batt_exception) { - if (pbi->batt_status == POWER_SUPPLY_STATUS_DISCHARGING) { - if (pbi->batt_charge_now - chrg_val) { - pbi->batt_charge_rate = ((pbi->batt_charge_now - - chrg_val) * 1000 * 60) / - update_time_intrvl; - } - } else if (pbi->batt_status == POWER_SUPPLY_STATUS_CHARGING) { - if (chrg_val - pbi->batt_charge_now) { - pbi->batt_charge_rate = ((chrg_val - - pbi->batt_charge_now) * 1000 * 60) / - update_time_intrvl; - } - } else - pbi->batt_charge_rate = 0; - } else { - pbi->batt_charge_rate = -1; - } - - /* batt_charge_now */ - if (batt_present && !batt_exception) - pbi->batt_charge_now = chrg_val; - else - pbi->batt_charge_now = -1; - - pbi->is_dev_info_updated = PMIC_BATT_DRV_INFO_UPDATED; -} - -/** - * pmic_usb_get_property - usb power source get property - * @psy: usb power supply context - * @psp: usb power source property - * @val: usb power source property value - * Context: can sleep - * - * PMIC usb power source property needs to be provided to power_supply - * subsytem for it to provide the information to users. - */ -static int pmic_usb_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - struct pmic_power_module_info *pbi = container_of(psy, - struct pmic_power_module_info, usb); - - /* update pmic_power_module_info members */ - pmic_battery_read_status(pbi); - - switch (psp) { - case POWER_SUPPLY_PROP_PRESENT: - val->intval = pbi->usb_is_present; - break; - case POWER_SUPPLY_PROP_HEALTH: - val->intval = pbi->usb_health; - break; - default: - return -EINVAL; - } - - return 0; -} - -static inline unsigned long mAStouAh(unsigned long v) -{ - /* seconds to hours, mA to µA */ - return (v * 1000) / 3600; -} - -/** - * pmic_battery_get_property - battery power source get property - * @psy: battery power supply context - * @psp: battery power source property - * @val: battery power source property value - * Context: can sleep - * - * PMIC battery power source property needs to be provided to power_supply - * subsytem for it to provide the information to users. - */ -static int pmic_battery_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - struct pmic_power_module_info *pbi = container_of(psy, - struct pmic_power_module_info, batt); - - /* update pmic_power_module_info members */ - pmic_battery_read_status(pbi); - - switch (psp) { - case POWER_SUPPLY_PROP_STATUS: - val->intval = pbi->batt_status; - break; - case POWER_SUPPLY_PROP_HEALTH: - val->intval = pbi->batt_health; - break; - case POWER_SUPPLY_PROP_PRESENT: - val->intval = pbi->batt_is_present; - break; - case POWER_SUPPLY_PROP_CHARGE_NOW: - val->intval = mAStouAh(pbi->batt_charge_now); - break; - case POWER_SUPPLY_PROP_CHARGE_FULL: - val->intval = mAStouAh(pbi->batt_prev_charge_full); - break; - default: - return -EINVAL; - } - - return 0; -} - -/** - * pmic_battery_monitor - monitor battery status - * @work: work structure - * Context: can sleep - * - * PMIC battery status needs to be monitored for any change - * and information needs to be frequently updated. - */ -static void pmic_battery_monitor(struct work_struct *work) -{ - struct pmic_power_module_info *pbi = container_of(work, - struct pmic_power_module_info, monitor_battery.work); - - /* update pmic_power_module_info members */ - pmic_battery_read_status(pbi); - queue_delayed_work(pbi->monitor_wqueue, &pbi->monitor_battery, HZ * 10); -} - -/** - * pmic_battery_set_charger - set battery charger - * @pbi: device info structure - * @chrg: charge mode to set battery charger in - * Context: can sleep - * - * PMIC battery charger needs to be enabled based on the usb charge - * capabilities connected to the platform. - */ -static int pmic_battery_set_charger(struct pmic_power_module_info *pbi, - enum batt_charge_type chrg) -{ - int retval; - - /* set usblmt bits and chrgcntl register bits appropriately */ - switch (chrg) { - case BATT_USBOTG_500MA_CHARGE: - retval = pmic_scu_ipc_set_charger(PMIC_BATT_CHR_IPC_FCHRG_SUBID); - break; - case BATT_USBOTG_TRICKLE_CHARGE: - retval = pmic_scu_ipc_set_charger(PMIC_BATT_CHR_IPC_TCHRG_SUBID); - break; - default: - dev_warn(pbi->dev, "%s(): out of range usb charger " - "charge detected\n", __func__); - return -EINVAL; - } - - if (retval) { - dev_warn(pbi->dev, "%s(): ipc pmic read failed\n", - __func__); - return retval;; - } - - return 0; -} - -/** - * pmic_battery_interrupt_handler - pmic battery interrupt handler - * Context: interrupt context - * - * PMIC battery interrupt handler which will be called with either - * battery full condition occurs or usb otg & battery connect - * condition occurs. - */ -static irqreturn_t pmic_battery_interrupt_handler(int id, void *dev) -{ - struct pmic_power_module_info *pbi = dev; - - schedule_work(&pbi->handler); - - return IRQ_HANDLED; -} - -/** - * pmic_battery_handle_intrpt - pmic battery service interrupt - * @work: work structure - * Context: can sleep - * - * PMIC battery needs to either update the battery status as full - * if it detects battery full condition caused the interrupt or needs - * to enable battery charger if it detects usb and battery detect - * caused the source of interrupt. - */ -static void pmic_battery_handle_intrpt(struct work_struct *work) -{ - struct pmic_power_module_info *pbi = container_of(work, - struct pmic_power_module_info, handler); - enum batt_charge_type chrg; - u8 r8; - - if (intel_scu_ipc_ioread8(PMIC_BATT_CHR_SCHRGINT_ADDR, &r8)) { - dev_warn(pbi->dev, "%s(): ipc pmic read failed\n", - __func__); - return; - } - /* find the cause of the interrupt */ - if (r8 & PMIC_BATT_CHR_SBATDET_MASK) { - pbi->batt_is_present = PMIC_BATT_PRESENT; - } else { - pbi->batt_is_present = PMIC_BATT_NOT_PRESENT; - pbi->batt_health = POWER_SUPPLY_HEALTH_UNKNOWN; - pbi->batt_status = POWER_SUPPLY_STATUS_UNKNOWN; - return; - } - - if (r8 & PMIC_BATT_CHR_EXCPT_MASK) { - pbi->batt_health = POWER_SUPPLY_HEALTH_UNKNOWN; - pbi->batt_status = POWER_SUPPLY_STATUS_NOT_CHARGING; - pbi->usb_health = POWER_SUPPLY_HEALTH_UNKNOWN; - pmic_battery_log_event(BATT_EVENT_EXCPT); - return; - } else { - pbi->batt_health = POWER_SUPPLY_HEALTH_GOOD; - pbi->usb_health = POWER_SUPPLY_HEALTH_GOOD; - } - - if (r8 & PMIC_BATT_CHR_SCOMP_MASK) { - u32 ccval; - pbi->batt_status = POWER_SUPPLY_STATUS_FULL; - - if (pmic_scu_ipc_battery_cc_read(&ccval)) { - dev_warn(pbi->dev, "%s(): ipc config cmd " - "failed\n", __func__); - return; - } - pbi->batt_prev_charge_full = ccval & - PMIC_BATT_ADC_ACCCHRGVAL_MASK; - return; - } - - if (r8 & PMIC_BATT_CHR_SUSBDET_MASK) { - pbi->usb_is_present = PMIC_USB_PRESENT; - } else { - pbi->usb_is_present = PMIC_USB_NOT_PRESENT; - pbi->usb_health = POWER_SUPPLY_HEALTH_UNKNOWN; - return; - } - - /* setup battery charging */ - -#if 0 - /* check usb otg power capability and set charger accordingly */ - retval = langwell_udc_maxpower(&power); - if (retval) { - dev_warn(pbi->dev, - "%s(): usb otg power query failed with error code %d\n", - __func__, retval); - return; - } - - if (power >= 500) - chrg = BATT_USBOTG_500MA_CHARGE; - else -#endif - chrg = BATT_USBOTG_TRICKLE_CHARGE; - - /* enable battery charging */ - if (pmic_battery_set_charger(pbi, chrg)) { - dev_warn(pbi->dev, - "%s(): failed to set up battery charging\n", __func__); - return; - } - - dev_dbg(pbi->dev, - "pmic-battery: %s() - setting up battery charger successful\n", - __func__); -} - -/** - * pmic_battery_probe - pmic battery initialize - * @irq: pmic battery device irq - * @dev: pmic battery device structure - * Context: can sleep - * - * PMIC battery initializes its internal data structue and other - * infrastructure components for it to work as expected. - */ -static __devinit int probe(int irq, struct device *dev) -{ - int retval = 0; - struct pmic_power_module_info *pbi; - - dev_dbg(dev, "pmic-battery: found pmic battery device\n"); - - pbi = kzalloc(sizeof(*pbi), GFP_KERNEL); - if (!pbi) { - dev_err(dev, "%s(): memory allocation failed\n", - __func__); - return -ENOMEM; - } - - pbi->dev = dev; - pbi->irq = irq; - dev_set_drvdata(dev, pbi); - - /* initialize all required framework before enabling interrupts */ - INIT_WORK(&pbi->handler, pmic_battery_handle_intrpt); - INIT_DELAYED_WORK(&pbi->monitor_battery, pmic_battery_monitor); - pbi->monitor_wqueue = - create_singlethread_workqueue(dev_name(dev)); - if (!pbi->monitor_wqueue) { - dev_err(dev, "%s(): wqueue init failed\n", __func__); - retval = -ESRCH; - goto wqueue_failed; - } - - /* register interrupt */ - retval = request_irq(pbi->irq, pmic_battery_interrupt_handler, - 0, DRIVER_NAME, pbi); - if (retval) { - dev_err(dev, "%s(): cannot get IRQ\n", __func__); - goto requestirq_failed; - } - - /* register pmic-batt with power supply subsystem */ - pbi->batt.name = "pmic-batt"; - pbi->batt.type = POWER_SUPPLY_TYPE_BATTERY; - pbi->batt.properties = pmic_battery_props; - pbi->batt.num_properties = ARRAY_SIZE(pmic_battery_props); - pbi->batt.get_property = pmic_battery_get_property; - retval = power_supply_register(dev, &pbi->batt); - if (retval) { - dev_err(dev, - "%s(): failed to register pmic battery device with power supply subsystem\n", - __func__); - goto power_reg_failed; - } - - dev_dbg(dev, "pmic-battery: %s() - pmic battery device " - "registration with power supply subsystem successful\n", - __func__); - - queue_delayed_work(pbi->monitor_wqueue, &pbi->monitor_battery, HZ * 1); - - /* register pmic-usb with power supply subsystem */ - pbi->usb.name = "pmic-usb"; - pbi->usb.type = POWER_SUPPLY_TYPE_USB; - pbi->usb.properties = pmic_usb_props; - pbi->usb.num_properties = ARRAY_SIZE(pmic_usb_props); - pbi->usb.get_property = pmic_usb_get_property; - retval = power_supply_register(dev, &pbi->usb); - if (retval) { - dev_err(dev, - "%s(): failed to register pmic usb device with power supply subsystem\n", - __func__); - goto power_reg_failed_1; - } - - if (debug) - printk(KERN_INFO "pmic-battery: %s() - pmic usb device " - "registration with power supply subsystem successful\n", - __func__); - - return retval; - -power_reg_failed_1: - power_supply_unregister(&pbi->batt); -power_reg_failed: - cancel_rearming_delayed_workqueue(pbi->monitor_wqueue, - &pbi->monitor_battery); -requestirq_failed: - destroy_workqueue(pbi->monitor_wqueue); -wqueue_failed: - kfree(pbi); - - return retval; -} - -static int __devinit platform_pmic_battery_probe(struct platform_device *pdev) -{ - return probe(pdev->id, &pdev->dev); -} - -/** - * pmic_battery_remove - pmic battery finalize - * @dev: pmic battery device structure - * Context: can sleep - * - * PMIC battery finalizes its internal data structue and other - * infrastructure components that it initialized in - * pmic_battery_probe. - */ - -static int __devexit platform_pmic_battery_remove(struct platform_device *pdev) -{ - struct pmic_power_module_info *pbi = dev_get_drvdata(&pdev->dev); - - free_irq(pbi->irq, pbi); - cancel_rearming_delayed_workqueue(pbi->monitor_wqueue, - &pbi->monitor_battery); - destroy_workqueue(pbi->monitor_wqueue); - - power_supply_unregister(&pbi->usb); - power_supply_unregister(&pbi->batt); - - flush_scheduled_work(); - kfree(pbi); - return 0; -} - -static struct platform_driver platform_pmic_battery_driver = { - .driver = { - .name = DRIVER_NAME, - .owner = THIS_MODULE, - }, - .probe = platform_pmic_battery_probe, - .remove = __devexit_p(platform_pmic_battery_remove), -}; - -static int __init platform_pmic_battery_module_init(void) -{ - return platform_driver_register(&platform_pmic_battery_driver); -} - -static void __exit platform_pmic_battery_module_exit(void) -{ - platform_driver_unregister(&platform_pmic_battery_driver); -} - -module_init(platform_pmic_battery_module_init); -module_exit(platform_pmic_battery_module_exit); - -MODULE_AUTHOR("Nithish Mahalingam "); -MODULE_DESCRIPTION("Intel Moorestown PMIC Battery Driver"); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/power/olpc_battery.c b/trunk/drivers/power/olpc_battery.c index aafc1c506eda..5ab9109b69e6 100644 --- a/trunk/drivers/power/olpc_battery.c +++ b/trunk/drivers/power/olpc_battery.c @@ -1,7 +1,7 @@ /* * Battery driver for One Laptop Per Child board. * - * Copyright © 2006-2010 David Woodhouse + * Copyright © 2006 David Woodhouse * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as diff --git a/trunk/drivers/power/s3c_adc_battery.c b/trunk/drivers/power/s3c_adc_battery.c deleted file mode 100644 index fe16b482e912..000000000000 --- a/trunk/drivers/power/s3c_adc_battery.c +++ /dev/null @@ -1,431 +0,0 @@ -/* - * iPAQ h1930/h1940/rx1950 battery controler driver - * Copyright (c) Vasily Khoruzhick - * Based on h1940_battery.c by Arnaud Patard - * - * 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. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define BAT_POLL_INTERVAL 10000 /* ms */ -#define JITTER_DELAY 500 /* ms */ - -struct s3c_adc_bat { - struct power_supply psy; - struct s3c_adc_client *client; - struct s3c_adc_bat_pdata *pdata; - int volt_value; - int cur_value; - unsigned int timestamp; - int level; - int status; - int cable_plugged:1; -}; - -static struct delayed_work bat_work; - -static void s3c_adc_bat_ext_power_changed(struct power_supply *psy) -{ - schedule_delayed_work(&bat_work, - msecs_to_jiffies(JITTER_DELAY)); -} - -static enum power_supply_property s3c_adc_backup_bat_props[] = { - POWER_SUPPLY_PROP_VOLTAGE_NOW, - POWER_SUPPLY_PROP_VOLTAGE_MIN, - POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, -}; - -static int s3c_adc_backup_bat_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - struct s3c_adc_bat *bat = container_of(psy, struct s3c_adc_bat, psy); - - if (!bat) { - dev_err(psy->dev, "%s: no battery infos ?!\n", __func__); - return -EINVAL; - } - - if (bat->volt_value < 0 || - jiffies_to_msecs(jiffies - bat->timestamp) > - BAT_POLL_INTERVAL) { - bat->volt_value = s3c_adc_read(bat->client, - bat->pdata->backup_volt_channel); - bat->volt_value *= bat->pdata->backup_volt_mult; - bat->timestamp = jiffies; - } - - switch (psp) { - case POWER_SUPPLY_PROP_VOLTAGE_NOW: - val->intval = bat->volt_value; - return 0; - case POWER_SUPPLY_PROP_VOLTAGE_MIN: - val->intval = bat->pdata->backup_volt_min; - return 0; - case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: - val->intval = bat->pdata->backup_volt_max; - return 0; - default: - return -EINVAL; - } -} - -static struct s3c_adc_bat backup_bat = { - .psy = { - .name = "backup-battery", - .type = POWER_SUPPLY_TYPE_BATTERY, - .properties = s3c_adc_backup_bat_props, - .num_properties = ARRAY_SIZE(s3c_adc_backup_bat_props), - .get_property = s3c_adc_backup_bat_get_property, - .use_for_apm = 1, - }, -}; - -static enum power_supply_property s3c_adc_main_bat_props[] = { - POWER_SUPPLY_PROP_STATUS, - POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, - POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN, - POWER_SUPPLY_PROP_CHARGE_NOW, - POWER_SUPPLY_PROP_VOLTAGE_NOW, - POWER_SUPPLY_PROP_CURRENT_NOW, -}; - -static int calc_full_volt(int volt_val, int cur_val, int impedance) -{ - return volt_val + cur_val * impedance / 1000; -} - -static int s3c_adc_bat_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - struct s3c_adc_bat *bat = container_of(psy, struct s3c_adc_bat, psy); - - int new_level; - int full_volt; - const struct s3c_adc_bat_thresh *lut = bat->pdata->lut_noac; - unsigned int lut_size = bat->pdata->lut_noac_cnt; - - if (!bat) { - dev_err(psy->dev, "no battery infos ?!\n"); - return -EINVAL; - } - - if (bat->volt_value < 0 || bat->cur_value < 0 || - jiffies_to_msecs(jiffies - bat->timestamp) > - BAT_POLL_INTERVAL) { - bat->volt_value = s3c_adc_read(bat->client, - bat->pdata->volt_channel) * bat->pdata->volt_mult; - bat->cur_value = s3c_adc_read(bat->client, - bat->pdata->current_channel) * bat->pdata->current_mult; - bat->timestamp = jiffies; - } - - if (bat->cable_plugged && - ((bat->pdata->gpio_charge_finished < 0) || - !gpio_get_value(bat->pdata->gpio_charge_finished))) { - lut = bat->pdata->lut_acin; - lut_size = bat->pdata->lut_acin_cnt; - } - - new_level = 100000; - full_volt = calc_full_volt((bat->volt_value / 1000), - (bat->cur_value / 1000), bat->pdata->internal_impedance); - - if (full_volt < calc_full_volt(lut->volt, lut->cur, - bat->pdata->internal_impedance)) { - lut_size--; - while (lut_size--) { - int lut_volt1; - int lut_volt2; - - lut_volt1 = calc_full_volt(lut[0].volt, lut[0].cur, - bat->pdata->internal_impedance); - lut_volt2 = calc_full_volt(lut[1].volt, lut[1].cur, - bat->pdata->internal_impedance); - if (full_volt < lut_volt1 && full_volt >= lut_volt2) { - new_level = (lut[1].level + - (lut[0].level - lut[1].level) * - (full_volt - lut_volt2) / - (lut_volt1 - lut_volt2)) * 1000; - break; - } - new_level = lut[1].level * 1000; - lut++; - } - } - - bat->level = new_level; - - switch (psp) { - case POWER_SUPPLY_PROP_STATUS: - if (bat->pdata->gpio_charge_finished < 0) - val->intval = bat->level == 100000 ? - POWER_SUPPLY_STATUS_FULL : bat->status; - else - val->intval = bat->status; - return 0; - case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: - val->intval = 100000; - return 0; - case POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN: - val->intval = 0; - return 0; - case POWER_SUPPLY_PROP_CHARGE_NOW: - val->intval = bat->level; - return 0; - case POWER_SUPPLY_PROP_VOLTAGE_NOW: - val->intval = bat->volt_value; - return 0; - case POWER_SUPPLY_PROP_CURRENT_NOW: - val->intval = bat->cur_value; - return 0; - default: - return -EINVAL; - } -} - -static struct s3c_adc_bat main_bat = { - .psy = { - .name = "main-battery", - .type = POWER_SUPPLY_TYPE_BATTERY, - .properties = s3c_adc_main_bat_props, - .num_properties = ARRAY_SIZE(s3c_adc_main_bat_props), - .get_property = s3c_adc_bat_get_property, - .external_power_changed = s3c_adc_bat_ext_power_changed, - .use_for_apm = 1, - }, -}; - -static void s3c_adc_bat_work(struct work_struct *work) -{ - struct s3c_adc_bat *bat = &main_bat; - int is_charged; - int is_plugged; - static int was_plugged; - - is_plugged = power_supply_am_i_supplied(&bat->psy); - bat->cable_plugged = is_plugged; - if (is_plugged != was_plugged) { - was_plugged = is_plugged; - if (is_plugged) { - if (bat->pdata->enable_charger) - bat->pdata->enable_charger(); - bat->status = POWER_SUPPLY_STATUS_CHARGING; - } else { - if (bat->pdata->disable_charger) - bat->pdata->disable_charger(); - bat->status = POWER_SUPPLY_STATUS_DISCHARGING; - } - } else { - if ((bat->pdata->gpio_charge_finished >= 0) && is_plugged) { - is_charged = gpio_get_value( - main_bat.pdata->gpio_charge_finished); - if (is_charged) { - if (bat->pdata->disable_charger) - bat->pdata->disable_charger(); - bat->status = POWER_SUPPLY_STATUS_FULL; - } else { - if (bat->pdata->enable_charger) - bat->pdata->enable_charger(); - bat->status = POWER_SUPPLY_STATUS_CHARGING; - } - } - } - - power_supply_changed(&bat->psy); -} - -static irqreturn_t s3c_adc_bat_charged(int irq, void *dev_id) -{ - schedule_delayed_work(&bat_work, - msecs_to_jiffies(JITTER_DELAY)); - return IRQ_HANDLED; -} - -static int __init s3c_adc_bat_probe(struct platform_device *pdev) -{ - struct s3c_adc_client *client; - struct s3c_adc_bat_pdata *pdata = pdev->dev.platform_data; - int ret; - - client = s3c_adc_register(pdev, NULL, NULL, 0); - if (IS_ERR(client)) { - dev_err(&pdev->dev, "cannot register adc\n"); - return PTR_ERR(client); - } - - platform_set_drvdata(pdev, client); - - main_bat.client = client; - main_bat.pdata = pdata; - main_bat.volt_value = -1; - main_bat.cur_value = -1; - main_bat.cable_plugged = 0; - main_bat.status = POWER_SUPPLY_STATUS_DISCHARGING; - - ret = power_supply_register(&pdev->dev, &main_bat.psy); - if (ret) - goto err_reg_main; - if (pdata->backup_volt_mult) { - backup_bat.client = client; - backup_bat.pdata = pdev->dev.platform_data; - backup_bat.volt_value = -1; - ret = power_supply_register(&pdev->dev, &backup_bat.psy); - if (ret) - goto err_reg_backup; - } - - INIT_DELAYED_WORK(&bat_work, s3c_adc_bat_work); - - if (pdata->gpio_charge_finished >= 0) { - ret = gpio_request(pdata->gpio_charge_finished, "charged"); - if (ret) - goto err_gpio; - - ret = request_irq(gpio_to_irq(pdata->gpio_charge_finished), - s3c_adc_bat_charged, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - "battery charged", NULL); - if (ret) - goto err_irq; - } - - if (pdata->init) { - ret = pdata->init(); - if (ret) - goto err_platform; - } - - dev_info(&pdev->dev, "successfully loaded\n"); - device_init_wakeup(&pdev->dev, 1); - - /* Schedule timer to check current status */ - schedule_delayed_work(&bat_work, - msecs_to_jiffies(JITTER_DELAY)); - - return 0; - -err_platform: - if (pdata->gpio_charge_finished >= 0) - free_irq(gpio_to_irq(pdata->gpio_charge_finished), NULL); -err_irq: - if (pdata->gpio_charge_finished >= 0) - gpio_free(pdata->gpio_charge_finished); -err_gpio: - if (pdata->backup_volt_mult) - power_supply_unregister(&backup_bat.psy); -err_reg_backup: - power_supply_unregister(&main_bat.psy); -err_reg_main: - return ret; -} - -static int s3c_adc_bat_remove(struct platform_device *pdev) -{ - struct s3c_adc_client *client = platform_get_drvdata(pdev); - struct s3c_adc_bat_pdata *pdata = pdev->dev.platform_data; - - power_supply_unregister(&main_bat.psy); - if (pdata->backup_volt_mult) - power_supply_unregister(&backup_bat.psy); - - s3c_adc_release(client); - - if (pdata->gpio_charge_finished >= 0) { - free_irq(gpio_to_irq(pdata->gpio_charge_finished), NULL); - gpio_free(pdata->gpio_charge_finished); - } - - cancel_delayed_work(&bat_work); - - if (pdata->exit) - pdata->exit(); - - return 0; -} - -#ifdef CONFIG_PM -static int s3c_adc_bat_suspend(struct platform_device *pdev, - pm_message_t state) -{ - struct s3c_adc_bat_pdata *pdata = pdev->dev.platform_data; - - if (pdata->gpio_charge_finished >= 0) { - if (device_may_wakeup(&pdev->dev)) - enable_irq_wake( - gpio_to_irq(pdata->gpio_charge_finished)); - else { - disable_irq(gpio_to_irq(pdata->gpio_charge_finished)); - main_bat.pdata->disable_charger(); - } - } - - return 0; -} - -static int s3c_adc_bat_resume(struct platform_device *pdev) -{ - struct s3c_adc_bat_pdata *pdata = pdev->dev.platform_data; - - if (pdata->gpio_charge_finished >= 0) { - if (device_may_wakeup(&pdev->dev)) - disable_irq_wake( - gpio_to_irq(pdata->gpio_charge_finished)); - else - enable_irq(gpio_to_irq(pdata->gpio_charge_finished)); - } - - /* Schedule timer to check current status */ - schedule_delayed_work(&bat_work, - msecs_to_jiffies(JITTER_DELAY)); - - return 0; -} -#else -#define s3c_adc_battery_suspend NULL -#define s3c_adc_battery_resume NULL -#endif - -static struct platform_driver s3c_adc_bat_driver = { - .driver = { - .name = "s3c-adc-battery", - }, - .probe = s3c_adc_bat_probe, - .remove = s3c_adc_bat_remove, - .suspend = s3c_adc_bat_suspend, - .resume = s3c_adc_bat_resume, -}; - -static int __init s3c_adc_bat_init(void) -{ - return platform_driver_register(&s3c_adc_bat_driver); -} -module_init(s3c_adc_bat_init); - -static void __exit s3c_adc_bat_exit(void) -{ - platform_driver_unregister(&s3c_adc_bat_driver); -} -module_exit(s3c_adc_bat_exit); - -MODULE_AUTHOR("Vasily Khoruzhick "); -MODULE_DESCRIPTION("iPAQ H1930/H1940/RX1950 battery controler driver"); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/regulator/Kconfig b/trunk/drivers/regulator/Kconfig index 172951bf23a4..04f2e085116a 100644 --- a/trunk/drivers/regulator/Kconfig +++ b/trunk/drivers/regulator/Kconfig @@ -100,14 +100,6 @@ config REGULATOR_MAX8925 help Say y here to support the voltage regulaltor of Maxim MAX8925 PMIC. -config REGULATOR_MAX8998 - tristate "Maxim 8998 voltage regulator" - depends on MFD_MAX8998 - help - This driver controls a Maxim 8998 voltage output regulator - via I2C bus. The provided regulator is suitable for S3C6410 - and S5PC1XX chips to control VCC_CORE and VCC_USIM voltages. - config REGULATOR_TWL4030 bool "TI TWL4030/TWL5030/TWL6030/TPS695x0 PMIC" depends on TWL4030_CORE @@ -209,31 +201,5 @@ config REGULATOR_88PM8607 help This driver supports 88PM8607 voltage regulator chips. -config REGULATOR_ISL6271A - tristate "Intersil ISL6271A Power regulator" - depends on I2C - help - This driver supports ISL6271A voltage regulator chip. - -config REGULATOR_AD5398 - tristate "Analog Devices AD5398/AD5821 regulators" - depends on I2C - help - This driver supports AD5398 and AD5821 current regulator chips. - If building into module, its name is ad5398.ko. - -config REGULATOR_AB8500 - bool "ST-Ericsson AB8500 Power Regulators" - depends on AB8500_CORE - help - This driver supports the regulators found on the ST-Ericsson mixed - signal AB8500 PMIC - -config REGULATOR_TPS6586X - tristate "TI TPS6586X Power regulators" - depends on MFD_TPS6586X - help - This driver supports TPS6586X voltage regulator chips. - endif diff --git a/trunk/drivers/regulator/Makefile b/trunk/drivers/regulator/Makefile index 8285fd832e16..4e7feece22d5 100644 --- a/trunk/drivers/regulator/Makefile +++ b/trunk/drivers/regulator/Makefile @@ -8,7 +8,6 @@ obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o -obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o obj-$(CONFIG_REGULATOR_DUMMY) += dummy.o obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o @@ -17,14 +16,12 @@ obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o -obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o -obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o obj-$(CONFIG_REGULATOR_DA903X) += da903x.o obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o @@ -34,7 +31,5 @@ obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o -obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o -obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG diff --git a/trunk/drivers/regulator/ab8500.c b/trunk/drivers/regulator/ab8500.c deleted file mode 100644 index dc3f1a491675..000000000000 --- a/trunk/drivers/regulator/ab8500.c +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2010 - * - * License Terms: GNU General Public License v2 - * - * Author: Sundar Iyer for ST-Ericsson - * - * AB8500 peripheral regulators - * - * AB8500 supports the following regulators, - * LDOs - VAUDIO, VANAMIC2/2, VDIGMIC, VINTCORE12, VTVOUT, - * VAUX1/2/3, VANA - * - * for DB8500 cut 1.0 and previous versions of the silicon, all accesses - * to registers are through the DB8500 SPI. In cut 1.1 onwards, these - * accesses are through the DB8500 PRCMU I2C - * - */ -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * struct ab8500_regulator_info - ab8500 regulator information - * @desc: regulator description - * @ab8500: ab8500 parent - * @regulator_dev: regulator device - * @max_uV: maximum voltage (for variable voltage supplies) - * @min_uV: minimum voltage (for variable voltage supplies) - * @fixed_uV: typical voltage (for fixed voltage supplies) - * @update_reg: register to control on/off - * @mask: mask to enable/disable regulator - * @enable: bits to enable the regulator in normal(high power) mode - * @voltage_reg: register to control regulator voltage - * @voltage_mask: mask to control regulator voltage - * @supported_voltages: supported voltage table - * @voltages_len: number of supported voltages for the regulator - */ -struct ab8500_regulator_info { - struct device *dev; - struct regulator_desc desc; - struct ab8500 *ab8500; - struct regulator_dev *regulator; - int max_uV; - int min_uV; - int fixed_uV; - int update_reg; - int mask; - int enable; - int voltage_reg; - int voltage_mask; - int const *supported_voltages; - int voltages_len; -}; - -/* voltage tables for the vauxn/vintcore supplies */ -static const int ldo_vauxn_voltages[] = { - 1100000, - 1200000, - 1300000, - 1400000, - 1500000, - 1800000, - 1850000, - 1900000, - 2500000, - 2650000, - 2700000, - 2750000, - 2800000, - 2900000, - 3000000, - 3300000, -}; - -static const int ldo_vintcore_voltages[] = { - 1200000, - 1225000, - 1250000, - 1275000, - 1300000, - 1325000, - 1350000, -}; - -static int ab8500_regulator_enable(struct regulator_dev *rdev) -{ - int regulator_id, ret; - struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); - - regulator_id = rdev_get_id(rdev); - if (regulator_id >= AB8500_NUM_REGULATORS) - return -EINVAL; - - ret = ab8500_set_bits(info->ab8500, info->update_reg, - info->mask, info->enable); - if (ret < 0) - dev_err(rdev_get_dev(rdev), - "couldn't set enable bits for regulator\n"); - return ret; -} - -static int ab8500_regulator_disable(struct regulator_dev *rdev) -{ - int regulator_id, ret; - struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); - - regulator_id = rdev_get_id(rdev); - if (regulator_id >= AB8500_NUM_REGULATORS) - return -EINVAL; - - ret = ab8500_set_bits(info->ab8500, info->update_reg, - info->mask, 0x0); - if (ret < 0) - dev_err(rdev_get_dev(rdev), - "couldn't set disable bits for regulator\n"); - return ret; -} - -static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) -{ - int regulator_id, ret; - struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); - - regulator_id = rdev_get_id(rdev); - if (regulator_id >= AB8500_NUM_REGULATORS) - return -EINVAL; - - ret = ab8500_read(info->ab8500, info->update_reg); - if (ret < 0) { - dev_err(rdev_get_dev(rdev), - "couldn't read 0x%x register\n", info->update_reg); - return ret; - } - - if (ret & info->mask) - return true; - else - return false; -} - -static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector) -{ - int regulator_id; - struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); - - regulator_id = rdev_get_id(rdev); - if (regulator_id >= AB8500_NUM_REGULATORS) - return -EINVAL; - - /* return the uV for the fixed regulators */ - if (info->fixed_uV) - return info->fixed_uV; - - if (selector > info->voltages_len) - return -EINVAL; - - return info->supported_voltages[selector]; -} - -static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) -{ - int regulator_id, ret, val; - struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); - - regulator_id = rdev_get_id(rdev); - if (regulator_id >= AB8500_NUM_REGULATORS) - return -EINVAL; - - ret = ab8500_read(info->ab8500, info->voltage_reg); - if (ret < 0) { - dev_err(rdev_get_dev(rdev), - "couldn't read voltage reg for regulator\n"); - return ret; - } - - /* vintcore has a different layout */ - val = ret & info->voltage_mask; - if (regulator_id == AB8500_LDO_INTCORE) - ret = info->supported_voltages[val >> 0x3]; - else - ret = info->supported_voltages[val]; - - return ret; -} - -static int ab8500_get_best_voltage_index(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); - int i; - - /* check the supported voltage */ - for (i = 0; i < info->voltages_len; i++) { - if ((info->supported_voltages[i] >= min_uV) && - (info->supported_voltages[i] <= max_uV)) - return i; - } - - return -EINVAL; -} - -static int ab8500_regulator_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - int regulator_id, ret; - struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); - - regulator_id = rdev_get_id(rdev); - if (regulator_id >= AB8500_NUM_REGULATORS) - return -EINVAL; - - /* get the appropriate voltages within the range */ - ret = ab8500_get_best_voltage_index(rdev, min_uV, max_uV); - if (ret < 0) { - dev_err(rdev_get_dev(rdev), - "couldn't get best voltage for regulator\n"); - return ret; - } - - /* set the registers for the request */ - ret = ab8500_set_bits(info->ab8500, info->voltage_reg, - info->voltage_mask, ret); - if (ret < 0) - dev_err(rdev_get_dev(rdev), - "couldn't set voltage reg for regulator\n"); - - return ret; -} - -static struct regulator_ops ab8500_regulator_ops = { - .enable = ab8500_regulator_enable, - .disable = ab8500_regulator_disable, - .is_enabled = ab8500_regulator_is_enabled, - .get_voltage = ab8500_regulator_get_voltage, - .set_voltage = ab8500_regulator_set_voltage, - .list_voltage = ab8500_list_voltage, -}; - -static int ab8500_fixed_get_voltage(struct regulator_dev *rdev) -{ - int regulator_id; - struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); - - regulator_id = rdev_get_id(rdev); - if (regulator_id >= AB8500_NUM_REGULATORS) - return -EINVAL; - - return info->fixed_uV; -} - -static struct regulator_ops ab8500_ldo_fixed_ops = { - .enable = ab8500_regulator_enable, - .disable = ab8500_regulator_disable, - .is_enabled = ab8500_regulator_is_enabled, - .get_voltage = ab8500_fixed_get_voltage, - .list_voltage = ab8500_list_voltage, -}; - -#define AB8500_LDO(_id, min, max, reg, reg_mask, reg_enable, \ - volt_reg, volt_mask, voltages, \ - len_volts) \ -{ \ - .desc = { \ - .name = "LDO-" #_id, \ - .ops = &ab8500_regulator_ops, \ - .type = REGULATOR_VOLTAGE, \ - .id = AB8500_LDO_##_id, \ - .owner = THIS_MODULE, \ - }, \ - .min_uV = (min) * 1000, \ - .max_uV = (max) * 1000, \ - .update_reg = reg, \ - .mask = reg_mask, \ - .enable = reg_enable, \ - .voltage_reg = volt_reg, \ - .voltage_mask = volt_mask, \ - .supported_voltages = voltages, \ - .voltages_len = len_volts, \ - .fixed_uV = 0, \ -} - -#define AB8500_FIXED_LDO(_id, fixed, reg, reg_mask, \ - reg_enable) \ -{ \ - .desc = { \ - .name = "LDO-" #_id, \ - .ops = &ab8500_ldo_fixed_ops, \ - .type = REGULATOR_VOLTAGE, \ - .id = AB8500_LDO_##_id, \ - .owner = THIS_MODULE, \ - }, \ - .fixed_uV = fixed * 1000, \ - .update_reg = reg, \ - .mask = reg_mask, \ - .enable = reg_enable, \ -} - -static struct ab8500_regulator_info ab8500_regulator_info[] = { - /* - * Variable Voltage LDOs - * name, min uV, max uV, ctrl reg, reg mask, enable mask, - * volt ctrl reg, volt ctrl mask, volt table, num supported volts - */ - AB8500_LDO(AUX1, 1100, 3300, 0x0409, 0x3, 0x1, 0x041f, 0xf, - ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), - AB8500_LDO(AUX2, 1100, 3300, 0x0409, 0xc, 0x4, 0x0420, 0xf, - ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), - AB8500_LDO(AUX3, 1100, 3300, 0x040a, 0x3, 0x1, 0x0421, 0xf, - ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)), - AB8500_LDO(INTCORE, 1100, 3300, 0x0380, 0x4, 0x4, 0x0380, 0x38, - ldo_vintcore_voltages, ARRAY_SIZE(ldo_vintcore_voltages)), - - /* - * Fixed Voltage LDOs - * name, o/p uV, ctrl reg, enable, disable - */ - AB8500_FIXED_LDO(TVOUT, 2000, 0x0380, 0x2, 0x2), - AB8500_FIXED_LDO(AUDIO, 2000, 0x0383, 0x2, 0x2), - AB8500_FIXED_LDO(ANAMIC1, 2050, 0x0383, 0x4, 0x4), - AB8500_FIXED_LDO(ANAMIC2, 2050, 0x0383, 0x8, 0x8), - AB8500_FIXED_LDO(DMIC, 1800, 0x0383, 0x10, 0x10), - AB8500_FIXED_LDO(ANA, 1200, 0x0383, 0xc, 0x4), -}; - -static inline struct ab8500_regulator_info *find_regulator_info(int id) -{ - struct ab8500_regulator_info *info; - int i; - - for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { - info = &ab8500_regulator_info[i]; - if (info->desc.id == id) - return info; - } - return NULL; -} - -static __devinit int ab8500_regulator_probe(struct platform_device *pdev) -{ - struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); - struct ab8500_platform_data *pdata = dev_get_platdata(ab8500->dev); - int i, err; - - if (!ab8500) { - dev_err(&pdev->dev, "null mfd parent\n"); - return -EINVAL; - } - - /* register all regulators */ - for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { - struct ab8500_regulator_info *info = NULL; - - /* assign per-regulator data */ - info = &ab8500_regulator_info[i]; - info->dev = &pdev->dev; - info->ab8500 = ab8500; - - info->regulator = regulator_register(&info->desc, &pdev->dev, - pdata->regulator[i], info); - if (IS_ERR(info->regulator)) { - err = PTR_ERR(info->regulator); - dev_err(&pdev->dev, "failed to register regulator %s\n", - info->desc.name); - /* when we fail, un-register all earlier regulators */ - i--; - while (i > 0) { - info = &ab8500_regulator_info[i]; - regulator_unregister(info->regulator); - i--; - } - return err; - } - } - - return 0; -} - -static __devexit int ab8500_regulator_remove(struct platform_device *pdev) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { - struct ab8500_regulator_info *info = NULL; - info = &ab8500_regulator_info[i]; - regulator_unregister(info->regulator); - } - - return 0; -} - -static struct platform_driver ab8500_regulator_driver = { - .probe = ab8500_regulator_probe, - .remove = __devexit_p(ab8500_regulator_remove), - .driver = { - .name = "ab8500-regulator", - .owner = THIS_MODULE, - }, -}; - -static int __init ab8500_regulator_init(void) -{ - int ret; - - ret = platform_driver_register(&ab8500_regulator_driver); - if (ret != 0) - pr_err("Failed to register ab8500 regulator: %d\n", ret); - - return ret; -} -subsys_initcall(ab8500_regulator_init); - -static void __exit ab8500_regulator_exit(void) -{ - platform_driver_unregister(&ab8500_regulator_driver); -} -module_exit(ab8500_regulator_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Sundar Iyer "); -MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC"); -MODULE_ALIAS("platform:ab8500-regulator"); diff --git a/trunk/drivers/regulator/ad5398.c b/trunk/drivers/regulator/ad5398.c deleted file mode 100644 index d59d2f2314af..000000000000 --- a/trunk/drivers/regulator/ad5398.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Voltage and current regulation for AD5398 and AD5821 - * - * Copyright 2010 Analog Devices Inc. - * - * Enter bugs at http://blackfin.uclinux.org/ - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define AD5398_CURRENT_EN_MASK 0x8000 - -struct ad5398_chip_info { - struct i2c_client *client; - int min_uA; - int max_uA; - unsigned int current_level; - unsigned int current_mask; - unsigned int current_offset; - struct regulator_dev rdev; -}; - -static int ad5398_calc_current(struct ad5398_chip_info *chip, - unsigned selector) -{ - unsigned range_uA = chip->max_uA - chip->min_uA; - - return chip->min_uA + (selector * range_uA / chip->current_level); -} - -static int ad5398_read_reg(struct i2c_client *client, unsigned short *data) -{ - unsigned short val; - int ret; - - ret = i2c_master_recv(client, (char *)&val, 2); - if (ret < 0) { - dev_err(&client->dev, "I2C read error\n"); - return ret; - } - *data = be16_to_cpu(val); - - return ret; -} - -static int ad5398_write_reg(struct i2c_client *client, const unsigned short data) -{ - unsigned short val; - int ret; - - val = cpu_to_be16(data); - ret = i2c_master_send(client, (char *)&val, 2); - if (ret < 0) - dev_err(&client->dev, "I2C write error\n"); - - return ret; -} - -static int ad5398_get_current_limit(struct regulator_dev *rdev) -{ - struct ad5398_chip_info *chip = rdev_get_drvdata(rdev); - struct i2c_client *client = chip->client; - unsigned short data; - int ret; - - ret = ad5398_read_reg(client, &data); - if (ret < 0) - return ret; - - ret = (data & chip->current_mask) >> chip->current_offset; - - return ad5398_calc_current(chip, ret); -} - -static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int max_uA) -{ - struct ad5398_chip_info *chip = rdev_get_drvdata(rdev); - struct i2c_client *client = chip->client; - unsigned range_uA = chip->max_uA - chip->min_uA; - unsigned selector; - unsigned short data; - int ret; - - if (min_uA > chip->max_uA || min_uA < chip->min_uA) - return -EINVAL; - if (max_uA > chip->max_uA || max_uA < chip->min_uA) - return -EINVAL; - - selector = ((min_uA - chip->min_uA) * chip->current_level + - range_uA - 1) / range_uA; - if (ad5398_calc_current(chip, selector) > max_uA) - return -EINVAL; - - dev_dbg(&client->dev, "changing current %dmA\n", - ad5398_calc_current(chip, selector) / 1000); - - /* read chip enable bit */ - ret = ad5398_read_reg(client, &data); - if (ret < 0) - return ret; - - /* prepare register data */ - selector = (selector << chip->current_offset) & chip->current_mask; - data = (unsigned short)selector | (data & AD5398_CURRENT_EN_MASK); - - /* write the new current value back as well as enable bit */ - ret = ad5398_write_reg(client, data); - - return ret; -} - -static int ad5398_is_enabled(struct regulator_dev *rdev) -{ - struct ad5398_chip_info *chip = rdev_get_drvdata(rdev); - struct i2c_client *client = chip->client; - unsigned short data; - int ret; - - ret = ad5398_read_reg(client, &data); - if (ret < 0) - return ret; - - if (data & AD5398_CURRENT_EN_MASK) - return 1; - else - return 0; -} - -static int ad5398_enable(struct regulator_dev *rdev) -{ - struct ad5398_chip_info *chip = rdev_get_drvdata(rdev); - struct i2c_client *client = chip->client; - unsigned short data; - int ret; - - ret = ad5398_read_reg(client, &data); - if (ret < 0) - return ret; - - if (data & AD5398_CURRENT_EN_MASK) - return 0; - - data |= AD5398_CURRENT_EN_MASK; - - ret = ad5398_write_reg(client, data); - - return ret; -} - -static int ad5398_disable(struct regulator_dev *rdev) -{ - struct ad5398_chip_info *chip = rdev_get_drvdata(rdev); - struct i2c_client *client = chip->client; - unsigned short data; - int ret; - - ret = ad5398_read_reg(client, &data); - if (ret < 0) - return ret; - - if (!(data & AD5398_CURRENT_EN_MASK)) - return 0; - - data &= ~AD5398_CURRENT_EN_MASK; - - ret = ad5398_write_reg(client, data); - - return ret; -} - -static struct regulator_ops ad5398_ops = { - .get_current_limit = ad5398_get_current_limit, - .set_current_limit = ad5398_set_current_limit, - .enable = ad5398_enable, - .disable = ad5398_disable, - .is_enabled = ad5398_is_enabled, -}; - -static struct regulator_desc ad5398_reg = { - .name = "isink", - .id = 0, - .ops = &ad5398_ops, - .type = REGULATOR_CURRENT, - .owner = THIS_MODULE, -}; - -struct ad5398_current_data_format { - int current_bits; - int current_offset; - int min_uA; - int max_uA; -}; - -static const struct ad5398_current_data_format df_10_4_120 = {10, 4, 0, 120000}; - -static const struct i2c_device_id ad5398_id[] = { - { "ad5398", (kernel_ulong_t)&df_10_4_120 }, - { "ad5821", (kernel_ulong_t)&df_10_4_120 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, ad5398_id); - -static int __devinit ad5398_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct regulator_dev *rdev; - struct regulator_init_data *init_data = client->dev.platform_data; - struct ad5398_chip_info *chip; - const struct ad5398_current_data_format *df = - (struct ad5398_current_data_format *)id->driver_data; - int ret; - - if (!init_data) - return -EINVAL; - - chip = kzalloc(sizeof(*chip), GFP_KERNEL); - if (!chip) - return -ENOMEM; - - chip->client = client; - - chip->min_uA = df->min_uA; - chip->max_uA = df->max_uA; - chip->current_level = 1 << df->current_bits; - chip->current_offset = df->current_offset; - chip->current_mask = (chip->current_level - 1) << chip->current_offset; - - rdev = regulator_register(&ad5398_reg, &client->dev, init_data, chip); - if (IS_ERR(rdev)) { - ret = PTR_ERR(rdev); - dev_err(&client->dev, "failed to register %s %s\n", - id->name, ad5398_reg.name); - goto err; - } - - i2c_set_clientdata(client, chip); - dev_dbg(&client->dev, "%s regulator driver is registered.\n", id->name); - return 0; - -err: - kfree(chip); - return ret; -} - -static int __devexit ad5398_remove(struct i2c_client *client) -{ - struct ad5398_chip_info *chip = i2c_get_clientdata(client); - - regulator_unregister(&chip->rdev); - kfree(chip); - i2c_set_clientdata(client, NULL); - - return 0; -} - -static struct i2c_driver ad5398_driver = { - .probe = ad5398_probe, - .remove = __devexit_p(ad5398_remove), - .driver = { - .name = "ad5398", - }, - .id_table = ad5398_id, -}; - -static int __init ad5398_init(void) -{ - return i2c_add_driver(&ad5398_driver); -} -subsys_initcall(ad5398_init); - -static void __exit ad5398_exit(void) -{ - i2c_del_driver(&ad5398_driver); -} -module_exit(ad5398_exit); - -MODULE_DESCRIPTION("AD5398 and AD5821 current regulator driver"); -MODULE_AUTHOR("Sonic Zhang"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("i2c:ad5398-regulator"); diff --git a/trunk/drivers/regulator/isl6271a-regulator.c b/trunk/drivers/regulator/isl6271a-regulator.c deleted file mode 100644 index e49d2bd393f2..000000000000 --- a/trunk/drivers/regulator/isl6271a-regulator.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * isl6271a-regulator.c - * - * Support for Intersil ISL6271A voltage regulator - * - * Copyright (C) 2010 Marek Vasut - * - * 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 version 2. - * - * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, - * whether express or implied; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define ISL6271A_VOLTAGE_MIN 850000 -#define ISL6271A_VOLTAGE_MAX 1600000 -#define ISL6271A_VOLTAGE_STEP 50000 - -/* PMIC details */ -struct isl_pmic { - struct i2c_client *client; - struct regulator_dev *rdev[3]; - struct mutex mtx; -}; - -static int isl6271a_get_voltage(struct regulator_dev *dev) -{ - struct isl_pmic *pmic = rdev_get_drvdata(dev); - int idx, data; - - mutex_lock(&pmic->mtx); - - idx = i2c_smbus_read_byte(pmic->client); - if (idx < 0) { - dev_err(&pmic->client->dev, "Error getting voltage\n"); - data = idx; - goto out; - } - - /* Convert the data from chip to microvolts */ - data = ISL6271A_VOLTAGE_MIN + (ISL6271A_VOLTAGE_STEP * (idx & 0xf)); - -out: - mutex_unlock(&pmic->mtx); - return data; -} - -static int isl6271a_set_voltage(struct regulator_dev *dev, int minuV, int maxuV) -{ - struct isl_pmic *pmic = rdev_get_drvdata(dev); - int vsel, err, data; - - if (minuV < ISL6271A_VOLTAGE_MIN || minuV > ISL6271A_VOLTAGE_MAX) - return -EINVAL; - if (maxuV < ISL6271A_VOLTAGE_MIN || maxuV > ISL6271A_VOLTAGE_MAX) - return -EINVAL; - - /* Align to 50000 mV */ - vsel = minuV - (minuV % ISL6271A_VOLTAGE_STEP); - - /* If the result fell out of [minuV,maxuV] range, put it back */ - if (vsel < minuV) - vsel += ISL6271A_VOLTAGE_STEP; - - /* Convert the microvolts to data for the chip */ - data = (vsel - ISL6271A_VOLTAGE_MIN) / ISL6271A_VOLTAGE_STEP; - - mutex_lock(&pmic->mtx); - - err = i2c_smbus_write_byte(pmic->client, data); - if (err < 0) - dev_err(&pmic->client->dev, "Error setting voltage\n"); - - mutex_unlock(&pmic->mtx); - return err; -} - -static int isl6271a_list_voltage(struct regulator_dev *dev, unsigned selector) -{ - return ISL6271A_VOLTAGE_MIN + (ISL6271A_VOLTAGE_STEP * selector); -} - -static struct regulator_ops isl_core_ops = { - .get_voltage = isl6271a_get_voltage, - .set_voltage = isl6271a_set_voltage, - .list_voltage = isl6271a_list_voltage, -}; - -static int isl6271a_get_fixed_voltage(struct regulator_dev *dev) -{ - int id = rdev_get_id(dev); - return (id == 1) ? 1100000 : 1300000; -} - -static int isl6271a_list_fixed_voltage(struct regulator_dev *dev, unsigned selector) -{ - int id = rdev_get_id(dev); - return (id == 1) ? 1100000 : 1300000; -} - -static struct regulator_ops isl_fixed_ops = { - .get_voltage = isl6271a_get_fixed_voltage, - .list_voltage = isl6271a_list_fixed_voltage, -}; - -static struct regulator_desc isl_rd[] = { - { - .name = "Core Buck", - .id = 0, - .n_voltages = 16, - .ops = &isl_core_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO1", - .id = 1, - .n_voltages = 1, - .ops = &isl_fixed_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO2", - .id = 2, - .n_voltages = 1, - .ops = &isl_fixed_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, -}; - -static int __devinit isl6271a_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - struct regulator_init_data *init_data = i2c->dev.platform_data; - struct isl_pmic *pmic; - int err, i; - - if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) - return -EIO; - - if (!init_data) { - dev_err(&i2c->dev, "no platform data supplied\n"); - return -EIO; - } - - pmic = kzalloc(sizeof(struct isl_pmic), GFP_KERNEL); - if (!pmic) - return -ENOMEM; - - pmic->client = i2c; - - mutex_init(&pmic->mtx); - - for (i = 0; i < 3; i++) { - pmic->rdev[i] = regulator_register(&isl_rd[0], &i2c->dev, - init_data, pmic); - if (IS_ERR(pmic->rdev[i])) { - dev_err(&i2c->dev, "failed to register %s\n", id->name); - err = PTR_ERR(pmic->rdev); - goto error; - } - } - - i2c_set_clientdata(i2c, pmic); - - return 0; - -error: - while (--i >= 0) - regulator_unregister(pmic->rdev[i]); - - kfree(pmic); - return err; -} - -static int __devexit isl6271a_remove(struct i2c_client *i2c) -{ - struct isl_pmic *pmic = i2c_get_clientdata(i2c); - int i; - - i2c_set_clientdata(i2c, NULL); - - for (i = 0; i < 3; i++) - regulator_unregister(pmic->rdev[i]); - - kfree(pmic); - - return 0; -} - -static const struct i2c_device_id isl6271a_id[] = { - {.name = "isl6271a", 0 }, - { }, -}; - -MODULE_DEVICE_TABLE(i2c, isl6271a_id); - -static struct i2c_driver isl6271a_i2c_driver = { - .driver = { - .name = "isl6271a", - .owner = THIS_MODULE, - }, - .probe = isl6271a_probe, - .remove = __devexit_p(isl6271a_remove), - .id_table = isl6271a_id, -}; - -static int __init isl6271a_init(void) -{ - return i2c_add_driver(&isl6271a_i2c_driver); -} - -static void __exit isl6271a_cleanup(void) -{ - i2c_del_driver(&isl6271a_i2c_driver); -} - -subsys_initcall(isl6271a_init); -module_exit(isl6271a_cleanup); - -MODULE_AUTHOR("Marek Vasut "); -MODULE_DESCRIPTION("Intersil ISL6271A voltage regulator driver"); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/regulator/lp3971.c b/trunk/drivers/regulator/lp3971.c index 3bb82b624e19..8ae3732eb24b 100644 --- a/trunk/drivers/regulator/lp3971.c +++ b/trunk/drivers/regulator/lp3971.c @@ -377,7 +377,7 @@ static int lp3971_i2c_read(struct i2c_client *i2c, char reg, int count, if (count != 1) return -EIO; ret = i2c_smbus_read_byte_data(i2c, reg); - if (ret < 0) + if (ret < 0 || count != 1) return -EIO; *dest = ret; @@ -387,9 +387,15 @@ static int lp3971_i2c_read(struct i2c_client *i2c, char reg, int count, static int lp3971_i2c_write(struct i2c_client *i2c, char reg, int count, const u16 *src) { + int ret; + if (count != 1) return -EIO; - return i2c_smbus_write_byte_data(i2c, reg, *src); + ret = i2c_smbus_write_byte_data(i2c, reg, *src); + if (ret >= 0) + return 0; + + return ret; } static u8 lp3971_reg_read(struct lp3971 *lp3971, u8 reg) diff --git a/trunk/drivers/regulator/max1586.c b/trunk/drivers/regulator/max1586.c index 8867c2710a6d..2b54d9d75f11 100644 --- a/trunk/drivers/regulator/max1586.c +++ b/trunk/drivers/regulator/max1586.c @@ -223,7 +223,7 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client, } } - i2c_set_clientdata(client, max1586); + i2c_set_clientdata(client, rdev); dev_info(&client->dev, "Maxim 1586 regulator driver loaded\n"); return 0; @@ -238,13 +238,13 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client, static int __devexit max1586_pmic_remove(struct i2c_client *client) { - struct max1586_data *max1586 = i2c_get_clientdata(client); + struct regulator_dev **rdev = i2c_get_clientdata(client); int i; for (i = 0; i <= MAX1586_V6; i++) - if (max1586->rdev[i]) - regulator_unregister(max1586->rdev[i]); - kfree(max1586); + if (rdev[i]) + regulator_unregister(rdev[i]); + kfree(rdev); return 0; } diff --git a/trunk/drivers/regulator/max8660.c b/trunk/drivers/regulator/max8660.c index c570e6eb0db2..d97220efae5a 100644 --- a/trunk/drivers/regulator/max8660.c +++ b/trunk/drivers/regulator/max8660.c @@ -450,7 +450,7 @@ static int __devinit max8660_probe(struct i2c_client *client, } } - i2c_set_clientdata(client, max8660); + i2c_set_clientdata(client, rdev); dev_info(&client->dev, "Maxim 8660/8661 regulator driver loaded\n"); return 0; @@ -465,13 +465,13 @@ static int __devinit max8660_probe(struct i2c_client *client, static int __devexit max8660_remove(struct i2c_client *client) { - struct max8660 *max8660 = i2c_get_clientdata(client); + struct regulator_dev **rdev = i2c_get_clientdata(client); int i; for (i = 0; i < MAX8660_V_END; i++) - if (max8660->rdev[i]) - regulator_unregister(max8660->rdev[i]); - kfree(max8660); + if (rdev[i]) + regulator_unregister(rdev[i]); + kfree(rdev); return 0; } diff --git a/trunk/drivers/regulator/max8998.c b/trunk/drivers/regulator/max8998.c deleted file mode 100644 index ab67298799f9..000000000000 --- a/trunk/drivers/regulator/max8998.c +++ /dev/null @@ -1,635 +0,0 @@ -/* - * max8998.c - Voltage regulator driver for the Maxim 8998 - * - * Copyright (C) 2009-2010 Samsung Electronics - * Kyungmin Park - * Marek Szyprowski - * - * 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 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct max8998_data { - struct device *dev; - struct max8998_dev *iodev; - int num_regulators; - struct regulator_dev **rdev; -}; - -struct voltage_map_desc { - int min; - int max; - int step; -}; - -/* Voltage maps */ -static const struct voltage_map_desc ldo23_voltage_map_desc = { - .min = 800, .step = 50, .max = 1300, -}; -static const struct voltage_map_desc ldo456711_voltage_map_desc = { - .min = 1600, .step = 100, .max = 3600, -}; -static const struct voltage_map_desc ldo8_voltage_map_desc = { - .min = 3000, .step = 100, .max = 3600, -}; -static const struct voltage_map_desc ldo9_voltage_map_desc = { - .min = 2800, .step = 100, .max = 3100, -}; -static const struct voltage_map_desc ldo10_voltage_map_desc = { - .min = 950, .step = 50, .max = 1300, -}; -static const struct voltage_map_desc ldo1213_voltage_map_desc = { - .min = 800, .step = 100, .max = 3300, -}; -static const struct voltage_map_desc ldo1415_voltage_map_desc = { - .min = 1200, .step = 100, .max = 3300, -}; -static const struct voltage_map_desc ldo1617_voltage_map_desc = { - .min = 1600, .step = 100, .max = 3600, -}; -static const struct voltage_map_desc buck12_voltage_map_desc = { - .min = 750, .step = 25, .max = 1525, -}; -static const struct voltage_map_desc buck3_voltage_map_desc = { - .min = 1600, .step = 100, .max = 3600, -}; -static const struct voltage_map_desc buck4_voltage_map_desc = { - .min = 800, .step = 100, .max = 2300, -}; - -static const struct voltage_map_desc *ldo_voltage_map[] = { - NULL, - NULL, - &ldo23_voltage_map_desc, /* LDO2 */ - &ldo23_voltage_map_desc, /* LDO3 */ - &ldo456711_voltage_map_desc, /* LDO4 */ - &ldo456711_voltage_map_desc, /* LDO5 */ - &ldo456711_voltage_map_desc, /* LDO6 */ - &ldo456711_voltage_map_desc, /* LDO7 */ - &ldo8_voltage_map_desc, /* LDO8 */ - &ldo9_voltage_map_desc, /* LDO9 */ - &ldo10_voltage_map_desc, /* LDO10 */ - &ldo456711_voltage_map_desc, /* LDO11 */ - &ldo1213_voltage_map_desc, /* LDO12 */ - &ldo1213_voltage_map_desc, /* LDO13 */ - &ldo1415_voltage_map_desc, /* LDO14 */ - &ldo1415_voltage_map_desc, /* LDO15 */ - &ldo1617_voltage_map_desc, /* LDO16 */ - &ldo1617_voltage_map_desc, /* LDO17 */ - &buck12_voltage_map_desc, /* BUCK1 */ - &buck12_voltage_map_desc, /* BUCK2 */ - &buck3_voltage_map_desc, /* BUCK3 */ - &buck4_voltage_map_desc, /* BUCK4 */ -}; - -static inline int max8998_get_ldo(struct regulator_dev *rdev) -{ - return rdev_get_id(rdev); -} - -static int max8998_list_voltage(struct regulator_dev *rdev, - unsigned int selector) -{ - const struct voltage_map_desc *desc; - int ldo = max8998_get_ldo(rdev); - int val; - - if (ldo >= ARRAY_SIZE(ldo_voltage_map)) - return -EINVAL; - - desc = ldo_voltage_map[ldo]; - if (desc == NULL) - return -EINVAL; - - val = desc->min + desc->step * selector; - if (val > desc->max) - return -EINVAL; - - return val * 1000; -} - -static int max8998_get_enable_register(struct regulator_dev *rdev, - int *reg, int *shift) -{ - int ldo = max8998_get_ldo(rdev); - - switch (ldo) { - case MAX8998_LDO2 ... MAX8998_LDO5: - *reg = MAX8998_REG_ONOFF1; - *shift = 3 - (ldo - MAX8998_LDO2); - break; - case MAX8998_LDO6 ... MAX8998_LDO13: - *reg = MAX8998_REG_ONOFF2; - *shift = 7 - (ldo - MAX8998_LDO6); - break; - case MAX8998_LDO14 ... MAX8998_LDO17: - *reg = MAX8998_REG_ONOFF3; - *shift = 7 - (ldo - MAX8998_LDO14); - break; - case MAX8998_BUCK1 ... MAX8998_BUCK4: - *reg = MAX8998_REG_ONOFF1; - *shift = 7 - (ldo - MAX8998_BUCK1); - break; - case MAX8998_EN32KHZ_AP ... MAX8998_ENVICHG: - *reg = MAX8998_REG_ONOFF4; - *shift = 7 - (ldo - MAX8998_EN32KHZ_AP); - break; - case MAX8998_ESAFEOUT1 ... MAX8998_ESAFEOUT2: - *reg = MAX8998_REG_CHGR2; - *shift = 7 - (ldo - MAX8998_ESAFEOUT1); - break; - default: - return -EINVAL; - } - - return 0; -} - -static int max8998_ldo_is_enabled(struct regulator_dev *rdev) -{ - struct max8998_data *max8998 = rdev_get_drvdata(rdev); - int ret, reg, shift = 8; - u8 val; - - ret = max8998_get_enable_register(rdev, ®, &shift); - if (ret) - return ret; - - ret = max8998_read_reg(max8998->iodev, reg, &val); - if (ret) - return ret; - - return val & (1 << shift); -} - -static int max8998_ldo_enable(struct regulator_dev *rdev) -{ - struct max8998_data *max8998 = rdev_get_drvdata(rdev); - int reg, shift = 8, ret; - - ret = max8998_get_enable_register(rdev, ®, &shift); - if (ret) - return ret; - - return max8998_update_reg(max8998->iodev, reg, 1<iodev, reg, 0, 1<iodev, reg, &val); - if (ret) - return ret; - - val >>= shift; - val &= mask; - - return max8998_list_voltage(rdev, val); -} - -static int max8998_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - struct max8998_data *max8998 = rdev_get_drvdata(rdev); - int min_vol = min_uV / 1000, max_vol = max_uV / 1000; - int previous_vol = 0; - const struct voltage_map_desc *desc; - int ldo = max8998_get_ldo(rdev); - int reg, shift = 0, mask, ret; - int i = 0; - u8 val; - bool en_ramp = false; - - if (ldo >= ARRAY_SIZE(ldo_voltage_map)) - return -EINVAL; - - desc = ldo_voltage_map[ldo]; - if (desc == NULL) - return -EINVAL; - - if (max_vol < desc->min || min_vol > desc->max) - return -EINVAL; - - while (desc->min + desc->step*i < min_vol && - desc->min + desc->step*i < desc->max) - i++; - - if (desc->min + desc->step*i > max_vol) - return -EINVAL; - - ret = max8998_get_voltage_register(rdev, ®, &shift, &mask); - if (ret) - return ret; - - /* wait for RAMP_UP_DELAY if rdev is BUCK1/2 and - * ENRAMP is ON */ - if (ldo == MAX8998_BUCK1 || ldo == MAX8998_BUCK2) { - max8998_read_reg(max8998->iodev, MAX8998_REG_ONOFF4, &val); - if (val & (1 << 4)) { - en_ramp = true; - previous_vol = max8998_get_voltage(rdev); - } - } - - ret = max8998_update_reg(max8998->iodev, reg, i<min + desc->step*i - previous_vol/1000; - if (difference > 0) - udelay(difference / ((val & 0x0f) + 1)); - } - - return ret; -} - -static struct regulator_ops max8998_ldo_ops = { - .list_voltage = max8998_list_voltage, - .is_enabled = max8998_ldo_is_enabled, - .enable = max8998_ldo_enable, - .disable = max8998_ldo_disable, - .get_voltage = max8998_get_voltage, - .set_voltage = max8998_set_voltage, - .set_suspend_enable = max8998_ldo_enable, - .set_suspend_disable = max8998_ldo_disable, -}; - -static struct regulator_ops max8998_buck_ops = { - .list_voltage = max8998_list_voltage, - .is_enabled = max8998_ldo_is_enabled, - .enable = max8998_ldo_enable, - .disable = max8998_ldo_disable, - .get_voltage = max8998_get_voltage, - .set_voltage = max8998_set_voltage, - .set_suspend_enable = max8998_ldo_enable, - .set_suspend_disable = max8998_ldo_disable, -}; - -static struct regulator_ops max8998_others_ops = { - .is_enabled = max8998_ldo_is_enabled, - .enable = max8998_ldo_enable, - .disable = max8998_ldo_disable, - .set_suspend_enable = max8998_ldo_enable, - .set_suspend_disable = max8998_ldo_disable, -}; - -static struct regulator_desc regulators[] = { - { - .name = "LDO2", - .id = MAX8998_LDO2, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO3", - .id = MAX8998_LDO3, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO4", - .id = MAX8998_LDO4, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO5", - .id = MAX8998_LDO5, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO6", - .id = MAX8998_LDO6, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO7", - .id = MAX8998_LDO7, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO8", - .id = MAX8998_LDO8, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO9", - .id = MAX8998_LDO9, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO10", - .id = MAX8998_LDO10, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO11", - .id = MAX8998_LDO11, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO12", - .id = MAX8998_LDO12, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO13", - .id = MAX8998_LDO13, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO14", - .id = MAX8998_LDO14, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO15", - .id = MAX8998_LDO15, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO16", - .id = MAX8998_LDO16, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "LDO17", - .id = MAX8998_LDO17, - .ops = &max8998_ldo_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "BUCK1", - .id = MAX8998_BUCK1, - .ops = &max8998_buck_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "BUCK2", - .id = MAX8998_BUCK2, - .ops = &max8998_buck_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "BUCK3", - .id = MAX8998_BUCK3, - .ops = &max8998_buck_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "BUCK4", - .id = MAX8998_BUCK4, - .ops = &max8998_buck_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "EN32KHz AP", - .id = MAX8998_EN32KHZ_AP, - .ops = &max8998_others_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "EN32KHz CP", - .id = MAX8998_EN32KHZ_CP, - .ops = &max8998_others_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "ENVICHG", - .id = MAX8998_ENVICHG, - .ops = &max8998_others_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "ESAFEOUT1", - .id = MAX8998_ESAFEOUT1, - .ops = &max8998_others_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - }, { - .name = "ESAFEOUT2", - .id = MAX8998_ESAFEOUT2, - .ops = &max8998_others_ops, - .type = REGULATOR_VOLTAGE, - .owner = THIS_MODULE, - } -}; - -static __devinit int max8998_pmic_probe(struct platform_device *pdev) -{ - struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct max8998_platform_data *pdata = dev_get_platdata(iodev->dev); - struct regulator_dev **rdev; - struct max8998_data *max8998; - int i, ret, size; - - if (!pdata) { - dev_err(pdev->dev.parent, "No platform init data supplied\n"); - return -ENODEV; - } - - max8998 = kzalloc(sizeof(struct max8998_data), GFP_KERNEL); - if (!max8998) - return -ENOMEM; - - size = sizeof(struct regulator_dev *) * (pdata->num_regulators + 1); - max8998->rdev = kzalloc(size, GFP_KERNEL); - if (!max8998->rdev) { - kfree(max8998); - return -ENOMEM; - } - - rdev = max8998->rdev; - max8998->iodev = iodev; - platform_set_drvdata(pdev, max8998); - - for (i = 0; i < pdata->num_regulators; i++) { - const struct voltage_map_desc *desc; - int id = pdata->regulators[i].id; - int index = id - MAX8998_LDO2; - - desc = ldo_voltage_map[id]; - if (desc && regulators[index].ops != &max8998_others_ops) { - int count = (desc->max - desc->min) / desc->step + 1; - regulators[index].n_voltages = count; - } - rdev[i] = regulator_register(®ulators[index], max8998->dev, - pdata->regulators[i].initdata, max8998); - if (IS_ERR(rdev[i])) { - ret = PTR_ERR(rdev[i]); - dev_err(max8998->dev, "regulator init failed\n"); - rdev[i] = NULL; - goto err; - } - } - - - return 0; -err: - for (i = 0; i <= max8998->num_regulators; i++) - if (rdev[i]) - regulator_unregister(rdev[i]); - - kfree(max8998->rdev); - kfree(max8998); - - return ret; -} - -static int __devexit max8998_pmic_remove(struct platform_device *pdev) -{ - struct max8998_data *max8998 = platform_get_drvdata(pdev); - struct regulator_dev **rdev = max8998->rdev; - int i; - - for (i = 0; i <= max8998->num_regulators; i++) - if (rdev[i]) - regulator_unregister(rdev[i]); - - kfree(max8998->rdev); - kfree(max8998); - - return 0; -} - -static struct platform_driver max8998_pmic_driver = { - .driver = { - .name = "max8998-pmic", - .owner = THIS_MODULE, - }, - .probe = max8998_pmic_probe, - .remove = __devexit_p(max8998_pmic_remove), -}; - -static int __init max8998_pmic_init(void) -{ - return platform_driver_register(&max8998_pmic_driver); -} -subsys_initcall(max8998_pmic_init); - -static void __exit max8998_pmic_cleanup(void) -{ - platform_driver_unregister(&max8998_pmic_driver); -} -module_exit(max8998_pmic_cleanup); - -MODULE_DESCRIPTION("MAXIM 8998 voltage regulator driver"); -MODULE_AUTHOR("Kyungmin Park "); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/regulator/tps65023-regulator.c b/trunk/drivers/regulator/tps65023-regulator.c index cd6d4fc9d74f..f50afc9f287a 100644 --- a/trunk/drivers/regulator/tps65023-regulator.c +++ b/trunk/drivers/regulator/tps65023-regulator.c @@ -585,8 +585,6 @@ static const struct tps_info tps65023_regs[] = { static const struct i2c_device_id tps_65023_id[] = { {.name = "tps65023", .driver_data = (unsigned long) tps65023_regs,}, - {.name = "tps65021", - .driver_data = (unsigned long) tps65023_regs,}, { }, }; diff --git a/trunk/drivers/regulator/tps6507x-regulator.c b/trunk/drivers/regulator/tps6507x-regulator.c index c239f42aa4a3..8152d65220f5 100644 --- a/trunk/drivers/regulator/tps6507x-regulator.c +++ b/trunk/drivers/regulator/tps6507x-regulator.c @@ -614,7 +614,6 @@ int tps6507x_pmic_probe(struct platform_device *pdev) } tps6507x_dev->pmic = tps; - platform_set_drvdata(pdev, tps6507x_dev); return 0; diff --git a/trunk/drivers/regulator/tps6586x-regulator.c b/trunk/drivers/regulator/tps6586x-regulator.c deleted file mode 100644 index 8cff1413a147..000000000000 --- a/trunk/drivers/regulator/tps6586x-regulator.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Regulator driver for TI TPS6586x - * - * Copyright (C) 2010 Compulab Ltd. - * Author: Mike Rapoport - * - * Based on da903x - * Copyright (C) 2006-2008 Marvell International Ltd. - * Copyright (C) 2008 Compulab Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* supply control and voltage setting */ -#define TPS6586X_SUPPLYENA 0x10 -#define TPS6586X_SUPPLYENB 0x11 -#define TPS6586X_SUPPLYENC 0x12 -#define TPS6586X_SUPPLYEND 0x13 -#define TPS6586X_SUPPLYENE 0x14 -#define TPS6586X_VCC1 0x20 -#define TPS6586X_VCC2 0x21 -#define TPS6586X_SM1V1 0x23 -#define TPS6586X_SM1V2 0x24 -#define TPS6586X_SM1SL 0x25 -#define TPS6586X_SM0V1 0x26 -#define TPS6586X_SM0V2 0x27 -#define TPS6586X_SM0SL 0x28 -#define TPS6586X_LDO2AV1 0x29 -#define TPS6586X_LDO2AV2 0x2A -#define TPS6586X_LDO2BV1 0x2F -#define TPS6586X_LDO2BV2 0x30 -#define TPS6586X_LDO4V1 0x32 -#define TPS6586X_LDO4V2 0x33 - -/* converter settings */ -#define TPS6586X_SUPPLYV1 0x41 -#define TPS6586X_SUPPLYV2 0x42 -#define TPS6586X_SUPPLYV3 0x43 -#define TPS6586X_SUPPLYV4 0x44 -#define TPS6586X_SUPPLYV5 0x45 -#define TPS6586X_SUPPLYV6 0x46 -#define TPS6586X_SMODE1 0x47 -#define TPS6586X_SMODE2 0x48 - -struct tps6586x_regulator { - struct regulator_desc desc; - - int volt_reg; - int volt_shift; - int volt_nbits; - int enable_bit[2]; - int enable_reg[2]; - - int *voltages; - - /* for DVM regulators */ - int go_reg; - int go_bit; -}; - -static inline struct device *to_tps6586x_dev(struct regulator_dev *rdev) -{ - return rdev_get_dev(rdev)->parent->parent; -} - -static int tps6586x_ldo_list_voltage(struct regulator_dev *rdev, - unsigned selector) -{ - struct tps6586x_regulator *info = rdev_get_drvdata(rdev); - - return info->voltages[selector] * 1000; -} - - -static int __tps6586x_ldo_set_voltage(struct device *parent, - struct tps6586x_regulator *ri, - int min_uV, int max_uV) -{ - int val, uV; - uint8_t mask; - - for (val = 0; val < ri->desc.n_voltages; val++) { - uV = ri->voltages[val] * 1000; - - /* LDO0 has minimal voltage 1.2 rather than 1.25 */ - if (ri->desc.id == TPS6586X_ID_LDO_0 && val == 0) - uV -= 50 * 1000; - - /* use the first in-range value */ - if (min_uV <= uV && uV <= max_uV) { - - val <<= ri->volt_shift; - mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift; - - return tps6586x_update(parent, ri->volt_reg, val, mask); - } - } - - return -EINVAL; -} - -static int tps6586x_ldo_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps6586x_dev(rdev); - - return __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV); -} - -static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev) -{ - struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps6586x_dev(rdev); - uint8_t val, mask; - int ret; - - ret = tps6586x_read(parent, ri->volt_reg, &val); - if (ret) - return ret; - - mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift; - val = (val & mask) >> ri->volt_shift; - - if (val > ri->desc.n_voltages) - BUG(); - - return ri->voltages[val] * 1000; -} - -static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps6586x_dev(rdev); - int ret; - - ret = __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV); - if (ret) - return ret; - - return tps6586x_set_bits(parent, ri->go_reg, ri->go_bit); -} - -static int tps6586x_regulator_enable(struct regulator_dev *rdev) -{ - struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps6586x_dev(rdev); - - return tps6586x_set_bits(parent, ri->enable_reg[0], - 1 << ri->enable_bit[0]); -} - -static int tps6586x_regulator_disable(struct regulator_dev *rdev) -{ - struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps6586x_dev(rdev); - - return tps6586x_clr_bits(parent, ri->enable_reg[0], - 1 << ri->enable_bit[0]); -} - -static int tps6586x_regulator_is_enabled(struct regulator_dev *rdev) -{ - struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); - struct device *parent = to_tps6586x_dev(rdev); - uint8_t reg_val; - int ret; - - ret = tps6586x_read(parent, ri->enable_reg[0], ®_val); - if (ret) - return ret; - - return !!(reg_val & (1 << ri->enable_bit[0])); -} - -static struct regulator_ops tps6586x_regulator_ldo_ops = { - .list_voltage = tps6586x_ldo_list_voltage, - .get_voltage = tps6586x_ldo_get_voltage, - .set_voltage = tps6586x_ldo_set_voltage, - - .is_enabled = tps6586x_regulator_is_enabled, - .enable = tps6586x_regulator_enable, - .disable = tps6586x_regulator_disable, -}; - -static struct regulator_ops tps6586x_regulator_dvm_ops = { - .list_voltage = tps6586x_ldo_list_voltage, - .get_voltage = tps6586x_ldo_get_voltage, - .set_voltage = tps6586x_dvm_set_voltage, - - .is_enabled = tps6586x_regulator_is_enabled, - .enable = tps6586x_regulator_enable, - .disable = tps6586x_regulator_disable, -}; - -static int tps6586x_ldo_voltages[] = { - 1250, 1500, 1800, 2500, 2700, 2850, 3100, 3300, -}; - -static int tps6586x_ldo4_voltages[] = { - 1700, 1725, 1750, 1775, 1800, 1825, 1850, 1875, - 1900, 1925, 1950, 1975, 2000, 2025, 2050, 2075, - 2100, 2125, 2150, 2175, 2200, 2225, 2250, 2275, - 2300, 2325, 2350, 2375, 2400, 2425, 2450, 2475, -}; - -static int tps6586x_sm2_voltages[] = { - 3000, 3050, 3100, 3150, 3200, 3250, 3300, 3350, - 3400, 3450, 3500, 3550, 3600, 3650, 3700, 3750, - 3800, 3850, 3900, 3950, 4000, 4050, 4100, 4150, - 4200, 4250, 4300, 4350, 4400, 4450, 4500, 4550, -}; - -static int tps6586x_dvm_voltages[] = { - 725, 750, 775, 800, 825, 850, 875, 900, - 925, 950, 975, 1000, 1025, 1050, 1075, 1100, - 1125, 1150, 1175, 1200, 1225, 1250, 1275, 1300, - 1325, 1350, 1375, 1400, 1425, 1450, 1475, 1500, -}; - -#define TPS6586X_REGULATOR(_id, vdata, _ops, vreg, shift, nbits, \ - ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ -{ \ - .desc = { \ - .name = "REG-" #_id, \ - .ops = &tps6586x_regulator_##_ops, \ - .type = REGULATOR_VOLTAGE, \ - .id = TPS6586X_ID_##_id, \ - .n_voltages = ARRAY_SIZE(tps6586x_##vdata##_voltages), \ - .owner = THIS_MODULE, \ - }, \ - .volt_reg = TPS6586X_##vreg, \ - .volt_shift = (shift), \ - .volt_nbits = (nbits), \ - .enable_reg[0] = TPS6586X_SUPPLY##ereg0, \ - .enable_bit[0] = (ebit0), \ - .enable_reg[1] = TPS6586X_SUPPLY##ereg1, \ - .enable_bit[1] = (ebit1), \ - .voltages = tps6586x_##vdata##_voltages, \ -} - -#define TPS6586X_LDO(_id, vdata, vreg, shift, nbits, \ - ereg0, ebit0, ereg1, ebit1) \ - TPS6586X_REGULATOR(_id, vdata, ldo_ops, vreg, shift, nbits, \ - ereg0, ebit0, ereg1, ebit1, 0, 0) - -#define TPS6586X_DVM(_id, vdata, vreg, shift, nbits, \ - ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ - TPS6586X_REGULATOR(_id, vdata, dvm_ops, vreg, shift, nbits, \ - ereg0, ebit0, ereg1, ebit1, goreg, gobit) - -static struct tps6586x_regulator tps6586x_regulator[] = { - TPS6586X_LDO(LDO_0, ldo, SUPPLYV1, 5, 3, ENC, 0, END, 0), - TPS6586X_LDO(LDO_3, ldo, SUPPLYV4, 0, 3, ENC, 2, END, 2), - TPS6586X_LDO(LDO_5, ldo, SUPPLYV6, 0, 3, ENE, 6, ENE, 6), - TPS6586X_LDO(LDO_6, ldo, SUPPLYV3, 0, 3, ENC, 4, END, 4), - TPS6586X_LDO(LDO_7, ldo, SUPPLYV3, 3, 3, ENC, 5, END, 5), - TPS6586X_LDO(LDO_8, ldo, SUPPLYV1, 5, 3, ENC, 6, END, 6), - TPS6586X_LDO(LDO_9, ldo, SUPPLYV6, 3, 3, ENE, 7, ENE, 7), - TPS6586X_LDO(LDO_RTC, ldo, SUPPLYV4, 3, 3, ENE, 7, ENE, 7), - TPS6586X_LDO(LDO_1, dvm, SUPPLYV1, 0, 5, ENC, 1, END, 1), - TPS6586X_LDO(SM_2, sm2, SUPPLYV2, 0, 5, ENC, 1, END, 1), - - TPS6586X_DVM(LDO_2, dvm, LDO2BV1, 0, 5, ENA, 3, ENB, 3, VCC2, 6), - TPS6586X_DVM(LDO_4, ldo4, LDO4V1, 0, 5, ENC, 3, END, 3, VCC1, 6), - TPS6586X_DVM(SM_0, dvm, SM0V1, 0, 5, ENA, 1, ENB, 1, VCC1, 2), - TPS6586X_DVM(SM_1, dvm, SM1V1, 0, 5, ENA, 0, ENB, 0, VCC1, 0), -}; - -/* - * TPS6586X has 2 enable bits that are OR'ed to determine the actual - * regulator state. Clearing one of this bits allows switching - * regulator on and of with single register write. - */ -static inline int tps6586x_regulator_preinit(struct device *parent, - struct tps6586x_regulator *ri) -{ - uint8_t val1, val2; - int ret; - - ret = tps6586x_read(parent, ri->enable_reg[0], &val1); - if (ret) - return ret; - - ret = tps6586x_read(parent, ri->enable_reg[1], &val2); - if (ret) - return ret; - - if (!(val2 & ri->enable_bit[1])) - return 0; - - /* - * The regulator is on, but it's enabled with the bit we don't - * want to use, so we switch the enable bits - */ - if (!(val1 & ri->enable_bit[0])) { - ret = tps6586x_set_bits(parent, ri->enable_reg[0], - 1 << ri->enable_bit[0]); - if (ret) - return ret; - } - - return tps6586x_clr_bits(parent, ri->enable_reg[1], - 1 << ri->enable_bit[1]); -} - -static inline struct tps6586x_regulator *find_regulator_info(int id) -{ - struct tps6586x_regulator *ri; - int i; - - for (i = 0; i < ARRAY_SIZE(tps6586x_regulator); i++) { - ri = &tps6586x_regulator[i]; - if (ri->desc.id == id) - return ri; - } - return NULL; -} - -static int __devinit tps6586x_regulator_probe(struct platform_device *pdev) -{ - struct tps6586x_regulator *ri = NULL; - struct regulator_dev *rdev; - int id = pdev->id; - int err; - - dev_dbg(&pdev->dev, "Probing reulator %d\n", id); - - ri = find_regulator_info(id); - if (ri == NULL) { - dev_err(&pdev->dev, "invalid regulator ID specified\n"); - return -EINVAL; - } - - err = tps6586x_regulator_preinit(pdev->dev.parent, ri); - if (err) - return err; - - rdev = regulator_register(&ri->desc, &pdev->dev, - pdev->dev.platform_data, ri); - if (IS_ERR(rdev)) { - dev_err(&pdev->dev, "failed to register regulator %s\n", - ri->desc.name); - return PTR_ERR(rdev); - } - - platform_set_drvdata(pdev, rdev); - - return 0; -} - -static int __devexit tps6586x_regulator_remove(struct platform_device *pdev) -{ - struct regulator_dev *rdev = platform_get_drvdata(pdev); - - regulator_unregister(rdev); - return 0; -} - -static struct platform_driver tps6586x_regulator_driver = { - .driver = { - .name = "tps6586x-regulator", - .owner = THIS_MODULE, - }, - .probe = tps6586x_regulator_probe, - .remove = __devexit_p(tps6586x_regulator_remove), -}; - -static int __init tps6586x_regulator_init(void) -{ - return platform_driver_register(&tps6586x_regulator_driver); -} -subsys_initcall(tps6586x_regulator_init); - -static void __exit tps6586x_regulator_exit(void) -{ - platform_driver_unregister(&tps6586x_regulator_driver); -} -module_exit(tps6586x_regulator_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Mike Rapoport "); -MODULE_DESCRIPTION("Regulator Driver for TI TPS6586X PMIC"); -MODULE_ALIAS("platform:tps6586x-regulator"); diff --git a/trunk/drivers/regulator/wm8994-regulator.c b/trunk/drivers/regulator/wm8994-regulator.c index 03713bc66e4a..5a1dc8a24d35 100644 --- a/trunk/drivers/regulator/wm8994-regulator.c +++ b/trunk/drivers/regulator/wm8994-regulator.c @@ -219,6 +219,8 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev) ldo->wm8994 = wm8994; + ldo->is_enabled = true; + if (pdata->ldo[id].enable && gpio_is_valid(pdata->ldo[id].enable)) { ldo->enable = pdata->ldo[id].enable; @@ -235,8 +237,7 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev) ret); goto err_gpio; } - } else - ldo->is_enabled = true; + } ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &pdev->dev, pdata->ldo[id].init_data, ldo); diff --git a/trunk/drivers/rtc/rtc-mpc5121.c b/trunk/drivers/rtc/rtc-mpc5121.c index dfcdf0901d21..db5d8c416d26 100644 --- a/trunk/drivers/rtc/rtc-mpc5121.c +++ b/trunk/drivers/rtc/rtc-mpc5121.c @@ -268,7 +268,7 @@ static const struct rtc_class_ops mpc5121_rtc_ops = { .update_irq_enable = mpc5121_rtc_update_irq_enable, }; -static int __devinit mpc5121_rtc_probe(struct platform_device *op, +static int __devinit mpc5121_rtc_probe(struct of_device *op, const struct of_device_id *match) { struct mpc5121_rtc_data *rtc; @@ -338,7 +338,7 @@ static int __devinit mpc5121_rtc_probe(struct platform_device *op, return err; } -static int __devexit mpc5121_rtc_remove(struct platform_device *op) +static int __devexit mpc5121_rtc_remove(struct of_device *op) { struct mpc5121_rtc_data *rtc = dev_get_drvdata(&op->dev); struct mpc5121_rtc_regs __iomem *regs = rtc->regs; diff --git a/trunk/drivers/sbus/char/bbc_envctrl.c b/trunk/drivers/sbus/char/bbc_envctrl.c index 160e7510aca6..103fdf6b0b89 100644 --- a/trunk/drivers/sbus/char/bbc_envctrl.c +++ b/trunk/drivers/sbus/char/bbc_envctrl.c @@ -443,7 +443,7 @@ static int kenvctrld(void *__unused) return 0; } -static void attach_one_temp(struct bbc_i2c_bus *bp, struct platform_device *op, +static void attach_one_temp(struct bbc_i2c_bus *bp, struct of_device *op, int temp_idx) { struct bbc_cpu_temperature *tp; @@ -488,7 +488,7 @@ static void attach_one_temp(struct bbc_i2c_bus *bp, struct platform_device *op, tp->fan_todo[FAN_CPU] = FAN_SAME; } -static void attach_one_fan(struct bbc_i2c_bus *bp, struct platform_device *op, +static void attach_one_fan(struct bbc_i2c_bus *bp, struct of_device *op, int fan_idx) { struct bbc_fan_control *fp; @@ -559,7 +559,7 @@ static void destroy_all_fans(struct bbc_i2c_bus *bp) int bbc_envctrl_init(struct bbc_i2c_bus *bp) { - struct platform_device *op; + struct of_device *op; int temp_index = 0; int fan_index = 0; int devidx = 0; diff --git a/trunk/drivers/sbus/char/bbc_i2c.c b/trunk/drivers/sbus/char/bbc_i2c.c index 614a5e114a19..3e89c313e98d 100644 --- a/trunk/drivers/sbus/char/bbc_i2c.c +++ b/trunk/drivers/sbus/char/bbc_i2c.c @@ -51,7 +51,7 @@ * The second controller also connects to the smartcard reader, if present. */ -static void set_device_claimage(struct bbc_i2c_bus *bp, struct platform_device *op, int val) +static void set_device_claimage(struct bbc_i2c_bus *bp, struct of_device *op, int val) { int i; @@ -66,9 +66,9 @@ static void set_device_claimage(struct bbc_i2c_bus *bp, struct platform_device * #define claim_device(BP,ECHILD) set_device_claimage(BP,ECHILD,1) #define release_device(BP,ECHILD) set_device_claimage(BP,ECHILD,0) -struct platform_device *bbc_i2c_getdev(struct bbc_i2c_bus *bp, int index) +struct of_device *bbc_i2c_getdev(struct bbc_i2c_bus *bp, int index) { - struct platform_device *op = NULL; + struct of_device *op = NULL; int curidx = 0, i; for (i = 0; i < NUM_CHILDREN; i++) { @@ -86,7 +86,7 @@ struct platform_device *bbc_i2c_getdev(struct bbc_i2c_bus *bp, int index) return NULL; } -struct bbc_i2c_client *bbc_i2c_attach(struct bbc_i2c_bus *bp, struct platform_device *op) +struct bbc_i2c_client *bbc_i2c_attach(struct bbc_i2c_bus *bp, struct of_device *op) { struct bbc_i2c_client *client; const u32 *reg; @@ -114,7 +114,7 @@ struct bbc_i2c_client *bbc_i2c_attach(struct bbc_i2c_bus *bp, struct platform_de void bbc_i2c_detach(struct bbc_i2c_client *client) { struct bbc_i2c_bus *bp = client->bp; - struct platform_device *op = client->op; + struct of_device *op = client->op; release_device(bp, op); kfree(client); @@ -297,7 +297,7 @@ static void __init reset_one_i2c(struct bbc_i2c_bus *bp) writeb(I2C_PCF_IDLE, bp->i2c_control_regs + 0x0); } -static struct bbc_i2c_bus * __init attach_one_i2c(struct platform_device *op, int index) +static struct bbc_i2c_bus * __init attach_one_i2c(struct of_device *op, int index) { struct bbc_i2c_bus *bp; struct device_node *dp; @@ -330,7 +330,7 @@ static struct bbc_i2c_bus * __init attach_one_i2c(struct platform_device *op, in for (dp = op->dev.of_node->child; dp && entry < 8; dp = dp->sibling, entry++) { - struct platform_device *child_op; + struct of_device *child_op; child_op = of_find_device_by_node(dp); bp->devs[entry].device = child_op; @@ -361,7 +361,7 @@ static struct bbc_i2c_bus * __init attach_one_i2c(struct platform_device *op, in extern int bbc_envctrl_init(struct bbc_i2c_bus *bp); extern void bbc_envctrl_cleanup(struct bbc_i2c_bus *bp); -static int __devinit bbc_i2c_probe(struct platform_device *op, +static int __devinit bbc_i2c_probe(struct of_device *op, const struct of_device_id *match) { struct bbc_i2c_bus *bp; @@ -386,7 +386,7 @@ static int __devinit bbc_i2c_probe(struct platform_device *op, return err; } -static int __devexit bbc_i2c_remove(struct platform_device *op) +static int __devexit bbc_i2c_remove(struct of_device *op) { struct bbc_i2c_bus *bp = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/sbus/char/bbc_i2c.h b/trunk/drivers/sbus/char/bbc_i2c.h index 4b4531066e75..83c4811b7b5e 100644 --- a/trunk/drivers/sbus/char/bbc_i2c.h +++ b/trunk/drivers/sbus/char/bbc_i2c.h @@ -7,7 +7,7 @@ struct bbc_i2c_client { struct bbc_i2c_bus *bp; - struct platform_device *op; + struct of_device *op; int bus; int address; }; @@ -64,16 +64,16 @@ struct bbc_i2c_bus { struct list_head temps; struct list_head fans; - struct platform_device *op; + struct of_device *op; struct { - struct platform_device *device; + struct of_device *device; int client_claimed; } devs[NUM_CHILDREN]; }; /* Probing and attachment. */ -extern struct platform_device *bbc_i2c_getdev(struct bbc_i2c_bus *, int); -extern struct bbc_i2c_client *bbc_i2c_attach(struct bbc_i2c_bus *bp, struct platform_device *); +extern struct of_device *bbc_i2c_getdev(struct bbc_i2c_bus *, int); +extern struct bbc_i2c_client *bbc_i2c_attach(struct bbc_i2c_bus *bp, struct of_device *); extern void bbc_i2c_detach(struct bbc_i2c_client *); /* Register read/write. NOTE: Blocking! */ diff --git a/trunk/drivers/sbus/char/display7seg.c b/trunk/drivers/sbus/char/display7seg.c index 1690e53fb84a..47db97583ea7 100644 --- a/trunk/drivers/sbus/char/display7seg.c +++ b/trunk/drivers/sbus/char/display7seg.c @@ -170,7 +170,7 @@ static struct miscdevice d7s_miscdev = { .fops = &d7s_fops }; -static int __devinit d7s_probe(struct platform_device *op, +static int __devinit d7s_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *opts; @@ -236,7 +236,7 @@ static int __devinit d7s_probe(struct platform_device *op, goto out; } -static int __devexit d7s_remove(struct platform_device *op) +static int __devexit d7s_remove(struct of_device *op) { struct d7s *p = dev_get_drvdata(&op->dev); u8 regs = readb(p->regs); diff --git a/trunk/drivers/sbus/char/envctrl.c b/trunk/drivers/sbus/char/envctrl.c index 078e5f4520ef..3c27f45e2b6d 100644 --- a/trunk/drivers/sbus/char/envctrl.c +++ b/trunk/drivers/sbus/char/envctrl.c @@ -1027,7 +1027,7 @@ static int kenvctrld(void *__unused) return 0; } -static int __devinit envctrl_probe(struct platform_device *op, +static int __devinit envctrl_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp; @@ -1104,7 +1104,7 @@ static int __devinit envctrl_probe(struct platform_device *op, return err; } -static int __devexit envctrl_remove(struct platform_device *op) +static int __devexit envctrl_remove(struct of_device *op) { int index; diff --git a/trunk/drivers/sbus/char/flash.c b/trunk/drivers/sbus/char/flash.c index 2b4b4b613c48..8bb31c584b64 100644 --- a/trunk/drivers/sbus/char/flash.c +++ b/trunk/drivers/sbus/char/flash.c @@ -160,7 +160,7 @@ static const struct file_operations flash_fops = { static struct miscdevice flash_dev = { FLASH_MINOR, "flash", &flash_fops }; -static int __devinit flash_probe(struct platform_device *op, +static int __devinit flash_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; @@ -192,7 +192,7 @@ static int __devinit flash_probe(struct platform_device *op, return misc_register(&flash_dev); } -static int __devexit flash_remove(struct platform_device *op) +static int __devexit flash_remove(struct of_device *op) { misc_deregister(&flash_dev); diff --git a/trunk/drivers/sbus/char/uctrl.c b/trunk/drivers/sbus/char/uctrl.c index 1b345be5cc02..41eb6725ff5f 100644 --- a/trunk/drivers/sbus/char/uctrl.c +++ b/trunk/drivers/sbus/char/uctrl.c @@ -348,7 +348,7 @@ static void uctrl_get_external_status(struct uctrl_driver *driver) } -static int __devinit uctrl_probe(struct platform_device *op, +static int __devinit uctrl_probe(struct of_device *op, const struct of_device_id *match) { struct uctrl_driver *p; @@ -404,7 +404,7 @@ static int __devinit uctrl_probe(struct platform_device *op, goto out; } -static int __devexit uctrl_remove(struct platform_device *op) +static int __devexit uctrl_remove(struct of_device *op) { struct uctrl_driver *p = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/scsi/bfa/bfad.c b/trunk/drivers/scsi/bfa/bfad.c index ca04cc9d332f..915a29d6c7ad 100644 --- a/trunk/drivers/scsi/bfa/bfad.c +++ b/trunk/drivers/scsi/bfa/bfad.c @@ -788,7 +788,6 @@ bfad_drv_init(struct bfad_s *bfad) memset(&driver_info, 0, sizeof(driver_info)); strncpy(driver_info.version, BFAD_DRIVER_VERSION, sizeof(driver_info.version) - 1); - __kernel_param_lock(); if (host_name) strncpy(driver_info.host_machine_name, host_name, sizeof(driver_info.host_machine_name) - 1); @@ -798,7 +797,6 @@ bfad_drv_init(struct bfad_s *bfad) if (os_patch) strncpy(driver_info.host_os_patch, os_patch, sizeof(driver_info.host_os_patch) - 1); - __kernel_param_unlock(); strncpy(driver_info.os_device_name, bfad->pci_name, sizeof(driver_info.os_device_name - 1)); diff --git a/trunk/drivers/scsi/qlogicpti.c b/trunk/drivers/scsi/qlogicpti.c index f8c561cf751e..53d7ed0dc169 100644 --- a/trunk/drivers/scsi/qlogicpti.c +++ b/trunk/drivers/scsi/qlogicpti.c @@ -704,7 +704,7 @@ static void __devexit qpti_chain_del(struct qlogicpti *qpti) static int __devinit qpti_map_regs(struct qlogicpti *qpti) { - struct platform_device *op = qpti->op; + struct of_device *op = qpti->op; qpti->qregs = of_ioremap(&op->resource[0], 0, resource_size(&op->resource[0]), @@ -727,7 +727,7 @@ static int __devinit qpti_map_regs(struct qlogicpti *qpti) static int __devinit qpti_register_irq(struct qlogicpti *qpti) { - struct platform_device *op = qpti->op; + struct of_device *op = qpti->op; qpti->qhost->irq = qpti->irq = op->archdata.irqs[0]; @@ -752,7 +752,7 @@ static int __devinit qpti_register_irq(struct qlogicpti *qpti) static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) { - struct platform_device *op = qpti->op; + struct of_device *op = qpti->op; struct device_node *dp; dp = op->dev.of_node; @@ -773,7 +773,7 @@ static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) static void qpti_get_bursts(struct qlogicpti *qpti) { - struct platform_device *op = qpti->op; + struct of_device *op = qpti->op; u8 bursts, bmask; bursts = of_getintprop_default(op->dev.of_node, "burst-sizes", 0xff); @@ -806,7 +806,7 @@ static void qpti_get_clock(struct qlogicpti *qpti) */ static int __devinit qpti_map_queues(struct qlogicpti *qpti) { - struct platform_device *op = qpti->op; + struct of_device *op = qpti->op; #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) qpti->res_cpu = dma_alloc_coherent(&op->dev, @@ -1290,7 +1290,7 @@ static struct scsi_host_template qpti_template = { .use_clustering = ENABLE_CLUSTERING, }; -static int __devinit qpti_sbus_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit qpti_sbus_probe(struct of_device *op, const struct of_device_id *match) { struct scsi_host_template *tpnt = match->data; struct device_node *dp = op->dev.of_node; @@ -1401,7 +1401,7 @@ static int __devinit qpti_sbus_probe(struct platform_device *op, const struct of return -ENODEV; } -static int __devexit qpti_sbus_remove(struct platform_device *op) +static int __devexit qpti_sbus_remove(struct of_device *op) { struct qlogicpti *qpti = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/scsi/qlogicpti.h b/trunk/drivers/scsi/qlogicpti.h index 4377e87ee79c..e3c74d1ee2db 100644 --- a/trunk/drivers/scsi/qlogicpti.h +++ b/trunk/drivers/scsi/qlogicpti.h @@ -342,7 +342,7 @@ struct qlogicpti { u_int req_in_ptr; /* index of next request slot */ u_int res_out_ptr; /* index of next result slot */ long send_marker; /* must we send a marker? */ - struct platform_device *op; + struct of_device *op; unsigned long __pad; int cmd_count[MAX_TARGETS]; diff --git a/trunk/drivers/scsi/sun_esp.c b/trunk/drivers/scsi/sun_esp.c index 193b37ba1834..89ba6fe02f80 100644 --- a/trunk/drivers/scsi/sun_esp.c +++ b/trunk/drivers/scsi/sun_esp.c @@ -44,7 +44,7 @@ enum dvma_rev { }; static int __devinit esp_sbus_setup_dma(struct esp *esp, - struct platform_device *dma_of) + struct of_device *dma_of) { esp->dma = dma_of; @@ -81,7 +81,7 @@ static int __devinit esp_sbus_setup_dma(struct esp *esp, static int __devinit esp_sbus_map_regs(struct esp *esp, int hme) { - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; struct resource *res; /* On HME, two reg sets exist, first is DVMA, @@ -101,7 +101,7 @@ static int __devinit esp_sbus_map_regs(struct esp *esp, int hme) static int __devinit esp_sbus_map_command_block(struct esp *esp) { - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; esp->command_block = dma_alloc_coherent(&op->dev, 16, &esp->command_block_dma, @@ -114,15 +114,15 @@ static int __devinit esp_sbus_map_command_block(struct esp *esp) static int __devinit esp_sbus_register_irq(struct esp *esp) { struct Scsi_Host *host = esp->host; - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; host->irq = op->archdata.irqs[0]; return request_irq(host->irq, scsi_esp_intr, IRQF_SHARED, "ESP", esp); } -static void __devinit esp_get_scsi_id(struct esp *esp, struct platform_device *espdma) +static void __devinit esp_get_scsi_id(struct esp *esp, struct of_device *espdma) { - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; struct device_node *dp; dp = op->dev.of_node; @@ -144,7 +144,7 @@ static void __devinit esp_get_scsi_id(struct esp *esp, struct platform_device *e static void __devinit esp_get_differential(struct esp *esp) { - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; struct device_node *dp; dp = op->dev.of_node; @@ -156,7 +156,7 @@ static void __devinit esp_get_differential(struct esp *esp) static void __devinit esp_get_clock_params(struct esp *esp) { - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; struct device_node *bus_dp, *dp; int fmhz; @@ -170,10 +170,10 @@ static void __devinit esp_get_clock_params(struct esp *esp) esp->cfreq = fmhz; } -static void __devinit esp_get_bursts(struct esp *esp, struct platform_device *dma_of) +static void __devinit esp_get_bursts(struct esp *esp, struct of_device *dma_of) { struct device_node *dma_dp = dma_of->dev.of_node; - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; struct device_node *dp; u8 bursts, val; @@ -195,7 +195,7 @@ static void __devinit esp_get_bursts(struct esp *esp, struct platform_device *dm esp->bursts = bursts; } -static void __devinit esp_sbus_get_props(struct esp *esp, struct platform_device *espdma) +static void __devinit esp_sbus_get_props(struct esp *esp, struct of_device *espdma) { esp_get_scsi_id(esp, espdma); esp_get_differential(esp); @@ -216,7 +216,7 @@ static u8 sbus_esp_read8(struct esp *esp, unsigned long reg) static dma_addr_t sbus_esp_map_single(struct esp *esp, void *buf, size_t sz, int dir) { - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; return dma_map_single(&op->dev, buf, sz, dir); } @@ -224,7 +224,7 @@ static dma_addr_t sbus_esp_map_single(struct esp *esp, void *buf, static int sbus_esp_map_sg(struct esp *esp, struct scatterlist *sg, int num_sg, int dir) { - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; return dma_map_sg(&op->dev, sg, num_sg, dir); } @@ -232,7 +232,7 @@ static int sbus_esp_map_sg(struct esp *esp, struct scatterlist *sg, static void sbus_esp_unmap_single(struct esp *esp, dma_addr_t addr, size_t sz, int dir) { - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; dma_unmap_single(&op->dev, addr, sz, dir); } @@ -240,7 +240,7 @@ static void sbus_esp_unmap_single(struct esp *esp, dma_addr_t addr, static void sbus_esp_unmap_sg(struct esp *esp, struct scatterlist *sg, int num_sg, int dir) { - struct platform_device *op = esp->dev; + struct of_device *op = esp->dev; dma_unmap_sg(&op->dev, sg, num_sg, dir); } @@ -256,7 +256,7 @@ static void sbus_esp_reset_dma(struct esp *esp) { int can_do_burst16, can_do_burst32, can_do_burst64; int can_do_sbus64, lim; - struct platform_device *op; + struct of_device *op; u32 val; can_do_burst16 = (esp->bursts & DMA_BURST16) != 0; @@ -487,8 +487,8 @@ static const struct esp_driver_ops sbus_esp_ops = { .dma_error = sbus_esp_dma_error, }; -static int __devinit esp_sbus_probe_one(struct platform_device *op, - struct platform_device *espdma, +static int __devinit esp_sbus_probe_one(struct of_device *op, + struct of_device *espdma, int hme) { struct scsi_host_template *tpnt = &scsi_esp_template; @@ -562,11 +562,11 @@ static int __devinit esp_sbus_probe_one(struct platform_device *op, return err; } -static int __devinit esp_sbus_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit esp_sbus_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dma_node = NULL; struct device_node *dp = op->dev.of_node; - struct platform_device *dma_of = NULL; + struct of_device *dma_of = NULL; int hme = 0; if (dp->parent && @@ -585,10 +585,10 @@ static int __devinit esp_sbus_probe(struct platform_device *op, const struct of_ return esp_sbus_probe_one(op, dma_of, hme); } -static int __devexit esp_sbus_remove(struct platform_device *op) +static int __devexit esp_sbus_remove(struct of_device *op) { struct esp *esp = dev_get_drvdata(&op->dev); - struct platform_device *dma_of = esp->dma; + struct of_device *dma_of = esp->dma; unsigned int irq = esp->host->irq; bool is_hme; u32 val; diff --git a/trunk/drivers/serial/apbuart.c b/trunk/drivers/serial/apbuart.c index cc01c650a144..0099b8692b60 100644 --- a/trunk/drivers/serial/apbuart.c +++ b/trunk/drivers/serial/apbuart.c @@ -551,7 +551,7 @@ static struct uart_driver grlib_apbuart_driver = { /* OF Platform Driver */ /* ======================================================================== */ -static int __devinit apbuart_probe(struct platform_device *op, +static int __devinit apbuart_probe(struct of_device *op, const struct of_device_id *match) { int i = -1; diff --git a/trunk/drivers/serial/cpm_uart/cpm_uart_core.c b/trunk/drivers/serial/cpm_uart/cpm_uart_core.c index f2b8adcc6c92..6016179db533 100644 --- a/trunk/drivers/serial/cpm_uart/cpm_uart_core.c +++ b/trunk/drivers/serial/cpm_uart/cpm_uart_core.c @@ -1340,7 +1340,7 @@ static struct uart_driver cpm_reg = { static int probe_index; -static int __devinit cpm_uart_probe(struct platform_device *ofdev, +static int __devinit cpm_uart_probe(struct of_device *ofdev, const struct of_device_id *match) { int index = probe_index++; @@ -1364,7 +1364,7 @@ static int __devinit cpm_uart_probe(struct platform_device *ofdev, return uart_add_one_port(&cpm_reg, &pinfo->port); } -static int __devexit cpm_uart_remove(struct platform_device *ofdev) +static int __devexit cpm_uart_remove(struct of_device *ofdev) { struct uart_cpm_port *pinfo = dev_get_drvdata(&ofdev->dev); return uart_remove_one_port(&cpm_reg, &pinfo->port); diff --git a/trunk/drivers/serial/mpc52xx_uart.c b/trunk/drivers/serial/mpc52xx_uart.c index 8dedb266f143..1a88b363005c 100644 --- a/trunk/drivers/serial/mpc52xx_uart.c +++ b/trunk/drivers/serial/mpc52xx_uart.c @@ -1298,7 +1298,7 @@ static struct of_device_id mpc52xx_uart_of_match[] = { }; static int __devinit -mpc52xx_uart_of_probe(struct platform_device *op, const struct of_device_id *match) +mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) { int idx = -1; unsigned int uartclk; @@ -1369,7 +1369,7 @@ mpc52xx_uart_of_probe(struct platform_device *op, const struct of_device_id *mat } static int -mpc52xx_uart_of_remove(struct platform_device *op) +mpc52xx_uart_of_remove(struct of_device *op) { struct uart_port *port = dev_get_drvdata(&op->dev); dev_set_drvdata(&op->dev, NULL); @@ -1382,7 +1382,7 @@ mpc52xx_uart_of_remove(struct platform_device *op) #ifdef CONFIG_PM static int -mpc52xx_uart_of_suspend(struct platform_device *op, pm_message_t state) +mpc52xx_uart_of_suspend(struct of_device *op, pm_message_t state) { struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev); @@ -1393,7 +1393,7 @@ mpc52xx_uart_of_suspend(struct platform_device *op, pm_message_t state) } static int -mpc52xx_uart_of_resume(struct platform_device *op) +mpc52xx_uart_of_resume(struct of_device *op) { struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/serial/nwpserial.c b/trunk/drivers/serial/nwpserial.c index de173671e3d0..e65b0d9202a5 100644 --- a/trunk/drivers/serial/nwpserial.c +++ b/trunk/drivers/serial/nwpserial.c @@ -344,7 +344,7 @@ int nwpserial_register_port(struct uart_port *port) mutex_lock(&nwpserial_mutex); - dn = port->dev->of_node; + dn = to_of_device(port->dev)->dev.of_node; if (dn == NULL) goto out; diff --git a/trunk/drivers/serial/of_serial.c b/trunk/drivers/serial/of_serial.c index 659a695bdad6..a48d9080f552 100644 --- a/trunk/drivers/serial/of_serial.c +++ b/trunk/drivers/serial/of_serial.c @@ -27,7 +27,7 @@ struct of_serial_info { /* * Fill a struct uart_port for a given device node */ -static int __devinit of_platform_serial_setup(struct platform_device *ofdev, +static int __devinit of_platform_serial_setup(struct of_device *ofdev, int type, struct uart_port *port) { struct resource resource; @@ -80,7 +80,7 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev, /* * Try to register a serial port */ -static int __devinit of_platform_serial_probe(struct platform_device *ofdev, +static int __devinit of_platform_serial_probe(struct of_device *ofdev, const struct of_device_id *id) { struct of_serial_info *info; @@ -134,7 +134,7 @@ static int __devinit of_platform_serial_probe(struct platform_device *ofdev, /* * Release a line */ -static int of_platform_serial_remove(struct platform_device *ofdev) +static int of_platform_serial_remove(struct of_device *ofdev) { struct of_serial_info *info = dev_get_drvdata(&ofdev->dev); switch (info->type) { diff --git a/trunk/drivers/serial/sunhv.c b/trunk/drivers/serial/sunhv.c index c9014868297d..a779e22d213e 100644 --- a/trunk/drivers/serial/sunhv.c +++ b/trunk/drivers/serial/sunhv.c @@ -519,7 +519,7 @@ static struct console sunhv_console = { .data = &sunhv_reg, }; -static int __devinit hv_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit hv_probe(struct of_device *op, const struct of_device_id *match) { struct uart_port *port; unsigned long minor; @@ -598,7 +598,7 @@ static int __devinit hv_probe(struct platform_device *op, const struct of_device return err; } -static int __devexit hv_remove(struct platform_device *dev) +static int __devexit hv_remove(struct of_device *dev) { struct uart_port *port = dev_get_drvdata(&dev->dev); diff --git a/trunk/drivers/serial/sunsab.c b/trunk/drivers/serial/sunsab.c index 5b246b18f42f..9845fb1cfb1f 100644 --- a/trunk/drivers/serial/sunsab.c +++ b/trunk/drivers/serial/sunsab.c @@ -883,7 +883,7 @@ static int sunsab_console_setup(struct console *con, char *options) printk("Console: ttyS%d (SAB82532)\n", (sunsab_reg.minor - 64) + con->index); - sunserial_console_termios(con, up->port.dev->of_node); + sunserial_console_termios(con, to_of_device(up->port.dev)->dev.of_node); switch (con->cflag & CBAUD) { case B150: baud = 150; break; @@ -954,7 +954,7 @@ static inline struct console *SUNSAB_CONSOLE(void) #endif static int __devinit sunsab_init_one(struct uart_sunsab_port *up, - struct platform_device *op, + struct of_device *op, unsigned long offset, int line) { @@ -1006,7 +1006,7 @@ static int __devinit sunsab_init_one(struct uart_sunsab_port *up, return 0; } -static int __devinit sab_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit sab_probe(struct of_device *op, const struct of_device_id *match) { static int inst; struct uart_sunsab_port *up; @@ -1062,7 +1062,7 @@ static int __devinit sab_probe(struct platform_device *op, const struct of_devic return err; } -static int __devexit sab_remove(struct platform_device *op) +static int __devexit sab_remove(struct of_device *op) { struct uart_sunsab_port *up = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/serial/sunsu.c b/trunk/drivers/serial/sunsu.c index 551ebfe3ccbb..3cdf74822db5 100644 --- a/trunk/drivers/serial/sunsu.c +++ b/trunk/drivers/serial/sunsu.c @@ -1200,7 +1200,7 @@ static int __devinit sunsu_kbd_ms_init(struct uart_sunsu_port *up) return -ENODEV; printk("%s: %s port at %llx, irq %u\n", - up->port.dev->of_node->full_name, + to_of_device(up->port.dev)->dev.of_node->full_name, (up->su_type == SU_PORT_KBD) ? "Keyboard" : "Mouse", (unsigned long long) up->port.mapbase, up->port.irq); @@ -1352,7 +1352,7 @@ static int __init sunsu_console_setup(struct console *co, char *options) spin_lock_init(&port->lock); /* Get firmware console settings. */ - sunserial_console_termios(co, port->dev->of_node); + sunserial_console_termios(co, to_of_device(port->dev)->dev.of_node); memset(&termios, 0, sizeof(struct ktermios)); termios.c_cflag = co->cflag; @@ -1406,7 +1406,7 @@ static enum su_type __devinit su_get_type(struct device_node *dp) return SU_PORT_PORT; } -static int __devinit su_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit su_probe(struct of_device *op, const struct of_device_id *match) { static int inst; struct device_node *dp = op->dev.of_node; @@ -1497,7 +1497,7 @@ static int __devinit su_probe(struct platform_device *op, const struct of_device return err; } -static int __devexit su_remove(struct platform_device *op) +static int __devexit su_remove(struct of_device *op) { struct uart_sunsu_port *up = dev_get_drvdata(&op->dev); bool kbdms = false; diff --git a/trunk/drivers/serial/sunzilog.c b/trunk/drivers/serial/sunzilog.c index c1967ac1c07f..d1e6bcb59546 100644 --- a/trunk/drivers/serial/sunzilog.c +++ b/trunk/drivers/serial/sunzilog.c @@ -1230,7 +1230,7 @@ static int __init sunzilog_console_setup(struct console *con, char *options) (sunzilog_reg.minor - 64) + con->index, con->index); /* Get firmware console settings. */ - sunserial_console_termios(con, up->port.dev->of_node); + sunserial_console_termios(con, to_of_device(up->port.dev)->dev.of_node); /* Firmware console speed is limited to 150-->38400 baud so * this hackish cflag thing is OK. @@ -1399,7 +1399,7 @@ static void __devinit sunzilog_init_hw(struct uart_sunzilog_port *up) static int zilog_irq = -1; -static int __devinit zs_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit zs_probe(struct of_device *op, const struct of_device_id *match) { static int kbm_inst, uart_inst; int inst; @@ -1516,7 +1516,7 @@ static void __devexit zs_remove_one(struct uart_sunzilog_port *up) uart_remove_one_port(&sunzilog_reg, &up->port); } -static int __devexit zs_remove(struct platform_device *op) +static int __devexit zs_remove(struct of_device *op) { struct uart_sunzilog_port *up = dev_get_drvdata(&op->dev); struct zilog_layout __iomem *regs; diff --git a/trunk/drivers/serial/uartlite.c b/trunk/drivers/serial/uartlite.c index 9b03d7b3e456..caf085d3a76a 100644 --- a/trunk/drivers/serial/uartlite.c +++ b/trunk/drivers/serial/uartlite.c @@ -584,7 +584,7 @@ static struct platform_driver ulite_platform_driver = { */ #if defined(CONFIG_OF) && (defined(CONFIG_PPC32) || defined(CONFIG_MICROBLAZE)) static int __devinit -ulite_of_probe(struct platform_device *op, const struct of_device_id *match) +ulite_of_probe(struct of_device *op, const struct of_device_id *match) { struct resource res; const unsigned int *id; @@ -605,7 +605,7 @@ ulite_of_probe(struct platform_device *op, const struct of_device_id *match) return ulite_assign(&op->dev, id ? *id : -1, res.start, irq); } -static int __devexit ulite_of_remove(struct platform_device *op) +static int __devexit ulite_of_remove(struct of_device *op) { return ulite_release(&op->dev); } diff --git a/trunk/drivers/serial/ucc_uart.c b/trunk/drivers/serial/ucc_uart.c index 3f4848e2174a..907b06f5c447 100644 --- a/trunk/drivers/serial/ucc_uart.c +++ b/trunk/drivers/serial/ucc_uart.c @@ -1194,7 +1194,7 @@ static void uart_firmware_cont(const struct firmware *fw, void *context) release_firmware(fw); } -static int ucc_uart_probe(struct platform_device *ofdev, +static int ucc_uart_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -1462,7 +1462,7 @@ static int ucc_uart_probe(struct platform_device *ofdev, return 0; } -static int ucc_uart_remove(struct platform_device *ofdev) +static int ucc_uart_remove(struct of_device *ofdev) { struct uart_qe_port *qe_port = dev_get_drvdata(&ofdev->dev); diff --git a/trunk/drivers/spi/mpc512x_psc_spi.c b/trunk/drivers/spi/mpc512x_psc_spi.c index cddbfceb324f..10baac3f8ea5 100644 --- a/trunk/drivers/spi/mpc512x_psc_spi.c +++ b/trunk/drivers/spi/mpc512x_psc_spi.c @@ -507,7 +507,7 @@ static int __exit mpc512x_psc_spi_do_remove(struct device *dev) return 0; } -static int __init mpc512x_psc_spi_of_probe(struct platform_device *op, +static int __init mpc512x_psc_spi_of_probe(struct of_device *op, const struct of_device_id *match) { const u32 *regaddr_p; @@ -539,7 +539,7 @@ static int __init mpc512x_psc_spi_of_probe(struct platform_device *op, irq_of_parse_and_map(op->dev.of_node, 0), id); } -static int __exit mpc512x_psc_spi_of_remove(struct platform_device *op) +static int __exit mpc512x_psc_spi_of_remove(struct of_device *op) { return mpc512x_psc_spi_do_remove(&op->dev); } diff --git a/trunk/drivers/spi/mpc52xx_psc_spi.c b/trunk/drivers/spi/mpc52xx_psc_spi.c index 983fbbfce76e..66d170147dcc 100644 --- a/trunk/drivers/spi/mpc52xx_psc_spi.c +++ b/trunk/drivers/spi/mpc52xx_psc_spi.c @@ -465,7 +465,7 @@ static int __exit mpc52xx_psc_spi_do_remove(struct device *dev) return 0; } -static int __init mpc52xx_psc_spi_of_probe(struct platform_device *op, +static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, const struct of_device_id *match) { const u32 *regaddr_p; @@ -495,7 +495,7 @@ static int __init mpc52xx_psc_spi_of_probe(struct platform_device *op, irq_of_parse_and_map(op->dev.of_node, 0), id); } -static int __exit mpc52xx_psc_spi_of_remove(struct platform_device *op) +static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op) { return mpc52xx_psc_spi_do_remove(&op->dev); } diff --git a/trunk/drivers/spi/mpc52xx_spi.c b/trunk/drivers/spi/mpc52xx_spi.c index ec9f0b1bf864..56136ff00e01 100644 --- a/trunk/drivers/spi/mpc52xx_spi.c +++ b/trunk/drivers/spi/mpc52xx_spi.c @@ -390,7 +390,7 @@ static int mpc52xx_spi_transfer(struct spi_device *spi, struct spi_message *m) /* * OF Platform Bus Binding */ -static int __devinit mpc52xx_spi_probe(struct platform_device *op, +static int __devinit mpc52xx_spi_probe(struct of_device *op, const struct of_device_id *match) { struct spi_master *master; @@ -530,7 +530,7 @@ static int __devinit mpc52xx_spi_probe(struct platform_device *op, return rc; } -static int __devexit mpc52xx_spi_remove(struct platform_device *op) +static int __devexit mpc52xx_spi_remove(struct of_device *op) { struct spi_master *master = dev_get_drvdata(&op->dev); struct mpc52xx_spi *ms = spi_master_get_devdata(master); diff --git a/trunk/drivers/spi/spi_mpc8xxx.c b/trunk/drivers/spi/spi_mpc8xxx.c index d31b57f7baaf..aad9ae1b9c69 100644 --- a/trunk/drivers/spi/spi_mpc8xxx.c +++ b/trunk/drivers/spi/spi_mpc8xxx.c @@ -1236,7 +1236,7 @@ static int of_mpc8xxx_spi_free_chipselects(struct device *dev) return 0; } -static int __devinit of_mpc8xxx_spi_probe(struct platform_device *ofdev, +static int __devinit of_mpc8xxx_spi_probe(struct of_device *ofdev, const struct of_device_id *ofid) { struct device *dev = &ofdev->dev; @@ -1308,7 +1308,7 @@ static int __devinit of_mpc8xxx_spi_probe(struct platform_device *ofdev, return ret; } -static int __devexit of_mpc8xxx_spi_remove(struct platform_device *ofdev) +static int __devexit of_mpc8xxx_spi_remove(struct of_device *ofdev) { int ret; diff --git a/trunk/drivers/spi/spi_ppc4xx.c b/trunk/drivers/spi/spi_ppc4xx.c index 80e172d3e72a..0f5fa7e2a550 100644 --- a/trunk/drivers/spi/spi_ppc4xx.c +++ b/trunk/drivers/spi/spi_ppc4xx.c @@ -388,9 +388,9 @@ static void free_gpios(struct ppc4xx_spi *hw) } /* - * platform_device layer stuff... + * of_device layer stuff... */ -static int __init spi_ppc4xx_of_probe(struct platform_device *op, +static int __init spi_ppc4xx_of_probe(struct of_device *op, const struct of_device_id *match) { struct ppc4xx_spi *hw; @@ -565,7 +565,7 @@ static int __init spi_ppc4xx_of_probe(struct platform_device *op, return ret; } -static int __exit spi_ppc4xx_of_remove(struct platform_device *op) +static int __exit spi_ppc4xx_of_remove(struct of_device *op) { struct spi_master *master = dev_get_drvdata(&op->dev); struct ppc4xx_spi *hw = spi_master_get_devdata(master); diff --git a/trunk/drivers/spi/xilinx_spi_of.c b/trunk/drivers/spi/xilinx_spi_of.c index b66c2dbf20a5..f53d3f6b9f61 100644 --- a/trunk/drivers/spi/xilinx_spi_of.c +++ b/trunk/drivers/spi/xilinx_spi_of.c @@ -38,7 +38,7 @@ #include "xilinx_spi.h" -static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev, +static int __devinit xilinx_spi_of_probe(struct of_device *ofdev, const struct of_device_id *match) { struct spi_master *master; @@ -84,7 +84,7 @@ static int __devinit xilinx_spi_of_probe(struct platform_device *ofdev, return 0; } -static int __devexit xilinx_spi_remove(struct platform_device *ofdev) +static int __devexit xilinx_spi_remove(struct of_device *ofdev) { xilinx_spi_deinit(dev_get_drvdata(&ofdev->dev)); dev_set_drvdata(&ofdev->dev, 0); @@ -93,7 +93,7 @@ static int __devexit xilinx_spi_remove(struct platform_device *ofdev) return 0; } -static int __exit xilinx_spi_of_remove(struct platform_device *op) +static int __exit xilinx_spi_of_remove(struct of_device *op) { return xilinx_spi_remove(op); } diff --git a/trunk/drivers/staging/rtl8187se/r8180_core.c b/trunk/drivers/staging/rtl8187se/r8180_core.c index ed7457bc24ea..49ab9fa9ffa7 100644 --- a/trunk/drivers/staging/rtl8187se/r8180_core.c +++ b/trunk/drivers/staging/rtl8187se/r8180_core.c @@ -61,7 +61,7 @@ static struct pci_device_id rtl8180_pci_id_tbl[] __devinitdata = { }; -static char ifname[IFNAMSIZ] = "wlan%d"; +static char *ifname = "wlan%d"; static int hwseqnum = 0; static int hwwep = 0; static int channels = 0x3fff; @@ -72,7 +72,7 @@ MODULE_AUTHOR("Andrea Merello "); MODULE_DESCRIPTION("Linux driver for Realtek RTL8180 / RTL8185 WiFi cards"); -module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); +module_param(ifname, charp, S_IRUGO|S_IWUSR); module_param(hwseqnum, int, S_IRUGO|S_IWUSR); module_param(hwwep, int, S_IRUGO|S_IWUSR); module_param(channels, int, S_IRUGO|S_IWUSR); @@ -3609,7 +3609,7 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, if (dev_alloc_name(dev, ifname) < 0) { DMESG("Oops: devname already taken! Trying wlan%%d...\n"); - strcpy(ifname, "wlan%d"); + ifname = "wlan%d"; dev_alloc_name(dev, ifname); } diff --git a/trunk/drivers/staging/rtl8192e/r8192E_core.c b/trunk/drivers/staging/rtl8192e/r8192E_core.c index 17a806f9ee77..4cd071adf84b 100644 --- a/trunk/drivers/staging/rtl8192e/r8192E_core.c +++ b/trunk/drivers/staging/rtl8192e/r8192E_core.c @@ -112,7 +112,7 @@ static const struct pci_device_id rtl8192_pci_id_tbl[] __devinitdata = { {} }; -static char ifname[IFNAMSIZ] = "wlan%d"; +static char* ifname = "wlan%d"; static int hwwep = 1; //default use hw. set 0 to use software security static int channels = 0x3fff; @@ -123,7 +123,7 @@ MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); MODULE_DESCRIPTION("Linux driver for Realtek RTL819x WiFi cards"); -module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); +module_param(ifname, charp, S_IRUGO|S_IWUSR ); //module_param(hwseqnum,int, S_IRUGO|S_IWUSR); module_param(hwwep,int, S_IRUGO|S_IWUSR); module_param(channels,int, S_IRUGO|S_IWUSR); @@ -6446,7 +6446,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, if (dev_alloc_name(dev, ifname) < 0){ RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); - strcpy(ifname, "wlan%d"); + ifname = "wlan%d"; dev_alloc_name(dev, ifname); } diff --git a/trunk/drivers/staging/rtl8192su/r8192U_core.c b/trunk/drivers/staging/rtl8192su/r8192U_core.c index df5b52baf893..6970c97713d8 100644 --- a/trunk/drivers/staging/rtl8192su/r8192U_core.c +++ b/trunk/drivers/staging/rtl8192su/r8192U_core.c @@ -144,13 +144,13 @@ MODULE_VERSION("V 1.1"); MODULE_DEVICE_TABLE(usb, rtl8192_usb_id_tbl); MODULE_DESCRIPTION("Linux driver for Realtek RTL8192 USB WiFi cards"); -static char ifname[IFNAMSIZ] = "wlan%d"; +static char* ifname = "wlan%d"; static int hwwep = 1; //default use hw. set 0 to use software security static int channels = 0x3fff; -module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); +module_param(ifname, charp, S_IRUGO|S_IWUSR ); //module_param(hwseqnum,int, S_IRUGO|S_IWUSR); module_param(hwwep,int, S_IRUGO|S_IWUSR); module_param(channels,int, S_IRUGO|S_IWUSR); @@ -7406,7 +7406,7 @@ static int __devinit rtl8192_usb_probe(struct usb_interface *intf, if (dev_alloc_name(dev, ifname) < 0){ RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); - strcpy(ifname, "wlan%d"); + ifname = "wlan%d"; dev_alloc_name(dev, ifname); } diff --git a/trunk/drivers/usb/atm/ueagle-atm.c b/trunk/drivers/usb/atm/ueagle-atm.c index ea071a5b6eee..5b3f555e01c9 100644 --- a/trunk/drivers/usb/atm/ueagle-atm.c +++ b/trunk/drivers/usb/atm/ueagle-atm.c @@ -1577,7 +1577,6 @@ static void cmvs_file_name(struct uea_softc *sc, char *const cmv_name, int ver) char file_arr[] = "CMVxy.bin"; char *file; - kparam_block_sysfs_write(cmv_file); /* set proper name corresponding modem version and line type */ if (cmv_file[sc->modem_index] == NULL) { if (UEA_CHIP_VERSION(sc) == ADI930) @@ -1596,7 +1595,6 @@ static void cmvs_file_name(struct uea_softc *sc, char *const cmv_name, int ver) strlcat(cmv_name, file, UEA_FW_NAME_MAX); if (ver == 2) strlcat(cmv_name, ".v2", UEA_FW_NAME_MAX); - kparam_unblock_sysfs_write(cmv_file); } static int request_cmvs_old(struct uea_softc *sc, diff --git a/trunk/drivers/usb/gadget/fsl_qe_udc.c b/trunk/drivers/usb/gadget/fsl_qe_udc.c index a5ea2c1d8c93..9648b75f0283 100644 --- a/trunk/drivers/usb/gadget/fsl_qe_udc.c +++ b/trunk/drivers/usb/gadget/fsl_qe_udc.c @@ -2398,7 +2398,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) EXPORT_SYMBOL(usb_gadget_unregister_driver); /* udc structure's alloc and setup, include ep-param alloc */ -static struct qe_udc __devinit *qe_udc_config(struct platform_device *ofdev) +static struct qe_udc __devinit *qe_udc_config(struct of_device *ofdev) { struct qe_udc *udc; struct device_node *np = ofdev->dev.of_node; @@ -2523,7 +2523,7 @@ static void qe_udc_release(struct device *dev) } /* Driver probe functions */ -static int __devinit qe_udc_probe(struct platform_device *ofdev, +static int __devinit qe_udc_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -2679,18 +2679,18 @@ static int __devinit qe_udc_probe(struct platform_device *ofdev, } #ifdef CONFIG_PM -static int qe_udc_suspend(struct platform_device *dev, pm_message_t state) +static int qe_udc_suspend(struct of_device *dev, pm_message_t state) { return -ENOTSUPP; } -static int qe_udc_resume(struct platform_device *dev) +static int qe_udc_resume(struct of_device *dev) { return -ENOTSUPP; } #endif -static int __devexit qe_udc_remove(struct platform_device *ofdev) +static int __devexit qe_udc_remove(struct of_device *ofdev) { struct qe_ep *ep; unsigned int size; diff --git a/trunk/drivers/usb/host/ehci-ppc-of.c b/trunk/drivers/usb/host/ehci-ppc-of.c index 335ee699fd85..5aec92866ab3 100644 --- a/trunk/drivers/usb/host/ehci-ppc-of.c +++ b/trunk/drivers/usb/host/ehci-ppc-of.c @@ -106,7 +106,7 @@ ppc44x_enable_bmt(struct device_node *dn) static int __devinit -ehci_hcd_ppc_of_probe(struct platform_device *op, const struct of_device_id *match) +ehci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dn = op->dev.of_node; struct usb_hcd *hcd; @@ -210,7 +210,7 @@ ehci_hcd_ppc_of_probe(struct platform_device *op, const struct of_device_id *mat } -static int ehci_hcd_ppc_of_remove(struct platform_device *op) +static int ehci_hcd_ppc_of_remove(struct of_device *op) { struct usb_hcd *hcd = dev_get_drvdata(&op->dev); struct ehci_hcd *ehci = hcd_to_ehci(hcd); @@ -253,7 +253,7 @@ static int ehci_hcd_ppc_of_remove(struct platform_device *op) } -static int ehci_hcd_ppc_of_shutdown(struct platform_device *op) +static int ehci_hcd_ppc_of_shutdown(struct of_device *op) { struct usb_hcd *hcd = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/usb/host/ehci-xilinx-of.c b/trunk/drivers/usb/host/ehci-xilinx-of.c index 6c8076ad821d..4899f451add9 100644 --- a/trunk/drivers/usb/host/ehci-xilinx-of.c +++ b/trunk/drivers/usb/host/ehci-xilinx-of.c @@ -140,7 +140,7 @@ static const struct hc_driver ehci_xilinx_of_hc_driver = { /** * ehci_hcd_xilinx_of_probe - Probe method for the USB host controller - * @op: pointer to the platform_device bound to the host controller + * @op: pointer to the of_device to which the host controller bound * @match: pointer to of_device_id structure, not used * * This function requests resources and sets up appropriate properties for the @@ -149,7 +149,7 @@ static const struct hc_driver ehci_xilinx_of_hc_driver = { * entry, and sets an appropriate value for hcd->has_tt. */ static int __devinit -ehci_hcd_xilinx_of_probe(struct platform_device *op, const struct of_device_id *match) +ehci_hcd_xilinx_of_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dn = op->dev.of_node; struct usb_hcd *hcd; @@ -242,12 +242,12 @@ ehci_hcd_xilinx_of_probe(struct platform_device *op, const struct of_device_id * /** * ehci_hcd_xilinx_of_remove - shutdown hcd and release resources - * @op: pointer to platform_device structure that is to be removed + * @op: pointer to of_device structure that is to be removed * * Remove the hcd structure, and release resources that has been requested * during probe. */ -static int ehci_hcd_xilinx_of_remove(struct platform_device *op) +static int ehci_hcd_xilinx_of_remove(struct of_device *op) { struct usb_hcd *hcd = dev_get_drvdata(&op->dev); dev_set_drvdata(&op->dev, NULL); @@ -266,11 +266,11 @@ static int ehci_hcd_xilinx_of_remove(struct platform_device *op) /** * ehci_hcd_xilinx_of_shutdown - shutdown the hcd - * @op: pointer to platform_device structure that is to be removed + * @op: pointer to of_device structure that is to be removed * * Properly shutdown the hcd, call driver's shutdown routine. */ -static int ehci_hcd_xilinx_of_shutdown(struct platform_device *op) +static int ehci_hcd_xilinx_of_shutdown(struct of_device *op) { struct usb_hcd *hcd = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/usb/host/fhci-hcd.c b/trunk/drivers/usb/host/fhci-hcd.c index 20092a27a1e8..c7c8392a88b9 100644 --- a/trunk/drivers/usb/host/fhci-hcd.c +++ b/trunk/drivers/usb/host/fhci-hcd.c @@ -561,7 +561,7 @@ static const struct hc_driver fhci_driver = { .hub_control = fhci_hub_control, }; -static int __devinit of_fhci_probe(struct platform_device *ofdev, +static int __devinit of_fhci_probe(struct of_device *ofdev, const struct of_device_id *ofid) { struct device *dev = &ofdev->dev; @@ -801,7 +801,7 @@ static int __devexit fhci_remove(struct device *dev) return 0; } -static int __devexit of_fhci_remove(struct platform_device *ofdev) +static int __devexit of_fhci_remove(struct of_device *ofdev) { return fhci_remove(&ofdev->dev); } diff --git a/trunk/drivers/usb/host/isp1760-if.c b/trunk/drivers/usb/host/isp1760-if.c index 3b28dbfca058..ec85d0c3cc3e 100644 --- a/trunk/drivers/usb/host/isp1760-if.c +++ b/trunk/drivers/usb/host/isp1760-if.c @@ -27,7 +27,7 @@ #endif #ifdef CONFIG_PPC_OF -static int of_isp1760_probe(struct platform_device *dev, +static int of_isp1760_probe(struct of_device *dev, const struct of_device_id *match) { struct usb_hcd *hcd; @@ -95,7 +95,7 @@ static int of_isp1760_probe(struct platform_device *dev, return ret; } -static int of_isp1760_remove(struct platform_device *dev) +static int of_isp1760_remove(struct of_device *dev) { struct usb_hcd *hcd = dev_get_drvdata(&dev->dev); diff --git a/trunk/drivers/usb/host/ohci-pnx4008.c b/trunk/drivers/usb/host/ohci-pnx4008.c index 653d6a60edb5..cd74bbdd007c 100644 --- a/trunk/drivers/usb/host/ohci-pnx4008.c +++ b/trunk/drivers/usb/host/ohci-pnx4008.c @@ -329,7 +329,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) memset(&i2c_info, 0, sizeof(struct i2c_board_info)); strlcpy(i2c_info.type, "isp1301_pnx", I2C_NAME_SIZE); isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, - normal_i2c, NULL); + normal_i2c); i2c_put_adapter(i2c_adap); if (!isp1301_i2c_client) { err("failed to connect I2C to ISP1301 USB Transceiver"); diff --git a/trunk/drivers/usb/host/ohci-ppc-of.c b/trunk/drivers/usb/host/ohci-ppc-of.c index b2c2dbf08766..df165917412a 100644 --- a/trunk/drivers/usb/host/ohci-ppc-of.c +++ b/trunk/drivers/usb/host/ohci-ppc-of.c @@ -81,7 +81,7 @@ static const struct hc_driver ohci_ppc_of_hc_driver = { static int __devinit -ohci_hcd_ppc_of_probe(struct platform_device *op, const struct of_device_id *match) +ohci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dn = op->dev.of_node; struct usb_hcd *hcd; @@ -183,7 +183,7 @@ ohci_hcd_ppc_of_probe(struct platform_device *op, const struct of_device_id *mat return rv; } -static int ohci_hcd_ppc_of_remove(struct platform_device *op) +static int ohci_hcd_ppc_of_remove(struct of_device *op) { struct usb_hcd *hcd = dev_get_drvdata(&op->dev); dev_set_drvdata(&op->dev, NULL); @@ -201,7 +201,7 @@ static int ohci_hcd_ppc_of_remove(struct platform_device *op) return 0; } -static int ohci_hcd_ppc_of_shutdown(struct platform_device *op) +static int ohci_hcd_ppc_of_shutdown(struct of_device *op) { struct usb_hcd *hcd = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/video/bw2.c b/trunk/drivers/video/bw2.c index 4dc13467281d..c7796637bafd 100644 --- a/trunk/drivers/video/bw2.c +++ b/trunk/drivers/video/bw2.c @@ -273,7 +273,7 @@ static int __devinit bw2_do_default_mode(struct bw2_par *par, return 0; } -static int __devinit bw2_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit bw2_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; struct fb_info *info; @@ -350,7 +350,7 @@ static int __devinit bw2_probe(struct platform_device *op, const struct of_devic return err; } -static int __devexit bw2_remove(struct platform_device *op) +static int __devexit bw2_remove(struct of_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct bw2_par *par = info->par; diff --git a/trunk/drivers/video/cg14.c b/trunk/drivers/video/cg14.c index 24249535ac86..d09fde8beb69 100644 --- a/trunk/drivers/video/cg14.c +++ b/trunk/drivers/video/cg14.c @@ -446,7 +446,7 @@ static struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] __devinitdata = { { .size = 0 } }; -static void cg14_unmap_regs(struct platform_device *op, struct fb_info *info, +static void cg14_unmap_regs(struct of_device *op, struct fb_info *info, struct cg14_par *par) { if (par->regs) @@ -463,7 +463,7 @@ static void cg14_unmap_regs(struct platform_device *op, struct fb_info *info, info->screen_base, info->fix.smem_len); } -static int __devinit cg14_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit cg14_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; struct fb_info *info; @@ -570,7 +570,7 @@ static int __devinit cg14_probe(struct platform_device *op, const struct of_devi return err; } -static int __devexit cg14_remove(struct platform_device *op) +static int __devexit cg14_remove(struct of_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct cg14_par *par = info->par; diff --git a/trunk/drivers/video/cg3.c b/trunk/drivers/video/cg3.c index 09c0c3c42482..64aa29809fb9 100644 --- a/trunk/drivers/video/cg3.c +++ b/trunk/drivers/video/cg3.c @@ -346,7 +346,7 @@ static int __devinit cg3_do_default_mode(struct cg3_par *par) return 0; } -static int __devinit cg3_probe(struct platform_device *op, +static int __devinit cg3_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; @@ -433,7 +433,7 @@ static int __devinit cg3_probe(struct platform_device *op, return err; } -static int __devexit cg3_remove(struct platform_device *op) +static int __devexit cg3_remove(struct of_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct cg3_par *par = info->par; diff --git a/trunk/drivers/video/cg6.c b/trunk/drivers/video/cg6.c index 2b5a97058b08..2389a719dcc7 100644 --- a/trunk/drivers/video/cg6.c +++ b/trunk/drivers/video/cg6.c @@ -718,7 +718,7 @@ static void __devinit cg6_chip_init(struct fb_info *info) sbus_writel(info->var.yres - 1, &fbc->clipmaxy); } -static void cg6_unmap_regs(struct platform_device *op, struct fb_info *info, +static void cg6_unmap_regs(struct of_device *op, struct fb_info *info, struct cg6_par *par) { if (par->fbc) @@ -737,7 +737,7 @@ static void cg6_unmap_regs(struct platform_device *op, struct fb_info *info, info->fix.smem_len); } -static int __devinit cg6_probe(struct platform_device *op, +static int __devinit cg6_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; @@ -827,7 +827,7 @@ static int __devinit cg6_probe(struct platform_device *op, return err; } -static int __devexit cg6_remove(struct platform_device *op) +static int __devexit cg6_remove(struct of_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct cg6_par *par = info->par; diff --git a/trunk/drivers/video/ffb.c b/trunk/drivers/video/ffb.c index 6739b2af3bc0..f6ecfab296d3 100644 --- a/trunk/drivers/video/ffb.c +++ b/trunk/drivers/video/ffb.c @@ -893,7 +893,7 @@ static void ffb_init_fix(struct fb_info *info) info->fix.accel = FB_ACCEL_SUN_CREATOR; } -static int __devinit ffb_probe(struct platform_device *op, +static int __devinit ffb_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; @@ -1023,7 +1023,7 @@ static int __devinit ffb_probe(struct platform_device *op, return err; } -static int __devexit ffb_remove(struct platform_device *op) +static int __devexit ffb_remove(struct of_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct ffb_par *par = info->par; diff --git a/trunk/drivers/video/fsl-diu-fb.c b/trunk/drivers/video/fsl-diu-fb.c index 8bbbf08fa3ce..e38ad2224540 100644 --- a/trunk/drivers/video/fsl-diu-fb.c +++ b/trunk/drivers/video/fsl-diu-fb.c @@ -1393,7 +1393,7 @@ static void free_irq_local(int irq) * Power management hooks. Note that we won't be called from IRQ context, * unlike the blank functions above, so we may sleep. */ -static int fsl_diu_suspend(struct platform_device *ofdev, pm_message_t state) +static int fsl_diu_suspend(struct of_device *ofdev, pm_message_t state) { struct fsl_diu_data *machine_data; @@ -1403,7 +1403,7 @@ static int fsl_diu_suspend(struct platform_device *ofdev, pm_message_t state) return 0; } -static int fsl_diu_resume(struct platform_device *ofdev) +static int fsl_diu_resume(struct of_device *ofdev) { struct fsl_diu_data *machine_data; @@ -1487,7 +1487,7 @@ static ssize_t show_monitor(struct device *device, return diu_ops.show_monitor_port(machine_data->monitor_port, buf); } -static int __devinit fsl_diu_probe(struct platform_device *ofdev, +static int __devinit fsl_diu_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -1667,7 +1667,7 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev, } -static int fsl_diu_remove(struct platform_device *ofdev) +static int fsl_diu_remove(struct of_device *ofdev) { struct fsl_diu_data *machine_data; int i; diff --git a/trunk/drivers/video/leo.c b/trunk/drivers/video/leo.c index b599e5e36ced..ad677637ffbb 100644 --- a/trunk/drivers/video/leo.c +++ b/trunk/drivers/video/leo.c @@ -529,7 +529,7 @@ static void leo_fixup_var_rgb(struct fb_var_screeninfo *var) var->transp.length = 0; } -static void leo_unmap_regs(struct platform_device *op, struct fb_info *info, +static void leo_unmap_regs(struct of_device *op, struct fb_info *info, struct leo_par *par) { if (par->lc_ss0_usr) @@ -547,7 +547,7 @@ static void leo_unmap_regs(struct platform_device *op, struct fb_info *info, of_iounmap(&op->resource[0], info->screen_base, 0x800000); } -static int __devinit leo_probe(struct platform_device *op, +static int __devinit leo_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; @@ -637,7 +637,7 @@ static int __devinit leo_probe(struct platform_device *op, return err; } -static int __devexit leo_remove(struct platform_device *op) +static int __devexit leo_remove(struct of_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct leo_par *par = info->par; diff --git a/trunk/drivers/video/matrox/i2c-matroxfb.c b/trunk/drivers/video/matrox/i2c-matroxfb.c index 0fb280ead3dc..403b14445a78 100644 --- a/trunk/drivers/video/matrox/i2c-matroxfb.c +++ b/trunk/drivers/video/matrox/i2c-matroxfb.c @@ -191,7 +191,7 @@ static void* i2c_matroxfb_probe(struct matrox_fb_info* minfo) { }; i2c_new_probed_device(&m2info->maven.adapter, - &maven_info, addr_list, NULL); + &maven_info, addr_list); } } return m2info; diff --git a/trunk/drivers/video/mb862xx/mb862xxfb.c b/trunk/drivers/video/mb862xx/mb862xxfb.c index b1c4374cf940..4e2b8cc3d460 100644 --- a/trunk/drivers/video/mb862xx/mb862xxfb.c +++ b/trunk/drivers/video/mb862xx/mb862xxfb.c @@ -550,7 +550,7 @@ static int mb862xx_gdc_init(struct mb862xxfb_par *par) return 0; } -static int __devinit of_platform_mb862xx_probe(struct platform_device *ofdev, +static int __devinit of_platform_mb862xx_probe(struct of_device *ofdev, const struct of_device_id *id) { struct device_node *np = ofdev->dev.of_node; @@ -669,7 +669,7 @@ static int __devinit of_platform_mb862xx_probe(struct platform_device *ofdev, return ret; } -static int __devexit of_platform_mb862xx_remove(struct platform_device *ofdev) +static int __devexit of_platform_mb862xx_remove(struct of_device *ofdev) { struct fb_info *fbi = dev_get_drvdata(&ofdev->dev); struct mb862xxfb_par *par = fbi->par; diff --git a/trunk/drivers/video/p9100.c b/trunk/drivers/video/p9100.c index b6c3fc2db632..688b055abab2 100644 --- a/trunk/drivers/video/p9100.c +++ b/trunk/drivers/video/p9100.c @@ -249,7 +249,7 @@ static void p9100_init_fix(struct fb_info *info, int linebytes, struct device_no info->fix.accel = FB_ACCEL_SUN_CGTHREE; } -static int __devinit p9100_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit p9100_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; struct fb_info *info; @@ -326,7 +326,7 @@ static int __devinit p9100_probe(struct platform_device *op, const struct of_dev return err; } -static int __devexit p9100_remove(struct platform_device *op) +static int __devexit p9100_remove(struct of_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct p9100_par *par = info->par; diff --git a/trunk/drivers/video/platinumfb.c b/trunk/drivers/video/platinumfb.c index a50e1977b316..72a1f4c04732 100644 --- a/trunk/drivers/video/platinumfb.c +++ b/trunk/drivers/video/platinumfb.c @@ -533,7 +533,7 @@ static int __init platinumfb_setup(char *options) #define invalidate_cache(addr) #endif -static int __devinit platinumfb_probe(struct platform_device* odev, +static int __devinit platinumfb_probe(struct of_device* odev, const struct of_device_id *match) { struct device_node *dp = odev->dev.of_node; @@ -646,7 +646,7 @@ static int __devinit platinumfb_probe(struct platform_device* odev, return rc; } -static int __devexit platinumfb_remove(struct platform_device* odev) +static int __devexit platinumfb_remove(struct of_device* odev) { struct fb_info *info = dev_get_drvdata(&odev->dev); struct fb_info_platinum *pinfo = info->par; diff --git a/trunk/drivers/video/sunxvr1000.c b/trunk/drivers/video/sunxvr1000.c index 5dbe06af2226..7288934c0d49 100644 --- a/trunk/drivers/video/sunxvr1000.c +++ b/trunk/drivers/video/sunxvr1000.c @@ -111,7 +111,7 @@ static int __devinit gfb_set_fbinfo(struct gfb_info *gp) return 0; } -static int __devinit gfb_probe(struct platform_device *op, +static int __devinit gfb_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; @@ -172,7 +172,7 @@ static int __devinit gfb_probe(struct platform_device *op, return err; } -static int __devexit gfb_remove(struct platform_device *op) +static int __devexit gfb_remove(struct of_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct gfb_info *gp = info->par; diff --git a/trunk/drivers/video/tcx.c b/trunk/drivers/video/tcx.c index 77ad27955cf0..f375e0db6776 100644 --- a/trunk/drivers/video/tcx.c +++ b/trunk/drivers/video/tcx.c @@ -342,7 +342,7 @@ tcx_init_fix(struct fb_info *info, int linebytes) info->fix.accel = FB_ACCEL_SUN_TCX; } -static void tcx_unmap_regs(struct platform_device *op, struct fb_info *info, +static void tcx_unmap_regs(struct of_device *op, struct fb_info *info, struct tcx_par *par) { if (par->tec) @@ -362,7 +362,7 @@ static void tcx_unmap_regs(struct platform_device *op, struct fb_info *info, info->screen_base, info->fix.smem_len); } -static int __devinit tcx_probe(struct platform_device *op, +static int __devinit tcx_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *dp = op->dev.of_node; @@ -486,7 +486,7 @@ static int __devinit tcx_probe(struct platform_device *op, return err; } -static int __devexit tcx_remove(struct platform_device *op) +static int __devexit tcx_remove(struct of_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct tcx_par *par = info->par; diff --git a/trunk/drivers/video/uvesafb.c b/trunk/drivers/video/uvesafb.c index 52ec0959d462..7b8839ebf3c4 100644 --- a/trunk/drivers/video/uvesafb.c +++ b/trunk/drivers/video/uvesafb.c @@ -1977,7 +1977,8 @@ static void __devexit uvesafb_exit(void) module_exit(uvesafb_exit); -static int param_set_scroll(const char *val, const struct kernel_param *kp) +#define param_get_scroll NULL +static int param_set_scroll(const char *val, struct kernel_param *kp) { ypan = 0; @@ -1992,9 +1993,7 @@ static int param_set_scroll(const char *val, const struct kernel_param *kp) return 0; } -static struct kernel_param_ops param_ops_scroll = { - .set = param_set_scroll, -}; + #define param_check_scroll(name, p) __param_check(name, p, void) module_param_named(scroll, ypan, scroll, 0); diff --git a/trunk/drivers/video/vt8623fb.c b/trunk/drivers/video/vt8623fb.c index 85d76ec4c63e..d31dc96f838a 100644 --- a/trunk/drivers/video/vt8623fb.c +++ b/trunk/drivers/video/vt8623fb.c @@ -726,9 +726,7 @@ static int __devinit vt8623_pci_probe(struct pci_dev *dev, const struct pci_devi /* Prepare startup mode */ - kparam_block_sysfs_write(mode_option); rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8); - kparam_unblock_sysfs_write(mode_option); if (! ((rc == 1) || (rc == 2))) { rc = -EINVAL; dev_err(info->device, "mode %s not found\n", mode_option); diff --git a/trunk/drivers/video/xilinxfb.c b/trunk/drivers/video/xilinxfb.c index 0c9ce88e95e8..29b5daacc217 100644 --- a/trunk/drivers/video/xilinxfb.c +++ b/trunk/drivers/video/xilinxfb.c @@ -397,7 +397,7 @@ static int xilinxfb_release(struct device *dev) */ static int __devinit -xilinxfb_of_probe(struct platform_device *op, const struct of_device_id *match) +xilinxfb_of_probe(struct of_device *op, const struct of_device_id *match) { const u32 *prop; u32 *p; @@ -477,7 +477,7 @@ xilinxfb_of_probe(struct platform_device *op, const struct of_device_id *match) return -ENODEV; } -static int __devexit xilinxfb_of_remove(struct platform_device *op) +static int __devexit xilinxfb_of_remove(struct of_device *op) { return xilinxfb_release(&op->dev); } diff --git a/trunk/drivers/watchdog/cpwd.c b/trunk/drivers/watchdog/cpwd.c index 566343b3c131..30a2512fd52e 100644 --- a/trunk/drivers/watchdog/cpwd.c +++ b/trunk/drivers/watchdog/cpwd.c @@ -526,7 +526,7 @@ static const struct file_operations cpwd_fops = { .release = cpwd_release, }; -static int __devinit cpwd_probe(struct platform_device *op, +static int __devinit cpwd_probe(struct of_device *op, const struct of_device_id *match) { struct device_node *options; @@ -639,7 +639,7 @@ static int __devinit cpwd_probe(struct platform_device *op, goto out; } -static int __devexit cpwd_remove(struct platform_device *op) +static int __devexit cpwd_remove(struct of_device *op) { struct cpwd *p = dev_get_drvdata(&op->dev); int i; diff --git a/trunk/drivers/watchdog/gef_wdt.c b/trunk/drivers/watchdog/gef_wdt.c index 9c21d19043a6..1df284f9c2a1 100644 --- a/trunk/drivers/watchdog/gef_wdt.c +++ b/trunk/drivers/watchdog/gef_wdt.c @@ -260,7 +260,7 @@ static struct miscdevice gef_wdt_miscdev = { }; -static int __devinit gef_wdt_probe(struct platform_device *dev, +static int __devinit gef_wdt_probe(struct of_device *dev, const struct of_device_id *match) { int timeout = 10; diff --git a/trunk/drivers/watchdog/mpc8xxx_wdt.c b/trunk/drivers/watchdog/mpc8xxx_wdt.c index 8fa213cdb499..4cda64dd309c 100644 --- a/trunk/drivers/watchdog/mpc8xxx_wdt.c +++ b/trunk/drivers/watchdog/mpc8xxx_wdt.c @@ -185,7 +185,7 @@ static struct miscdevice mpc8xxx_wdt_miscdev = { .fops = &mpc8xxx_wdt_fops, }; -static int __devinit mpc8xxx_wdt_probe(struct platform_device *ofdev, +static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev, const struct of_device_id *match) { int ret; @@ -238,7 +238,7 @@ static int __devinit mpc8xxx_wdt_probe(struct platform_device *ofdev, return ret; } -static int __devexit mpc8xxx_wdt_remove(struct platform_device *ofdev) +static int __devexit mpc8xxx_wdt_remove(struct of_device *ofdev) { mpc8xxx_wdt_pr_warn("watchdog removed"); del_timer_sync(&wdt_timer); diff --git a/trunk/drivers/watchdog/riowd.c b/trunk/drivers/watchdog/riowd.c index 3faee1ae64bd..4082b4ace1fc 100644 --- a/trunk/drivers/watchdog/riowd.c +++ b/trunk/drivers/watchdog/riowd.c @@ -172,7 +172,7 @@ static struct miscdevice riowd_miscdev = { .fops = &riowd_fops }; -static int __devinit riowd_probe(struct platform_device *op, +static int __devinit riowd_probe(struct of_device *op, const struct of_device_id *match) { struct riowd *p; @@ -219,7 +219,7 @@ static int __devinit riowd_probe(struct platform_device *op, return err; } -static int __devexit riowd_remove(struct platform_device *op) +static int __devexit riowd_remove(struct of_device *op) { struct riowd *p = dev_get_drvdata(&op->dev); diff --git a/trunk/drivers/xen/Kconfig b/trunk/drivers/xen/Kconfig index 60d71e9abe9f..0a8826936639 100644 --- a/trunk/drivers/xen/Kconfig +++ b/trunk/drivers/xen/Kconfig @@ -71,9 +71,4 @@ config XEN_PLATFORM_PCI initializing xenbus and grant_table when running in a Xen HVM domain. As a consequence this driver is required to run any Xen PV frontend on Xen HVM. - -config SWIOTLB_XEN - def_bool y - depends on SWIOTLB - endmenu diff --git a/trunk/drivers/xen/Makefile b/trunk/drivers/xen/Makefile index fcaf838f54be..e392fb776af3 100644 --- a/trunk/drivers/xen/Makefile +++ b/trunk/drivers/xen/Makefile @@ -11,4 +11,3 @@ obj-$(CONFIG_XEN_DEV_EVTCHN) += evtchn.o obj-$(CONFIG_XENFS) += xenfs/ obj-$(CONFIG_XEN_SYS_HYPERVISOR) += sys-hypervisor.o obj-$(CONFIG_XEN_PLATFORM_PCI) += platform-pci.o -obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o diff --git a/trunk/drivers/xen/balloon.c b/trunk/drivers/xen/balloon.c index 500290b150bb..1a0d8c2a0354 100644 --- a/trunk/drivers/xen/balloon.c +++ b/trunk/drivers/xen/balloon.c @@ -85,6 +85,13 @@ static struct sys_device balloon_sysdev; static int register_balloon(struct sys_device *sysdev); +/* + * Protects atomic reservation decrease/increase against concurrent increases. + * Also protects non-atomic updates of current_pages and driver_pages, and + * balloon lists. + */ +static DEFINE_SPINLOCK(balloon_lock); + static struct balloon_stats balloon_stats; /* We increase/decrease in batches which fit in a page */ @@ -203,7 +210,7 @@ static int increase_reservation(unsigned long nr_pages) if (nr_pages > ARRAY_SIZE(frame_list)) nr_pages = ARRAY_SIZE(frame_list); - spin_lock_irqsave(&xen_reservation_lock, flags); + spin_lock_irqsave(&balloon_lock, flags); page = balloon_first_page(); for (i = 0; i < nr_pages; i++) { @@ -247,7 +254,7 @@ static int increase_reservation(unsigned long nr_pages) balloon_stats.current_pages += rc; out: - spin_unlock_irqrestore(&xen_reservation_lock, flags); + spin_unlock_irqrestore(&balloon_lock, flags); return rc < 0 ? rc : rc != nr_pages; } @@ -292,7 +299,7 @@ static int decrease_reservation(unsigned long nr_pages) kmap_flush_unused(); flush_tlb_all(); - spin_lock_irqsave(&xen_reservation_lock, flags); + spin_lock_irqsave(&balloon_lock, flags); /* No more mappings: invalidate P2M and add to balloon. */ for (i = 0; i < nr_pages; i++) { @@ -308,7 +315,7 @@ static int decrease_reservation(unsigned long nr_pages) balloon_stats.current_pages -= nr_pages; - spin_unlock_irqrestore(&xen_reservation_lock, flags); + spin_unlock_irqrestore(&balloon_lock, flags); return need_sleep; } diff --git a/trunk/drivers/xen/swiotlb-xen.c b/trunk/drivers/xen/swiotlb-xen.c deleted file mode 100644 index 54469c3eeacd..000000000000 --- a/trunk/drivers/xen/swiotlb-xen.c +++ /dev/null @@ -1,515 +0,0 @@ -/* - * Copyright 2010 - * by Konrad Rzeszutek Wilk - * - * This code provides a IOMMU for Xen PV guests with PCI passthrough. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License v2.0 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. - * - * PV guests under Xen are running in an non-contiguous memory architecture. - * - * When PCI pass-through is utilized, this necessitates an IOMMU for - * translating bus (DMA) to virtual and vice-versa and also providing a - * mechanism to have contiguous pages for device drivers operations (say DMA - * operations). - * - * Specifically, under Xen the Linux idea of pages is an illusion. It - * assumes that pages start at zero and go up to the available memory. To - * help with that, the Linux Xen MMU provides a lookup mechanism to - * translate the page frame numbers (PFN) to machine frame numbers (MFN) - * and vice-versa. The MFN are the "real" frame numbers. Furthermore - * memory is not contiguous. Xen hypervisor stitches memory for guests - * from different pools, which means there is no guarantee that PFN==MFN - * and PFN+1==MFN+1. Lastly with Xen 4.0, pages (in debug mode) are - * allocated in descending order (high to low), meaning the guest might - * never get any MFN's under the 4GB mark. - * - */ - -#include -#include -#include -#include -#include -/* - * Used to do a quick range check in swiotlb_tbl_unmap_single and - * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this - * API. - */ - -static char *xen_io_tlb_start, *xen_io_tlb_end; -static unsigned long xen_io_tlb_nslabs; -/* - * Quick lookup value of the bus address of the IOTLB. - */ - -u64 start_dma_addr; - -static dma_addr_t xen_phys_to_bus(phys_addr_t paddr) -{ - return phys_to_machine(XPADDR(paddr)).maddr;; -} - -static phys_addr_t xen_bus_to_phys(dma_addr_t baddr) -{ - return machine_to_phys(XMADDR(baddr)).paddr; -} - -static dma_addr_t xen_virt_to_bus(void *address) -{ - return xen_phys_to_bus(virt_to_phys(address)); -} - -static int check_pages_physically_contiguous(unsigned long pfn, - unsigned int offset, - size_t length) -{ - unsigned long next_mfn; - int i; - int nr_pages; - - next_mfn = pfn_to_mfn(pfn); - nr_pages = (offset + length + PAGE_SIZE-1) >> PAGE_SHIFT; - - for (i = 1; i < nr_pages; i++) { - if (pfn_to_mfn(++pfn) != ++next_mfn) - return 0; - } - return 1; -} - -static int range_straddles_page_boundary(phys_addr_t p, size_t size) -{ - unsigned long pfn = PFN_DOWN(p); - unsigned int offset = p & ~PAGE_MASK; - - if (offset + size <= PAGE_SIZE) - return 0; - if (check_pages_physically_contiguous(pfn, offset, size)) - return 0; - return 1; -} - -static int is_xen_swiotlb_buffer(dma_addr_t dma_addr) -{ - unsigned long mfn = PFN_DOWN(dma_addr); - unsigned long pfn = mfn_to_local_pfn(mfn); - phys_addr_t paddr; - - /* If the address is outside our domain, it CAN - * have the same virtual address as another address - * in our domain. Therefore _only_ check address within our domain. - */ - if (pfn_valid(pfn)) { - paddr = PFN_PHYS(pfn); - return paddr >= virt_to_phys(xen_io_tlb_start) && - paddr < virt_to_phys(xen_io_tlb_end); - } - return 0; -} - -static int max_dma_bits = 32; - -static int -xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs) -{ - int i, rc; - int dma_bits; - - dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT; - - i = 0; - do { - int slabs = min(nslabs - i, (unsigned long)IO_TLB_SEGSIZE); - - do { - rc = xen_create_contiguous_region( - (unsigned long)buf + (i << IO_TLB_SHIFT), - get_order(slabs << IO_TLB_SHIFT), - dma_bits); - } while (rc && dma_bits++ < max_dma_bits); - if (rc) - return rc; - - i += slabs; - } while (i < nslabs); - return 0; -} - -void __init xen_swiotlb_init(int verbose) -{ - unsigned long bytes; - int rc; - - xen_io_tlb_nslabs = (64 * 1024 * 1024 >> IO_TLB_SHIFT); - xen_io_tlb_nslabs = ALIGN(xen_io_tlb_nslabs, IO_TLB_SEGSIZE); - - bytes = xen_io_tlb_nslabs << IO_TLB_SHIFT; - - /* - * Get IO TLB memory from any location. - */ - xen_io_tlb_start = alloc_bootmem(bytes); - if (!xen_io_tlb_start) - panic("Cannot allocate SWIOTLB buffer"); - - xen_io_tlb_end = xen_io_tlb_start + bytes; - /* - * And replace that memory with pages under 4GB. - */ - rc = xen_swiotlb_fixup(xen_io_tlb_start, - bytes, - xen_io_tlb_nslabs); - if (rc) - goto error; - - start_dma_addr = xen_virt_to_bus(xen_io_tlb_start); - swiotlb_init_with_tbl(xen_io_tlb_start, xen_io_tlb_nslabs, verbose); - - return; -error: - panic("DMA(%d): Failed to exchange pages allocated for DMA with Xen! "\ - "We either don't have the permission or you do not have enough"\ - "free memory under 4GB!\n", rc); -} - -void * -xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size, - dma_addr_t *dma_handle, gfp_t flags) -{ - void *ret; - int order = get_order(size); - u64 dma_mask = DMA_BIT_MASK(32); - unsigned long vstart; - - /* - * Ignore region specifiers - the kernel's ideas of - * pseudo-phys memory layout has nothing to do with the - * machine physical layout. We can't allocate highmem - * because we can't return a pointer to it. - */ - flags &= ~(__GFP_DMA | __GFP_HIGHMEM); - - if (dma_alloc_from_coherent(hwdev, size, dma_handle, &ret)) - return ret; - - vstart = __get_free_pages(flags, order); - ret = (void *)vstart; - - if (hwdev && hwdev->coherent_dma_mask) - dma_mask = dma_alloc_coherent_mask(hwdev, flags); - - if (ret) { - if (xen_create_contiguous_region(vstart, order, - fls64(dma_mask)) != 0) { - free_pages(vstart, order); - return NULL; - } - memset(ret, 0, size); - *dma_handle = virt_to_machine(ret).maddr; - } - return ret; -} -EXPORT_SYMBOL_GPL(xen_swiotlb_alloc_coherent); - -void -xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr, - dma_addr_t dev_addr) -{ - int order = get_order(size); - - if (dma_release_from_coherent(hwdev, order, vaddr)) - return; - - xen_destroy_contiguous_region((unsigned long)vaddr, order); - free_pages((unsigned long)vaddr, order); -} -EXPORT_SYMBOL_GPL(xen_swiotlb_free_coherent); - - -/* - * Map a single buffer of the indicated size for DMA in streaming mode. The - * physical address to use is returned. - * - * Once the device is given the dma address, the device owns this memory until - * either xen_swiotlb_unmap_page or xen_swiotlb_dma_sync_single is performed. - */ -dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page, - unsigned long offset, size_t size, - enum dma_data_direction dir, - struct dma_attrs *attrs) -{ - phys_addr_t phys = page_to_phys(page) + offset; - dma_addr_t dev_addr = xen_phys_to_bus(phys); - void *map; - - BUG_ON(dir == DMA_NONE); - /* - * If the address happens to be in the device's DMA window, - * we can safely return the device addr and not worry about bounce - * buffering it. - */ - if (dma_capable(dev, dev_addr, size) && - !range_straddles_page_boundary(phys, size) && !swiotlb_force) - return dev_addr; - - /* - * Oh well, have to allocate and map a bounce buffer. - */ - map = swiotlb_tbl_map_single(dev, start_dma_addr, phys, size, dir); - if (!map) - return DMA_ERROR_CODE; - - dev_addr = xen_virt_to_bus(map); - - /* - * Ensure that the address returned is DMA'ble - */ - if (!dma_capable(dev, dev_addr, size)) - panic("map_single: bounce buffer is not DMA'ble"); - - return dev_addr; -} -EXPORT_SYMBOL_GPL(xen_swiotlb_map_page); - -/* - * Unmap a single streaming mode DMA translation. The dma_addr and size must - * match what was provided for in a previous xen_swiotlb_map_page call. All - * other usages are undefined. - * - * After this call, reads by the cpu to the buffer are guaranteed to see - * whatever the device wrote there. - */ -static void xen_unmap_single(struct device *hwdev, dma_addr_t dev_addr, - size_t size, enum dma_data_direction dir) -{ - phys_addr_t paddr = xen_bus_to_phys(dev_addr); - - BUG_ON(dir == DMA_NONE); - - /* NOTE: We use dev_addr here, not paddr! */ - if (is_xen_swiotlb_buffer(dev_addr)) { - swiotlb_tbl_unmap_single(hwdev, phys_to_virt(paddr), size, dir); - return; - } - - if (dir != DMA_FROM_DEVICE) - return; - - /* - * phys_to_virt doesn't work with hihgmem page but we could - * call dma_mark_clean() with hihgmem page here. However, we - * are fine since dma_mark_clean() is null on POWERPC. We can - * make dma_mark_clean() take a physical address if necessary. - */ - dma_mark_clean(phys_to_virt(paddr), size); -} - -void xen_swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr, - size_t size, enum dma_data_direction dir, - struct dma_attrs *attrs) -{ - xen_unmap_single(hwdev, dev_addr, size, dir); -} -EXPORT_SYMBOL_GPL(xen_swiotlb_unmap_page); - -/* - * Make physical memory consistent for a single streaming mode DMA translation - * after a transfer. - * - * If you perform a xen_swiotlb_map_page() but wish to interrogate the buffer - * using the cpu, yet do not wish to teardown the dma mapping, you must - * call this function before doing so. At the next point you give the dma - * address back to the card, you must first perform a - * xen_swiotlb_dma_sync_for_device, and then the device again owns the buffer - */ -static void -xen_swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr, - size_t size, enum dma_data_direction dir, - enum dma_sync_target target) -{ - phys_addr_t paddr = xen_bus_to_phys(dev_addr); - - BUG_ON(dir == DMA_NONE); - - /* NOTE: We use dev_addr here, not paddr! */ - if (is_xen_swiotlb_buffer(dev_addr)) { - swiotlb_tbl_sync_single(hwdev, phys_to_virt(paddr), size, dir, - target); - return; - } - - if (dir != DMA_FROM_DEVICE) - return; - - dma_mark_clean(phys_to_virt(paddr), size); -} - -void -xen_swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr, - size_t size, enum dma_data_direction dir) -{ - xen_swiotlb_sync_single(hwdev, dev_addr, size, dir, SYNC_FOR_CPU); -} -EXPORT_SYMBOL_GPL(xen_swiotlb_sync_single_for_cpu); - -void -xen_swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr, - size_t size, enum dma_data_direction dir) -{ - xen_swiotlb_sync_single(hwdev, dev_addr, size, dir, SYNC_FOR_DEVICE); -} -EXPORT_SYMBOL_GPL(xen_swiotlb_sync_single_for_device); - -/* - * Map a set of buffers described by scatterlist in streaming mode for DMA. - * This is the scatter-gather version of the above xen_swiotlb_map_page - * interface. Here the scatter gather list elements are each tagged with the - * appropriate dma address and length. They are obtained via - * sg_dma_{address,length}(SG). - * - * NOTE: An implementation may be able to use a smaller number of - * DMA address/length pairs than there are SG table elements. - * (for example via virtual mapping capabilities) - * The routine returns the number of addr/length pairs actually - * used, at most nents. - * - * Device ownership issues as mentioned above for xen_swiotlb_map_page are the - * same here. - */ -int -xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, - int nelems, enum dma_data_direction dir, - struct dma_attrs *attrs) -{ - struct scatterlist *sg; - int i; - - BUG_ON(dir == DMA_NONE); - - for_each_sg(sgl, sg, nelems, i) { - phys_addr_t paddr = sg_phys(sg); - dma_addr_t dev_addr = xen_phys_to_bus(paddr); - - if (swiotlb_force || - !dma_capable(hwdev, dev_addr, sg->length) || - range_straddles_page_boundary(paddr, sg->length)) { - void *map = swiotlb_tbl_map_single(hwdev, - start_dma_addr, - sg_phys(sg), - sg->length, dir); - if (!map) { - /* Don't panic here, we expect map_sg users - to do proper error handling. */ - xen_swiotlb_unmap_sg_attrs(hwdev, sgl, i, dir, - attrs); - sgl[0].dma_length = 0; - return DMA_ERROR_CODE; - } - sg->dma_address = xen_virt_to_bus(map); - } else - sg->dma_address = dev_addr; - sg->dma_length = sg->length; - } - return nelems; -} -EXPORT_SYMBOL_GPL(xen_swiotlb_map_sg_attrs); - -int -xen_swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, - enum dma_data_direction dir) -{ - return xen_swiotlb_map_sg_attrs(hwdev, sgl, nelems, dir, NULL); -} -EXPORT_SYMBOL_GPL(xen_swiotlb_map_sg); - -/* - * Unmap a set of streaming mode DMA translations. Again, cpu read rules - * concerning calls here are the same as for swiotlb_unmap_page() above. - */ -void -xen_swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl, - int nelems, enum dma_data_direction dir, - struct dma_attrs *attrs) -{ - struct scatterlist *sg; - int i; - - BUG_ON(dir == DMA_NONE); - - for_each_sg(sgl, sg, nelems, i) - xen_unmap_single(hwdev, sg->dma_address, sg->dma_length, dir); - -} -EXPORT_SYMBOL_GPL(xen_swiotlb_unmap_sg_attrs); - -void -xen_swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, - enum dma_data_direction dir) -{ - return xen_swiotlb_unmap_sg_attrs(hwdev, sgl, nelems, dir, NULL); -} -EXPORT_SYMBOL_GPL(xen_swiotlb_unmap_sg); - -/* - * Make physical memory consistent for a set of streaming mode DMA translations - * after a transfer. - * - * The same as swiotlb_sync_single_* but for a scatter-gather list, same rules - * and usage. - */ -static void -xen_swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sgl, - int nelems, enum dma_data_direction dir, - enum dma_sync_target target) -{ - struct scatterlist *sg; - int i; - - for_each_sg(sgl, sg, nelems, i) - xen_swiotlb_sync_single(hwdev, sg->dma_address, - sg->dma_length, dir, target); -} - -void -xen_swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg, - int nelems, enum dma_data_direction dir) -{ - xen_swiotlb_sync_sg(hwdev, sg, nelems, dir, SYNC_FOR_CPU); -} -EXPORT_SYMBOL_GPL(xen_swiotlb_sync_sg_for_cpu); - -void -xen_swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg, - int nelems, enum dma_data_direction dir) -{ - xen_swiotlb_sync_sg(hwdev, sg, nelems, dir, SYNC_FOR_DEVICE); -} -EXPORT_SYMBOL_GPL(xen_swiotlb_sync_sg_for_device); - -int -xen_swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr) -{ - return !dma_addr; -} -EXPORT_SYMBOL_GPL(xen_swiotlb_dma_mapping_error); - -/* - * Return whether the given device DMA address mask can be supported - * properly. For example, if your device can only drive the low 24-bits - * during bus mastering, then you would pass 0x00ffffff as the mask to - * this function. - */ -int -xen_swiotlb_dma_supported(struct device *hwdev, u64 mask) -{ - return xen_virt_to_bus(xen_io_tlb_end - 1) <= mask; -} -EXPORT_SYMBOL_GPL(xen_swiotlb_dma_supported); diff --git a/trunk/fs/afs/internal.h b/trunk/fs/afs/internal.h index c6c93f180707..8679089ce9a1 100644 --- a/trunk/fs/afs/internal.h +++ b/trunk/fs/afs/internal.h @@ -752,6 +752,12 @@ extern unsigned afs_debug; #define dbgprintk(FMT,...) \ printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) +/* make sure we maintain the format strings, even when debugging is disabled */ +static inline __attribute__((format(printf,1,2))) +void _dbprintk(const char *fmt, ...) +{ +} + #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) @@ -786,9 +792,9 @@ do { \ } while (0) #else -#define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) -#define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) -#define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) +#define _enter(FMT,...) _dbprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) +#define _leave(FMT,...) _dbprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) +#define _debug(FMT,...) _dbprintk(" "FMT ,##__VA_ARGS__) #endif /* diff --git a/trunk/fs/cachefiles/internal.h b/trunk/fs/cachefiles/internal.h index bd6bc1bde2d7..a8cd821226da 100644 --- a/trunk/fs/cachefiles/internal.h +++ b/trunk/fs/cachefiles/internal.h @@ -267,6 +267,13 @@ do { \ #define dbgprintk(FMT, ...) \ printk(KERN_DEBUG "[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__) +/* make sure we maintain the format strings, even when debugging is disabled */ +static inline void _dbprintk(const char *fmt, ...) + __attribute__((format(printf, 1, 2))); +static inline void _dbprintk(const char *fmt, ...) +{ +} + #define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__) #define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__) #define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__) @@ -297,9 +304,9 @@ do { \ } while (0) #else -#define _enter(FMT, ...) no_printk("==> %s("FMT")", __func__, ##__VA_ARGS__) -#define _leave(FMT, ...) no_printk("<== %s()"FMT"", __func__, ##__VA_ARGS__) -#define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__) +#define _enter(FMT, ...) _dbprintk("==> %s("FMT")", __func__, ##__VA_ARGS__) +#define _leave(FMT, ...) _dbprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__) +#define _debug(FMT, ...) _dbprintk(FMT, ##__VA_ARGS__) #endif #if 1 /* defined(__KDEBUGALL) */ diff --git a/trunk/fs/cifs/README b/trunk/fs/cifs/README index a7081eeeb85d..7099a526f775 100644 --- a/trunk/fs/cifs/README +++ b/trunk/fs/cifs/README @@ -301,6 +301,16 @@ A partial list of the supported mount options follows: gid Set the default gid for inodes (similar to above). file_mode If CIFS Unix extensions are not supported by the server this overrides the default mode for file inodes. + fsc Enable local disk caching using FS-Cache (off by default). This + option could be useful to improve performance on a slow link, + heavily loaded server and/or network where reading from the + disk is faster than reading from the server (over the network). + This could also impact scalability positively as the + number of calls to the server are reduced. However, local + caching is not suitable for all workloads for e.g. read-once + type workloads. So, you need to consider carefully your + workload/scenario before using this option. Currently, local + disk caching is functional for CIFS files opened as read-only. dir_mode If CIFS Unix extensions are not supported by the server this overrides the default mode for directory inodes. port attempt to contact the server on this tcp port, before diff --git a/trunk/fs/file_table.c b/trunk/fs/file_table.c index edecd36fed9b..2fc3b3c08911 100644 --- a/trunk/fs/file_table.c +++ b/trunk/fs/file_table.c @@ -230,6 +230,15 @@ static void __fput(struct file *file) might_sleep(); fsnotify_close(file); + + /* + * fsnotify_create_event may have taken one or more references on this + * file. If it did so it left one reference for us to drop to make sure + * its calls to fput could not prematurely destroy the file. + */ + if (atomic_long_read(&file->f_count)) + return fput(file); + /* * The function eventpoll_release() should be the first called * in the file cleanup chain. diff --git a/trunk/fs/fs-writeback.c b/trunk/fs/fs-writeback.c index 7d9d06ba184b..2f76c4a081a2 100644 --- a/trunk/fs/fs-writeback.c +++ b/trunk/fs/fs-writeback.c @@ -68,7 +68,7 @@ int nr_pdflush_threads; */ int writeback_in_progress(struct backing_dev_info *bdi) { - return test_bit(BDI_writeback_running, &bdi->state); + return !list_empty(&bdi->work_list); } static void bdi_queue_work(struct backing_dev_info *bdi, @@ -249,18 +249,10 @@ static void move_expired_inodes(struct list_head *delaying_queue, /* * Queue all expired dirty inodes for io, eldest first. - * Before - * newly dirtied b_dirty b_io b_more_io - * =============> gf edc BA - * After - * newly dirtied b_dirty b_io b_more_io - * =============> g fBAedc - * | - * +--> dequeue for IO */ static void queue_io(struct bdi_writeback *wb, unsigned long *older_than_this) { - list_splice_init(&wb->b_more_io, &wb->b_io); + list_splice_init(&wb->b_more_io, wb->b_io.prev); move_expired_inodes(&wb->b_dirty, &wb->b_io, older_than_this); } @@ -371,35 +363,62 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) spin_lock(&inode_lock); inode->i_state &= ~I_SYNC; if (!(inode->i_state & I_FREEING)) { - if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { + if ((inode->i_state & I_DIRTY_PAGES) && wbc->for_kupdate) { + /* + * More pages get dirtied by a fast dirtier. + */ + goto select_queue; + } else if (inode->i_state & I_DIRTY) { + /* + * At least XFS will redirty the inode during the + * writeback (delalloc) and on io completion (isize). + */ + redirty_tail(inode); + } else if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { /* * We didn't write back all the pages. nfs_writepages() - * sometimes bales out without doing anything. + * sometimes bales out without doing anything. Redirty + * the inode; Move it from b_io onto b_more_io/b_dirty. */ - inode->i_state |= I_DIRTY_PAGES; - if (wbc->nr_to_write <= 0) { + /* + * akpm: if the caller was the kupdate function we put + * this inode at the head of b_dirty so it gets first + * consideration. Otherwise, move it to the tail, for + * the reasons described there. I'm not really sure + * how much sense this makes. Presumably I had a good + * reasons for doing it this way, and I'd rather not + * muck with it at present. + */ + if (wbc->for_kupdate) { /* - * slice used up: queue for next turn + * For the kupdate function we move the inode + * to b_more_io so it will get more writeout as + * soon as the queue becomes uncongested. */ - requeue_io(inode); + inode->i_state |= I_DIRTY_PAGES; +select_queue: + if (wbc->nr_to_write <= 0) { + /* + * slice used up: queue for next turn + */ + requeue_io(inode); + } else { + /* + * somehow blocked: retry later + */ + redirty_tail(inode); + } } else { /* - * Writeback blocked by something other than - * congestion. Delay the inode for some time to - * avoid spinning on the CPU (100% iowait) - * retrying writeback of the dirty page/inode - * that cannot be performed immediately. + * Otherwise fully redirty the inode so that + * other inodes on this superblock will get some + * writeout. Otherwise heavy writing to one + * file would indefinitely suspend writeout of + * all the other files. */ + inode->i_state |= I_DIRTY_PAGES; redirty_tail(inode); } - } else if (inode->i_state & I_DIRTY) { - /* - * Filesystems can dirty the inode during writeback - * operations, such as delayed allocation during - * submission or metadata updates after data IO - * completion. - */ - redirty_tail(inode); } else if (atomic_read(&inode->i_count)) { /* * The inode is clean, inuse @@ -571,7 +590,7 @@ static inline bool over_bground_thresh(void) { unsigned long background_thresh, dirty_thresh; - global_dirty_limits(&background_thresh, &dirty_thresh); + get_dirty_limits(&background_thresh, &dirty_thresh, NULL, NULL); return (global_page_state(NR_FILE_DIRTY) + global_page_state(NR_UNSTABLE_NFS) >= background_thresh); @@ -740,7 +759,6 @@ long wb_do_writeback(struct bdi_writeback *wb, int force_wait) struct wb_writeback_work *work; long wrote = 0; - set_bit(BDI_writeback_running, &wb->bdi->state); while ((work = get_next_work_item(bdi)) != NULL) { /* * Override sync mode, in case we must wait for completion @@ -767,7 +785,6 @@ long wb_do_writeback(struct bdi_writeback *wb, int force_wait) * Check for periodic writeback, kupdated() style */ wrote += wb_check_old_data_flush(wb); - clear_bit(BDI_writeback_running, &wb->bdi->state); return wrote; } diff --git a/trunk/fs/fscache/internal.h b/trunk/fs/fscache/internal.h index f6aad48d38a8..6a026441c5a6 100644 --- a/trunk/fs/fscache/internal.h +++ b/trunk/fs/fscache/internal.h @@ -321,11 +321,17 @@ void fscache_put_context(struct fscache_cookie *cookie, void *context) #define dbgprintk(FMT, ...) \ printk(KERN_DEBUG "[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__) +/* make sure we maintain the format strings, even when debugging is disabled */ +static inline __attribute__((format(printf, 1, 2))) +void _dbprintk(const char *fmt, ...) +{ +} + #define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__) #define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__) #define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__) -#define kjournal(FMT, ...) no_printk(FMT, ##__VA_ARGS__) +#define kjournal(FMT, ...) _dbprintk(FMT, ##__VA_ARGS__) #ifdef __KDEBUG #define _enter(FMT, ...) kenter(FMT, ##__VA_ARGS__) @@ -352,9 +358,9 @@ do { \ } while (0) #else -#define _enter(FMT, ...) no_printk("==> %s("FMT")", __func__, ##__VA_ARGS__) -#define _leave(FMT, ...) no_printk("<== %s()"FMT"", __func__, ##__VA_ARGS__) -#define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__) +#define _enter(FMT, ...) _dbprintk("==> %s("FMT")", __func__, ##__VA_ARGS__) +#define _leave(FMT, ...) _dbprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__) +#define _debug(FMT, ...) _dbprintk(FMT, ##__VA_ARGS__) #endif /* diff --git a/trunk/fs/nfs/callback.c b/trunk/fs/nfs/callback.c index e17b49e2eabd..36dfdae95123 100644 --- a/trunk/fs/nfs/callback.c +++ b/trunk/fs/nfs/callback.c @@ -45,7 +45,7 @@ unsigned short nfs_callback_tcpport; unsigned short nfs_callback_tcpport6; #define NFS_CALLBACK_MAXPORTNR (65535U) -static int param_set_portnr(const char *val, const struct kernel_param *kp) +static int param_set_portnr(const char *val, struct kernel_param *kp) { unsigned long num; int ret; @@ -58,10 +58,11 @@ static int param_set_portnr(const char *val, const struct kernel_param *kp) *((unsigned int *)kp->arg) = num; return 0; } -static struct kernel_param_ops param_ops_portnr = { - .set = param_set_portnr, - .get = param_get_uint, -}; + +static int param_get_portnr(char *buffer, struct kernel_param *kp) +{ + return param_get_uint(buffer, kp); +} #define param_check_portnr(name, p) __param_check(name, p, unsigned int); module_param_named(callback_tcpport, nfs_callback_set_tcpport, portnr, 0644); diff --git a/trunk/fs/notify/fanotify/fanotify.c b/trunk/fs/notify/fanotify/fanotify.c index 756566fe8449..eb8f73c9c131 100644 --- a/trunk/fs/notify/fanotify/fanotify.c +++ b/trunk/fs/notify/fanotify/fanotify.c @@ -17,9 +17,9 @@ static bool should_merge(struct fsnotify_event *old, struct fsnotify_event *new) old->data_type == new->data_type && old->tgid == new->tgid) { switch (old->data_type) { - case (FSNOTIFY_EVENT_PATH): - if ((old->path.mnt == new->path.mnt) && - (old->path.dentry == new->path.dentry)) + case (FSNOTIFY_EVENT_FILE): + if ((old->file->f_path.mnt == new->file->f_path.mnt) && + (old->file->f_path.dentry == new->file->f_path.dentry)) return true; case (FSNOTIFY_EVENT_NONE): return true; @@ -174,7 +174,7 @@ static bool fanotify_should_send_event(struct fsnotify_group *group, return false; /* if we don't have enough info to send an event to userspace say no */ - if (data_type != FSNOTIFY_EVENT_PATH) + if (data_type != FSNOTIFY_EVENT_FILE) return false; if (inode_mark && vfsmnt_mark) { diff --git a/trunk/fs/notify/fanotify/fanotify_user.c b/trunk/fs/notify/fanotify/fanotify_user.c index 032b837fcd11..25a3b4dfcf61 100644 --- a/trunk/fs/notify/fanotify/fanotify_user.c +++ b/trunk/fs/notify/fanotify/fanotify_user.c @@ -65,7 +65,7 @@ static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event) if (client_fd < 0) return client_fd; - if (event->data_type != FSNOTIFY_EVENT_PATH) { + if (event->data_type != FSNOTIFY_EVENT_FILE) { WARN_ON(1); put_unused_fd(client_fd); return -EINVAL; @@ -75,8 +75,8 @@ static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event) * we need a new file handle for the userspace program so it can read even if it was * originally opened O_WRONLY. */ - dentry = dget(event->path.dentry); - mnt = mntget(event->path.mnt); + dentry = dget(event->file->f_path.dentry); + mnt = mntget(event->file->f_path.mnt); /* it's possible this event was an overflow event. in that case dentry and mnt * are NULL; That's fine, just don't call dentry open */ if (dentry && mnt) diff --git a/trunk/fs/notify/fsnotify.c b/trunk/fs/notify/fsnotify.c index 3970392b2722..4d2a82c1ceb1 100644 --- a/trunk/fs/notify/fsnotify.c +++ b/trunk/fs/notify/fsnotify.c @@ -84,7 +84,7 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode) } /* Notify this dentry's parent about a child's events. */ -void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) +void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask) { struct dentry *parent; struct inode *p_inode; @@ -92,7 +92,7 @@ void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) bool should_update_children = false; if (!dentry) - dentry = path->dentry; + dentry = file->f_path.dentry; if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED)) return; @@ -124,8 +124,8 @@ void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) * specifies these are events which came from a child. */ mask |= FS_EVENT_ON_CHILD; - if (path) - fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH, + if (file) + fsnotify(p_inode, mask, file, FSNOTIFY_EVENT_FILE, dentry->d_name.name, 0); else fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE, @@ -217,8 +217,8 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, /* global tests shouldn't care about events on child only the specific event */ __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); - if (data_is == FSNOTIFY_EVENT_PATH) - mnt = ((struct path *)data)->mnt; + if (data_is == FSNOTIFY_EVENT_FILE) + mnt = ((struct file *)data)->f_path.mnt; else mnt = NULL; diff --git a/trunk/fs/notify/inotify/inotify_fsnotify.c b/trunk/fs/notify/inotify/inotify_fsnotify.c index a91b69a6a291..5e73eeb2c697 100644 --- a/trunk/fs/notify/inotify/inotify_fsnotify.c +++ b/trunk/fs/notify/inotify/inotify_fsnotify.c @@ -52,9 +52,9 @@ static bool event_compare(struct fsnotify_event *old, struct fsnotify_event *new !strcmp(old->file_name, new->file_name)) return true; break; - case (FSNOTIFY_EVENT_PATH): - if ((old->path.mnt == new->path.mnt) && - (old->path.dentry == new->path.dentry)) + case (FSNOTIFY_EVENT_FILE): + if ((old->file->f_path.mnt == new->file->f_path.mnt) && + (old->file->f_path.dentry == new->file->f_path.dentry)) return true; break; case (FSNOTIFY_EVENT_NONE): @@ -147,10 +147,10 @@ static bool inotify_should_send_event(struct fsnotify_group *group, struct inode __u32 mask, void *data, int data_type) { if ((inode_mark->mask & FS_EXCL_UNLINK) && - (data_type == FSNOTIFY_EVENT_PATH)) { - struct path *path = data; + (data_type == FSNOTIFY_EVENT_FILE)) { + struct file *file = data; - if (d_unlinked(path->dentry)) + if (d_unlinked(file->f_path.dentry)) return false; } diff --git a/trunk/fs/notify/notification.c b/trunk/fs/notify/notification.c index f39260f8f865..d6c435adc7a2 100644 --- a/trunk/fs/notify/notification.c +++ b/trunk/fs/notify/notification.c @@ -31,6 +31,7 @@ * allocated and used. */ +#include #include #include #include @@ -89,8 +90,8 @@ void fsnotify_put_event(struct fsnotify_event *event) if (atomic_dec_and_test(&event->refcnt)) { pr_debug("%s: event=%p\n", __func__, event); - if (event->data_type == FSNOTIFY_EVENT_PATH) - path_put(&event->path); + if (event->data_type == FSNOTIFY_EVENT_FILE) + fput(event->file); BUG_ON(!list_empty(&event->private_data_list)); @@ -375,8 +376,8 @@ struct fsnotify_event *fsnotify_clone_event(struct fsnotify_event *old_event) } } event->tgid = get_pid(old_event->tgid); - if (event->data_type == FSNOTIFY_EVENT_PATH) - path_get(&event->path); + if (event->data_type == FSNOTIFY_EVENT_FILE) + get_file(event->file); return event; } @@ -423,11 +424,22 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, event->data_type = data_type; switch (data_type) { - case FSNOTIFY_EVENT_PATH: { - struct path *path = data; - event->path.dentry = path->dentry; - event->path.mnt = path->mnt; - path_get(&event->path); + case FSNOTIFY_EVENT_FILE: { + event->file = data; + /* + * if this file is about to disappear hold an extra reference + * until we return to __fput so we don't have to worry about + * future get/put destroying the file under us or generating + * additional events. Notice that we change f_mode without + * holding f_lock. This is safe since this is the only possible + * reference to this object in the kernel (it was about to be + * freed, remember?) + */ + if (!atomic_long_read(&event->file->f_count)) { + event->file->f_mode |= FMODE_NONOTIFY; + get_file(event->file); + } + get_file(event->file); break; } case FSNOTIFY_EVENT_INODE: @@ -435,8 +447,7 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, break; case FSNOTIFY_EVENT_NONE: event->inode = NULL; - event->path.dentry = NULL; - event->path.mnt = NULL; + event->file = NULL; break; default: BUG(); diff --git a/trunk/include/acpi/platform/aclinux.h b/trunk/include/acpi/platform/aclinux.h index 103f08aca764..e5039a2856f8 100644 --- a/trunk/include/acpi/platform/aclinux.h +++ b/trunk/include/acpi/platform/aclinux.h @@ -148,17 +148,13 @@ static inline void *acpi_os_acquire_object(acpi_cache_t * cache) #define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a) #define ACPI_FREE(a) kfree(a) -#ifndef CONFIG_PREEMPT -/* - * Used within ACPICA to show where it is safe to preempt execution - * when CONFIG_PREEMPT=n - */ +/* Used within ACPICA to show where it is safe to preempt execution */ +#include #define ACPI_PREEMPTION_POINT() \ do { \ - if (!irqs_disabled()) \ + if (!in_atomic_preempt_off() && !irqs_disabled()) \ cond_resched(); \ } while (0) -#endif #endif /* __KERNEL__ */ diff --git a/trunk/include/drm/drmP.h b/trunk/include/drm/drmP.h index 2a512bc0d4ab..e2a4da7d7fab 100644 --- a/trunk/include/drm/drmP.h +++ b/trunk/include/drm/drmP.h @@ -1075,6 +1075,7 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev, return ((dev->driver->driver_features & feature) ? 1 : 0); } + static inline int drm_dev_to_irq(struct drm_device *dev) { if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) @@ -1083,22 +1084,11 @@ static inline int drm_dev_to_irq(struct drm_device *dev) return dev->pdev->irq; } -static inline int drm_get_pci_domain(struct drm_device *dev) -{ - if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) - return 0; - -#ifndef __alpha__ - /* For historical reasons, drm_get_pci_domain() is busticated - * on most archs and has to remain so for userspace interface - * < 1.4, except on alpha which was right from the beginning - */ - if (dev->if_version < 0x10004) - return 0; -#endif /* __alpha__ */ - - return pci_domain_nr(dev->pdev->bus); -} +#ifdef __alpha__ +#define drm_get_pci_domain(dev) dev->hose->index +#else +#define drm_get_pci_domain(dev) 0 +#endif #if __OS_HAS_AGP static inline int drm_core_has_AGP(struct drm_device *dev) diff --git a/trunk/include/drm/drm_core.h b/trunk/include/drm/drm_core.h index 4e7523863a4b..316739036079 100644 --- a/trunk/include/drm/drm_core.h +++ b/trunk/include/drm/drm_core.h @@ -27,7 +27,7 @@ #define CORE_DATE "20060810" #define DRM_IF_MAJOR 1 -#define DRM_IF_MINOR 4 +#define DRM_IF_MINOR 3 #define CORE_MAJOR 1 #define CORE_MINOR 1 diff --git a/trunk/include/drm/drm_crtc.h b/trunk/include/drm/drm_crtc.h index c9f3cc5949a8..c707270bff5a 100644 --- a/trunk/include/drm/drm_crtc.h +++ b/trunk/include/drm/drm_crtc.h @@ -189,16 +189,49 @@ enum subpixel_order { */ struct drm_display_info { char name[DRM_DISPLAY_INFO_LEN]; - + /* Input info */ + bool serration_vsync; + bool sync_on_green; + bool composite_sync; + bool separate_syncs; + bool blank_to_black; + unsigned char video_level; + bool digital; /* Physical size */ unsigned int width_mm; unsigned int height_mm; + /* Display parameters */ + unsigned char gamma; /* FIXME: storage format */ + bool gtf_supported; + bool standard_color; + enum { + monochrome = 0, + rgb, + other, + unknown, + } display_type; + bool active_off_supported; + bool suspend_supported; + bool standby_supported; + + /* Color info FIXME: storage format */ + unsigned short redx, redy; + unsigned short greenx, greeny; + unsigned short bluex, bluey; + unsigned short whitex, whitey; + /* Clock limits FIXME: storage format */ unsigned int min_vfreq, max_vfreq; unsigned int min_hfreq, max_hfreq; unsigned int pixel_clock; + /* White point indices FIXME: storage format */ + unsigned int wpx1, wpy1; + unsigned int wpgamma1; + unsigned int wpx2, wpy2; + unsigned int wpgamma2; + enum subpixel_order subpixel_order; char *raw_edid; /* if any */ @@ -309,7 +342,7 @@ struct drm_crtc_funcs { /* Set gamma on the CRTC */ void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, - uint32_t start, uint32_t size); + uint32_t size); /* Object destroy routine */ void (*destroy)(struct drm_crtc *crtc); diff --git a/trunk/include/drm/drm_edid.h b/trunk/include/drm/drm_edid.h index 5881fad91faa..39e2cc5c7e66 100644 --- a/trunk/include/drm/drm_edid.h +++ b/trunk/include/drm/drm_edid.h @@ -28,12 +28,6 @@ #define EDID_LENGTH 128 #define DDC_ADDR 0x50 -#define CEA_EXT 0x02 -#define VTB_EXT 0x10 -#define DI_EXT 0x40 -#define LS_EXT 0x50 -#define MI_EXT 0x60 - struct est_timings { u8 t1; u8 t2; diff --git a/trunk/include/linux/backing-dev.h b/trunk/include/linux/backing-dev.h index 35b00746c712..7628219e5386 100644 --- a/trunk/include/linux/backing-dev.h +++ b/trunk/include/linux/backing-dev.h @@ -31,7 +31,6 @@ enum bdi_state { BDI_async_congested, /* The async (write) queue is getting full */ BDI_sync_congested, /* The sync queue is getting full */ BDI_registered, /* bdi_register() was done */ - BDI_writeback_running, /* Writeback is in progress */ BDI_unused, /* Available bits start here */ }; diff --git a/trunk/include/linux/blk_types.h b/trunk/include/linux/blk_types.h index ca83a97c9715..53691774d34e 100644 --- a/trunk/include/linux/blk_types.h +++ b/trunk/include/linux/blk_types.h @@ -150,7 +150,6 @@ enum rq_flag_bits { __REQ_FLUSH, /* request for cache flush */ __REQ_IO_STAT, /* account I/O stat */ __REQ_MIXED_MERGE, /* merge of different types, fail separately */ - __REQ_SECURE, /* secure discard (used with __REQ_DISCARD) */ __REQ_NR_BITS, /* stops here */ }; @@ -191,6 +190,5 @@ enum rq_flag_bits { #define REQ_FLUSH (1 << __REQ_FLUSH) #define REQ_IO_STAT (1 << __REQ_IO_STAT) #define REQ_MIXED_MERGE (1 << __REQ_MIXED_MERGE) -#define REQ_SECURE (1 << __REQ_SECURE) #endif /* __LINUX_BLK_TYPES_H */ diff --git a/trunk/include/linux/blkdev.h b/trunk/include/linux/blkdev.h index 2c54906f678f..89c855c5655c 100644 --- a/trunk/include/linux/blkdev.h +++ b/trunk/include/linux/blkdev.h @@ -389,7 +389,6 @@ struct request_queue #define QUEUE_FLAG_DISCARD 16 /* supports DISCARD */ #define QUEUE_FLAG_NOXMERGES 17 /* No extended merges */ #define QUEUE_FLAG_ADD_RANDOM 18 /* Contributes to random pool */ -#define QUEUE_FLAG_SECDISCARD 19 /* supports SECDISCARD */ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_CLUSTER) | \ @@ -525,8 +524,6 @@ enum { #define blk_queue_stackable(q) \ test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags) #define blk_queue_discard(q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags) -#define blk_queue_secdiscard(q) (blk_queue_discard(q) && \ - test_bit(QUEUE_FLAG_SECDISCARD, &(q)->queue_flags)) #define blk_noretry_request(rq) \ ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ @@ -921,12 +918,10 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt, } enum{ BLKDEV_WAIT, /* wait for completion */ - BLKDEV_BARRIER, /* issue request with barrier */ - BLKDEV_SECURE, /* secure discard */ + BLKDEV_BARRIER, /*issue request with barrier */ }; #define BLKDEV_IFL_WAIT (1 << BLKDEV_WAIT) #define BLKDEV_IFL_BARRIER (1 << BLKDEV_BARRIER) -#define BLKDEV_IFL_SECURE (1 << BLKDEV_SECURE) extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *, unsigned long); extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector, diff --git a/trunk/include/linux/device-mapper.h b/trunk/include/linux/device-mapper.h index 2970022faa63..1381cd97b4ed 100644 --- a/trunk/include/linux/device-mapper.h +++ b/trunk/include/linux/device-mapper.h @@ -22,7 +22,7 @@ typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; union map_info { void *ptr; unsigned long long ll; - unsigned target_request_nr; + unsigned flush_request; }; /* @@ -174,18 +174,12 @@ struct dm_target { * A number of zero-length barrier requests that will be submitted * to the target for the purpose of flushing cache. * - * The request number will be placed in union map_info->target_request_nr. + * The request number will be placed in union map_info->flush_request. * It is a responsibility of the target driver to remap these requests * to the real underlying devices. */ unsigned num_flush_requests; - /* - * The number of discard requests that will be submitted to the - * target. map_info->request_nr is used just like num_flush_requests. - */ - unsigned num_discard_requests; - /* target specific data */ void *private; @@ -398,12 +392,6 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size); #define dm_array_too_big(fixed, obj, num) \ ((num) > (UINT_MAX - (fixed)) / (obj)) -/* - * Sector offset taken relative to the start of the target instead of - * relative to the start of the device. - */ -#define dm_target_offset(ti, sector) ((sector) - (ti)->begin) - static inline sector_t to_sector(unsigned long n) { return (n >> SECTOR_SHIFT); diff --git a/trunk/include/linux/dm-ioctl.h b/trunk/include/linux/dm-ioctl.h index 49eab360d5d4..2c445e113790 100644 --- a/trunk/include/linux/dm-ioctl.h +++ b/trunk/include/linux/dm-ioctl.h @@ -11,7 +11,6 @@ #include #define DM_DIR "mapper" /* Slashes not supported */ -#define DM_CONTROL_NODE "control" #define DM_MAX_TYPE_NAME 16 #define DM_NAME_LEN 128 #define DM_UUID_LEN 129 @@ -267,9 +266,9 @@ enum { #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) #define DM_VERSION_MAJOR 4 -#define DM_VERSION_MINOR 18 +#define DM_VERSION_MINOR 17 #define DM_VERSION_PATCHLEVEL 0 -#define DM_VERSION_EXTRA "-ioctl (2010-06-29)" +#define DM_VERSION_EXTRA "-ioctl (2010-03-05)" /* Status bits */ #define DM_READONLY_FLAG (1 << 0) /* In/Out */ diff --git a/trunk/include/linux/fs.h b/trunk/include/linux/fs.h index 7a0625e26a39..267d02630517 100644 --- a/trunk/include/linux/fs.h +++ b/trunk/include/linux/fs.h @@ -174,7 +174,6 @@ struct inodes_stat_t { */ #define DISCARD_NOBARRIER (WRITE | REQ_DISCARD) #define DISCARD_BARRIER (WRITE | REQ_DISCARD | REQ_HARDBARRIER) -#define DISCARD_SECURE (DISCARD_NOBARRIER | REQ_SECURE) #define SEL_IN 1 #define SEL_OUT 2 @@ -318,7 +317,6 @@ struct inodes_stat_t { #define BLKALIGNOFF _IO(0x12,122) #define BLKPBSZGET _IO(0x12,123) #define BLKDISCARDZEROES _IO(0x12,124) -#define BLKSECDISCARD _IO(0x12,125) #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1) /* bmap access */ diff --git a/trunk/include/linux/fsnotify.h b/trunk/include/linux/fsnotify.h index 59d0df43ff9d..e4e2204187ee 100644 --- a/trunk/include/linux/fsnotify.h +++ b/trunk/include/linux/fsnotify.h @@ -26,19 +26,18 @@ static inline void fsnotify_d_instantiate(struct dentry *dentry, } /* Notify this dentry's parent about a child's events. */ -static inline void fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) +static inline void fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask) { if (!dentry) - dentry = path->dentry; + dentry = file->f_path.dentry; - __fsnotify_parent(path, dentry, mask); + __fsnotify_parent(file, dentry, mask); } /* simple call site for access decisions */ static inline int fsnotify_perm(struct file *file, int mask) { - struct path *path = &file->f_path; - struct inode *inode = path->dentry->d_inode; + struct inode *inode = file->f_path.dentry->d_inode; __u32 fsnotify_mask = 0; if (file->f_mode & FMODE_NONOTIFY) @@ -52,7 +51,7 @@ static inline int fsnotify_perm(struct file *file, int mask) else BUG(); - return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); + return fsnotify(inode, fsnotify_mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); } /* @@ -187,16 +186,15 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) */ static inline void fsnotify_access(struct file *file) { - struct path *path = &file->f_path; - struct inode *inode = path->dentry->d_inode; + struct inode *inode = file->f_path.dentry->d_inode; __u32 mask = FS_ACCESS; if (S_ISDIR(inode->i_mode)) mask |= FS_IN_ISDIR; if (!(file->f_mode & FMODE_NONOTIFY)) { - fsnotify_parent(path, NULL, mask); - fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); + fsnotify_parent(file, NULL, mask); + fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); } } @@ -205,16 +203,15 @@ static inline void fsnotify_access(struct file *file) */ static inline void fsnotify_modify(struct file *file) { - struct path *path = &file->f_path; - struct inode *inode = path->dentry->d_inode; + struct inode *inode = file->f_path.dentry->d_inode; __u32 mask = FS_MODIFY; if (S_ISDIR(inode->i_mode)) mask |= FS_IN_ISDIR; if (!(file->f_mode & FMODE_NONOTIFY)) { - fsnotify_parent(path, NULL, mask); - fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); + fsnotify_parent(file, NULL, mask); + fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); } } @@ -223,16 +220,15 @@ static inline void fsnotify_modify(struct file *file) */ static inline void fsnotify_open(struct file *file) { - struct path *path = &file->f_path; - struct inode *inode = path->dentry->d_inode; + struct inode *inode = file->f_path.dentry->d_inode; __u32 mask = FS_OPEN; if (S_ISDIR(inode->i_mode)) mask |= FS_IN_ISDIR; if (!(file->f_mode & FMODE_NONOTIFY)) { - fsnotify_parent(path, NULL, mask); - fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); + fsnotify_parent(file, NULL, mask); + fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); } } @@ -241,7 +237,6 @@ static inline void fsnotify_open(struct file *file) */ static inline void fsnotify_close(struct file *file) { - struct path *path = &file->f_path; struct inode *inode = file->f_path.dentry->d_inode; fmode_t mode = file->f_mode; __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; @@ -250,8 +245,8 @@ static inline void fsnotify_close(struct file *file) mask |= FS_IN_ISDIR; if (!(file->f_mode & FMODE_NONOTIFY)) { - fsnotify_parent(path, NULL, mask); - fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); + fsnotify_parent(file, NULL, mask); + fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); } } diff --git a/trunk/include/linux/fsnotify_backend.h b/trunk/include/linux/fsnotify_backend.h index ed36fb57c426..9bbfd7204b04 100644 --- a/trunk/include/linux/fsnotify_backend.h +++ b/trunk/include/linux/fsnotify_backend.h @@ -203,20 +203,20 @@ struct fsnotify_event { /* to_tell may ONLY be dereferenced during handle_event(). */ struct inode *to_tell; /* either the inode the event happened to or its parent */ /* - * depending on the event type we should have either a path or inode - * We hold a reference on path, but NOT on inode. Since we have the ref on - * the path, it may be dereferenced at any point during this object's + * depending on the event type we should have either a file or inode + * We hold a reference on file, but NOT on inode. Since we have the ref on + * the file, it may be dereferenced at any point during this object's * lifetime. That reference is dropped when this object's refcnt hits - * 0. If this event contains an inode instead of a path, the inode may + * 0. If this event contains an inode instead of a file, the inode may * ONLY be used during handle_event(). */ union { - struct path path; + struct file *file; struct inode *inode; }; /* when calling fsnotify tell it if the data is a path or inode */ #define FSNOTIFY_EVENT_NONE 0 -#define FSNOTIFY_EVENT_PATH 1 +#define FSNOTIFY_EVENT_FILE 1 #define FSNOTIFY_EVENT_INODE 2 int data_type; /* which of the above union we have */ atomic_t refcnt; /* how many groups still are using/need to send this event */ @@ -293,7 +293,7 @@ struct fsnotify_mark { /* main fsnotify call to send events */ extern int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const unsigned char *name, u32 cookie); -extern void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask); +extern void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask); extern void __fsnotify_inode_delete(struct inode *inode); extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); extern u32 fsnotify_get_cookie(void); @@ -422,7 +422,7 @@ static inline int fsnotify(struct inode *to_tell, __u32 mask, void *data, int da return 0; } -static inline void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) +static inline void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask) {} static inline void __fsnotify_inode_delete(struct inode *inode) diff --git a/trunk/include/linux/hugetlb.h b/trunk/include/linux/hugetlb.h index f479700df61b..78b4bc64c006 100644 --- a/trunk/include/linux/hugetlb.h +++ b/trunk/include/linux/hugetlb.h @@ -2,7 +2,6 @@ #define _LINUX_HUGETLB_H #include -#include struct ctl_table; struct user_struct; @@ -15,6 +14,11 @@ struct user_struct; int PageHuge(struct page *page); +static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) +{ + return vma->vm_flags & VM_HUGETLB; +} + void reset_vma_resv_huge_pages(struct vm_area_struct *vma); int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); int hugetlb_overcommit_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); @@ -43,7 +47,6 @@ int hugetlb_reserve_pages(struct inode *inode, long from, long to, struct vm_area_struct *vma, int acctflags); void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); -void __isolate_hwpoisoned_huge_page(struct page *page); extern unsigned long hugepages_treat_as_movable; extern const unsigned long hugetlb_zero, hugetlb_infinity; @@ -74,6 +77,11 @@ static inline int PageHuge(struct page *page) return 0; } +static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) +{ + return 0; +} + static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma) { } @@ -100,8 +108,6 @@ static inline void hugetlb_report_meminfo(struct seq_file *m) #define is_hugepage_only_range(mm, addr, len) 0 #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) #define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; }) -#define huge_pte_offset(mm, address) 0 -#define __isolate_hwpoisoned_huge_page(page) 0 #define hugetlb_change_protection(vma, address, end, newprot) diff --git a/trunk/include/linux/hugetlb_inline.h b/trunk/include/linux/hugetlb_inline.h deleted file mode 100644 index 6931489a5c14..000000000000 --- a/trunk/include/linux/hugetlb_inline.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _LINUX_HUGETLB_INLINE_H -#define _LINUX_HUGETLB_INLINE_H - -#ifdef CONFIG_HUGETLB_PAGE - -#include - -static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) -{ - return vma->vm_flags & VM_HUGETLB; -} - -#else - -static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) -{ - return 0; -} - -#endif - -#endif diff --git a/trunk/include/linux/i2c-mux.h b/trunk/include/linux/i2c-mux.h deleted file mode 100644 index 34536effd652..000000000000 --- a/trunk/include/linux/i2c-mux.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * i2c-mux.h - functions for the i2c-bus mux support - * - * Copyright (c) 2008-2009 Rodolfo Giometti - * Copyright (c) 2008-2009 Eurotech S.p.A. - * Michael Lawnick - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _LINUX_I2C_MUX_H -#define _LINUX_I2C_MUX_H - -#ifdef __KERNEL__ - -/* - * Called to create a i2c bus on a multiplexed bus segment. - * The mux_dev and chan_id parameters are passed to the select - * and deselect callback functions to perform hardware-specific - * mux control. - */ -struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, - void *mux_dev, u32 force_nr, u32 chan_id, - int (*select) (struct i2c_adapter *, - void *mux_dev, u32 chan_id), - int (*deselect) (struct i2c_adapter *, - void *mux_dev, u32 chan_id)); - -int i2c_del_mux_adapter(struct i2c_adapter *adap); - -#endif /* __KERNEL__ */ - -#endif /* _LINUX_I2C_MUX_H */ diff --git a/trunk/include/linux/i2c.h b/trunk/include/linux/i2c.h index 4bae0b72ed3c..38dd4025aa4e 100644 --- a/trunk/include/linux/i2c.h +++ b/trunk/include/linux/i2c.h @@ -37,7 +37,6 @@ #include /* for struct device_node */ extern struct bus_type i2c_bus_type; -extern struct device_type i2c_adapter_type; /* --- General options ------------------------------------------------ */ @@ -285,18 +284,12 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info); /* If you don't know the exact address of an I2C device, use this variant * instead, which can probe for device presence in a list of possible - * addresses. The "probe" callback function is optional. If it is provided, - * it must return 1 on successful probe, 0 otherwise. If it is not provided, - * a default probing method is used. + * addresses. */ extern struct i2c_client * i2c_new_probed_device(struct i2c_adapter *adap, struct i2c_board_info *info, - unsigned short const *addr_list, - int (*probe)(struct i2c_adapter *, unsigned short addr)); - -/* Common custom probe functions */ -extern int i2c_probe_func_quick_read(struct i2c_adapter *, unsigned short addr); + unsigned short const *addr_list); /* For devices that use several addresses, use i2c_new_dummy() to make * client handles for the extra addresses. @@ -369,7 +362,6 @@ struct i2c_adapter { char name[48]; struct completion dev_released; - struct mutex userspace_clients_lock; struct list_head userspace_clients; }; #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) @@ -384,16 +376,23 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data) dev_set_drvdata(&dev->dev, data); } -static inline int i2c_parent_is_i2c_adapter(const struct i2c_adapter *adapter) +/** + * i2c_lock_adapter - Prevent access to an I2C bus segment + * @adapter: Target I2C bus segment + */ +static inline void i2c_lock_adapter(struct i2c_adapter *adapter) { - return adapter->dev.parent != NULL - && adapter->dev.parent->bus == &i2c_bus_type - && adapter->dev.parent->type == &i2c_adapter_type; + rt_mutex_lock(&adapter->bus_lock); } -/* Adapter locking functions, exported for shared pin cases */ -void i2c_lock_adapter(struct i2c_adapter *); -void i2c_unlock_adapter(struct i2c_adapter *); +/** + * i2c_unlock_adapter - Reauthorize access to an I2C bus segment + * @adapter: Target I2C bus segment + */ +static inline void i2c_unlock_adapter(struct i2c_adapter *adapter) +{ + rt_mutex_unlock(&adapter->bus_lock); +} /*flags for the client struct: */ #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */ diff --git a/trunk/include/linux/i2c/pca954x.h b/trunk/include/linux/i2c/pca954x.h deleted file mode 100644 index 28f1f8d5ab1f..000000000000 --- a/trunk/include/linux/i2c/pca954x.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * pca954x.h - I2C multiplexer/switch support - * - * Copyright (c) 2008-2009 Rodolfo Giometti - * Copyright (c) 2008-2009 Eurotech S.p.A. - * Michael Lawnick - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -#ifndef _LINUX_I2C_PCA954X_H -#define _LINUX_I2C_PCA954X_H - -/* Platform data for the PCA954x I2C multiplexers */ - -/* Per channel initialisation data: - * @adap_id: bus number for the adapter. 0 = don't care - * @deselect_on_exit: set this entry to 1, if your H/W needs deselection - * of this channel after transaction. - * - */ -struct pca954x_platform_mode { - int adap_id; - unsigned int deselect_on_exit:1; -}; - -/* Per mux/switch data, used with i2c_register_board_info */ -struct pca954x_platform_data { - struct pca954x_platform_mode *modes; - int num_modes; -}; - -#endif /* _LINUX_I2C_PCA954X_H */ diff --git a/trunk/include/linux/io-mapping.h b/trunk/include/linux/io-mapping.h index 0a6b3d5c490c..e0ea40f6c515 100644 --- a/trunk/include/linux/io-mapping.h +++ b/trunk/include/linux/io-mapping.h @@ -22,6 +22,7 @@ #include #include #include +#include /* * The io_mapping mechanism provides an abstraction for mapping @@ -32,8 +33,6 @@ #ifdef CONFIG_HAVE_ATOMIC_IOMAP -#include - struct io_mapping { resource_size_t base; unsigned long size; diff --git a/trunk/include/linux/jz4740-adc.h b/trunk/include/linux/jz4740-adc.h deleted file mode 100644 index 9053f95e9687..000000000000 --- a/trunk/include/linux/jz4740-adc.h +++ /dev/null @@ -1,32 +0,0 @@ - -#ifndef __LINUX_JZ4740_ADC -#define __LINUX_JZ4740_ADC - -#include - -/* - * jz4740_adc_set_config - Configure a JZ4740 adc device - * @dev: Pointer to a jz4740-adc device - * @mask: Mask for the config value to be set - * @val: Value to be set - * - * This function can be used by the JZ4740 ADC mfd cells to configure their - * options in the shared config register. -*/ -int jz4740_adc_set_config(struct device *dev, uint32_t mask, uint32_t val); - -#define JZ_ADC_CONFIG_SPZZ BIT(31) -#define JZ_ADC_CONFIG_EX_IN BIT(30) -#define JZ_ADC_CONFIG_DNUM_MASK (0x7 << 16) -#define JZ_ADC_CONFIG_DMA_ENABLE BIT(15) -#define JZ_ADC_CONFIG_XYZ_MASK (0x2 << 13) -#define JZ_ADC_CONFIG_SAMPLE_NUM_MASK (0x7 << 10) -#define JZ_ADC_CONFIG_CLKDIV_MASK (0xf << 5) -#define JZ_ADC_CONFIG_BAT_MB BIT(4) - -#define JZ_ADC_CONFIG_DNUM(dnum) ((dnum) << 16) -#define JZ_ADC_CONFIG_XYZ_OFFSET(dnum) ((xyz) << 13) -#define JZ_ADC_CONFIG_SAMPLE_NUM(x) ((x) << 10) -#define JZ_ADC_CONFIG_CLKDIV(div) ((div) << 5) - -#endif diff --git a/trunk/include/linux/kernel.h b/trunk/include/linux/kernel.h index 2b0a35e6bc69..d848cb854655 100644 --- a/trunk/include/linux/kernel.h +++ b/trunk/include/linux/kernel.h @@ -306,13 +306,6 @@ static inline void log_buf_kexec_setup(void) } #endif -/* - * Dummy printk for disabled debugging statements to use whilst maintaining - * gcc's format and side-effect checking. - */ -static inline __attribute__ ((format (printf, 1, 2))) -int no_printk(const char *s, ...) { return 0; } - extern int printk_needs_cpu(int cpu); extern void printk_tick(void); diff --git a/trunk/include/linux/mfd/ab8500.h b/trunk/include/linux/mfd/ab8500.h index f5cec4500f38..b63ff3ba3351 100644 --- a/trunk/include/linux/mfd/ab8500.h +++ b/trunk/include/linux/mfd/ab8500.h @@ -76,8 +76,6 @@ #define AB8500_NR_IRQS 104 #define AB8500_NUM_IRQ_REGS 13 -#define AB8500_NUM_REGULATORS 15 - /** * struct ab8500 - ab8500 internal structure * @dev: parent device @@ -110,18 +108,14 @@ struct ab8500 { u8 oldmask[AB8500_NUM_IRQ_REGS]; }; -struct regulator_init_data; - /** * struct ab8500_platform_data - AB8500 platform data * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used * @init: board-specific initialization after detection of ab8500 - * @regulator: machine-specific constraints for regulators */ struct ab8500_platform_data { int irq_base; void (*init) (struct ab8500 *); - struct regulator_init_data *regulator[AB8500_NUM_REGULATORS]; }; extern int ab8500_write(struct ab8500 *a8500, u16 addr, u8 data); diff --git a/trunk/include/linux/mfd/max8998-private.h b/trunk/include/linux/mfd/max8998-private.h deleted file mode 100644 index 6dc75b3e2d33..000000000000 --- a/trunk/include/linux/mfd/max8998-private.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * max8698.h - Voltage regulator driver for the Maxim 8998 - * - * Copyright (C) 2009-2010 Samsung Electrnoics - * Kyungmin Park - * Marek Szyprowski - * - * 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 - */ - -#ifndef __LINUX_MFD_MAX8998_PRIV_H -#define __LINUX_MFD_MAX8998_PRIV_H - -/* MAX 8998 registers */ -enum { - MAX8998_REG_IRQ1, - MAX8998_REG_IRQ2, - MAX8998_REG_IRQ3, - MAX8998_REG_IRQ4, - MAX8998_REG_IRQM1, - MAX8998_REG_IRQM2, - MAX8998_REG_IRQM3, - MAX8998_REG_IRQM4, - MAX8998_REG_STATUS1, - MAX8998_REG_STATUS2, - MAX8998_REG_STATUSM1, - MAX8998_REG_STATUSM2, - MAX8998_REG_CHGR1, - MAX8998_REG_CHGR2, - MAX8998_REG_LDO_ACTIVE_DISCHARGE1, - MAX8998_REG_LDO_ACTIVE_DISCHARGE2, - MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, - MAX8998_REG_ONOFF1, - MAX8998_REG_ONOFF2, - MAX8998_REG_ONOFF3, - MAX8998_REG_ONOFF4, - MAX8998_REG_BUCK1_DVSARM1, - MAX8998_REG_BUCK1_DVSARM2, - MAX8998_REG_BUCK1_DVSARM3, - MAX8998_REG_BUCK1_DVSARM4, - MAX8998_REG_BUCK2_DVSINT1, - MAX8998_REG_BUCK2_DVSINT2, - MAX8998_REG_BUCK3, - MAX8998_REG_BUCK4, - MAX8998_REG_LDO2_LDO3, - MAX8998_REG_LDO4, - MAX8998_REG_LDO5, - MAX8998_REG_LDO6, - MAX8998_REG_LDO7, - MAX8998_REG_LDO8_LDO9, - MAX8998_REG_LDO10_LDO11, - MAX8998_REG_LDO12, - MAX8998_REG_LDO13, - MAX8998_REG_LDO14, - MAX8998_REG_LDO15, - MAX8998_REG_LDO16, - MAX8998_REG_LDO17, - MAX8998_REG_BKCHR, - MAX8998_REG_LBCNFG1, - MAX8998_REG_LBCNFG2, -}; - -/** - * struct max8998_dev - max8998 master device for sub-drivers - * @dev: master device of the chip (can be used to access platform data) - * @i2c_client: i2c client private data - * @dev_read(): chip register read function - * @dev_write(): chip register write function - * @dev_update(): chip register update function - * @iolock: mutex for serializing io access - */ - -struct max8998_dev { - struct device *dev; - struct i2c_client *i2c_client; - int (*dev_read)(struct max8998_dev *max8998, u8 reg, u8 *dest); - int (*dev_write)(struct max8998_dev *max8998, u8 reg, u8 val); - int (*dev_update)(struct max8998_dev *max8998, u8 reg, u8 val, u8 mask); - struct mutex iolock; -}; - -static inline int max8998_read_reg(struct max8998_dev *max8998, u8 reg, - u8 *value) -{ - return max8998->dev_read(max8998, reg, value); -} - -static inline int max8998_write_reg(struct max8998_dev *max8998, u8 reg, - u8 value) -{ - return max8998->dev_write(max8998, reg, value); -} - -static inline int max8998_update_reg(struct max8998_dev *max8998, u8 reg, - u8 value, u8 mask) -{ - return max8998->dev_update(max8998, reg, value, mask); -} - -#endif /* __LINUX_MFD_MAX8998_PRIV_H */ diff --git a/trunk/include/linux/mfd/max8998.h b/trunk/include/linux/mfd/max8998.h deleted file mode 100644 index 1d3601a2d853..000000000000 --- a/trunk/include/linux/mfd/max8998.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * max8698.h - Voltage regulator driver for the Maxim 8998 - * - * Copyright (C) 2009-2010 Samsung Electrnoics - * Kyungmin Park - * Marek Szyprowski - * - * 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 - */ - -#ifndef __LINUX_MFD_MAX8998_H -#define __LINUX_MFD_MAX8998_H - -#include - -/* MAX 8998 regulator ids */ -enum { - MAX8998_LDO2 = 2, - MAX8998_LDO3, - MAX8998_LDO4, - MAX8998_LDO5, - MAX8998_LDO6, - MAX8998_LDO7, - MAX8998_LDO8, - MAX8998_LDO9, - MAX8998_LDO10, - MAX8998_LDO11, - MAX8998_LDO12, - MAX8998_LDO13, - MAX8998_LDO14, - MAX8998_LDO15, - MAX8998_LDO16, - MAX8998_LDO17, - MAX8998_BUCK1, - MAX8998_BUCK2, - MAX8998_BUCK3, - MAX8998_BUCK4, - MAX8998_EN32KHZ_AP, - MAX8998_EN32KHZ_CP, - MAX8998_ENVICHG, - MAX8998_ESAFEOUT1, - MAX8998_ESAFEOUT2, -}; - -/** - * max8998_regulator_data - regulator data - * @id: regulator id - * @initdata: regulator init data (contraints, supplies, ...) - */ -struct max8998_regulator_data { - int id; - struct regulator_init_data *initdata; -}; - -/** - * struct max8998_board - packages regulator init data - * @num_regulators: number of regultors used - * @regulators: array of defined regulators - */ - -struct max8998_platform_data { - int num_regulators; - struct max8998_regulator_data *regulators; -}; - -#endif /* __LINUX_MFD_MAX8998_H */ diff --git a/trunk/include/linux/mfd/mc13783-private.h b/trunk/include/linux/mfd/mc13783-private.h new file mode 100644 index 000000000000..95cf9360553f --- /dev/null +++ b/trunk/include/linux/mfd/mc13783-private.h @@ -0,0 +1,220 @@ +/* + * Copyright 2009 Pengutronix, Sascha Hauer + * + * Initial development of this code was funded by + * Phytec Messtechnik GmbH, http://www.phytec.de + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __LINUX_MFD_MC13783_PRIV_H +#define __LINUX_MFD_MC13783_PRIV_H + +#include +#include +#include +#include + +struct mc13783 { + struct spi_device *spidev; + struct mutex lock; + int irq; + int flags; + + irq_handler_t irqhandler[MC13783_NUM_IRQ]; + void *irqdata[MC13783_NUM_IRQ]; + + /* XXX these should go as platformdata to the regulator subdevice */ + struct mc13783_regulator_init_data *regulators; + int num_regulators; +}; + +#define MC13783_REG_INTERRUPT_STATUS_0 0 +#define MC13783_REG_INTERRUPT_MASK_0 1 +#define MC13783_REG_INTERRUPT_SENSE_0 2 +#define MC13783_REG_INTERRUPT_STATUS_1 3 +#define MC13783_REG_INTERRUPT_MASK_1 4 +#define MC13783_REG_INTERRUPT_SENSE_1 5 +#define MC13783_REG_POWER_UP_MODE_SENSE 6 +#define MC13783_REG_REVISION 7 +#define MC13783_REG_SEMAPHORE 8 +#define MC13783_REG_ARBITRATION_PERIPHERAL_AUDIO 9 +#define MC13783_REG_ARBITRATION_SWITCHERS 10 +#define MC13783_REG_ARBITRATION_REGULATORS_0 11 +#define MC13783_REG_ARBITRATION_REGULATORS_1 12 +#define MC13783_REG_POWER_CONTROL_0 13 +#define MC13783_REG_POWER_CONTROL_1 14 +#define MC13783_REG_POWER_CONTROL_2 15 +#define MC13783_REG_REGEN_ASSIGNMENT 16 +#define MC13783_REG_CONTROL_SPARE 17 +#define MC13783_REG_MEMORY_A 18 +#define MC13783_REG_MEMORY_B 19 +#define MC13783_REG_RTC_TIME 20 +#define MC13783_REG_RTC_ALARM 21 +#define MC13783_REG_RTC_DAY 22 +#define MC13783_REG_RTC_DAY_ALARM 23 +#define MC13783_REG_SWITCHERS_0 24 +#define MC13783_REG_SWITCHERS_1 25 +#define MC13783_REG_SWITCHERS_2 26 +#define MC13783_REG_SWITCHERS_3 27 +#define MC13783_REG_SWITCHERS_4 28 +#define MC13783_REG_SWITCHERS_5 29 +#define MC13783_REG_REGULATOR_SETTING_0 30 +#define MC13783_REG_REGULATOR_SETTING_1 31 +#define MC13783_REG_REGULATOR_MODE_0 32 +#define MC13783_REG_REGULATOR_MODE_1 33 +#define MC13783_REG_POWER_MISCELLANEOUS 34 +#define MC13783_REG_POWER_SPARE 35 +#define MC13783_REG_AUDIO_RX_0 36 +#define MC13783_REG_AUDIO_RX_1 37 +#define MC13783_REG_AUDIO_TX 38 +#define MC13783_REG_AUDIO_SSI_NETWORK 39 +#define MC13783_REG_AUDIO_CODEC 40 +#define MC13783_REG_AUDIO_STEREO_DAC 41 +#define MC13783_REG_AUDIO_SPARE 42 +#define MC13783_REG_ADC_0 43 +#define MC13783_REG_ADC_1 44 +#define MC13783_REG_ADC_2 45 +#define MC13783_REG_ADC_3 46 +#define MC13783_REG_ADC_4 47 +#define MC13783_REG_CHARGER 48 +#define MC13783_REG_USB 49 +#define MC13783_REG_CHARGE_USB_SPARE 50 +#define MC13783_REG_LED_CONTROL_0 51 +#define MC13783_REG_LED_CONTROL_1 52 +#define MC13783_REG_LED_CONTROL_2 53 +#define MC13783_REG_LED_CONTROL_3 54 +#define MC13783_REG_LED_CONTROL_4 55 +#define MC13783_REG_LED_CONTROL_5 56 +#define MC13783_REG_SPARE 57 +#define MC13783_REG_TRIM_0 58 +#define MC13783_REG_TRIM_1 59 +#define MC13783_REG_TEST_0 60 +#define MC13783_REG_TEST_1 61 +#define MC13783_REG_TEST_2 62 +#define MC13783_REG_TEST_3 63 +#define MC13783_REG_NB 64 + +/* + * Reg Regulator Mode 0 + */ +#define MC13783_REGCTRL_VAUDIO_EN (1 << 0) +#define MC13783_REGCTRL_VAUDIO_STBY (1 << 1) +#define MC13783_REGCTRL_VAUDIO_MODE (1 << 2) +#define MC13783_REGCTRL_VIOHI_EN (1 << 3) +#define MC13783_REGCTRL_VIOHI_STBY (1 << 4) +#define MC13783_REGCTRL_VIOHI_MODE (1 << 5) +#define MC13783_REGCTRL_VIOLO_EN (1 << 6) +#define MC13783_REGCTRL_VIOLO_STBY (1 << 7) +#define MC13783_REGCTRL_VIOLO_MODE (1 << 8) +#define MC13783_REGCTRL_VDIG_EN (1 << 9) +#define MC13783_REGCTRL_VDIG_STBY (1 << 10) +#define MC13783_REGCTRL_VDIG_MODE (1 << 11) +#define MC13783_REGCTRL_VGEN_EN (1 << 12) +#define MC13783_REGCTRL_VGEN_STBY (1 << 13) +#define MC13783_REGCTRL_VGEN_MODE (1 << 14) +#define MC13783_REGCTRL_VRFDIG_EN (1 << 15) +#define MC13783_REGCTRL_VRFDIG_STBY (1 << 16) +#define MC13783_REGCTRL_VRFDIG_MODE (1 << 17) +#define MC13783_REGCTRL_VRFREF_EN (1 << 18) +#define MC13783_REGCTRL_VRFREF_STBY (1 << 19) +#define MC13783_REGCTRL_VRFREF_MODE (1 << 20) +#define MC13783_REGCTRL_VRFCP_EN (1 << 21) +#define MC13783_REGCTRL_VRFCP_STBY (1 << 22) +#define MC13783_REGCTRL_VRFCP_MODE (1 << 23) + +/* + * Reg Regulator Mode 1 + */ +#define MC13783_REGCTRL_VSIM_EN (1 << 0) +#define MC13783_REGCTRL_VSIM_STBY (1 << 1) +#define MC13783_REGCTRL_VSIM_MODE (1 << 2) +#define MC13783_REGCTRL_VESIM_EN (1 << 3) +#define MC13783_REGCTRL_VESIM_STBY (1 << 4) +#define MC13783_REGCTRL_VESIM_MODE (1 << 5) +#define MC13783_REGCTRL_VCAM_EN (1 << 6) +#define MC13783_REGCTRL_VCAM_STBY (1 << 7) +#define MC13783_REGCTRL_VCAM_MODE (1 << 8) +#define MC13783_REGCTRL_VRFBG_EN (1 << 9) +#define MC13783_REGCTRL_VRFBG_STBY (1 << 10) +#define MC13783_REGCTRL_VVIB_EN (1 << 11) +#define MC13783_REGCTRL_VRF1_EN (1 << 12) +#define MC13783_REGCTRL_VRF1_STBY (1 << 13) +#define MC13783_REGCTRL_VRF1_MODE (1 << 14) +#define MC13783_REGCTRL_VRF2_EN (1 << 15) +#define MC13783_REGCTRL_VRF2_STBY (1 << 16) +#define MC13783_REGCTRL_VRF2_MODE (1 << 17) +#define MC13783_REGCTRL_VMMC1_EN (1 << 18) +#define MC13783_REGCTRL_VMMC1_STBY (1 << 19) +#define MC13783_REGCTRL_VMMC1_MODE (1 << 20) +#define MC13783_REGCTRL_VMMC2_EN (1 << 21) +#define MC13783_REGCTRL_VMMC2_STBY (1 << 22) +#define MC13783_REGCTRL_VMMC2_MODE (1 << 23) + +/* + * Reg Regulator Misc. + */ +#define MC13783_REGCTRL_GPO1_EN (1 << 6) +#define MC13783_REGCTRL_GPO2_EN (1 << 8) +#define MC13783_REGCTRL_GPO3_EN (1 << 10) +#define MC13783_REGCTRL_GPO4_EN (1 << 12) +#define MC13783_REGCTRL_VIBPINCTRL (1 << 14) + +/* + * Reg Switcher 4 + */ +#define MC13783_SWCTRL_SW1A_MODE (1 << 0) +#define MC13783_SWCTRL_SW1A_STBY_MODE (1 << 2) +#define MC13783_SWCTRL_SW1A_DVS_SPEED (1 << 6) +#define MC13783_SWCTRL_SW1A_PANIC_MODE (1 << 8) +#define MC13783_SWCTRL_SW1A_SOFTSTART (1 << 9) +#define MC13783_SWCTRL_SW1B_MODE (1 << 10) +#define MC13783_SWCTRL_SW1B_STBY_MODE (1 << 12) +#define MC13783_SWCTRL_SW1B_DVS_SPEED (1 << 14) +#define MC13783_SWCTRL_SW1B_PANIC_MODE (1 << 16) +#define MC13783_SWCTRL_SW1B_SOFTSTART (1 << 17) +#define MC13783_SWCTRL_PLL_EN (1 << 18) +#define MC13783_SWCTRL_PLL_FACTOR (1 << 19) + +/* + * Reg Switcher 5 + */ +#define MC13783_SWCTRL_SW2A_MODE (1 << 0) +#define MC13783_SWCTRL_SW2A_STBY_MODE (1 << 2) +#define MC13783_SWCTRL_SW2A_DVS_SPEED (1 << 6) +#define MC13783_SWCTRL_SW2A_PANIC_MODE (1 << 8) +#define MC13783_SWCTRL_SW2A_SOFTSTART (1 << 9) +#define MC13783_SWCTRL_SW2B_MODE (1 << 10) +#define MC13783_SWCTRL_SW2B_STBY_MODE (1 << 12) +#define MC13783_SWCTRL_SW2B_DVS_SPEED (1 << 14) +#define MC13783_SWCTRL_SW2B_PANIC_MODE (1 << 16) +#define MC13783_SWCTRL_SW2B_SOFTSTART (1 << 17) +#define MC13783_SWSET_SW3 (1 << 18) +#define MC13783_SWCTRL_SW3_EN (1 << 20) +#define MC13783_SWCTRL_SW3_STBY (1 << 21) +#define MC13783_SWCTRL_SW3_MODE (1 << 22) + +static inline int mc13783_set_bits(struct mc13783 *mc13783, unsigned int offset, + u32 mask, u32 val) +{ + int ret; + mc13783_lock(mc13783); + ret = mc13783_reg_rmw(mc13783, offset, mask, val); + mc13783_unlock(mc13783); + + return ret; +} + +#endif /* __LINUX_MFD_MC13783_PRIV_H */ diff --git a/trunk/include/linux/mfd/mc13783.h b/trunk/include/linux/mfd/mc13783.h index 0fa44fb8dd26..4a894f688549 100644 --- a/trunk/include/linux/mfd/mc13783.h +++ b/trunk/include/linux/mfd/mc13783.h @@ -21,8 +21,6 @@ int mc13783_reg_write(struct mc13783 *mc13783, unsigned int offset, u32 val); int mc13783_reg_rmw(struct mc13783 *mc13783, unsigned int offset, u32 mask, u32 val); -int mc13783_get_flags(struct mc13783 *mc13783); - int mc13783_irq_request(struct mc13783 *mc13783, int irq, irq_handler_t handler, const char *name, void *dev); int mc13783_irq_request_nounmask(struct mc13783 *mc13783, int irq, diff --git a/trunk/include/linux/mfd/stmpe.h b/trunk/include/linux/mfd/stmpe.h deleted file mode 100644 index 39ca7588659b..000000000000 --- a/trunk/include/linux/mfd/stmpe.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2010 - * - * License Terms: GNU General Public License, version 2 - * Author: Rabin Vincent for ST-Ericsson - */ - -#ifndef __LINUX_MFD_STMPE_H -#define __LINUX_MFD_STMPE_H - -#include - -enum stmpe_block { - STMPE_BLOCK_GPIO = 1 << 0, - STMPE_BLOCK_KEYPAD = 1 << 1, - STMPE_BLOCK_TOUCHSCREEN = 1 << 2, - STMPE_BLOCK_ADC = 1 << 3, - STMPE_BLOCK_PWM = 1 << 4, - STMPE_BLOCK_ROTATOR = 1 << 5, -}; - -enum stmpe_partnum { - STMPE811, - STMPE1601, - STMPE2401, - STMPE2403, -}; - -/* - * For registers whose locations differ on variants, the correct address is - * obtained by indexing stmpe->regs with one of the following. - */ -enum { - STMPE_IDX_CHIP_ID, - STMPE_IDX_ICR_LSB, - STMPE_IDX_IER_LSB, - STMPE_IDX_ISR_MSB, - STMPE_IDX_GPMR_LSB, - STMPE_IDX_GPSR_LSB, - STMPE_IDX_GPCR_LSB, - STMPE_IDX_GPDR_LSB, - STMPE_IDX_GPEDR_MSB, - STMPE_IDX_GPRER_LSB, - STMPE_IDX_GPFER_LSB, - STMPE_IDX_GPAFR_U_MSB, - STMPE_IDX_IEGPIOR_LSB, - STMPE_IDX_ISGPIOR_MSB, - STMPE_IDX_MAX, -}; - - -struct stmpe_variant_info; - -/** - * struct stmpe - STMPE MFD structure - * @lock: lock protecting I/O operations - * @irq_lock: IRQ bus lock - * @dev: device, mostly for dev_dbg() - * @i2c: i2c client - * @variant: the detected STMPE model number - * @regs: list of addresses of registers which are at different addresses on - * different variants. Indexed by one of STMPE_IDX_*. - * @irq_base: starting IRQ number for internal IRQs - * @num_gpios: number of gpios, differs for variants - * @ier: cache of IER registers for bus_lock - * @oldier: cache of IER registers for bus_lock - * @pdata: platform data - */ -struct stmpe { - struct mutex lock; - struct mutex irq_lock; - struct device *dev; - struct i2c_client *i2c; - enum stmpe_partnum partnum; - struct stmpe_variant_info *variant; - const u8 *regs; - - int irq_base; - int num_gpios; - u8 ier[2]; - u8 oldier[2]; - struct stmpe_platform_data *pdata; -}; - -extern int stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 data); -extern int stmpe_reg_read(struct stmpe *stmpe, u8 reg); -extern int stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length, - u8 *values); -extern int stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length, - const u8 *values); -extern int stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val); -extern int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, - enum stmpe_block block); -extern int stmpe_enable(struct stmpe *stmpe, unsigned int blocks); -extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks); - -struct matrix_keymap_data; - -/** - * struct stmpe_keypad_platform_data - STMPE keypad platform data - * @keymap_data: key map table and size - * @debounce_ms: debounce interval, in ms. Maximum is - * %STMPE_KEYPAD_MAX_DEBOUNCE. - * @scan_count: number of key scanning cycles to confirm key data. - * Maximum is %STMPE_KEYPAD_MAX_SCAN_COUNT. - * @no_autorepeat: disable key autorepeat - */ -struct stmpe_keypad_platform_data { - struct matrix_keymap_data *keymap_data; - unsigned int debounce_ms; - unsigned int scan_count; - bool no_autorepeat; -}; - -/** - * struct stmpe_gpio_platform_data - STMPE GPIO platform data - * @gpio_base: first gpio number assigned. A maximum of - * %STMPE_NR_GPIOS GPIOs will be allocated. - */ -struct stmpe_gpio_platform_data { - int gpio_base; - void (*setup)(struct stmpe *stmpe, unsigned gpio_base); - void (*remove)(struct stmpe *stmpe, unsigned gpio_base); -}; - -/** - * struct stmpe_ts_platform_data - stmpe811 touch screen controller platform - * data - * @sample_time: ADC converstion time in number of clock. - * (0 -> 36 clocks, 1 -> 44 clocks, 2 -> 56 clocks, 3 -> 64 clocks, - * 4 -> 80 clocks, 5 -> 96 clocks, 6 -> 144 clocks), - * recommended is 4. - * @mod_12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC) - * @ref_sel: ADC reference source - * (0 -> internal reference, 1 -> external reference) - * @adc_freq: ADC Clock speed - * (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz) - * @ave_ctrl: Sample average control - * (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples) - * @touch_det_delay: Touch detect interrupt delay - * (0 -> 10 us, 1 -> 50 us, 2 -> 100 us, 3 -> 500 us, - * 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms) - * recommended is 3 - * @settling: Panel driver settling time - * (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3 -> 1 ms, - * 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms) - * recommended is 2 - * @fraction_z: Length of the fractional part in z - * (fraction_z ([0..7]) = Count of the fractional part) - * recommended is 7 - * @i_drive: current limit value of the touchscreen drivers - * (0 -> 20 mA typical 35 mA max, 1 -> 50 mA typical 80 mA max) - * - * */ -struct stmpe_ts_platform_data { - u8 sample_time; - u8 mod_12b; - u8 ref_sel; - u8 adc_freq; - u8 ave_ctrl; - u8 touch_det_delay; - u8 settling; - u8 fraction_z; - u8 i_drive; -}; - -/** - * struct stmpe_platform_data - STMPE platform data - * @id: device id to distinguish between multiple STMPEs on the same board - * @blocks: bitmask of blocks to enable (use STMPE_BLOCK_*) - * @irq_trigger: IRQ trigger to use for the interrupt to the host - * @irq_invert_polarity: IRQ line is connected with reversed polarity - * @autosleep: bool to enable/disable stmpe autosleep - * @autosleep_timeout: inactivity timeout in milliseconds for autosleep - * @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or - * %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used. - * @gpio: GPIO-specific platform data - * @keypad: keypad-specific platform data - * @ts: touchscreen-specific platform data - */ -struct stmpe_platform_data { - int id; - unsigned int blocks; - int irq_base; - unsigned int irq_trigger; - bool irq_invert_polarity; - bool autosleep; - int autosleep_timeout; - - struct stmpe_gpio_platform_data *gpio; - struct stmpe_keypad_platform_data *keypad; - struct stmpe_ts_platform_data *ts; -}; - -#define STMPE_NR_INTERNAL_IRQS 9 -#define STMPE_INT_GPIO(x) (STMPE_NR_INTERNAL_IRQS + (x)) - -#define STMPE_NR_GPIOS 24 -#define STMPE_NR_IRQS STMPE_INT_GPIO(STMPE_NR_GPIOS) - -#endif diff --git a/trunk/include/linux/mfd/tps6586x.h b/trunk/include/linux/mfd/tps6586x.h deleted file mode 100644 index 772b3ae640af..000000000000 --- a/trunk/include/linux/mfd/tps6586x.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __LINUX_MFD_TPS6586X_H -#define __LINUX_MFD_TPS6586X_H - -enum { - TPS6586X_ID_SM_0, - TPS6586X_ID_SM_1, - TPS6586X_ID_SM_2, - TPS6586X_ID_LDO_0, - TPS6586X_ID_LDO_1, - TPS6586X_ID_LDO_2, - TPS6586X_ID_LDO_3, - TPS6586X_ID_LDO_4, - TPS6586X_ID_LDO_5, - TPS6586X_ID_LDO_6, - TPS6586X_ID_LDO_7, - TPS6586X_ID_LDO_8, - TPS6586X_ID_LDO_9, - TPS6586X_ID_LDO_RTC, -}; - -struct tps6586x_subdev_info { - int id; - const char *name; - void *platform_data; -}; - -struct tps6586x_platform_data { - int num_subdevs; - struct tps6586x_subdev_info *subdevs; - - int gpio_base; -}; - -/* - * NOTE: the functions below are not intended for use outside - * of the TPS6586X sub-device drivers - */ -extern int tps6586x_write(struct device *dev, int reg, uint8_t val); -extern int tps6586x_writes(struct device *dev, int reg, int len, uint8_t *val); -extern int tps6586x_read(struct device *dev, int reg, uint8_t *val); -extern int tps6586x_reads(struct device *dev, int reg, int len, uint8_t *val); -extern int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask); -extern int tps6586x_clr_bits(struct device *dev, int reg, uint8_t bit_mask); -extern int tps6586x_update(struct device *dev, int reg, uint8_t val, - uint8_t mask); - -#endif /*__LINUX_MFD_TPS6586X_H */ diff --git a/trunk/include/linux/mfd/wm8994/gpio.h b/trunk/include/linux/mfd/wm8994/gpio.h index 0c79b5ff4b5a..b4d4c22991e8 100644 --- a/trunk/include/linux/mfd/wm8994/gpio.h +++ b/trunk/include/linux/mfd/wm8994/gpio.h @@ -36,10 +36,6 @@ #define WM8994_GP_FN_WSEQ_STATUS 16 #define WM8994_GP_FN_FIFO_ERROR 17 #define WM8994_GP_FN_OPCLK 18 -#define WM8994_GP_FN_THW 19 -#define WM8994_GP_FN_DCS_DONE 20 -#define WM8994_GP_FN_FLL1_OUT 21 -#define WM8994_GP_FN_FLL2_OUT 22 #define WM8994_GPN_DIR 0x8000 /* GPN_DIR */ #define WM8994_GPN_DIR_MASK 0x8000 /* GPN_DIR */ diff --git a/trunk/include/linux/miscdevice.h b/trunk/include/linux/miscdevice.h index bafffc737903..f6c9b7dcb9fd 100644 --- a/trunk/include/linux/miscdevice.h +++ b/trunk/include/linux/miscdevice.h @@ -38,7 +38,6 @@ #define KVM_MINOR 232 #define BTRFS_MINOR 234 #define AUTOFS_MINOR 235 -#define MAPPER_CTRL_MINOR 236 #define MISC_DYNAMIC_MINOR 255 struct device; diff --git a/trunk/include/linux/mmc/card.h b/trunk/include/linux/mmc/card.h index 6b7525099e56..4d893eaf8174 100644 --- a/trunk/include/linux/mmc/card.h +++ b/trunk/include/linux/mmc/card.h @@ -31,7 +31,6 @@ struct mmc_csd { unsigned int tacc_ns; unsigned int r2w_factor; unsigned int max_dtr; - unsigned int erase_size; /* In sectors */ unsigned int read_blkbits; unsigned int write_blkbits; unsigned int capacity; @@ -43,16 +42,9 @@ struct mmc_csd { struct mmc_ext_csd { u8 rev; - u8 erase_group_def; - u8 sec_feature_support; unsigned int sa_timeout; /* Units: 100ns */ unsigned int hs_max_dtr; unsigned int sectors; - unsigned int hc_erase_size; /* In sectors */ - unsigned int hc_erase_timeout; /* In milliseconds */ - unsigned int sec_trim_mult; /* Secure trim multiplier */ - unsigned int sec_erase_mult; /* Secure erase multiplier */ - unsigned int trim_timeout; /* In milliseconds */ }; struct sd_scr { @@ -62,12 +54,6 @@ struct sd_scr { #define SD_SCR_BUS_WIDTH_4 (1<<2) }; -struct sd_ssr { - unsigned int au; /* In sectors */ - unsigned int erase_timeout; /* In milliseconds */ - unsigned int erase_offset; /* In milliseconds */ -}; - struct sd_switch_caps { unsigned int hs_max_dtr; }; @@ -120,11 +106,6 @@ struct mmc_card { #define MMC_QUIRK_NONSTD_SDIO (1<<2) /* non-standard SDIO card attached */ /* (missing CIA registers) */ - unsigned int erase_size; /* erase size in sectors */ - unsigned int erase_shift; /* if erase unit is power 2 */ - unsigned int pref_erase; /* in sectors */ - u8 erased_byte; /* value of erased bytes */ - u32 raw_cid[4]; /* raw card CID */ u32 raw_csd[4]; /* raw card CSD */ u32 raw_scr[2]; /* raw card SCR */ @@ -132,7 +113,6 @@ struct mmc_card { struct mmc_csd csd; /* card specific */ struct mmc_ext_csd ext_csd; /* mmc v4 extended card specific */ struct sd_scr scr; /* extra SD information */ - struct sd_ssr ssr; /* yet more SD information */ struct sd_switch_caps sw_caps; /* switch (CMD6) caps */ unsigned int sdio_funcs; /* number of SDIO functions */ diff --git a/trunk/include/linux/mmc/core.h b/trunk/include/linux/mmc/core.h index 7429033acb66..e4898e9eeb59 100644 --- a/trunk/include/linux/mmc/core.h +++ b/trunk/include/linux/mmc/core.h @@ -92,8 +92,6 @@ struct mmc_command { * actively failing requests */ - unsigned int erase_timeout; /* in milliseconds */ - struct mmc_data *data; /* data segment associated with cmd */ struct mmc_request *mrq; /* associated request */ }; @@ -136,23 +134,6 @@ extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int); extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *, struct mmc_command *, int); -#define MMC_ERASE_ARG 0x00000000 -#define MMC_SECURE_ERASE_ARG 0x80000000 -#define MMC_TRIM_ARG 0x00000001 -#define MMC_SECURE_TRIM1_ARG 0x80000001 -#define MMC_SECURE_TRIM2_ARG 0x80008000 - -#define MMC_SECURE_ARGS 0x80000000 -#define MMC_TRIM_ARGS 0x00008001 - -extern int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr, - unsigned int arg); -extern int mmc_can_erase(struct mmc_card *card); -extern int mmc_can_trim(struct mmc_card *card); -extern int mmc_can_secure_erase_trim(struct mmc_card *card); -extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from, - unsigned int nr); - extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *); extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int); diff --git a/trunk/include/linux/mmc/host.h b/trunk/include/linux/mmc/host.h index 1575b52c3bfa..513ff0376b09 100644 --- a/trunk/include/linux/mmc/host.h +++ b/trunk/include/linux/mmc/host.h @@ -156,7 +156,6 @@ struct mmc_host { #define MMC_CAP_DISABLE (1 << 7) /* Can the host be disabled */ #define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */ #define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */ -#define MMC_CAP_ERASE (1 << 10) /* Allow erase/trim commands */ mmc_pm_flag_t pm_caps; /* supported pm features */ diff --git a/trunk/include/linux/mmc/mmc.h b/trunk/include/linux/mmc/mmc.h index dd11ae51fb68..52ce98866287 100644 --- a/trunk/include/linux/mmc/mmc.h +++ b/trunk/include/linux/mmc/mmc.h @@ -251,21 +251,13 @@ struct _mmc_csd { * EXT_CSD fields */ -#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ -#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ -#define EXT_CSD_BUS_WIDTH 183 /* R/W */ -#define EXT_CSD_HS_TIMING 185 /* R/W */ -#define EXT_CSD_REV 192 /* RO */ -#define EXT_CSD_STRUCTURE 194 /* RO */ -#define EXT_CSD_CARD_TYPE 196 /* RO */ -#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ -#define EXT_CSD_S_A_TIMEOUT 217 /* RO */ -#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ -#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ -#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */ -#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ -#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ -#define EXT_CSD_TRIM_MULT 232 /* RO */ +#define EXT_CSD_BUS_WIDTH 183 /* R/W */ +#define EXT_CSD_HS_TIMING 185 /* R/W */ +#define EXT_CSD_CARD_TYPE 196 /* RO */ +#define EXT_CSD_STRUCTURE 194 /* RO */ +#define EXT_CSD_REV 192 /* RO */ +#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ +#define EXT_CSD_S_A_TIMEOUT 217 /* * EXT_CSD field definitions @@ -283,10 +275,6 @@ struct _mmc_csd { #define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ #define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ -#define EXT_CSD_SEC_ER_EN BIT(0) -#define EXT_CSD_SEC_BD_BLK_EN BIT(2) -#define EXT_CSD_SEC_GB_CL_EN BIT(4) - /* * MMC_SWITCH access modes */ diff --git a/trunk/include/linux/mmc/sd.h b/trunk/include/linux/mmc/sd.h index 3fd85e088cc3..f310062cffb4 100644 --- a/trunk/include/linux/mmc/sd.h +++ b/trunk/include/linux/mmc/sd.h @@ -21,13 +21,8 @@ /* class 10 */ #define SD_SWITCH 6 /* adtc [31:0] See below R1 */ - /* class 5 */ -#define SD_ERASE_WR_BLK_START 32 /* ac [31:0] data addr R1 */ -#define SD_ERASE_WR_BLK_END 33 /* ac [31:0] data addr R1 */ - /* Application commands */ #define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */ -#define SD_APP_SD_STATUS 13 /* adtc R1 */ #define SD_APP_SEND_NUM_WR_BLKS 22 /* adtc R1 */ #define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */ #define SD_APP_SEND_SCR 51 /* adtc R1 */ diff --git a/trunk/include/linux/moduleparam.h b/trunk/include/linux/moduleparam.h index 9d2f1837b3d8..82a9124f7d75 100644 --- a/trunk/include/linux/moduleparam.h +++ b/trunk/include/linux/moduleparam.h @@ -31,23 +31,20 @@ static const char __module_cat(name,__LINE__)[] \ struct kernel_param; -struct kernel_param_ops { - /* Returns 0, or -errno. arg is in kp->arg. */ - int (*set)(const char *val, const struct kernel_param *kp); - /* Returns length written or -errno. Buffer is 4k (ie. be short!) */ - int (*get)(char *buffer, const struct kernel_param *kp); - /* Optional function to free kp->arg when module unloaded. */ - void (*free)(void *arg); -}; +/* Returns 0, or -errno. arg is in kp->arg. */ +typedef int (*param_set_fn)(const char *val, struct kernel_param *kp); +/* Returns length written or -errno. Buffer is 4k (ie. be short!) */ +typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp); /* Flag bits for kernel_param.flags */ #define KPARAM_ISBOOL 2 struct kernel_param { const char *name; - const struct kernel_param_ops *ops; u16 perm; u16 flags; + param_set_fn set; + param_get_fn get; union { void *arg; const struct kparam_string *str; @@ -66,67 +63,12 @@ struct kparam_array { unsigned int max; unsigned int *num; - const struct kernel_param_ops *ops; + param_set_fn set; + param_get_fn get; unsigned int elemsize; void *elem; }; -/** - * module_param - typesafe helper for a module/cmdline parameter - * @value: the variable to alter, and exposed parameter name. - * @type: the type of the parameter - * @perm: visibility in sysfs. - * - * @value becomes the module parameter, or (prefixed by KBUILD_MODNAME and a - * ".") the kernel commandline parameter. Note that - is changed to _, so - * the user can use "foo-bar=1" even for variable "foo_bar". - * - * @perm is 0 if the the variable is not to appear in sysfs, or 0444 - * for world-readable, 0644 for root-writable, etc. Note that if it - * is writable, you may need to use kparam_block_sysfs_write() around - * accesses (esp. charp, which can be kfreed when it changes). - * - * The @type is simply pasted to refer to a param_ops_##type and a - * param_check_##type: for convenience many standard types are provided but - * you can create your own by defining those variables. - * - * Standard types are: - * byte, short, ushort, int, uint, long, ulong - * charp: a character pointer - * bool: a bool, values 0/1, y/n, Y/N. - * invbool: the above, only sense-reversed (N = true). - */ -#define module_param(name, type, perm) \ - module_param_named(name, name, type, perm) - -/** - * module_param_named - typesafe helper for a renamed module/cmdline parameter - * @name: a valid C identifier which is the parameter name. - * @value: the actual lvalue to alter. - * @type: the type of the parameter - * @perm: visibility in sysfs. - * - * Usually it's a good idea to have variable names and user-exposed names the - * same, but that's harder if the variable must be non-static or is inside a - * structure. This allows exposure under a different name. - */ -#define module_param_named(name, value, type, perm) \ - param_check_##type(name, &(value)); \ - module_param_cb(name, ¶m_ops_##type, &value, perm); \ - __MODULE_PARM_TYPE(name, #type) - -/** - * module_param_cb - general callback for a module/cmdline parameter - * @name: a valid C identifier which is the parameter name. - * @ops: the set & get operations for this parameter. - * @perm: visibility in sysfs. - * - * The ops can have NULL set or get functions. - */ -#define module_param_cb(name, ops, arg, perm) \ - __module_param_call(MODULE_PARAM_PREFIX, \ - name, ops, arg, __same_type((arg), bool *), perm) - /* On alpha, ia64 and ppc64 relocations to global data cannot go into read-only sections (which is part of respective UNIX ABI on these platforms). So 'const' makes no sense and even causes compile failures @@ -138,8 +80,10 @@ struct kparam_array #endif /* This is the fundamental function for registering boot/module - parameters. */ -#define __module_param_call(prefix, name, ops, arg, isbool, perm) \ + parameters. perm sets the visibility in sysfs: 000 means it's + not there, read bits mean it's readable, write bits mean it's + writable. */ +#define __module_param_call(prefix, name, set, get, arg, isbool, perm) \ /* Default value instead of permissions? */ \ static int __param_perm_check_##name __attribute__((unused)) = \ BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \ @@ -148,87 +92,31 @@ struct kparam_array static struct kernel_param __moduleparam_const __param_##name \ __used \ __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ - = { __param_str_##name, ops, perm, isbool ? KPARAM_ISBOOL : 0, \ - { arg } } - -/* Obsolete - use module_param_cb() */ -#define module_param_call(name, set, get, arg, perm) \ - static struct kernel_param_ops __param_ops_##name = \ - { (void *)set, (void *)get }; \ - __module_param_call(MODULE_PARAM_PREFIX, \ - name, &__param_ops_##name, arg, \ - __same_type(arg, bool *), \ - (perm) + sizeof(__check_old_set_param(set))*0) - -/* We don't get oldget: it's often a new-style param_get_uint, etc. */ -static inline int -__check_old_set_param(int (*oldset)(const char *, struct kernel_param *)) -{ - return 0; -} + = { __param_str_##name, perm, isbool ? KPARAM_ISBOOL : 0, \ + set, get, { arg } } -/** - * kparam_block_sysfs_write - make sure a parameter isn't written via sysfs. - * @name: the name of the parameter - * - * There's no point blocking write on a paramter that isn't writable via sysfs! - */ -#define kparam_block_sysfs_write(name) \ - do { \ - BUG_ON(!(__param_##name.perm & 0222)); \ - __kernel_param_lock(); \ - } while (0) - -/** - * kparam_unblock_sysfs_write - allows sysfs to write to a parameter again. - * @name: the name of the parameter - */ -#define kparam_unblock_sysfs_write(name) \ - do { \ - BUG_ON(!(__param_##name.perm & 0222)); \ - __kernel_param_unlock(); \ - } while (0) - -/** - * kparam_block_sysfs_read - make sure a parameter isn't read via sysfs. - * @name: the name of the parameter - * - * This also blocks sysfs writes. - */ -#define kparam_block_sysfs_read(name) \ - do { \ - BUG_ON(!(__param_##name.perm & 0444)); \ - __kernel_param_lock(); \ - } while (0) +#define module_param_call(name, set, get, arg, perm) \ + __module_param_call(MODULE_PARAM_PREFIX, \ + name, set, get, arg, \ + __same_type(*(arg), bool), perm) -/** - * kparam_unblock_sysfs_read - allows sysfs to read a parameter again. - * @name: the name of the parameter - */ -#define kparam_unblock_sysfs_read(name) \ - do { \ - BUG_ON(!(__param_##name.perm & 0444)); \ - __kernel_param_unlock(); \ - } while (0) +/* Helper functions: type is byte, short, ushort, int, uint, long, + ulong, charp, bool or invbool, or XXX if you define param_get_XXX, + param_set_XXX and param_check_XXX. */ +#define module_param_named(name, value, type, perm) \ + param_check_##type(name, &(value)); \ + module_param_call(name, param_set_##type, param_get_##type, &value, perm); \ + __MODULE_PARM_TYPE(name, #type) -#ifdef CONFIG_SYSFS -extern void __kernel_param_lock(void); -extern void __kernel_param_unlock(void); -#else -static inline void __kernel_param_lock(void) -{ -} -static inline void __kernel_param_unlock(void) -{ -} -#endif +#define module_param(name, type, perm) \ + module_param_named(name, name, type, perm) #ifndef MODULE /** * core_param - define a historical core kernel parameter. * @name: the name of the cmdline and sysfs parameter (often the same as var) * @var: the variable - * @type: the type of the parameter + * @type: the type (for param_set_##type and param_get_##type) * @perm: visibility in sysfs * * core_param is just like module_param(), but cannot be modular and @@ -238,32 +126,23 @@ static inline void __kernel_param_unlock(void) */ #define core_param(name, var, type, perm) \ param_check_##type(name, &(var)); \ - __module_param_call("", name, ¶m_ops_##type, \ + __module_param_call("", name, param_set_##type, param_get_##type, \ &var, __same_type(var, bool), perm) #endif /* !MODULE */ -/** - * module_param_string - a char array parameter - * @name: the name of the parameter - * @string: the string variable - * @len: the maximum length of the string, incl. terminator - * @perm: visibility in sysfs. - * - * This actually copies the string when it's set (unlike type charp). - * @len is usually just sizeof(string). - */ +/* Actually copy string: maxlen param is usually sizeof(string). */ #define module_param_string(name, string, len, perm) \ static const struct kparam_string __param_string_##name \ = { len, string }; \ __module_param_call(MODULE_PARAM_PREFIX, name, \ - ¶m_ops_string, \ + param_set_copystring, param_get_string, \ .str = &__param_string_##name, 0, perm); \ __MODULE_PARM_TYPE(name, "string") /* Called on module insert or kernel boot */ extern int parse_args(const char *name, char *args, - const struct kernel_param *params, + struct kernel_param *params, unsigned num, int (*unknown)(char *param, char *val)); @@ -283,105 +162,72 @@ static inline void destroy_params(const struct kernel_param *params, #define __param_check(name, p, type) \ static inline type *__check_##name(void) { return(p); } -extern struct kernel_param_ops param_ops_byte; -extern int param_set_byte(const char *val, const struct kernel_param *kp); -extern int param_get_byte(char *buffer, const struct kernel_param *kp); +extern int param_set_byte(const char *val, struct kernel_param *kp); +extern int param_get_byte(char *buffer, struct kernel_param *kp); #define param_check_byte(name, p) __param_check(name, p, unsigned char) -extern struct kernel_param_ops param_ops_short; -extern int param_set_short(const char *val, const struct kernel_param *kp); -extern int param_get_short(char *buffer, const struct kernel_param *kp); +extern int param_set_short(const char *val, struct kernel_param *kp); +extern int param_get_short(char *buffer, struct kernel_param *kp); #define param_check_short(name, p) __param_check(name, p, short) -extern struct kernel_param_ops param_ops_ushort; -extern int param_set_ushort(const char *val, const struct kernel_param *kp); -extern int param_get_ushort(char *buffer, const struct kernel_param *kp); +extern int param_set_ushort(const char *val, struct kernel_param *kp); +extern int param_get_ushort(char *buffer, struct kernel_param *kp); #define param_check_ushort(name, p) __param_check(name, p, unsigned short) -extern struct kernel_param_ops param_ops_int; -extern int param_set_int(const char *val, const struct kernel_param *kp); -extern int param_get_int(char *buffer, const struct kernel_param *kp); +extern int param_set_int(const char *val, struct kernel_param *kp); +extern int param_get_int(char *buffer, struct kernel_param *kp); #define param_check_int(name, p) __param_check(name, p, int) -extern struct kernel_param_ops param_ops_uint; -extern int param_set_uint(const char *val, const struct kernel_param *kp); -extern int param_get_uint(char *buffer, const struct kernel_param *kp); +extern int param_set_uint(const char *val, struct kernel_param *kp); +extern int param_get_uint(char *buffer, struct kernel_param *kp); #define param_check_uint(name, p) __param_check(name, p, unsigned int) -extern struct kernel_param_ops param_ops_long; -extern int param_set_long(const char *val, const struct kernel_param *kp); -extern int param_get_long(char *buffer, const struct kernel_param *kp); +extern int param_set_long(const char *val, struct kernel_param *kp); +extern int param_get_long(char *buffer, struct kernel_param *kp); #define param_check_long(name, p) __param_check(name, p, long) -extern struct kernel_param_ops param_ops_ulong; -extern int param_set_ulong(const char *val, const struct kernel_param *kp); -extern int param_get_ulong(char *buffer, const struct kernel_param *kp); +extern int param_set_ulong(const char *val, struct kernel_param *kp); +extern int param_get_ulong(char *buffer, struct kernel_param *kp); #define param_check_ulong(name, p) __param_check(name, p, unsigned long) -extern struct kernel_param_ops param_ops_charp; -extern int param_set_charp(const char *val, const struct kernel_param *kp); -extern int param_get_charp(char *buffer, const struct kernel_param *kp); +extern int param_set_charp(const char *val, struct kernel_param *kp); +extern int param_get_charp(char *buffer, struct kernel_param *kp); #define param_check_charp(name, p) __param_check(name, p, char *) /* For historical reasons "bool" parameters can be (unsigned) "int". */ -extern struct kernel_param_ops param_ops_bool; -extern int param_set_bool(const char *val, const struct kernel_param *kp); -extern int param_get_bool(char *buffer, const struct kernel_param *kp); +extern int param_set_bool(const char *val, struct kernel_param *kp); +extern int param_get_bool(char *buffer, struct kernel_param *kp); #define param_check_bool(name, p) \ static inline void __check_##name(void) \ { \ - BUILD_BUG_ON(!__same_type((p), bool *) && \ - !__same_type((p), unsigned int *) && \ - !__same_type((p), int *)); \ + BUILD_BUG_ON(!__same_type(*(p), bool) && \ + !__same_type(*(p), unsigned int) && \ + !__same_type(*(p), int)); \ } -extern struct kernel_param_ops param_ops_invbool; -extern int param_set_invbool(const char *val, const struct kernel_param *kp); -extern int param_get_invbool(char *buffer, const struct kernel_param *kp); +extern int param_set_invbool(const char *val, struct kernel_param *kp); +extern int param_get_invbool(char *buffer, struct kernel_param *kp); #define param_check_invbool(name, p) __param_check(name, p, bool) -/** - * module_param_array - a parameter which is an array of some type - * @name: the name of the array variable - * @type: the type, as per module_param() - * @nump: optional pointer filled in with the number written - * @perm: visibility in sysfs - * - * Input and output are as comma-separated values. Commas inside values - * don't work properly (eg. an array of charp). - * - * ARRAY_SIZE(@name) is used to determine the number of elements in the - * array, so the definition must be visible. - */ -#define module_param_array(name, type, nump, perm) \ - module_param_array_named(name, name, type, nump, perm) - -/** - * module_param_array_named - renamed parameter which is an array of some type - * @name: a valid C identifier which is the parameter name - * @array: the name of the array variable - * @type: the type, as per module_param() - * @nump: optional pointer filled in with the number written - * @perm: visibility in sysfs - * - * This exposes a different name than the actual variable name. See - * module_param_named() for why this might be necessary. - */ +/* Comma-separated array: *nump is set to number they actually specified. */ #define module_param_array_named(name, array, type, nump, perm) \ static const struct kparam_array __param_arr_##name \ - = { ARRAY_SIZE(array), nump, ¶m_ops_##type, \ + = { ARRAY_SIZE(array), nump, param_set_##type, param_get_##type,\ sizeof(array[0]), array }; \ __module_param_call(MODULE_PARAM_PREFIX, name, \ - ¶m_array_ops, \ + param_array_set, param_array_get, \ .arr = &__param_arr_##name, \ __same_type(array[0], bool), perm); \ __MODULE_PARM_TYPE(name, "array of " #type) -extern struct kernel_param_ops param_array_ops; +#define module_param_array(name, type, nump, perm) \ + module_param_array_named(name, name, type, nump, perm) + +extern int param_array_set(const char *val, struct kernel_param *kp); +extern int param_array_get(char *buffer, struct kernel_param *kp); -extern struct kernel_param_ops param_ops_string; -extern int param_set_copystring(const char *val, const struct kernel_param *); -extern int param_get_string(char *buffer, const struct kernel_param *kp); +extern int param_set_copystring(const char *val, struct kernel_param *kp); +extern int param_get_string(char *buffer, struct kernel_param *kp); /* for exporting parameters in /sys/parameters */ @@ -389,13 +235,13 @@ struct module; #if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES) extern int module_param_sysfs_setup(struct module *mod, - const struct kernel_param *kparam, + struct kernel_param *kparam, unsigned int num_params); extern void module_param_sysfs_remove(struct module *mod); #else static inline int module_param_sysfs_setup(struct module *mod, - const struct kernel_param *kparam, + struct kernel_param *kparam, unsigned int num_params) { return 0; diff --git a/trunk/include/linux/of_device.h b/trunk/include/linux/of_device.h index 835f85ecd2de..35aa44ad9f2c 100644 --- a/trunk/include/linux/of_device.h +++ b/trunk/include/linux/of_device.h @@ -1,6 +1,20 @@ #ifndef _LINUX_OF_DEVICE_H #define _LINUX_OF_DEVICE_H +/* + * The of_device *was* a kind of "base class" that was a superset of + * struct device for use by devices attached to an OF node and probed + * using OF properties. However, the important bit of OF-style + * probing, namely the device node pointer, has been moved into the + * common struct device when CONFIG_OF is set to make OF-style probing + * available to all bus types. So now, just make of_device and + * platform_device equivalent so that current of_platform bus users + * can be transparently migrated over to using the platform bus. + * + * This line will go away once all references to of_device are removed + * from the kernel. + */ +#define of_device platform_device #include #include /* temporary until merge */ @@ -9,6 +23,8 @@ #include #include +#define to_of_device(d) container_of(d, struct of_device, dev) + extern const struct of_device_id *of_match_device( const struct of_device_id *matches, const struct device *dev); extern void of_device_make_bus_id(struct device *dev); diff --git a/trunk/include/linux/of_platform.h b/trunk/include/linux/of_platform.h index a68716ad38ce..4e6d989c06df 100644 --- a/trunk/include/linux/of_platform.h +++ b/trunk/include/linux/of_platform.h @@ -19,17 +19,9 @@ #include #include -/** - * of_platform_driver - Legacy of-aware driver for platform devices. - * - * An of_platform_driver driver is attached to a basic platform_device on - * ether the "platform bus" (platform_bus_type), or the ibm ebus - * (ibmebus_bus_type). - * - * of_platform_driver is being phased out when used with the platform_bus_type, - * and regular platform_drivers should be used instead. When the transition - * is complete, only ibmebus will be using this structure, and the - * platform_driver member of this structure will be removed. +/* + * An of_platform_driver driver is attached to a basic of_device on + * the "platform bus" (platform_bus_type). */ struct of_platform_driver { diff --git a/trunk/include/linux/pagemap.h b/trunk/include/linux/pagemap.h index e12cdc6d79ee..78a702ce4fcb 100644 --- a/trunk/include/linux/pagemap.h +++ b/trunk/include/linux/pagemap.h @@ -13,7 +13,6 @@ #include #include #include /* for in_interrupt() */ -#include /* * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page @@ -282,16 +281,10 @@ static inline loff_t page_offset(struct page *page) return ((loff_t)page->index) << PAGE_CACHE_SHIFT; } -extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma, - unsigned long address); - static inline pgoff_t linear_page_index(struct vm_area_struct *vma, unsigned long address) { - pgoff_t pgoff; - if (unlikely(is_vm_hugetlb_page(vma))) - return linear_hugepage_index(vma, address); - pgoff = (address - vma->vm_start) >> PAGE_SHIFT; + pgoff_t pgoff = (address - vma->vm_start) >> PAGE_SHIFT; pgoff += vma->vm_pgoff; return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT); } diff --git a/trunk/include/linux/poison.h b/trunk/include/linux/poison.h index 2110a81c5e2a..34066ffd893d 100644 --- a/trunk/include/linux/poison.h +++ b/trunk/include/linux/poison.h @@ -48,6 +48,15 @@ #define POISON_FREE 0x6b /* for use-after-free poisoning */ #define POISON_END 0xa5 /* end-byte of poisoning */ +/********** mm/hugetlb.c **********/ +/* + * Private mappings of hugetlb pages use this poisoned value for + * page->mapping. The core VM should not be doing anything with this mapping + * but futex requires the existence of some page->mapping value even though it + * is unused if PAGE_MAPPING_ANON is set. + */ +#define HUGETLB_POISON ((void *)(0x00300300 + POISON_POINTER_DELTA + PAGE_MAPPING_ANON)) + /********** arch/$ARCH/mm/init.c **********/ #define POISON_FREE_INITMEM 0xcc diff --git a/trunk/include/linux/raid/pq.h b/trunk/include/linux/raid/pq.h index 2b59cc824395..1cbbd2c11aa9 100644 --- a/trunk/include/linux/raid/pq.h +++ b/trunk/include/linux/raid/pq.h @@ -62,9 +62,7 @@ extern const char raid6_empty_zero_page[PAGE_SIZE]; #define disable_kernel_altivec() #define EXPORT_SYMBOL(sym) -#define EXPORT_SYMBOL_GPL(sym) #define MODULE_LICENSE(licence) -#define MODULE_DESCRIPTION(desc) #define subsys_initcall(x) #define module_exit(x) #endif /* __KERNEL__ */ diff --git a/trunk/include/linux/regulator/ab8500.h b/trunk/include/linux/regulator/ab8500.h deleted file mode 100644 index f509877c2ed4..000000000000 --- a/trunk/include/linux/regulator/ab8500.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2010 - * - * License Terms: GNU General Public License v2 - * - * Author: Sundar Iyer for ST-Ericsson - * - */ - -#ifndef __LINUX_MFD_AB8500_REGULATOR_H -#define __LINUX_MFD_AB8500_REGULATOR_H - -/* AB8500 regulators */ -#define AB8500_LDO_AUX1 0 -#define AB8500_LDO_AUX2 1 -#define AB8500_LDO_AUX3 2 -#define AB8500_LDO_INTCORE 3 -#define AB8500_LDO_TVOUT 4 -#define AB8500_LDO_AUDIO 5 -#define AB8500_LDO_ANAMIC1 6 -#define AB8500_LDO_ANAMIC2 7 -#define AB8500_LDO_DMIC 8 -#define AB8500_LDO_ANA 9 - -#endif diff --git a/trunk/include/linux/rmap.h b/trunk/include/linux/rmap.h index 31b2fd75dcba..d6661de56f30 100644 --- a/trunk/include/linux/rmap.h +++ b/trunk/include/linux/rmap.h @@ -168,11 +168,6 @@ void page_add_new_anon_rmap(struct page *, struct vm_area_struct *, unsigned lon void page_add_file_rmap(struct page *); void page_remove_rmap(struct page *); -void hugepage_add_anon_rmap(struct page *, struct vm_area_struct *, - unsigned long); -void hugepage_add_new_anon_rmap(struct page *, struct vm_area_struct *, - unsigned long); - static inline void page_dup_rmap(struct page *page) { atomic_inc(&page->_mapcount); diff --git a/trunk/include/linux/s3c_adc_battery.h b/trunk/include/linux/s3c_adc_battery.h deleted file mode 100644 index dbce22faa660..000000000000 --- a/trunk/include/linux/s3c_adc_battery.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _S3C_ADC_BATTERY_H -#define _S3C_ADC_BATTERY_H - -struct s3c_adc_bat_thresh { - int volt; /* mV */ - int cur; /* mA */ - int level; /* percent */ -}; - -struct s3c_adc_bat_pdata { - int (*init)(void); - void (*exit)(void); - void (*enable_charger)(void); - void (*disable_charger)(void); - - int gpio_charge_finished; - - const struct s3c_adc_bat_thresh *lut_noac; - unsigned int lut_noac_cnt; - const struct s3c_adc_bat_thresh *lut_acin; - unsigned int lut_acin_cnt; - - const unsigned int volt_channel; - const unsigned int current_channel; - const unsigned int backup_volt_channel; - - const unsigned int volt_mult; - const unsigned int current_mult; - const unsigned int backup_volt_mult; - const unsigned int internal_impedance; - - const unsigned int backup_volt_max; - const unsigned int backup_volt_min; -}; - -#endif diff --git a/trunk/include/linux/time.h b/trunk/include/linux/time.h index 12612701b1ae..cb34e35fabac 100644 --- a/trunk/include/linux/time.h +++ b/trunk/include/linux/time.h @@ -38,7 +38,7 @@ extern struct timezone sys_tz; #define NSEC_PER_MSEC 1000000L #define USEC_PER_SEC 1000000L #define NSEC_PER_SEC 1000000000L -#define FSEC_PER_SEC 1000000000000000LL +#define FSEC_PER_SEC 1000000000000000L #define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1) diff --git a/trunk/include/linux/vgaarb.h b/trunk/include/linux/vgaarb.h index 6228b5b77d35..814f294d4cd0 100644 --- a/trunk/include/linux/vgaarb.h +++ b/trunk/include/linux/vgaarb.h @@ -31,6 +31,7 @@ #ifndef LINUX_VGA_H #define LINUX_VGA_H +#include /* Legacy VGA regions */ #define VGA_RSRC_NONE 0x00 diff --git a/trunk/include/linux/vmalloc.h b/trunk/include/linux/vmalloc.h index 01c2145118dc..de05e96e0a70 100644 --- a/trunk/include/linux/vmalloc.h +++ b/trunk/include/linux/vmalloc.h @@ -7,8 +7,6 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */ -extern bool vmap_lazy_unmap; - /* bits in flags of vmalloc's vm_struct below */ #define VM_IOREMAP 0x00000001 /* ioremap() and friends */ #define VM_ALLOC 0x00000002 /* vmalloc() */ diff --git a/trunk/include/linux/writeback.h b/trunk/include/linux/writeback.h index 72a5d647a5f2..c24eca71e80c 100644 --- a/trunk/include/linux/writeback.h +++ b/trunk/include/linux/writeback.h @@ -124,9 +124,8 @@ struct ctl_table; int dirty_writeback_centisecs_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); -void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty); -unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, - unsigned long dirty); +void get_dirty_limits(unsigned long *pbackground, unsigned long *pdirty, + unsigned long *pbdi_dirty, struct backing_dev_info *bdi); void page_writeback_init(void); void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, diff --git a/trunk/include/xen/interface/memory.h b/trunk/include/xen/interface/memory.h index d3938d3e71f8..af36ead16817 100644 --- a/trunk/include/xen/interface/memory.h +++ b/trunk/include/xen/interface/memory.h @@ -9,8 +9,6 @@ #ifndef __XEN_PUBLIC_MEMORY_H__ #define __XEN_PUBLIC_MEMORY_H__ -#include - /* * Increase or decrease the specified domain's memory reservation. Returns a * -ve errcode on failure, or the # extents successfully allocated or freed. @@ -54,48 +52,6 @@ struct xen_memory_reservation { }; DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation); -/* - * An atomic exchange of memory pages. If return code is zero then - * @out.extent_list provides GMFNs of the newly-allocated memory. - * Returns zero on complete success, otherwise a negative error code. - * On complete success then always @nr_exchanged == @in.nr_extents. - * On partial success @nr_exchanged indicates how much work was done. - */ -#define XENMEM_exchange 11 -struct xen_memory_exchange { - /* - * [IN] Details of memory extents to be exchanged (GMFN bases). - * Note that @in.address_bits is ignored and unused. - */ - struct xen_memory_reservation in; - - /* - * [IN/OUT] Details of new memory extents. - * We require that: - * 1. @in.domid == @out.domid - * 2. @in.nr_extents << @in.extent_order == - * @out.nr_extents << @out.extent_order - * 3. @in.extent_start and @out.extent_start lists must not overlap - * 4. @out.extent_start lists GPFN bases to be populated - * 5. @out.extent_start is overwritten with allocated GMFN bases - */ - struct xen_memory_reservation out; - - /* - * [OUT] Number of input extents that were successfully exchanged: - * 1. The first @nr_exchanged input extents were successfully - * deallocated. - * 2. The corresponding first entries in the output extent list correctly - * indicate the GMFNs that were successfully exchanged. - * 3. All other input and output extents are untouched. - * 4. If not all input exents are exchanged then the return code of this - * command will be non-zero. - * 5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER! - */ - unsigned long nr_exchanged; -}; - -DEFINE_GUEST_HANDLE_STRUCT(xen_memory_exchange); /* * Returns the maximum machine frame number of mapped RAM in this system. * This command always succeeds (it never returns an error code). @@ -186,10 +142,4 @@ struct xen_translate_gpfn_list { }; DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list); - -/* - * Prevent the balloon driver from changing the memory reservation - * during a driver critical region. - */ -extern spinlock_t xen_reservation_lock; #endif /* __XEN_PUBLIC_MEMORY_H__ */ diff --git a/trunk/include/xen/swiotlb-xen.h b/trunk/include/xen/swiotlb-xen.h deleted file mode 100644 index 2ea2fdc79c16..000000000000 --- a/trunk/include/xen/swiotlb-xen.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef __LINUX_SWIOTLB_XEN_H -#define __LINUX_SWIOTLB_XEN_H - -#include - -extern void xen_swiotlb_init(int verbose); - -extern void -*xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size, - dma_addr_t *dma_handle, gfp_t flags); - -extern void -xen_swiotlb_free_coherent(struct device *hwdev, size_t size, - void *vaddr, dma_addr_t dma_handle); - -extern dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page, - unsigned long offset, size_t size, - enum dma_data_direction dir, - struct dma_attrs *attrs); - -extern void xen_swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr, - size_t size, enum dma_data_direction dir, - struct dma_attrs *attrs); -/* -extern int -xen_swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, - enum dma_data_direction dir); - -extern void -xen_swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents, - enum dma_data_direction dir); -*/ -extern int -xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, - int nelems, enum dma_data_direction dir, - struct dma_attrs *attrs); - -extern void -xen_swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl, - int nelems, enum dma_data_direction dir, - struct dma_attrs *attrs); - -extern void -xen_swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr, - size_t size, enum dma_data_direction dir); - -extern void -xen_swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg, - int nelems, enum dma_data_direction dir); - -extern void -xen_swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr, - size_t size, enum dma_data_direction dir); - -extern void -xen_swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg, - int nelems, enum dma_data_direction dir); - -extern int -xen_swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr); - -extern int -xen_swiotlb_dma_supported(struct device *hwdev, u64 mask); - -#endif /* __LINUX_SWIOTLB_XEN_H */ diff --git a/trunk/include/xen/xen-ops.h b/trunk/include/xen/xen-ops.h index 351f4051f6d8..46bc81ef74c6 100644 --- a/trunk/include/xen/xen-ops.h +++ b/trunk/include/xen/xen-ops.h @@ -17,10 +17,4 @@ void xen_arch_resume(void); int xen_setup_shutdown_event(void); -extern unsigned long *xen_contiguous_bitmap; -int xen_create_contiguous_region(unsigned long vstart, unsigned int order, - unsigned int address_bits); - -void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order); - #endif /* INCLUDE_XEN_OPS_H */ diff --git a/trunk/init/main.c b/trunk/init/main.c index 22d61cb06f98..86cbfd085b01 100644 --- a/trunk/init/main.c +++ b/trunk/init/main.c @@ -201,11 +201,11 @@ static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, }; char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, }; static const char *panic_later, *panic_param; -extern const struct obs_kernel_param __setup_start[], __setup_end[]; +extern struct obs_kernel_param __setup_start[], __setup_end[]; static int __init obsolete_checksetup(char *line) { - const struct obs_kernel_param *p; + struct obs_kernel_param *p; int had_early_param = 0; p = __setup_start; @@ -458,7 +458,7 @@ static noinline void __init_refok rest_init(void) /* Check for early params. */ static int __init do_early_param(char *param, char *val) { - const struct obs_kernel_param *p; + struct obs_kernel_param *p; for (p = __setup_start; p < __setup_end; p++) { if ((p->early && strcmp(param, p->str) == 0) || @@ -536,7 +536,7 @@ static void __init mm_init(void) asmlinkage void __init start_kernel(void) { char * command_line; - extern const struct kernel_param __start___param[], __stop___param[]; + extern struct kernel_param __start___param[], __stop___param[]; smp_setup_processor_id(); diff --git a/trunk/kernel/audit_watch.c b/trunk/kernel/audit_watch.c index f0c9b2e7542d..6bf2306be7d6 100644 --- a/trunk/kernel/audit_watch.c +++ b/trunk/kernel/audit_watch.c @@ -526,8 +526,8 @@ static int audit_watch_handle_event(struct fsnotify_group *group, BUG_ON(group != audit_watch_group); switch (event->data_type) { - case (FSNOTIFY_EVENT_PATH): - inode = event->path.dentry->d_inode; + case (FSNOTIFY_EVENT_FILE): + inode = event->file->f_path.dentry->d_inode; break; case (FSNOTIFY_EVENT_INODE): inode = event->inode; diff --git a/trunk/kernel/cred.c b/trunk/kernel/cred.c index 9a3e22641fe7..60bc8b1e32e6 100644 --- a/trunk/kernel/cred.c +++ b/trunk/kernel/cred.c @@ -22,6 +22,10 @@ #define kdebug(FMT, ...) \ printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__) #else +static inline __attribute__((format(printf, 1, 2))) +void no_printk(const char *fmt, ...) +{ +} #define kdebug(FMT, ...) \ no_printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__) #endif diff --git a/trunk/kernel/kfifo.c b/trunk/kernel/kfifo.c index 4502604ecadf..02192dd905cc 100644 --- a/trunk/kernel/kfifo.c +++ b/trunk/kernel/kfifo.c @@ -10,7 +10,7 @@ * * 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 + * 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 @@ -333,16 +333,17 @@ static int setup_sgl_buf(struct scatterlist *sgl, void *buf, buf += PAGE_SIZE; npage = virt_to_page(buf); if (page_to_phys(page) != page_to_phys(npage) - l) { - sg_set_page(sgl, page, l - off, off); - sgl = sg_next(sgl); - if (++n == nents || sgl == NULL) + sgl->page_link = 0; + sg_set_page(sgl++, page, l - off, off); + if (++n == nents) return n; page = npage; len -= l - off; l = off = 0; } } - sg_set_page(sgl, page, len, off); + sgl->page_link = 0; + sg_set_page(sgl++, page, len, off); return n + 1; } @@ -362,7 +363,7 @@ static unsigned int setup_sgl(struct __kfifo *fifo, struct scatterlist *sgl, } l = min(len, size - off); - n = setup_sgl_buf(sgl, fifo->data + off, nents, l); + n = setup_sgl_buf(sgl, fifo->data + off, nents, l); n += setup_sgl_buf(sgl + n, fifo->data, nents - n, len - l); if (n) diff --git a/trunk/kernel/params.c b/trunk/kernel/params.c index 08107d181758..0b30ecd53a52 100644 --- a/trunk/kernel/params.c +++ b/trunk/kernel/params.c @@ -31,42 +31,6 @@ #define DEBUGP(fmt, a...) #endif -/* Protects all parameters, and incidentally kmalloced_param list. */ -static DEFINE_MUTEX(param_lock); - -/* This just allows us to keep track of which parameters are kmalloced. */ -struct kmalloced_param { - struct list_head list; - char val[]; -}; -static LIST_HEAD(kmalloced_params); - -static void *kmalloc_parameter(unsigned int size) -{ - struct kmalloced_param *p; - - p = kmalloc(sizeof(*p) + size, GFP_KERNEL); - if (!p) - return NULL; - - list_add(&p->list, &kmalloced_params); - return p->val; -} - -/* Does nothing if parameter wasn't kmalloced above. */ -static void maybe_kfree_parameter(void *param) -{ - struct kmalloced_param *p; - - list_for_each_entry(p, &kmalloced_params, list) { - if (p->val == param) { - list_del(&p->list); - kfree(p); - break; - } - } -} - static inline char dash2underscore(char c) { if (c == '-') @@ -85,25 +49,18 @@ static inline int parameq(const char *input, const char *paramname) static int parse_one(char *param, char *val, - const struct kernel_param *params, + struct kernel_param *params, unsigned num_params, int (*handle_unknown)(char *param, char *val)) { unsigned int i; - int err; /* Find parameter */ for (i = 0; i < num_params; i++) { if (parameq(param, params[i].name)) { - /* Noone handled NULL, so do it here. */ - if (!val && params[i].ops->set != param_set_bool) - return -EINVAL; DEBUGP("They are equal! Calling %p\n", - params[i].ops->set); - mutex_lock(¶m_lock); - err = params[i].ops->set(val, ¶ms[i]); - mutex_unlock(¶m_lock); - return err; + params[i].set); + return params[i].set(val, ¶ms[i]); } } @@ -171,7 +128,7 @@ static char *next_arg(char *args, char **param, char **val) /* Args looks like "foo=bar,bar2 baz=fuz wiz". */ int parse_args(const char *name, char *args, - const struct kernel_param *params, + struct kernel_param *params, unsigned num, int (*unknown)(char *param, char *val)) { @@ -219,29 +176,22 @@ int parse_args(const char *name, /* Lazy bastard, eh? */ #define STANDARD_PARAM_DEF(name, type, format, tmptype, strtolfn) \ - int param_set_##name(const char *val, const struct kernel_param *kp) \ + int param_set_##name(const char *val, struct kernel_param *kp) \ { \ tmptype l; \ int ret; \ \ + if (!val) return -EINVAL; \ ret = strtolfn(val, 0, &l); \ if (ret == -EINVAL || ((type)l != l)) \ return -EINVAL; \ *((type *)kp->arg) = l; \ return 0; \ } \ - int param_get_##name(char *buffer, const struct kernel_param *kp) \ + int param_get_##name(char *buffer, struct kernel_param *kp) \ { \ return sprintf(buffer, format, *((type *)kp->arg)); \ - } \ - struct kernel_param_ops param_ops_##name = { \ - .set = param_set_##name, \ - .get = param_get_##name, \ - }; \ - EXPORT_SYMBOL(param_set_##name); \ - EXPORT_SYMBOL(param_get_##name); \ - EXPORT_SYMBOL(param_ops_##name) - + } STANDARD_PARAM_DEF(byte, unsigned char, "%c", unsigned long, strict_strtoul); STANDARD_PARAM_DEF(short, short, "%hi", long, strict_strtol); @@ -251,50 +201,39 @@ STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, strict_strtoul); STANDARD_PARAM_DEF(long, long, "%li", long, strict_strtol); STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, strict_strtoul); -int param_set_charp(const char *val, const struct kernel_param *kp) +int param_set_charp(const char *val, struct kernel_param *kp) { + if (!val) { + printk(KERN_ERR "%s: string parameter expected\n", + kp->name); + return -EINVAL; + } + if (strlen(val) > 1024) { printk(KERN_ERR "%s: string parameter too long\n", kp->name); return -ENOSPC; } - maybe_kfree_parameter(*(char **)kp->arg); - - /* This is a hack. We can't kmalloc in early boot, and we + /* This is a hack. We can't need to strdup in early boot, and we * don't need to; this mangled commandline is preserved. */ if (slab_is_available()) { - *(char **)kp->arg = kmalloc_parameter(strlen(val)+1); + *(char **)kp->arg = kstrdup(val, GFP_KERNEL); if (!*(char **)kp->arg) return -ENOMEM; - strcpy(*(char **)kp->arg, val); } else *(const char **)kp->arg = val; return 0; } -EXPORT_SYMBOL(param_set_charp); -int param_get_charp(char *buffer, const struct kernel_param *kp) +int param_get_charp(char *buffer, struct kernel_param *kp) { return sprintf(buffer, "%s", *((char **)kp->arg)); } -EXPORT_SYMBOL(param_get_charp); - -static void param_free_charp(void *arg) -{ - maybe_kfree_parameter(*((char **)arg)); -} - -struct kernel_param_ops param_ops_charp = { - .set = param_set_charp, - .get = param_get_charp, - .free = param_free_charp, -}; -EXPORT_SYMBOL(param_ops_charp); /* Actually could be a bool or an int, for historical reasons. */ -int param_set_bool(const char *val, const struct kernel_param *kp) +int param_set_bool(const char *val, struct kernel_param *kp) { bool v; @@ -319,9 +258,8 @@ int param_set_bool(const char *val, const struct kernel_param *kp) *(int *)kp->arg = v; return 0; } -EXPORT_SYMBOL(param_set_bool); -int param_get_bool(char *buffer, const struct kernel_param *kp) +int param_get_bool(char *buffer, struct kernel_param *kp) { bool val; if (kp->flags & KPARAM_ISBOOL) @@ -332,16 +270,9 @@ int param_get_bool(char *buffer, const struct kernel_param *kp) /* Y and N chosen as being relatively non-coder friendly */ return sprintf(buffer, "%c", val ? 'Y' : 'N'); } -EXPORT_SYMBOL(param_get_bool); - -struct kernel_param_ops param_ops_bool = { - .set = param_set_bool, - .get = param_get_bool, -}; -EXPORT_SYMBOL(param_ops_bool); /* This one must be bool. */ -int param_set_invbool(const char *val, const struct kernel_param *kp) +int param_set_invbool(const char *val, struct kernel_param *kp) { int ret; bool boolval; @@ -354,26 +285,18 @@ int param_set_invbool(const char *val, const struct kernel_param *kp) *(bool *)kp->arg = !boolval; return ret; } -EXPORT_SYMBOL(param_set_invbool); -int param_get_invbool(char *buffer, const struct kernel_param *kp) +int param_get_invbool(char *buffer, struct kernel_param *kp) { return sprintf(buffer, "%c", (*(bool *)kp->arg) ? 'N' : 'Y'); } -EXPORT_SYMBOL(param_get_invbool); - -struct kernel_param_ops param_ops_invbool = { - .set = param_set_invbool, - .get = param_get_invbool, -}; -EXPORT_SYMBOL(param_ops_invbool); /* We break the rule and mangle the string. */ static int param_array(const char *name, const char *val, unsigned int min, unsigned int max, void *elem, int elemsize, - int (*set)(const char *, const struct kernel_param *kp), + int (*set)(const char *, struct kernel_param *kp), u16 flags, unsigned int *num) { @@ -386,6 +309,12 @@ static int param_array(const char *name, kp.arg = elem; kp.flags = flags; + /* No equals sign? */ + if (!val) { + printk(KERN_ERR "%s: expects arguments\n", name); + return -EINVAL; + } + *num = 0; /* We expect a comma-separated list of values. */ do { @@ -401,7 +330,6 @@ static int param_array(const char *name, /* nul-terminate and parse */ save = val[len]; ((char *)val)[len] = '\0'; - BUG_ON(!mutex_is_locked(¶m_lock)); ret = set(val, &kp); if (ret != 0) @@ -419,17 +347,17 @@ static int param_array(const char *name, return 0; } -static int param_array_set(const char *val, const struct kernel_param *kp) +int param_array_set(const char *val, struct kernel_param *kp) { const struct kparam_array *arr = kp->arr; unsigned int temp_num; return param_array(kp->name, val, 1, arr->max, arr->elem, - arr->elemsize, arr->ops->set, kp->flags, + arr->elemsize, arr->set, kp->flags, arr->num ?: &temp_num); } -static int param_array_get(char *buffer, const struct kernel_param *kp) +int param_array_get(char *buffer, struct kernel_param *kp) { int i, off, ret; const struct kparam_array *arr = kp->arr; @@ -440,8 +368,7 @@ static int param_array_get(char *buffer, const struct kernel_param *kp) if (i) buffer[off++] = ','; p.arg = arr->elem + arr->elemsize * i; - BUG_ON(!mutex_is_locked(¶m_lock)); - ret = arr->ops->get(buffer + off, &p); + ret = arr->get(buffer + off, &p); if (ret < 0) return ret; off += ret; @@ -450,27 +377,14 @@ static int param_array_get(char *buffer, const struct kernel_param *kp) return off; } -static void param_array_free(void *arg) -{ - unsigned int i; - const struct kparam_array *arr = arg; - - if (arr->ops->free) - for (i = 0; i < (arr->num ? *arr->num : arr->max); i++) - arr->ops->free(arr->elem + arr->elemsize * i); -} - -struct kernel_param_ops param_array_ops = { - .set = param_array_set, - .get = param_array_get, - .free = param_array_free, -}; -EXPORT_SYMBOL(param_array_ops); - -int param_set_copystring(const char *val, const struct kernel_param *kp) +int param_set_copystring(const char *val, struct kernel_param *kp) { const struct kparam_string *kps = kp->str; + if (!val) { + printk(KERN_ERR "%s: missing param set value\n", kp->name); + return -EINVAL; + } if (strlen(val)+1 > kps->maxlen) { printk(KERN_ERR "%s: string doesn't fit in %u chars.\n", kp->name, kps->maxlen-1); @@ -479,20 +393,12 @@ int param_set_copystring(const char *val, const struct kernel_param *kp) strcpy(kps->string, val); return 0; } -EXPORT_SYMBOL(param_set_copystring); -int param_get_string(char *buffer, const struct kernel_param *kp) +int param_get_string(char *buffer, struct kernel_param *kp) { const struct kparam_string *kps = kp->str; return strlcpy(buffer, kps->string, kps->maxlen); } -EXPORT_SYMBOL(param_get_string); - -struct kernel_param_ops param_ops_string = { - .set = param_set_copystring, - .get = param_get_string, -}; -EXPORT_SYMBOL(param_ops_string); /* sysfs output in /sys/modules/XYZ/parameters/ */ #define to_module_attr(n) container_of(n, struct module_attribute, attr) @@ -503,7 +409,7 @@ extern struct kernel_param __start___param[], __stop___param[]; struct param_attribute { struct module_attribute mattr; - const struct kernel_param *param; + struct kernel_param *param; }; struct module_param_attrs @@ -522,12 +428,10 @@ static ssize_t param_attr_show(struct module_attribute *mattr, int count; struct param_attribute *attribute = to_param_attr(mattr); - if (!attribute->param->ops->get) + if (!attribute->param->get) return -EPERM; - mutex_lock(¶m_lock); - count = attribute->param->ops->get(buf, attribute->param); - mutex_unlock(¶m_lock); + count = attribute->param->get(buf, attribute->param); if (count > 0) { strcat(buf, "\n"); ++count; @@ -543,12 +447,10 @@ static ssize_t param_attr_store(struct module_attribute *mattr, int err; struct param_attribute *attribute = to_param_attr(mattr); - if (!attribute->param->ops->set) + if (!attribute->param->set) return -EPERM; - mutex_lock(¶m_lock); - err = attribute->param->ops->set(buf, attribute->param); - mutex_unlock(¶m_lock); + err = attribute->param->set(buf, attribute->param); if (!err) return len; return err; @@ -562,18 +464,6 @@ static ssize_t param_attr_store(struct module_attribute *mattr, #endif #ifdef CONFIG_SYSFS -void __kernel_param_lock(void) -{ - mutex_lock(¶m_lock); -} -EXPORT_SYMBOL(__kernel_param_lock); - -void __kernel_param_unlock(void) -{ - mutex_unlock(¶m_lock); -} -EXPORT_SYMBOL(__kernel_param_unlock); - /* * add_sysfs_param - add a parameter to sysfs * @mk: struct module_kobject @@ -585,7 +475,7 @@ EXPORT_SYMBOL(__kernel_param_unlock); * if there's an error. */ static __modinit int add_sysfs_param(struct module_kobject *mk, - const struct kernel_param *kp, + struct kernel_param *kp, const char *name) { struct module_param_attrs *new; @@ -667,7 +557,7 @@ static void free_module_param_attrs(struct module_kobject *mk) * /sys/module/[mod->name]/parameters/ */ int module_param_sysfs_setup(struct module *mod, - const struct kernel_param *kparam, + struct kernel_param *kparam, unsigned int num_params) { int i, err; @@ -712,11 +602,7 @@ void module_param_sysfs_remove(struct module *mod) void destroy_params(const struct kernel_param *params, unsigned num) { - unsigned int i; - - for (i = 0; i < num; i++) - if (params[i].ops->free) - params[i].ops->free(params[i].arg); + /* FIXME: This should free kmalloced charp parameters. It doesn't. */ } static void __init kernel_add_sysfs_param(const char *name, @@ -882,3 +768,28 @@ static int __init param_sysfs_init(void) subsys_initcall(param_sysfs_init); #endif /* CONFIG_SYSFS */ + +EXPORT_SYMBOL(param_set_byte); +EXPORT_SYMBOL(param_get_byte); +EXPORT_SYMBOL(param_set_short); +EXPORT_SYMBOL(param_get_short); +EXPORT_SYMBOL(param_set_ushort); +EXPORT_SYMBOL(param_get_ushort); +EXPORT_SYMBOL(param_set_int); +EXPORT_SYMBOL(param_get_int); +EXPORT_SYMBOL(param_set_uint); +EXPORT_SYMBOL(param_get_uint); +EXPORT_SYMBOL(param_set_long); +EXPORT_SYMBOL(param_get_long); +EXPORT_SYMBOL(param_set_ulong); +EXPORT_SYMBOL(param_get_ulong); +EXPORT_SYMBOL(param_set_charp); +EXPORT_SYMBOL(param_get_charp); +EXPORT_SYMBOL(param_set_bool); +EXPORT_SYMBOL(param_get_bool); +EXPORT_SYMBOL(param_set_invbool); +EXPORT_SYMBOL(param_get_invbool); +EXPORT_SYMBOL(param_array_set); +EXPORT_SYMBOL(param_array_get); +EXPORT_SYMBOL(param_set_copystring); +EXPORT_SYMBOL(param_get_string); diff --git a/trunk/kernel/time/timekeeping.c b/trunk/kernel/time/timekeeping.c index e960d824263f..e14c839e9faa 100644 --- a/trunk/kernel/time/timekeeping.c +++ b/trunk/kernel/time/timekeeping.c @@ -690,7 +690,6 @@ static void timekeeping_adjust(s64 offset) static cycle_t logarithmic_accumulation(cycle_t offset, int shift) { u64 nsecps = (u64)NSEC_PER_SEC << timekeeper.shift; - u64 raw_nsecs; /* If the offset is smaller then a shifted interval, do nothing */ if (offset < timekeeper.cycle_interval<= NSEC_PER_SEC) { - raw_nsecs -= NSEC_PER_SEC; + /* Accumulate into raw time */ + raw_time.tv_nsec += timekeeper.raw_interval << shift;; + while (raw_time.tv_nsec >= NSEC_PER_SEC) { + raw_time.tv_nsec -= NSEC_PER_SEC; raw_time.tv_sec++; } - raw_time.tv_nsec = raw_nsecs; /* Accumulate error between NTP and clock interval */ timekeeper.ntp_error += tick_length << shift; diff --git a/trunk/kernel/trace/blktrace.c b/trunk/kernel/trace/blktrace.c index 959f8d6c8cc1..82499a5bdcb7 100644 --- a/trunk/kernel/trace/blktrace.c +++ b/trunk/kernel/trace/blktrace.c @@ -710,9 +710,6 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq, if (rq->cmd_flags & REQ_DISCARD) rw |= REQ_DISCARD; - if (rq->cmd_flags & REQ_SECURE) - rw |= REQ_SECURE; - if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { what |= BLK_TC_ACT(BLK_TC_PC); __blk_add_trace(bt, 0, blk_rq_bytes(rq), rw, @@ -1819,8 +1816,6 @@ void blk_fill_rwbs(char *rwbs, u32 rw, int bytes) rwbs[i++] = 'S'; if (rw & REQ_META) rwbs[i++] = 'M'; - if (rw & REQ_SECURE) - rwbs[i++] = 'E'; rwbs[i] = '\0'; } @@ -1833,9 +1828,6 @@ void blk_fill_rwbs_rq(char *rwbs, struct request *rq) if (rq->cmd_flags & REQ_DISCARD) rw |= REQ_DISCARD; - if (rq->cmd_flags & REQ_SECURE) - rw |= REQ_SECURE; - bytes = blk_rq_bytes(rq); blk_fill_rwbs(rwbs, rw, bytes); diff --git a/trunk/lib/inflate.c b/trunk/lib/inflate.c index 013a76193481..677b738c2204 100644 --- a/trunk/lib/inflate.c +++ b/trunk/lib/inflate.c @@ -103,9 +103,7 @@ the two sets of lengths. */ #include -#ifdef NO_INFLATE_MALLOC #include -#endif #ifdef RCSID static char rcsid[] = "#Id: inflate.c,v 0.14 1993/06/10 13:27:04 jloup Exp #"; diff --git a/trunk/lib/raid6/Makefile b/trunk/lib/raid6/Makefile index 8a38102770f3..19bf32da644f 100644 --- a/trunk/lib/raid6/Makefile +++ b/trunk/lib/raid6/Makefile @@ -1,8 +1,11 @@ obj-$(CONFIG_RAID6_PQ) += raid6_pq.o -raid6_pq-y += algos.o recov.o tables.o int1.o int2.o int4.o \ - int8.o int16.o int32.o altivec1.o altivec2.o altivec4.o \ - altivec8.o mmx.o sse1.o sse2.o +raid6_pq-y += raid6algos.o raid6recov.o raid6tables.o \ + raid6int1.o raid6int2.o raid6int4.o \ + raid6int8.o raid6int16.o raid6int32.o \ + raid6altivec1.o raid6altivec2.o raid6altivec4.o \ + raid6altivec8.o \ + raid6mmx.o raid6sse1.o raid6sse2.o hostprogs-y += mktables quiet_cmd_unroll = UNROLL $@ @@ -13,63 +16,63 @@ ifeq ($(CONFIG_ALTIVEC),y) altivec_flags := -maltivec -mabi=altivec endif -targets += int1.c -$(obj)/int1.c: UNROLL := 1 -$(obj)/int1.c: $(src)/int.uc $(src)/unroll.awk FORCE +targets += raid6int1.c +$(obj)/raid6int1.c: UNROLL := 1 +$(obj)/raid6int1.c: $(src)/raid6int.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -targets += int2.c -$(obj)/int2.c: UNROLL := 2 -$(obj)/int2.c: $(src)/int.uc $(src)/unroll.awk FORCE +targets += raid6int2.c +$(obj)/raid6int2.c: UNROLL := 2 +$(obj)/raid6int2.c: $(src)/raid6int.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -targets += int4.c -$(obj)/int4.c: UNROLL := 4 -$(obj)/int4.c: $(src)/int.uc $(src)/unroll.awk FORCE +targets += raid6int4.c +$(obj)/raid6int4.c: UNROLL := 4 +$(obj)/raid6int4.c: $(src)/raid6int.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -targets += int8.c -$(obj)/int8.c: UNROLL := 8 -$(obj)/int8.c: $(src)/int.uc $(src)/unroll.awk FORCE +targets += raid6int8.c +$(obj)/raid6int8.c: UNROLL := 8 +$(obj)/raid6int8.c: $(src)/raid6int.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -targets += int16.c -$(obj)/int16.c: UNROLL := 16 -$(obj)/int16.c: $(src)/int.uc $(src)/unroll.awk FORCE +targets += raid6int16.c +$(obj)/raid6int16.c: UNROLL := 16 +$(obj)/raid6int16.c: $(src)/raid6int.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -targets += int32.c -$(obj)/int32.c: UNROLL := 32 -$(obj)/int32.c: $(src)/int.uc $(src)/unroll.awk FORCE +targets += raid6int32.c +$(obj)/raid6int32.c: UNROLL := 32 +$(obj)/raid6int32.c: $(src)/raid6int.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -CFLAGS_altivec1.o += $(altivec_flags) -targets += altivec1.c -$(obj)/altivec1.c: UNROLL := 1 -$(obj)/altivec1.c: $(src)/altivec.uc $(src)/unroll.awk FORCE +CFLAGS_raid6altivec1.o += $(altivec_flags) +targets += raid6altivec1.c +$(obj)/raid6altivec1.c: UNROLL := 1 +$(obj)/raid6altivec1.c: $(src)/raid6altivec.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -CFLAGS_altivec2.o += $(altivec_flags) -targets += altivec2.c -$(obj)/altivec2.c: UNROLL := 2 -$(obj)/altivec2.c: $(src)/altivec.uc $(src)/unroll.awk FORCE +CFLAGS_raid6altivec2.o += $(altivec_flags) +targets += raid6altivec2.c +$(obj)/raid6altivec2.c: UNROLL := 2 +$(obj)/raid6altivec2.c: $(src)/raid6altivec.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -CFLAGS_altivec4.o += $(altivec_flags) -targets += altivec4.c -$(obj)/altivec4.c: UNROLL := 4 -$(obj)/altivec4.c: $(src)/altivec.uc $(src)/unroll.awk FORCE +CFLAGS_raid6altivec4.o += $(altivec_flags) +targets += raid6altivec4.c +$(obj)/raid6altivec4.c: UNROLL := 4 +$(obj)/raid6altivec4.c: $(src)/raid6altivec.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -CFLAGS_altivec8.o += $(altivec_flags) -targets += altivec8.c -$(obj)/altivec8.c: UNROLL := 8 -$(obj)/altivec8.c: $(src)/altivec.uc $(src)/unroll.awk FORCE +CFLAGS_raid6altivec8.o += $(altivec_flags) +targets += raid6altivec8.c +$(obj)/raid6altivec8.c: UNROLL := 8 +$(obj)/raid6altivec8.c: $(src)/raid6altivec.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) quiet_cmd_mktable = TABLE $@ cmd_mktable = $(obj)/mktables > $@ || ( rm -f $@ && exit 1 ) -targets += tables.c -$(obj)/tables.c: $(obj)/mktables FORCE +targets += raid6tables.c +$(obj)/raid6tables.c: $(obj)/mktables FORCE $(call if_changed,mktable) diff --git a/trunk/lib/raid6/algos.c b/trunk/lib/raid6/raid6algos.c similarity index 99% rename from trunk/lib/raid6/algos.c rename to trunk/lib/raid6/raid6algos.c index b595f560bee7..1f8784bfd44d 100644 --- a/trunk/lib/raid6/algos.c +++ b/trunk/lib/raid6/raid6algos.c @@ -11,17 +11,17 @@ * ----------------------------------------------------------------------- */ /* - * raid6/algos.c + * raid6algos.c * * Algorithm list and algorithm selection for RAID-6 */ #include +#include #ifndef __KERNEL__ #include #include #else -#include #if !RAID6_USE_EMPTY_ZERO_PAGE /* In .bss so it's zeroed */ const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(256))); diff --git a/trunk/lib/raid6/altivec.uc b/trunk/lib/raid6/raid6altivec.uc similarity index 100% rename from trunk/lib/raid6/altivec.uc rename to trunk/lib/raid6/raid6altivec.uc diff --git a/trunk/lib/raid6/int.uc b/trunk/lib/raid6/raid6int.uc similarity index 100% rename from trunk/lib/raid6/int.uc rename to trunk/lib/raid6/raid6int.uc diff --git a/trunk/lib/raid6/mmx.c b/trunk/lib/raid6/raid6mmx.c similarity index 98% rename from trunk/lib/raid6/mmx.c rename to trunk/lib/raid6/raid6mmx.c index 279347f23094..e7f6c13132bf 100644 --- a/trunk/lib/raid6/mmx.c +++ b/trunk/lib/raid6/raid6mmx.c @@ -11,7 +11,7 @@ * ----------------------------------------------------------------------- */ /* - * raid6/mmx.c + * raid6mmx.c * * MMX implementation of RAID-6 syndrome functions */ @@ -19,9 +19,9 @@ #if defined(__i386__) && !defined(__arch_um__) #include -#include "x86.h" +#include "raid6x86.h" -/* Shared with raid6/sse1.c */ +/* Shared with raid6sse1.c */ const struct raid6_mmx_constants { u64 x1d; } raid6_mmx_constants = { diff --git a/trunk/lib/raid6/recov.c b/trunk/lib/raid6/raid6recov.c similarity index 99% rename from trunk/lib/raid6/recov.c rename to trunk/lib/raid6/raid6recov.c index 8590d19cf522..2609f00e0d61 100644 --- a/trunk/lib/raid6/recov.c +++ b/trunk/lib/raid6/raid6recov.c @@ -11,7 +11,7 @@ * ----------------------------------------------------------------------- */ /* - * raid6/recov.c + * raid6recov.c * * RAID-6 data recovery in dual failure mode. In single failure mode, * use the RAID-5 algorithm (or, in the case of Q failure, just reconstruct diff --git a/trunk/lib/raid6/sse1.c b/trunk/lib/raid6/raid6sse1.c similarity index 98% rename from trunk/lib/raid6/sse1.c rename to trunk/lib/raid6/raid6sse1.c index 10dd91948c07..b274dd5eab8f 100644 --- a/trunk/lib/raid6/sse1.c +++ b/trunk/lib/raid6/raid6sse1.c @@ -11,7 +11,7 @@ * ----------------------------------------------------------------------- */ /* - * raid6/sse1.c + * raid6sse1.c * * SSE-1/MMXEXT implementation of RAID-6 syndrome functions * @@ -24,9 +24,9 @@ #if defined(__i386__) && !defined(__arch_um__) #include -#include "x86.h" +#include "raid6x86.h" -/* Defined in raid6/mmx.c */ +/* Defined in raid6mmx.c */ extern const struct raid6_mmx_constants { u64 x1d; } raid6_mmx_constants; diff --git a/trunk/lib/raid6/sse2.c b/trunk/lib/raid6/raid6sse2.c similarity index 99% rename from trunk/lib/raid6/sse2.c rename to trunk/lib/raid6/raid6sse2.c index bc2d57daa589..6ed6c6c0389f 100644 --- a/trunk/lib/raid6/sse2.c +++ b/trunk/lib/raid6/raid6sse2.c @@ -11,7 +11,7 @@ * ----------------------------------------------------------------------- */ /* - * raid6/sse2.c + * raid6sse2.c * * SSE-2 implementation of RAID-6 syndrome functions * @@ -20,7 +20,7 @@ #if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) #include -#include "x86.h" +#include "raid6x86.h" static const struct raid6_sse_constants { u64 x1d[2]; diff --git a/trunk/lib/raid6/raid6test/Makefile b/trunk/lib/raid6/raid6test/Makefile new file mode 100644 index 000000000000..2874cbef529d --- /dev/null +++ b/trunk/lib/raid6/raid6test/Makefile @@ -0,0 +1,75 @@ +# +# This is a simple Makefile to test some of the RAID-6 code +# from userspace. +# + +CC = gcc +OPTFLAGS = -O2 # Adjust as desired +CFLAGS = -I.. -I ../../../include -g $(OPTFLAGS) +LD = ld +AWK = awk +AR = ar +RANLIB = ranlib + +.c.o: + $(CC) $(CFLAGS) -c -o $@ $< + +%.c: ../%.c + cp -f $< $@ + +%.uc: ../%.uc + cp -f $< $@ + +all: raid6.a raid6test + +raid6.a: raid6int1.o raid6int2.o raid6int4.o raid6int8.o raid6int16.o \ + raid6int32.o \ + raid6mmx.o raid6sse1.o raid6sse2.o \ + raid6altivec1.o raid6altivec2.o raid6altivec4.o raid6altivec8.o \ + raid6recov.o raid6algos.o \ + raid6tables.o + rm -f $@ + $(AR) cq $@ $^ + $(RANLIB) $@ + +raid6test: test.c raid6.a + $(CC) $(CFLAGS) -o raid6test $^ + +raid6altivec1.c: raid6altivec.uc ../unroll.awk + $(AWK) ../unroll.awk -vN=1 < raid6altivec.uc > $@ + +raid6altivec2.c: raid6altivec.uc ../unroll.awk + $(AWK) ../unroll.awk -vN=2 < raid6altivec.uc > $@ + +raid6altivec4.c: raid6altivec.uc ../unroll.awk + $(AWK) ../unroll.awk -vN=4 < raid6altivec.uc > $@ + +raid6altivec8.c: raid6altivec.uc ../unroll.awk + $(AWK) ../unroll.awk -vN=8 < raid6altivec.uc > $@ + +raid6int1.c: raid6int.uc ../unroll.awk + $(AWK) ../unroll.awk -vN=1 < raid6int.uc > $@ + +raid6int2.c: raid6int.uc ../unroll.awk + $(AWK) ../unroll.awk -vN=2 < raid6int.uc > $@ + +raid6int4.c: raid6int.uc ../unroll.awk + $(AWK) ../unroll.awk -vN=4 < raid6int.uc > $@ + +raid6int8.c: raid6int.uc ../unroll.awk + $(AWK) ../unroll.awk -vN=8 < raid6int.uc > $@ + +raid6int16.c: raid6int.uc ../unroll.awk + $(AWK) ../unroll.awk -vN=16 < raid6int.uc > $@ + +raid6int32.c: raid6int.uc ../unroll.awk + $(AWK) ../unroll.awk -vN=32 < raid6int.uc > $@ + +raid6tables.c: mktables + ./mktables > raid6tables.c + +clean: + rm -f *.o *.a mktables mktables.c raid6int.uc raid6*.c raid6test + +spotless: clean + rm -f *~ diff --git a/trunk/lib/raid6/test/test.c b/trunk/lib/raid6/raid6test/test.c similarity index 100% rename from trunk/lib/raid6/test/test.c rename to trunk/lib/raid6/raid6test/test.c diff --git a/trunk/lib/raid6/x86.h b/trunk/lib/raid6/raid6x86.h similarity index 99% rename from trunk/lib/raid6/x86.h rename to trunk/lib/raid6/raid6x86.h index cb2a8c91c886..4c22c1568558 100644 --- a/trunk/lib/raid6/x86.h +++ b/trunk/lib/raid6/raid6x86.h @@ -11,7 +11,7 @@ * ----------------------------------------------------------------------- */ /* - * raid6/x86.h + * raid6x86.h * * Definitions common to x86 and x86-64 RAID-6 code only */ diff --git a/trunk/lib/raid6/test/Makefile b/trunk/lib/raid6/test/Makefile deleted file mode 100644 index aa651697b6dc..000000000000 --- a/trunk/lib/raid6/test/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -# -# This is a simple Makefile to test some of the RAID-6 code -# from userspace. -# - -CC = gcc -OPTFLAGS = -O2 # Adjust as desired -CFLAGS = -I.. -I ../../../include -g $(OPTFLAGS) -LD = ld -AWK = awk -f -AR = ar -RANLIB = ranlib - -.c.o: - $(CC) $(CFLAGS) -c -o $@ $< - -%.c: ../%.c - cp -f $< $@ - -%.uc: ../%.uc - cp -f $< $@ - -all: raid6.a raid6test - -raid6.a: int1.o int2.o int4.o int8.o int16.o int32.o mmx.o sse1.o sse2.o \ - altivec1.o altivec2.o altivec4.o altivec8.o recov.o algos.o \ - tables.o - rm -f $@ - $(AR) cq $@ $^ - $(RANLIB) $@ - -raid6test: test.c raid6.a - $(CC) $(CFLAGS) -o raid6test $^ - -altivec1.c: altivec.uc ../unroll.awk - $(AWK) ../unroll.awk -vN=1 < altivec.uc > $@ - -altivec2.c: altivec.uc ../unroll.awk - $(AWK) ../unroll.awk -vN=2 < altivec.uc > $@ - -altivec4.c: altivec.uc ../unroll.awk - $(AWK) ../unroll.awk -vN=4 < altivec.uc > $@ - -altivec8.c: altivec.uc ../unroll.awk - $(AWK) ../unroll.awk -vN=8 < altivec.uc > $@ - -int1.c: int.uc ../unroll.awk - $(AWK) ../unroll.awk -vN=1 < int.uc > $@ - -int2.c: int.uc ../unroll.awk - $(AWK) ../unroll.awk -vN=2 < int.uc > $@ - -int4.c: int.uc ../unroll.awk - $(AWK) ../unroll.awk -vN=4 < int.uc > $@ - -int8.c: int.uc ../unroll.awk - $(AWK) ../unroll.awk -vN=8 < int.uc > $@ - -int16.c: int.uc ../unroll.awk - $(AWK) ../unroll.awk -vN=16 < int.uc > $@ - -int32.c: int.uc ../unroll.awk - $(AWK) ../unroll.awk -vN=32 < int.uc > $@ - -tables.c: mktables - ./mktables > tables.c - -clean: - rm -f *.o *.a mktables mktables.c *.uc int*.c altivec*.c tables.c raid6test - -spotless: clean - rm -f *~ diff --git a/trunk/mm/backing-dev.c b/trunk/mm/backing-dev.c index eaa4a5bbe063..08d357522e78 100644 --- a/trunk/mm/backing-dev.c +++ b/trunk/mm/backing-dev.c @@ -81,8 +81,7 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v) nr_more_io++; spin_unlock(&inode_lock); - global_dirty_limits(&background_thresh, &dirty_thresh); - bdi_thresh = bdi_dirty_limit(bdi, dirty_thresh); + get_dirty_limits(&background_thresh, &dirty_thresh, &bdi_thresh, bdi); #define K(x) ((x) << (PAGE_SHIFT - 10)) seq_printf(m, diff --git a/trunk/mm/hugetlb.c b/trunk/mm/hugetlb.c index cc5be788a39f..b61d2db9f34e 100644 --- a/trunk/mm/hugetlb.c +++ b/trunk/mm/hugetlb.c @@ -18,9 +18,6 @@ #include #include #include -#include -#include -#include #include #include @@ -223,12 +220,6 @@ static pgoff_t vma_hugecache_offset(struct hstate *h, (vma->vm_pgoff >> huge_page_order(h)); } -pgoff_t linear_hugepage_index(struct vm_area_struct *vma, - unsigned long address) -{ - return vma_hugecache_offset(hstate_vma(vma), vma, address); -} - /* * Return the size of the pages allocated when backing a VMA. In the majority * cases this will be same size as used by the page table entries. @@ -561,7 +552,6 @@ static void free_huge_page(struct page *page) set_page_private(page, 0); page->mapping = NULL; BUG_ON(page_count(page)); - BUG_ON(page_mapcount(page)); INIT_LIST_HEAD(&page->lru); spin_lock(&hugetlb_lock); @@ -615,8 +605,6 @@ int PageHuge(struct page *page) return dtor == free_huge_page; } -EXPORT_SYMBOL_GPL(PageHuge); - static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid) { struct page *page; @@ -2141,7 +2129,6 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, entry = huge_ptep_get(src_pte); ptepage = pte_page(entry); get_page(ptepage); - page_dup_rmap(ptepage); set_huge_pte_at(dst, addr, dst_pte, entry); } spin_unlock(&src->page_table_lock); @@ -2153,19 +2140,6 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, return -ENOMEM; } -static int is_hugetlb_entry_hwpoisoned(pte_t pte) -{ - swp_entry_t swp; - - if (huge_pte_none(pte) || pte_present(pte)) - return 0; - swp = pte_to_swp_entry(pte); - if (non_swap_entry(swp) && is_hwpoison_entry(swp)) { - return 1; - } else - return 0; -} - void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, unsigned long end, struct page *ref_page) { @@ -2224,12 +2198,6 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, if (huge_pte_none(pte)) continue; - /* - * HWPoisoned hugepage is already unmapped and dropped reference - */ - if (unlikely(is_hugetlb_entry_hwpoisoned(pte))) - continue; - page = pte_page(pte); if (pte_dirty(pte)) set_page_dirty(page); @@ -2239,7 +2207,6 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, flush_tlb_range(vma, start, end); mmu_notifier_invalidate_range_end(mm, start, end); list_for_each_entry_safe(page, tmp, &page_list, lru) { - page_remove_rmap(page); list_del(&page->lru); put_page(page); } @@ -2305,9 +2272,6 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma, return 1; } -/* - * Hugetlb_cow() should be called with page lock of the original hugepage held. - */ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, pte_t *ptep, pte_t pte, struct page *pagecache_page) @@ -2322,13 +2286,8 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, retry_avoidcopy: /* If no-one else is actually using this page, avoid the copy * and just make the page writable */ - avoidcopy = (page_mapcount(old_page) == 1); + avoidcopy = (page_count(old_page) == 1); if (avoidcopy) { - if (!trylock_page(old_page)) { - if (PageAnon(old_page)) - page_move_anon_rmap(old_page, vma, address); - } else - unlock_page(old_page); set_huge_ptep_writable(vma, address, ptep); return 0; } @@ -2379,13 +2338,6 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, return -PTR_ERR(new_page); } - /* - * When the original hugepage is shared one, it does not have - * anon_vma prepared. - */ - if (unlikely(anon_vma_prepare(vma))) - return VM_FAULT_OOM; - copy_huge_page(new_page, old_page, address, vma); __SetPageUptodate(new_page); @@ -2403,8 +2355,6 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, huge_ptep_clear_flush(vma, address, ptep); set_huge_pte_at(mm, address, ptep, make_huge_pte(vma, new_page, 1)); - page_remove_rmap(old_page); - hugepage_add_anon_rmap(new_page, vma, address); /* Make the old page be freed below */ new_page = old_page; mmu_notifier_invalidate_range_end(mm, @@ -2508,29 +2458,10 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, spin_lock(&inode->i_lock); inode->i_blocks += blocks_per_huge_page(h); spin_unlock(&inode->i_lock); - page_dup_rmap(page); } else { lock_page(page); - if (unlikely(anon_vma_prepare(vma))) { - ret = VM_FAULT_OOM; - goto backout_unlocked; - } - hugepage_add_new_anon_rmap(page, vma, address); + page->mapping = HUGETLB_POISON; } - } else { - page_dup_rmap(page); - } - - /* - * Since memory error handler replaces pte into hwpoison swap entry - * at the time of error handling, a process which reserved but not have - * the mapping to the error hugepage does not have hwpoison swap entry. - * So we need to block accesses from such a process by checking - * PG_hwpoison bit here. - */ - if (unlikely(PageHWPoison(page))) { - ret = VM_FAULT_HWPOISON; - goto backout_unlocked; } /* @@ -2582,18 +2513,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, pte_t *ptep; pte_t entry; int ret; - struct page *page = NULL; struct page *pagecache_page = NULL; static DEFINE_MUTEX(hugetlb_instantiation_mutex); struct hstate *h = hstate_vma(vma); - ptep = huge_pte_offset(mm, address); - if (ptep) { - entry = huge_ptep_get(ptep); - if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) - return VM_FAULT_HWPOISON; - } - ptep = huge_pte_alloc(mm, address, huge_page_size(h)); if (!ptep) return VM_FAULT_OOM; @@ -2631,11 +2554,6 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, vma, address); } - if (!pagecache_page) { - page = pte_page(entry); - lock_page(page); - } - spin_lock(&mm->page_table_lock); /* Check for a racing update before calling hugetlb_cow */ if (unlikely(!pte_same(entry, huge_ptep_get(ptep)))) @@ -2661,8 +2579,6 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, if (pagecache_page) { unlock_page(pagecache_page); put_page(pagecache_page); - } else { - unlock_page(page); } out_mutex: @@ -2875,19 +2791,3 @@ void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed) hugetlb_put_quota(inode->i_mapping, (chg - freed)); hugetlb_acct_memory(h, -(chg - freed)); } - -/* - * This function is called from memory failure code. - * Assume the caller holds page lock of the head page. - */ -void __isolate_hwpoisoned_huge_page(struct page *hpage) -{ - struct hstate *h = page_hstate(hpage); - int nid = page_to_nid(hpage); - - spin_lock(&hugetlb_lock); - list_del(&hpage->lru); - h->free_huge_pages--; - h->free_huge_pages_node[nid]--; - spin_unlock(&hugetlb_lock); -} diff --git a/trunk/mm/hwpoison-inject.c b/trunk/mm/hwpoison-inject.c index 0948f1072d6b..10ea71905c1f 100644 --- a/trunk/mm/hwpoison-inject.c +++ b/trunk/mm/hwpoison-inject.c @@ -5,7 +5,6 @@ #include #include #include -#include #include "internal.h" static struct dentry *hwpoison_dir; @@ -14,7 +13,6 @@ static int hwpoison_inject(void *data, u64 val) { unsigned long pfn = val; struct page *p; - struct page *hpage; int err; if (!capable(CAP_SYS_ADMIN)) @@ -26,19 +24,18 @@ static int hwpoison_inject(void *data, u64 val) return -ENXIO; p = pfn_to_page(pfn); - hpage = compound_head(p); /* * This implies unable to support free buddy pages. */ - if (!get_page_unless_zero(hpage)) + if (!get_page_unless_zero(p)) return 0; - if (!PageLRU(p) && !PageHuge(p)) + if (!PageLRU(p)) shake_page(p, 0); /* * This implies unable to support non-LRU pages. */ - if (!PageLRU(p) && !PageHuge(p)) + if (!PageLRU(p)) return 0; /* @@ -47,9 +44,9 @@ static int hwpoison_inject(void *data, u64 val) * We temporarily take page lock for try_get_mem_cgroup_from_page(). * __memory_failure() will redo the check reliably inside page lock. */ - lock_page(hpage); - err = hwpoison_filter(hpage); - unlock_page(hpage); + lock_page(p); + err = hwpoison_filter(p); + unlock_page(p); if (err) return 0; diff --git a/trunk/mm/memory-failure.c b/trunk/mm/memory-failure.c index 9c26eeca1342..6b44e52cacaa 100644 --- a/trunk/mm/memory-failure.c +++ b/trunk/mm/memory-failure.c @@ -46,7 +46,6 @@ #include #include #include -#include #include "internal.h" int sysctl_memory_failure_early_kill __read_mostly = 0; @@ -691,29 +690,17 @@ static int me_swapcache_clean(struct page *p, unsigned long pfn) /* * Huge pages. Needs work. * Issues: - * - Error on hugepage is contained in hugepage unit (not in raw page unit.) - * To narrow down kill region to one page, we need to break up pmd. - * - To support soft-offlining for hugepage, we need to support hugepage - * migration. + * No rmap support so we cannot find the original mapper. In theory could walk + * all MMs and look for the mappings, but that would be non atomic and racy. + * Need rmap for hugepages for this. Alternatively we could employ a heuristic, + * like just walking the current process and hoping it has it mapped (that + * should be usually true for the common "shared database cache" case) + * Should handle free huge pages and dequeue them too, but this needs to + * handle huge page accounting correctly. */ static int me_huge_page(struct page *p, unsigned long pfn) { - struct page *hpage = compound_head(p); - /* - * We can safely recover from error on free or reserved (i.e. - * not in-use) hugepage by dequeuing it from freelist. - * To check whether a hugepage is in-use or not, we can't use - * page->lru because it can be used in other hugepage operations, - * such as __unmap_hugepage_range() and gather_surplus_pages(). - * So instead we use page_mapping() and PageAnon(). - * We assume that this function is called with page lock held, - * so there is no race between isolation and mapping/unmapping. - */ - if (!(page_mapping(hpage) || PageAnon(hpage))) { - __isolate_hwpoisoned_huge_page(hpage); - return RECOVERED; - } - return DELAYED; + return FAILED; } /* @@ -851,7 +838,6 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, int ret; int i; int kill = 1; - struct page *hpage = compound_head(p); if (PageReserved(p) || PageSlab(p)) return SWAP_SUCCESS; @@ -860,10 +846,10 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, * This check implies we don't kill processes if their pages * are in the swap cache early. Those are always late kills. */ - if (!page_mapped(hpage)) + if (!page_mapped(p)) return SWAP_SUCCESS; - if (PageKsm(p)) + if (PageCompound(p) || PageKsm(p)) return SWAP_FAIL; if (PageSwapCache(p)) { @@ -878,11 +864,10 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, * XXX: the dirty test could be racy: set_page_dirty() may not always * be called inside page lock (it's recommended but not enforced). */ - mapping = page_mapping(hpage); - if (!PageDirty(hpage) && mapping && - mapping_cap_writeback_dirty(mapping)) { - if (page_mkclean(hpage)) { - SetPageDirty(hpage); + mapping = page_mapping(p); + if (!PageDirty(p) && mapping && mapping_cap_writeback_dirty(mapping)) { + if (page_mkclean(p)) { + SetPageDirty(p); } else { kill = 0; ttu |= TTU_IGNORE_HWPOISON; @@ -901,14 +886,14 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, * there's nothing that can be done. */ if (kill) - collect_procs(hpage, &tokill); + collect_procs(p, &tokill); /* * try_to_unmap can fail temporarily due to races. * Try a few times (RED-PEN better strategy?) */ for (i = 0; i < N_UNMAP_TRIES; i++) { - ret = try_to_unmap(hpage, ttu); + ret = try_to_unmap(p, ttu); if (ret == SWAP_SUCCESS) break; pr_debug("MCE %#lx: try_to_unmap retry needed %d\n", pfn, ret); @@ -916,7 +901,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, if (ret != SWAP_SUCCESS) printk(KERN_ERR "MCE %#lx: failed to unmap page (mapcount=%d)\n", - pfn, page_mapcount(hpage)); + pfn, page_mapcount(p)); /* * Now that the dirty bit has been propagated to the @@ -927,35 +912,17 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, * use a more force-full uncatchable kill to prevent * any accesses to the poisoned memory. */ - kill_procs_ao(&tokill, !!PageDirty(hpage), trapno, + kill_procs_ao(&tokill, !!PageDirty(p), trapno, ret != SWAP_SUCCESS, pfn); return ret; } -static void set_page_hwpoison_huge_page(struct page *hpage) -{ - int i; - int nr_pages = 1 << compound_order(hpage); - for (i = 0; i < nr_pages; i++) - SetPageHWPoison(hpage + i); -} - -static void clear_page_hwpoison_huge_page(struct page *hpage) -{ - int i; - int nr_pages = 1 << compound_order(hpage); - for (i = 0; i < nr_pages; i++) - ClearPageHWPoison(hpage + i); -} - int __memory_failure(unsigned long pfn, int trapno, int flags) { struct page_state *ps; struct page *p; - struct page *hpage; int res; - unsigned int nr_pages; if (!sysctl_memory_failure_recovery) panic("Memory failure from trap %d on page %lx", trapno, pfn); @@ -968,14 +935,12 @@ int __memory_failure(unsigned long pfn, int trapno, int flags) } p = pfn_to_page(pfn); - hpage = compound_head(p); if (TestSetPageHWPoison(p)) { printk(KERN_ERR "MCE %#lx: already hardware poisoned\n", pfn); return 0; } - nr_pages = 1 << compound_order(hpage); - atomic_long_add(nr_pages, &mce_bad_pages); + atomic_long_add(1, &mce_bad_pages); /* * We need/can do nothing about count=0 pages. @@ -989,7 +954,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags) * that may make page_freeze_refs()/page_unfreeze_refs() mismatch. */ if (!(flags & MF_COUNT_INCREASED) && - !get_page_unless_zero(hpage)) { + !get_page_unless_zero(compound_head(p))) { if (is_free_buddy_page(p)) { action_result(pfn, "free buddy", DELAYED); return 0; @@ -1007,9 +972,9 @@ int __memory_failure(unsigned long pfn, int trapno, int flags) * The check (unnecessarily) ignores LRU pages being isolated and * walked by the page reclaim code, however that's not a big loss. */ - if (!PageLRU(p) && !PageHuge(p)) + if (!PageLRU(p)) shake_page(p, 0); - if (!PageLRU(p) && !PageHuge(p)) { + if (!PageLRU(p)) { /* * shake_page could have turned it free. */ @@ -1027,7 +992,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags) * It's very difficult to mess with pages currently under IO * and in many cases impossible, so we just avoid it here. */ - lock_page_nosync(hpage); + lock_page_nosync(p); /* * unpoison always clear PG_hwpoison inside page lock @@ -1039,31 +1004,11 @@ int __memory_failure(unsigned long pfn, int trapno, int flags) } if (hwpoison_filter(p)) { if (TestClearPageHWPoison(p)) - atomic_long_sub(nr_pages, &mce_bad_pages); - unlock_page(hpage); - put_page(hpage); - return 0; - } - - /* - * For error on the tail page, we should set PG_hwpoison - * on the head page to show that the hugepage is hwpoisoned - */ - if (PageTail(p) && TestSetPageHWPoison(hpage)) { - action_result(pfn, "hugepage already hardware poisoned", - IGNORED); - unlock_page(hpage); - put_page(hpage); + atomic_long_dec(&mce_bad_pages); + unlock_page(p); + put_page(p); return 0; } - /* - * Set PG_hwpoison on all pages in an error hugepage, - * because containment is done in hugepage unit for now. - * Since we have done TestSetPageHWPoison() for the head page with - * page lock held, we can safely set PG_hwpoison bits on tail pages. - */ - if (PageHuge(p)) - set_page_hwpoison_huge_page(hpage); wait_on_page_writeback(p); @@ -1094,7 +1039,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags) } } out: - unlock_page(hpage); + unlock_page(p); return res; } EXPORT_SYMBOL_GPL(__memory_failure); @@ -1138,7 +1083,6 @@ int unpoison_memory(unsigned long pfn) struct page *page; struct page *p; int freeit = 0; - unsigned int nr_pages; if (!pfn_valid(pfn)) return -ENXIO; @@ -1151,11 +1095,9 @@ int unpoison_memory(unsigned long pfn) return 0; } - nr_pages = 1 << compound_order(page); - if (!get_page_unless_zero(page)) { if (TestClearPageHWPoison(p)) - atomic_long_sub(nr_pages, &mce_bad_pages); + atomic_long_dec(&mce_bad_pages); pr_debug("MCE: Software-unpoisoned free page %#lx\n", pfn); return 0; } @@ -1167,13 +1109,11 @@ int unpoison_memory(unsigned long pfn) * the PG_hwpoison page will be caught and isolated on the entrance to * the free buddy page pool. */ - if (TestClearPageHWPoison(page)) { + if (TestClearPageHWPoison(p)) { pr_debug("MCE: Software-unpoisoned page %#lx\n", pfn); - atomic_long_sub(nr_pages, &mce_bad_pages); + atomic_long_dec(&mce_bad_pages); freeit = 1; } - if (PageHuge(p)) - clear_page_hwpoison_huge_page(page); unlock_page(page); put_page(page); diff --git a/trunk/mm/memory.c b/trunk/mm/memory.c index 9b3b73f4ae9c..858829d06a92 100644 --- a/trunk/mm/memory.c +++ b/trunk/mm/memory.c @@ -2759,26 +2759,6 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma, return ret; } -/* - * This is like a special single-page "expand_downwards()", - * except we must first make sure that 'address-PAGE_SIZE' - * doesn't hit another vma. - * - * The "find_vma()" will do the right thing even if we wrap - */ -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address) -{ - address &= PAGE_MASK; - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) { - address -= PAGE_SIZE; - if (find_vma(vma->vm_mm, address) != vma) - return -ENOMEM; - - expand_stack(vma, address); - } - return 0; -} - /* * We enter with non-exclusive mmap_sem (to exclude vma changes, * but allow concurrent faults), and pte mapped but not yet locked. @@ -2792,11 +2772,6 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma, spinlock_t *ptl; pte_t entry; - if (check_stack_guard_page(vma, address) < 0) { - pte_unmap(page_table); - return VM_FAULT_SIGBUS; - } - if (!(flags & FAULT_FLAG_WRITE)) { entry = pte_mkspecial(pfn_pte(my_zero_pfn(address), vma->vm_page_prot)); diff --git a/trunk/mm/page-writeback.c b/trunk/mm/page-writeback.c index 20890d80c7ef..0c6258bd1ba3 100644 --- a/trunk/mm/page-writeback.c +++ b/trunk/mm/page-writeback.c @@ -253,6 +253,32 @@ static void bdi_writeout_fraction(struct backing_dev_info *bdi, } } +/* + * Clip the earned share of dirty pages to that which is actually available. + * This avoids exceeding the total dirty_limit when the floating averages + * fluctuate too quickly. + */ +static void clip_bdi_dirty_limit(struct backing_dev_info *bdi, + unsigned long dirty, unsigned long *pbdi_dirty) +{ + unsigned long avail_dirty; + + avail_dirty = global_page_state(NR_FILE_DIRTY) + + global_page_state(NR_WRITEBACK) + + global_page_state(NR_UNSTABLE_NFS) + + global_page_state(NR_WRITEBACK_TEMP); + + if (avail_dirty < dirty) + avail_dirty = dirty - avail_dirty; + else + avail_dirty = 0; + + avail_dirty += bdi_stat(bdi, BDI_RECLAIMABLE) + + bdi_stat(bdi, BDI_WRITEBACK); + + *pbdi_dirty = min(*pbdi_dirty, avail_dirty); +} + static inline void task_dirties_fraction(struct task_struct *tsk, long *numerator, long *denominator) { @@ -261,24 +287,16 @@ static inline void task_dirties_fraction(struct task_struct *tsk, } /* - * task_dirty_limit - scale down dirty throttling threshold for one task + * scale the dirty limit * * task specific dirty limit: * * dirty -= (dirty/8) * p_{t} - * - * To protect light/slow dirtying tasks from heavier/fast ones, we start - * throttling individual tasks before reaching the bdi dirty limit. - * Relatively low thresholds will be allocated to heavy dirtiers. So when - * dirty pages grow large, heavy dirtiers will be throttled first, which will - * effectively curb the growth of dirty pages. Light dirtiers with high enough - * dirty threshold may never get throttled. */ -static unsigned long task_dirty_limit(struct task_struct *tsk, - unsigned long bdi_dirty) +static void task_dirty_limit(struct task_struct *tsk, unsigned long *pdirty) { long numerator, denominator; - unsigned long dirty = bdi_dirty; + unsigned long dirty = *pdirty; u64 inv = dirty >> 3; task_dirties_fraction(tsk, &numerator, &denominator); @@ -286,8 +304,10 @@ static unsigned long task_dirty_limit(struct task_struct *tsk, do_div(inv, denominator); dirty -= inv; + if (dirty < *pdirty/2) + dirty = *pdirty/2; - return max(dirty, bdi_dirty/2); + *pdirty = dirty; } /* @@ -397,16 +417,9 @@ unsigned long determine_dirtyable_memory(void) return x + 1; /* Ensure that we never return 0 */ } -/** - * global_dirty_limits - background-writeback and dirty-throttling thresholds - * - * Calculate the dirty thresholds based on sysctl parameters - * - vm.dirty_background_ratio or vm.dirty_background_bytes - * - vm.dirty_ratio or vm.dirty_bytes - * The dirty limits will be lifted by 1/4 for PF_LESS_THROTTLE (ie. nfsd) and - * runtime tasks. - */ -void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty) +void +get_dirty_limits(unsigned long *pbackground, unsigned long *pdirty, + unsigned long *pbdi_dirty, struct backing_dev_info *bdi) { unsigned long background; unsigned long dirty; @@ -438,37 +451,27 @@ void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty) } *pbackground = background; *pdirty = dirty; -} - -/** - * bdi_dirty_limit - @bdi's share of dirty throttling threshold - * - * Allocate high/low dirty limits to fast/slow devices, in order to prevent - * - starving fast devices - * - piling up dirty pages (that will take long time to sync) on slow devices - * - * The bdi's share of dirty limit will be adapting to its throughput and - * bounded by the bdi->min_ratio and/or bdi->max_ratio parameters, if set. - */ -unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty) -{ - u64 bdi_dirty; - long numerator, denominator; - - /* - * Calculate this BDI's share of the dirty ratio. - */ - bdi_writeout_fraction(bdi, &numerator, &denominator); - - bdi_dirty = (dirty * (100 - bdi_min_ratio)) / 100; - bdi_dirty *= numerator; - do_div(bdi_dirty, denominator); - bdi_dirty += (dirty * bdi->min_ratio) / 100; - if (bdi_dirty > (dirty * bdi->max_ratio) / 100) - bdi_dirty = dirty * bdi->max_ratio / 100; + if (bdi) { + u64 bdi_dirty; + long numerator, denominator; - return bdi_dirty; + /* + * Calculate this BDI's share of the dirty ratio. + */ + bdi_writeout_fraction(bdi, &numerator, &denominator); + + bdi_dirty = (dirty * (100 - bdi_min_ratio)) / 100; + bdi_dirty *= numerator; + do_div(bdi_dirty, denominator); + bdi_dirty += (dirty * bdi->min_ratio) / 100; + if (bdi_dirty > (dirty * bdi->max_ratio) / 100) + bdi_dirty = dirty * bdi->max_ratio / 100; + + *pbdi_dirty = bdi_dirty; + clip_bdi_dirty_limit(bdi, dirty, pbdi_dirty); + task_dirty_limit(current, pbdi_dirty); + } } /* @@ -488,7 +491,7 @@ static void balance_dirty_pages(struct address_space *mapping, unsigned long bdi_thresh; unsigned long pages_written = 0; unsigned long pause = 1; - bool dirty_exceeded = false; + struct backing_dev_info *bdi = mapping->backing_dev_info; for (;;) { @@ -499,11 +502,18 @@ static void balance_dirty_pages(struct address_space *mapping, .range_cyclic = 1, }; + get_dirty_limits(&background_thresh, &dirty_thresh, + &bdi_thresh, bdi); + nr_reclaimable = global_page_state(NR_FILE_DIRTY) + global_page_state(NR_UNSTABLE_NFS); nr_writeback = global_page_state(NR_WRITEBACK); - global_dirty_limits(&background_thresh, &dirty_thresh); + bdi_nr_reclaimable = bdi_stat(bdi, BDI_RECLAIMABLE); + bdi_nr_writeback = bdi_stat(bdi, BDI_WRITEBACK); + + if (bdi_nr_reclaimable + bdi_nr_writeback <= bdi_thresh) + break; /* * Throttle it only when the background writeback cannot @@ -514,8 +524,26 @@ static void balance_dirty_pages(struct address_space *mapping, (background_thresh + dirty_thresh) / 2) break; - bdi_thresh = bdi_dirty_limit(bdi, dirty_thresh); - bdi_thresh = task_dirty_limit(current, bdi_thresh); + if (!bdi->dirty_exceeded) + bdi->dirty_exceeded = 1; + + /* Note: nr_reclaimable denotes nr_dirty + nr_unstable. + * Unstable writes are a feature of certain networked + * filesystems (i.e. NFS) in which data may have been + * written to the server's write cache, but has not yet + * been flushed to permanent storage. + * Only move pages to writeback if this bdi is over its + * threshold otherwise wait until the disk writes catch + * up. + */ + trace_wbc_balance_dirty_start(&wbc, bdi); + if (bdi_nr_reclaimable > bdi_thresh) { + writeback_inodes_wb(&bdi->wb, &wbc); + pages_written += write_chunk - wbc.nr_to_write; + get_dirty_limits(&background_thresh, &dirty_thresh, + &bdi_thresh, bdi); + trace_wbc_balance_dirty_written(&wbc, bdi); + } /* * In order to avoid the stacked BDI deadlock we need @@ -530,44 +558,16 @@ static void balance_dirty_pages(struct address_space *mapping, if (bdi_thresh < 2*bdi_stat_error(bdi)) { bdi_nr_reclaimable = bdi_stat_sum(bdi, BDI_RECLAIMABLE); bdi_nr_writeback = bdi_stat_sum(bdi, BDI_WRITEBACK); - } else { + } else if (bdi_nr_reclaimable) { bdi_nr_reclaimable = bdi_stat(bdi, BDI_RECLAIMABLE); bdi_nr_writeback = bdi_stat(bdi, BDI_WRITEBACK); } - /* - * The bdi thresh is somehow "soft" limit derived from the - * global "hard" limit. The former helps to prevent heavy IO - * bdi or process from holding back light ones; The latter is - * the last resort safeguard. - */ - dirty_exceeded = - (bdi_nr_reclaimable + bdi_nr_writeback >= bdi_thresh) - || (nr_reclaimable + nr_writeback >= dirty_thresh); - - if (!dirty_exceeded) + if (bdi_nr_reclaimable + bdi_nr_writeback <= bdi_thresh) break; + if (pages_written >= write_chunk) + break; /* We've done our duty */ - if (!bdi->dirty_exceeded) - bdi->dirty_exceeded = 1; - - /* Note: nr_reclaimable denotes nr_dirty + nr_unstable. - * Unstable writes are a feature of certain networked - * filesystems (i.e. NFS) in which data may have been - * written to the server's write cache, but has not yet - * been flushed to permanent storage. - * Only move pages to writeback if this bdi is over its - * threshold otherwise wait until the disk writes catch - * up. - */ - trace_wbc_balance_dirty_start(&wbc, bdi); - if (bdi_nr_reclaimable > bdi_thresh) { - writeback_inodes_wb(&bdi->wb, &wbc); - pages_written += write_chunk - wbc.nr_to_write; - trace_wbc_balance_dirty_written(&wbc, bdi); - if (pages_written >= write_chunk) - break; /* We've done our duty */ - } trace_wbc_balance_dirty_wait(&wbc, bdi); __set_current_state(TASK_INTERRUPTIBLE); io_schedule_timeout(pause); @@ -581,7 +581,8 @@ static void balance_dirty_pages(struct address_space *mapping, pause = HZ / 10; } - if (!dirty_exceeded && bdi->dirty_exceeded) + if (bdi_nr_reclaimable + bdi_nr_writeback < bdi_thresh && + bdi->dirty_exceeded) bdi->dirty_exceeded = 0; if (writeback_in_progress(bdi)) @@ -596,7 +597,9 @@ static void balance_dirty_pages(struct address_space *mapping, * background_thresh, to keep the amount of dirty memory low. */ if ((laptop_mode && pages_written) || - (!laptop_mode && (nr_reclaimable > background_thresh))) + (!laptop_mode && ((global_page_state(NR_FILE_DIRTY) + + global_page_state(NR_UNSTABLE_NFS)) + > background_thresh))) bdi_start_background_writeback(bdi); } @@ -660,7 +663,7 @@ void throttle_vm_writeout(gfp_t gfp_mask) unsigned long dirty_thresh; for ( ; ; ) { - global_dirty_limits(&background_thresh, &dirty_thresh); + get_dirty_limits(&background_thresh, &dirty_thresh, NULL, NULL); /* * Boost the allowable dirty threshold a bit for page @@ -822,10 +825,10 @@ void __init page_writeback_init(void) /* * We tag pages in batches of WRITEBACK_TAG_BATCH to reduce tree_lock latency. */ +#define WRITEBACK_TAG_BATCH 4096 void tag_pages_for_writeback(struct address_space *mapping, pgoff_t start, pgoff_t end) { -#define WRITEBACK_TAG_BATCH 4096 unsigned long tagged; do { diff --git a/trunk/mm/rmap.c b/trunk/mm/rmap.c index 87b9e8ad4509..a7d0f5482634 100644 --- a/trunk/mm/rmap.c +++ b/trunk/mm/rmap.c @@ -56,7 +56,6 @@ #include #include #include -#include #include @@ -351,8 +350,6 @@ vma_address(struct page *page, struct vm_area_struct *vma) pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); unsigned long address; - if (unlikely(is_vm_hugetlb_page(vma))) - pgoff = page->index << huge_page_order(page_hstate(page)); address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); if (unlikely(address < vma->vm_start || address >= vma->vm_end)) { /* page should be within @vma mapping range */ @@ -397,12 +394,6 @@ pte_t *page_check_address(struct page *page, struct mm_struct *mm, pte_t *pte; spinlock_t *ptl; - if (unlikely(PageHuge(page))) { - pte = huge_pte_offset(mm, address); - ptl = &mm->page_table_lock; - goto check; - } - pgd = pgd_offset(mm, address); if (!pgd_present(*pgd)) return NULL; @@ -423,7 +414,6 @@ pte_t *page_check_address(struct page *page, struct mm_struct *mm, } ptl = pte_lockptr(mm, pmd); -check: spin_lock(ptl); if (pte_present(*pte) && page_to_pfn(page) == pte_pfn(*pte)) { *ptlp = ptl; @@ -926,12 +916,6 @@ void page_remove_rmap(struct page *page) page_clear_dirty(page); set_page_dirty(page); } - /* - * Hugepages are not counted in NR_ANON_PAGES nor NR_FILE_MAPPED - * and not charged by memcg for now. - */ - if (unlikely(PageHuge(page))) - return; if (PageAnon(page)) { mem_cgroup_uncharge_page(page); __dec_zone_page_state(page, NR_ANON_PAGES); @@ -1540,46 +1524,3 @@ int rmap_walk(struct page *page, int (*rmap_one)(struct page *, return rmap_walk_file(page, rmap_one, arg); } #endif /* CONFIG_MIGRATION */ - -#ifdef CONFIG_HUGETLB_PAGE -/* - * The following three functions are for anonymous (private mapped) hugepages. - * Unlike common anonymous pages, anonymous hugepages have no accounting code - * and no lru code, because we handle hugepages differently from common pages. - */ -static void __hugepage_set_anon_rmap(struct page *page, - struct vm_area_struct *vma, unsigned long address, int exclusive) -{ - struct anon_vma *anon_vma = vma->anon_vma; - BUG_ON(!anon_vma); - if (!exclusive) { - struct anon_vma_chain *avc; - avc = list_entry(vma->anon_vma_chain.prev, - struct anon_vma_chain, same_vma); - anon_vma = avc->anon_vma; - } - anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON; - page->mapping = (struct address_space *) anon_vma; - page->index = linear_page_index(vma, address); -} - -void hugepage_add_anon_rmap(struct page *page, - struct vm_area_struct *vma, unsigned long address) -{ - struct anon_vma *anon_vma = vma->anon_vma; - int first; - BUG_ON(!anon_vma); - BUG_ON(address < vma->vm_start || address >= vma->vm_end); - first = atomic_inc_and_test(&page->_mapcount); - if (first) - __hugepage_set_anon_rmap(page, vma, address, 0); -} - -void hugepage_add_new_anon_rmap(struct page *page, - struct vm_area_struct *vma, unsigned long address) -{ - BUG_ON(address < vma->vm_start || address >= vma->vm_end); - atomic_set(&page->_mapcount, 0); - __hugepage_set_anon_rmap(page, vma, address, 1); -} -#endif /* CONFIG_HUGETLB_PAGE */ diff --git a/trunk/mm/vmalloc.c b/trunk/mm/vmalloc.c index 6b8889da69a6..918c51335d64 100644 --- a/trunk/mm/vmalloc.c +++ b/trunk/mm/vmalloc.c @@ -31,7 +31,6 @@ #include #include -bool vmap_lazy_unmap __read_mostly = true; /*** Page table manipulation functions ***/ @@ -503,9 +502,6 @@ static unsigned long lazy_max_pages(void) { unsigned int log; - if (!vmap_lazy_unmap) - return 0; - log = fls(num_online_cpus()); return log * (32UL * 1024 * 1024 / PAGE_SIZE); diff --git a/trunk/net/mac80211/rate.c b/trunk/net/mac80211/rate.c index be04d46110fe..6d0bd198af19 100644 --- a/trunk/net/mac80211/rate.c +++ b/trunk/net/mac80211/rate.c @@ -103,7 +103,6 @@ ieee80211_rate_control_ops_get(const char *name) struct rate_control_ops *ops; const char *alg_name; - kparam_block_sysfs_write(ieee80211_default_rc_algo); if (!name) alg_name = ieee80211_default_rc_algo; else @@ -121,7 +120,6 @@ ieee80211_rate_control_ops_get(const char *name) /* try built-in one if specific alg requested but not found */ if (!ops && strlen(CONFIG_MAC80211_RC_DEFAULT)) ops = ieee80211_try_rate_control_ops_get(CONFIG_MAC80211_RC_DEFAULT); - kparam_unblock_sysfs_write(ieee80211_default_rc_algo); return ops; } diff --git a/trunk/net/rxrpc/ar-internal.h b/trunk/net/rxrpc/ar-internal.h index 8e22bd345e71..7043b294bb67 100644 --- a/trunk/net/rxrpc/ar-internal.h +++ b/trunk/net/rxrpc/ar-internal.h @@ -597,6 +597,12 @@ extern unsigned rxrpc_debug; #define dbgprintk(FMT,...) \ printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) +/* make sure we maintain the format strings, even when debugging is disabled */ +static inline __attribute__((format(printf,1,2))) +void _dbprintk(const char *fmt, ...) +{ +} + #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) @@ -649,11 +655,11 @@ do { \ } while (0) #else -#define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) -#define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) -#define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) -#define _proto(FMT,...) no_printk("### "FMT ,##__VA_ARGS__) -#define _net(FMT,...) no_printk("@@@ "FMT ,##__VA_ARGS__) +#define _enter(FMT,...) _dbprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) +#define _leave(FMT,...) _dbprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) +#define _debug(FMT,...) _dbprintk(" "FMT ,##__VA_ARGS__) +#define _proto(FMT,...) _dbprintk("### "FMT ,##__VA_ARGS__) +#define _net(FMT,...) _dbprintk("@@@ "FMT ,##__VA_ARGS__) #endif /* diff --git a/trunk/net/sunrpc/auth.c b/trunk/net/sunrpc/auth.c index 36cb66022a27..880d0de3f50f 100644 --- a/trunk/net/sunrpc/auth.c +++ b/trunk/net/sunrpc/auth.c @@ -39,7 +39,7 @@ static LIST_HEAD(cred_unused); static unsigned long number_cred_unused; #define MAX_HASHTABLE_BITS (10) -static int param_set_hashtbl_sz(const char *val, const struct kernel_param *kp) +static int param_set_hashtbl_sz(const char *val, struct kernel_param *kp) { unsigned long num; unsigned int nbits; @@ -61,7 +61,7 @@ static int param_set_hashtbl_sz(const char *val, const struct kernel_param *kp) return -EINVAL; } -static int param_get_hashtbl_sz(char *buffer, const struct kernel_param *kp) +static int param_get_hashtbl_sz(char *buffer, struct kernel_param *kp) { unsigned int nbits; @@ -71,11 +71,6 @@ static int param_get_hashtbl_sz(char *buffer, const struct kernel_param *kp) #define param_check_hashtbl_sz(name, p) __param_check(name, p, unsigned int); -static struct kernel_param_ops param_ops_hashtbl_sz = { - .set = param_set_hashtbl_sz, - .get = param_get_hashtbl_sz, -}; - module_param_named(auth_hashtable_size, auth_hashbits, hashtbl_sz, 0644); MODULE_PARM_DESC(auth_hashtable_size, "RPC credential cache hashtable size"); diff --git a/trunk/net/sunrpc/xprtsock.c b/trunk/net/sunrpc/xprtsock.c index 49a62f0c4b87..7ca65c7005ea 100644 --- a/trunk/net/sunrpc/xprtsock.c +++ b/trunk/net/sunrpc/xprtsock.c @@ -2577,8 +2577,7 @@ void cleanup_socket_xprt(void) xprt_unregister_transport(&xs_bc_tcp_transport); } -static int param_set_uint_minmax(const char *val, - const struct kernel_param *kp, +static int param_set_uint_minmax(const char *val, struct kernel_param *kp, unsigned int min, unsigned int max) { unsigned long num; @@ -2593,37 +2592,34 @@ static int param_set_uint_minmax(const char *val, return 0; } -static int param_set_portnr(const char *val, const struct kernel_param *kp) +static int param_set_portnr(const char *val, struct kernel_param *kp) { return param_set_uint_minmax(val, kp, RPC_MIN_RESVPORT, RPC_MAX_RESVPORT); } -static struct kernel_param_ops param_ops_portnr = { - .set = param_set_portnr, - .get = param_get_uint, -}; - +static int param_get_portnr(char *buffer, struct kernel_param *kp) +{ + return param_get_uint(buffer, kp); +} #define param_check_portnr(name, p) \ __param_check(name, p, unsigned int); module_param_named(min_resvport, xprt_min_resvport, portnr, 0644); module_param_named(max_resvport, xprt_max_resvport, portnr, 0644); -static int param_set_slot_table_size(const char *val, - const struct kernel_param *kp) +static int param_set_slot_table_size(const char *val, struct kernel_param *kp) { return param_set_uint_minmax(val, kp, RPC_MIN_SLOT_TABLE, RPC_MAX_SLOT_TABLE); } -static struct kernel_param_ops param_ops_slot_table_size = { - .set = param_set_slot_table_size, - .get = param_get_uint, -}; - +static int param_get_slot_table_size(char *buffer, struct kernel_param *kp) +{ + return param_get_uint(buffer, kp); +} #define param_check_slot_table_size(name, p) \ __param_check(name, p, unsigned int); diff --git a/trunk/scripts/mod/modpost.c b/trunk/scripts/mod/modpost.c index 1ec7158b6c1f..7acbdd8fcaed 100644 --- a/trunk/scripts/mod/modpost.c +++ b/trunk/scripts/mod/modpost.c @@ -790,7 +790,6 @@ static const char *section_white_list[] = { ".comment*", ".debug*", - ".GCC-command-line", /* mn10300 */ ".mdebug*", /* alpha, score, mips etc. */ ".pdr", /* alpha, score, mips etc. */ ".stab*", @@ -1035,13 +1034,6 @@ static const struct sectioncheck *section_mismatch( * fromsec = .data* * atsym =__param* * - * Pattern 1a: - * module_param_call() ops can refer to __init set function if permissions=0 - * The pattern is identified by: - * tosec = .init.text - * fromsec = .data* - * atsym = __param_ops_* - * * Pattern 2: * Many drivers utilise a *driver container with references to * add, remove, probe functions etc. @@ -1076,12 +1068,6 @@ static int secref_whitelist(const struct sectioncheck *mismatch, (strncmp(fromsym, "__param", strlen("__param")) == 0)) return 0; - /* Check for pattern 1a */ - if (strcmp(tosec, ".init.text") == 0 && - match(fromsec, data_sections) && - (strncmp(fromsym, "__param_ops_", strlen("__param_ops_")) == 0)) - return 0; - /* Check for pattern 2 */ if (match(tosec, init_exit_sections) && match(fromsec, data_sections) && diff --git a/trunk/security/apparmor/lsm.c b/trunk/security/apparmor/lsm.c index d5666d3cc21b..8db33a8b50c4 100644 --- a/trunk/security/apparmor/lsm.c +++ b/trunk/security/apparmor/lsm.c @@ -667,29 +667,17 @@ static struct security_operations apparmor_ops = { * AppArmor sysfs module parameters */ -static int param_set_aabool(const char *val, const struct kernel_param *kp); -static int param_get_aabool(char *buffer, const struct kernel_param *kp); +static int param_set_aabool(const char *val, struct kernel_param *kp); +static int param_get_aabool(char *buffer, struct kernel_param *kp); #define param_check_aabool(name, p) __param_check(name, p, int) -static struct kernel_param_ops param_ops_aabool = { - .set = param_set_aabool, - .get = param_get_aabool -}; -static int param_set_aauint(const char *val, const struct kernel_param *kp); -static int param_get_aauint(char *buffer, const struct kernel_param *kp); +static int param_set_aauint(const char *val, struct kernel_param *kp); +static int param_get_aauint(char *buffer, struct kernel_param *kp); #define param_check_aauint(name, p) __param_check(name, p, int) -static struct kernel_param_ops param_ops_aauint = { - .set = param_set_aauint, - .get = param_get_aauint -}; -static int param_set_aalockpolicy(const char *val, const struct kernel_param *kp); -static int param_get_aalockpolicy(char *buffer, const struct kernel_param *kp); +static int param_set_aalockpolicy(const char *val, struct kernel_param *kp); +static int param_get_aalockpolicy(char *buffer, struct kernel_param *kp); #define param_check_aalockpolicy(name, p) __param_check(name, p, int) -static struct kernel_param_ops param_ops_aalockpolicy = { - .set = param_set_aalockpolicy, - .get = param_get_aalockpolicy -}; static int param_set_audit(const char *val, struct kernel_param *kp); static int param_get_audit(char *buffer, struct kernel_param *kp); @@ -763,7 +751,7 @@ static int __init apparmor_enabled_setup(char *str) __setup("apparmor=", apparmor_enabled_setup); /* set global flag turning off the ability to load policy */ -static int param_set_aalockpolicy(const char *val, const struct kernel_param *kp) +static int param_set_aalockpolicy(const char *val, struct kernel_param *kp) { if (!capable(CAP_MAC_ADMIN)) return -EPERM; @@ -772,35 +760,35 @@ static int param_set_aalockpolicy(const char *val, const struct kernel_param *kp return param_set_bool(val, kp); } -static int param_get_aalockpolicy(char *buffer, const struct kernel_param *kp) +static int param_get_aalockpolicy(char *buffer, struct kernel_param *kp) { if (!capable(CAP_MAC_ADMIN)) return -EPERM; return param_get_bool(buffer, kp); } -static int param_set_aabool(const char *val, const struct kernel_param *kp) +static int param_set_aabool(const char *val, struct kernel_param *kp) { if (!capable(CAP_MAC_ADMIN)) return -EPERM; return param_set_bool(val, kp); } -static int param_get_aabool(char *buffer, const struct kernel_param *kp) +static int param_get_aabool(char *buffer, struct kernel_param *kp) { if (!capable(CAP_MAC_ADMIN)) return -EPERM; return param_get_bool(buffer, kp); } -static int param_set_aauint(const char *val, const struct kernel_param *kp) +static int param_set_aauint(const char *val, struct kernel_param *kp) { if (!capable(CAP_MAC_ADMIN)) return -EPERM; return param_set_uint(val, kp); } -static int param_get_aauint(char *buffer, const struct kernel_param *kp) +static int param_get_aauint(char *buffer, struct kernel_param *kp) { if (!capable(CAP_MAC_ADMIN)) return -EPERM; diff --git a/trunk/security/keys/internal.h b/trunk/security/keys/internal.h index 56a133d8f37d..addb67b169f4 100644 --- a/trunk/security/keys/internal.h +++ b/trunk/security/keys/internal.h @@ -15,6 +15,11 @@ #include #include +static inline __attribute__((format(printf, 1, 2))) +void no_printk(const char *fmt, ...) +{ +} + #ifdef __KDEBUG #define kenter(FMT, ...) \ printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__) diff --git a/trunk/sound/aoa/soundbus/core.c b/trunk/sound/aoa/soundbus/core.c index 7487eb76e034..99ca7120e269 100644 --- a/trunk/sound/aoa/soundbus/core.c +++ b/trunk/sound/aoa/soundbus/core.c @@ -59,7 +59,7 @@ static int soundbus_probe(struct device *dev) static int soundbus_uevent(struct device *dev, struct kobj_uevent_env *env) { struct soundbus_dev * soundbus_dev; - struct platform_device * of; + struct of_device * of; const char *compat; int retval = 0; int cplen, seen = 0; diff --git a/trunk/sound/aoa/soundbus/soundbus.h b/trunk/sound/aoa/soundbus/soundbus.h index adecbf36f4f6..a0f223c13f66 100644 --- a/trunk/sound/aoa/soundbus/soundbus.h +++ b/trunk/sound/aoa/soundbus/soundbus.h @@ -141,7 +141,7 @@ struct soundbus_dev { struct list_head onbuslist; /* the of device it represents */ - struct platform_device ofdev; + struct of_device ofdev; /* what modules go by */ char modalias[32]; diff --git a/trunk/sound/aoa/soundbus/sysfs.c b/trunk/sound/aoa/soundbus/sysfs.c index e0980b5c2cd8..6496e754f00a 100644 --- a/trunk/sound/aoa/soundbus/sysfs.c +++ b/trunk/sound/aoa/soundbus/sysfs.c @@ -16,7 +16,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { struct soundbus_dev *sdev = to_soundbus_device(dev); - struct platform_device *of = &sdev->ofdev; + struct of_device *of = &sdev->ofdev; int length; if (*sdev->modalias) { diff --git a/trunk/sound/oss/ad1848.c b/trunk/sound/oss/ad1848.c index 4d2a6ae978f7..24793c5b65ac 100644 --- a/trunk/sound/oss/ad1848.c +++ b/trunk/sound/oss/ad1848.c @@ -716,7 +716,7 @@ static int ad1848_mixer_ioctl(int dev, unsigned int cmd, void __user *arg) default: if (get_user(val, (int __user *)arg)) - return -EFAULT; + return -EFAULT; val = ad1848_mixer_set(devc, cmd & 0xff, val); break; } diff --git a/trunk/sound/oss/au1550_ac97.c b/trunk/sound/oss/au1550_ac97.c index c6f2621221ba..c4a4cdc07ab9 100644 --- a/trunk/sound/oss/au1550_ac97.c +++ b/trunk/sound/oss/au1550_ac97.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include diff --git a/trunk/sound/pci/hda/hda_codec.c b/trunk/sound/pci/hda/hda_codec.c index 720a81d711e3..a7802b99436c 100644 --- a/trunk/sound/pci/hda/hda_codec.c +++ b/trunk/sound/pci/hda/hda_codec.c @@ -970,36 +970,6 @@ static void restore_init_pincfgs(struct hda_codec *codec) snd_array_free(&codec->init_pins); } -/* - * audio-converter setup caches - */ -struct hda_cvt_setup { - hda_nid_t nid; - u8 stream_tag; - u8 channel_id; - u16 format_id; - unsigned char active; /* cvt is currently used */ - unsigned char dirty; /* setups should be cleared */ -}; - -/* get or create a cache entry for the given audio converter NID */ -static struct hda_cvt_setup * -get_hda_cvt_setup(struct hda_codec *codec, hda_nid_t nid) -{ - struct hda_cvt_setup *p; - int i; - - for (i = 0; i < codec->cvt_setups.used; i++) { - p = snd_array_elem(&codec->cvt_setups, i); - if (p->nid == nid) - return p; - } - p = snd_array_new(&codec->cvt_setups); - if (p) - p->nid = nid; - return p; -} - /* * codec destructor */ @@ -1068,14 +1038,12 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, codec->addr = codec_addr; mutex_init(&codec->spdif_mutex); mutex_init(&codec->control_mutex); - mutex_init(&codec->prepare_mutex); init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32); snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32); snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); - snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); if (codec->bus->modelname) { codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); if (!codec->modelname) { @@ -1213,51 +1181,16 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, int channel_id, int format) { - struct hda_cvt_setup *p; - unsigned int oldval, newval; - int i; - if (!nid) return; snd_printdd("hda_codec_setup_stream: " "NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", nid, stream_tag, channel_id, format); - p = get_hda_cvt_setup(codec, nid); - if (!p) - return; - /* update the stream-id if changed */ - if (p->stream_tag != stream_tag || p->channel_id != channel_id) { - oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); - newval = (stream_tag << 4) | channel_id; - if (oldval != newval) - snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_CHANNEL_STREAMID, - newval); - p->stream_tag = stream_tag; - p->channel_id = channel_id; - } - /* update the format-id if changed */ - if (p->format_id != format) { - oldval = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_STREAM_FORMAT, 0); - if (oldval != format) { - msleep(1); - snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_STREAM_FORMAT, - format); - } - p->format_id = format; - } - p->active = 1; - p->dirty = 0; - - /* make other inactive cvts with the same stream-tag dirty */ - for (i = 0; i < codec->cvt_setups.used; i++) { - p = snd_array_elem(&codec->cvt_setups, i); - if (!p->active && p->stream_tag == stream_tag) - p->dirty = 1; - } + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, + (stream_tag << 4) | channel_id); + msleep(1); + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); } EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream); @@ -1268,54 +1201,17 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream); */ void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid) { - struct hda_cvt_setup *p; - if (!nid) return; snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid); - /* here we just clear the active flag; actual clean-ups will be done - * in purify_inactive_streams() - */ - p = get_hda_cvt_setup(codec, nid); - if (p) - p->active = 0; -} -EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream); - -static void really_cleanup_stream(struct hda_codec *codec, - struct hda_cvt_setup *q) -{ - hda_nid_t nid = q->nid; snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0); +#if 0 /* keep the format */ + msleep(1); snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0); - memset(q, 0, sizeof(*q)); - q->nid = nid; -} - -/* clean up the all conflicting obsolete streams */ -static void purify_inactive_streams(struct hda_codec *codec) -{ - int i; - - for (i = 0; i < codec->cvt_setups.used; i++) { - struct hda_cvt_setup *p = snd_array_elem(&codec->cvt_setups, i); - if (p->dirty) - really_cleanup_stream(codec, p); - } -} - -/* clean up all streams; called from suspend */ -static void hda_cleanup_all_streams(struct hda_codec *codec) -{ - int i; - - for (i = 0; i < codec->cvt_setups.used; i++) { - struct hda_cvt_setup *p = snd_array_elem(&codec->cvt_setups, i); - if (p->stream_tag) - really_cleanup_stream(codec, p); - } +#endif } +EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream); /* * amp access functions @@ -3032,7 +2928,6 @@ static void hda_call_codec_suspend(struct hda_codec *codec) { if (codec->patch_ops.suspend) codec->patch_ops.suspend(codec, PMSG_SUSPEND); - hda_cleanup_all_streams(codec); hda_set_power_state(codec, codec->afg ? codec->afg : codec->mfg, AC_PWRST_D3); @@ -3482,35 +3377,6 @@ static int set_pcm_default_values(struct hda_codec *codec, return 0; } -/* - * codec prepare/cleanup entries - */ -int snd_hda_codec_prepare(struct hda_codec *codec, - struct hda_pcm_stream *hinfo, - unsigned int stream, - unsigned int format, - struct snd_pcm_substream *substream) -{ - int ret; - mutex_lock(&codec->prepare_mutex); - ret = hinfo->ops.prepare(hinfo, codec, stream, format, substream); - if (ret >= 0) - purify_inactive_streams(codec); - mutex_unlock(&codec->prepare_mutex); - return ret; -} -EXPORT_SYMBOL_HDA(snd_hda_codec_prepare); - -void snd_hda_codec_cleanup(struct hda_codec *codec, - struct hda_pcm_stream *hinfo, - struct snd_pcm_substream *substream) -{ - mutex_lock(&codec->prepare_mutex); - hinfo->ops.cleanup(hinfo, codec, substream); - mutex_unlock(&codec->prepare_mutex); -} -EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup); - /* global */ const char *snd_hda_pcm_type_name[HDA_PCM_NTYPES] = { "Audio", "SPDIF", "HDMI", "Modem" diff --git a/trunk/sound/pci/hda/hda_codec.h b/trunk/sound/pci/hda/hda_codec.h index 3f7a479881e5..0328cf55cdba 100644 --- a/trunk/sound/pci/hda/hda_codec.h +++ b/trunk/sound/pci/hda/hda_codec.h @@ -826,14 +826,12 @@ struct hda_codec { struct mutex spdif_mutex; struct mutex control_mutex; - struct mutex prepare_mutex; unsigned int spdif_status; /* IEC958 status bits */ unsigned short spdif_ctls; /* SPDIF control bits */ unsigned int spdif_in_enable; /* SPDIF input enable? */ hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ struct snd_array init_pins; /* initial (BIOS) pin configurations */ struct snd_array driver_pins; /* pin configs set by codec parser */ - struct snd_array cvt_setups; /* audio convert setups */ #ifdef CONFIG_SND_HDA_HWDEP struct snd_hwdep *hwdep; /* assigned hwdep device */ @@ -950,16 +948,6 @@ int snd_hda_codec_build_controls(struct hda_codec *codec); */ int snd_hda_build_pcms(struct hda_bus *bus); int snd_hda_codec_build_pcms(struct hda_codec *codec); - -int snd_hda_codec_prepare(struct hda_codec *codec, - struct hda_pcm_stream *hinfo, - unsigned int stream, - unsigned int format, - struct snd_pcm_substream *substream); -void snd_hda_codec_cleanup(struct hda_codec *codec, - struct hda_pcm_stream *hinfo, - struct snd_pcm_substream *substream); - void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, int channel_id, int format); diff --git a/trunk/sound/pci/hda/hda_intel.c b/trunk/sound/pci/hda/hda_intel.c index 1053fff4bd0a..66d420212d9a 100644 --- a/trunk/sound/pci/hda/hda_intel.c +++ b/trunk/sound/pci/hda/hda_intel.c @@ -1634,7 +1634,7 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream) azx_dev->period_bytes = 0; azx_dev->format_val = 0; - snd_hda_codec_cleanup(apcm->codec, hinfo, substream); + hinfo->ops.cleanup(hinfo, apcm->codec, substream); return snd_pcm_lib_free_pages(substream); } @@ -1688,8 +1688,8 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) else azx_dev->fifo_size = 0; - return snd_hda_codec_prepare(apcm->codec, hinfo, azx_dev->stream_tag, - azx_dev->format_val, substream); + return hinfo->ops.prepare(hinfo, apcm->codec, azx_dev->stream_tag, + azx_dev->format_val, substream); } static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) diff --git a/trunk/sound/pci/hda/patch_conexant.c b/trunk/sound/pci/hda/patch_conexant.c index f7e234e5ee96..df8b19b17308 100644 --- a/trunk/sound/pci/hda/patch_conexant.c +++ b/trunk/sound/pci/hda/patch_conexant.c @@ -3206,8 +3206,6 @@ static struct hda_codec_preset snd_hda_preset_conexant[] = { .patch = patch_cxt5066 }, { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", .patch = patch_cxt5066 }, - { .id = 0x14f15068, .name = "CX20584", - .patch = patch_cxt5066 }, { .id = 0x14f15069, .name = "CX20585", .patch = patch_cxt5066 }, {} /* terminator */ @@ -3218,7 +3216,6 @@ MODULE_ALIAS("snd-hda-codec-id:14f15047"); MODULE_ALIAS("snd-hda-codec-id:14f15051"); MODULE_ALIAS("snd-hda-codec-id:14f15066"); MODULE_ALIAS("snd-hda-codec-id:14f15067"); -MODULE_ALIAS("snd-hda-codec-id:14f15068"); MODULE_ALIAS("snd-hda-codec-id:14f15069"); MODULE_LICENSE("GPL"); diff --git a/trunk/sound/pci/hda/patch_nvhdmi.c b/trunk/sound/pci/hda/patch_nvhdmi.c index 77e2b4028b9f..a281836fd472 100644 --- a/trunk/sound/pci/hda/patch_nvhdmi.c +++ b/trunk/sound/pci/hda/patch_nvhdmi.c @@ -540,32 +540,26 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec) * patch entries */ static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { - { .id = 0x10de0002, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0003, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, - { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, + { .id = 0x10de0002, .name = "MCP77/78 HDMI", + .patch = patch_nvhdmi_8ch_7x }, + { .id = 0x10de0003, .name = "MCP77/78 HDMI", + .patch = patch_nvhdmi_8ch_7x }, + { .id = 0x10de0005, .name = "MCP77/78 HDMI", + .patch = patch_nvhdmi_8ch_7x }, + { .id = 0x10de0006, .name = "MCP77/78 HDMI", + .patch = patch_nvhdmi_8ch_7x }, + { .id = 0x10de0007, .name = "MCP79/7A HDMI", + .patch = patch_nvhdmi_8ch_7x }, + { .id = 0x10de000a, .name = "GT220 HDMI", + .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de000b, .name = "GT21x HDMI", + .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de000c, .name = "MCP89 HDMI", + .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de000d, .name = "GT240 HDMI", + .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, + { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, {} /* terminator */ }; @@ -578,21 +572,6 @@ MODULE_ALIAS("snd-hda-codec-id:10de000a"); MODULE_ALIAS("snd-hda-codec-id:10de000b"); MODULE_ALIAS("snd-hda-codec-id:10de000c"); MODULE_ALIAS("snd-hda-codec-id:10de000d"); -MODULE_ALIAS("snd-hda-codec-id:10de0010"); -MODULE_ALIAS("snd-hda-codec-id:10de0011"); -MODULE_ALIAS("snd-hda-codec-id:10de0012"); -MODULE_ALIAS("snd-hda-codec-id:10de0013"); -MODULE_ALIAS("snd-hda-codec-id:10de0014"); -MODULE_ALIAS("snd-hda-codec-id:10de0018"); -MODULE_ALIAS("snd-hda-codec-id:10de0019"); -MODULE_ALIAS("snd-hda-codec-id:10de001a"); -MODULE_ALIAS("snd-hda-codec-id:10de001b"); -MODULE_ALIAS("snd-hda-codec-id:10de001c"); -MODULE_ALIAS("snd-hda-codec-id:10de0040"); -MODULE_ALIAS("snd-hda-codec-id:10de0041"); -MODULE_ALIAS("snd-hda-codec-id:10de0042"); -MODULE_ALIAS("snd-hda-codec-id:10de0043"); -MODULE_ALIAS("snd-hda-codec-id:10de0044"); MODULE_ALIAS("snd-hda-codec-id:10de0067"); MODULE_ALIAS("snd-hda-codec-id:10de8001"); diff --git a/trunk/sound/pci/hda/patch_realtek.c b/trunk/sound/pci/hda/patch_realtek.c index 55d6e5b6bb7d..6ac53f7de549 100644 --- a/trunk/sound/pci/hda/patch_realtek.c +++ b/trunk/sound/pci/hda/patch_realtek.c @@ -137,7 +137,6 @@ enum { ALC269VB_DMIC, ALC269_FUJITSU, ALC269_LIFEBOOK, - ALC271_ACER, ALC269_AUTO, ALC269_MODEL_LAST /* last tag */ }; @@ -7042,7 +7041,6 @@ static int patch_alc260(struct hda_codec *codec) spec->stream_analog_playback = &alc260_pcm_analog_playback; spec->stream_analog_capture = &alc260_pcm_analog_capture; - spec->stream_analog_alt_capture = &alc260_pcm_analog_capture; spec->stream_digital_playback = &alc260_pcm_digital_playback; spec->stream_digital_capture = &alc260_pcm_digital_capture; @@ -13477,6 +13475,7 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = { SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), + SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL), {} }; @@ -13867,12 +13866,6 @@ static struct snd_kcontrol_new alc269vb_laptop_mixer[] = { { } /* end */ }; -static struct snd_kcontrol_new alc269_asus_mixer[] = { - HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), - HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT), - { } /* end */ -}; - /* capture mixer elements */ static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = { HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), @@ -14093,20 +14086,6 @@ static struct hda_verb alc269vb_laptop_amic_init_verbs[] = { {} }; -static struct hda_verb alc271_acer_dmic_verbs[] = { - {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, - {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, - {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, - {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, - {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, - {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, - {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, - {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, - {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, - {0x22, AC_VERB_SET_CONNECT_SEL, 6}, - { } -}; - /* toggle speaker-output according to the hp-jack state */ static void alc269_speaker_automute(struct hda_codec *codec) { @@ -14486,7 +14465,6 @@ static const char *alc269_models[ALC269_MODEL_LAST] = { static struct snd_pci_quirk alc269_cfg_tbl[] = { SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), - SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER), SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", ALC269_AMIC), SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC), @@ -14648,23 +14626,6 @@ static struct alc_config_preset alc269_presets[] = { .unsol_event = alc269_lifebook_unsol_event, .init_hook = alc269_lifebook_init_hook, }, - [ALC271_ACER] = { - .mixers = { alc269_asus_mixer }, - .cap_mixer = alc269vb_laptop_digital_capture_mixer, - .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs }, - .num_dacs = ARRAY_SIZE(alc269_dac_nids), - .dac_nids = alc269_dac_nids, - .adc_nids = alc262_dmic_adc_nids, - .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids), - .capsrc_nids = alc262_dmic_capsrc_nids, - .num_channel_mode = ARRAY_SIZE(alc269_modes), - .channel_mode = alc269_modes, - .input_mux = &alc269_capture_source, - .dig_out_nid = ALC880_DIGOUT_NID, - .unsol_event = alc_sku_unsol_event, - .setup = alc269vb_laptop_dmic_setup, - .init_hook = alc_inithook, - }, }; static int patch_alc269(struct hda_codec *codec) diff --git a/trunk/sound/pci/hda/patch_sigmatel.c b/trunk/sound/pci/hda/patch_sigmatel.c index f3f861bd1bf8..b8d730c47df1 100644 --- a/trunk/sound/pci/hda/patch_sigmatel.c +++ b/trunk/sound/pci/hda/patch_sigmatel.c @@ -94,7 +94,6 @@ enum { STAC_92HD83XXX_PWR_REF, STAC_DELL_S14, STAC_92HD83XXX_HP, - STAC_HP_DV7_4000, STAC_92HD83XXX_MODELS }; @@ -1633,17 +1632,10 @@ static unsigned int dell_s14_pin_configs[10] = { 0x40f000f0, 0x40f000f0, }; -static unsigned int hp_dv7_4000_pin_configs[10] = { - 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110, - 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140, - 0x40f000f0, 0x40f000f0, -}; - static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, [STAC_DELL_S14] = dell_s14_pin_configs, - [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs, }; static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { @@ -1652,7 +1644,6 @@ static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { [STAC_92HD83XXX_PWR_REF] = "mic-ref", [STAC_DELL_S14] = "dell-s14", [STAC_92HD83XXX_HP] = "hp", - [STAC_HP_DV7_4000] = "hp-dv7-4000", }; static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { @@ -5349,8 +5340,6 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) case 0x111d7667: case 0x111d7668: case 0x111d7669: - case 0x111d76d1: - case 0x111d76d9: spec->num_pins = ARRAY_SIZE(stac92hd88xxx_pin_nids); spec->pin_nids = stac92hd88xxx_pin_nids; spec->mono_nid = 0; @@ -6285,8 +6274,6 @@ static struct hda_codec_preset snd_hda_preset_sigmatel[] = { { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx}, { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, - { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx}, - { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx}, { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx}, { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx}, { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx}, diff --git a/trunk/sound/soc/blackfin/Kconfig b/trunk/sound/soc/blackfin/Kconfig index 3abeeddc67d3..8ef25025f3dc 100644 --- a/trunk/sound/soc/blackfin/Kconfig +++ b/trunk/sound/soc/blackfin/Kconfig @@ -105,18 +105,13 @@ config SND_BF5XX_RESET_GPIO_NUM Set the correct GPIO for RESET the sound chip. config SND_BF5XX_SOC_AD1980 - tristate "SoC AD1980/1 Audio support for BF5xx (Obsolete)" + tristate "SoC AD1980/1 Audio support for BF5xx" depends on SND_BF5XX_AC97 select SND_BF5XX_SOC_AC97 select SND_SOC_AD1980 help Say Y if you want to add support for SoC audio on BF5xx STAMP/EZKIT. - Warning: - Because Analog Devices Inc. discontinued the ad1980 sound chip since - Sep. 2009, this ad1980 driver is not maintained, tested and supported - by ADI now. - config SND_BF5XX_SOC_SPORT tristate diff --git a/trunk/sound/soc/blackfin/bf5xx-ad1980.c b/trunk/sound/soc/blackfin/bf5xx-ad1980.c index 92f7c327bb7a..d8f591273778 100644 --- a/trunk/sound/soc/blackfin/bf5xx-ad1980.c +++ b/trunk/sound/soc/blackfin/bf5xx-ad1980.c @@ -26,14 +26,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* - * WARNING: - * - * Because Analog Devices Inc. discontinued the ad1980 sound chip since - * Sep. 2009, this ad1980 driver is not maintained, tested and supported - * by ADI now. - */ - #include #include #include @@ -117,5 +109,5 @@ module_exit(bf5xx_board_exit); /* Module information */ MODULE_AUTHOR("Cliff Cai"); -MODULE_DESCRIPTION("ALSA SoC AD1980/1 BF5xx board (Obsolete)"); +MODULE_DESCRIPTION("ALSA SoC AD1980/1 BF5xx board"); MODULE_LICENSE("GPL"); diff --git a/trunk/sound/soc/codecs/ad1980.c b/trunk/sound/soc/codecs/ad1980.c index 70cfaec3be2c..042072738cdc 100644 --- a/trunk/sound/soc/codecs/ad1980.c +++ b/trunk/sound/soc/codecs/ad1980.c @@ -11,14 +11,6 @@ * option) any later version. */ -/* - * WARNING: - * - * Because Analog Devices Inc. discontinued the ad1980 sound chip since - * Sep. 2009, this ad1980 driver is not maintained, tested and supported - * by ADI now. - */ - #include #include #include @@ -306,6 +298,6 @@ struct snd_soc_codec_device soc_codec_dev_ad1980 = { }; EXPORT_SYMBOL_GPL(soc_codec_dev_ad1980); -MODULE_DESCRIPTION("ASoC ad1980 driver (Obsolete)"); +MODULE_DESCRIPTION("ASoC ad1980 driver"); MODULE_AUTHOR("Roy Huang, Cliff Cai"); MODULE_LICENSE("GPL"); diff --git a/trunk/sound/soc/codecs/ad1980.h b/trunk/sound/soc/codecs/ad1980.h index 538f37c90806..db6c8500d66b 100644 --- a/trunk/sound/soc/codecs/ad1980.h +++ b/trunk/sound/soc/codecs/ad1980.h @@ -1,11 +1,5 @@ /* * ad1980.h -- ad1980 Soc Audio driver - * - * WARNING: - * - * Because Analog Devices Inc. discontinued the ad1980 sound chip since - * Sep. 2009, this ad1980 driver is not maintained, tested and supported - * by ADI now. */ #ifndef _AD1980_H diff --git a/trunk/sound/soc/codecs/wm8580.c b/trunk/sound/soc/codecs/wm8580.c index 72deeabef4fe..c3571ee5c11b 100644 --- a/trunk/sound/soc/codecs/wm8580.c +++ b/trunk/sound/soc/codecs/wm8580.c @@ -269,9 +269,9 @@ SOC_DOUBLE("DAC2 Invert Switch", WM8580_DAC_CONTROL4, 2, 3, 1, 0), SOC_DOUBLE("DAC3 Invert Switch", WM8580_DAC_CONTROL4, 4, 5, 1, 0), SOC_SINGLE("DAC ZC Switch", WM8580_DAC_CONTROL5, 5, 1, 0), -SOC_SINGLE("DAC1 Switch", WM8580_DAC_CONTROL5, 0, 1, 1), -SOC_SINGLE("DAC2 Switch", WM8580_DAC_CONTROL5, 1, 1, 1), -SOC_SINGLE("DAC3 Switch", WM8580_DAC_CONTROL5, 2, 1, 1), +SOC_SINGLE("DAC1 Switch", WM8580_DAC_CONTROL5, 0, 1, 0), +SOC_SINGLE("DAC2 Switch", WM8580_DAC_CONTROL5, 1, 1, 0), +SOC_SINGLE("DAC3 Switch", WM8580_DAC_CONTROL5, 2, 1, 0), SOC_DOUBLE("ADC Mute Switch", WM8580_ADC_CONTROL1, 0, 1, 1, 0), SOC_SINGLE("ADC High-Pass Filter Switch", WM8580_ADC_CONTROL1, 4, 1, 0), diff --git a/trunk/sound/soc/fsl/mpc5200_dma.c b/trunk/sound/soc/fsl/mpc5200_dma.c index 3dcd1469f283..1d4e7164e80a 100644 --- a/trunk/sound/soc/fsl/mpc5200_dma.c +++ b/trunk/sound/soc/fsl/mpc5200_dma.c @@ -369,7 +369,7 @@ struct snd_soc_platform mpc5200_audio_dma_platform = { }; EXPORT_SYMBOL_GPL(mpc5200_audio_dma_platform); -int mpc5200_audio_dma_create(struct platform_device *op) +int mpc5200_audio_dma_create(struct of_device *op) { phys_addr_t fifo; struct psc_dma *psc_dma; @@ -488,7 +488,7 @@ int mpc5200_audio_dma_create(struct platform_device *op) } EXPORT_SYMBOL_GPL(mpc5200_audio_dma_create); -int mpc5200_audio_dma_destroy(struct platform_device *op) +int mpc5200_audio_dma_destroy(struct of_device *op) { struct psc_dma *psc_dma = dev_get_drvdata(&op->dev); diff --git a/trunk/sound/soc/fsl/mpc5200_dma.h b/trunk/sound/soc/fsl/mpc5200_dma.h index ca99586f2ad9..e1ec6d91ea38 100644 --- a/trunk/sound/soc/fsl/mpc5200_dma.h +++ b/trunk/sound/soc/fsl/mpc5200_dma.h @@ -81,8 +81,8 @@ to_psc_dma_stream(struct snd_pcm_substream *substream, struct psc_dma *psc_dma) return &psc_dma->playback; } -int mpc5200_audio_dma_create(struct platform_device *op); -int mpc5200_audio_dma_destroy(struct platform_device *op); +int mpc5200_audio_dma_create(struct of_device *op); +int mpc5200_audio_dma_destroy(struct of_device *op); extern struct snd_soc_platform mpc5200_audio_dma_platform; diff --git a/trunk/sound/soc/fsl/mpc5200_psc_ac97.c b/trunk/sound/soc/fsl/mpc5200_psc_ac97.c index a9560235daee..e7f5d50ed084 100644 --- a/trunk/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/trunk/sound/soc/fsl/mpc5200_psc_ac97.c @@ -277,7 +277,7 @@ EXPORT_SYMBOL_GPL(psc_ac97_dai); * - Probe/remove operations * - OF device match table */ -static int __devinit psc_ac97_of_probe(struct platform_device *op, +static int __devinit psc_ac97_of_probe(struct of_device *op, const struct of_device_id *match) { int rc, i; @@ -317,7 +317,7 @@ static int __devinit psc_ac97_of_probe(struct platform_device *op, return 0; } -static int __devexit psc_ac97_of_remove(struct platform_device *op) +static int __devexit psc_ac97_of_remove(struct of_device *op) { return mpc5200_audio_dma_destroy(op); } diff --git a/trunk/sound/soc/fsl/mpc5200_psc_i2s.c b/trunk/sound/soc/fsl/mpc5200_psc_i2s.c index 534f04cb15d7..676841cbae98 100644 --- a/trunk/sound/soc/fsl/mpc5200_psc_i2s.c +++ b/trunk/sound/soc/fsl/mpc5200_psc_i2s.c @@ -152,7 +152,7 @@ EXPORT_SYMBOL_GPL(psc_i2s_dai); * - Probe/remove operations * - OF device match table */ -static int __devinit psc_i2s_of_probe(struct platform_device *op, +static int __devinit psc_i2s_of_probe(struct of_device *op, const struct of_device_id *match) { int rc; @@ -205,7 +205,7 @@ static int __devinit psc_i2s_of_probe(struct platform_device *op, } -static int __devexit psc_i2s_of_remove(struct platform_device *op) +static int __devexit psc_i2s_of_remove(struct of_device *op) { return mpc5200_audio_dma_destroy(op); } diff --git a/trunk/sound/soc/fsl/mpc8610_hpcd.c b/trunk/sound/soc/fsl/mpc8610_hpcd.c index 3b13b8d65262..3a501062c244 100644 --- a/trunk/sound/soc/fsl/mpc8610_hpcd.c +++ b/trunk/sound/soc/fsl/mpc8610_hpcd.c @@ -200,7 +200,7 @@ static struct snd_soc_ops mpc8610_hpcd_ops = { * SSI devices. We also probably aren't compatible with the generic Elo DMA * device driver. */ -static int mpc8610_hpcd_probe(struct platform_device *ofdev, +static int mpc8610_hpcd_probe(struct of_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -534,7 +534,7 @@ static int mpc8610_hpcd_probe(struct platform_device *ofdev, * * This function is called when the OF device is removed. */ -static int mpc8610_hpcd_remove(struct platform_device *ofdev) +static int mpc8610_hpcd_remove(struct of_device *ofdev) { struct platform_device *sound_device = dev_get_drvdata(&ofdev->dev); struct mpc8610_hpcd_data *machine_data = diff --git a/trunk/sound/soc/imx/Kconfig b/trunk/sound/soc/imx/Kconfig index 687c76fc0839..52dac5e3874c 100644 --- a/trunk/sound/soc/imx/Kconfig +++ b/trunk/sound/soc/imx/Kconfig @@ -28,9 +28,7 @@ config SND_SOC_PHYCORE_AC97 config SND_SOC_EUKREA_TLV320 tristate "Eukrea TLV320" - depends on MACH_EUKREA_MBIMX27_BASEBOARD \ - || MACH_EUKREA_MBIMXSD25_BASEBOARD \ - || MACH_EUKREA_MBIMXSD35_BASEBOARD + depends on MACH_EUKREA_MBIMX27_BASEBOARD || MACH_EUKREA_MBIMXSD_BASEBOARD select SND_SOC_TLV320AIC23 help Enable I2S based access to the TLV320AIC23B codec attached diff --git a/trunk/sound/soc/soc-cache.c b/trunk/sound/soc/soc-cache.c index adbc68ce9050..472af38188c1 100644 --- a/trunk/sound/soc/soc-cache.c +++ b/trunk/sound/soc/soc-cache.c @@ -340,7 +340,7 @@ static unsigned int snd_soc_16_8_read_i2c(struct snd_soc_codec *codec, static unsigned int snd_soc_16_8_read(struct snd_soc_codec *codec, unsigned int reg) { - u8 *cache = codec->reg_cache; + u16 *cache = codec->reg_cache; reg &= 0xff; if (reg >= codec->reg_cache_size) @@ -351,7 +351,7 @@ static unsigned int snd_soc_16_8_read(struct snd_soc_codec *codec, static int snd_soc_16_8_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { - u8 *cache = codec->reg_cache; + u16 *cache = codec->reg_cache; u8 data[3]; int ret; diff --git a/trunk/sound/sparc/amd7930.c b/trunk/sound/sparc/amd7930.c index f8bcfc30f800..9eb1a4e0363b 100644 --- a/trunk/sound/sparc/amd7930.c +++ b/trunk/sound/sparc/amd7930.c @@ -336,7 +336,7 @@ struct snd_amd7930 { int pgain; int mgain; - struct platform_device *op; + struct of_device *op; unsigned int irq; struct snd_amd7930 *next; }; @@ -906,7 +906,7 @@ static int __devinit snd_amd7930_mixer(struct snd_amd7930 *amd) static int snd_amd7930_free(struct snd_amd7930 *amd) { - struct platform_device *op = amd->op; + struct of_device *op = amd->op; amd7930_idle(amd); @@ -934,7 +934,7 @@ static struct snd_device_ops snd_amd7930_dev_ops = { }; static int __devinit snd_amd7930_create(struct snd_card *card, - struct platform_device *op, + struct of_device *op, int irq, int dev, struct snd_amd7930 **ramd) { @@ -1002,7 +1002,7 @@ static int __devinit snd_amd7930_create(struct snd_card *card, return 0; } -static int __devinit amd7930_sbus_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit amd7930_sbus_probe(struct of_device *op, const struct of_device_id *match) { struct resource *rp = &op->resource[0]; static int dev_num; diff --git a/trunk/sound/sparc/cs4231.c b/trunk/sound/sparc/cs4231.c index c276086c3b57..68570ee2c9bb 100644 --- a/trunk/sound/sparc/cs4231.c +++ b/trunk/sound/sparc/cs4231.c @@ -111,7 +111,7 @@ struct snd_cs4231 { struct mutex mce_mutex; /* mutex for mce register */ struct mutex open_mutex; /* mutex for ALSA open/close */ - struct platform_device *op; + struct of_device *op; unsigned int irq[2]; unsigned int regs_size; struct snd_cs4231 *next; @@ -1771,7 +1771,7 @@ static unsigned int sbus_dma_addr(struct cs4231_dma_control *dma_cont) static int snd_cs4231_sbus_free(struct snd_cs4231 *chip) { - struct platform_device *op = chip->op; + struct of_device *op = chip->op; if (chip->irq[0]) free_irq(chip->irq[0], chip); @@ -1794,7 +1794,7 @@ static struct snd_device_ops snd_cs4231_sbus_dev_ops = { }; static int __devinit snd_cs4231_sbus_create(struct snd_card *card, - struct platform_device *op, + struct of_device *op, int dev) { struct snd_cs4231 *chip = card->private_data; @@ -1856,7 +1856,7 @@ static int __devinit snd_cs4231_sbus_create(struct snd_card *card, return 0; } -static int __devinit cs4231_sbus_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit cs4231_sbus_probe(struct of_device *op, const struct of_device_id *match) { struct resource *rp = &op->resource[0]; struct snd_card *card; @@ -1931,7 +1931,7 @@ static unsigned int _ebus_dma_addr(struct cs4231_dma_control *dma_cont) static int snd_cs4231_ebus_free(struct snd_cs4231 *chip) { - struct platform_device *op = chip->op; + struct of_device *op = chip->op; if (chip->c_dma.ebus_info.regs) { ebus_dma_unregister(&chip->c_dma.ebus_info); @@ -1960,7 +1960,7 @@ static struct snd_device_ops snd_cs4231_ebus_dev_ops = { }; static int __devinit snd_cs4231_ebus_create(struct snd_card *card, - struct platform_device *op, + struct of_device *op, int dev) { struct snd_cs4231 *chip = card->private_data; @@ -2048,7 +2048,7 @@ static int __devinit snd_cs4231_ebus_create(struct snd_card *card, return 0; } -static int __devinit cs4231_ebus_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit cs4231_ebus_probe(struct of_device *op, const struct of_device_id *match) { struct snd_card *card; int err; @@ -2072,7 +2072,7 @@ static int __devinit cs4231_ebus_probe(struct platform_device *op, const struct } #endif -static int __devinit cs4231_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit cs4231_probe(struct of_device *op, const struct of_device_id *match) { #ifdef EBUS_SUPPORT if (!strcmp(op->dev.of_node->parent->name, "ebus")) @@ -2086,7 +2086,7 @@ static int __devinit cs4231_probe(struct platform_device *op, const struct of_de return -ENODEV; } -static int __devexit cs4231_remove(struct platform_device *op) +static int __devexit cs4231_remove(struct of_device *op) { struct snd_cs4231 *chip = dev_get_drvdata(&op->dev); diff --git a/trunk/sound/sparc/dbri.c b/trunk/sound/sparc/dbri.c index 39cd5d69d051..c421901c48d0 100644 --- a/trunk/sound/sparc/dbri.c +++ b/trunk/sound/sparc/dbri.c @@ -299,7 +299,7 @@ struct dbri_streaminfo { /* This structure holds the information for both chips (DBRI & CS4215) */ struct snd_dbri { int regs_size, irq; /* Needed for unload */ - struct platform_device *op; /* OF device info */ + struct of_device *op; /* OF device info */ spinlock_t lock; struct dbri_dma *dma; /* Pointer to our DMA block */ @@ -2523,7 +2523,7 @@ static void __devinit snd_dbri_proc(struct snd_card *card) static void snd_dbri_free(struct snd_dbri *dbri); static int __devinit snd_dbri_create(struct snd_card *card, - struct platform_device *op, + struct of_device *op, int irq, int dev) { struct snd_dbri *dbri = card->private_data; @@ -2592,7 +2592,7 @@ static void snd_dbri_free(struct snd_dbri *dbri) (void *)dbri->dma, dbri->dma_dvma); } -static int __devinit dbri_probe(struct platform_device *op, const struct of_device_id *match) +static int __devinit dbri_probe(struct of_device *op, const struct of_device_id *match) { struct snd_dbri *dbri; struct resource *rp; @@ -2662,7 +2662,7 @@ static int __devinit dbri_probe(struct platform_device *op, const struct of_devi return err; } -static int __devexit dbri_remove(struct platform_device *op) +static int __devexit dbri_remove(struct of_device *op) { struct snd_card *card = dev_get_drvdata(&op->dev);