From patchwork Tue Aug 18 07:00:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 42269 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7I70PuE028239 for ; Tue, 18 Aug 2009 07:00:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751492AbZHRHAW (ORCPT ); Tue, 18 Aug 2009 03:00:22 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751643AbZHRHAW (ORCPT ); Tue, 18 Aug 2009 03:00:22 -0400 Received: from mail.renesas.com ([202.234.163.13]:38838 "EHLO mail02.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751492AbZHRHAW (ORCPT ); Tue, 18 Aug 2009 03:00:22 -0400 X-AuditID: ac140385-0000000a000002de-e1-4a8a51853232 Received: from guardian02.idc.renesas.com ([172.20.8.201]) by mail02.idc.renesas.com (sendmail) with ESMTP id n7I70LqH000146; Tue, 18 Aug 2009 16:00:21 +0900 (JST) Received: (from root@localhost) by guardian02.idc.renesas.com with id n7I70LC7005077; Tue, 18 Aug 2009 16:00:21 +0900 (JST) Received: from mta03.idc.renesas.com (localhost [127.0.0.1]) by mta03.idc.renesas.com with ESMTP id n7I70NUi017598; Tue, 18 Aug 2009 16:00:23 +0900 (JST) Received: from PG10870.renesas.com ([172.30.8.159]) by ims05.idc.renesas.com (Sendmail) with ESMTPA id <0KOK00C4F8SLAI@ims05.idc.renesas.com>; Tue, 18 Aug 2009 16:00:21 +0900 (JST) Date: Tue, 18 Aug 2009 16:00:20 +0900 From: Kuninori Morimoto Subject: [PATCH] heartbeat: add bit mask operation on heartbeat_toggle_bit To: linux-sh@vger.kernel.org Cc: lethal@linux-sh.org Message-id: MIME-version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-type: text/plain; charset=US-ASCII User-Agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.7 Emacs/22.1 (i386-mingw-nt5.1.2600) MULE/5.0 (SAKAKI) Meadow/3.00-dev (KIKU) X-Brightmail-Tracker: AAAAAA== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Current heartbeat driver has the possibility to change area that is not LED. This patch add bit mask operation to not change it. Signed-off-by: Kuninori Morimoto --- arch/sh/drivers/heartbeat.c | 10 ++++++++++ arch/sh/include/asm/heartbeat.h | 1 + 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/arch/sh/drivers/heartbeat.c b/arch/sh/drivers/heartbeat.c index 938817e..a9339a6 100644 --- a/arch/sh/drivers/heartbeat.c +++ b/arch/sh/drivers/heartbeat.c @@ -40,14 +40,19 @@ static inline void heartbeat_toggle_bit(struct heartbeat_data *hd, if (inverted) new = ~new; + new &= hd->mask; + switch (hd->regsize) { case 32: + new |= ioread32(hd->base) & ~hd->mask; iowrite32(new, hd->base); break; case 16: + new |= ioread16(hd->base) & ~hd->mask; iowrite16(new, hd->base); break; default: + new |= ioread8(hd->base) & ~hd->mask; iowrite8(new, hd->base); break; } @@ -72,6 +77,7 @@ static int heartbeat_drv_probe(struct platform_device *pdev) { struct resource *res; struct heartbeat_data *hd; + int i; if (unlikely(pdev->num_resources != 1)) { dev_err(&pdev->dev, "invalid number of resources\n"); @@ -107,6 +113,10 @@ static int heartbeat_drv_probe(struct platform_device *pdev) hd->nr_bits = ARRAY_SIZE(default_bit_pos); } + hd->mask = 0; + for (i = 0; i < hd->nr_bits; i++) + hd->mask |= (1 << hd->bit_pos[i]); + if (!hd->regsize) hd->regsize = 8; /* default access size */ diff --git a/arch/sh/include/asm/heartbeat.h b/arch/sh/include/asm/heartbeat.h index 724a43e..caaafe5 100644 --- a/arch/sh/include/asm/heartbeat.h +++ b/arch/sh/include/asm/heartbeat.h @@ -11,6 +11,7 @@ struct heartbeat_data { unsigned int nr_bits; struct timer_list timer; unsigned int regsize; + unsigned int mask; unsigned long flags; };