From a2529ad9e5bed1935ac30cbe5b53de805485b171 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:06:50 -0800 Subject: drivers/iommu/omap-iopgtable.h: remove unneeded cast of void* Signed-off-by: Jingoo Han Cc: Joerg Roedel Cc: Tony Lindgren Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/iommu/omap-iopgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/iommu/omap-iopgtable.h b/drivers/iommu/omap-iopgtable.h index f4003d5..b6f9a51 100644 --- a/drivers/iommu/omap-iopgtable.h +++ b/drivers/iommu/omap-iopgtable.h @@ -95,4 +95,4 @@ static inline phys_addr_t omap_iommu_translate(u32 d, u32 va, u32 mask) #define iopte_offset(iopgd, da) (iopgd_page_vaddr(iopgd) + iopte_index(da)) #define to_iommu(dev) \ - ((struct omap_iommu *)platform_get_drvdata(to_platform_device(dev))) + (platform_get_drvdata(to_platform_device(dev))) -- cgit v1.1 From 3207d9e72c6227b0a9a2624ae7984b32af5fb288 Mon Sep 17 00:00:00 2001 From: Xishi Qiu Date: Tue, 12 Nov 2013 15:07:14 -0800 Subject: drivers/video/acornfb.c: use __free_reserved_page() to simplify the code Use __free_reserved_page() to simplify the code in the others. Signed-off-by: Xishi Qiu Cc: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/acornfb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c index 7e8346e..a305cae 100644 --- a/drivers/video/acornfb.c +++ b/drivers/video/acornfb.c @@ -949,9 +949,7 @@ free_unused_pages(unsigned int virtual_start, unsigned int virtual_end) * the page. */ page = virt_to_page(virtual_start); - ClearPageReserved(page); - init_page_count(page); - free_page(virtual_start); + __free_reserved_page(page); virtual_start += PAGE_SIZE; mb_freed += PAGE_SIZE / 1024; -- cgit v1.1 From 3d035f580699feba352f8703cced127fc203f0dd Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 12 Nov 2013 15:08:33 -0800 Subject: drivers/char/hpet.c: allow user controlled mmap for user processes The CONFIG_HPET_MMAP Kconfig option exposes the memory map of the HPET registers to userspace. The Kconfig help points out that in some cases this can be a security risk as some systems may erroneously configure the map such that additional data is exposed to userspace. This is a problem for distributions -- some users want the MMAP functionality but it comes with a significant security risk. In an effort to mitigate this risk, and due to the low number of users of the MMAP functionality, I've introduced a kernel parameter, hpet_mmap_enable, that is required in order to actually have the HPET MMAP exposed. Signed-off-by: Prarit Bhargava Acked-by: Matt Wilson Signed-off-by: Clemens Ladisch Cc: Randy Dunlap Cc: Tomas Winkler Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/Kconfig | 10 ++++++++-- drivers/char/hpet.c | 24 ++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 1421997..fa3243d 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -522,10 +522,16 @@ config HPET_MMAP If you say Y here, user applications will be able to mmap the HPET registers. +config HPET_MMAP_DEFAULT + bool "Enable HPET MMAP access by default" + default y + depends on HPET_MMAP + help In some hardware implementations, the page containing HPET registers may also contain other things that shouldn't be - exposed to the user. If this applies to your hardware, - say N here. + exposed to the user. This option selects the default (if + kernel parameter hpet_mmap is not set) user access to the + registers for applications that require it. config HANGCHECK_TIMER tristate "Hangcheck timer" diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index dca5834..5d9c31d 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -367,12 +367,29 @@ static unsigned int hpet_poll(struct file *file, poll_table * wait) return 0; } +#ifdef CONFIG_HPET_MMAP +#ifdef CONFIG_HPET_MMAP_DEFAULT +static int hpet_mmap_enabled = 1; +#else +static int hpet_mmap_enabled = 0; +#endif + +static __init int hpet_mmap_enable(char *str) +{ + get_option(&str, &hpet_mmap_enabled); + pr_info("HPET mmap %s\n", hpet_mmap_enabled ? "enabled" : "disabled"); + return 1; +} +__setup("hpet_mmap", hpet_mmap_enable); + static int hpet_mmap(struct file *file, struct vm_area_struct *vma) { -#ifdef CONFIG_HPET_MMAP struct hpet_dev *devp; unsigned long addr; + if (!hpet_mmap_enabled) + return -EACCES; + devp = file->private_data; addr = devp->hd_hpets->hp_hpet_phys; @@ -381,10 +398,13 @@ static int hpet_mmap(struct file *file, struct vm_area_struct *vma) vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); return vm_iomap_memory(vma, addr, PAGE_SIZE); +} #else +static int hpet_mmap(struct file *file, struct vm_area_struct *vma) +{ return -ENOSYS; -#endif } +#endif static int hpet_fasync(int fd, struct file *file, int on) { -- cgit v1.1 From 0ca43435188b9f911c8efcdf10731f726142dda1 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Tue, 12 Nov 2013 15:08:40 -0800 Subject: errno.h: remove "NFS" from descriptions in comments glibc recently changed the error string for ESTALE to remove "NFS" - https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=96945714ec61951cc748da2b4b8a80cf02127ee9 from: [ERR_REMAP (ESTALE)] = N_("Stale NFS file handle"), to: [ERR_REMAP (ESTALE)] = N_("Stale file handle"), And some have expressed concern that the kernel's errno.h comments still refer to NFS. So make that change... note that this is a comment-only change, and has no functional difference. Signed-off-by: Eric Sandeen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/staging/lustre/lustre/include/lustre/lustre_errno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h b/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h index 2870487..35aefa2 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h @@ -165,7 +165,7 @@ #define LUSTRE_EHOSTUNREACH 113 /* No route to host */ #define LUSTRE_EALREADY 114 /* Operation already in progress */ #define LUSTRE_EINPROGRESS 115 /* Operation now in progress */ -#define LUSTRE_ESTALE 116 /* Stale NFS file handle */ +#define LUSTRE_ESTALE 116 /* Stale file handle */ #define LUSTRE_EUCLEAN 117 /* Structure needs cleaning */ #define LUSTRE_ENOTNAM 118 /* Not a XENIX named type file */ #define LUSTRE_ENAVAIL 119 /* No XENIX semaphores available */ -- cgit v1.1 From 5812c13a4e636da4bd7f7cabbbbc59d9dbf3c86c Mon Sep 17 00:00:00 2001 From: Milo Kim Date: Tue, 12 Nov 2013 15:08:57 -0800 Subject: backlight: lp855x_bl: support new LP8555 device LP8555 is one of the LP855x family devices. This device needs pre_init_device() and post_init_device() driver structure. It's same as LP8557, so the device configuration code is shared with LP8557. Backlight outputs are generated from dual DC-DC boost converters. It's configurable EPROM settings which are defined in the platform data. Driver documentation and device tree bindings are updated. Signed-off-by: Milo Kim Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/Kconfig | 4 ++-- drivers/video/backlight/lp855x_bl.c | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index d4a7a35..a65dd06 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -388,8 +388,8 @@ config BACKLIGHT_LP855X tristate "Backlight driver for TI LP855X" depends on BACKLIGHT_CLASS_DEVICE && I2C help - This supports TI LP8550, LP8551, LP8552, LP8553, LP8556 and LP8557 - backlight driver. + This supports TI LP8550, LP8551, LP8552, LP8553, LP8555, LP8556 and + LP8557 backlight driver. config BACKLIGHT_LP8788 tristate "Backlight driver for TI LP8788 MFD" diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index c0b41f13..c952175 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -26,13 +26,15 @@ #define LP8556_EPROM_START 0xA0 #define LP8556_EPROM_END 0xAF -/* LP8557 Registers */ +/* LP8555/7 Registers */ #define LP8557_BL_CMD 0x00 #define LP8557_BL_MASK 0x01 #define LP8557_BL_ON 0x01 #define LP8557_BL_OFF 0x00 #define LP8557_BRIGHTNESS_CTRL 0x04 #define LP8557_CONFIG 0x10 +#define LP8555_EPROM_START 0x10 +#define LP8555_EPROM_END 0x7A #define LP8557_EPROM_START 0x10 #define LP8557_EPROM_END 0x1E @@ -111,6 +113,10 @@ static bool lp855x_is_valid_rom_area(struct lp855x *lp, u8 addr) start = LP8556_EPROM_START; end = LP8556_EPROM_END; break; + case LP8555: + start = LP8555_EPROM_START; + end = LP8555_EPROM_END; + break; case LP8557: start = LP8557_EPROM_START; end = LP8557_EPROM_END; @@ -165,9 +171,14 @@ static int lp855x_configure(struct lp855x *lp) struct lp855x_platform_data *pd = lp->pdata; switch (lp->chip_id) { - case LP8550 ... LP8556: + case LP8550: + case LP8551: + case LP8552: + case LP8553: + case LP8556: lp->cfg = &lp855x_dev_cfg; break; + case LP8555: case LP8557: lp->cfg = &lp8557_dev_cfg; break; @@ -470,6 +481,7 @@ static const struct of_device_id lp855x_dt_ids[] = { { .compatible = "ti,lp8551", }, { .compatible = "ti,lp8552", }, { .compatible = "ti,lp8553", }, + { .compatible = "ti,lp8555", }, { .compatible = "ti,lp8556", }, { .compatible = "ti,lp8557", }, { } @@ -481,6 +493,7 @@ static const struct i2c_device_id lp855x_ids[] = { {"lp8551", LP8551}, {"lp8552", LP8552}, {"lp8553", LP8553}, + {"lp8555", LP8555}, {"lp8556", LP8556}, {"lp8557", LP8557}, { } -- cgit v1.1 From 28e64a68a2ef1c48f30e8b6803725199929069fc Mon Sep 17 00:00:00 2001 From: Daniel Jeong Date: Tue, 12 Nov 2013 15:08:58 -0800 Subject: backlight: lm3630: apply chip revision The LM3630 chip was revised by TI and chip name was also changed to LM3630A. And register map, default values and initial sequences are changed. The files, lm3630_bl.{c,h} are replaced by lm3630a_bl.{c,h} You can find more information about LM3630A(datasheet, evm etc) at http://www.ti.com/product/lm3630a Signed-off-by: Daniel Jeong Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/Kconfig | 6 +- drivers/video/backlight/Makefile | 2 +- drivers/video/backlight/lm3630_bl.c | 475 ---------------------------------- drivers/video/backlight/lm3630a_bl.c | 483 +++++++++++++++++++++++++++++++++++ 4 files changed, 487 insertions(+), 479 deletions(-) delete mode 100644 drivers/video/backlight/lm3630_bl.c create mode 100644 drivers/video/backlight/lm3630a_bl.c (limited to 'drivers') diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index a65dd06..5a3eb2e 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -368,12 +368,12 @@ config BACKLIGHT_AAT2870 If you have a AnalogicTech AAT2870 say Y to enable the backlight driver. -config BACKLIGHT_LM3630 - tristate "Backlight Driver for LM3630" +config BACKLIGHT_LM3630A + tristate "Backlight Driver for LM3630A" depends on BACKLIGHT_CLASS_DEVICE && I2C select REGMAP_I2C help - This supports TI LM3630 Backlight Driver + This supports TI LM3630A Backlight Driver config BACKLIGHT_LM3639 tristate "Backlight Driver for LM3639" diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 38e1bab..bb82002 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -37,7 +37,7 @@ obj-$(CONFIG_BACKLIGHT_GPIO) += gpio_backlight.o obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_bl.o -obj-$(CONFIG_BACKLIGHT_LM3630) += lm3630_bl.o +obj-$(CONFIG_BACKLIGHT_LM3630A) += lm3630a_bl.o obj-$(CONFIG_BACKLIGHT_LM3639) += lm3639_bl.o obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o diff --git a/drivers/video/backlight/lm3630_bl.c b/drivers/video/backlight/lm3630_bl.c deleted file mode 100644 index 76a62e9..0000000 --- a/drivers/video/backlight/lm3630_bl.c +++ /dev/null @@ -1,475 +0,0 @@ -/* -* Simple driver for Texas Instruments LM3630 Backlight driver chip -* Copyright (C) 2012 Texas Instruments -* -* 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 -#include -#include - -#define REG_CTRL 0x00 -#define REG_CONFIG 0x01 -#define REG_BRT_A 0x03 -#define REG_BRT_B 0x04 -#define REG_INT_STATUS 0x09 -#define REG_INT_EN 0x0A -#define REG_FAULT 0x0B -#define REG_PWM_OUTLOW 0x12 -#define REG_PWM_OUTHIGH 0x13 -#define REG_MAX 0x1F - -#define INT_DEBOUNCE_MSEC 10 - -enum lm3630_leds { - BLED_ALL = 0, - BLED_1, - BLED_2 -}; - -static const char * const bled_name[] = { - [BLED_ALL] = "lm3630_bled", /*Bank1 controls all string */ - [BLED_1] = "lm3630_bled1", /*Bank1 controls bled1 */ - [BLED_2] = "lm3630_bled2", /*Bank1 or 2 controls bled2 */ -}; - -struct lm3630_chip_data { - struct device *dev; - struct delayed_work work; - int irq; - struct workqueue_struct *irqthread; - struct lm3630_platform_data *pdata; - struct backlight_device *bled1; - struct backlight_device *bled2; - struct regmap *regmap; -}; - -/* initialize chip */ -static int lm3630_chip_init(struct lm3630_chip_data *pchip) -{ - int ret; - unsigned int reg_val; - struct lm3630_platform_data *pdata = pchip->pdata; - - /*pwm control */ - reg_val = ((pdata->pwm_active & 0x01) << 2) | (pdata->pwm_ctrl & 0x03); - ret = regmap_update_bits(pchip->regmap, REG_CONFIG, 0x07, reg_val); - if (ret < 0) - goto out; - - /* bank control */ - reg_val = ((pdata->bank_b_ctrl & 0x01) << 1) | - (pdata->bank_a_ctrl & 0x07); - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x07, reg_val); - if (ret < 0) - goto out; - - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - - /* set initial brightness */ - if (pdata->bank_a_ctrl != BANK_A_CTRL_DISABLE) { - ret = regmap_write(pchip->regmap, - REG_BRT_A, pdata->init_brt_led1); - if (ret < 0) - goto out; - } - - if (pdata->bank_b_ctrl != BANK_B_CTRL_DISABLE) { - ret = regmap_write(pchip->regmap, - REG_BRT_B, pdata->init_brt_led2); - if (ret < 0) - goto out; - } - return ret; - -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return ret; -} - -/* interrupt handling */ -static void lm3630_delayed_func(struct work_struct *work) -{ - int ret; - unsigned int reg_val; - struct lm3630_chip_data *pchip; - - pchip = container_of(work, struct lm3630_chip_data, work.work); - - ret = regmap_read(pchip->regmap, REG_INT_STATUS, ®_val); - if (ret < 0) { - dev_err(pchip->dev, - "i2c failed to access REG_INT_STATUS Register\n"); - return; - } - - dev_info(pchip->dev, "REG_INT_STATUS Register is 0x%x\n", reg_val); -} - -static irqreturn_t lm3630_isr_func(int irq, void *chip) -{ - int ret; - struct lm3630_chip_data *pchip = chip; - unsigned long delay = msecs_to_jiffies(INT_DEBOUNCE_MSEC); - - queue_delayed_work(pchip->irqthread, &pchip->work, delay); - - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - - return IRQ_HANDLED; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return IRQ_HANDLED; -} - -static int lm3630_intr_config(struct lm3630_chip_data *pchip) -{ - INIT_DELAYED_WORK(&pchip->work, lm3630_delayed_func); - pchip->irqthread = create_singlethread_workqueue("lm3630-irqthd"); - if (!pchip->irqthread) { - dev_err(pchip->dev, "create irq thread fail...\n"); - return -1; - } - if (request_threaded_irq - (pchip->irq, NULL, lm3630_isr_func, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "lm3630_irq", pchip)) { - dev_err(pchip->dev, "request threaded irq fail..\n"); - return -1; - } - return 0; -} - -static bool -set_intensity(struct backlight_device *bl, struct lm3630_chip_data *pchip) -{ - if (!pchip->pdata->pwm_set_intensity) - return false; - pchip->pdata->pwm_set_intensity(bl->props.brightness - 1, - pchip->pdata->pwm_period); - return true; -} - -/* update and get brightness */ -static int lm3630_bank_a_update_status(struct backlight_device *bl) -{ - int ret; - struct lm3630_chip_data *pchip = bl_get_data(bl); - enum lm3630_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; - - /* brightness 0 means disable */ - if (!bl->props.brightness) { - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x04, 0x00); - if (ret < 0) - goto out; - return bl->props.brightness; - } - - /* pwm control */ - if (pwm_ctrl == PWM_CTRL_BANK_A || pwm_ctrl == PWM_CTRL_BANK_ALL) { - if (!set_intensity(bl, pchip)) - dev_err(pchip->dev, "No pwm control func. in plat-data\n"); - } else { - - /* i2c control */ - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - mdelay(1); - ret = regmap_write(pchip->regmap, - REG_BRT_A, bl->props.brightness - 1); - if (ret < 0) - goto out; - } - return bl->props.brightness; -out: - dev_err(pchip->dev, "i2c failed to access REG_CTRL\n"); - return bl->props.brightness; -} - -static int lm3630_bank_a_get_brightness(struct backlight_device *bl) -{ - unsigned int reg_val; - int brightness, ret; - struct lm3630_chip_data *pchip = bl_get_data(bl); - enum lm3630_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; - - if (pwm_ctrl == PWM_CTRL_BANK_A || pwm_ctrl == PWM_CTRL_BANK_ALL) { - ret = regmap_read(pchip->regmap, REG_PWM_OUTHIGH, ®_val); - if (ret < 0) - goto out; - brightness = reg_val & 0x01; - ret = regmap_read(pchip->regmap, REG_PWM_OUTLOW, ®_val); - if (ret < 0) - goto out; - brightness = ((brightness << 8) | reg_val) + 1; - } else { - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - mdelay(1); - ret = regmap_read(pchip->regmap, REG_BRT_A, ®_val); - if (ret < 0) - goto out; - brightness = reg_val + 1; - } - bl->props.brightness = brightness; - return bl->props.brightness; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return 0; -} - -static const struct backlight_ops lm3630_bank_a_ops = { - .options = BL_CORE_SUSPENDRESUME, - .update_status = lm3630_bank_a_update_status, - .get_brightness = lm3630_bank_a_get_brightness, -}; - -static int lm3630_bank_b_update_status(struct backlight_device *bl) -{ - int ret; - struct lm3630_chip_data *pchip = bl_get_data(bl); - enum lm3630_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; - - if (pwm_ctrl == PWM_CTRL_BANK_B || pwm_ctrl == PWM_CTRL_BANK_ALL) { - if (!set_intensity(bl, pchip)) - dev_err(pchip->dev, - "no pwm control func. in plat-data\n"); - } else { - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - mdelay(1); - ret = regmap_write(pchip->regmap, - REG_BRT_B, bl->props.brightness - 1); - } - return bl->props.brightness; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return bl->props.brightness; -} - -static int lm3630_bank_b_get_brightness(struct backlight_device *bl) -{ - unsigned int reg_val; - int brightness, ret; - struct lm3630_chip_data *pchip = bl_get_data(bl); - enum lm3630_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; - - if (pwm_ctrl == PWM_CTRL_BANK_B || pwm_ctrl == PWM_CTRL_BANK_ALL) { - ret = regmap_read(pchip->regmap, REG_PWM_OUTHIGH, ®_val); - if (ret < 0) - goto out; - brightness = reg_val & 0x01; - ret = regmap_read(pchip->regmap, REG_PWM_OUTLOW, ®_val); - if (ret < 0) - goto out; - brightness = ((brightness << 8) | reg_val) + 1; - } else { - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - mdelay(1); - ret = regmap_read(pchip->regmap, REG_BRT_B, ®_val); - if (ret < 0) - goto out; - brightness = reg_val + 1; - } - bl->props.brightness = brightness; - - return bl->props.brightness; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return bl->props.brightness; -} - -static const struct backlight_ops lm3630_bank_b_ops = { - .options = BL_CORE_SUSPENDRESUME, - .update_status = lm3630_bank_b_update_status, - .get_brightness = lm3630_bank_b_get_brightness, -}; - -static int lm3630_backlight_register(struct lm3630_chip_data *pchip, - enum lm3630_leds ledno) -{ - const char *name = bled_name[ledno]; - struct backlight_properties props; - struct lm3630_platform_data *pdata = pchip->pdata; - - props.type = BACKLIGHT_RAW; - switch (ledno) { - case BLED_1: - case BLED_ALL: - props.brightness = pdata->init_brt_led1; - props.max_brightness = pdata->max_brt_led1; - pchip->bled1 = - backlight_device_register(name, pchip->dev, pchip, - &lm3630_bank_a_ops, &props); - if (IS_ERR(pchip->bled1)) - return PTR_ERR(pchip->bled1); - break; - case BLED_2: - props.brightness = pdata->init_brt_led2; - props.max_brightness = pdata->max_brt_led2; - pchip->bled2 = - backlight_device_register(name, pchip->dev, pchip, - &lm3630_bank_b_ops, &props); - if (IS_ERR(pchip->bled2)) - return PTR_ERR(pchip->bled2); - break; - } - return 0; -} - -static void lm3630_backlight_unregister(struct lm3630_chip_data *pchip) -{ - if (pchip->bled1) - backlight_device_unregister(pchip->bled1); - if (pchip->bled2) - backlight_device_unregister(pchip->bled2); -} - -static const struct regmap_config lm3630_regmap = { - .reg_bits = 8, - .val_bits = 8, - .max_register = REG_MAX, -}; - -static int lm3630_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct lm3630_platform_data *pdata = client->dev.platform_data; - struct lm3630_chip_data *pchip; - int ret; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - dev_err(&client->dev, "fail : i2c functionality check...\n"); - return -EOPNOTSUPP; - } - - if (pdata == NULL) { - dev_err(&client->dev, "fail : no platform data.\n"); - return -ENODATA; - } - - pchip = devm_kzalloc(&client->dev, sizeof(struct lm3630_chip_data), - GFP_KERNEL); - if (!pchip) - return -ENOMEM; - pchip->pdata = pdata; - pchip->dev = &client->dev; - - pchip->regmap = devm_regmap_init_i2c(client, &lm3630_regmap); - if (IS_ERR(pchip->regmap)) { - ret = PTR_ERR(pchip->regmap); - dev_err(&client->dev, "fail : allocate register map: %d\n", - ret); - return ret; - } - i2c_set_clientdata(client, pchip); - - /* chip initialize */ - ret = lm3630_chip_init(pchip); - if (ret < 0) { - dev_err(&client->dev, "fail : init chip\n"); - goto err_chip_init; - } - - switch (pdata->bank_a_ctrl) { - case BANK_A_CTRL_ALL: - ret = lm3630_backlight_register(pchip, BLED_ALL); - pdata->bank_b_ctrl = BANK_B_CTRL_DISABLE; - break; - case BANK_A_CTRL_LED1: - ret = lm3630_backlight_register(pchip, BLED_1); - break; - case BANK_A_CTRL_LED2: - ret = lm3630_backlight_register(pchip, BLED_2); - pdata->bank_b_ctrl = BANK_B_CTRL_DISABLE; - break; - default: - break; - } - - if (ret < 0) - goto err_bl_reg; - - if (pdata->bank_b_ctrl && pchip->bled2 == NULL) { - ret = lm3630_backlight_register(pchip, BLED_2); - if (ret < 0) - goto err_bl_reg; - } - - /* interrupt enable : irq 0 is not allowed for lm3630 */ - pchip->irq = client->irq; - if (pchip->irq) - lm3630_intr_config(pchip); - - dev_info(&client->dev, "LM3630 backlight register OK.\n"); - return 0; - -err_bl_reg: - dev_err(&client->dev, "fail : backlight register.\n"); - lm3630_backlight_unregister(pchip); -err_chip_init: - return ret; -} - -static int lm3630_remove(struct i2c_client *client) -{ - int ret; - struct lm3630_chip_data *pchip = i2c_get_clientdata(client); - - ret = regmap_write(pchip->regmap, REG_BRT_A, 0); - if (ret < 0) - dev_err(pchip->dev, "i2c failed to access register\n"); - - ret = regmap_write(pchip->regmap, REG_BRT_B, 0); - if (ret < 0) - dev_err(pchip->dev, "i2c failed to access register\n"); - - lm3630_backlight_unregister(pchip); - if (pchip->irq) { - free_irq(pchip->irq, pchip); - flush_workqueue(pchip->irqthread); - destroy_workqueue(pchip->irqthread); - } - return 0; -} - -static const struct i2c_device_id lm3630_id[] = { - {LM3630_NAME, 0}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, lm3630_id); - -static struct i2c_driver lm3630_i2c_driver = { - .driver = { - .name = LM3630_NAME, - }, - .probe = lm3630_probe, - .remove = lm3630_remove, - .id_table = lm3630_id, -}; - -module_i2c_driver(lm3630_i2c_driver); - -MODULE_DESCRIPTION("Texas Instruments Backlight driver for LM3630"); -MODULE_AUTHOR("G.Shark Jeong "); -MODULE_AUTHOR("Daniel Jeong "); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c new file mode 100644 index 0000000..cf40cc8 --- /dev/null +++ b/drivers/video/backlight/lm3630a_bl.c @@ -0,0 +1,483 @@ +/* +* Simple driver for Texas Instruments LM3630A Backlight driver chip +* Copyright (C) 2012 Texas Instruments +* +* 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 +#include +#include +#include + +#define REG_CTRL 0x00 +#define REG_BOOST 0x02 +#define REG_CONFIG 0x01 +#define REG_BRT_A 0x03 +#define REG_BRT_B 0x04 +#define REG_I_A 0x05 +#define REG_I_B 0x06 +#define REG_INT_STATUS 0x09 +#define REG_INT_EN 0x0A +#define REG_FAULT 0x0B +#define REG_PWM_OUTLOW 0x12 +#define REG_PWM_OUTHIGH 0x13 +#define REG_MAX 0x1F + +#define INT_DEBOUNCE_MSEC 10 +struct lm3630a_chip { + struct device *dev; + struct delayed_work work; + + int irq; + struct workqueue_struct *irqthread; + struct lm3630a_platform_data *pdata; + struct backlight_device *bleda; + struct backlight_device *bledb; + struct regmap *regmap; + struct pwm_device *pwmd; +}; + +/* i2c access */ +static int lm3630a_read(struct lm3630a_chip *pchip, unsigned int reg) +{ + int rval; + unsigned int reg_val; + + rval = regmap_read(pchip->regmap, reg, ®_val); + if (rval < 0) + return rval; + return reg_val & 0xFF; +} + +static int lm3630a_write(struct lm3630a_chip *pchip, + unsigned int reg, unsigned int data) +{ + return regmap_write(pchip->regmap, reg, data); +} + +static int lm3630a_update(struct lm3630a_chip *pchip, + unsigned int reg, unsigned int mask, + unsigned int data) +{ + return regmap_update_bits(pchip->regmap, reg, mask, data); +} + +/* initialize chip */ +static int lm3630a_chip_init(struct lm3630a_chip *pchip) +{ + int rval; + struct lm3630a_platform_data *pdata = pchip->pdata; + + usleep_range(1000, 2000); + /* set Filter Strength Register */ + rval = lm3630a_write(pchip, 0x50, 0x03); + /* set Cofig. register */ + rval |= lm3630a_update(pchip, REG_CONFIG, 0x07, pdata->pwm_ctrl); + /* set boost control */ + rval |= lm3630a_write(pchip, REG_BOOST, 0x38); + /* set current A */ + rval |= lm3630a_update(pchip, REG_I_A, 0x1F, 0x1F); + /* set current B */ + rval |= lm3630a_write(pchip, REG_I_B, 0x1F); + /* set control */ + rval |= + lm3630a_write(pchip, REG_CTRL, pdata->leda_ctrl | pdata->ledb_ctrl); + usleep_range(1000, 2000); + /* set brightness A and B */ + rval |= lm3630a_write(pchip, REG_BRT_A, pdata->leda_init_brt); + rval |= lm3630a_write(pchip, REG_BRT_B, pdata->ledb_init_brt); + + if (rval < 0) + dev_err(pchip->dev, "i2c failed to access register\n"); + return rval; +} + +/* interrupt handling */ +static void lm3630a_delayed_func(struct work_struct *work) +{ + unsigned int rval; + struct lm3630a_chip *pchip; + + pchip = container_of(work, struct lm3630a_chip, work.work); + + rval = lm3630a_read(pchip, REG_INT_STATUS); + if (rval < 0) { + dev_err(pchip->dev, + "i2c failed to access REG_INT_STATUS Register\n"); + return; + } + + dev_info(pchip->dev, "REG_INT_STATUS Register is 0x%x\n", rval); +} + +static irqreturn_t lm3630a_isr_func(int irq, void *chip) +{ + int rval; + struct lm3630a_chip *pchip = chip; + unsigned long delay = msecs_to_jiffies(INT_DEBOUNCE_MSEC); + + queue_delayed_work(pchip->irqthread, &pchip->work, delay); + + rval = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00); + if (rval < 0) { + dev_err(pchip->dev, "i2c failed to access register\n"); + return IRQ_NONE; + } + return IRQ_HANDLED; +} + +static int lm3630a_intr_config(struct lm3630a_chip *pchip) +{ + int rval; + + rval = lm3630a_write(pchip, REG_INT_EN, 0x87); + if (rval < 0) + return rval; + + INIT_DELAYED_WORK(&pchip->work, lm3630a_delayed_func); + pchip->irqthread = create_singlethread_workqueue("lm3630a-irqthd"); + if (!pchip->irqthread) { + dev_err(pchip->dev, "create irq thread fail\n"); + return -ENOMEM; + } + if (request_threaded_irq + (pchip->irq, NULL, lm3630a_isr_func, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "lm3630a_irq", pchip)) { + dev_err(pchip->dev, "request threaded irq fail\n"); + return -ENOMEM; + } + return rval; +} + +static void lm3630a_pwm_ctrl(struct lm3630a_chip *pchip, int br, int br_max) +{ + unsigned int period = pwm_get_period(pchip->pwmd); + unsigned int duty = br * period / br_max; + + pwm_config(pchip->pwmd, duty, period); + if (duty) + pwm_enable(pchip->pwmd); + else + pwm_disable(pchip->pwmd); +} + +/* update and get brightness */ +static int lm3630a_bank_a_update_status(struct backlight_device *bl) +{ + int ret; + struct lm3630a_chip *pchip = bl_get_data(bl); + enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; + + /* pwm control */ + if ((pwm_ctrl & LM3630A_PWM_BANK_A) != 0) { + lm3630a_pwm_ctrl(pchip, bl->props.brightness, + bl->props.max_brightness); + return bl->props.brightness; + } + + /* disable sleep */ + ret = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00); + if (ret < 0) + goto out_i2c_err; + usleep_range(1000, 2000); + /* minimum brightness is 0x04 */ + ret = lm3630a_write(pchip, REG_BRT_A, bl->props.brightness); + if (bl->props.brightness < 0x4) + ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDA_ENABLE, 0); + else + ret |= lm3630a_update(pchip, REG_CTRL, + LM3630A_LEDA_ENABLE, LM3630A_LEDA_ENABLE); + if (ret < 0) + goto out_i2c_err; + return bl->props.brightness; + +out_i2c_err: + dev_err(pchip->dev, "i2c failed to access\n"); + return bl->props.brightness; +} + +static int lm3630a_bank_a_get_brightness(struct backlight_device *bl) +{ + int brightness, rval; + struct lm3630a_chip *pchip = bl_get_data(bl); + enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; + + if ((pwm_ctrl & LM3630A_PWM_BANK_A) != 0) { + rval = lm3630a_read(pchip, REG_PWM_OUTHIGH); + if (rval < 0) + goto out_i2c_err; + brightness = (rval & 0x01) << 8; + rval = lm3630a_read(pchip, REG_PWM_OUTLOW); + if (rval < 0) + goto out_i2c_err; + brightness |= rval; + goto out; + } + + /* disable sleep */ + rval = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00); + if (rval < 0) + goto out_i2c_err; + usleep_range(1000, 2000); + rval = lm3630a_read(pchip, REG_BRT_A); + if (rval < 0) + goto out_i2c_err; + brightness = rval; + +out: + bl->props.brightness = brightness; + return bl->props.brightness; +out_i2c_err: + dev_err(pchip->dev, "i2c failed to access register\n"); + return 0; +} + +static const struct backlight_ops lm3630a_bank_a_ops = { + .options = BL_CORE_SUSPENDRESUME, + .update_status = lm3630a_bank_a_update_status, + .get_brightness = lm3630a_bank_a_get_brightness, +}; + +/* update and get brightness */ +static int lm3630a_bank_b_update_status(struct backlight_device *bl) +{ + int ret; + struct lm3630a_chip *pchip = bl_get_data(bl); + enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; + + /* pwm control */ + if ((pwm_ctrl & LM3630A_PWM_BANK_B) != 0) { + lm3630a_pwm_ctrl(pchip, bl->props.brightness, + bl->props.max_brightness); + return bl->props.brightness; + } + + /* disable sleep */ + ret = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00); + if (ret < 0) + goto out_i2c_err; + usleep_range(1000, 2000); + /* minimum brightness is 0x04 */ + ret = lm3630a_write(pchip, REG_BRT_B, bl->props.brightness); + if (bl->props.brightness < 0x4) + ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDB_ENABLE, 0); + else + ret |= lm3630a_update(pchip, REG_CTRL, + LM3630A_LEDB_ENABLE, LM3630A_LEDB_ENABLE); + if (ret < 0) + goto out_i2c_err; + return bl->props.brightness; + +out_i2c_err: + dev_err(pchip->dev, "i2c failed to access REG_CTRL\n"); + return bl->props.brightness; +} + +static int lm3630a_bank_b_get_brightness(struct backlight_device *bl) +{ + int brightness, rval; + struct lm3630a_chip *pchip = bl_get_data(bl); + enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; + + if ((pwm_ctrl & LM3630A_PWM_BANK_B) != 0) { + rval = lm3630a_read(pchip, REG_PWM_OUTHIGH); + if (rval < 0) + goto out_i2c_err; + brightness = (rval & 0x01) << 8; + rval = lm3630a_read(pchip, REG_PWM_OUTLOW); + if (rval < 0) + goto out_i2c_err; + brightness |= rval; + goto out; + } + + /* disable sleep */ + rval = lm3630a_update(pchip, REG_CTRL, 0x80, 0x00); + if (rval < 0) + goto out_i2c_err; + usleep_range(1000, 2000); + rval = lm3630a_read(pchip, REG_BRT_B); + if (rval < 0) + goto out_i2c_err; + brightness = rval; + +out: + bl->props.brightness = brightness; + return bl->props.brightness; +out_i2c_err: + dev_err(pchip->dev, "i2c failed to access register\n"); + return 0; +} + +static const struct backlight_ops lm3630a_bank_b_ops = { + .options = BL_CORE_SUSPENDRESUME, + .update_status = lm3630a_bank_b_update_status, + .get_brightness = lm3630a_bank_b_get_brightness, +}; + +static int lm3630a_backlight_register(struct lm3630a_chip *pchip) +{ + struct backlight_properties props; + struct lm3630a_platform_data *pdata = pchip->pdata; + + props.type = BACKLIGHT_RAW; + if (pdata->leda_ctrl != LM3630A_LEDA_DISABLE) { + props.brightness = pdata->leda_init_brt; + props.max_brightness = pdata->leda_max_brt; + pchip->bleda = + devm_backlight_device_register(pchip->dev, "lm3630a_leda", + pchip->dev, pchip, + &lm3630a_bank_a_ops, &props); + if (IS_ERR(pchip->bleda)) + return PTR_ERR(pchip->bleda); + } + + if ((pdata->ledb_ctrl != LM3630A_LEDB_DISABLE) && + (pdata->ledb_ctrl != LM3630A_LEDB_ON_A)) { + props.brightness = pdata->ledb_init_brt; + props.max_brightness = pdata->ledb_max_brt; + pchip->bledb = + devm_backlight_device_register(pchip->dev, "lm3630a_ledb", + pchip->dev, pchip, + &lm3630a_bank_b_ops, &props); + if (IS_ERR(pchip->bledb)) + return PTR_ERR(pchip->bledb); + } + return 0; +} + +static const struct regmap_config lm3630a_regmap = { + .reg_bits = 8, + .val_bits = 8, + .max_register = REG_MAX, +}; + +static int lm3630a_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct lm3630a_platform_data *pdata = client->dev.platform_data; + struct lm3630a_chip *pchip; + int rval; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + dev_err(&client->dev, "fail : i2c functionality check\n"); + return -EOPNOTSUPP; + } + + pchip = devm_kzalloc(&client->dev, sizeof(struct lm3630a_chip), + GFP_KERNEL); + if (!pchip) + return -ENOMEM; + pchip->dev = &client->dev; + + pchip->regmap = devm_regmap_init_i2c(client, &lm3630a_regmap); + if (IS_ERR(pchip->regmap)) { + rval = PTR_ERR(pchip->regmap); + dev_err(&client->dev, "fail : allocate reg. map: %d\n", rval); + return rval; + } + + i2c_set_clientdata(client, pchip); + if (pdata == NULL) { + pchip->pdata = devm_kzalloc(pchip->dev, + sizeof(struct + lm3630a_platform_data), + GFP_KERNEL); + if (pchip->pdata == NULL) + return -ENOMEM; + /* default values */ + pchip->pdata->leda_ctrl = LM3630A_LEDA_ENABLE; + pchip->pdata->ledb_ctrl = LM3630A_LEDB_ENABLE; + pchip->pdata->leda_max_brt = LM3630A_MAX_BRIGHTNESS; + pchip->pdata->ledb_max_brt = LM3630A_MAX_BRIGHTNESS; + pchip->pdata->leda_init_brt = LM3630A_MAX_BRIGHTNESS; + pchip->pdata->ledb_init_brt = LM3630A_MAX_BRIGHTNESS; + } else { + pchip->pdata = pdata; + } + /* chip initialize */ + rval = lm3630a_chip_init(pchip); + if (rval < 0) { + dev_err(&client->dev, "fail : init chip\n"); + return rval; + } + /* backlight register */ + rval = lm3630a_backlight_register(pchip); + if (rval < 0) { + dev_err(&client->dev, "fail : backlight register.\n"); + return rval; + } + /* pwm */ + if (pdata->pwm_ctrl != LM3630A_PWM_DISABLE) { + pchip->pwmd = devm_pwm_get(pchip->dev, "lm3630a-pwm"); + if (IS_ERR(pchip->pwmd)) { + dev_err(&client->dev, "fail : get pwm device\n"); + return PTR_ERR(pchip->pwmd); + } + } + pchip->pwmd->period = pdata->pwm_period; + + /* interrupt enable : irq 0 is not allowed */ + pchip->irq = client->irq; + if (pchip->irq) { + rval = lm3630a_intr_config(pchip); + if (rval < 0) + return rval; + } + dev_info(&client->dev, "LM3630A backlight register OK.\n"); + return 0; +} + +static int lm3630a_remove(struct i2c_client *client) +{ + int rval; + struct lm3630a_chip *pchip = i2c_get_clientdata(client); + + rval = lm3630a_write(pchip, REG_BRT_A, 0); + if (rval < 0) + dev_err(pchip->dev, "i2c failed to access register\n"); + + rval = lm3630a_write(pchip, REG_BRT_B, 0); + if (rval < 0) + dev_err(pchip->dev, "i2c failed to access register\n"); + + if (pchip->irq) { + free_irq(pchip->irq, pchip); + flush_workqueue(pchip->irqthread); + destroy_workqueue(pchip->irqthread); + } + return 0; +} + +static const struct i2c_device_id lm3630a_id[] = { + {LM3630A_NAME, 0}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, lm3630a_id); + +static struct i2c_driver lm3630a_i2c_driver = { + .driver = { + .name = LM3630A_NAME, + }, + .probe = lm3630a_probe, + .remove = lm3630a_remove, + .id_table = lm3630a_id, +}; + +module_i2c_driver(lm3630a_i2c_driver); + +MODULE_DESCRIPTION("Texas Instruments Backlight driver for LM3630A"); +MODULE_AUTHOR("Daniel Jeong "); +MODULE_AUTHOR("LDD MLP "); +MODULE_LICENSE("GPL v2"); -- cgit v1.1 From 2a0c316bf3ccd910dc58ec62465ff620c664b5e4 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 12 Nov 2013 15:08:59 -0800 Subject: drivers/video/backlight/lm3630a_bl.c: fix signedness bug in lm3630a_chip_init() "rval" needs to be signed for the error handling to work. Signed-off-by: Dan Carpenter Acked-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lm3630a_bl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index cf40cc8..200dca0 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -105,7 +105,7 @@ static int lm3630a_chip_init(struct lm3630a_chip *pchip) /* interrupt handling */ static void lm3630a_delayed_func(struct work_struct *work) { - unsigned int rval; + int rval; struct lm3630a_chip *pchip; pchip = container_of(work, struct lm3630a_chip, work.work); -- cgit v1.1 From e19493c1f29a3ac48db8797a79532b62a03442b8 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 12 Nov 2013 15:09:00 -0800 Subject: drivers/video/backlight/lm3630a_bl.c: potential NULL deref in probe() We dereference "pdata" later in the function so we can't leave it as NULL. Signed-off-by: Dan Carpenter Acked-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lm3630a_bl.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index 200dca0..d719a89 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -389,22 +389,21 @@ static int lm3630a_probe(struct i2c_client *client, i2c_set_clientdata(client, pchip); if (pdata == NULL) { - pchip->pdata = devm_kzalloc(pchip->dev, - sizeof(struct - lm3630a_platform_data), - GFP_KERNEL); - if (pchip->pdata == NULL) + pdata = devm_kzalloc(pchip->dev, + sizeof(struct lm3630a_platform_data), + GFP_KERNEL); + if (pdata == NULL) return -ENOMEM; /* default values */ - pchip->pdata->leda_ctrl = LM3630A_LEDA_ENABLE; - pchip->pdata->ledb_ctrl = LM3630A_LEDB_ENABLE; - pchip->pdata->leda_max_brt = LM3630A_MAX_BRIGHTNESS; - pchip->pdata->ledb_max_brt = LM3630A_MAX_BRIGHTNESS; - pchip->pdata->leda_init_brt = LM3630A_MAX_BRIGHTNESS; - pchip->pdata->ledb_init_brt = LM3630A_MAX_BRIGHTNESS; - } else { - pchip->pdata = pdata; + pdata->leda_ctrl = LM3630A_LEDA_ENABLE; + pdata->ledb_ctrl = LM3630A_LEDB_ENABLE; + pdata->leda_max_brt = LM3630A_MAX_BRIGHTNESS; + pdata->ledb_max_brt = LM3630A_MAX_BRIGHTNESS; + pdata->leda_init_brt = LM3630A_MAX_BRIGHTNESS; + pdata->ledb_init_brt = LM3630A_MAX_BRIGHTNESS; } + pchip->pdata = pdata; + /* chip initialize */ rval = lm3630a_chip_init(pchip); if (rval < 0) { -- cgit v1.1 From 4c4d2a3a064c893324ad3daca5c097dc7f06bbe3 Mon Sep 17 00:00:00 2001 From: Daniel Jeong Date: Tue, 12 Nov 2013 15:09:01 -0800 Subject: backlight: lm3630: fix sparse warning This patch is to fix sparse warning due to mixing different enum type. Signed-off-by: Daniel Jeong Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lm3630a_bl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index d719a89..1128a02 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -90,8 +90,8 @@ static int lm3630a_chip_init(struct lm3630a_chip *pchip) /* set current B */ rval |= lm3630a_write(pchip, REG_I_B, 0x1F); /* set control */ - rval |= - lm3630a_write(pchip, REG_CTRL, pdata->leda_ctrl | pdata->ledb_ctrl); + rval |= lm3630a_update(pchip, REG_CTRL, 0x14, pdata->leda_ctrl); + rval |= lm3630a_update(pchip, REG_CTRL, 0x0B, pdata->ledb_ctrl); usleep_range(1000, 2000); /* set brightness A and B */ rval |= lm3630a_write(pchip, REG_BRT_A, pdata->leda_init_brt); -- cgit v1.1 From 86b15d5d3bae0b4a64bd2bf834fc1d876285dbf0 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:01 -0800 Subject: backlight: ld9040: Staticize local variable gamma_table Fix the following sparse warnings: drivers/video/backlight/ld9040_gamma.h:172:3: warning: symbol 'gamma_table' was not declared. Should it be static? Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/ld9040_gamma.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/video/backlight/ld9040_gamma.h b/drivers/video/backlight/ld9040_gamma.h index 038d9c8..c5e586d 100644 --- a/drivers/video/backlight/ld9040_gamma.h +++ b/drivers/video/backlight/ld9040_gamma.h @@ -169,7 +169,9 @@ static const unsigned int ld9040_22_50[] = { struct ld9040_gamma { unsigned int *gamma_22_table[MAX_GAMMA_LEVEL]; -} gamma_table = { +}; + +static struct ld9040_gamma gamma_table = { .gamma_22_table[0] = (unsigned int *)&ld9040_22_50, .gamma_22_table[1] = (unsigned int *)&ld9040_22_70, .gamma_22_table[2] = (unsigned int *)&ld9040_22_80, -- cgit v1.1 From 0ab7b20fa011f25f900b04e8f6f6e8221864eefd Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:02 -0800 Subject: backlight: lm3639: don't mix different enum types Don't mix different enum types to fix the sparse warnings. drivers/video/backlight/lm3639_bl.c:80:51: warning: mixing different enum types drivers/video/backlight/lm3639_bl.c:80:51: int enum lm3639_fleds versus drivers/video/backlight/lm3639_bl.c:80:51: int enum lm3639_bleds drivers/video/backlight/lm3639_bl.c:82:51: warning: mixing different enum types drivers/video/backlight/lm3639_bl.c:82:51: int enum lm3639_fleds versus drivers/video/backlight/lm3639_bl.c:82:51: int enum lm3639_bleds Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lm3639_bl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/lm3639_bl.c b/drivers/video/backlight/lm3639_bl.c index 053964d..6c888e3 100644 --- a/drivers/video/backlight/lm3639_bl.c +++ b/drivers/video/backlight/lm3639_bl.c @@ -76,10 +76,13 @@ static int lm3639_chip_init(struct lm3639_chip_data *pchip) goto out; /* output pins config. */ - if (!pdata->init_brt_led) - reg_val = pdata->fled_pins | pdata->bled_pins; - else - reg_val = pdata->fled_pins | pdata->bled_pins | 0x01; + if (!pdata->init_brt_led) { + reg_val = pdata->fled_pins; + reg_val |= pdata->bled_pins; + } else { + reg_val = pdata->fled_pins; + reg_val |= pdata->bled_pins | 0x01; + } ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x79, reg_val); if (ret < 0) -- cgit v1.1 From 1f299997b460d08356006945345a8962f7ecd719 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:03 -0800 Subject: backlight: lp8788: staticize 'default_bl_config' Fix the following sparse warning: drivers/video/backlight/lp8788_bl.c:55:25: warning: symbol 'default_bl_config' was not declared. Should it be static? Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lp8788_bl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/video/backlight/lp8788_bl.c b/drivers/video/backlight/lp8788_bl.c index 980855e..e49905d 100644 --- a/drivers/video/backlight/lp8788_bl.c +++ b/drivers/video/backlight/lp8788_bl.c @@ -52,7 +52,7 @@ struct lp8788_bl { struct pwm_device *pwm; }; -struct lp8788_bl_config default_bl_config = { +static struct lp8788_bl_config default_bl_config = { .bl_mode = LP8788_BL_REGISTER_ONLY, .dim_mode = LP8788_DIM_EXPONENTIAL, .full_scale = LP8788_FULLSCALE_1900uA, -- cgit v1.1 From c512794cada491e008eeca822af7e4ad5db72a56 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:04 -0800 Subject: backlight: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/88pm860x_bl.c | 2 +- drivers/video/backlight/aat2870_bl.c | 2 +- drivers/video/backlight/adp5520_bl.c | 2 +- drivers/video/backlight/adp8860_bl.c | 6 +++--- drivers/video/backlight/adp8870_bl.c | 6 +++--- drivers/video/backlight/ams369fg06.c | 2 +- drivers/video/backlight/atmel-pwm-bl.c | 2 +- drivers/video/backlight/bd6107.c | 2 +- drivers/video/backlight/corgi_lcd.c | 2 +- drivers/video/backlight/da903x_bl.c | 2 +- drivers/video/backlight/generic_bl.c | 2 +- drivers/video/backlight/gpio_backlight.c | 3 ++- drivers/video/backlight/ili9320.c | 2 +- drivers/video/backlight/kb3886_bl.c | 2 +- drivers/video/backlight/l4f00242t03.c | 6 +++--- drivers/video/backlight/ld9040.c | 2 +- drivers/video/backlight/lm3533_bl.c | 2 +- drivers/video/backlight/lm3630a_bl.c | 2 +- drivers/video/backlight/lm3639_bl.c | 2 +- drivers/video/backlight/lms283gf05.c | 4 ++-- drivers/video/backlight/lms501kf03.c | 2 +- drivers/video/backlight/lp855x_bl.c | 4 ++-- drivers/video/backlight/lv5207lp.c | 2 +- drivers/video/backlight/omap1_bl.c | 2 +- drivers/video/backlight/pcf50633-backlight.c | 2 +- drivers/video/backlight/platform_lcd.c | 2 +- drivers/video/backlight/pwm_bl.c | 2 +- drivers/video/backlight/s6e63m0.c | 2 +- drivers/video/backlight/tdo24m.c | 2 +- drivers/video/backlight/tosa_bl.c | 2 +- drivers/video/backlight/tps65217_bl.c | 5 ++--- drivers/video/backlight/wm831x_bl.c | 8 +++----- 32 files changed, 44 insertions(+), 46 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c index 2cd6350..a84a12a6 100644 --- a/drivers/video/backlight/88pm860x_bl.c +++ b/drivers/video/backlight/88pm860x_bl.c @@ -196,7 +196,7 @@ static int pm860x_backlight_dt_init(struct platform_device *pdev, static int pm860x_backlight_probe(struct platform_device *pdev) { struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); - struct pm860x_backlight_pdata *pdata = pdev->dev.platform_data; + struct pm860x_backlight_pdata *pdata = dev_get_platdata(&pdev->dev); struct pm860x_backlight_data *data; struct backlight_device *bl; struct resource *res; diff --git a/drivers/video/backlight/aat2870_bl.c b/drivers/video/backlight/aat2870_bl.c index c6fc668..c68232b 100644 --- a/drivers/video/backlight/aat2870_bl.c +++ b/drivers/video/backlight/aat2870_bl.c @@ -127,7 +127,7 @@ static const struct backlight_ops aat2870_bl_ops = { static int aat2870_bl_probe(struct platform_device *pdev) { - struct aat2870_bl_platform_data *pdata = pdev->dev.platform_data; + struct aat2870_bl_platform_data *pdata = dev_get_platdata(&pdev->dev); struct aat2870_bl_driver_data *aat2870_bl; struct backlight_device *bd; struct backlight_properties props; diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c index c84701b..fe8e3d1 100644 --- a/drivers/video/backlight/adp5520_bl.c +++ b/drivers/video/backlight/adp5520_bl.c @@ -297,7 +297,7 @@ static int adp5520_bl_probe(struct platform_device *pdev) return -ENOMEM; data->master = pdev->dev.parent; - data->pdata = pdev->dev.platform_data; + data->pdata = dev_get_platdata(&pdev->dev); if (data->pdata == NULL) { dev_err(&pdev->dev, "missing platform data\n"); diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index 75b10f8..2f77f37 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c @@ -216,7 +216,7 @@ static int adp8860_led_setup(struct adp8860_led *led) static int adp8860_led_probe(struct i2c_client *client) { struct adp8860_backlight_platform_data *pdata = - client->dev.platform_data; + dev_get_platdata(&client->dev); struct adp8860_bl *data = i2c_get_clientdata(client); struct adp8860_led *led, *led_dat; struct led_info *cur_led; @@ -300,7 +300,7 @@ static int adp8860_led_probe(struct i2c_client *client) static int adp8860_led_remove(struct i2c_client *client) { struct adp8860_backlight_platform_data *pdata = - client->dev.platform_data; + dev_get_platdata(&client->dev); struct adp8860_bl *data = i2c_get_clientdata(client); int i; @@ -658,7 +658,7 @@ static int adp8860_probe(struct i2c_client *client, struct backlight_device *bl; struct adp8860_bl *data; struct adp8860_backlight_platform_data *pdata = - client->dev.platform_data; + dev_get_platdata(&client->dev); struct backlight_properties props; uint8_t reg_val; int ret; diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 90049d7..9eee69f 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c @@ -238,7 +238,7 @@ static int adp8870_led_setup(struct adp8870_led *led) static int adp8870_led_probe(struct i2c_client *client) { struct adp8870_backlight_platform_data *pdata = - client->dev.platform_data; + dev_get_platdata(&client->dev); struct adp8870_bl *data = i2c_get_clientdata(client); struct adp8870_led *led, *led_dat; struct led_info *cur_led; @@ -325,7 +325,7 @@ static int adp8870_led_probe(struct i2c_client *client) static int adp8870_led_remove(struct i2c_client *client) { struct adp8870_backlight_platform_data *pdata = - client->dev.platform_data; + dev_get_platdata(&client->dev); struct adp8870_bl *data = i2c_get_clientdata(client); int i; @@ -848,7 +848,7 @@ static int adp8870_probe(struct i2c_client *client, struct backlight_device *bl; struct adp8870_bl *data; struct adp8870_backlight_platform_data *pdata = - client->dev.platform_data; + dev_get_platdata(&client->dev); uint8_t reg_val; int ret; diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c index 319fef6..df5507b 100644 --- a/drivers/video/backlight/ams369fg06.c +++ b/drivers/video/backlight/ams369fg06.c @@ -471,7 +471,7 @@ static int ams369fg06_probe(struct spi_device *spi) lcd->spi = spi; lcd->dev = &spi->dev; - lcd->lcd_pd = spi->dev.platform_data; + lcd->lcd_pd = dev_get_platdata(&spi->dev); if (!lcd->lcd_pd) { dev_err(&spi->dev, "platform data is NULL\n"); return -EINVAL; diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index f7447f7..c11121e 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -133,7 +133,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) pwmbl->pdev = pdev; - pdata = pdev->dev.platform_data; + pdata = dev_get_platdata(&pdev->dev); if (!pdata) { retval = -ENODEV; goto err_free_mem; diff --git a/drivers/video/backlight/bd6107.c b/drivers/video/backlight/bd6107.c index 15e3294..43c434e 100644 --- a/drivers/video/backlight/bd6107.c +++ b/drivers/video/backlight/bd6107.c @@ -128,7 +128,7 @@ static const struct backlight_ops bd6107_backlight_ops = { static int bd6107_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct bd6107_platform_data *pdata = client->dev.platform_data; + struct bd6107_platform_data *pdata = dev_get_platdata(&client->dev); struct backlight_device *backlight; struct backlight_properties props; struct bd6107 *bd; diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c index c97867a..be56cfe 100644 --- a/drivers/video/backlight/corgi_lcd.c +++ b/drivers/video/backlight/corgi_lcd.c @@ -533,7 +533,7 @@ static int setup_gpio_backlight(struct corgi_lcd *lcd, static int corgi_lcd_probe(struct spi_device *spi) { struct backlight_properties props; - struct corgi_lcd_platform_data *pdata = spi->dev.platform_data; + struct corgi_lcd_platform_data *pdata = dev_get_platdata(&spi->dev); struct corgi_lcd *lcd; int ret = 0; diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c index 67cadd3..bbad5c2 100644 --- a/drivers/video/backlight/da903x_bl.c +++ b/drivers/video/backlight/da903x_bl.c @@ -109,7 +109,7 @@ static const struct backlight_ops da903x_backlight_ops = { static int da903x_backlight_probe(struct platform_device *pdev) { - struct da9034_backlight_pdata *pdata = pdev->dev.platform_data; + struct da9034_backlight_pdata *pdata = dev_get_platdata(&pdev->dev); struct da903x_backlight_data *data; struct backlight_device *bl; struct backlight_properties props; diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c index 19e393b..48fa914 100644 --- a/drivers/video/backlight/generic_bl.c +++ b/drivers/video/backlight/generic_bl.c @@ -79,7 +79,7 @@ static const struct backlight_ops genericbl_ops = { static int genericbl_probe(struct platform_device *pdev) { struct backlight_properties props; - struct generic_bl_info *machinfo = pdev->dev.platform_data; + struct generic_bl_info *machinfo = dev_get_platdata(&pdev->dev); const char *name = "generic-bl"; struct backlight_device *bd; diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index 5fa217f..118da0c 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -62,7 +62,8 @@ static const struct backlight_ops gpio_backlight_ops = { static int gpio_backlight_probe(struct platform_device *pdev) { - struct gpio_backlight_platform_data *pdata = pdev->dev.platform_data; + struct gpio_backlight_platform_data *pdata = + dev_get_platdata(&pdev->dev); struct backlight_properties props; struct backlight_device *bl; struct gpio_backlight *gbl; diff --git a/drivers/video/backlight/ili9320.c b/drivers/video/backlight/ili9320.c index f8be90c..4dd43e0 100644 --- a/drivers/video/backlight/ili9320.c +++ b/drivers/video/backlight/ili9320.c @@ -198,7 +198,7 @@ static void ili9320_setup_spi(struct ili9320 *ili, int ili9320_probe_spi(struct spi_device *spi, struct ili9320_client *client) { - struct ili9320_platdata *cfg = spi->dev.platform_data; + struct ili9320_platdata *cfg = dev_get_platdata(&spi->dev); struct device *dev = &spi->dev; struct ili9320 *ili; struct lcd_device *lcd; diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c index bca6ccc..5bacabb 100644 --- a/drivers/video/backlight/kb3886_bl.c +++ b/drivers/video/backlight/kb3886_bl.c @@ -141,7 +141,7 @@ static const struct backlight_ops kb3886bl_ops = { static int kb3886bl_probe(struct platform_device *pdev) { struct backlight_properties props; - struct kb3886bl_machinfo *machinfo = pdev->dev.platform_data; + struct kb3886bl_machinfo *machinfo = dev_get_platdata(&pdev->dev); bl_machinfo = machinfo; if (!machinfo->limit_mask) diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c index a35a38c..923eae2 100644 --- a/drivers/video/backlight/l4f00242t03.c +++ b/drivers/video/backlight/l4f00242t03.c @@ -48,7 +48,7 @@ static void l4f00242t03_reset(unsigned int gpio) static void l4f00242t03_lcd_init(struct spi_device *spi) { - struct l4f00242t03_pdata *pdata = spi->dev.platform_data; + struct l4f00242t03_pdata *pdata = dev_get_platdata(&spi->dev); struct l4f00242t03_priv *priv = spi_get_drvdata(spi); const u16 cmd[] = { 0x36, param(0), 0x3A, param(0x60) }; int ret; @@ -88,7 +88,7 @@ static void l4f00242t03_lcd_init(struct spi_device *spi) static void l4f00242t03_lcd_powerdown(struct spi_device *spi) { - struct l4f00242t03_pdata *pdata = spi->dev.platform_data; + struct l4f00242t03_pdata *pdata = dev_get_platdata(&spi->dev); struct l4f00242t03_priv *priv = spi_get_drvdata(spi); dev_dbg(&spi->dev, "Powering down LCD\n"); @@ -171,7 +171,7 @@ static struct lcd_ops l4f_ops = { static int l4f00242t03_probe(struct spi_device *spi) { struct l4f00242t03_priv *priv; - struct l4f00242t03_pdata *pdata = spi->dev.platform_data; + struct l4f00242t03_pdata *pdata = dev_get_platdata(&spi->dev); int ret; if (pdata == NULL) { diff --git a/drivers/video/backlight/ld9040.c b/drivers/video/backlight/ld9040.c index 1e0a309..26d5139 100644 --- a/drivers/video/backlight/ld9040.c +++ b/drivers/video/backlight/ld9040.c @@ -702,7 +702,7 @@ static int ld9040_probe(struct spi_device *spi) lcd->spi = spi; lcd->dev = &spi->dev; - lcd->lcd_pd = spi->dev.platform_data; + lcd->lcd_pd = dev_get_platdata(&spi->dev); if (!lcd->lcd_pd) { dev_err(&spi->dev, "platform data is NULL.\n"); return -EINVAL; diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c index 1d1dbfb..93eea65 100644 --- a/drivers/video/backlight/lm3533_bl.c +++ b/drivers/video/backlight/lm3533_bl.c @@ -284,7 +284,7 @@ static int lm3533_bl_probe(struct platform_device *pdev) if (!lm3533) return -EINVAL; - pdata = pdev->dev.platform_data; + pdata = dev_get_platdata(&pdev->dev); if (!pdata) { dev_err(&pdev->dev, "no platform data\n"); return -EINVAL; diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index 1128a02..999075a 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -365,7 +365,7 @@ static const struct regmap_config lm3630a_regmap = { static int lm3630a_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct lm3630a_platform_data *pdata = client->dev.platform_data; + struct lm3630a_platform_data *pdata = dev_get_platdata(&client->dev); struct lm3630a_chip *pchip; int rval; diff --git a/drivers/video/backlight/lm3639_bl.c b/drivers/video/backlight/lm3639_bl.c index 6c888e3..6fd60ad 100644 --- a/drivers/video/backlight/lm3639_bl.c +++ b/drivers/video/backlight/lm3639_bl.c @@ -307,7 +307,7 @@ static int lm3639_probe(struct i2c_client *client, { int ret; struct lm3639_chip_data *pchip; - struct lm3639_platform_data *pdata = client->dev.platform_data; + struct lm3639_platform_data *pdata = dev_get_platdata(&client->dev); struct backlight_properties props; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c index 4eec472..80b5929 100644 --- a/drivers/video/backlight/lms283gf05.c +++ b/drivers/video/backlight/lms283gf05.c @@ -128,7 +128,7 @@ static int lms283gf05_power_set(struct lcd_device *ld, int power) { struct lms283gf05_state *st = lcd_get_data(ld); struct spi_device *spi = st->spi; - struct lms283gf05_pdata *pdata = spi->dev.platform_data; + struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev); if (power <= FB_BLANK_NORMAL) { if (pdata) @@ -153,7 +153,7 @@ static struct lcd_ops lms_ops = { static int lms283gf05_probe(struct spi_device *spi) { struct lms283gf05_state *st; - struct lms283gf05_pdata *pdata = spi->dev.platform_data; + struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev); struct lcd_device *ld; int ret = 0; diff --git a/drivers/video/backlight/lms501kf03.c b/drivers/video/backlight/lms501kf03.c index cf01b9a..ff46e19 100644 --- a/drivers/video/backlight/lms501kf03.c +++ b/drivers/video/backlight/lms501kf03.c @@ -344,7 +344,7 @@ static int lms501kf03_probe(struct spi_device *spi) lcd->spi = spi; lcd->dev = &spi->dev; - lcd->lcd_pd = spi->dev.platform_data; + lcd->lcd_pd = dev_get_platdata(&spi->dev); if (!lcd->lcd_pd) { dev_err(&spi->dev, "platform data is NULL\n"); return -EINVAL; diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index c952175..57f005a 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -405,7 +405,7 @@ static int lp855x_parse_dt(struct device *dev, struct device_node *node) static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) { struct lp855x *lp; - struct lp855x_platform_data *pdata = cl->dev.platform_data; + struct lp855x_platform_data *pdata = dev_get_platdata(&cl->dev); struct device_node *node = cl->dev.of_node; int ret; @@ -414,7 +414,7 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) if (ret < 0) return ret; - pdata = cl->dev.platform_data; + pdata = dev_get_platdata(&cl->dev); } if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) diff --git a/drivers/video/backlight/lv5207lp.c b/drivers/video/backlight/lv5207lp.c index 498fd73..8091a28 100644 --- a/drivers/video/backlight/lv5207lp.c +++ b/drivers/video/backlight/lv5207lp.c @@ -93,7 +93,7 @@ static const struct backlight_ops lv5207lp_backlight_ops = { static int lv5207lp_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct lv5207lp_platform_data *pdata = client->dev.platform_data; + struct lv5207lp_platform_data *pdata = dev_get_platdata(&client->dev); struct backlight_device *backlight; struct backlight_properties props; struct lv5207lp *lv; diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c index 812e22e..ac11a46 100644 --- a/drivers/video/backlight/omap1_bl.c +++ b/drivers/video/backlight/omap1_bl.c @@ -133,7 +133,7 @@ static int omapbl_probe(struct platform_device *pdev) struct backlight_properties props; struct backlight_device *dev; struct omap_backlight *bl; - struct omap_backlight_config *pdata = pdev->dev.platform_data; + struct omap_backlight_config *pdata = dev_get_platdata(&pdev->dev); if (!pdata) return -ENXIO; diff --git a/drivers/video/backlight/pcf50633-backlight.c b/drivers/video/backlight/pcf50633-backlight.c index 6ed76be..b2184cf 100644 --- a/drivers/video/backlight/pcf50633-backlight.c +++ b/drivers/video/backlight/pcf50633-backlight.c @@ -103,7 +103,7 @@ static int pcf50633_bl_probe(struct platform_device *pdev) { struct pcf50633_bl *pcf_bl; struct device *parent = pdev->dev.parent; - struct pcf50633_platform_data *pcf50633_data = parent->platform_data; + struct pcf50633_platform_data *pcf50633_data = dev_get_platdata(parent); struct pcf50633_bl_platform_data *pdata = pcf50633_data->backlight_data; struct backlight_properties bl_props; diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c index 0568367..cc0f067 100644 --- a/drivers/video/backlight/platform_lcd.c +++ b/drivers/video/backlight/platform_lcd.c @@ -80,7 +80,7 @@ static int platform_lcd_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int err; - pdata = pdev->dev.platform_data; + pdata = dev_get_platdata(&pdev->dev); if (!pdata) { dev_err(dev, "no platform data supplied\n"); return -EINVAL; diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 1fea627..36db5d9 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -163,7 +163,7 @@ static int pwm_backlight_parse_dt(struct device *dev, static int pwm_backlight_probe(struct platform_device *pdev) { - struct platform_pwm_backlight_data *data = pdev->dev.platform_data; + struct platform_pwm_backlight_data *data = dev_get_platdata(&pdev->dev); struct platform_pwm_backlight_data defdata; struct backlight_properties props; struct backlight_device *bl; diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c index b37bb18..4e339ad 100644 --- a/drivers/video/backlight/s6e63m0.c +++ b/drivers/video/backlight/s6e63m0.c @@ -735,7 +735,7 @@ static int s6e63m0_probe(struct spi_device *spi) lcd->spi = spi; lcd->dev = &spi->dev; - lcd->lcd_pd = spi->dev.platform_data; + lcd->lcd_pd = dev_get_platdata(&spi->dev); if (!lcd->lcd_pd) { dev_err(&spi->dev, "platform data is NULL.\n"); return -EINVAL; diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c index 18cdf46..2ccfa46 100644 --- a/drivers/video/backlight/tdo24m.c +++ b/drivers/video/backlight/tdo24m.c @@ -338,7 +338,7 @@ static int tdo24m_probe(struct spi_device *spi) enum tdo24m_model model; int err; - pdata = spi->dev.platform_data; + pdata = dev_get_platdata(&spi->dev); if (pdata) model = pdata->model; else diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c index 9df66ac..b8db933 100644 --- a/drivers/video/backlight/tosa_bl.c +++ b/drivers/video/backlight/tosa_bl.c @@ -38,7 +38,7 @@ struct tosa_bl_data { static void tosa_bl_set_backlight(struct tosa_bl_data *data, int brightness) { - struct spi_device *spi = data->i2c->dev.platform_data; + struct spi_device *spi = dev_get_platdata(&data->i2c->dev); i2c_smbus_write_byte_data(data->i2c, DAC_CH1, data->comadj); diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c index 0578231..4ea2039 100644 --- a/drivers/video/backlight/tps65217_bl.c +++ b/drivers/video/backlight/tps65217_bl.c @@ -287,12 +287,11 @@ static int tps65217_bl_probe(struct platform_device *pdev) if (IS_ERR(pdata)) return PTR_ERR(pdata); } else { - if (!pdev->dev.platform_data) { + pdata = dev_get_platdata(&pdev->dev); + if (!pdata) { dev_err(&pdev->dev, "no platform data provided\n"); return -EINVAL; } - - pdata = pdev->dev.platform_data; } tps65217_bl = devm_kzalloc(&pdev->dev, sizeof(*tps65217_bl), diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c index 9e5517a..2ccf320 100644 --- a/drivers/video/backlight/wm831x_bl.c +++ b/drivers/video/backlight/wm831x_bl.c @@ -123,7 +123,7 @@ static const struct backlight_ops wm831x_backlight_ops = { static int wm831x_backlight_probe(struct platform_device *pdev) { struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); - struct wm831x_pdata *wm831x_pdata; + struct wm831x_pdata *wm831x_pdata = dev_get_platdata(pdev->dev.parent); struct wm831x_backlight_pdata *pdata; struct wm831x_backlight_data *data; struct backlight_device *bl; @@ -131,12 +131,10 @@ static int wm831x_backlight_probe(struct platform_device *pdev) int ret, i, max_isel, isink_reg, dcdc_cfg; /* We need platform data */ - if (pdev->dev.parent->platform_data) { - wm831x_pdata = pdev->dev.parent->platform_data; + if (wm831x_pdata) pdata = wm831x_pdata->backlight; - } else { + else pdata = NULL; - } if (!pdata) { dev_err(&pdev->dev, "No platform data supplied\n"); -- cgit v1.1 From f829c9ef826a4247ac2e6017632be266df0b13ae Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:05 -0800 Subject: backlight: 88pm860x_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/88pm860x_bl.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c index a84a12a6..7db5234 100644 --- a/drivers/video/backlight/88pm860x_bl.c +++ b/drivers/video/backlight/88pm860x_bl.c @@ -243,7 +243,7 @@ static int pm860x_backlight_probe(struct platform_device *pdev) memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = MAX_BRIGHTNESS; - bl = backlight_device_register(name, &pdev->dev, data, + bl = devm_backlight_device_register(&pdev->dev, name, &pdev->dev, data, &pm860x_backlight_ops, &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); @@ -256,21 +256,10 @@ static int pm860x_backlight_probe(struct platform_device *pdev) /* read current backlight */ ret = pm860x_backlight_get_brightness(bl); if (ret < 0) - goto out_brt; + return ret; backlight_update_status(bl); return 0; -out_brt: - backlight_device_unregister(bl); - return ret; -} - -static int pm860x_backlight_remove(struct platform_device *pdev) -{ - struct backlight_device *bl = platform_get_drvdata(pdev); - - backlight_device_unregister(bl); - return 0; } static struct platform_driver pm860x_backlight_driver = { @@ -279,7 +268,6 @@ static struct platform_driver pm860x_backlight_driver = { .owner = THIS_MODULE, }, .probe = pm860x_backlight_probe, - .remove = pm860x_backlight_remove, }; module_platform_driver(pm860x_backlight_driver); -- cgit v1.1 From c7a2bf3b217869f277c5cce229e482ef3bf5ad16 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:06 -0800 Subject: backlight: aat2870: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/aat2870_bl.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/aat2870_bl.c b/drivers/video/backlight/aat2870_bl.c index c68232b..ee0c0a9 100644 --- a/drivers/video/backlight/aat2870_bl.c +++ b/drivers/video/backlight/aat2870_bl.c @@ -158,8 +158,9 @@ static int aat2870_bl_probe(struct platform_device *pdev) memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; - bd = backlight_device_register("aat2870-backlight", &pdev->dev, - aat2870_bl, &aat2870_bl_ops, &props); + bd = devm_backlight_device_register(&pdev->dev, "aat2870-backlight", + &pdev->dev, aat2870_bl, &aat2870_bl_ops, + &props); if (IS_ERR(bd)) { dev_err(&pdev->dev, "Failed allocate memory for backlight device\n"); @@ -194,13 +195,11 @@ static int aat2870_bl_probe(struct platform_device *pdev) ret = aat2870_bl_update_status(bd); if (ret < 0) { dev_err(&pdev->dev, "Failed to initialize\n"); - goto out_bl_dev_unregister; + return ret; } return 0; -out_bl_dev_unregister: - backlight_device_unregister(bd); out: return ret; } @@ -214,8 +213,6 @@ static int aat2870_bl_remove(struct platform_device *pdev) bd->props.brightness = 0; backlight_update_status(bd); - backlight_device_unregister(bd); - return 0; } -- cgit v1.1 From 5f652c710d0aa7a4b97b4a55a2d035187eb0efcf Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:07 -0800 Subject: backlight: adp5520: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/adp5520_bl.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c index fe8e3d1..f37097a 100644 --- a/drivers/video/backlight/adp5520_bl.c +++ b/drivers/video/backlight/adp5520_bl.c @@ -312,8 +312,9 @@ static int adp5520_bl_probe(struct platform_device *pdev) memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = ADP5020_MAX_BRIGHTNESS; - bl = backlight_device_register(pdev->name, data->master, data, - &adp5520_bl_ops, &props); + bl = devm_backlight_device_register(&pdev->dev, pdev->name, + data->master, data, &adp5520_bl_ops, + &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); return PTR_ERR(bl); @@ -326,7 +327,7 @@ static int adp5520_bl_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "failed to register sysfs\n"); - backlight_device_unregister(bl); + return ret; } platform_set_drvdata(pdev, bl); @@ -347,8 +348,6 @@ static int adp5520_bl_remove(struct platform_device *pdev) sysfs_remove_group(&bl->dev.kobj, &adp5520_bl_attr_group); - backlight_device_unregister(bl); - return 0; } -- cgit v1.1 From 91fa4ee8f4c77e7ab87a42d795d6589ef3478094 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:08 -0800 Subject: backlight: adp8860: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/adp8860_bl.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index 2f77f37..9d65671 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c @@ -711,8 +711,9 @@ static int adp8860_probe(struct i2c_client *client, mutex_init(&data->lock); - bl = backlight_device_register(dev_driver_string(&client->dev), - &client->dev, data, &adp8860_bl_ops, &props); + bl = devm_backlight_device_register(&client->dev, + dev_driver_string(&client->dev), + &client->dev, data, &adp8860_bl_ops, &props); if (IS_ERR(bl)) { dev_err(&client->dev, "failed to register backlight\n"); return PTR_ERR(bl); @@ -728,7 +729,7 @@ static int adp8860_probe(struct i2c_client *client, if (ret) { dev_err(&client->dev, "failed to register sysfs\n"); - goto out1; + return ret; } ret = adp8860_bl_setup(bl); @@ -751,8 +752,6 @@ out: if (data->en_ambl_sens) sysfs_remove_group(&data->bl->dev.kobj, &adp8860_bl_attr_group); -out1: - backlight_device_unregister(bl); return ret; } @@ -770,8 +769,6 @@ static int adp8860_remove(struct i2c_client *client) sysfs_remove_group(&data->bl->dev.kobj, &adp8860_bl_attr_group); - backlight_device_unregister(data->bl); - return 0; } -- cgit v1.1 From 568ee6c3c852610a3951da31519aa28cc9f1927e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:09 -0800 Subject: backlight: adp8870: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/adp8870_bl.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 9eee69f..6370720 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c @@ -888,8 +888,9 @@ static int adp8870_probe(struct i2c_client *client, memset(&props, 0, sizeof(props)); props.type = BACKLIGHT_RAW; props.max_brightness = props.brightness = ADP8870_MAX_BRIGHTNESS; - bl = backlight_device_register(dev_driver_string(&client->dev), - &client->dev, data, &adp8870_bl_ops, &props); + bl = devm_backlight_device_register(&client->dev, + dev_driver_string(&client->dev), + &client->dev, data, &adp8870_bl_ops, &props); if (IS_ERR(bl)) { dev_err(&client->dev, "failed to register backlight\n"); return PTR_ERR(bl); @@ -902,7 +903,7 @@ static int adp8870_probe(struct i2c_client *client, &adp8870_bl_attr_group); if (ret) { dev_err(&client->dev, "failed to register sysfs\n"); - goto out1; + return ret; } } @@ -925,8 +926,6 @@ out: if (data->pdata->en_ambl_sens) sysfs_remove_group(&data->bl->dev.kobj, &adp8870_bl_attr_group); -out1: - backlight_device_unregister(bl); return ret; } @@ -944,8 +943,6 @@ static int adp8870_remove(struct i2c_client *client) sysfs_remove_group(&data->bl->dev.kobj, &adp8870_bl_attr_group); - backlight_device_unregister(data->bl); - return 0; } -- cgit v1.1 From 83dedc056b61bcfc693d1085b76aa32cc242db6f Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:10 -0800 Subject: backlight: as3711_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/as3711_bl.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c index 123887cd..bb1fc45 100644 --- a/drivers/video/backlight/as3711_bl.c +++ b/drivers/video/backlight/as3711_bl.c @@ -240,7 +240,8 @@ static int as3711_bl_register(struct platform_device *pdev, /* max tuning I = 31uA for voltage- and 38250uA for current-feedback */ props.max_brightness = max_brightness; - bl = backlight_device_register(su->type == AS3711_BL_SU1 ? + bl = devm_backlight_device_register(&pdev->dev, + su->type == AS3711_BL_SU1 ? "as3711-su1" : "as3711-su2", &pdev->dev, su, &as3711_bl_ops, &props); @@ -432,8 +433,7 @@ static int as3711_backlight_probe(struct platform_device *pdev) case AS3711_SU2_LX_SD4: break; default: - ret = -EINVAL; - goto esu2; + return -EINVAL; } switch (pdata->su2_feedback) { @@ -447,8 +447,7 @@ static int as3711_backlight_probe(struct platform_device *pdev) max_brightness = min(pdata->su2_max_uA / 150, 255); break; default: - ret = -EINVAL; - goto esu2; + return -EINVAL; } ret = as3711_bl_init_su2(supply); @@ -457,26 +456,12 @@ static int as3711_backlight_probe(struct platform_device *pdev) ret = as3711_bl_register(pdev, max_brightness, su); if (ret < 0) - goto esu2; + return ret; } platform_set_drvdata(pdev, supply); return 0; - -esu2: - backlight_device_unregister(supply->su1.bl); - return ret; -} - -static int as3711_backlight_remove(struct platform_device *pdev) -{ - struct as3711_bl_supply *supply = platform_get_drvdata(pdev); - - backlight_device_unregister(supply->su1.bl); - backlight_device_unregister(supply->su2.bl); - - return 0; } static struct platform_driver as3711_backlight_driver = { @@ -485,7 +470,6 @@ static struct platform_driver as3711_backlight_driver = { .owner = THIS_MODULE, }, .probe = as3711_backlight_probe, - .remove = as3711_backlight_remove, }; module_platform_driver(as3711_backlight_driver); -- cgit v1.1 From 3e61c73c52443b98a587a0db70a7ebf417de34f6 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:11 -0800 Subject: backlight: atmel-pwm-bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/atmel-pwm-bl.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index c11121e..66885fb 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -171,8 +171,9 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min; - bldev = backlight_device_register("atmel-pwm-bl", &pdev->dev, pwmbl, - &atmel_pwm_bl_ops, &props); + bldev = devm_backlight_device_register(&pdev->dev, "atmel-pwm-bl", + &pdev->dev, pwmbl, &atmel_pwm_bl_ops, + &props); if (IS_ERR(bldev)) { retval = PTR_ERR(bldev); goto err_free_pwm; @@ -188,14 +189,12 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) retval = atmel_pwm_bl_init_pwm(pwmbl); if (retval) - goto err_free_bl_dev; + goto err_free_pwm; atmel_pwm_bl_set_intensity(bldev); return 0; -err_free_bl_dev: - backlight_device_unregister(bldev); err_free_pwm: pwm_channel_free(&pwmbl->pwmc); err_free_mem: @@ -210,7 +209,6 @@ static int atmel_pwm_bl_remove(struct platform_device *pdev) gpio_set_value(pwmbl->gpio_on, 0); pwm_channel_disable(&pwmbl->pwmc); pwm_channel_free(&pwmbl->pwmc); - backlight_device_unregister(pwmbl->bldev); return 0; } -- cgit v1.1 From 26faf15cc650c6f30687c3e3c22d480bb1e3542b Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:12 -0800 Subject: backlight: bd6107: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/bd6107.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/bd6107.c b/drivers/video/backlight/bd6107.c index 43c434e..16dd9bc 100644 --- a/drivers/video/backlight/bd6107.c +++ b/drivers/video/backlight/bd6107.c @@ -166,7 +166,8 @@ static int bd6107_probe(struct i2c_client *client, props.brightness = clamp_t(unsigned int, pdata->def_value, 0, props.max_brightness); - backlight = backlight_device_register(dev_name(&client->dev), + backlight = devm_backlight_device_register(&client->dev, + dev_name(&client->dev), &bd->client->dev, bd, &bd6107_backlight_ops, &props); if (IS_ERR(backlight)) { @@ -186,7 +187,6 @@ static int bd6107_remove(struct i2c_client *client) backlight->props.brightness = 0; backlight_update_status(backlight); - backlight_device_unregister(backlight); return 0; } -- cgit v1.1 From 564452938311c81194fb9da8fc51f2a12c9a3afd Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:12 -0800 Subject: backlight: da903x_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/da903x_bl.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c index bbad5c2..12c5d84 100644 --- a/drivers/video/backlight/da903x_bl.c +++ b/drivers/video/backlight/da903x_bl.c @@ -144,8 +144,9 @@ static int da903x_backlight_probe(struct platform_device *pdev) memset(&props, 0, sizeof(props)); props.type = BACKLIGHT_RAW; props.max_brightness = max_brightness; - bl = backlight_device_register(pdev->name, data->da903x_dev, data, - &da903x_backlight_ops, &props); + bl = devm_backlight_device_register(&pdev->dev, pdev->name, + data->da903x_dev, data, + &da903x_backlight_ops, &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); return PTR_ERR(bl); @@ -158,21 +159,12 @@ static int da903x_backlight_probe(struct platform_device *pdev) return 0; } -static int da903x_backlight_remove(struct platform_device *pdev) -{ - struct backlight_device *bl = platform_get_drvdata(pdev); - - backlight_device_unregister(bl); - return 0; -} - static struct platform_driver da903x_backlight_driver = { .driver = { .name = "da903x-backlight", .owner = THIS_MODULE, }, .probe = da903x_backlight_probe, - .remove = da903x_backlight_remove, }; module_platform_driver(da903x_backlight_driver); -- cgit v1.1 From 02f0092cb37669fd9c68770365a18168b8cd5f60 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:13 -0800 Subject: backlight: da9052_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/da9052_bl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/da9052_bl.c b/drivers/video/backlight/da9052_bl.c index 842da5a..20d55be 100644 --- a/drivers/video/backlight/da9052_bl.c +++ b/drivers/video/backlight/da9052_bl.c @@ -125,8 +125,9 @@ static int da9052_backlight_probe(struct platform_device *pdev) props.type = BACKLIGHT_RAW; props.max_brightness = DA9052_MAX_BRIGHTNESS; - bl = backlight_device_register(pdev->name, wleds->da9052->dev, wleds, - &da9052_backlight_ops, &props); + bl = devm_backlight_device_register(&pdev->dev, pdev->name, + wleds->da9052->dev, wleds, + &da9052_backlight_ops, &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "Failed to register backlight\n"); return PTR_ERR(bl); @@ -147,7 +148,6 @@ static int da9052_backlight_remove(struct platform_device *pdev) wleds->brightness = 0; wleds->state = DA9052_WLEDS_OFF; da9052_adjust_wled_brightness(wleds); - backlight_device_unregister(bl); return 0; } -- cgit v1.1 From 23741ada20103cda6a39fad9eb0171757ef997ff Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:14 -0800 Subject: backlight: ep93xx: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/ep93xx_bl.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/ep93xx_bl.c b/drivers/video/backlight/ep93xx_bl.c index 018368b..0d1f633 100644 --- a/drivers/video/backlight/ep93xx_bl.c +++ b/drivers/video/backlight/ep93xx_bl.c @@ -92,8 +92,8 @@ static int ep93xxbl_probe(struct platform_device *dev) memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = EP93XX_MAX_BRIGHT; - bl = backlight_device_register(dev->name, &dev->dev, ep93xxbl, - &ep93xxbl_ops, &props); + bl = devm_backlight_device_register(&dev->dev, dev->name, &dev->dev, + ep93xxbl, &ep93xxbl_ops, &props); if (IS_ERR(bl)) return PTR_ERR(bl); @@ -106,14 +106,6 @@ static int ep93xxbl_probe(struct platform_device *dev) return 0; } -static int ep93xxbl_remove(struct platform_device *dev) -{ - struct backlight_device *bl = platform_get_drvdata(dev); - - backlight_device_unregister(bl); - return 0; -} - #ifdef CONFIG_PM_SLEEP static int ep93xxbl_suspend(struct device *dev) { @@ -140,7 +132,6 @@ static struct platform_driver ep93xxbl_driver = { .pm = &ep93xxbl_pm_ops, }, .probe = ep93xxbl_probe, - .remove = ep93xxbl_remove, }; module_platform_driver(ep93xxbl_driver); -- cgit v1.1 From de2efd2a9ffba56eb0c00a48346685baa377c370 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:15 -0800 Subject: backlight: generic_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/generic_bl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c index 48fa914..5d8d652 100644 --- a/drivers/video/backlight/generic_bl.c +++ b/drivers/video/backlight/generic_bl.c @@ -93,8 +93,8 @@ static int genericbl_probe(struct platform_device *pdev) memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = machinfo->max_intensity; - bd = backlight_device_register(name, &pdev->dev, NULL, &genericbl_ops, - &props); + bd = devm_backlight_device_register(&pdev->dev, name, &pdev->dev, + NULL, &genericbl_ops, &props); if (IS_ERR(bd)) return PTR_ERR(bd); @@ -118,8 +118,6 @@ static int genericbl_remove(struct platform_device *pdev) bd->props.brightness = 0; backlight_update_status(bd); - backlight_device_unregister(bd); - dev_info(&pdev->dev, "Generic Backlight Driver Unloaded\n"); return 0; } -- cgit v1.1 From ff47201582a5bbe6d14d2004e637351c41f78214 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:16 -0800 Subject: backlight: gpio_backlight: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/gpio_backlight.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index 118da0c..81fb127 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -95,8 +95,9 @@ static int gpio_backlight_probe(struct platform_device *pdev) memset(&props, 0, sizeof(props)); props.type = BACKLIGHT_RAW; props.max_brightness = 1; - bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, gbl, - &gpio_backlight_ops, &props); + bl = devm_backlight_device_register(&pdev->dev, dev_name(&pdev->dev), + &pdev->dev, gbl, &gpio_backlight_ops, + &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); return PTR_ERR(bl); @@ -109,21 +110,12 @@ static int gpio_backlight_probe(struct platform_device *pdev) return 0; } -static int gpio_backlight_remove(struct platform_device *pdev) -{ - struct backlight_device *bl = platform_get_drvdata(pdev); - - backlight_device_unregister(bl); - return 0; -} - static struct platform_driver gpio_backlight_driver = { .driver = { .name = "gpio-backlight", .owner = THIS_MODULE, }, .probe = gpio_backlight_probe, - .remove = gpio_backlight_remove, }; module_platform_driver(gpio_backlight_driver); -- cgit v1.1 From da6537850eb0d54eed44ba686be0f5f83c5c6559 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:17 -0800 Subject: backlight: kb3886_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/kb3886_bl.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c index 5bacabb..7592cc2 100644 --- a/drivers/video/backlight/kb3886_bl.c +++ b/drivers/video/backlight/kb3886_bl.c @@ -150,10 +150,10 @@ static int kb3886bl_probe(struct platform_device *pdev) memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = machinfo->max_intensity; - kb3886_backlight_device = backlight_device_register("kb3886-bl", - &pdev->dev, NULL, - &kb3886bl_ops, - &props); + kb3886_backlight_device = devm_backlight_device_register(&pdev->dev, + "kb3886-bl", &pdev->dev, + NULL, &kb3886bl_ops, + &props); if (IS_ERR(kb3886_backlight_device)) return PTR_ERR(kb3886_backlight_device); @@ -166,18 +166,8 @@ static int kb3886bl_probe(struct platform_device *pdev) return 0; } -static int kb3886bl_remove(struct platform_device *pdev) -{ - struct backlight_device *bd = platform_get_drvdata(pdev); - - backlight_device_unregister(bd); - - return 0; -} - static struct platform_driver kb3886bl_driver = { .probe = kb3886bl_probe, - .remove = kb3886bl_remove, .driver = { .name = "kb3886-bl", .pm = &kb3886bl_pm_ops, -- cgit v1.1 From e86c7098942d6446004ccf89a81c93328d93446a Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:18 -0800 Subject: backlight: lm3533_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lm3533_bl.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c index 93eea65..187d1c2 100644 --- a/drivers/video/backlight/lm3533_bl.c +++ b/drivers/video/backlight/lm3533_bl.c @@ -313,8 +313,9 @@ static int lm3533_bl_probe(struct platform_device *pdev) props.type = BACKLIGHT_RAW; props.max_brightness = LM3533_BL_MAX_BRIGHTNESS; props.brightness = pdata->default_brightness; - bd = backlight_device_register(pdata->name, pdev->dev.parent, bl, - &lm3533_bl_ops, &props); + bd = devm_backlight_device_register(&pdev->dev, pdata->name, + pdev->dev.parent, bl, &lm3533_bl_ops, + &props); if (IS_ERR(bd)) { dev_err(&pdev->dev, "failed to register backlight device\n"); return PTR_ERR(bd); @@ -328,7 +329,7 @@ static int lm3533_bl_probe(struct platform_device *pdev) ret = sysfs_create_group(&bd->dev.kobj, &lm3533_bl_attribute_group); if (ret < 0) { dev_err(&pdev->dev, "failed to create sysfs attributes\n"); - goto err_unregister; + return ret; } backlight_update_status(bd); @@ -345,8 +346,6 @@ static int lm3533_bl_probe(struct platform_device *pdev) err_sysfs_remove: sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group); -err_unregister: - backlight_device_unregister(bd); return ret; } @@ -363,7 +362,6 @@ static int lm3533_bl_remove(struct platform_device *pdev) lm3533_ctrlbank_disable(&bl->cb); sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group); - backlight_device_unregister(bd); return 0; } -- cgit v1.1 From 6255e8e9849767bcc9c9074aff7c0ec4f6e06c88 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:19 -0800 Subject: backlight: lp855x: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Also, unnecessary lp855x_backlight_unregister() is removed. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lp855x_bl.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index 57f005a..cae80d5 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -300,7 +300,7 @@ static int lp855x_backlight_register(struct lp855x *lp) props.brightness = pdata->initial_brightness; - bl = backlight_device_register(name, lp->dev, lp, + bl = devm_backlight_device_register(lp->dev, name, lp->dev, lp, &lp855x_bl_ops, &props); if (IS_ERR(bl)) return PTR_ERR(bl); @@ -310,12 +310,6 @@ static int lp855x_backlight_register(struct lp855x *lp) return 0; } -static void lp855x_backlight_unregister(struct lp855x *lp) -{ - if (lp->bl) - backlight_device_unregister(lp->bl); -} - static ssize_t lp855x_get_chip_id(struct device *dev, struct device_attribute *attr, char *buf) { @@ -439,29 +433,24 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) ret = lp855x_configure(lp); if (ret) { dev_err(lp->dev, "device config err: %d", ret); - goto err_dev; + return ret; } ret = lp855x_backlight_register(lp); if (ret) { dev_err(lp->dev, "failed to register backlight. err: %d\n", ret); - goto err_dev; + return ret; } ret = sysfs_create_group(&lp->dev->kobj, &lp855x_attr_group); if (ret) { dev_err(lp->dev, "failed to register sysfs. err: %d\n", ret); - goto err_sysfs; + return ret; } backlight_update_status(lp->bl); return 0; - -err_sysfs: - lp855x_backlight_unregister(lp); -err_dev: - return ret; } static int lp855x_remove(struct i2c_client *cl) @@ -471,7 +460,6 @@ static int lp855x_remove(struct i2c_client *cl) lp->bl->props.brightness = 0; backlight_update_status(lp->bl); sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group); - lp855x_backlight_unregister(lp); return 0; } -- cgit v1.1 From e924c2aadfbd18a38bcc805f32e5ffc1bdad4ad7 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:20 -0800 Subject: backlight: lv5207lp: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lv5207lp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/lv5207lp.c b/drivers/video/backlight/lv5207lp.c index 8091a28..1802b2d 100644 --- a/drivers/video/backlight/lv5207lp.c +++ b/drivers/video/backlight/lv5207lp.c @@ -124,9 +124,9 @@ static int lv5207lp_probe(struct i2c_client *client, props.brightness = clamp_t(unsigned int, pdata->def_value, 0, props.max_brightness); - backlight = backlight_device_register(dev_name(&client->dev), - &lv->client->dev, lv, - &lv5207lp_backlight_ops, &props); + backlight = devm_backlight_device_register(&client->dev, + dev_name(&client->dev), &lv->client->dev, + lv, &lv5207lp_backlight_ops, &props); if (IS_ERR(backlight)) { dev_err(&client->dev, "failed to register backlight\n"); return PTR_ERR(backlight); @@ -144,7 +144,6 @@ static int lv5207lp_remove(struct i2c_client *client) backlight->props.brightness = 0; backlight_update_status(backlight); - backlight_device_unregister(backlight); return 0; } -- cgit v1.1 From 18d9dbce468135c07ab57d2a53b406b9d1e05f18 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:21 -0800 Subject: backlight: max8925_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/max8925_bl.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c index 886e797..66fa08c 100644 --- a/drivers/video/backlight/max8925_bl.c +++ b/drivers/video/backlight/max8925_bl.c @@ -163,7 +163,8 @@ static int max8925_backlight_probe(struct platform_device *pdev) memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = MAX_BRIGHTNESS; - bl = backlight_device_register("max8925-backlight", &pdev->dev, data, + bl = devm_backlight_device_register(&pdev->dev, "max8925-backlight", + &pdev->dev, data, &max8925_backlight_ops, &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); @@ -188,20 +189,9 @@ static int max8925_backlight_probe(struct platform_device *pdev) } ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value); if (ret < 0) - goto out_brt; + return ret; backlight_update_status(bl); return 0; -out_brt: - backlight_device_unregister(bl); - return ret; -} - -static int max8925_backlight_remove(struct platform_device *pdev) -{ - struct backlight_device *bl = platform_get_drvdata(pdev); - - backlight_device_unregister(bl); - return 0; } static struct platform_driver max8925_backlight_driver = { @@ -210,7 +200,6 @@ static struct platform_driver max8925_backlight_driver = { .owner = THIS_MODULE, }, .probe = max8925_backlight_probe, - .remove = max8925_backlight_remove, }; module_platform_driver(max8925_backlight_driver); -- cgit v1.1 From 75d4baec9becbf1ed9c8804bd94004622f38cb11 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:22 -0800 Subject: backlight: pandora_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/pandora_bl.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/pandora_bl.c b/drivers/video/backlight/pandora_bl.c index 633b0a2..2098c5d 100644 --- a/drivers/video/backlight/pandora_bl.c +++ b/drivers/video/backlight/pandora_bl.c @@ -120,8 +120,8 @@ static int pandora_backlight_probe(struct platform_device *pdev) memset(&props, 0, sizeof(props)); props.max_brightness = MAX_USER_VALUE; props.type = BACKLIGHT_RAW; - bl = backlight_device_register(pdev->name, &pdev->dev, - NULL, &pandora_backlight_ops, &props); + bl = devm_backlight_device_register(&pdev->dev, pdev->name, &pdev->dev, + NULL, &pandora_backlight_ops, &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); return PTR_ERR(bl); @@ -145,20 +145,12 @@ static int pandora_backlight_probe(struct platform_device *pdev) return 0; } -static int pandora_backlight_remove(struct platform_device *pdev) -{ - struct backlight_device *bl = platform_get_drvdata(pdev); - backlight_device_unregister(bl); - return 0; -} - static struct platform_driver pandora_backlight_driver = { .driver = { .name = "pandora-backlight", .owner = THIS_MODULE, }, .probe = pandora_backlight_probe, - .remove = pandora_backlight_remove, }; module_platform_driver(pandora_backlight_driver); -- cgit v1.1 From c423a7712170f2ce51a71cc117cd2d588664bebe Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:23 -0800 Subject: backlight: pcf50633: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/pcf50633-backlight.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/pcf50633-backlight.c b/drivers/video/backlight/pcf50633-backlight.c index b2184cf..b95d3b0 100644 --- a/drivers/video/backlight/pcf50633-backlight.c +++ b/drivers/video/backlight/pcf50633-backlight.c @@ -126,7 +126,8 @@ static int pcf50633_bl_probe(struct platform_device *pdev) pcf_bl->pcf = dev_to_pcf50633(pdev->dev.parent); - pcf_bl->bl = backlight_device_register(pdev->name, &pdev->dev, pcf_bl, + pcf_bl->bl = devm_backlight_device_register(&pdev->dev, pdev->name, + &pdev->dev, pcf_bl, &pcf50633_bl_ops, &bl_props); if (IS_ERR(pcf_bl->bl)) @@ -147,18 +148,8 @@ static int pcf50633_bl_probe(struct platform_device *pdev) return 0; } -static int pcf50633_bl_remove(struct platform_device *pdev) -{ - struct pcf50633_bl *pcf_bl = platform_get_drvdata(pdev); - - backlight_device_unregister(pcf_bl->bl); - - return 0; -} - static struct platform_driver pcf50633_bl_driver = { .probe = pcf50633_bl_probe, - .remove = pcf50633_bl_remove, .driver = { .name = "pcf50633-backlight", }, -- cgit v1.1 From 626d09089f350f876f965c1e6fa4621498213b1e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:24 -0800 Subject: backlight: tps65217_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/tps65217_bl.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c index 4ea2039..cbba37e 100644 --- a/drivers/video/backlight/tps65217_bl.c +++ b/drivers/video/backlight/tps65217_bl.c @@ -313,7 +313,7 @@ static int tps65217_bl_probe(struct platform_device *pdev) bl_props.type = BACKLIGHT_RAW; bl_props.max_brightness = 100; - tps65217_bl->bl = backlight_device_register(pdev->name, + tps65217_bl->bl = devm_backlight_device_register(&pdev->dev, pdev->name, tps65217_bl->dev, tps65217_bl, &tps65217_bl_ops, &bl_props); if (IS_ERR(tps65217_bl->bl)) { @@ -329,18 +329,8 @@ static int tps65217_bl_probe(struct platform_device *pdev) return 0; } -static int tps65217_bl_remove(struct platform_device *pdev) -{ - struct tps65217_bl *tps65217_bl = platform_get_drvdata(pdev); - - backlight_device_unregister(tps65217_bl->bl); - - return 0; -} - static struct platform_driver tps65217_bl_driver = { .probe = tps65217_bl_probe, - .remove = tps65217_bl_remove, .driver = { .owner = THIS_MODULE, .name = "tps65217-bl", -- cgit v1.1 From f369e664498c8e73f24d137f5356bb3492917bc2 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:25 -0800 Subject: backlight: wm831x_bl: use devm_backlight_device_register() Use devm_backlight_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/wm831x_bl.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c index 2ccf320..8b9455e 100644 --- a/drivers/video/backlight/wm831x_bl.c +++ b/drivers/video/backlight/wm831x_bl.c @@ -195,8 +195,8 @@ static int wm831x_backlight_probe(struct platform_device *pdev) memset(&props, 0, sizeof(props)); props.type = BACKLIGHT_RAW; props.max_brightness = max_isel; - bl = backlight_device_register("wm831x", &pdev->dev, data, - &wm831x_backlight_ops, &props); + bl = devm_backlight_device_register(&pdev->dev, "wm831x", &pdev->dev, + data, &wm831x_backlight_ops, &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); return PTR_ERR(bl); @@ -214,21 +214,12 @@ static int wm831x_backlight_probe(struct platform_device *pdev) return 0; } -static int wm831x_backlight_remove(struct platform_device *pdev) -{ - struct backlight_device *bl = platform_get_drvdata(pdev); - - backlight_device_unregister(bl); - return 0; -} - static struct platform_driver wm831x_backlight_driver = { .driver = { .name = "wm831x-backlight", .owner = THIS_MODULE, }, .probe = wm831x_backlight_probe, - .remove = wm831x_backlight_remove, }; module_platform_driver(wm831x_backlight_driver); -- cgit v1.1 From ea5092c890ed093297554e0216188543ee445068 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:25 -0800 Subject: backlight: hx8357: use devm_lcd_device_register() Use devm_lcd_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/hx8357.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c index c7af8c4..0d252e7 100644 --- a/drivers/video/backlight/hx8357.c +++ b/drivers/video/backlight/hx8357.c @@ -648,7 +648,8 @@ static int hx8357_probe(struct spi_device *spi) lcd->use_im_pins = 0; } - lcdev = lcd_device_register("mxsfb", &spi->dev, lcd, &hx8357_ops); + lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd, + &hx8357_ops); if (IS_ERR(lcdev)) { ret = PTR_ERR(lcdev); return ret; @@ -660,29 +661,16 @@ static int hx8357_probe(struct spi_device *spi) ret = ((int (*)(struct lcd_device *))match->data)(lcdev); if (ret) { dev_err(&spi->dev, "Couldn't initialize panel\n"); - goto init_error; + return ret; } dev_info(&spi->dev, "Panel probed\n"); return 0; - -init_error: - lcd_device_unregister(lcdev); - return ret; -} - -static int hx8357_remove(struct spi_device *spi) -{ - struct lcd_device *lcdev = spi_get_drvdata(spi); - - lcd_device_unregister(lcdev); - return 0; } static struct spi_driver hx8357_driver = { .probe = hx8357_probe, - .remove = hx8357_remove, .driver = { .name = "hx8357", .of_match_table = of_match_ptr(hx8357_dt_ids), -- cgit v1.1 From a7e9e3ffd7e80db0d5eb181bc5b3054604db7811 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:26 -0800 Subject: backlight: ili922x: use devm_lcd_device_register() Use devm_lcd_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/ili922x.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/ili922x.c b/drivers/video/backlight/ili922x.c index d9f65c2..73464e4 100644 --- a/drivers/video/backlight/ili922x.c +++ b/drivers/video/backlight/ili922x.c @@ -513,8 +513,8 @@ static int ili922x_probe(struct spi_device *spi) ili->power = FB_BLANK_POWERDOWN; - lcd = lcd_device_register("ili922xlcd", &spi->dev, ili, - &ili922x_ops); + lcd = devm_lcd_device_register(&spi->dev, "ili922xlcd", &spi->dev, ili, + &ili922x_ops); if (IS_ERR(lcd)) { dev_err(&spi->dev, "cannot register LCD\n"); return PTR_ERR(lcd); @@ -530,10 +530,7 @@ static int ili922x_probe(struct spi_device *spi) static int ili922x_remove(struct spi_device *spi) { - struct ili922x *ili = spi_get_drvdata(spi); - ili922x_poweroff(spi); - lcd_device_unregister(ili->ld); return 0; } -- cgit v1.1 From 5690378efa8b232161d4cae5d9650da85c88ab1f Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:27 -0800 Subject: backlight: ili9320: use devm_lcd_device_register() Use devm_lcd_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/ili9320.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/ili9320.c b/drivers/video/backlight/ili9320.c index 4dd43e0..e2b8b40 100644 --- a/drivers/video/backlight/ili9320.c +++ b/drivers/video/backlight/ili9320.c @@ -235,7 +235,8 @@ int ili9320_probe_spi(struct spi_device *spi, ili9320_setup_spi(ili, spi); - lcd = lcd_device_register("ili9320", dev, ili, &ili9320_ops); + lcd = devm_lcd_device_register(&spi->dev, "ili9320", dev, ili, + &ili9320_ops); if (IS_ERR(lcd)) { dev_err(dev, "failed to register lcd device\n"); return PTR_ERR(lcd); @@ -248,24 +249,16 @@ int ili9320_probe_spi(struct spi_device *spi, ret = ili9320_power(ili, FB_BLANK_UNBLANK); if (ret != 0) { dev_err(dev, "failed to set lcd power state\n"); - goto err_unregister; + return ret; } return 0; - - err_unregister: - lcd_device_unregister(lcd); - - return ret; } EXPORT_SYMBOL_GPL(ili9320_probe_spi); int ili9320_remove(struct ili9320 *ili) { ili9320_power(ili, FB_BLANK_POWERDOWN); - - lcd_device_unregister(ili->lcd); - return 0; } EXPORT_SYMBOL_GPL(ili9320_remove); -- cgit v1.1 From 0a1c55d0212661a582e9b4688410ccf9d4b163e8 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:28 -0800 Subject: backlight: lms283gf05: use devm_lcd_device_register() Use devm_lcd_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lms283gf05.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c index 80b5929..de88325 100644 --- a/drivers/video/backlight/lms283gf05.c +++ b/drivers/video/backlight/lms283gf05.c @@ -173,7 +173,8 @@ static int lms283gf05_probe(struct spi_device *spi) return -ENOMEM; } - ld = lcd_device_register("lms283gf05", &spi->dev, st, &lms_ops); + ld = devm_lcd_device_register(&spi->dev, "lms283gf05", &spi->dev, st, + &lms_ops); if (IS_ERR(ld)) return PTR_ERR(ld); @@ -190,22 +191,12 @@ static int lms283gf05_probe(struct spi_device *spi) return 0; } -static int lms283gf05_remove(struct spi_device *spi) -{ - struct lms283gf05_state *st = spi_get_drvdata(spi); - - lcd_device_unregister(st->ld); - - return 0; -} - static struct spi_driver lms283gf05_driver = { .driver = { .name = "lms283gf05", .owner = THIS_MODULE, }, .probe = lms283gf05_probe, - .remove = lms283gf05_remove, }; module_spi_driver(lms283gf05_driver); -- cgit v1.1 From 8358741ab72a6a15165d1a855304c81beee74240 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:29 -0800 Subject: backlight: lms501kf03: use devm_lcd_device_register() Use devm_lcd_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lms501kf03.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/lms501kf03.c b/drivers/video/backlight/lms501kf03.c index ff46e19..77258b7 100644 --- a/drivers/video/backlight/lms501kf03.c +++ b/drivers/video/backlight/lms501kf03.c @@ -350,8 +350,8 @@ static int lms501kf03_probe(struct spi_device *spi) return -EINVAL; } - ld = lcd_device_register("lms501kf03", &spi->dev, lcd, - &lms501kf03_lcd_ops); + ld = devm_lcd_device_register(&spi->dev, "lms501kf03", &spi->dev, lcd, + &lms501kf03_lcd_ops); if (IS_ERR(ld)) return PTR_ERR(ld); @@ -382,8 +382,6 @@ static int lms501kf03_remove(struct spi_device *spi) struct lms501kf03 *lcd = spi_get_drvdata(spi); lms501kf03_power(lcd, FB_BLANK_POWERDOWN); - lcd_device_unregister(lcd->ld); - return 0; } -- cgit v1.1 From e8796d9f4fde228478ccf953c3f97a58f8e34e48 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:30 -0800 Subject: backlight: ltv350qv: use devm_lcd_device_register() Use devm_lcd_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/ltv350qv.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/ltv350qv.c b/drivers/video/backlight/ltv350qv.c index ed1b392..383f550 100644 --- a/drivers/video/backlight/ltv350qv.c +++ b/drivers/video/backlight/ltv350qv.c @@ -242,7 +242,8 @@ static int ltv350qv_probe(struct spi_device *spi) if (!lcd->buffer) return -ENOMEM; - ld = lcd_device_register("ltv350qv", &spi->dev, lcd, <v_ops); + ld = devm_lcd_device_register(&spi->dev, "ltv350qv", &spi->dev, lcd, + <v_ops); if (IS_ERR(ld)) return PTR_ERR(ld); @@ -250,15 +251,11 @@ static int ltv350qv_probe(struct spi_device *spi) ret = ltv350qv_power(lcd, FB_BLANK_UNBLANK); if (ret) - goto out_unregister; + return ret; spi_set_drvdata(spi, lcd); return 0; - -out_unregister: - lcd_device_unregister(ld); - return ret; } static int ltv350qv_remove(struct spi_device *spi) @@ -266,8 +263,6 @@ static int ltv350qv_remove(struct spi_device *spi) struct ltv350qv *lcd = spi_get_drvdata(spi); ltv350qv_power(lcd, FB_BLANK_POWERDOWN); - lcd_device_unregister(lcd->ld); - return 0; } -- cgit v1.1 From 1f9ca1eee8e93cacf1bff11dc3fdd01b7fd80cd7 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:31 -0800 Subject: backlight: platform_lcd: use devm_lcd_device_register() Use devm_lcd_device_register() to make cleanup paths simpler, and remove unnecessary remove(). Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/platform_lcd.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c index cc0f067..d01884d 100644 --- a/drivers/video/backlight/platform_lcd.c +++ b/drivers/video/backlight/platform_lcd.c @@ -101,30 +101,17 @@ static int platform_lcd_probe(struct platform_device *pdev) plcd->us = dev; plcd->pdata = pdata; - plcd->lcd = lcd_device_register(dev_name(dev), dev, - plcd, &platform_lcd_ops); + plcd->lcd = devm_lcd_device_register(&pdev->dev, dev_name(dev), dev, + plcd, &platform_lcd_ops); if (IS_ERR(plcd->lcd)) { dev_err(dev, "cannot register lcd device\n"); - err = PTR_ERR(plcd->lcd); - goto err; + return PTR_ERR(plcd->lcd); } platform_set_drvdata(pdev, plcd); platform_lcd_set_power(plcd->lcd, FB_BLANK_NORMAL); return 0; - - err: - return err; -} - -static int platform_lcd_remove(struct platform_device *pdev) -{ - struct platform_lcd *plcd = platform_get_drvdata(pdev); - - lcd_device_unregister(plcd->lcd); - - return 0; } #ifdef CONFIG_PM_SLEEP @@ -168,7 +155,6 @@ static struct platform_driver platform_lcd_driver = { .of_match_table = of_match_ptr(platform_lcd_of_match), }, .probe = platform_lcd_probe, - .remove = platform_lcd_remove, }; module_platform_driver(platform_lcd_driver); -- cgit v1.1 From 0524fc5194e548a4fe32d87850b976e0ec4e9007 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:32 -0800 Subject: backlight: tdo24m: use devm_lcd_device_register() Use devm_lcd_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/tdo24m.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c index 2ccfa46..908016f 100644 --- a/drivers/video/backlight/tdo24m.c +++ b/drivers/video/backlight/tdo24m.c @@ -385,21 +385,17 @@ static int tdo24m_probe(struct spi_device *spi) return -EINVAL; } - lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, - lcd, &tdo24m_ops); + lcd->lcd_dev = devm_lcd_device_register(&spi->dev, "tdo24m", &spi->dev, + lcd, &tdo24m_ops); if (IS_ERR(lcd->lcd_dev)) return PTR_ERR(lcd->lcd_dev); spi_set_drvdata(spi, lcd); err = tdo24m_power(lcd, FB_BLANK_UNBLANK); if (err) - goto out_unregister; + return err; return 0; - -out_unregister: - lcd_device_unregister(lcd->lcd_dev); - return err; } static int tdo24m_remove(struct spi_device *spi) @@ -407,8 +403,6 @@ static int tdo24m_remove(struct spi_device *spi) struct tdo24m *lcd = spi_get_drvdata(spi); tdo24m_power(lcd, FB_BLANK_POWERDOWN); - lcd_device_unregister(lcd->lcd_dev); - return 0; } -- cgit v1.1 From ebc41e43b2b72e236019580490044604a48824e5 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:32 -0800 Subject: backlight: ams369fg06: use devm_{backlight,lcd}_device_register() Use devm_backlight_device_register() and devm_lcd_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/ams369fg06.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c index df5507b..d8952c4 100644 --- a/drivers/video/backlight/ams369fg06.c +++ b/drivers/video/backlight/ams369fg06.c @@ -477,8 +477,8 @@ static int ams369fg06_probe(struct spi_device *spi) return -EINVAL; } - ld = lcd_device_register("ams369fg06", &spi->dev, lcd, - &ams369fg06_lcd_ops); + ld = devm_lcd_device_register(&spi->dev, "ams369fg06", &spi->dev, lcd, + &ams369fg06_lcd_ops); if (IS_ERR(ld)) return PTR_ERR(ld); @@ -488,12 +488,11 @@ static int ams369fg06_probe(struct spi_device *spi) props.type = BACKLIGHT_RAW; props.max_brightness = MAX_BRIGHTNESS; - bd = backlight_device_register("ams369fg06-bl", &spi->dev, lcd, - &ams369fg06_backlight_ops, &props); - if (IS_ERR(bd)) { - ret = PTR_ERR(bd); - goto out_lcd_unregister; - } + bd = devm_backlight_device_register(&spi->dev, "ams369fg06-bl", + &spi->dev, lcd, + &ams369fg06_backlight_ops, &props); + if (IS_ERR(bd)) + return PTR_ERR(bd); bd->props.brightness = DEFAULT_BRIGHTNESS; lcd->bd = bd; @@ -516,10 +515,6 @@ static int ams369fg06_probe(struct spi_device *spi) dev_info(&spi->dev, "ams369fg06 panel driver has been probed.\n"); return 0; - -out_lcd_unregister: - lcd_device_unregister(ld); - return ret; } static int ams369fg06_remove(struct spi_device *spi) @@ -527,9 +522,6 @@ static int ams369fg06_remove(struct spi_device *spi) struct ams369fg06 *lcd = spi_get_drvdata(spi); ams369fg06_power(lcd, FB_BLANK_POWERDOWN); - backlight_device_unregister(lcd->bd); - lcd_device_unregister(lcd->ld); - return 0; } -- cgit v1.1 From 7a78e1b24b993b3af257d4d4f10fa7bd0913deaa Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:33 -0800 Subject: backlight: ld9040: use devm_{backlight,lcd}_device_register() Use devm_backlight_device_register() and devm_lcd_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/ld9040.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/ld9040.c b/drivers/video/backlight/ld9040.c index 26d5139..506a6c2 100644 --- a/drivers/video/backlight/ld9040.c +++ b/drivers/video/backlight/ld9040.c @@ -716,7 +716,8 @@ static int ld9040_probe(struct spi_device *spi) return ret; } - ld = lcd_device_register("ld9040", &spi->dev, lcd, &ld9040_lcd_ops); + ld = devm_lcd_device_register(&spi->dev, "ld9040", &spi->dev, lcd, + &ld9040_lcd_ops); if (IS_ERR(ld)) return PTR_ERR(ld); @@ -726,12 +727,10 @@ static int ld9040_probe(struct spi_device *spi) props.type = BACKLIGHT_RAW; props.max_brightness = MAX_BRIGHTNESS; - bd = backlight_device_register("ld9040-bl", &spi->dev, - lcd, &ld9040_backlight_ops, &props); - if (IS_ERR(bd)) { - ret = PTR_ERR(bd); - goto out_unregister_lcd; - } + bd = devm_backlight_device_register(&spi->dev, "ld9040-bl", &spi->dev, + lcd, &ld9040_backlight_ops, &props); + if (IS_ERR(bd)) + return PTR_ERR(bd); bd->props.brightness = MAX_BRIGHTNESS; lcd->bd = bd; @@ -757,11 +756,6 @@ static int ld9040_probe(struct spi_device *spi) dev_info(&spi->dev, "ld9040 panel driver has been probed.\n"); return 0; - -out_unregister_lcd: - lcd_device_unregister(lcd->ld); - - return ret; } static int ld9040_remove(struct spi_device *spi) @@ -769,9 +763,6 @@ static int ld9040_remove(struct spi_device *spi) struct ld9040 *lcd = spi_get_drvdata(spi); ld9040_power(lcd, FB_BLANK_POWERDOWN); - backlight_device_unregister(lcd->bd); - lcd_device_unregister(lcd->ld); - return 0; } -- cgit v1.1 From 10645a1d1878cf4c1dde0398a6d6e82aed06ab4a Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:34 -0800 Subject: backlight: corgi_lcd: use devm_{backlight,lcd}_device_register() Use devm_backlight_device_register() and devm_lcd_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/corgi_lcd.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c index be56cfe..db8db5f 100644 --- a/drivers/video/backlight/corgi_lcd.c +++ b/drivers/video/backlight/corgi_lcd.c @@ -550,8 +550,8 @@ static int corgi_lcd_probe(struct spi_device *spi) lcd->spi_dev = spi; - lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev, - lcd, &corgi_lcd_ops); + lcd->lcd_dev = devm_lcd_device_register(&spi->dev, "corgi_lcd", + &spi->dev, lcd, &corgi_lcd_ops); if (IS_ERR(lcd->lcd_dev)) return PTR_ERR(lcd->lcd_dev); @@ -561,18 +561,18 @@ static int corgi_lcd_probe(struct spi_device *spi) memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = pdata->max_intensity; - lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, lcd, - &corgi_bl_ops, &props); - if (IS_ERR(lcd->bl_dev)) { - ret = PTR_ERR(lcd->bl_dev); - goto err_unregister_lcd; - } + lcd->bl_dev = devm_backlight_device_register(&spi->dev, "corgi_bl", + &spi->dev, lcd, &corgi_bl_ops, + &props); + if (IS_ERR(lcd->bl_dev)) + return PTR_ERR(lcd->bl_dev); + lcd->bl_dev->props.brightness = pdata->default_intensity; lcd->bl_dev->props.power = FB_BLANK_UNBLANK; ret = setup_gpio_backlight(lcd, pdata); if (ret) - goto err_unregister_bl; + return ret; lcd->kick_battery = pdata->kick_battery; @@ -583,12 +583,6 @@ static int corgi_lcd_probe(struct spi_device *spi) lcd->limit_mask = pdata->limit_mask; the_corgi_lcd = lcd; return 0; - -err_unregister_bl: - backlight_device_unregister(lcd->bl_dev); -err_unregister_lcd: - lcd_device_unregister(lcd->lcd_dev); - return ret; } static int corgi_lcd_remove(struct spi_device *spi) @@ -598,11 +592,7 @@ static int corgi_lcd_remove(struct spi_device *spi) lcd->bl_dev->props.power = FB_BLANK_UNBLANK; lcd->bl_dev->props.brightness = 0; backlight_update_status(lcd->bl_dev); - backlight_device_unregister(lcd->bl_dev); - corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); - lcd_device_unregister(lcd->lcd_dev); - return 0; } -- cgit v1.1 From 289a65e46b0eb57a5c8f54b4881b93d6ebed9f4e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:35 -0800 Subject: backlight: cr_bllcd: use devm_{backlight,lcd}_device_register() Use devm_backlight_device_register() and devm_lcd_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/cr_bllcd.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c index 37bae80..f3fed9e 100644 --- a/drivers/video/backlight/cr_bllcd.c +++ b/drivers/video/backlight/cr_bllcd.c @@ -195,16 +195,17 @@ static int cr_backlight_probe(struct platform_device *pdev) memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; - bdp = backlight_device_register("cr-backlight", &pdev->dev, NULL, - &cr_backlight_ops, &props); + bdp = devm_backlight_device_register(&pdev->dev, "cr-backlight", + &pdev->dev, NULL, &cr_backlight_ops, + &props); if (IS_ERR(bdp)) { pci_dev_put(lpc_dev); return PTR_ERR(bdp); } - ldp = lcd_device_register("cr-lcd", &pdev->dev, NULL, &cr_lcd_ops); + ldp = devm_lcd_device_register(&pdev->dev, "cr-lcd", &pdev->dev, NULL, + &cr_lcd_ops); if (IS_ERR(ldp)) { - backlight_device_unregister(bdp); pci_dev_put(lpc_dev); return PTR_ERR(ldp); } @@ -215,8 +216,6 @@ static int cr_backlight_probe(struct platform_device *pdev) crp = devm_kzalloc(&pdev->dev, sizeof(*crp), GFP_KERNEL); if (!crp) { - lcd_device_unregister(ldp); - backlight_device_unregister(bdp); pci_dev_put(lpc_dev); return -ENOMEM; } @@ -241,8 +240,6 @@ static int cr_backlight_remove(struct platform_device *pdev) crp->cr_backlight_device->props.max_brightness = 0; cr_backlight_set_intensity(crp->cr_backlight_device); cr_lcd_set_power(crp->cr_lcd_device, FB_BLANK_POWERDOWN); - backlight_device_unregister(crp->cr_backlight_device); - lcd_device_unregister(crp->cr_lcd_device); pci_dev_put(lpc_dev); return 0; -- cgit v1.1 From a18863f5e83881e3ed1f4ee92496898045e1f5c3 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:09:36 -0800 Subject: backlight: s6e63m0: use devm_{backlight,lcd}_device_register() Use devm_backlight_device_register() and devm_lcd_device_register() to make cleanup paths simpler. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/s6e63m0.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c index 4e339ad..510a1bc 100644 --- a/drivers/video/backlight/s6e63m0.c +++ b/drivers/video/backlight/s6e63m0.c @@ -741,7 +741,8 @@ static int s6e63m0_probe(struct spi_device *spi) return -EINVAL; } - ld = lcd_device_register("s6e63m0", &spi->dev, lcd, &s6e63m0_lcd_ops); + ld = devm_lcd_device_register(&spi->dev, "s6e63m0", &spi->dev, lcd, + &s6e63m0_lcd_ops); if (IS_ERR(ld)) return PTR_ERR(ld); @@ -751,12 +752,11 @@ static int s6e63m0_probe(struct spi_device *spi) props.type = BACKLIGHT_RAW; props.max_brightness = MAX_BRIGHTNESS; - bd = backlight_device_register("s6e63m0bl-bl", &spi->dev, lcd, - &s6e63m0_backlight_ops, &props); - if (IS_ERR(bd)) { - ret = PTR_ERR(bd); - goto out_lcd_unregister; - } + bd = devm_backlight_device_register(&spi->dev, "s6e63m0bl-bl", + &spi->dev, lcd, &s6e63m0_backlight_ops, + &props); + if (IS_ERR(bd)) + return PTR_ERR(bd); bd->props.brightness = MAX_BRIGHTNESS; lcd->bd = bd; @@ -798,10 +798,6 @@ static int s6e63m0_probe(struct spi_device *spi) dev_info(&spi->dev, "s6e63m0 panel driver has been probed.\n"); return 0; - -out_lcd_unregister: - lcd_device_unregister(ld); - return ret; } static int s6e63m0_remove(struct spi_device *spi) @@ -811,8 +807,6 @@ static int s6e63m0_remove(struct spi_device *spi) s6e63m0_power(lcd, FB_BLANK_POWERDOWN); device_remove_file(&spi->dev, &dev_attr_gamma_table); device_remove_file(&spi->dev, &dev_attr_gamma_mode); - backlight_device_unregister(lcd->bd); - lcd_device_unregister(lcd->ld); return 0; } -- cgit v1.1 From bcd5b4165645eb44c781bca456c11c0478546161 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 12 Nov 2013 15:09:37 -0800 Subject: drivers/video/backlight/lm3630a_bl.c: add missing destroy_workqueue() on error in lm3630a_intr_config() Add the missing destroy_workqueue() before return from lm3630a_intr_config() in the error handling case. Signed-off-by: Wei Yongjun Acked-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/lm3630a_bl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c index 999075a..35fe482 100644 --- a/drivers/video/backlight/lm3630a_bl.c +++ b/drivers/video/backlight/lm3630a_bl.c @@ -154,6 +154,7 @@ static int lm3630a_intr_config(struct lm3630a_chip *pchip) (pchip->irq, NULL, lm3630a_isr_func, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "lm3630a_irq", pchip)) { dev_err(pchip->dev, "request threaded irq fail\n"); + destroy_workqueue(pchip->irqthread); return -ENOMEM; } return rval; -- cgit v1.1 From 185d91442550110db67a7dc794a32efcea455a36 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 12 Nov 2013 15:09:38 -0800 Subject: backlight: atmel-pwm-bl: fix reported brightness The driver supports 16-bit brightness values, but the value returned from get_brightness was truncated to eight bits. Signed-off-by: Johan Hovold Cc: Jingoo Han Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/atmel-pwm-bl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index 66885fb..0971a8e 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -70,7 +70,7 @@ static int atmel_pwm_bl_set_intensity(struct backlight_device *bd) static int atmel_pwm_bl_get_intensity(struct backlight_device *bd) { struct atmel_pwm_bl *pwmbl = bl_get_data(bd); - u8 intensity; + u32 intensity; if (pwmbl->pdata->pwm_active_low) { intensity = pwm_channel_readl(&pwmbl->pwmc, PWM_CDTY) - @@ -80,7 +80,7 @@ static int atmel_pwm_bl_get_intensity(struct backlight_device *bd) pwm_channel_readl(&pwmbl->pwmc, PWM_CDTY); } - return intensity; + return intensity & 0xffff; } static int atmel_pwm_bl_init_pwm(struct atmel_pwm_bl *pwmbl) -- cgit v1.1 From ad5066d4c2b1d696749f8d7816357c23b648c4d3 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 12 Nov 2013 15:09:39 -0800 Subject: backlight: atmel-pwm-bl: fix gpio polarity in remove Make sure to honour gpio polarity also at remove so that the backlight is actually disabled on boards with active-low enable pin. Signed-off-by: Johan Hovold Acked-by: Jingoo Han Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/atmel-pwm-bl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index 0971a8e..e21beb6 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -205,8 +205,10 @@ static int atmel_pwm_bl_remove(struct platform_device *pdev) { struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev); - if (pwmbl->gpio_on != -1) - gpio_set_value(pwmbl->gpio_on, 0); + if (pwmbl->gpio_on != -1) { + gpio_set_value(pwmbl->gpio_on, + 0 ^ pwmbl->pdata->on_active_low); + } pwm_channel_disable(&pwmbl->pwmc); pwm_channel_free(&pwmbl->pwmc); -- cgit v1.1 From 5c057e5570f18b9d0f4eea99e0a0d55ad5f30e36 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 12 Nov 2013 15:09:40 -0800 Subject: backlight: atmel-pwm-bl: fix module autoload Add missing module alias which is needed for module autoloading. Signed-off-by: Johan Hovold Acked-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/atmel-pwm-bl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index e21beb6..4886028 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -229,3 +229,4 @@ module_platform_driver(atmel_pwm_bl_driver); MODULE_AUTHOR("Hans-Christian egtvedt "); MODULE_DESCRIPTION("Atmel PWM backlight driver"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:atmel-pwm-bl"); -- cgit v1.1 From ce726c9738a27ee32a00136cc512b1058044a0fe Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 12 Nov 2013 15:09:41 -0800 Subject: backlight: atmel-pwm-bl: clean up probe error handling Clean up probe error handling by checking parameters before any allocations and removing an obsolete error label. Also remove unnecessary reset of private gpio number. Signed-off-by: Johan Hovold Acked-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/atmel-pwm-bl.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index 4886028..01af5c2 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -126,40 +126,33 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) struct atmel_pwm_bl *pwmbl; int retval; + pdata = dev_get_platdata(&pdev->dev); + if (!pdata) + return -ENODEV; + + if (pdata->pwm_compare_max < pdata->pwm_duty_max || + pdata->pwm_duty_min > pdata->pwm_duty_max || + pdata->pwm_frequency == 0) + return -EINVAL; + pwmbl = devm_kzalloc(&pdev->dev, sizeof(struct atmel_pwm_bl), GFP_KERNEL); if (!pwmbl) return -ENOMEM; pwmbl->pdev = pdev; - - pdata = dev_get_platdata(&pdev->dev); - if (!pdata) { - retval = -ENODEV; - goto err_free_mem; - } - - if (pdata->pwm_compare_max < pdata->pwm_duty_max || - pdata->pwm_duty_min > pdata->pwm_duty_max || - pdata->pwm_frequency == 0) { - retval = -EINVAL; - goto err_free_mem; - } - pwmbl->pdata = pdata; pwmbl->gpio_on = pdata->gpio_on; retval = pwm_channel_alloc(pdata->pwm_channel, &pwmbl->pwmc); if (retval) - goto err_free_mem; + return retval; if (pwmbl->gpio_on != -1) { retval = devm_gpio_request(&pdev->dev, pwmbl->gpio_on, "gpio_atmel_pwm_bl"); - if (retval) { - pwmbl->gpio_on = -1; + if (retval) goto err_free_pwm; - } /* Turn display off by default. */ retval = gpio_direction_output(pwmbl->gpio_on, @@ -197,7 +190,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) err_free_pwm: pwm_channel_free(&pwmbl->pwmc); -err_free_mem: + return retval; } -- cgit v1.1 From 9a26a84e3f77850ab80dbb9fb7f9821109f38f12 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 12 Nov 2013 15:09:42 -0800 Subject: backlight: atmel-pwm-bl: clean up get_intensity Clean up get_intensity to increase readability. Signed-off-by: Johan Hovold Acked-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/atmel-pwm-bl.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index 01af5c2..abfaada 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -70,15 +70,14 @@ static int atmel_pwm_bl_set_intensity(struct backlight_device *bd) static int atmel_pwm_bl_get_intensity(struct backlight_device *bd) { struct atmel_pwm_bl *pwmbl = bl_get_data(bd); + u32 cdty; u32 intensity; - if (pwmbl->pdata->pwm_active_low) { - intensity = pwm_channel_readl(&pwmbl->pwmc, PWM_CDTY) - - pwmbl->pdata->pwm_duty_min; - } else { - intensity = pwmbl->pdata->pwm_duty_max - - pwm_channel_readl(&pwmbl->pwmc, PWM_CDTY); - } + cdty = pwm_channel_readl(&pwmbl->pwmc, PWM_CDTY); + if (pwmbl->pdata->pwm_active_low) + intensity = cdty - pwmbl->pdata->pwm_duty_min; + else + intensity = pwmbl->pdata->pwm_duty_max - cdty; return intensity & 0xffff; } -- cgit v1.1 From 7bb8abe6ed58835c58153d59e4b13513b7306802 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 12 Nov 2013 15:09:43 -0800 Subject: backlight: atmel-pwm-bl: remove unused include Remove unused include of clk.h. Signed-off-by: Johan Hovold Acked-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/atmel-pwm-bl.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index abfaada..bfd6a96 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include -- cgit v1.1 From 5ada4550e86b081b889bced50e5ab6c510f9cdd7 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 12 Nov 2013 15:09:44 -0800 Subject: backlight: atmel-pwm-bl: use gpio_is_valid Use gpio_is_valid rather than open coding the more restrictive != -1 test. Signed-off-by: Johan Hovold Acked-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/atmel-pwm-bl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index bfd6a96..c254209 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -48,7 +48,7 @@ static int atmel_pwm_bl_set_intensity(struct backlight_device *bd) pwm_duty = pwmbl->pdata->pwm_duty_min; if (!intensity) { - if (pwmbl->gpio_on != -1) { + if (gpio_is_valid(pwmbl->gpio_on)) { gpio_set_value(pwmbl->gpio_on, 0 ^ pwmbl->pdata->on_active_low); } @@ -57,7 +57,7 @@ static int atmel_pwm_bl_set_intensity(struct backlight_device *bd) } else { pwm_channel_enable(&pwmbl->pwmc); pwm_channel_writel(&pwmbl->pwmc, PWM_CUPD, pwm_duty); - if (pwmbl->gpio_on != -1) { + if (gpio_is_valid(pwmbl->gpio_on)) { gpio_set_value(pwmbl->gpio_on, 1 ^ pwmbl->pdata->on_active_low); } @@ -146,7 +146,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) if (retval) return retval; - if (pwmbl->gpio_on != -1) { + if (gpio_is_valid(pwmbl->gpio_on)) { retval = devm_gpio_request(&pdev->dev, pwmbl->gpio_on, "gpio_atmel_pwm_bl"); if (retval) @@ -196,7 +196,7 @@ static int atmel_pwm_bl_remove(struct platform_device *pdev) { struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev); - if (pwmbl->gpio_on != -1) { + if (gpio_is_valid(pwmbl->gpio_on)) { gpio_set_value(pwmbl->gpio_on, 0 ^ pwmbl->pdata->on_active_low); } -- cgit v1.1 From 81b62db56dbdfef8f3b596dc2845df7ee3ab2165 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 12 Nov 2013 15:09:45 -0800 Subject: backlight: atmel-pwm-bl: refactor gpio_on handling Add helper function to control the gpio_on signal. Signed-off-by: Johan Hovold Acked-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/atmel-pwm-bl.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index c254209..bd1ed34 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -26,6 +26,14 @@ struct atmel_pwm_bl { int gpio_on; }; +static void atmel_pwm_bl_set_gpio_on(struct atmel_pwm_bl *pwmbl, int on) +{ + if (!gpio_is_valid(pwmbl->gpio_on)) + return; + + gpio_set_value(pwmbl->gpio_on, on ^ pwmbl->pdata->on_active_low); +} + static int atmel_pwm_bl_set_intensity(struct backlight_device *bd) { struct atmel_pwm_bl *pwmbl = bl_get_data(bd); @@ -48,19 +56,13 @@ static int atmel_pwm_bl_set_intensity(struct backlight_device *bd) pwm_duty = pwmbl->pdata->pwm_duty_min; if (!intensity) { - if (gpio_is_valid(pwmbl->gpio_on)) { - gpio_set_value(pwmbl->gpio_on, - 0 ^ pwmbl->pdata->on_active_low); - } + atmel_pwm_bl_set_gpio_on(pwmbl, 0); pwm_channel_writel(&pwmbl->pwmc, PWM_CUPD, pwm_duty); pwm_channel_disable(&pwmbl->pwmc); } else { pwm_channel_enable(&pwmbl->pwmc); pwm_channel_writel(&pwmbl->pwmc, PWM_CUPD, pwm_duty); - if (gpio_is_valid(pwmbl->gpio_on)) { - gpio_set_value(pwmbl->gpio_on, - 1 ^ pwmbl->pdata->on_active_low); - } + atmel_pwm_bl_set_gpio_on(pwmbl, 1); } return 0; @@ -196,10 +198,7 @@ static int atmel_pwm_bl_remove(struct platform_device *pdev) { struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev); - if (gpio_is_valid(pwmbl->gpio_on)) { - gpio_set_value(pwmbl->gpio_on, - 0 ^ pwmbl->pdata->on_active_low); - } + atmel_pwm_bl_set_gpio_on(pwmbl, 0); pwm_channel_disable(&pwmbl->pwmc); pwm_channel_free(&pwmbl->pwmc); -- cgit v1.1 From 9b3521ee8f35faa73459cda9a8b9b6e0a08a8d30 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 12 Nov 2013 15:09:46 -0800 Subject: backlight: atmel-pwm-bl: use gpio_request_one Use devm_gpio_request_one rather than requesting and setting direction in two calls. Signed-off-by: Johan Hovold Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/atmel-pwm-bl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index bd1ed34..261b1a4 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c @@ -124,6 +124,7 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) const struct atmel_pwm_bl_platform_data *pdata; struct backlight_device *bldev; struct atmel_pwm_bl *pwmbl; + unsigned long flags; int retval; pdata = dev_get_platdata(&pdev->dev); @@ -149,14 +150,14 @@ static int atmel_pwm_bl_probe(struct platform_device *pdev) return retval; if (gpio_is_valid(pwmbl->gpio_on)) { - retval = devm_gpio_request(&pdev->dev, pwmbl->gpio_on, - "gpio_atmel_pwm_bl"); - if (retval) - goto err_free_pwm; - /* Turn display off by default. */ - retval = gpio_direction_output(pwmbl->gpio_on, - 0 ^ pdata->on_active_low); + if (pdata->on_active_low) + flags = GPIOF_OUT_INIT_HIGH; + else + flags = GPIOF_OUT_INIT_LOW; + + retval = devm_gpio_request_one(&pdev->dev, pwmbl->gpio_on, + flags, "gpio_atmel_pwm_bl"); if (retval) goto err_free_pwm; } -- cgit v1.1 From c962f7b95c98d2b42019cc9cb074886d177ee3a3 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:09:47 -0800 Subject: drivers/video/backlight/hx8357.c: remove redundant of_match_ptr 'hx8357_dt_ids' is always compiled in. Hence of_match_ptr is not needed. Signed-off-by: Sachin Kamat Acked-by: Maxime Ripard Acked-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/backlight/hx8357.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c index 0d252e7..985e854 100644 --- a/drivers/video/backlight/hx8357.c +++ b/drivers/video/backlight/hx8357.c @@ -673,7 +673,7 @@ static struct spi_driver hx8357_driver = { .probe = hx8357_probe, .driver = { .name = "hx8357", - .of_match_table = of_match_ptr(hx8357_dt_ids), + .of_match_table = hx8357_dt_ids, }, }; -- cgit v1.1 From a6dd30e2bc88b3816341534c3cd0ebbecdda3ec6 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Tue, 12 Nov 2013 15:09:55 -0800 Subject: drivers/dma/mmp_tdma.c: use gen_pool_dma_alloc() to allocate descriptor Since gen_pool_dma_alloc() is introduced, we implement it to simplify code. Signed-off-by: Nicolin Chen Cc: Dan Williams Cc: Vinod Koul Cc: Grant Likely Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/dma/mmp_tdma.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/dma/mmp_tdma.c b/drivers/dma/mmp_tdma.c index 38cb517..d3b6358 100644 --- a/drivers/dma/mmp_tdma.c +++ b/drivers/dma/mmp_tdma.c @@ -350,12 +350,7 @@ struct mmp_tdma_desc *mmp_tdma_alloc_descriptor(struct mmp_tdma_chan *tdmac) if (!gpool) return NULL; - tdmac->desc_arr = (void *)gen_pool_alloc(gpool, size); - if (!tdmac->desc_arr) - return NULL; - - tdmac->desc_arr_phys = gen_pool_virt_to_phys(gpool, - (unsigned long)tdmac->desc_arr); + tdmac->desc_arr = gen_pool_dma_alloc(gpool, size, &tdmac->desc_arr_phys); return tdmac->desc_arr; } -- cgit v1.1 From 43f950f454815cca2c39244c7441f9288d7389e0 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Tue, 12 Nov 2013 15:09:56 -0800 Subject: drivers/media/platform/coda.c: use gen_pool_dma_alloc() to allocate iram buffer Since gen_pool_dma_alloc() is introduced, we implement it to simplify code. Signed-off-by: Nicolin Chen Acked-by: Mauro Carvalho Chehab Cc: Grant Likely Cc: Rob Herring Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/platform/coda.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 449d2fe..4993610 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -3232,13 +3232,12 @@ static int coda_probe(struct platform_device *pdev) dev->iram_size = CODA7_IRAM_SIZE; break; } - dev->iram_vaddr = gen_pool_alloc(dev->iram_pool, dev->iram_size); + dev->iram_vaddr = (unsigned long)gen_pool_dma_alloc(dev->iram_pool, + dev->iram_size, (dma_addr_t *)&dev->iram_paddr); if (!dev->iram_vaddr) { dev_err(&pdev->dev, "unable to alloc iram\n"); return -ENOMEM; } - dev->iram_paddr = gen_pool_virt_to_phys(dev->iram_pool, - dev->iram_vaddr); platform_set_drvdata(pdev, dev); -- cgit v1.1 From 288342e9cc867421d20f940d0c06b7aa4bf39096 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Tue, 12 Nov 2013 15:09:57 -0800 Subject: drivers/uio/uio_pruss.c: use gen_pool_dma_alloc() to allocate sram memory Since gen_pool_dma_alloc() is introduced, we implement it to simplify code. Signed-off-by: Nicolin Chen Cc: "Hans J. Koch" Cc: Greg Kroah-Hartman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/uio/uio_pruss.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c index f519da9..96c4a19 100644 --- a/drivers/uio/uio_pruss.c +++ b/drivers/uio/uio_pruss.c @@ -158,14 +158,12 @@ static int pruss_probe(struct platform_device *dev) if (pdata->sram_pool) { gdev->sram_pool = pdata->sram_pool; gdev->sram_vaddr = - gen_pool_alloc(gdev->sram_pool, sram_pool_sz); + (unsigned long)gen_pool_dma_alloc(gdev->sram_pool, + sram_pool_sz, &gdev->sram_paddr); if (!gdev->sram_vaddr) { dev_err(&dev->dev, "Could not allocate SRAM pool\n"); goto out_free; } - gdev->sram_paddr = - gen_pool_virt_to_phys(gdev->sram_pool, - gdev->sram_vaddr); } gdev->ddr_vaddr = dma_alloc_coherent(&dev->dev, extram_pool_sz, -- cgit v1.1 From 008208c6b26f21c2648c250a09c55e737c02c5f8 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Tue, 12 Nov 2013 15:10:01 -0800 Subject: list: introduce list_next_entry() and list_prev_entry() Add two trivial helpers list_next_entry() and list_prev_entry(), they can have a lot of users including list.h itself. In fact the 1st one is already defined in events/core.c and bnx2x_sp.c, so the patch simply moves the definition to list.h. Signed-off-by: Oleg Nesterov Cc: Eilon Greenstein Cc: Greg Kroah-Hartman Cc: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index 9fbeee5..32c92ab 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c @@ -1217,9 +1217,6 @@ static void bnx2x_set_one_vlan_mac_e1h(struct bnx2x *bp, ETH_VLAN_FILTER_CLASSIFY, config); } -#define list_next_entry(pos, member) \ - list_entry((pos)->member.next, typeof(*(pos)), member) - /** * bnx2x_vlan_mac_restore - reconfigure next MAC/VLAN/VLAN-MAC element * -- cgit v1.1 From 10992435b30eb470e6b91d2415abfb79680d00b6 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 12 Nov 2013 15:10:24 -0800 Subject: drivers/message/i2o/driver.c: add missing destroy_workqueue() on error in i2o_driver_register() Add the missing destroy_workqueue() before return from i2o_driver_register() in the error handling case. Signed-off-by: Wei Yongjun Acked-by: Kees Cook Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/message/i2o/driver.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c index b6b92d7..1b18a0d 100644 --- a/drivers/message/i2o/driver.c +++ b/drivers/message/i2o/driver.c @@ -105,7 +105,8 @@ int i2o_driver_register(struct i2o_driver *drv) osm_err("too many drivers registered, increase " "max_drivers\n"); spin_unlock_irqrestore(&i2o_drivers_lock, flags); - return -EFAULT; + rc = -EFAULT; + goto out; } drv->context = i; @@ -124,11 +125,14 @@ int i2o_driver_register(struct i2o_driver *drv) } rc = driver_register(&drv->driver); - if (rc) { - if (drv->event) { - destroy_workqueue(drv->event_queue); - drv->event_queue = NULL; - } + if (rc) + goto out; + + return 0; +out: + if (drv->event_queue) { + destroy_workqueue(drv->event_queue); + drv->event_queue = NULL; } return rc; -- cgit v1.1 From 50ccf0455e51eba51e645b3724c8e932c75774b1 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:25 -0800 Subject: drivers/rtc/rtc-ds1307.c: release irq on error 'client->irq' was not released on error. Fix it. Signed-off-by: Sachin Kamat Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-ds1307.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index ca18fd1..e8ac439 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -956,7 +956,7 @@ read_rtc: GFP_KERNEL); if (!ds1307->nvram) { err = -ENOMEM; - goto exit; + goto err_irq; } ds1307->nvram->attr.name = "nvram"; ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR; @@ -967,13 +967,15 @@ read_rtc: ds1307->nvram_offset = chip->nvram_offset; err = sysfs_create_bin_file(&client->dev.kobj, ds1307->nvram); if (err) - goto exit; + goto err_irq; set_bit(HAS_NVRAM, &ds1307->flags); dev_info(&client->dev, "%zu bytes nvram\n", ds1307->nvram->size); } return 0; +err_irq: + free_irq(client->irq, client); exit: return err; } -- cgit v1.1 From c91fd91d686654f8afbbbca18f5ff0a6ebc9c7a2 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:26 -0800 Subject: drivers/rtc/rtc-isl1208.c: remove redundant checks i2c_smbus_read_byte_data() returns negative errno on failure. Return the value obtained from it directly. Signed-off-by: Sachin Kamat Cc: Herbert Valerio Riedel Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-isl1208.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index c016ad8..5a0bf7c 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c @@ -144,11 +144,7 @@ isl1208_i2c_validate_client(struct i2c_client *client) static int isl1208_i2c_get_sr(struct i2c_client *client) { - int sr = i2c_smbus_read_byte_data(client, ISL1208_REG_SR); - if (sr < 0) - return -EIO; - - return sr; + return i2c_smbus_read_byte_data(client, ISL1208_REG_SR); } static int -- cgit v1.1 From f16189aca0e2c6395e7fd6593c3a3063764c628d Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:27 -0800 Subject: drivers/rtc/rtc-max6900.c: remove redundant checks i2c_smbus_write_byte_data() returns negative errno on failure or 0 on success. Return the value obtained from it directly. Signed-off-by: Sachin Kamat Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-max6900.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c index 55969b1..4804985 100644 --- a/drivers/rtc/rtc-max6900.c +++ b/drivers/rtc/rtc-max6900.c @@ -164,14 +164,7 @@ static int max6900_i2c_read_time(struct i2c_client *client, struct rtc_time *tm) static int max6900_i2c_clear_write_protect(struct i2c_client *client) { - int rc; - rc = i2c_smbus_write_byte_data(client, MAX6900_REG_CONTROL_WRITE, 0); - if (rc < 0) { - dev_err(&client->dev, "%s: control register write failed\n", - __func__); - return -EIO; - } - return 0; + return i2c_smbus_write_byte_data(client, MAX6900_REG_CONTROL_WRITE, 0); } static int -- cgit v1.1 From 58f27d7d061b47f57c84cad7d9af239c6bc6977e Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:28 -0800 Subject: drivers/rtc/rtc-vt8500.c: fix return value Propagate the return value from platform_get_irq() instead of hardcoding. Signed-off-by: Sachin Kamat Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-vt8500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c index c2d6331..5be217d 100644 --- a/drivers/rtc/rtc-vt8500.c +++ b/drivers/rtc/rtc-vt8500.c @@ -228,7 +228,7 @@ static int vt8500_rtc_probe(struct platform_device *pdev) vt8500_rtc->irq_alarm = platform_get_irq(pdev, 0); if (vt8500_rtc->irq_alarm < 0) { dev_err(&pdev->dev, "No alarm IRQ resource defined\n"); - return -ENXIO; + return vt8500_rtc->irq_alarm; } vt8500_rtc->res = devm_request_mem_region(&pdev->dev, -- cgit v1.1 From f3766250b2e9f2920c3c9ef9821827ac82fa7a84 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:29 -0800 Subject: drivers/rtc/rtc-at91rm9200.c: use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-at91rm9200.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index 7418926..8b2cd8a 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c @@ -376,7 +376,8 @@ static int __init at91_rtc_probe(struct platform_device *pdev) return -ENXIO; } - at91_rtc_regs = ioremap(regs->start, resource_size(regs)); + at91_rtc_regs = devm_ioremap(&pdev->dev, regs->start, + resource_size(regs)); if (!at91_rtc_regs) { dev_err(&pdev->dev, "failed to map registers, aborting.\n"); return -ENOMEM; @@ -390,12 +391,12 @@ static int __init at91_rtc_probe(struct platform_device *pdev) AT91_RTC_SECEV | AT91_RTC_TIMEV | AT91_RTC_CALEV); - ret = request_irq(irq, at91_rtc_interrupt, + ret = devm_request_irq(&pdev->dev, irq, at91_rtc_interrupt, IRQF_SHARED, "at91_rtc", pdev); if (ret) { dev_err(&pdev->dev, "IRQ %d already in use.\n", irq); - goto err_unmap; + return ret; } /* cpu init code should really have flagged this device as @@ -404,23 +405,14 @@ static int __init at91_rtc_probe(struct platform_device *pdev) if (!device_can_wakeup(&pdev->dev)) device_init_wakeup(&pdev->dev, 1); - rtc = rtc_device_register(pdev->name, &pdev->dev, + rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &at91_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc)) { - ret = PTR_ERR(rtc); - goto err_free_irq; - } + if (IS_ERR(rtc)) + return PTR_ERR(rtc); platform_set_drvdata(pdev, rtc); dev_info(&pdev->dev, "AT91 Real Time Clock driver.\n"); return 0; - -err_free_irq: - free_irq(irq, pdev); -err_unmap: - iounmap(at91_rtc_regs); - - return ret; } /* @@ -428,16 +420,10 @@ err_unmap: */ static int __exit at91_rtc_remove(struct platform_device *pdev) { - struct rtc_device *rtc = platform_get_drvdata(pdev); - /* Disable all interrupts */ at91_rtc_write_idr(AT91_RTC_ACKUPD | AT91_RTC_ALARM | AT91_RTC_SECEV | AT91_RTC_TIMEV | AT91_RTC_CALEV); - free_irq(irq, pdev); - - rtc_device_unregister(rtc); - iounmap(at91_rtc_regs); return 0; } -- cgit v1.1 From adce8c14c9eaf8e184d9410f4a0bdfa8be07ee6f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:30 -0800 Subject: drivers/rtc/rtc-isl1208.c: use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Cc: Herbert Valerio Riedel Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-isl1208.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index 5a0bf7c..c3c549d 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c @@ -643,10 +643,11 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) "chip found, driver version " DRV_VERSION "\n"); if (client->irq > 0) { - rc = request_threaded_irq(client->irq, NULL, - isl1208_rtc_interrupt, - IRQF_SHARED, - isl1208_driver.driver.name, client); + rc = devm_request_threaded_irq(&client->dev, client->irq, NULL, + isl1208_rtc_interrupt, + IRQF_SHARED, + isl1208_driver.driver.name, + client); if (!rc) { device_init_wakeup(&client->dev, 1); enable_irq_wake(client->irq); @@ -658,20 +659,18 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) } } - rtc = rtc_device_register(isl1208_driver.driver.name, - &client->dev, &isl1208_rtc_ops, + rtc = devm_rtc_device_register(&client->dev, isl1208_driver.driver.name, + &isl1208_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc)) { - rc = PTR_ERR(rtc); - goto exit_free_irq; - } + if (IS_ERR(rtc)) + return PTR_ERR(rtc); i2c_set_clientdata(client, rtc); rc = isl1208_i2c_get_sr(client); if (rc < 0) { dev_err(&client->dev, "reading status failed\n"); - goto exit_unregister; + return rc; } if (rc & ISL1208_REG_SR_RTCF) @@ -680,28 +679,15 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) rc = sysfs_create_group(&client->dev.kobj, &isl1208_rtc_sysfs_files); if (rc) - goto exit_unregister; + return rc; return 0; - -exit_unregister: - rtc_device_unregister(rtc); -exit_free_irq: - if (client->irq) - free_irq(client->irq, client); - - return rc; } static int isl1208_remove(struct i2c_client *client) { - struct rtc_device *rtc = i2c_get_clientdata(client); - sysfs_remove_group(&client->dev.kobj, &isl1208_rtc_sysfs_files); - rtc_device_unregister(rtc); - if (client->irq) - free_irq(client->irq, client); return 0; } -- cgit v1.1 From 3d09162e9976d1ae79dd737849ca63ab6cff6df6 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:31 -0800 Subject: drivers/rtc/rtc-sirfsoc.c: use devm_rtc_device_register devm_rtc_device_register simplifies the code. Signed-off-by: Sachin Kamat Cc: Xianglong Du Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-sirfsoc.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-sirfsoc.c b/drivers/rtc/rtc-sirfsoc.c index 63460cf..1775265 100644 --- a/drivers/rtc/rtc-sirfsoc.c +++ b/drivers/rtc/rtc-sirfsoc.c @@ -274,7 +274,7 @@ static int sirfsoc_rtc_probe(struct platform_device *pdev) err = of_property_read_u32(np, "reg", &rtcdrv->rtc_base); if (err) { dev_err(&pdev->dev, "unable to find base address of rtc node in dtb\n"); - goto error; + return err; } platform_set_drvdata(pdev, rtcdrv); @@ -290,7 +290,7 @@ static int sirfsoc_rtc_probe(struct platform_device *pdev) rtc_div = ((32768 / RTC_HZ) / 2) - 1; sirfsoc_rtc_iobrg_writel(rtc_div, rtcdrv->rtc_base + RTC_DIV); - rtcdrv->rtc = rtc_device_register(pdev->name, &(pdev->dev), + rtcdrv->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &sirfsoc_rtc_ops, THIS_MODULE); if (IS_ERR(rtcdrv->rtc)) { err = PTR_ERR(rtcdrv->rtc); @@ -322,24 +322,15 @@ static int sirfsoc_rtc_probe(struct platform_device *pdev) rtcdrv); if (err) { dev_err(&pdev->dev, "Unable to register for the SiRF SOC RTC IRQ\n"); - goto error; + return err; } return 0; - -error: - if (rtcdrv->rtc) - rtc_device_unregister(rtcdrv->rtc); - - return err; } static int sirfsoc_rtc_remove(struct platform_device *pdev) { - struct sirfsoc_rtc_drv *rtcdrv = platform_get_drvdata(pdev); - device_init_wakeup(&pdev->dev, 0); - rtc_device_unregister(rtcdrv->rtc); return 0; } -- cgit v1.1 From d7d954acb7eb204eeed10cd4494812e9f2e48bd8 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:32 -0800 Subject: drivers/rtc/rtc-cmos.c: remove redundant dev_set_drvdata Driver core sets the driver data to NULL upon device_release or on probe failure. Signed-off-by: Sachin Kamat Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-cmos.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 24e733c..79680b1 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -789,7 +789,6 @@ static void __exit cmos_do_remove(struct device *dev) cmos->iomem = NULL; cmos->dev = NULL; - dev_set_drvdata(dev, NULL); } #ifdef CONFIG_PM -- cgit v1.1 From 8e3dd0d8e9217e5076538e7232e206e024a04b3c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:33 -0800 Subject: drivers/rtc/rtc-mrst.c: remove redundant dev_set_drvdata Driver core sets the driver data to NULL upon device_release or on probe failure. Signed-off-by: Sachin Kamat Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-mrst.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c index 315209d9..e2436d1 100644 --- a/drivers/rtc/rtc-mrst.c +++ b/drivers/rtc/rtc-mrst.c @@ -380,7 +380,6 @@ static int vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, cleanup1: rtc_device_unregister(mrst_rtc.rtc); cleanup0: - dev_set_drvdata(dev, NULL); mrst_rtc.dev = NULL; release_mem_region(iomem->start, resource_size(iomem)); dev_err(dev, "rtc-mrst: unable to initialise\n"); @@ -412,7 +411,6 @@ static void rtc_mrst_do_remove(struct device *dev) mrst->iomem = NULL; mrst->dev = NULL; - dev_set_drvdata(dev, NULL); } #ifdef CONFIG_PM -- cgit v1.1 From 4271e7ff1a9fc49efeff8496d1e21878e7de74eb Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:34 -0800 Subject: drivers/rtc/rtc-vr41xx.c: fix checkpatch warnings Fixes the following warnings: WARNING: Use #include instead of WARNING: Use #include instead of Signed-off-by: Sachin Kamat Cc: Yoichi Yuasa Cc: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-vr41xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index 54e104e..aabc22c 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -27,11 +28,10 @@ #include #include #include +#include #include #include -#include -#include MODULE_AUTHOR("Yoichi Yuasa "); MODULE_DESCRIPTION("NEC VR4100 series RTC driver"); -- cgit v1.1 From b7efdf3b1be423d21fa3106aede5a8bcb9c4d152 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:35 -0800 Subject: drivers/rtc/rtc-sirfsoc.c: remove unneeded casts of void* Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-sirfsoc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-sirfsoc.c b/drivers/rtc/rtc-sirfsoc.c index 1775265..de132b4 100644 --- a/drivers/rtc/rtc-sirfsoc.c +++ b/drivers/rtc/rtc-sirfsoc.c @@ -59,7 +59,7 @@ static int sirfsoc_rtc_read_alarm(struct device *dev, unsigned long rtc_alarm, rtc_count; struct sirfsoc_rtc_drv *rtcdrv; - rtcdrv = (struct sirfsoc_rtc_drv *)dev_get_drvdata(dev); + rtcdrv = dev_get_drvdata(dev); local_irq_disable(); @@ -94,7 +94,7 @@ static int sirfsoc_rtc_set_alarm(struct device *dev, { unsigned long rtc_status_reg, rtc_alarm; struct sirfsoc_rtc_drv *rtcdrv; - rtcdrv = (struct sirfsoc_rtc_drv *)dev_get_drvdata(dev); + rtcdrv = dev_get_drvdata(dev); if (alrm->enabled) { rtc_tm_to_time(&(alrm->time), &rtc_alarm); @@ -157,7 +157,7 @@ static int sirfsoc_rtc_read_time(struct device *dev, { unsigned long tmp_rtc = 0; struct sirfsoc_rtc_drv *rtcdrv; - rtcdrv = (struct sirfsoc_rtc_drv *)dev_get_drvdata(dev); + rtcdrv = dev_get_drvdata(dev); /* * This patch is taken from WinCE - Need to validate this for * correctness. To work around sirfsoc RTC counter double sync logic @@ -178,7 +178,7 @@ static int sirfsoc_rtc_set_time(struct device *dev, { unsigned long rtc_time; struct sirfsoc_rtc_drv *rtcdrv; - rtcdrv = (struct sirfsoc_rtc_drv *)dev_get_drvdata(dev); + rtcdrv = dev_get_drvdata(dev); rtc_tm_to_time(tm, &rtc_time); @@ -364,7 +364,7 @@ static int sirfsoc_rtc_thaw(struct device *dev) { u32 tmp; struct sirfsoc_rtc_drv *rtcdrv; - rtcdrv = (struct sirfsoc_rtc_drv *)dev_get_drvdata(dev); + rtcdrv = dev_get_drvdata(dev); /* * if resume from snapshot and the rtc power is losed, -- cgit v1.1 From b5ebf0780da1846d985998565a51935d10b807da Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:36 -0800 Subject: drivers/rtc/rtc-88pm80x.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-88pm80x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c index 354c937..0916089 100644 --- a/drivers/rtc/rtc-88pm80x.c +++ b/drivers/rtc/rtc-88pm80x.c @@ -251,14 +251,15 @@ static SIMPLE_DEV_PM_OPS(pm80x_rtc_pm_ops, pm80x_rtc_suspend, pm80x_rtc_resume); static int pm80x_rtc_probe(struct platform_device *pdev) { struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent); - struct pm80x_platform_data *pm80x_pdata; + struct pm80x_platform_data *pm80x_pdata = + dev_get_platdata(pdev->dev.parent); struct pm80x_rtc_pdata *pdata = NULL; struct pm80x_rtc_info *info; struct rtc_time tm; unsigned long ticks = 0; int ret; - pdata = pdev->dev.platform_data; + pdata = dev_get_platdata(&pdev->dev); if (pdata == NULL) dev_warn(&pdev->dev, "No platform data!\n"); @@ -326,8 +327,7 @@ static int pm80x_rtc_probe(struct platform_device *pdev) regmap_update_bits(info->map, PM800_RTC_CONTROL, PM800_RTC1_USE_XO, PM800_RTC1_USE_XO); - if (pdev->dev.parent->platform_data) { - pm80x_pdata = pdev->dev.parent->platform_data; + if (pm80x_pdata) { pdata = pm80x_pdata->rtc; if (pdata) info->rtc_dev->dev.platform_data = &pdata->rtc_wakeup; -- cgit v1.1 From 82df0b28557a3e4cad4b8258b19bb61d097da9df Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:37 -0800 Subject: drivers/rtc/rtc-88pm860x.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Acked-by: Haojian Zhuang Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-88pm860x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c index 4e30c85..81650484 100644 --- a/drivers/rtc/rtc-88pm860x.c +++ b/drivers/rtc/rtc-88pm860x.c @@ -316,7 +316,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev) unsigned long ticks = 0; int ret; - pdata = pdev->dev.platform_data; + pdata = dev_get_platdata(&pdev->dev); info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_rtc_info), GFP_KERNEL); -- cgit v1.1 From 97a92e77ca5d3d899619282e3f4cbb94e3162251 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:38 -0800 Subject: drivers/rtc/rtc-cmos.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-cmos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 79680b1..f148762 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -595,7 +595,7 @@ static irqreturn_t cmos_interrupt(int irq, void *p) static int INITSECTION cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) { - struct cmos_rtc_board_info *info = dev->platform_data; + struct cmos_rtc_board_info *info = dev_get_platdata(dev); int retval = 0; unsigned char rtc_control; unsigned address_space; -- cgit v1.1 From d1fa24524899b342690f565a3dbf190fb65cc145 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:39 -0800 Subject: drivers/rtc/rtc-da9055.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-da9055.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-da9055.c b/drivers/rtc/rtc-da9055.c index e00642b..48cb2ac3 100644 --- a/drivers/rtc/rtc-da9055.c +++ b/drivers/rtc/rtc-da9055.c @@ -278,7 +278,7 @@ static int da9055_rtc_probe(struct platform_device *pdev) return -ENOMEM; rtc->da9055 = dev_get_drvdata(pdev->dev.parent); - pdata = rtc->da9055->dev->platform_data; + pdata = dev_get_platdata(rtc->da9055->dev); platform_set_drvdata(pdev, rtc); ret = da9055_rtc_device_init(rtc->da9055, pdata); -- cgit v1.1 From cfa13b249ed5f63db55df6ff123fc8856b48ff9f Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:40 -0800 Subject: drivers/rtc/rtc-ds1305.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-ds1305.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index dd6170a..80f3237 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c @@ -606,7 +606,7 @@ static int ds1305_probe(struct spi_device *spi) struct ds1305 *ds1305; int status; u8 addr, value; - struct ds1305_platform_data *pdata = spi->dev.platform_data; + struct ds1305_platform_data *pdata = dev_get_platdata(&spi->dev); bool write_ctrl = false; /* Sanity check board setup data. This may be hooked up -- cgit v1.1 From 01ce893d37f053a9f76dd461adf4a4715ac388f1 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:41 -0800 Subject: drivers/rtc/rtc-ds1307.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-ds1307.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index e8ac439..bd94920 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -672,7 +672,7 @@ static int ds1307_probe(struct i2c_client *client, struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); int want_irq = false; unsigned char *buf; - struct ds1307_platform_data *pdata = client->dev.platform_data; + struct ds1307_platform_data *pdata = dev_get_platdata(&client->dev); static const int bbsqi_bitpos[] = { [ds_1337] = 0, [ds_1339] = DS1339_BIT_BBSQI, -- cgit v1.1 From 77bf38223c0bf51bb303bc074881b403be3c09b4 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:42 -0800 Subject: drivers/rtc/rtc-ds2404.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-ds2404.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-ds2404.c b/drivers/rtc/rtc-ds2404.c index 2ca5a23..fc209dc 100644 --- a/drivers/rtc/rtc-ds2404.c +++ b/drivers/rtc/rtc-ds2404.c @@ -224,7 +224,7 @@ static const struct rtc_class_ops ds2404_rtc_ops = { static int rtc_probe(struct platform_device *pdev) { - struct ds2404_platform_data *pdata = pdev->dev.platform_data; + struct ds2404_platform_data *pdata = dev_get_platdata(&pdev->dev); struct ds2404 *chip; int retval = -EBUSY; -- cgit v1.1 From 28dc5f803899c14f3096b36b643424717ba2b271 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:43 -0800 Subject: drivers/rtc/rtc-ep93xx.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-ep93xx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 580e7b5..5e4f5dc 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c @@ -42,7 +42,7 @@ struct ep93xx_rtc { static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, unsigned short *delete) { - struct ep93xx_rtc *ep93xx_rtc = dev->platform_data; + struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); unsigned long comp; comp = __raw_readl(ep93xx_rtc->mmio_base + EP93XX_RTC_SWCOMP); @@ -60,7 +60,7 @@ static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm) { - struct ep93xx_rtc *ep93xx_rtc = dev->platform_data; + struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); unsigned long time; time = __raw_readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA); @@ -71,7 +71,7 @@ static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm) static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs) { - struct ep93xx_rtc *ep93xx_rtc = dev->platform_data; + struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); __raw_writel(secs + 1, ep93xx_rtc->mmio_base + EP93XX_RTC_LOAD); return 0; -- cgit v1.1 From 8136032ba50c9e1efdc93b047543fadfc691e884 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:44 -0800 Subject: drivers/rtc/rtc-m48t59.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-m48t59.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index fcb0329..11880c1 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c @@ -68,7 +68,7 @@ m48t59_mem_readb(struct device *dev, u32 ofs) static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct platform_device *pdev = to_platform_device(dev); - struct m48t59_plat_data *pdata = pdev->dev.platform_data; + struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); unsigned long flags; u8 val; @@ -111,7 +111,7 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm) static int m48t59_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct platform_device *pdev = to_platform_device(dev); - struct m48t59_plat_data *pdata = pdev->dev.platform_data; + struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); unsigned long flags; u8 val = 0; @@ -158,7 +158,7 @@ static int m48t59_rtc_set_time(struct device *dev, struct rtc_time *tm) static int m48t59_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) { struct platform_device *pdev = to_platform_device(dev); - struct m48t59_plat_data *pdata = pdev->dev.platform_data; + struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); struct rtc_time *tm = &alrm->time; unsigned long flags; @@ -205,7 +205,7 @@ static int m48t59_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) static int m48t59_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) { struct platform_device *pdev = to_platform_device(dev); - struct m48t59_plat_data *pdata = pdev->dev.platform_data; + struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); struct rtc_time *tm = &alrm->time; u8 mday, hour, min, sec; @@ -266,7 +266,7 @@ static int m48t59_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) static int m48t59_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) { struct platform_device *pdev = to_platform_device(dev); - struct m48t59_plat_data *pdata = pdev->dev.platform_data; + struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); unsigned long flags; @@ -283,7 +283,7 @@ static int m48t59_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) static int m48t59_rtc_proc(struct device *dev, struct seq_file *seq) { struct platform_device *pdev = to_platform_device(dev); - struct m48t59_plat_data *pdata = pdev->dev.platform_data; + struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); unsigned long flags; u8 val; @@ -304,7 +304,7 @@ static irqreturn_t m48t59_rtc_interrupt(int irq, void *dev_id) { struct device *dev = (struct device *)dev_id; struct platform_device *pdev = to_platform_device(dev); - struct m48t59_plat_data *pdata = pdev->dev.platform_data; + struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); u8 event; @@ -340,7 +340,7 @@ static ssize_t m48t59_nvram_read(struct file *filp, struct kobject *kobj, { struct device *dev = container_of(kobj, struct device, kobj); struct platform_device *pdev = to_platform_device(dev); - struct m48t59_plat_data *pdata = pdev->dev.platform_data; + struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); ssize_t cnt = 0; unsigned long flags; @@ -360,7 +360,7 @@ static ssize_t m48t59_nvram_write(struct file *filp, struct kobject *kobj, { struct device *dev = container_of(kobj, struct device, kobj); struct platform_device *pdev = to_platform_device(dev); - struct m48t59_plat_data *pdata = pdev->dev.platform_data; + struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); ssize_t cnt = 0; unsigned long flags; @@ -385,7 +385,7 @@ static struct bin_attribute m48t59_nvram_attr = { static int m48t59_rtc_probe(struct platform_device *pdev) { - struct m48t59_plat_data *pdata = pdev->dev.platform_data; + struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = NULL; struct resource *res; int ret = -ENOMEM; -- cgit v1.1 From b5f0902dcdb5e6f8f1eb8dd083ae56dc8245ab53 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:44 -0800 Subject: drivers/rtc/rtc-m48t86.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-m48t86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c index 2d30314..32f64c9 100644 --- a/drivers/rtc/rtc-m48t86.c +++ b/drivers/rtc/rtc-m48t86.c @@ -46,7 +46,7 @@ static int m48t86_rtc_read_time(struct device *dev, struct rtc_time *tm) { unsigned char reg; struct platform_device *pdev = to_platform_device(dev); - struct m48t86_ops *ops = pdev->dev.platform_data; + struct m48t86_ops *ops = dev_get_platdata(&pdev->dev); reg = ops->readbyte(M48T86_REG_B); @@ -84,7 +84,7 @@ static int m48t86_rtc_set_time(struct device *dev, struct rtc_time *tm) { unsigned char reg; struct platform_device *pdev = to_platform_device(dev); - struct m48t86_ops *ops = pdev->dev.platform_data; + struct m48t86_ops *ops = dev_get_platdata(&pdev->dev); reg = ops->readbyte(M48T86_REG_B); @@ -123,7 +123,7 @@ static int m48t86_rtc_proc(struct device *dev, struct seq_file *seq) { unsigned char reg; struct platform_device *pdev = to_platform_device(dev); - struct m48t86_ops *ops = pdev->dev.platform_data; + struct m48t86_ops *ops = dev_get_platdata(&pdev->dev); reg = ops->readbyte(M48T86_REG_B); @@ -147,7 +147,7 @@ static const struct rtc_class_ops m48t86_rtc_ops = { static int m48t86_rtc_probe(struct platform_device *dev) { unsigned char reg; - struct m48t86_ops *ops = dev->dev.platform_data; + struct m48t86_ops *ops = dev_get_platdata(&dev->dev); struct rtc_device *rtc; rtc = devm_rtc_device_register(&dev->dev, "m48t86", -- cgit v1.1 From ffc75bb8f240b65ecd4e23d7f87863d9f7aeeeff Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:50 -0800 Subject: drivers/rtc/rtc-pcf2123.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-pcf2123.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c index 1725b50..d1953bb 100644 --- a/drivers/rtc/rtc-pcf2123.c +++ b/drivers/rtc/rtc-pcf2123.c @@ -327,7 +327,7 @@ kfree_exit: static int pcf2123_remove(struct spi_device *spi) { - struct pcf2123_plat_data *pdata = spi->dev.platform_data; + struct pcf2123_plat_data *pdata = dev_get_platdata(&spi->dev); int i; if (pdata) { -- cgit v1.1 From f6405afe238f9f16362dd64a814b0381113da67e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:51 -0800 Subject: drivers/rtc/rtc-rs5c348.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-rs5c348.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c index f7a90a1..090a101 100644 --- a/drivers/rtc/rtc-rs5c348.c +++ b/drivers/rtc/rtc-rs5c348.c @@ -64,7 +64,7 @@ static int rs5c348_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct spi_device *spi = to_spi_device(dev); - struct rs5c348_plat_data *pdata = spi->dev.platform_data; + struct rs5c348_plat_data *pdata = dev_get_platdata(&spi->dev); u8 txbuf[5+7], *txp; int ret; @@ -100,7 +100,7 @@ static int rs5c348_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct spi_device *spi = to_spi_device(dev); - struct rs5c348_plat_data *pdata = spi->dev.platform_data; + struct rs5c348_plat_data *pdata = dev_get_platdata(&spi->dev); u8 txbuf[5], rxbuf[7]; int ret; -- cgit v1.1 From e58c18d434a44d0d4402ea08f08c6ed0f4c4ff72 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:52 -0800 Subject: drivers/rtc/rtc-sh.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-sh.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index 6d87e26..d0d2b04 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c @@ -649,8 +649,9 @@ static int __init sh_rtc_probe(struct platform_device *pdev) clk_enable(rtc->clk); rtc->capabilities = RTC_DEF_CAPABILITIES; - if (pdev->dev.platform_data) { - struct sh_rtc_platform_info *pinfo = pdev->dev.platform_data; + if (dev_get_platdata(&pdev->dev)) { + struct sh_rtc_platform_info *pinfo = + dev_get_platdata(&pdev->dev); /* * Some CPUs have special capabilities in addition to the -- cgit v1.1 From a65ddcebabe3e824ab63669e6e14a3352bae4948 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:10:53 -0800 Subject: drivers/rtc/rtc-v3020.c: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-v3020.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c index d07d898..25222cd 100644 --- a/drivers/rtc/rtc-v3020.c +++ b/drivers/rtc/rtc-v3020.c @@ -303,7 +303,7 @@ static const struct rtc_class_ops v3020_rtc_ops = { static int rtc_probe(struct platform_device *pdev) { - struct v3020_platform_data *pdata = pdev->dev.platform_data; + struct v3020_platform_data *pdata = dev_get_platdata(&pdev->dev); struct v3020 *chip; int retval = -EBUSY; int i; -- cgit v1.1 From ce6bafdf94d827bea25bae59bb1abc23d52e5ff7 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:54 -0800 Subject: drivers/rtc/rtc-vt8500.c: remove redundant of_match_ptr The data structure of_match_ptr() protects is always compiled in. Hence of_match_ptr() is not needed. Signed-off-by: Sachin Kamat Cc: Tony Prisk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-vt8500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c index 5be217d..df2ef3e 100644 --- a/drivers/rtc/rtc-vt8500.c +++ b/drivers/rtc/rtc-vt8500.c @@ -296,7 +296,7 @@ static struct platform_driver vt8500_rtc_driver = { .driver = { .name = "vt8500-rtc", .owner = THIS_MODULE, - .of_match_table = of_match_ptr(wmt_dt_ids), + .of_match_table = wmt_dt_ids, }, }; -- cgit v1.1 From 616b734130af858e9e9dce57c9f49ebc75b19869 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:55 -0800 Subject: drivers/rtc/rtc-omap.c: remove redundant of_match_ptr The data structure of_match_ptr() protects is always compiled in. Hence of_match_ptr() is not needed. Signed-off-by: Sachin Kamat Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index c7d97ee..26de5f8 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -553,7 +553,7 @@ static struct platform_driver omap_rtc_driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, .pm = &omap_rtc_pm_ops, - .of_match_table = of_match_ptr(omap_rtc_of_match), + .of_match_table = omap_rtc_of_match, }, .id_table = omap_rtc_devtype, }; -- cgit v1.1 From d149632e037e1d84a058c1e70666d4ced10ae156 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:56 -0800 Subject: drivers/rtc/rtc-sirfsoc.c: remove redundant of_match_ptr The data structure of_match_ptr() protects is always compiled in. Hence of_match_ptr() is not needed. Signed-off-by: Sachin Kamat Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-sirfsoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-sirfsoc.c b/drivers/rtc/rtc-sirfsoc.c index de132b4..3eb3642 100644 --- a/drivers/rtc/rtc-sirfsoc.c +++ b/drivers/rtc/rtc-sirfsoc.c @@ -458,7 +458,7 @@ static struct platform_driver sirfsoc_rtc_driver = { #ifdef CONFIG_PM .pm = &sirfsoc_rtc_pm_ops, #endif - .of_match_table = of_match_ptr(sirfsoc_rtc_of_match), + .of_match_table = sirfsoc_rtc_of_match, }, .probe = sirfsoc_rtc_probe, .remove = sirfsoc_rtc_remove, -- cgit v1.1 From c39b3717b869a0b74e1951416819cc2ec1da629c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:57 -0800 Subject: drivers/rtc/rtc-snvs.c: remove redundant of_match_ptr The data structure of_match_ptr() protects is always compiled in. Hence of_match_ptr() is not needed. Signed-off-by: Sachin Kamat Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-snvs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c index 316a342..fa384fe 100644 --- a/drivers/rtc/rtc-snvs.c +++ b/drivers/rtc/rtc-snvs.c @@ -329,7 +329,7 @@ static struct platform_driver snvs_rtc_driver = { .name = "snvs_rtc", .owner = THIS_MODULE, .pm = &snvs_rtc_pm_ops, - .of_match_table = of_match_ptr(snvs_dt_ids), + .of_match_table = snvs_dt_ids, }, .probe = snvs_rtc_probe, }; -- cgit v1.1 From 462a465be2c4cb376875fe8511e3c2c23aae2227 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:10:58 -0800 Subject: drivers/rtc/rtc-stmp3xxx.c: remove redundant of_match_ptr The data structure of_match_ptr() protects is always compiled in. Hence of_match_ptr() is not needed. Signed-off-by: Sachin Kamat Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-stmp3xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index 2601953..ea96492 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c @@ -343,7 +343,7 @@ static struct platform_driver stmp3xxx_rtcdrv = { .name = "stmp3xxx-rtc", .owner = THIS_MODULE, .pm = &stmp3xxx_rtc_pm_ops, - .of_match_table = of_match_ptr(rtc_dt_ids), + .of_match_table = rtc_dt_ids, }, }; -- cgit v1.1 From c8b18da7769af46455180a61e7c292ec514e47e7 Mon Sep 17 00:00:00 2001 From: Peter Senna Tschudin Date: Tue, 12 Nov 2013 15:10:59 -0800 Subject: drivers/rtc/rtc-ds1307.c: change variable type to bool The variable want_irq is only assigned the values true and false. Change its type to bool. The simplified semantic patch that find this problem is as follows (http://coccinelle.lip6.fr/): @exists@ type T; identifier b; @@ - T + bool b = ...; ... when any b = \(true\|false\) Signed-off-by: Peter Senna Tschudin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-ds1307.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index bd94920..4e75345 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -670,7 +670,7 @@ static int ds1307_probe(struct i2c_client *client, int tmp; const struct chip_desc *chip = &chips[id->driver_data]; struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); - int want_irq = false; + bool want_irq = false; unsigned char *buf; struct ds1307_platform_data *pdata = dev_get_platdata(&client->dev); static const int bbsqi_bitpos[] = { -- cgit v1.1 From a2726061920f43f594e03236d694c71f77adc6a2 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Tue, 12 Nov 2013 15:11:00 -0800 Subject: drivers/rtc/rtc-pl03x.c: remove unnecessary amba_set_drvdata() Driver core clears the driver data to NULL after device_release or on probe failure, so just remove it from here. The relevant driver core change was commit 0998d0631001 ("device-core: Ensure drvdata = NULL when no driver is bound"). Signed-off-by: Michal Simek Cc: Linus Walleij Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-pl030.c | 2 -- drivers/rtc/rtc-pl031.c | 2 -- 2 files changed, 4 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index 22bacdb..a804f75 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c @@ -153,8 +153,6 @@ static int pl030_remove(struct amba_device *dev) { struct pl030_rtc *rtc = amba_get_drvdata(dev); - amba_set_drvdata(dev, NULL); - writel(0, rtc->base + RTC_CR); free_irq(dev->irq[0], rtc); diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index e3b2571..99181fff 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c @@ -305,7 +305,6 @@ static int pl031_remove(struct amba_device *adev) { struct pl031_local *ldata = dev_get_drvdata(&adev->dev); - amba_set_drvdata(adev, NULL); free_irq(adev->irq[0], ldata); rtc_device_unregister(ldata->rtc); iounmap(ldata->base); @@ -391,7 +390,6 @@ out_no_irq: rtc_device_unregister(ldata->rtc); out_no_rtc: iounmap(ldata->base); - amba_set_drvdata(adev, NULL); out_no_remap: kfree(ldata); out: -- cgit v1.1 From 1fbc4c4d79e63709b919bc1a72e991c29ea13f4c Mon Sep 17 00:00:00 2001 From: Sangjung Woo Date: Tue, 12 Nov 2013 15:11:00 -0800 Subject: drivers/rtc/rtc-puv3.c: use dev_dbg() instead of pr_debug() Because dev_*() are used along with pr_debug() function in this code, the debug message is not tidy. This patch converts from pr_debug() to dev_dbg() since dev_*() are encouraged to use in device driver code. Signed-off-by: Sangjung Woo Cc: Guan Xuetao Cc: Alessandro Zummo Cc: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-puv3.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c index 402732c..1ecfe3b 100644 --- a/drivers/rtc/rtc-puv3.c +++ b/drivers/rtc/rtc-puv3.c @@ -53,11 +53,11 @@ static irqreturn_t puv3_rtc_tickirq(int irq, void *id) } /* Update control registers */ -static void puv3_rtc_setaie(int to) +static void puv3_rtc_setaie(struct device *dev, int to) { unsigned int tmp; - pr_debug("%s: aie=%d\n", __func__, to); + dev_dbg(dev, "%s: aie=%d\n", __func__, to); tmp = readl(RTC_RTSR) & ~RTC_RTSR_ALE; @@ -71,7 +71,7 @@ static int puv3_rtc_setpie(struct device *dev, int enabled) { unsigned int tmp; - pr_debug("%s: pie=%d\n", __func__, enabled); + dev_debug(dev, "%s: pie=%d\n", __func__, enabled); spin_lock_irq(&puv3_rtc_pie_lock); tmp = readl(RTC_RTSR) & ~RTC_RTSR_HZE; @@ -90,7 +90,7 @@ static int puv3_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) { rtc_time_to_tm(readl(RTC_RCNR), rtc_tm); - pr_debug("read time %02x.%02x.%02x %02x/%02x/%02x\n", + dev_dbg(dev, "read time %02x.%02x.%02x %02x/%02x/%02x\n", rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); @@ -101,7 +101,7 @@ static int puv3_rtc_settime(struct device *dev, struct rtc_time *tm) { unsigned long rtc_count = 0; - pr_debug("set time %02d.%02d.%02d %02d/%02d/%02d\n", + dev_dbg(dev, "set time %02d.%02d.%02d %02d/%02d/%02d\n", tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); @@ -119,7 +119,7 @@ static int puv3_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) alrm->enabled = readl(RTC_RTSR) & RTC_RTSR_ALE; - pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n", + dev_dbg(dev, "read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n", alrm->enabled, alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec); @@ -132,7 +132,7 @@ static int puv3_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) struct rtc_time *tm = &alrm->time; unsigned long rtcalarm_count = 0; - pr_debug("puv3_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n", + dev_dbg(dev, "puv3_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n", alrm->enabled, tm->tm_mday & 0xff, tm->tm_mon & 0xff, tm->tm_year & 0xff, tm->tm_hour & 0xff, tm->tm_min & 0xff, tm->tm_sec); @@ -140,7 +140,7 @@ static int puv3_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) rtc_tm_to_time(tm, &rtcalarm_count); writel(rtcalarm_count, RTC_RTAR); - puv3_rtc_setaie(alrm->enabled); + puv3_rtc_setaie(&dev->dev, alrm->enabled); if (alrm->enabled) enable_irq_wake(puv3_rtc_alarmno); @@ -227,7 +227,7 @@ static int puv3_rtc_remove(struct platform_device *dev) rtc_device_unregister(rtc); puv3_rtc_setpie(&dev->dev, 0); - puv3_rtc_setaie(0); + puv3_rtc_setaie(&dev->dev, 0); release_resource(puv3_rtc_mem); kfree(puv3_rtc_mem); @@ -241,7 +241,7 @@ static int puv3_rtc_probe(struct platform_device *pdev) struct resource *res; int ret; - pr_debug("%s: probe=%p\n", __func__, pdev); + dev_dbg(&pdev->dev, "%s: probe=%p\n", __func__, pdev); /* find the IRQs */ puv3_rtc_tickno = platform_get_irq(pdev, 1); @@ -256,7 +256,7 @@ static int puv3_rtc_probe(struct platform_device *pdev) return -ENOENT; } - pr_debug("PKUnity_rtc: tick irq %d, alarm irq %d\n", + dev_dbg(&pdev->dev, "PKUnity_rtc: tick irq %d, alarm irq %d\n", puv3_rtc_tickno, puv3_rtc_alarmno); /* get the memory region */ -- cgit v1.1 From 58c181c8255b8f23c5772b4c4d2328450a95081f Mon Sep 17 00:00:00 2001 From: Sangjung Woo Date: Tue, 12 Nov 2013 15:11:02 -0800 Subject: drivers/rtc/rtc-pl030.c: use devm_kzalloc() instead of kmalloc() In order to be free automatically and make the cleanup paths more simple, use devm_kzalloc() instead of kmalloc(). Signed-off-by: Sangjung Woo Cc: Joe Perches Cc: Alessandro Zummo Cc: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-pl030.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index a804f75..f85a1a9 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c @@ -106,7 +106,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) if (ret) goto err_req; - rtc = kmalloc(sizeof(*rtc), GFP_KERNEL); + rtc = devm_kzalloc(&dev->dev, sizeof(*rtc), GFP_KERNEL); if (!rtc) { ret = -ENOMEM; goto err_rtc; @@ -115,7 +115,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) rtc->base = ioremap(dev->res.start, resource_size(&dev->res)); if (!rtc->base) { ret = -ENOMEM; - goto err_map; + goto err_rtc; } __raw_writel(0, rtc->base + RTC_CR); @@ -141,8 +141,6 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) free_irq(dev->irq[0], rtc); err_irq: iounmap(rtc->base); - err_map: - kfree(rtc); err_rtc: amba_release_regions(dev); err_req: @@ -158,7 +156,6 @@ static int pl030_remove(struct amba_device *dev) free_irq(dev->irq[0], rtc); rtc_device_unregister(rtc->rtc); iounmap(rtc->base); - kfree(rtc); amba_release_regions(dev); return 0; -- cgit v1.1 From 5e0d12142e1cf5dc7a8a276fc1fe60b8a5ecb1d3 Mon Sep 17 00:00:00 2001 From: Manish Badarkhe Date: Tue, 12 Nov 2013 15:11:03 -0800 Subject: drivers/rtc/rtc-tps65910.c: remove unnecessary include Currently, driver includes 'pm_runtime.h' which is not used anywhere in code hence remove this unnecessory inclusion. Signed-off-by: Manish Badarkhe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/rtc-tps65910.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c index a9caf04..7af0020 100644 --- a/drivers/rtc/rtc-tps65910.c +++ b/drivers/rtc/rtc-tps65910.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include -- cgit v1.1 From 5bccae6ec4587044779f0b8e6fcb8f87db4181f0 Mon Sep 17 00:00:00 2001 From: Sangbeom Kim Date: Tue, 12 Nov 2013 15:11:04 -0800 Subject: rtc: s5m-rtc: add real-time clock driver for s5m8767 Add real-time clock driver for s5m8767. Signed-off-by: Sangbeom Kim Signed-off-by: Sachin Kamat Cc: Todd Broch Cc: Mark Brown Acked-by: Lee Jones [mfd parts] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-s5m.c | 635 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 646 insertions(+) create mode 100644 drivers/rtc/rtc-s5m.c (limited to 'drivers') diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 9654aa3..4f48b9a 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -497,6 +497,16 @@ config RTC_DRV_RV3029C2 This driver can also be built as a module. If so, the module will be called rtc-rv3029c2. +config RTC_DRV_S5M + tristate "Samsung S5M series" + depends on MFD_SEC_CORE + help + If you say yes here you will get support for the + RTC of Samsung S5M PMIC series. + + This driver can also be built as a module. If so, the module + will be called rtc-s5m. + endif # I2C comment "SPI RTC drivers" diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 2dff3d2..9312e79 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -107,6 +107,7 @@ obj-$(CONFIG_RTC_DRV_RX8025) += rtc-rx8025.o obj-$(CONFIG_RTC_DRV_RX8581) += rtc-rx8581.o obj-$(CONFIG_RTC_DRV_S35390A) += rtc-s35390a.o obj-$(CONFIG_RTC_DRV_S3C) += rtc-s3c.o +obj-$(CONFIG_RTC_DRV_S5M) += rtc-s5m.o obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o obj-$(CONFIG_RTC_DRV_SH) += rtc-sh.o obj-$(CONFIG_RTC_DRV_SNVS) += rtc-snvs.o diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c new file mode 100644 index 0000000..b7fd02b --- /dev/null +++ b/drivers/rtc/rtc-s5m.c @@ -0,0 +1,635 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd + * http://www.samsung.com + * + * Copyright (C) 2013 Google, Inc + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct s5m_rtc_info { + struct device *dev; + struct sec_pmic_dev *s5m87xx; + struct regmap *rtc; + struct rtc_device *rtc_dev; + int irq; + int device_type; + int rtc_24hr_mode; + bool wtsr_smpl; +}; + +static void s5m8767_data_to_tm(u8 *data, struct rtc_time *tm, + int rtc_24hr_mode) +{ + tm->tm_sec = data[RTC_SEC] & 0x7f; + tm->tm_min = data[RTC_MIN] & 0x7f; + if (rtc_24hr_mode) { + tm->tm_hour = data[RTC_HOUR] & 0x1f; + } else { + tm->tm_hour = data[RTC_HOUR] & 0x0f; + if (data[RTC_HOUR] & HOUR_PM_MASK) + tm->tm_hour += 12; + } + + tm->tm_wday = ffs(data[RTC_WEEKDAY] & 0x7f); + tm->tm_mday = data[RTC_DATE] & 0x1f; + tm->tm_mon = (data[RTC_MONTH] & 0x0f) - 1; + tm->tm_year = (data[RTC_YEAR1] & 0x7f) + 100; + tm->tm_yday = 0; + tm->tm_isdst = 0; +} + +static int s5m8767_tm_to_data(struct rtc_time *tm, u8 *data) +{ + data[RTC_SEC] = tm->tm_sec; + data[RTC_MIN] = tm->tm_min; + + if (tm->tm_hour >= 12) + data[RTC_HOUR] = tm->tm_hour | HOUR_PM_MASK; + else + data[RTC_HOUR] = tm->tm_hour & ~HOUR_PM_MASK; + + data[RTC_WEEKDAY] = 1 << tm->tm_wday; + data[RTC_DATE] = tm->tm_mday; + data[RTC_MONTH] = tm->tm_mon + 1; + data[RTC_YEAR1] = tm->tm_year > 100 ? (tm->tm_year - 100) : 0; + + if (tm->tm_year < 100) { + pr_err("s5m8767 RTC cannot handle the year %d.\n", + 1900 + tm->tm_year); + return -EINVAL; + } else { + return 0; + } +} + +static inline int s5m8767_rtc_set_time_reg(struct s5m_rtc_info *info) +{ + int ret; + unsigned int data; + + ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data); + if (ret < 0) { + dev_err(info->dev, "failed to read update reg(%d)\n", ret); + return ret; + } + + data |= RTC_TIME_EN_MASK; + data |= RTC_UDR_MASK; + + ret = regmap_write(info->rtc, SEC_RTC_UDR_CON, data); + if (ret < 0) { + dev_err(info->dev, "failed to write update reg(%d)\n", ret); + return ret; + } + + do { + ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data); + } while ((data & RTC_UDR_MASK) && !ret); + + return ret; +} + +static inline int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info) +{ + int ret; + unsigned int data; + + ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data); + if (ret < 0) { + dev_err(info->dev, "%s: fail to read update reg(%d)\n", + __func__, ret); + return ret; + } + + data &= ~RTC_TIME_EN_MASK; + data |= RTC_UDR_MASK; + + ret = regmap_write(info->rtc, SEC_RTC_UDR_CON, data); + if (ret < 0) { + dev_err(info->dev, "%s: fail to write update reg(%d)\n", + __func__, ret); + return ret; + } + + do { + ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data); + } while ((data & RTC_UDR_MASK) && !ret); + + return ret; +} + +static void s5m8763_data_to_tm(u8 *data, struct rtc_time *tm) +{ + tm->tm_sec = bcd2bin(data[RTC_SEC]); + tm->tm_min = bcd2bin(data[RTC_MIN]); + + if (data[RTC_HOUR] & HOUR_12) { + tm->tm_hour = bcd2bin(data[RTC_HOUR] & 0x1f); + if (data[RTC_HOUR] & HOUR_PM) + tm->tm_hour += 12; + } else { + tm->tm_hour = bcd2bin(data[RTC_HOUR] & 0x3f); + } + + tm->tm_wday = data[RTC_WEEKDAY] & 0x07; + tm->tm_mday = bcd2bin(data[RTC_DATE]); + tm->tm_mon = bcd2bin(data[RTC_MONTH]); + tm->tm_year = bcd2bin(data[RTC_YEAR1]) + bcd2bin(data[RTC_YEAR2]) * 100; + tm->tm_year -= 1900; +} + +static void s5m8763_tm_to_data(struct rtc_time *tm, u8 *data) +{ + data[RTC_SEC] = bin2bcd(tm->tm_sec); + data[RTC_MIN] = bin2bcd(tm->tm_min); + data[RTC_HOUR] = bin2bcd(tm->tm_hour); + data[RTC_WEEKDAY] = tm->tm_wday; + data[RTC_DATE] = bin2bcd(tm->tm_mday); + data[RTC_MONTH] = bin2bcd(tm->tm_mon); + data[RTC_YEAR1] = bin2bcd(tm->tm_year % 100); + data[RTC_YEAR2] = bin2bcd((tm->tm_year + 1900) / 100); +} + +static int s5m_rtc_read_time(struct device *dev, struct rtc_time *tm) +{ + struct s5m_rtc_info *info = dev_get_drvdata(dev); + u8 data[8]; + int ret; + + ret = regmap_bulk_read(info->rtc, SEC_RTC_SEC, data, 8); + if (ret < 0) + return ret; + + switch (info->device_type) { + case S5M8763X: + s5m8763_data_to_tm(data, tm); + break; + + case S5M8767X: + s5m8767_data_to_tm(data, tm, info->rtc_24hr_mode); + break; + + default: + return -EINVAL; + } + + dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, + 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday); + + return rtc_valid_tm(tm); +} + +static int s5m_rtc_set_time(struct device *dev, struct rtc_time *tm) +{ + struct s5m_rtc_info *info = dev_get_drvdata(dev); + u8 data[8]; + int ret = 0; + + switch (info->device_type) { + case S5M8763X: + s5m8763_tm_to_data(tm, data); + break; + case S5M8767X: + ret = s5m8767_tm_to_data(tm, data); + break; + default: + return -EINVAL; + } + + if (ret < 0) + return ret; + + dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, + 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday); + + ret = regmap_raw_write(info->rtc, SEC_RTC_SEC, data, 8); + if (ret < 0) + return ret; + + ret = s5m8767_rtc_set_time_reg(info); + + return ret; +} + +static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) +{ + struct s5m_rtc_info *info = dev_get_drvdata(dev); + u8 data[8]; + unsigned int val; + int ret, i; + + ret = regmap_bulk_read(info->rtc, SEC_ALARM0_SEC, data, 8); + if (ret < 0) + return ret; + + switch (info->device_type) { + case S5M8763X: + s5m8763_data_to_tm(data, &alrm->time); + ret = regmap_read(info->rtc, SEC_ALARM0_CONF, &val); + if (ret < 0) + return ret; + + alrm->enabled = !!val; + + ret = regmap_read(info->rtc, SEC_RTC_STATUS, &val); + if (ret < 0) + return ret; + + break; + + case S5M8767X: + s5m8767_data_to_tm(data, &alrm->time, info->rtc_24hr_mode); + dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, + 1900 + alrm->time.tm_year, 1 + alrm->time.tm_mon, + alrm->time.tm_mday, alrm->time.tm_hour, + alrm->time.tm_min, alrm->time.tm_sec, + alrm->time.tm_wday); + + alrm->enabled = 0; + for (i = 0; i < 7; i++) { + if (data[i] & ALARM_ENABLE_MASK) { + alrm->enabled = 1; + break; + } + } + + alrm->pending = 0; + ret = regmap_read(info->rtc, SEC_RTC_STATUS, &val); + if (ret < 0) + return ret; + break; + + default: + return -EINVAL; + } + + if (val & ALARM0_STATUS) + alrm->pending = 1; + else + alrm->pending = 0; + + return 0; +} + +static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info) +{ + u8 data[8]; + int ret, i; + struct rtc_time tm; + + ret = regmap_bulk_read(info->rtc, SEC_ALARM0_SEC, data, 8); + if (ret < 0) + return ret; + + s5m8767_data_to_tm(data, &tm, info->rtc_24hr_mode); + dev_dbg(info->dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, + 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_wday); + + switch (info->device_type) { + case S5M8763X: + ret = regmap_write(info->rtc, SEC_ALARM0_CONF, 0); + break; + + case S5M8767X: + for (i = 0; i < 7; i++) + data[i] &= ~ALARM_ENABLE_MASK; + + ret = regmap_raw_write(info->rtc, SEC_ALARM0_SEC, data, 8); + if (ret < 0) + return ret; + + ret = s5m8767_rtc_set_alarm_reg(info); + + break; + + default: + return -EINVAL; + } + + return ret; +} + +static int s5m_rtc_start_alarm(struct s5m_rtc_info *info) +{ + int ret; + u8 data[8]; + u8 alarm0_conf; + struct rtc_time tm; + + ret = regmap_bulk_read(info->rtc, SEC_ALARM0_SEC, data, 8); + if (ret < 0) + return ret; + + s5m8767_data_to_tm(data, &tm, info->rtc_24hr_mode); + dev_dbg(info->dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, + 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_wday); + + switch (info->device_type) { + case S5M8763X: + alarm0_conf = 0x77; + ret = regmap_write(info->rtc, SEC_ALARM0_CONF, alarm0_conf); + break; + + case S5M8767X: + data[RTC_SEC] |= ALARM_ENABLE_MASK; + data[RTC_MIN] |= ALARM_ENABLE_MASK; + data[RTC_HOUR] |= ALARM_ENABLE_MASK; + data[RTC_WEEKDAY] &= ~ALARM_ENABLE_MASK; + if (data[RTC_DATE] & 0x1f) + data[RTC_DATE] |= ALARM_ENABLE_MASK; + if (data[RTC_MONTH] & 0xf) + data[RTC_MONTH] |= ALARM_ENABLE_MASK; + if (data[RTC_YEAR1] & 0x7f) + data[RTC_YEAR1] |= ALARM_ENABLE_MASK; + + ret = regmap_raw_write(info->rtc, SEC_ALARM0_SEC, data, 8); + if (ret < 0) + return ret; + ret = s5m8767_rtc_set_alarm_reg(info); + + break; + + default: + return -EINVAL; + } + + return ret; +} + +static int s5m_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) +{ + struct s5m_rtc_info *info = dev_get_drvdata(dev); + u8 data[8]; + int ret; + + switch (info->device_type) { + case S5M8763X: + s5m8763_tm_to_data(&alrm->time, data); + break; + + case S5M8767X: + s5m8767_tm_to_data(&alrm->time, data); + break; + + default: + return -EINVAL; + } + + dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, + 1900 + alrm->time.tm_year, 1 + alrm->time.tm_mon, + alrm->time.tm_mday, alrm->time.tm_hour, alrm->time.tm_min, + alrm->time.tm_sec, alrm->time.tm_wday); + + ret = s5m_rtc_stop_alarm(info); + if (ret < 0) + return ret; + + ret = regmap_raw_write(info->rtc, SEC_ALARM0_SEC, data, 8); + if (ret < 0) + return ret; + + ret = s5m8767_rtc_set_alarm_reg(info); + if (ret < 0) + return ret; + + if (alrm->enabled) + ret = s5m_rtc_start_alarm(info); + + return ret; +} + +static int s5m_rtc_alarm_irq_enable(struct device *dev, + unsigned int enabled) +{ + struct s5m_rtc_info *info = dev_get_drvdata(dev); + + if (enabled) + return s5m_rtc_start_alarm(info); + else + return s5m_rtc_stop_alarm(info); +} + +static irqreturn_t s5m_rtc_alarm_irq(int irq, void *data) +{ + struct s5m_rtc_info *info = data; + + rtc_update_irq(info->rtc_dev, 1, RTC_IRQF | RTC_AF); + + return IRQ_HANDLED; +} + +static const struct rtc_class_ops s5m_rtc_ops = { + .read_time = s5m_rtc_read_time, + .set_time = s5m_rtc_set_time, + .read_alarm = s5m_rtc_read_alarm, + .set_alarm = s5m_rtc_set_alarm, + .alarm_irq_enable = s5m_rtc_alarm_irq_enable, +}; + +static void s5m_rtc_enable_wtsr(struct s5m_rtc_info *info, bool enable) +{ + int ret; + ret = regmap_update_bits(info->rtc, SEC_WTSR_SMPL_CNTL, + WTSR_ENABLE_MASK, + enable ? WTSR_ENABLE_MASK : 0); + if (ret < 0) + dev_err(info->dev, "%s: fail to update WTSR reg(%d)\n", + __func__, ret); +} + +static void s5m_rtc_enable_smpl(struct s5m_rtc_info *info, bool enable) +{ + int ret; + ret = regmap_update_bits(info->rtc, SEC_WTSR_SMPL_CNTL, + SMPL_ENABLE_MASK, + enable ? SMPL_ENABLE_MASK : 0); + if (ret < 0) + dev_err(info->dev, "%s: fail to update SMPL reg(%d)\n", + __func__, ret); +} + +static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info) +{ + u8 data[2]; + unsigned int tp_read; + int ret; + struct rtc_time tm; + + ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &tp_read); + if (ret < 0) { + dev_err(info->dev, "%s: fail to read control reg(%d)\n", + __func__, ret); + return ret; + } + + /* Set RTC control register : Binary mode, 24hour mode */ + data[0] = (1 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT); + data[1] = (0 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT); + + info->rtc_24hr_mode = 1; + ret = regmap_raw_write(info->rtc, SEC_ALARM0_CONF, data, 2); + if (ret < 0) { + dev_err(info->dev, "%s: fail to write controlm reg(%d)\n", + __func__, ret); + return ret; + } + + /* In first boot time, Set rtc time to 1/1/2012 00:00:00(SUN) */ + if ((tp_read & RTC_TCON_MASK) == 0) { + dev_dbg(info->dev, "rtc init\n"); + tm.tm_sec = 0; + tm.tm_min = 0; + tm.tm_hour = 0; + tm.tm_wday = 0; + tm.tm_mday = 1; + tm.tm_mon = 0; + tm.tm_year = 112; + tm.tm_yday = 0; + tm.tm_isdst = 0; + ret = s5m_rtc_set_time(info->dev, &tm); + } + + ret = regmap_update_bits(info->rtc, SEC_RTC_UDR_CON, + RTC_TCON_MASK, tp_read | RTC_TCON_MASK); + if (ret < 0) + dev_err(info->dev, "%s: fail to update TCON reg(%d)\n", + __func__, ret); + + return ret; +} + +static int s5m_rtc_probe(struct platform_device *pdev) +{ + struct sec_pmic_dev *s5m87xx = dev_get_drvdata(pdev->dev.parent); + struct sec_platform_data *pdata = s5m87xx->pdata; + struct s5m_rtc_info *info; + int ret; + + if (!pdata) { + dev_err(pdev->dev.parent, "Platform data not supplied\n"); + return -ENODEV; + } + + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + info->dev = &pdev->dev; + info->s5m87xx = s5m87xx; + info->rtc = s5m87xx->rtc; + info->device_type = s5m87xx->device_type; + info->wtsr_smpl = s5m87xx->wtsr_smpl; + + switch (pdata->device_type) { + case S5M8763X: + info->irq = s5m87xx->irq_base + S5M8763_IRQ_ALARM0; + break; + + case S5M8767X: + info->irq = s5m87xx->irq_base + S5M8767_IRQ_RTCA1; + break; + + default: + ret = -EINVAL; + dev_err(&pdev->dev, "Unsupported device type: %d\n", ret); + return ret; + } + + platform_set_drvdata(pdev, info); + + ret = s5m8767_rtc_init_reg(info); + + if (info->wtsr_smpl) { + s5m_rtc_enable_wtsr(info, true); + s5m_rtc_enable_smpl(info, true); + } + + device_init_wakeup(&pdev->dev, 1); + + info->rtc_dev = devm_rtc_device_register(&pdev->dev, "s5m-rtc", + &s5m_rtc_ops, THIS_MODULE); + + if (IS_ERR(info->rtc_dev)) + return PTR_ERR(info->rtc_dev); + + ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, + s5m_rtc_alarm_irq, 0, "rtc-alarm0", + info); + if (ret < 0) + dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", + info->irq, ret); + + return ret; +} + +static void s5m_rtc_shutdown(struct platform_device *pdev) +{ + struct s5m_rtc_info *info = platform_get_drvdata(pdev); + int i; + unsigned int val = 0; + if (info->wtsr_smpl) { + for (i = 0; i < 3; i++) { + s5m_rtc_enable_wtsr(info, false); + regmap_read(info->rtc, SEC_WTSR_SMPL_CNTL, &val); + pr_debug("%s: WTSR_SMPL reg(0x%02x)\n", __func__, val); + if (val & WTSR_ENABLE_MASK) + pr_emerg("%s: fail to disable WTSR\n", + __func__); + else { + pr_info("%s: success to disable WTSR\n", + __func__); + break; + } + } + } + /* Disable SMPL when power off */ + s5m_rtc_enable_smpl(info, false); +} + +static const struct platform_device_id s5m_rtc_id[] = { + { "s5m-rtc", 0 }, +}; + +static struct platform_driver s5m_rtc_driver = { + .driver = { + .name = "s5m-rtc", + .owner = THIS_MODULE, + }, + .probe = s5m_rtc_probe, + .shutdown = s5m_rtc_shutdown, + .id_table = s5m_rtc_id, +}; + +module_platform_driver(s5m_rtc_driver); + +/* Module information */ +MODULE_AUTHOR("Sangbeom Kim "); +MODULE_DESCRIPTION("Samsung S5M RTC driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:s5m-rtc"); -- cgit v1.1 From b45062619840a56c090bab57df7b0fb36a30c2af Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 12 Nov 2013 15:11:05 -0800 Subject: drivers/rtc/rtc-as3722: add RTC driver The ams AS3722 is a compact system PMU suitable for mobile phones, tablets etc. Add a driver to support accessing the RTC found on the ams AS3722 PMIC using RTC framework. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Laxman Dewangan Signed-off-by: Florian Lobmaier Cc: Mark Brown Cc: Linus Walleij Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-as3722.c | 275 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 286 insertions(+) create mode 100644 drivers/rtc/rtc-as3722.c (limited to 'drivers') diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 4f48b9a..15f166a 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -153,6 +153,16 @@ config RTC_DRV_88PM80X This driver can also be built as a module. If so, the module will be called rtc-88pm80x. +config RTC_DRV_AS3722 + tristate "ams AS3722 RTC driver" + depends on MFD_AS3722 + help + If you say yes here you get support for the RTC of ams AS3722 PMIC + chips. + + This driver can also be built as a module. If so, the module + will be called rtc-as3722. + config RTC_DRV_DS1307 tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025" help diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 9312e79..27b4bd8 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o obj-$(CONFIG_RTC_DRV_88PM80X) += rtc-88pm80x.o obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o +obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o diff --git a/drivers/rtc/rtc-as3722.c b/drivers/rtc/rtc-as3722.c new file mode 100644 index 0000000..9cfa817 --- /dev/null +++ b/drivers/rtc/rtc-as3722.c @@ -0,0 +1,275 @@ +/* + * rtc-as3722.c - Real Time Clock driver for ams AS3722 PMICs + * + * Copyright (C) 2013 ams AG + * Copyright (c) 2013, NVIDIA Corporation. All rights reserved. + * + * Author: Florian Lobmaier + * Author: Laxman Dewangan + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AS3722_RTC_START_YEAR 2000 +struct as3722_rtc { + struct rtc_device *rtc; + struct device *dev; + struct as3722 *as3722; + int alarm_irq; + bool irq_enable; +}; + +static void as3722_time_to_reg(u8 *rbuff, struct rtc_time *tm) +{ + rbuff[0] = bin2bcd(tm->tm_sec); + rbuff[1] = bin2bcd(tm->tm_min); + rbuff[2] = bin2bcd(tm->tm_hour); + rbuff[3] = bin2bcd(tm->tm_mday); + rbuff[4] = bin2bcd(tm->tm_mon); + rbuff[5] = bin2bcd(tm->tm_year - (AS3722_RTC_START_YEAR - 1900)); +} + +static void as3722_reg_to_time(u8 *rbuff, struct rtc_time *tm) +{ + tm->tm_sec = bcd2bin(rbuff[0] & 0x7F); + tm->tm_min = bcd2bin(rbuff[1] & 0x7F); + tm->tm_hour = bcd2bin(rbuff[2] & 0x3F); + tm->tm_mday = bcd2bin(rbuff[3] & 0x3F); + tm->tm_mon = bcd2bin(rbuff[4] & 0x1F); + tm->tm_year = (AS3722_RTC_START_YEAR - 1900) + bcd2bin(rbuff[5] & 0x7F); + return; +} + +static int as3722_rtc_read_time(struct device *dev, struct rtc_time *tm) +{ + struct as3722_rtc *as3722_rtc = dev_get_drvdata(dev); + struct as3722 *as3722 = as3722_rtc->as3722; + u8 as_time_array[6]; + int ret; + + ret = as3722_block_read(as3722, AS3722_RTC_SECOND_REG, + 6, as_time_array); + if (ret < 0) { + dev_err(dev, "RTC_SECOND reg block read failed %d\n", ret); + return ret; + } + as3722_reg_to_time(as_time_array, tm); + return 0; +} + +static int as3722_rtc_set_time(struct device *dev, struct rtc_time *tm) +{ + struct as3722_rtc *as3722_rtc = dev_get_drvdata(dev); + struct as3722 *as3722 = as3722_rtc->as3722; + u8 as_time_array[6]; + int ret; + + if (tm->tm_year < (AS3722_RTC_START_YEAR - 1900)) + return -EINVAL; + + as3722_time_to_reg(as_time_array, tm); + ret = as3722_block_write(as3722, AS3722_RTC_SECOND_REG, 6, + as_time_array); + if (ret < 0) + dev_err(dev, "RTC_SECOND reg block write failed %d\n", ret); + return ret; +} + +static int as3722_rtc_alarm_irq_enable(struct device *dev, + unsigned int enabled) +{ + struct as3722_rtc *as3722_rtc = dev_get_drvdata(dev); + + if (enabled && !as3722_rtc->irq_enable) { + enable_irq(as3722_rtc->alarm_irq); + as3722_rtc->irq_enable = true; + } else if (!enabled && as3722_rtc->irq_enable) { + disable_irq(as3722_rtc->alarm_irq); + as3722_rtc->irq_enable = false; + } + return 0; +} + +static int as3722_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) +{ + struct as3722_rtc *as3722_rtc = dev_get_drvdata(dev); + struct as3722 *as3722 = as3722_rtc->as3722; + u8 as_time_array[6]; + int ret; + + ret = as3722_block_read(as3722, AS3722_RTC_ALARM_SECOND_REG, 6, + as_time_array); + if (ret < 0) { + dev_err(dev, "RTC_ALARM_SECOND block read failed %d\n", ret); + return ret; + } + + as3722_reg_to_time(as_time_array, &alrm->time); + return 0; +} + +static int as3722_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) +{ + struct as3722_rtc *as3722_rtc = dev_get_drvdata(dev); + struct as3722 *as3722 = as3722_rtc->as3722; + u8 as_time_array[6]; + int ret; + + if (alrm->time.tm_year < (AS3722_RTC_START_YEAR - 1900)) + return -EINVAL; + + ret = as3722_rtc_alarm_irq_enable(dev, 0); + if (ret < 0) { + dev_err(dev, "Disable RTC alarm failed\n"); + return ret; + } + + as3722_time_to_reg(as_time_array, &alrm->time); + ret = as3722_block_write(as3722, AS3722_RTC_ALARM_SECOND_REG, 6, + as_time_array); + if (ret < 0) { + dev_err(dev, "RTC_ALARM_SECOND block write failed %d\n", ret); + return ret; + } + + if (alrm->enabled) + ret = as3722_rtc_alarm_irq_enable(dev, alrm->enabled); + return ret; +} + +static irqreturn_t as3722_alarm_irq(int irq, void *data) +{ + struct as3722_rtc *as3722_rtc = data; + + rtc_update_irq(as3722_rtc->rtc, 1, RTC_IRQF | RTC_AF); + return IRQ_HANDLED; +} + +static const struct rtc_class_ops as3722_rtc_ops = { + .read_time = as3722_rtc_read_time, + .set_time = as3722_rtc_set_time, + .read_alarm = as3722_rtc_read_alarm, + .set_alarm = as3722_rtc_set_alarm, + .alarm_irq_enable = as3722_rtc_alarm_irq_enable, +}; + +static int as3722_rtc_probe(struct platform_device *pdev) +{ + struct as3722 *as3722 = dev_get_drvdata(pdev->dev.parent); + struct as3722_rtc *as3722_rtc; + int ret; + + as3722_rtc = devm_kzalloc(&pdev->dev, sizeof(*as3722_rtc), GFP_KERNEL); + if (!as3722_rtc) + return -ENOMEM; + + as3722_rtc->as3722 = as3722; + as3722_rtc->dev = &pdev->dev; + platform_set_drvdata(pdev, as3722_rtc); + + /* Enable the RTC to make sure it is running. */ + ret = as3722_update_bits(as3722, AS3722_RTC_CONTROL_REG, + AS3722_RTC_ON | AS3722_RTC_ALARM_WAKEUP_EN, + AS3722_RTC_ON | AS3722_RTC_ALARM_WAKEUP_EN); + if (ret < 0) { + dev_err(&pdev->dev, "RTC_CONTROL reg write failed: %d\n", ret); + return ret; + } + + device_init_wakeup(&pdev->dev, 1); + + as3722_rtc->rtc = rtc_device_register("as3722", &pdev->dev, + &as3722_rtc_ops, THIS_MODULE); + if (IS_ERR(as3722_rtc->rtc)) { + ret = PTR_ERR(as3722_rtc->rtc); + dev_err(&pdev->dev, "RTC register failed: %d\n", ret); + return ret; + } + + as3722_rtc->alarm_irq = platform_get_irq(pdev, 0); + dev_info(&pdev->dev, "RTC interrupt %d\n", as3722_rtc->alarm_irq); + + ret = request_threaded_irq(as3722_rtc->alarm_irq, NULL, + as3722_alarm_irq, IRQF_ONESHOT | IRQF_EARLY_RESUME, + "rtc-alarm", as3722_rtc); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to request alarm IRQ %d: %d\n", + as3722_rtc->alarm_irq, ret); + goto scrub; + } + disable_irq(as3722_rtc->alarm_irq); + return 0; +scrub: + rtc_device_unregister(as3722_rtc->rtc); + return ret; +} + +static int as3722_rtc_remove(struct platform_device *pdev) +{ + struct as3722_rtc *as3722_rtc = platform_get_drvdata(pdev); + + free_irq(as3722_rtc->alarm_irq, as3722_rtc); + rtc_device_unregister(as3722_rtc->rtc); + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int as3722_rtc_suspend(struct device *dev) +{ + struct as3722_rtc *as3722_rtc = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + enable_irq_wake(as3722_rtc->alarm_irq); + + return 0; +} + +static int as3722_rtc_resume(struct device *dev) +{ + struct as3722_rtc *as3722_rtc = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + disable_irq_wake(as3722_rtc->alarm_irq); + return 0; +} +#endif + +static const struct dev_pm_ops as3722_rtc_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(as3722_rtc_suspend, as3722_rtc_resume) +}; + +static struct platform_driver as3722_rtc_driver = { + .probe = as3722_rtc_probe, + .remove = as3722_rtc_remove, + .driver = { + .name = "as3722-rtc", + .pm = &as3722_rtc_pm_ops, + }, +}; +module_platform_driver(as3722_rtc_driver); + +MODULE_DESCRIPTION("RTC driver for AS3722 PMICs"); +MODULE_ALIAS("platform:as3722-rtc"); +MODULE_AUTHOR("Florian Lobmaier "); +MODULE_AUTHOR("Laxman Dewangan "); +MODULE_LICENSE("GPL"); -- cgit v1.1 From 1a10bd9424d463e550676e74f4875863d1bae3f5 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 12 Nov 2013 15:11:33 -0800 Subject: drivers/pps/clients/pps-gpio.c: remove redundant of_match_ptr The data structure of_match_ptr() protects is always compiled in. Hence of_match_ptr() is not needed. Signed-off-by: Sachin Kamat Cc: Rodolfo Giometti Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pps/clients/pps-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c index 9966124..f41bacf 100644 --- a/drivers/pps/clients/pps-gpio.c +++ b/drivers/pps/clients/pps-gpio.c @@ -201,7 +201,7 @@ static struct platform_driver pps_gpio_driver = { .driver = { .name = PPS_GPIO_NAME, .owner = THIS_MODULE, - .of_match_table = of_match_ptr(pps_gpio_dt_ids), + .of_match_table = pps_gpio_dt_ids, }, }; -- cgit v1.1 From be2d3f97e90cdf9f1523daaba705f320c3efaf00 Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Tue, 12 Nov 2013 15:11:39 -0800 Subject: drivers/memstick/core/mspro_block.c: fix attributes array allocation attrs field of attribute_group structure is a pointer to a pointer (as in an array of pointers) rather than pointer to attribute struct (as in an array of structures), so when allocating size of the pointer sholud be used instead of the structure it is pointing to. While at it, also change the call to use kcalloc rather than kzalloc. Signed-off-by: Michal Nazarewicz Cc: Tejun Heo Cc: Al Viro Cc: Alex Dubov Cc: Maxim Levitsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/memstick/core/mspro_block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index f4176ca..fc145d2 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c @@ -1023,8 +1023,8 @@ static int mspro_block_read_attributes(struct memstick_dev *card) } else attr_count = attr->count; - msb->attr_group.attrs = kzalloc((attr_count + 1) - * sizeof(struct attribute), + msb->attr_group.attrs = kcalloc(attr_count + 1, + sizeof(*msb->attr_group.attrs), GFP_KERNEL); if (!msb->attr_group.attrs) { rc = -ENOMEM; -- cgit v1.1 From a0e5a12fd18d47aa87a7a8c60ca5bc422b136564 Mon Sep 17 00:00:00 2001 From: Roger Tseng Date: Tue, 12 Nov 2013 15:11:40 -0800 Subject: drivers/memstick/core/ms_block.c: fix unreachable state in h_msb_read_page() In h_msb_read_page() in ms_block.c, flow never reaches case MSB_RP_RECIVE_STATUS_REG. This causes error when MEMSTICK_INT_ERR is encountered and status error bits are going to be examined, but the status will never be copied back. Fix it by transitioning to MSB_RP_RECIVE_STATUS_REG right after MSB_RP_SEND_READ_STATUS_REG. Signed-off-by: Roger Tseng Acked-by: Maxim Levitsky Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/memstick/core/ms_block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c index 08e7023..9188ef5 100644 --- a/drivers/memstick/core/ms_block.c +++ b/drivers/memstick/core/ms_block.c @@ -401,7 +401,7 @@ again: sizeof(struct ms_status_register))) return 0; - msb->state = MSB_RP_RECEIVE_OOB_READ; + msb->state = MSB_RP_RECIVE_STATUS_REG; return 0; case MSB_RP_RECIVE_STATUS_REG: -- cgit v1.1 From 75f9e937d24fdf661ebd5c9bed05caa4aad90539 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 12 Nov 2013 15:11:41 -0800 Subject: drivers/w1/masters/ds1wm.cuse dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Acked-by: Evgeniy Polyakov Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/w1/masters/ds1wm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c index 41613f9..02df3b1 100644 --- a/drivers/w1/masters/ds1wm.c +++ b/drivers/w1/masters/ds1wm.c @@ -255,17 +255,17 @@ static int ds1wm_find_divisor(int gclk) static void ds1wm_up(struct ds1wm_data *ds1wm_data) { int divisor; - struct ds1wm_driver_data *plat = ds1wm_data->pdev->dev.platform_data; + struct device *dev = &ds1wm_data->pdev->dev; + struct ds1wm_driver_data *plat = dev_get_platdata(dev); if (ds1wm_data->cell->enable) ds1wm_data->cell->enable(ds1wm_data->pdev); divisor = ds1wm_find_divisor(plat->clock_rate); - dev_dbg(&ds1wm_data->pdev->dev, - "found divisor 0x%x for clock %d\n", divisor, plat->clock_rate); + dev_dbg(dev, "found divisor 0x%x for clock %d\n", + divisor, plat->clock_rate); if (divisor == 0) { - dev_err(&ds1wm_data->pdev->dev, - "no suitable divisor for %dHz clock\n", + dev_err(dev, "no suitable divisor for %dHz clock\n", plat->clock_rate); return; } @@ -481,7 +481,7 @@ static int ds1wm_probe(struct platform_device *pdev) ds1wm_data->cell = mfd_get_cell(pdev); if (!ds1wm_data->cell) return -ENODEV; - plat = pdev->dev.platform_data; + plat = dev_get_platdata(&pdev->dev); if (!plat) return -ENODEV; -- cgit v1.1 From bb67093796a41e0f2601f5c0022fd8873ed59fee Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Tue, 12 Nov 2013 15:11:42 -0800 Subject: drivers: w1: make w1_slave::flags long to avoid memory corruption On architectures where long is more then 32 bits, modifying a 32-bit field with set_bit (and other atomic bit operations) may cause bytes following the field to by modified. Because the endianness of the bits within a field is the native endianness of the CPU[1], on big-endian machines, bit number zero is in the last byte of the field. Therefore, `set_bit(0, ptr)' on a 64-bit big-endian machine is roughly equivalent to `((char *)ptr)[7] |= 1', and since w1 driver uses a 32-bit field for holding the flags, this causes bytes beyond the field to be modified. [1] From Documentation/atomic_ops.txt: Native atomic bit operations are defined to operate on objects aligned to the size of an "unsigned long" C data type, and are least of that size. The endianness of the bits within each "unsigned long" are the native endianness of the cpu. Signed-off-by: Michal Nazarewicz Cc: Evgeniy Polyakov Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/w1/w1.c | 10 +++++----- drivers/w1/w1.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index fa932c2..66efa96 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -709,7 +709,7 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn) sl->owner = THIS_MODULE; sl->master = dev; - set_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags); + set_bit(W1_SLAVE_ACTIVE, &sl->flags); memset(&msg, 0, sizeof(msg)); memcpy(&sl->reg_num, rn, sizeof(sl->reg_num)); @@ -866,7 +866,7 @@ void w1_slave_found(struct w1_master *dev, u64 rn) sl = w1_slave_search_device(dev, tmp); if (sl) { - set_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags); + set_bit(W1_SLAVE_ACTIVE, &sl->flags); } else { if (rn && tmp->crc == w1_calc_crc8((u8 *)&rn_le, 7)) w1_attach_slave_device(dev, tmp); @@ -984,14 +984,14 @@ void w1_search_process_cb(struct w1_master *dev, u8 search_type, struct w1_slave *sl, *sln; list_for_each_entry(sl, &dev->slist, w1_slave_entry) - clear_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags); + clear_bit(W1_SLAVE_ACTIVE, &sl->flags); w1_search_devices(dev, search_type, cb); list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { - if (!test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags) && !--sl->ttl) + if (!test_bit(W1_SLAVE_ACTIVE, &sl->flags) && !--sl->ttl) w1_slave_detach(sl); - else if (test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags)) + else if (test_bit(W1_SLAVE_ACTIVE, &sl->flags)) sl->ttl = dev->slave_ttl; } diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index 45908e5..ca8081a 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h @@ -67,8 +67,8 @@ struct w1_slave struct w1_reg_num reg_num; atomic_t refcnt; u8 rom[9]; - u32 flags; int ttl; + unsigned long flags; struct w1_master *master; struct w1_family *family; -- cgit v1.1