[PATCH] proc: report eip and esp for all threads when coredumping

2019-05-22 Thread Jan Luebbe
Commit 0a1eb2d474ed ("fs/proc: Stop reporting eip and esp in
/proc/PID/stat") stopped reporting eip/esp and commit fd7d56270b52
("fs/proc: Report eip/esp in /prod/PID/stat for coredumping")
reintroduced the feature to fix a regression with userspace core dump
handlers (such as minicoredumper).

Because PF_DUMPCORE is only set for the primary thread, this didn't fix
the original problem for secondary threads. This commit checks
mm->core_state instead, as already done for /proc//status in
task_core_dumping(). As we have a mm_struct available here anyway, this
seems to be a clean solution.

Signed-off-by: Jan Luebbe 
---
 fs/proc/array.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 2edbb657f859..b76b1e29fc36 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -462,7 +462,7 @@ static int do_task_stat(struct seq_file *m, struct 
pid_namespace *ns,
 * a program is not able to use ptrace(2) in that case. It is
 * safe because the task has stopped executing permanently.
 */
-   if (permitted && (task->flags & PF_DUMPCORE)) {
+   if (permitted && (!!mm->core_state)) {
if (try_get_task_stack(task)) {
eip = KSTK_EIP(task);
esp = KSTK_ESP(task);
-- 
2.11.0



[RFC] ARM: Orion: Check DRAM window size

2017-08-28 Thread Jan Luebbe
This is a corresponding change as "PCI: mvebu: Check DRAM window size" applied
to the Orion PCIe driver. I don't have the relevant hardware myself, but the
patch may still be useful for someone who has. This is completely untested.

Signed-off-by: Jan Luebbe <j...@pengutronix.de>
---
 arch/arm/mach-dove/pcie.c|  3 ++-
 arch/arm/mach-mv78xx0/pcie.c |  3 ++-
 arch/arm/mach-orion5x/pci.c  |  3 ++-
 arch/arm/plat-orion/pcie.c   | 19 +++
 4 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c
index 91fe97144570..27e4689ee58d 100644
--- a/arch/arm/mach-dove/pcie.c
+++ b/arch/arm/mach-dove/pcie.c
@@ -51,7 +51,8 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data 
*sys)
 */
orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
 
-   orion_pcie_setup(pp->base);
+   if (!orion_pcie_setup(pp->base))
+   return 0;
 
if (pp->index == 0)
pci_ioremap_io(sys->busnr * SZ_64K, DOVE_PCIE0_IO_PHYS_BASE);
diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c
index 81ff4327a962..3d17eeff44bf 100644
--- a/arch/arm/mach-mv78xx0/pcie.c
+++ b/arch/arm/mach-mv78xx0/pcie.c
@@ -113,7 +113,8 @@ static int __init mv78xx0_pcie_setup(int nr, struct 
pci_sys_data *sys)
 * Generic PCIe unit setup.
 */
orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
-   orion_pcie_setup(pp->base);
+   if (!orion_pcie_setup(pp->base))
+   return 0;
 
pci_ioremap_io(nr * SZ_64K, MV78XX0_PCIE_IO_PHYS_BASE(nr));
 
diff --git a/arch/arm/mach-orion5x/pci.c b/arch/arm/mach-orion5x/pci.c
index ecb998e7f8dc..f7f830872cc9 100644
--- a/arch/arm/mach-orion5x/pci.c
+++ b/arch/arm/mach-orion5x/pci.c
@@ -147,7 +147,8 @@ static int __init pcie_setup(struct pci_sys_data *sys)
/*
 * Generic PCIe unit setup.
 */
-   orion_pcie_setup(PCIE_BASE);
+   if (!orion_pcie_setup(PCIE_BASE))
+   return 0;
 
/*
 * Check whether to apply Orion-1/Orion-NAS PCIe config
diff --git a/arch/arm/plat-orion/pcie.c b/arch/arm/plat-orion/pcie.c
index 8b8c06d2e9c4..07ae382cf48a 100644
--- a/arch/arm/plat-orion/pcie.c
+++ b/arch/arm/plat-orion/pcie.c
@@ -120,10 +120,10 @@ void __init orion_pcie_reset(void __iomem *base)
  * BAR[0,2] -> disabled, BAR[1] -> covers all DRAM banks
  * WIN[0-3] -> DRAM bank[0-3]
  */
-static void __init orion_pcie_setup_wins(void __iomem *base)
+static int __init orion_pcie_setup_wins(void __iomem *base)
 {
const struct mbus_dram_target_info *dram;
-   u32 size;
+   u64 size;
int i;
 
dram = mv_mbus_dram_info();
@@ -170,15 +170,23 @@ static void __init orion_pcie_setup_wins(void __iomem 
*base)
if ((size & (size - 1)) != 0)
size = 1 << fls(size);
 
+   if (size > 0x1) {
+   pr_err("Could not configure DRAM window (too large): 0x%llx\n",
+  size);
+   return 0;
+   }
+
/*
 * Setup BAR[1] to all DRAM banks.
 */
writel(dram->cs[0].base, base + PCIE_BAR_LO_OFF(1));
writel(0, base + PCIE_BAR_HI_OFF(1));
writel(((size - 1) & 0x) | 1, base + PCIE_BAR_CTRL_OFF(1));
+
+   return 1;
 }
 
-void __init orion_pcie_setup(void __iomem *base)
+int __init orion_pcie_setup(void __iomem *base)
 {
u16 cmd;
u32 mask;
@@ -186,7 +194,8 @@ void __init orion_pcie_setup(void __iomem *base)
/*
 * Point PCIe unit MBUS decode windows to DRAM space.
 */
-   orion_pcie_setup_wins(base);
+   if (!orion_pcie_setup_wins(base))
+   return 0;
 
/*
 * Master + slave enable.
@@ -203,6 +212,8 @@ void __init orion_pcie_setup(void __iomem *base)
mask = readl(base + PCIE_MASK_OFF);
mask |= 0x0f00;
writel(mask, base + PCIE_MASK_OFF);
+
+   return 1;
 }
 
 int orion_pcie_rd_conf(void __iomem *base, struct pci_bus *bus,
-- 
2.11.0



[RFC] ARM: Orion: Check DRAM window size

2017-08-28 Thread Jan Luebbe
This is a corresponding change as "PCI: mvebu: Check DRAM window size" applied
to the Orion PCIe driver. I don't have the relevant hardware myself, but the
patch may still be useful for someone who has. This is completely untested.

Signed-off-by: Jan Luebbe 
---
 arch/arm/mach-dove/pcie.c|  3 ++-
 arch/arm/mach-mv78xx0/pcie.c |  3 ++-
 arch/arm/mach-orion5x/pci.c  |  3 ++-
 arch/arm/plat-orion/pcie.c   | 19 +++
 4 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c
index 91fe97144570..27e4689ee58d 100644
--- a/arch/arm/mach-dove/pcie.c
+++ b/arch/arm/mach-dove/pcie.c
@@ -51,7 +51,8 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data 
*sys)
 */
orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
 
-   orion_pcie_setup(pp->base);
+   if (!orion_pcie_setup(pp->base))
+   return 0;
 
if (pp->index == 0)
pci_ioremap_io(sys->busnr * SZ_64K, DOVE_PCIE0_IO_PHYS_BASE);
diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c
index 81ff4327a962..3d17eeff44bf 100644
--- a/arch/arm/mach-mv78xx0/pcie.c
+++ b/arch/arm/mach-mv78xx0/pcie.c
@@ -113,7 +113,8 @@ static int __init mv78xx0_pcie_setup(int nr, struct 
pci_sys_data *sys)
 * Generic PCIe unit setup.
 */
orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
-   orion_pcie_setup(pp->base);
+   if (!orion_pcie_setup(pp->base))
+   return 0;
 
pci_ioremap_io(nr * SZ_64K, MV78XX0_PCIE_IO_PHYS_BASE(nr));
 
diff --git a/arch/arm/mach-orion5x/pci.c b/arch/arm/mach-orion5x/pci.c
index ecb998e7f8dc..f7f830872cc9 100644
--- a/arch/arm/mach-orion5x/pci.c
+++ b/arch/arm/mach-orion5x/pci.c
@@ -147,7 +147,8 @@ static int __init pcie_setup(struct pci_sys_data *sys)
/*
 * Generic PCIe unit setup.
 */
-   orion_pcie_setup(PCIE_BASE);
+   if (!orion_pcie_setup(PCIE_BASE))
+   return 0;
 
/*
 * Check whether to apply Orion-1/Orion-NAS PCIe config
diff --git a/arch/arm/plat-orion/pcie.c b/arch/arm/plat-orion/pcie.c
index 8b8c06d2e9c4..07ae382cf48a 100644
--- a/arch/arm/plat-orion/pcie.c
+++ b/arch/arm/plat-orion/pcie.c
@@ -120,10 +120,10 @@ void __init orion_pcie_reset(void __iomem *base)
  * BAR[0,2] -> disabled, BAR[1] -> covers all DRAM banks
  * WIN[0-3] -> DRAM bank[0-3]
  */
-static void __init orion_pcie_setup_wins(void __iomem *base)
+static int __init orion_pcie_setup_wins(void __iomem *base)
 {
const struct mbus_dram_target_info *dram;
-   u32 size;
+   u64 size;
int i;
 
dram = mv_mbus_dram_info();
@@ -170,15 +170,23 @@ static void __init orion_pcie_setup_wins(void __iomem 
*base)
if ((size & (size - 1)) != 0)
size = 1 << fls(size);
 
+   if (size > 0x1) {
+   pr_err("Could not configure DRAM window (too large): 0x%llx\n",
+  size);
+   return 0;
+   }
+
/*
 * Setup BAR[1] to all DRAM banks.
 */
writel(dram->cs[0].base, base + PCIE_BAR_LO_OFF(1));
writel(0, base + PCIE_BAR_HI_OFF(1));
writel(((size - 1) & 0x) | 1, base + PCIE_BAR_CTRL_OFF(1));
+
+   return 1;
 }
 
-void __init orion_pcie_setup(void __iomem *base)
+int __init orion_pcie_setup(void __iomem *base)
 {
u16 cmd;
u32 mask;
@@ -186,7 +194,8 @@ void __init orion_pcie_setup(void __iomem *base)
/*
 * Point PCIe unit MBUS decode windows to DRAM space.
 */
-   orion_pcie_setup_wins(base);
+   if (!orion_pcie_setup_wins(base))
+   return 0;
 
/*
 * Master + slave enable.
@@ -203,6 +212,8 @@ void __init orion_pcie_setup(void __iomem *base)
mask = readl(base + PCIE_MASK_OFF);
mask |= 0x0f00;
writel(mask, base + PCIE_MASK_OFF);
+
+   return 1;
 }
 
 int orion_pcie_rd_conf(void __iomem *base, struct pci_bus *bus,
-- 
2.11.0



[PATCH 2/2] PCI: mvebu: Check DRAM window size

2017-08-28 Thread Jan Luebbe
The sum of the DRAM windows may exceed 4GB (at least on Armada XP).
Return an error in that case.

Signed-off-by: Jan Luebbe <j...@pengutronix.de>
---
 drivers/pci/host/pci-mvebu.c | 27 ++-
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index f353a6eb2f01..5d74af81d104 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -206,10 +206,10 @@ static void mvebu_pcie_set_local_dev_nr(struct 
mvebu_pcie_port *port, int nr)
  * BAR[0,2] -> disabled, BAR[1] -> covers all DRAM banks
  * WIN[0-3] -> DRAM bank[0-3]
  */
-static void mvebu_pcie_setup_wins(struct mvebu_pcie_port *port)
+static int mvebu_pcie_setup_wins(struct mvebu_pcie_port *port)
 {
const struct mbus_dram_target_info *dram;
-   u32 size;
+   u64 size;
int i;
 
dram = mv_mbus_dram_info();
@@ -252,19 +252,32 @@ static void mvebu_pcie_setup_wins(struct mvebu_pcie_port 
*port)
if ((size & (size - 1)) != 0)
size = 1 << fls(size);
 
+   if (size > 0x1) {
+   dev_err(>pcie->pdev->dev,
+   "Could not configure DRAM window (too large): 0x%llx\n",
+   size);
+
+   return -EINVAL;
+   }
+
/* Setup BAR[1] to all DRAM banks. */
mvebu_writel(port, dram->cs[0].base, PCIE_BAR_LO_OFF(1));
mvebu_writel(port, 0, PCIE_BAR_HI_OFF(1));
mvebu_writel(port, ((size - 1) & 0x) | 1,
 PCIE_BAR_CTRL_OFF(1));
+
+   return 0;
 }
 
-static void mvebu_pcie_setup_hw(struct mvebu_pcie_port *port)
+static int mvebu_pcie_setup_hw(struct mvebu_pcie_port *port)
 {
u32 cmd, mask;
+   int ret;
 
/* Point PCIe unit MBUS decode windows to DRAM space. */
-   mvebu_pcie_setup_wins(port);
+   ret = mvebu_pcie_setup_wins(port);
+   if (ret)
+   return ret;
 
/* Master + slave enable. */
cmd = mvebu_readl(port, PCIE_CMD_OFF);
@@ -277,6 +290,8 @@ static void mvebu_pcie_setup_hw(struct mvebu_pcie_port 
*port)
mask = mvebu_readl(port, PCIE_MASK_OFF);
mask |= PCIE_MASK_ENABLE_INTS;
mvebu_writel(port, mask, PCIE_MASK_OFF);
+
+   return 0;
 }
 
 static int mvebu_pcie_hw_rd_conf(struct mvebu_pcie_port *port,
@@ -882,7 +897,9 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data 
*sys)
 
if (!port->base)
continue;
-   mvebu_pcie_setup_hw(port);
+   err = mvebu_pcie_setup_hw(port);
+   if (err)
+   return 0;
}
 
return 1;
-- 
2.11.0



[PATCH 2/2] PCI: mvebu: Check DRAM window size

2017-08-28 Thread Jan Luebbe
The sum of the DRAM windows may exceed 4GB (at least on Armada XP).
Return an error in that case.

Signed-off-by: Jan Luebbe 
---
 drivers/pci/host/pci-mvebu.c | 27 ++-
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index f353a6eb2f01..5d74af81d104 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -206,10 +206,10 @@ static void mvebu_pcie_set_local_dev_nr(struct 
mvebu_pcie_port *port, int nr)
  * BAR[0,2] -> disabled, BAR[1] -> covers all DRAM banks
  * WIN[0-3] -> DRAM bank[0-3]
  */
-static void mvebu_pcie_setup_wins(struct mvebu_pcie_port *port)
+static int mvebu_pcie_setup_wins(struct mvebu_pcie_port *port)
 {
const struct mbus_dram_target_info *dram;
-   u32 size;
+   u64 size;
int i;
 
dram = mv_mbus_dram_info();
@@ -252,19 +252,32 @@ static void mvebu_pcie_setup_wins(struct mvebu_pcie_port 
*port)
if ((size & (size - 1)) != 0)
size = 1 << fls(size);
 
+   if (size > 0x1) {
+   dev_err(>pcie->pdev->dev,
+   "Could not configure DRAM window (too large): 0x%llx\n",
+   size);
+
+   return -EINVAL;
+   }
+
/* Setup BAR[1] to all DRAM banks. */
mvebu_writel(port, dram->cs[0].base, PCIE_BAR_LO_OFF(1));
mvebu_writel(port, 0, PCIE_BAR_HI_OFF(1));
mvebu_writel(port, ((size - 1) & 0x) | 1,
 PCIE_BAR_CTRL_OFF(1));
+
+   return 0;
 }
 
-static void mvebu_pcie_setup_hw(struct mvebu_pcie_port *port)
+static int mvebu_pcie_setup_hw(struct mvebu_pcie_port *port)
 {
u32 cmd, mask;
+   int ret;
 
/* Point PCIe unit MBUS decode windows to DRAM space. */
-   mvebu_pcie_setup_wins(port);
+   ret = mvebu_pcie_setup_wins(port);
+   if (ret)
+   return ret;
 
/* Master + slave enable. */
cmd = mvebu_readl(port, PCIE_CMD_OFF);
@@ -277,6 +290,8 @@ static void mvebu_pcie_setup_hw(struct mvebu_pcie_port 
*port)
mask = mvebu_readl(port, PCIE_MASK_OFF);
mask |= PCIE_MASK_ENABLE_INTS;
mvebu_writel(port, mask, PCIE_MASK_OFF);
+
+   return 0;
 }
 
 static int mvebu_pcie_hw_rd_conf(struct mvebu_pcie_port *port,
@@ -882,7 +897,9 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data 
*sys)
 
if (!port->base)
continue;
-   mvebu_pcie_setup_hw(port);
+   err = mvebu_pcie_setup_hw(port);
+   if (err)
+   return 0;
}
 
return 1;
-- 
2.11.0



[PATCH 1/2] bus: mbus: fix window size calculation for 4GB windows

2017-08-28 Thread Jan Luebbe
At least the Armada XP SoC supports 4GB on a single DRAM window. Because
the size register values contain the actual size - 1, the MSB is set in
that case. For example, the SDRAM window's control register's value is
0xffe1 for 4GB (bits 31 to 24 contain the size).

The MBUS driver reads back each window's size from registers and
calculates the actual size as (control_reg | ~DDR_SIZE_MASK) + 1, which
overflows for 32 bit values, resulting in other miscalculations further
on (a bad RAM window for the CESA crypto engine calculated by
mvebu_mbus_setup_cpu_target_nooverlap() in my case).

This patch changes the type in 'struct mbus_dram_window' from u32 to
u64, which allows us to keep using the same register calculation code in
most MBUS-using drivers (which calculate ->size - 1 again).

Signed-off-by: Jan Luebbe <j...@pengutronix.de>
---
 drivers/bus/mvebu-mbus.c | 2 +-
 include/linux/mbus.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index c7f396903184..70db4d5638a6 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -720,7 +720,7 @@ mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state 
*mbus)
if (mbus->hw_io_coherency)
w->mbus_attr |= ATTR_HW_COHERENCY;
w->base = base & DDR_BASE_CS_LOW_MASK;
-   w->size = (size | ~DDR_SIZE_MASK) + 1;
+   w->size = (u64)(size | ~DDR_SIZE_MASK) + 1;
}
}
mvebu_mbus_dram_info.num_cs = cs;
diff --git a/include/linux/mbus.h b/include/linux/mbus.h
index 0d3f14fd2621..4773145246ed 100644
--- a/include/linux/mbus.h
+++ b/include/linux/mbus.h
@@ -31,8 +31,8 @@ struct mbus_dram_target_info
struct mbus_dram_window {
u8  cs_index;
u8  mbus_attr;
-   u32 base;
-   u32 size;
+   u64 base;
+   u64 size;
} cs[4];
 };
 
-- 
2.11.0



[PATCH 1/2] bus: mbus: fix window size calculation for 4GB windows

2017-08-28 Thread Jan Luebbe
At least the Armada XP SoC supports 4GB on a single DRAM window. Because
the size register values contain the actual size - 1, the MSB is set in
that case. For example, the SDRAM window's control register's value is
0xffe1 for 4GB (bits 31 to 24 contain the size).

The MBUS driver reads back each window's size from registers and
calculates the actual size as (control_reg | ~DDR_SIZE_MASK) + 1, which
overflows for 32 bit values, resulting in other miscalculations further
on (a bad RAM window for the CESA crypto engine calculated by
mvebu_mbus_setup_cpu_target_nooverlap() in my case).

This patch changes the type in 'struct mbus_dram_window' from u32 to
u64, which allows us to keep using the same register calculation code in
most MBUS-using drivers (which calculate ->size - 1 again).

Signed-off-by: Jan Luebbe 
---
 drivers/bus/mvebu-mbus.c | 2 +-
 include/linux/mbus.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index c7f396903184..70db4d5638a6 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -720,7 +720,7 @@ mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state 
*mbus)
if (mbus->hw_io_coherency)
w->mbus_attr |= ATTR_HW_COHERENCY;
w->base = base & DDR_BASE_CS_LOW_MASK;
-   w->size = (size | ~DDR_SIZE_MASK) + 1;
+   w->size = (u64)(size | ~DDR_SIZE_MASK) + 1;
}
}
mvebu_mbus_dram_info.num_cs = cs;
diff --git a/include/linux/mbus.h b/include/linux/mbus.h
index 0d3f14fd2621..4773145246ed 100644
--- a/include/linux/mbus.h
+++ b/include/linux/mbus.h
@@ -31,8 +31,8 @@ struct mbus_dram_target_info
struct mbus_dram_window {
u8  cs_index;
u8  mbus_attr;
-   u32 base;
-   u32 size;
+   u64 base;
+   u64 size;
} cs[4];
 };
 
-- 
2.11.0



[PATCH 0/2] fix 4GB DRAM window support on mvebu

2017-08-28 Thread Jan Luebbe
The current MBUS DRAM window calculation fails for 4GB windows because it
overflows. This is fixed in the first patch by using u64 instead of u32 to
store the size. The second excplicitly checks that we don't try to configure a
too large memory window in the pci driver.

As they don't depend on each other, they could also go in separatly.

Jan Luebbe (2):
  bus: mbus: fix window size calculation for 4GB windows
  PCI: mvebu: Check DRAM window size

 drivers/bus/mvebu-mbus.c |  2 +-
 drivers/pci/host/pci-mvebu.c | 27 ++-
 include/linux/mbus.h |  4 ++--
 3 files changed, 25 insertions(+), 8 deletions(-)

-- 
2.11.0



[PATCH 0/2] fix 4GB DRAM window support on mvebu

2017-08-28 Thread Jan Luebbe
The current MBUS DRAM window calculation fails for 4GB windows because it
overflows. This is fixed in the first patch by using u64 instead of u32 to
store the size. The second excplicitly checks that we don't try to configure a
too large memory window in the pci driver.

As they don't depend on each other, they could also go in separatly.

Jan Luebbe (2):
  bus: mbus: fix window size calculation for 4GB windows
  PCI: mvebu: Check DRAM window size

 drivers/bus/mvebu-mbus.c |  2 +-
 drivers/pci/host/pci-mvebu.c | 27 ++-
 include/linux/mbus.h |  4 ++--
 3 files changed, 25 insertions(+), 8 deletions(-)

-- 
2.11.0



[PATCH] eeprom: fix Kconfig typo (swtich)

2017-06-19 Thread Jan Luebbe
Signed-off-by: Jan Luebbe <j...@pengutronix.de>
---
 drivers/misc/eeprom/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/eeprom/Kconfig b/drivers/misc/eeprom/Kconfig
index de58762097c4..d1c8cd5b33e2 100644
--- a/drivers/misc/eeprom/Kconfig
+++ b/drivers/misc/eeprom/Kconfig
@@ -101,11 +101,11 @@ config EEPROM_DIGSY_MTC_CFG
  If unsure, say N.
 
 config EEPROM_IDT_89HPESX
-   tristate "IDT 89HPESx PCIe-swtiches EEPROM / CSR support"
+   tristate "IDT 89HPESx PCIe-switches EEPROM / CSR support"
depends on I2C && SYSFS
help
  Enable this driver to get read/write access to EEPROM / CSRs
- over IDT PCIe-swtich i2c-slave interface.
+ over IDT PCIe-switch i2c-slave interface.
 
  This driver can also be built as a module. If so, the module
  will be called idt_89hpesx.
-- 
2.11.0



[PATCH] eeprom: fix Kconfig typo (swtich)

2017-06-19 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---
 drivers/misc/eeprom/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/eeprom/Kconfig b/drivers/misc/eeprom/Kconfig
index de58762097c4..d1c8cd5b33e2 100644
--- a/drivers/misc/eeprom/Kconfig
+++ b/drivers/misc/eeprom/Kconfig
@@ -101,11 +101,11 @@ config EEPROM_DIGSY_MTC_CFG
  If unsure, say N.
 
 config EEPROM_IDT_89HPESX
-   tristate "IDT 89HPESx PCIe-swtiches EEPROM / CSR support"
+   tristate "IDT 89HPESx PCIe-switches EEPROM / CSR support"
depends on I2C && SYSFS
help
  Enable this driver to get read/write access to EEPROM / CSRs
- over IDT PCIe-swtich i2c-slave interface.
+ over IDT PCIe-switch i2c-slave interface.
 
  This driver can also be built as a module. If so, the module
  will be called idt_89hpesx.
-- 
2.11.0



[PATCH v2] pps-gpio: add device-tree binding and support

2013-06-01 Thread Jan Luebbe
Instead of allocating a struct pps_gpio_platform_data in the DT case, store
the necessary information in struct pps_gpio_device_data itself. This avoids
an additional allocation and the ifdef. It also gets rid of some indirection.

Also use dev_err instead of pr_err in the changed code.

Signed-off-by: Jan Luebbe 

---
This patch depends on my two recent pps-gpio patches, which are currently
in Andrew Morton's mmotm. So it should probably also go via Andrew if it
is acceptable.

Changes since v1:
  - Do not allocate a pdata struct, store info in pps_gpio_device_data.
Also fold the two calls from pps_gpio_setup into the probe function.
(suggested by Arnd Bergmann)

 Documentation/devicetree/bindings/pps/pps-gpio.txt |   20 +++
 drivers/pps/clients/pps-gpio.c |  128 +++-
 2 files changed, 93 insertions(+), 55 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pps/pps-gpio.txt

diff --git a/Documentation/devicetree/bindings/pps/pps-gpio.txt 
b/Documentation/devicetree/bindings/pps/pps-gpio.txt
new file mode 100644
index 000..40bf9c3
--- /dev/null
+++ b/Documentation/devicetree/bindings/pps/pps-gpio.txt
@@ -0,0 +1,20 @@
+Device-Tree Bindings for a PPS Signal on GPIO
+
+These properties describe a PPS (pulse-per-second) signal connected to
+a GPIO pin.
+
+Required properties:
+- compatible: should be "pps-gpio"
+- gpios: one PPS GPIO in the format described by ../gpio/gpio.txt
+
+Optional properties:
+- assert-falling-edge: when present, assert is indicated by a falling edge
+   (instead of by a rising edge)
+
+Example:
+   pps {
+   compatible = "pps-gpio";
+   gpios = < 6 0>;
+
+   assert-falling-edge;
+   };
diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 6768f95..eae0eda 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -33,13 +33,17 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* Info for each registered platform device */
 struct pps_gpio_device_data {
int irq;/* IRQ used as PPS source */
struct pps_device *pps; /* PPS source device */
struct pps_source_info info;/* PPS source information */
-   const struct pps_gpio_platform_data *pdata;
+   bool assert_falling_edge;
+   bool capture_clear;
+   unsigned int gpio_pin;
 };
 
 /*
@@ -57,45 +61,25 @@ static irqreturn_t pps_gpio_irq_handler(int irq, void *data)
 
info = data;
 
-   rising_edge = gpio_get_value(info->pdata->gpio_pin);
-   if ((rising_edge && !info->pdata->assert_falling_edge) ||
-   (!rising_edge && info->pdata->assert_falling_edge))
+   rising_edge = gpio_get_value(info->gpio_pin);
+   if ((rising_edge && !info->assert_falling_edge) ||
+   (!rising_edge && info->assert_falling_edge))
pps_event(info->pps, , PPS_CAPTUREASSERT, NULL);
-   else if (info->pdata->capture_clear &&
-   ((rising_edge && info->pdata->assert_falling_edge) ||
-(!rising_edge && !info->pdata->assert_falling_edge)))
+   else if (info->capture_clear &&
+   ((rising_edge && info->assert_falling_edge) ||
+(!rising_edge && !info->assert_falling_edge)))
pps_event(info->pps, , PPS_CAPTURECLEAR, NULL);
 
return IRQ_HANDLED;
 }
 
-static int pps_gpio_setup(struct platform_device *pdev)
-{
-   int ret;
-   const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
-
-   ret = devm_gpio_request(>dev, pdata->gpio_pin, pdata->gpio_label);
-   if (ret) {
-   pr_warning("failed to request GPIO %u\n", pdata->gpio_pin);
-   return -EINVAL;
-   }
-
-   ret = gpio_direction_input(pdata->gpio_pin);
-   if (ret) {
-   pr_warning("failed to set pin direction\n");
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
 static unsigned long
-get_irqf_trigger_flags(const struct pps_gpio_platform_data *pdata)
+get_irqf_trigger_flags(const struct pps_gpio_device_data *data)
 {
-   unsigned long flags = pdata->assert_falling_edge ?
+   unsigned long flags = data->assert_falling_edge ?
IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
 
-   if (pdata->capture_clear) {
+   if (data->capture_clear) {
flags |= ((flags & IRQF_TRIGGER_RISING) ?
IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING);
}
@@ -106,35 +90,63 @@ get_irqf_trigger_flags(const struct pps_gpio_platform_data 
*pdata)
 static int pps_gpio_probe(stru

[PATCH v2] pps-gpio: add device-tree binding and support

2013-06-01 Thread Jan Luebbe
Instead of allocating a struct pps_gpio_platform_data in the DT case, store
the necessary information in struct pps_gpio_device_data itself. This avoids
an additional allocation and the ifdef. It also gets rid of some indirection.

Also use dev_err instead of pr_err in the changed code.

Signed-off-by: Jan Luebbe j...@pengutronix.de

---
This patch depends on my two recent pps-gpio patches, which are currently
in Andrew Morton's mmotm. So it should probably also go via Andrew if it
is acceptable.

Changes since v1:
  - Do not allocate a pdata struct, store info in pps_gpio_device_data.
Also fold the two calls from pps_gpio_setup into the probe function.
(suggested by Arnd Bergmann)

 Documentation/devicetree/bindings/pps/pps-gpio.txt |   20 +++
 drivers/pps/clients/pps-gpio.c |  128 +++-
 2 files changed, 93 insertions(+), 55 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pps/pps-gpio.txt

diff --git a/Documentation/devicetree/bindings/pps/pps-gpio.txt 
b/Documentation/devicetree/bindings/pps/pps-gpio.txt
new file mode 100644
index 000..40bf9c3
--- /dev/null
+++ b/Documentation/devicetree/bindings/pps/pps-gpio.txt
@@ -0,0 +1,20 @@
+Device-Tree Bindings for a PPS Signal on GPIO
+
+These properties describe a PPS (pulse-per-second) signal connected to
+a GPIO pin.
+
+Required properties:
+- compatible: should be pps-gpio
+- gpios: one PPS GPIO in the format described by ../gpio/gpio.txt
+
+Optional properties:
+- assert-falling-edge: when present, assert is indicated by a falling edge
+   (instead of by a rising edge)
+
+Example:
+   pps {
+   compatible = pps-gpio;
+   gpios = gpio2 6 0;
+
+   assert-falling-edge;
+   };
diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 6768f95..eae0eda 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -33,13 +33,17 @@
 #include linux/pps-gpio.h
 #include linux/gpio.h
 #include linux/list.h
+#include linux/of_device.h
+#include linux/of_gpio.h
 
 /* Info for each registered platform device */
 struct pps_gpio_device_data {
int irq;/* IRQ used as PPS source */
struct pps_device *pps; /* PPS source device */
struct pps_source_info info;/* PPS source information */
-   const struct pps_gpio_platform_data *pdata;
+   bool assert_falling_edge;
+   bool capture_clear;
+   unsigned int gpio_pin;
 };
 
 /*
@@ -57,45 +61,25 @@ static irqreturn_t pps_gpio_irq_handler(int irq, void *data)
 
info = data;
 
-   rising_edge = gpio_get_value(info-pdata-gpio_pin);
-   if ((rising_edge  !info-pdata-assert_falling_edge) ||
-   (!rising_edge  info-pdata-assert_falling_edge))
+   rising_edge = gpio_get_value(info-gpio_pin);
+   if ((rising_edge  !info-assert_falling_edge) ||
+   (!rising_edge  info-assert_falling_edge))
pps_event(info-pps, ts, PPS_CAPTUREASSERT, NULL);
-   else if (info-pdata-capture_clear 
-   ((rising_edge  info-pdata-assert_falling_edge) ||
-(!rising_edge  !info-pdata-assert_falling_edge)))
+   else if (info-capture_clear 
+   ((rising_edge  info-assert_falling_edge) ||
+(!rising_edge  !info-assert_falling_edge)))
pps_event(info-pps, ts, PPS_CAPTURECLEAR, NULL);
 
return IRQ_HANDLED;
 }
 
-static int pps_gpio_setup(struct platform_device *pdev)
-{
-   int ret;
-   const struct pps_gpio_platform_data *pdata = pdev-dev.platform_data;
-
-   ret = devm_gpio_request(pdev-dev, pdata-gpio_pin, pdata-gpio_label);
-   if (ret) {
-   pr_warning(failed to request GPIO %u\n, pdata-gpio_pin);
-   return -EINVAL;
-   }
-
-   ret = gpio_direction_input(pdata-gpio_pin);
-   if (ret) {
-   pr_warning(failed to set pin direction\n);
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
 static unsigned long
-get_irqf_trigger_flags(const struct pps_gpio_platform_data *pdata)
+get_irqf_trigger_flags(const struct pps_gpio_device_data *data)
 {
-   unsigned long flags = pdata-assert_falling_edge ?
+   unsigned long flags = data-assert_falling_edge ?
IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
 
-   if (pdata-capture_clear) {
+   if (data-capture_clear) {
flags |= ((flags  IRQF_TRIGGER_RISING) ?
IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING);
}
@@ -106,35 +90,63 @@ get_irqf_trigger_flags(const struct pps_gpio_platform_data 
*pdata)
 static int pps_gpio_probe(struct platform_device *pdev)
 {
struct pps_gpio_device_data *data;
-   int irq;
+   const char *gpio_label;
int ret;
int pps_default_params

[PATCH] pps-gpio: add device-tree binding and support

2013-05-31 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---
This patch depends on my two recent pps-gpio patches, which are currently
in Andrew Morton's mmotm. So it should probably also go via Andrew if it
is acceptable.

 Documentation/devicetree/bindings/pps/pps-gpio.txt |   20 +++
 drivers/pps/clients/pps-gpio.c |   55 +++-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pps/pps-gpio.txt

diff --git a/Documentation/devicetree/bindings/pps/pps-gpio.txt 
b/Documentation/devicetree/bindings/pps/pps-gpio.txt
new file mode 100644
index 000..40bf9c3
--- /dev/null
+++ b/Documentation/devicetree/bindings/pps/pps-gpio.txt
@@ -0,0 +1,20 @@
+Device-Tree Bindings for a PPS Signal on GPIO
+
+These properties describe a PPS (pulse-per-second) signal connected to
+a GPIO pin.
+
+Required properties:
+- compatible: should be "pps-gpio"
+- gpios: one PPS GPIO in the format described by ../gpio/gpio.txt
+
+Optional properties:
+- assert-falling-edge: when present, assert is indicated by a falling edge
+   (instead of by a rising edge)
+
+Example:
+   pps {
+   compatible = "pps-gpio";
+   gpios = < 6 0>;
+
+   assert-falling-edge;
+   };
diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 6768f95..b5806da 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -33,6 +33,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* Info for each registered platform device */
 struct pps_gpio_device_data {
@@ -103,14 +105,62 @@ get_irqf_trigger_flags(const struct 
pps_gpio_platform_data *pdata)
return flags;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id pps_gpio_dt_ids[] = {
+   { .compatible = "pps-gpio", },
+   { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, pps_gpio_dt_ids);
+
+static struct pps_gpio_platform_data *
+of_get_pps_gpio_pdata(struct platform_device *pdev)
+{
+   struct device_node *np = pdev->dev.of_node;
+   struct pps_gpio_platform_data *pdata;
+   int ret;
+
+   pdata = devm_kzalloc(>dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata)
+   return NULL;
+
+   ret = of_get_gpio(np, 0);
+   if (ret < 0) {
+   pr_err("failed to get GPIO from device tree\n");
+   return NULL;
+   }
+
+   pdata->gpio_pin = ret;
+   pdata->gpio_label = PPS_GPIO_NAME;
+
+   if (of_get_property(np, "assert-falling-edge", NULL))
+   pdata->assert_falling_edge = true;
+
+   return pdata;
+}
+#else
+static struct pps_gpio_platform_data *
+of_get_pps_gpio_pdata(struct platform_device *pdev)
+{
+   return NULL;
+}
+#endif
+
 static int pps_gpio_probe(struct platform_device *pdev)
 {
struct pps_gpio_device_data *data;
int irq;
int ret;
int pps_default_params;
-   const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
+   struct pps_gpio_platform_data *pdata;
+   const struct of_device_id *match;
+
+   match = of_match_device(pps_gpio_dt_ids, >dev);
+   if (match)
+   pdev->dev.platform_data = of_get_pps_gpio_pdata(pdev);
+   pdata = pdev->dev.platform_data;
 
+   if (!pdata)
+   return -ENODEV;
 
/* GPIO setup */
ret = pps_gpio_setup(pdev);
@@ -184,7 +234,8 @@ static struct platform_driver pps_gpio_driver = {
.remove = pps_gpio_remove,
.driver = {
.name   = PPS_GPIO_NAME,
-   .owner  = THIS_MODULE
+   .owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(pps_gpio_dt_ids),
},
 };
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] pps-gpio: add device-tree binding and support

2013-05-31 Thread Jan Luebbe
Signed-off-by: Jan Luebbe j...@pengutronix.de
---
This patch depends on my two recent pps-gpio patches, which are currently
in Andrew Morton's mmotm. So it should probably also go via Andrew if it
is acceptable.

 Documentation/devicetree/bindings/pps/pps-gpio.txt |   20 +++
 drivers/pps/clients/pps-gpio.c |   55 +++-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pps/pps-gpio.txt

diff --git a/Documentation/devicetree/bindings/pps/pps-gpio.txt 
b/Documentation/devicetree/bindings/pps/pps-gpio.txt
new file mode 100644
index 000..40bf9c3
--- /dev/null
+++ b/Documentation/devicetree/bindings/pps/pps-gpio.txt
@@ -0,0 +1,20 @@
+Device-Tree Bindings for a PPS Signal on GPIO
+
+These properties describe a PPS (pulse-per-second) signal connected to
+a GPIO pin.
+
+Required properties:
+- compatible: should be pps-gpio
+- gpios: one PPS GPIO in the format described by ../gpio/gpio.txt
+
+Optional properties:
+- assert-falling-edge: when present, assert is indicated by a falling edge
+   (instead of by a rising edge)
+
+Example:
+   pps {
+   compatible = pps-gpio;
+   gpios = gpio2 6 0;
+
+   assert-falling-edge;
+   };
diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 6768f95..b5806da 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -33,6 +33,8 @@
 #include linux/pps-gpio.h
 #include linux/gpio.h
 #include linux/list.h
+#include linux/of_device.h
+#include linux/of_gpio.h
 
 /* Info for each registered platform device */
 struct pps_gpio_device_data {
@@ -103,14 +105,62 @@ get_irqf_trigger_flags(const struct 
pps_gpio_platform_data *pdata)
return flags;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id pps_gpio_dt_ids[] = {
+   { .compatible = pps-gpio, },
+   { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, pps_gpio_dt_ids);
+
+static struct pps_gpio_platform_data *
+of_get_pps_gpio_pdata(struct platform_device *pdev)
+{
+   struct device_node *np = pdev-dev.of_node;
+   struct pps_gpio_platform_data *pdata;
+   int ret;
+
+   pdata = devm_kzalloc(pdev-dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata)
+   return NULL;
+
+   ret = of_get_gpio(np, 0);
+   if (ret  0) {
+   pr_err(failed to get GPIO from device tree\n);
+   return NULL;
+   }
+
+   pdata-gpio_pin = ret;
+   pdata-gpio_label = PPS_GPIO_NAME;
+
+   if (of_get_property(np, assert-falling-edge, NULL))
+   pdata-assert_falling_edge = true;
+
+   return pdata;
+}
+#else
+static struct pps_gpio_platform_data *
+of_get_pps_gpio_pdata(struct platform_device *pdev)
+{
+   return NULL;
+}
+#endif
+
 static int pps_gpio_probe(struct platform_device *pdev)
 {
struct pps_gpio_device_data *data;
int irq;
int ret;
int pps_default_params;
-   const struct pps_gpio_platform_data *pdata = pdev-dev.platform_data;
+   struct pps_gpio_platform_data *pdata;
+   const struct of_device_id *match;
+
+   match = of_match_device(pps_gpio_dt_ids, pdev-dev);
+   if (match)
+   pdev-dev.platform_data = of_get_pps_gpio_pdata(pdev);
+   pdata = pdev-dev.platform_data;
 
+   if (!pdata)
+   return -ENODEV;
 
/* GPIO setup */
ret = pps_gpio_setup(pdev);
@@ -184,7 +234,8 @@ static struct platform_driver pps_gpio_driver = {
.remove = pps_gpio_remove,
.driver = {
.name   = PPS_GPIO_NAME,
-   .owner  = THIS_MODULE
+   .owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(pps_gpio_dt_ids),
},
 };
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] rtc: rs5c372: add R2221T/L variant to the driver

2013-04-29 Thread Jan Luebbe
From: Lucas Stach 

Register layout is the same, so just add the variant to the
appropriate places.

Signed-off-by: Lucas Stach 
Signed-off-by: Jan Luebbe 
---
 drivers/rtc/rtc-rs5c372.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index 581739f..b533acf 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -68,6 +68,7 @@
 enum rtc_type {
rtc_undef = 0,
rtc_r2025sd,
+   rtc_r2221tl,
rtc_rs5c372a,
rtc_rs5c372b,
rtc_rv5c386,
@@ -76,6 +77,7 @@ enum rtc_type {
 
 static const struct i2c_device_id rs5c372_id[] = {
{ "r2025sd", rtc_r2025sd },
+   { "r2221tl", rtc_r2221tl },
{ "rs5c372a", rtc_rs5c372a },
{ "rs5c372b", rtc_rs5c372b },
{ "rv5c386", rtc_rv5c386 },
@@ -529,6 +531,7 @@ static int rs5c_oscillator_setup(struct rs5c372 *rs5c372)
rs5c372->time24 = 1;
break;
case rtc_r2025sd:
+   case rtc_r2221tl:
case rtc_rv5c386:
case rtc_rv5c387a:
buf[0] |= RV5C387_CTRL1_24;
@@ -607,6 +610,7 @@ static int rs5c372_probe(struct i2c_client *client,
rs5c372->time24 = 1;
break;
case rtc_r2025sd:
+   case rtc_r2221tl:
case rtc_rv5c386:
case rtc_rv5c387a:
if (rs5c372->regs[RS5C_REG_CTRL1] & RV5C387_CTRL1_24)
@@ -638,6 +642,7 @@ static int rs5c372_probe(struct i2c_client *client,
dev_info(>dev, "%s found, %s, driver version " DRV_VERSION "\n",
({ char *s; switch (rs5c372->type) {
case rtc_r2025sd:   s = "r2025sd"; break;
+   case rtc_r2221tl:   s = "r2221tl"; break;
case rtc_rs5c372a:  s = "rs5c372a"; break;
case rtc_rs5c372b:  s = "rs5c372b"; break;
case rtc_rv5c386:   s = "rv5c386"; break;
-- 
1.8.2.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] rtc: rs5c372: add R2221T/L variant to the driver

2013-04-29 Thread Jan Luebbe
From: Lucas Stach l.st...@pengutronix.de

Register layout is the same, so just add the variant to the
appropriate places.

Signed-off-by: Lucas Stach l.st...@pengutronix.de
Signed-off-by: Jan Luebbe j...@pengutronix.de
---
 drivers/rtc/rtc-rs5c372.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index 581739f..b533acf 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -68,6 +68,7 @@
 enum rtc_type {
rtc_undef = 0,
rtc_r2025sd,
+   rtc_r2221tl,
rtc_rs5c372a,
rtc_rs5c372b,
rtc_rv5c386,
@@ -76,6 +77,7 @@ enum rtc_type {
 
 static const struct i2c_device_id rs5c372_id[] = {
{ r2025sd, rtc_r2025sd },
+   { r2221tl, rtc_r2221tl },
{ rs5c372a, rtc_rs5c372a },
{ rs5c372b, rtc_rs5c372b },
{ rv5c386, rtc_rv5c386 },
@@ -529,6 +531,7 @@ static int rs5c_oscillator_setup(struct rs5c372 *rs5c372)
rs5c372-time24 = 1;
break;
case rtc_r2025sd:
+   case rtc_r2221tl:
case rtc_rv5c386:
case rtc_rv5c387a:
buf[0] |= RV5C387_CTRL1_24;
@@ -607,6 +610,7 @@ static int rs5c372_probe(struct i2c_client *client,
rs5c372-time24 = 1;
break;
case rtc_r2025sd:
+   case rtc_r2221tl:
case rtc_rv5c386:
case rtc_rv5c387a:
if (rs5c372-regs[RS5C_REG_CTRL1]  RV5C387_CTRL1_24)
@@ -638,6 +642,7 @@ static int rs5c372_probe(struct i2c_client *client,
dev_info(client-dev, %s found, %s, driver version  DRV_VERSION \n,
({ char *s; switch (rs5c372-type) {
case rtc_r2025sd:   s = r2025sd; break;
+   case rtc_r2221tl:   s = r2221tl; break;
case rtc_rs5c372a:  s = rs5c372a; break;
case rtc_rs5c372b:  s = rs5c372b; break;
case rtc_rv5c386:   s = rv5c386; break;
-- 
1.8.2.rc2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] pps-gpio: convert to module_platform_driver

2013-04-26 Thread Jan Luebbe
This removes some boilerplate code (no functional changes).

Signed-off-by: Jan Luebbe 
Acked-by: Rodolfo Giometti 
---
 drivers/pps/clients/pps-gpio.c |   18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 221858d..6768f95 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -188,23 +188,7 @@ static struct platform_driver pps_gpio_driver = {
},
 };
 
-static int __init pps_gpio_init(void)
-{
-   int ret = platform_driver_register(_gpio_driver);
-   if (ret < 0)
-   pr_err("failed to register platform driver\n");
-   return ret;
-}
-
-static void __exit pps_gpio_exit(void)
-{
-   platform_driver_unregister(_gpio_driver);
-   pr_debug("unregistered platform driver\n");
-}
-
-module_init(pps_gpio_init);
-module_exit(pps_gpio_exit);
-
+module_platform_driver(pps_gpio_driver);
 MODULE_AUTHOR("Ricardo Martins ");
 MODULE_AUTHOR("James Nuss ");
 MODULE_DESCRIPTION("Use GPIO pin as PPS source");
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] pps-gpio: convert to devm_* helpers

2013-04-26 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
Acked-by: Rodolfo Giometti 
---
Andrew,

I send these patches to you as requested by PPS maintainer Rodolfo Giometti:
http://www.linuxpps.org/pipermail/discussions/2013-April/004424.html

The acks were only posed to the list above.

Thanks,
Jan

 drivers/pps/clients/pps-gpio.c |   31 ---
 1 file changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 2bf0c1b..221858d 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -74,7 +74,7 @@ static int pps_gpio_setup(struct platform_device *pdev)
int ret;
const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
 
-   ret = gpio_request(pdata->gpio_pin, pdata->gpio_label);
+   ret = devm_gpio_request(>dev, pdata->gpio_pin, pdata->gpio_label);
if (ret) {
pr_warning("failed to request GPIO %u\n", pdata->gpio_pin);
return -EINVAL;
@@ -83,7 +83,6 @@ static int pps_gpio_setup(struct platform_device *pdev)
ret = gpio_direction_input(pdata->gpio_pin);
if (ret) {
pr_warning("failed to set pin direction\n");
-   gpio_free(pdata->gpio_pin);
return -EINVAL;
}
 
@@ -109,7 +108,6 @@ static int pps_gpio_probe(struct platform_device *pdev)
struct pps_gpio_device_data *data;
int irq;
int ret;
-   int err;
int pps_default_params;
const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
 
@@ -123,15 +121,14 @@ static int pps_gpio_probe(struct platform_device *pdev)
irq = gpio_to_irq(pdata->gpio_pin);
if (irq < 0) {
pr_err("failed to map GPIO to IRQ: %d\n", irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
/* allocate space for device info */
-   data = kzalloc(sizeof(struct pps_gpio_device_data), GFP_KERNEL);
+   data = devm_kzalloc(>dev, sizeof(struct pps_gpio_device_data),
+   GFP_KERNEL);
if (data == NULL) {
-   err = -ENOMEM;
-   goto return_error;
+   return -ENOMEM;
}
 
/* initialize PPS specific parts of the bookkeeping data structure. */
@@ -150,47 +147,35 @@ static int pps_gpio_probe(struct platform_device *pdev)
pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR;
data->pps = pps_register_source(>info, pps_default_params);
if (data->pps == NULL) {
-   kfree(data);
pr_err("failed to register IRQ %d as PPS source\n", irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
data->irq = irq;
data->pdata = pdata;
 
/* register IRQ interrupt handler */
-   ret = request_irq(irq, pps_gpio_irq_handler,
+   ret = devm_request_irq(>dev, irq, pps_gpio_irq_handler,
get_irqf_trigger_flags(pdata), data->info.name, data);
if (ret) {
pps_unregister_source(data->pps);
-   kfree(data);
pr_err("failed to acquire IRQ %d\n", irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
platform_set_drvdata(pdev, data);
dev_info(data->pps->dev, "Registered IRQ %d as PPS source\n", irq);
 
return 0;
-
-return_error:
-   gpio_free(pdata->gpio_pin);
-   return err;
 }
 
 static int pps_gpio_remove(struct platform_device *pdev)
 {
struct pps_gpio_device_data *data = platform_get_drvdata(pdev);
-   const struct pps_gpio_platform_data *pdata = data->pdata;
 
platform_set_drvdata(pdev, NULL);
-   free_irq(data->irq, data);
-   gpio_free(pdata->gpio_pin);
pps_unregister_source(data->pps);
pr_info("removed IRQ %d as PPS source\n", data->irq);
-   kfree(data);
return 0;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] pps-gpio: convert to devm_* helpers

2013-04-26 Thread Jan Luebbe
Signed-off-by: Jan Luebbe j...@pengutronix.de
Acked-by: Rodolfo Giometti giome...@enneenne.com
---
Andrew,

I send these patches to you as requested by PPS maintainer Rodolfo Giometti:
http://www.linuxpps.org/pipermail/discussions/2013-April/004424.html

The acks were only posed to the list above.

Thanks,
Jan

 drivers/pps/clients/pps-gpio.c |   31 ---
 1 file changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 2bf0c1b..221858d 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -74,7 +74,7 @@ static int pps_gpio_setup(struct platform_device *pdev)
int ret;
const struct pps_gpio_platform_data *pdata = pdev-dev.platform_data;
 
-   ret = gpio_request(pdata-gpio_pin, pdata-gpio_label);
+   ret = devm_gpio_request(pdev-dev, pdata-gpio_pin, pdata-gpio_label);
if (ret) {
pr_warning(failed to request GPIO %u\n, pdata-gpio_pin);
return -EINVAL;
@@ -83,7 +83,6 @@ static int pps_gpio_setup(struct platform_device *pdev)
ret = gpio_direction_input(pdata-gpio_pin);
if (ret) {
pr_warning(failed to set pin direction\n);
-   gpio_free(pdata-gpio_pin);
return -EINVAL;
}
 
@@ -109,7 +108,6 @@ static int pps_gpio_probe(struct platform_device *pdev)
struct pps_gpio_device_data *data;
int irq;
int ret;
-   int err;
int pps_default_params;
const struct pps_gpio_platform_data *pdata = pdev-dev.platform_data;
 
@@ -123,15 +121,14 @@ static int pps_gpio_probe(struct platform_device *pdev)
irq = gpio_to_irq(pdata-gpio_pin);
if (irq  0) {
pr_err(failed to map GPIO to IRQ: %d\n, irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
/* allocate space for device info */
-   data = kzalloc(sizeof(struct pps_gpio_device_data), GFP_KERNEL);
+   data = devm_kzalloc(pdev-dev, sizeof(struct pps_gpio_device_data),
+   GFP_KERNEL);
if (data == NULL) {
-   err = -ENOMEM;
-   goto return_error;
+   return -ENOMEM;
}
 
/* initialize PPS specific parts of the bookkeeping data structure. */
@@ -150,47 +147,35 @@ static int pps_gpio_probe(struct platform_device *pdev)
pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR;
data-pps = pps_register_source(data-info, pps_default_params);
if (data-pps == NULL) {
-   kfree(data);
pr_err(failed to register IRQ %d as PPS source\n, irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
data-irq = irq;
data-pdata = pdata;
 
/* register IRQ interrupt handler */
-   ret = request_irq(irq, pps_gpio_irq_handler,
+   ret = devm_request_irq(pdev-dev, irq, pps_gpio_irq_handler,
get_irqf_trigger_flags(pdata), data-info.name, data);
if (ret) {
pps_unregister_source(data-pps);
-   kfree(data);
pr_err(failed to acquire IRQ %d\n, irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
platform_set_drvdata(pdev, data);
dev_info(data-pps-dev, Registered IRQ %d as PPS source\n, irq);
 
return 0;
-
-return_error:
-   gpio_free(pdata-gpio_pin);
-   return err;
 }
 
 static int pps_gpio_remove(struct platform_device *pdev)
 {
struct pps_gpio_device_data *data = platform_get_drvdata(pdev);
-   const struct pps_gpio_platform_data *pdata = data-pdata;
 
platform_set_drvdata(pdev, NULL);
-   free_irq(data-irq, data);
-   gpio_free(pdata-gpio_pin);
pps_unregister_source(data-pps);
pr_info(removed IRQ %d as PPS source\n, data-irq);
-   kfree(data);
return 0;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] pps-gpio: convert to module_platform_driver

2013-04-26 Thread Jan Luebbe
This removes some boilerplate code (no functional changes).

Signed-off-by: Jan Luebbe j...@pengutronix.de
Acked-by: Rodolfo Giometti giome...@enneenne.com
---
 drivers/pps/clients/pps-gpio.c |   18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 221858d..6768f95 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -188,23 +188,7 @@ static struct platform_driver pps_gpio_driver = {
},
 };
 
-static int __init pps_gpio_init(void)
-{
-   int ret = platform_driver_register(pps_gpio_driver);
-   if (ret  0)
-   pr_err(failed to register platform driver\n);
-   return ret;
-}
-
-static void __exit pps_gpio_exit(void)
-{
-   platform_driver_unregister(pps_gpio_driver);
-   pr_debug(unregistered platform driver\n);
-}
-
-module_init(pps_gpio_init);
-module_exit(pps_gpio_exit);
-
+module_platform_driver(pps_gpio_driver);
 MODULE_AUTHOR(Ricardo Martins r...@fe.up.pt);
 MODULE_AUTHOR(James Nuss jamesn...@nanometrics.ca);
 MODULE_DESCRIPTION(Use GPIO pin as PPS source);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] pps-gpio: convert to devm_* helpers

2013-04-10 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---
 drivers/pps/clients/pps-gpio.c |   31 ---
 1 file changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 2bf0c1b..221858d 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -74,7 +74,7 @@ static int pps_gpio_setup(struct platform_device *pdev)
int ret;
const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
 
-   ret = gpio_request(pdata->gpio_pin, pdata->gpio_label);
+   ret = devm_gpio_request(>dev, pdata->gpio_pin, pdata->gpio_label);
if (ret) {
pr_warning("failed to request GPIO %u\n", pdata->gpio_pin);
return -EINVAL;
@@ -83,7 +83,6 @@ static int pps_gpio_setup(struct platform_device *pdev)
ret = gpio_direction_input(pdata->gpio_pin);
if (ret) {
pr_warning("failed to set pin direction\n");
-   gpio_free(pdata->gpio_pin);
return -EINVAL;
}
 
@@ -109,7 +108,6 @@ static int pps_gpio_probe(struct platform_device *pdev)
struct pps_gpio_device_data *data;
int irq;
int ret;
-   int err;
int pps_default_params;
const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
 
@@ -123,15 +121,14 @@ static int pps_gpio_probe(struct platform_device *pdev)
irq = gpio_to_irq(pdata->gpio_pin);
if (irq < 0) {
pr_err("failed to map GPIO to IRQ: %d\n", irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
/* allocate space for device info */
-   data = kzalloc(sizeof(struct pps_gpio_device_data), GFP_KERNEL);
+   data = devm_kzalloc(>dev, sizeof(struct pps_gpio_device_data),
+   GFP_KERNEL);
if (data == NULL) {
-   err = -ENOMEM;
-   goto return_error;
+   return -ENOMEM;
}
 
/* initialize PPS specific parts of the bookkeeping data structure. */
@@ -150,47 +147,35 @@ static int pps_gpio_probe(struct platform_device *pdev)
pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR;
data->pps = pps_register_source(>info, pps_default_params);
if (data->pps == NULL) {
-   kfree(data);
pr_err("failed to register IRQ %d as PPS source\n", irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
data->irq = irq;
data->pdata = pdata;
 
/* register IRQ interrupt handler */
-   ret = request_irq(irq, pps_gpio_irq_handler,
+   ret = devm_request_irq(>dev, irq, pps_gpio_irq_handler,
get_irqf_trigger_flags(pdata), data->info.name, data);
if (ret) {
pps_unregister_source(data->pps);
-   kfree(data);
pr_err("failed to acquire IRQ %d\n", irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
platform_set_drvdata(pdev, data);
dev_info(data->pps->dev, "Registered IRQ %d as PPS source\n", irq);
 
return 0;
-
-return_error:
-   gpio_free(pdata->gpio_pin);
-   return err;
 }
 
 static int pps_gpio_remove(struct platform_device *pdev)
 {
struct pps_gpio_device_data *data = platform_get_drvdata(pdev);
-   const struct pps_gpio_platform_data *pdata = data->pdata;
 
platform_set_drvdata(pdev, NULL);
-   free_irq(data->irq, data);
-   gpio_free(pdata->gpio_pin);
pps_unregister_source(data->pps);
pr_info("removed IRQ %d as PPS source\n", data->irq);
-   kfree(data);
return 0;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] pps-gpio: convert to module_platform_driver

2013-04-10 Thread Jan Luebbe
This removes some boilerplate code (no functional changes).

Signed-off-by: Jan Luebbe 
---
 drivers/pps/clients/pps-gpio.c |   18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 221858d..6768f95 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -188,23 +188,7 @@ static struct platform_driver pps_gpio_driver = {
},
 };
 
-static int __init pps_gpio_init(void)
-{
-   int ret = platform_driver_register(_gpio_driver);
-   if (ret < 0)
-   pr_err("failed to register platform driver\n");
-   return ret;
-}
-
-static void __exit pps_gpio_exit(void)
-{
-   platform_driver_unregister(_gpio_driver);
-   pr_debug("unregistered platform driver\n");
-}
-
-module_init(pps_gpio_init);
-module_exit(pps_gpio_exit);
-
+module_platform_driver(pps_gpio_driver);
 MODULE_AUTHOR("Ricardo Martins ");
 MODULE_AUTHOR("James Nuss ");
 MODULE_DESCRIPTION("Use GPIO pin as PPS source");
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] pps-gpio: convert to devm_* helpers

2013-04-10 Thread Jan Luebbe
Signed-off-by: Jan Luebbe j...@pengutronix.de
---
 drivers/pps/clients/pps-gpio.c |   31 ---
 1 file changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 2bf0c1b..221858d 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -74,7 +74,7 @@ static int pps_gpio_setup(struct platform_device *pdev)
int ret;
const struct pps_gpio_platform_data *pdata = pdev-dev.platform_data;
 
-   ret = gpio_request(pdata-gpio_pin, pdata-gpio_label);
+   ret = devm_gpio_request(pdev-dev, pdata-gpio_pin, pdata-gpio_label);
if (ret) {
pr_warning(failed to request GPIO %u\n, pdata-gpio_pin);
return -EINVAL;
@@ -83,7 +83,6 @@ static int pps_gpio_setup(struct platform_device *pdev)
ret = gpio_direction_input(pdata-gpio_pin);
if (ret) {
pr_warning(failed to set pin direction\n);
-   gpio_free(pdata-gpio_pin);
return -EINVAL;
}
 
@@ -109,7 +108,6 @@ static int pps_gpio_probe(struct platform_device *pdev)
struct pps_gpio_device_data *data;
int irq;
int ret;
-   int err;
int pps_default_params;
const struct pps_gpio_platform_data *pdata = pdev-dev.platform_data;
 
@@ -123,15 +121,14 @@ static int pps_gpio_probe(struct platform_device *pdev)
irq = gpio_to_irq(pdata-gpio_pin);
if (irq  0) {
pr_err(failed to map GPIO to IRQ: %d\n, irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
/* allocate space for device info */
-   data = kzalloc(sizeof(struct pps_gpio_device_data), GFP_KERNEL);
+   data = devm_kzalloc(pdev-dev, sizeof(struct pps_gpio_device_data),
+   GFP_KERNEL);
if (data == NULL) {
-   err = -ENOMEM;
-   goto return_error;
+   return -ENOMEM;
}
 
/* initialize PPS specific parts of the bookkeeping data structure. */
@@ -150,47 +147,35 @@ static int pps_gpio_probe(struct platform_device *pdev)
pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR;
data-pps = pps_register_source(data-info, pps_default_params);
if (data-pps == NULL) {
-   kfree(data);
pr_err(failed to register IRQ %d as PPS source\n, irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
data-irq = irq;
data-pdata = pdata;
 
/* register IRQ interrupt handler */
-   ret = request_irq(irq, pps_gpio_irq_handler,
+   ret = devm_request_irq(pdev-dev, irq, pps_gpio_irq_handler,
get_irqf_trigger_flags(pdata), data-info.name, data);
if (ret) {
pps_unregister_source(data-pps);
-   kfree(data);
pr_err(failed to acquire IRQ %d\n, irq);
-   err = -EINVAL;
-   goto return_error;
+   return -EINVAL;
}
 
platform_set_drvdata(pdev, data);
dev_info(data-pps-dev, Registered IRQ %d as PPS source\n, irq);
 
return 0;
-
-return_error:
-   gpio_free(pdata-gpio_pin);
-   return err;
 }
 
 static int pps_gpio_remove(struct platform_device *pdev)
 {
struct pps_gpio_device_data *data = platform_get_drvdata(pdev);
-   const struct pps_gpio_platform_data *pdata = data-pdata;
 
platform_set_drvdata(pdev, NULL);
-   free_irq(data-irq, data);
-   gpio_free(pdata-gpio_pin);
pps_unregister_source(data-pps);
pr_info(removed IRQ %d as PPS source\n, data-irq);
-   kfree(data);
return 0;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] pps-gpio: convert to module_platform_driver

2013-04-10 Thread Jan Luebbe
This removes some boilerplate code (no functional changes).

Signed-off-by: Jan Luebbe j...@pengutronix.de
---
 drivers/pps/clients/pps-gpio.c |   18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 221858d..6768f95 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -188,23 +188,7 @@ static struct platform_driver pps_gpio_driver = {
},
 };
 
-static int __init pps_gpio_init(void)
-{
-   int ret = platform_driver_register(pps_gpio_driver);
-   if (ret  0)
-   pr_err(failed to register platform driver\n);
-   return ret;
-}
-
-static void __exit pps_gpio_exit(void)
-{
-   platform_driver_unregister(pps_gpio_driver);
-   pr_debug(unregistered platform driver\n);
-}
-
-module_init(pps_gpio_init);
-module_exit(pps_gpio_exit);
-
+module_platform_driver(pps_gpio_driver);
 MODULE_AUTHOR(Ricardo Martins r...@fe.up.pt);
 MODULE_AUTHOR(James Nuss jamesn...@nanometrics.ca);
 MODULE_DESCRIPTION(Use GPIO pin as PPS source);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] rtc-isl1208: call rtc_update_irq from the alarm irq handler

2013-01-29 Thread Jan Luebbe
Previously the alarm event was not propagated into the RTC subsystem.
By adding a call to rtc_update_irq, this fixes a timeout problem with
the hwclock utility.

Signed-off-by: Jan Luebbe 
---
 drivers/rtc/rtc-isl1208.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index afb7cfa..c016ad8 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -506,6 +506,7 @@ isl1208_rtc_interrupt(int irq, void *data)
 {
unsigned long timeout = jiffies + msecs_to_jiffies(1000);
struct i2c_client *client = data;
+   struct rtc_device *rtc = i2c_get_clientdata(client);
int handled = 0, sr, err;
 
/*
@@ -528,6 +529,8 @@ isl1208_rtc_interrupt(int irq, void *data)
if (sr & ISL1208_REG_SR_ALM) {
dev_dbg(>dev, "alarm!\n");
 
+   rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
+
/* Clear the alarm */
sr &= ~ISL1208_REG_SR_ALM;
sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] rtc-isl1208: call rtc_update_irq from the alarm irq handler

2013-01-29 Thread Jan Luebbe
Previously the alarm event was not propagated into the RTC subsystem.
By adding a call to rtc_update_irq, this fixes a timeout problem with
the hwclock utility.

Signed-off-by: Jan Luebbe j...@pengutronix.de
---
 drivers/rtc/rtc-isl1208.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index afb7cfa..c016ad8 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -506,6 +506,7 @@ isl1208_rtc_interrupt(int irq, void *data)
 {
unsigned long timeout = jiffies + msecs_to_jiffies(1000);
struct i2c_client *client = data;
+   struct rtc_device *rtc = i2c_get_clientdata(client);
int handled = 0, sr, err;
 
/*
@@ -528,6 +529,8 @@ isl1208_rtc_interrupt(int irq, void *data)
if (sr  ISL1208_REG_SR_ALM) {
dev_dbg(client-dev, alarm!\n);
 
+   rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
+
/* Clear the alarm */
sr = ~ISL1208_REG_SR_ALM;
sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] rtc: rtc-imxdi: add missing spin lock initialization

2012-10-17 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---
 drivers/rtc/rtc-imxdi.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index b2fe920..85f19ad 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -392,6 +392,8 @@ static int dryice_rtc_probe(struct platform_device *pdev)
if (imxdi->ioaddr == NULL)
return -ENOMEM;
 
+   spin_lock_init(>irq_lock);
+
imxdi->irq = platform_get_irq(pdev, 0);
if (imxdi->irq < 0)
return imxdi->irq;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] rtc: rtc-imxdi: add missing spin lock initialization

2012-10-17 Thread Jan Luebbe
Signed-off-by: Jan Luebbe j...@pengutronix.de
---
 drivers/rtc/rtc-imxdi.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index b2fe920..85f19ad 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -392,6 +392,8 @@ static int dryice_rtc_probe(struct platform_device *pdev)
if (imxdi-ioaddr == NULL)
return -ENOMEM;
 
+   spin_lock_init(imxdi-irq_lock);
+
imxdi-irq = platform_get_irq(pdev, 0);
if (imxdi-irq  0)
return imxdi-irq;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] lib/dma-debug: check for vmalloc and module addresses used with the DMA-API

2012-09-19 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---

Changes since v1:
 - As recommended by Joerg Roedel, check for overlap with vmalloc and
   module address ranges.

 lib/dma-debug.c |8 
 1 file changed, 8 insertions(+)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 66ce414..b35992b 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -944,6 +944,14 @@ static void check_for_illegal_area(struct device *dev, 
void *addr, unsigned long
if (overlap(addr, len, _text, _etext) ||
overlap(addr, len, __start_rodata, __end_rodata))
err_printk(dev, NULL, "DMA-API: device driver maps memory from 
kernel text or rodata [addr=%p] [len=%lu]\n", addr, len);
+#ifdef CONFIG_MMU
+   if (overlap(addr, len, (void *)VMALLOC_START, (void *)VMALLOC_END))
+   err_printk(dev, NULL, "DMA-API: device driver maps memory from 
vmalloc address range [addr=%p] [len=%lu]\n", addr, len);
+#endif
+#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
+   if (overlap(addr, len, (void *)MODULES_VADDR, (void *)MODULES_END))
+   err_printk(dev, NULL, "DMA-API: device driver maps memory from 
kernel module address range [addr=%p] [len=%lu]\n", addr, len);
+#endif
 }
 
 static void check_sync(struct device *dev,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] lib/dma-debug: check for vmalloc and module addresses used with the DMA-API

2012-09-19 Thread Jan Luebbe
Signed-off-by: Jan Luebbe j...@pengutronix.de
---

Changes since v1:
 - As recommended by Joerg Roedel, check for overlap with vmalloc and
   module address ranges.

 lib/dma-debug.c |8 
 1 file changed, 8 insertions(+)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 66ce414..b35992b 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -944,6 +944,14 @@ static void check_for_illegal_area(struct device *dev, 
void *addr, unsigned long
if (overlap(addr, len, _text, _etext) ||
overlap(addr, len, __start_rodata, __end_rodata))
err_printk(dev, NULL, DMA-API: device driver maps memory from 
kernel text or rodata [addr=%p] [len=%lu]\n, addr, len);
+#ifdef CONFIG_MMU
+   if (overlap(addr, len, (void *)VMALLOC_START, (void *)VMALLOC_END))
+   err_printk(dev, NULL, DMA-API: device driver maps memory from 
vmalloc address range [addr=%p] [len=%lu]\n, addr, len);
+#endif
+#if defined(CONFIG_MODULES)  defined(MODULES_VADDR)
+   if (overlap(addr, len, (void *)MODULES_VADDR, (void *)MODULES_END))
+   err_printk(dev, NULL, DMA-API: device driver maps memory from 
kernel module address range [addr=%p] [len=%lu]\n, addr, len);
+#endif
 }
 
 static void check_sync(struct device *dev,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] lib/dma-debug: check for vmalloc buffers used with the DMA-API

2012-09-03 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---
I'm not sure why we don't check for high memory, is there any problem
with this approach?

 lib/dma-debug.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 66ce414..7d60ff0 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -944,6 +944,9 @@ static void check_for_illegal_area(struct device *dev, void 
*addr, unsigned long
if (overlap(addr, len, _text, _etext) ||
overlap(addr, len, __start_rodata, __end_rodata))
err_printk(dev, NULL, "DMA-API: device driver maps memory from 
kernel text or rodata [addr=%p] [len=%lu]\n", addr, len);
+   if (is_vmalloc_or_module_addr(addr) ||
+   is_vmalloc_or_module_addr(addr+len))
+   err_printk(dev, NULL, "DMA-API: device driver maps memory from 
vmalloc or module address range [addr=%p] [len=%lu]\n", addr, len);
 }
 
 static void check_sync(struct device *dev,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] lib/dma-debug: check for vmalloc buffers used with the DMA-API

2012-09-03 Thread Jan Luebbe
Signed-off-by: Jan Luebbe j...@pengutronix.de
---
I'm not sure why we don't check for high memory, is there any problem
with this approach?

 lib/dma-debug.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 66ce414..7d60ff0 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -944,6 +944,9 @@ static void check_for_illegal_area(struct device *dev, void 
*addr, unsigned long
if (overlap(addr, len, _text, _etext) ||
overlap(addr, len, __start_rodata, __end_rodata))
err_printk(dev, NULL, DMA-API: device driver maps memory from 
kernel text or rodata [addr=%p] [len=%lu]\n, addr, len);
+   if (is_vmalloc_or_module_addr(addr) ||
+   is_vmalloc_or_module_addr(addr+len))
+   err_printk(dev, NULL, DMA-API: device driver maps memory from 
vmalloc or module address range [addr=%p] [len=%lu]\n, addr, len);
 }
 
 static void check_sync(struct device *dev,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] fix console change race exposed by CFS

2007-09-30 Thread Jan Luebbe
On Sun, 2007-09-30 at 09:20 +0200, Ingo Molnar wrote:
> * Jan Luebbe <[EMAIL PROTECTED]> wrote:
> > From: Jan Lübbe <[EMAIL PROTECTED]>
> > 
> > The new behaviour of CFS exposes a race which occurs if a switch is
> > requested when vt_mode.mode is VT_PROCESS.
> > 
> > The process with vc->vt_pid is signaled before vc->vt_newvt is set. This
> > causes the switch to fail when triggered by the monitoing process
> > because the target is still -1.
> > 
> > Signed-off-by: Jan Lübbe <[EMAIL PROTECTED]>
> 
> nifty! I'm wondering what the symptoms of this bug were - how did you 
> notice it? Also, i'm wondering how you managed to debug this - looks 
> quite hard to trigger this race, right?
> 
> Acked-by: Ingo Molnar <[EMAIL PROTECTED]>
> 
>   Ingo

I'm currenly porting the OpenMoko patchset to 2.6.23-rc8. We are using
psplash and kdrive. When booting, I got an error from psplash about
being unable to switch consoles. Strangely, it was possible to start
kdrive manually. So i set up qemu for kernel debugging, set some
interesting breakpoints and then saw that it was scheduling away
directly after the kill_pid. Then it was quite obvious.

It was triggering every time, on the device and in qemu identically.
Most people testing the RCs probably don't run psplash (or any other
program which sets vt_mode.mode to VT_PROCESS), so it wasn't noticed
earlier.

Jan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] fix console change race exposed by CFS

2007-09-30 Thread Jan Luebbe
On Sun, 2007-09-30 at 09:20 +0200, Ingo Molnar wrote:
 * Jan Luebbe [EMAIL PROTECTED] wrote:
  From: Jan Lübbe [EMAIL PROTECTED]
  
  The new behaviour of CFS exposes a race which occurs if a switch is
  requested when vt_mode.mode is VT_PROCESS.
  
  The process with vc-vt_pid is signaled before vc-vt_newvt is set. This
  causes the switch to fail when triggered by the monitoing process
  because the target is still -1.
  
  Signed-off-by: Jan Lübbe [EMAIL PROTECTED]
 
 nifty! I'm wondering what the symptoms of this bug were - how did you 
 notice it? Also, i'm wondering how you managed to debug this - looks 
 quite hard to trigger this race, right?
 
 Acked-by: Ingo Molnar [EMAIL PROTECTED]
 
   Ingo

I'm currenly porting the OpenMoko patchset to 2.6.23-rc8. We are using
psplash and kdrive. When booting, I got an error from psplash about
being unable to switch consoles. Strangely, it was possible to start
kdrive manually. So i set up qemu for kernel debugging, set some
interesting breakpoints and then saw that it was scheduling away
directly after the kill_pid. Then it was quite obvious.

It was triggering every time, on the device and in qemu identically.
Most people testing the RCs probably don't run psplash (or any other
program which sets vt_mode.mode to VT_PROCESS), so it wasn't noticed
earlier.

Jan

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] fix console change race exposed by CFS

2007-09-29 Thread Jan Luebbe
From: Jan Lübbe <[EMAIL PROTECTED]>

The new behaviour of CFS exposes a race which occurs if a switch is
requested when vt_mode.mode is VT_PROCESS.

The process with vc->vt_pid is signaled before vc->vt_newvt is set. This
causes the switch to fail when triggered by the monitoing process
because the target is still -1.

Signed-off-by: Jan Lübbe <[EMAIL PROTECTED]>
---
Index: linux-2.6.22/drivers/char/vt_ioctl.c
===
--- linux-2.6.22.orig/drivers/char/vt_ioctl.c
+++ linux-2.6.22/drivers/char/vt_ioctl.c
@@ -1208,15 +1208,18 @@
/*
 * Send the signal as privileged - kill_pid() will
 * tell us if the process has gone or something else
-* is awry
+* is awry.
+*
+* We need to set vt_newvt *before* sending the signal or we
+* have a race.
 */
+   vc->vt_newvt = new_vc->vc_num;
if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) {
/*
 * It worked. Mark the vt to switch to and
 * return. The process needs to send us a
 * VT_RELDISP ioctl to complete the switch.
 */
-   vc->vt_newvt = new_vc->vc_num;
return;
}


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] fix console change race exposed by CFS

2007-09-29 Thread Jan Luebbe
From: Jan Lübbe [EMAIL PROTECTED]

The new behaviour of CFS exposes a race which occurs if a switch is
requested when vt_mode.mode is VT_PROCESS.

The process with vc-vt_pid is signaled before vc-vt_newvt is set. This
causes the switch to fail when triggered by the monitoing process
because the target is still -1.

Signed-off-by: Jan Lübbe [EMAIL PROTECTED]
---
Index: linux-2.6.22/drivers/char/vt_ioctl.c
===
--- linux-2.6.22.orig/drivers/char/vt_ioctl.c
+++ linux-2.6.22/drivers/char/vt_ioctl.c
@@ -1208,15 +1208,18 @@
/*
 * Send the signal as privileged - kill_pid() will
 * tell us if the process has gone or something else
-* is awry
+* is awry.
+*
+* We need to set vt_newvt *before* sending the signal or we
+* have a race.
 */
+   vc-vt_newvt = new_vc-vc_num;
if (kill_pid(vc-vt_pid, vc-vt_mode.relsig, 1) == 0) {
/*
 * It worked. Mark the vt to switch to and
 * return. The process needs to send us a
 * VT_RELDISP ioctl to complete the switch.
 */
-   vc-vt_newvt = new_vc-vc_num;
return;
}


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/