From patchwork Mon Jun 18 09:28:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9382 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id EB39523F19 for ; Mon, 18 Jun 2012 09:29:18 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 9D2C5A186A9 for ; Mon, 18 Jun 2012 09:29:18 +0000 (UTC) Received: by yhpp61 with SMTP id p61so3902905yhp.11 for ; Mon, 18 Jun 2012 02:29:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=QG7PKYSIOnX2nFyzqiabQHWBVSDGWTLGsEvgNWvKTz8=; b=frQ3QnO8C4YXW38e12QUvF8wMHHheuKGW+aV1HbJxaynSYjximdKVsoBl/dP8Y6oR2 LvI4d3PH/mOiFfe+GO/wa9ggC69eg+jGi1hmsY1LGb1CdnNE7lZ9uO81F+4Wijh8TgbP bmkF/ZPnkuqgQcnKsKlcR+Smb3Ptam60G95BusFQOciy6U/VNviI5abjT7TjwWzZqLGi 5D665xW8wp1/4BuiJsESP2DrLG4KkBa8mDEb+ZNvqzQ3Z3C/2U8FOLp4GpPoiStQFDkc sHn+IaD7AsU8xchEAZcGa9XBKPKVoEzpmaIyQxODv2YVOuABPkGCkE0boakMnTilLnwY Bz5g== Received: by 10.50.203.39 with SMTP id kn7mr7633232igc.53.1340011757934; Mon, 18 Jun 2012 02:29:17 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp56519ibb; Mon, 18 Jun 2012 02:29:16 -0700 (PDT) Received: by 10.14.37.201 with SMTP id y49mr2664836eea.128.1340011756083; Mon, 18 Jun 2012 02:29:16 -0700 (PDT) Received: from eu1sys200aog106.obsmtp.com (eu1sys200aog106.obsmtp.com. [207.126.144.121]) by mx.google.com with SMTP id d5si8242927eei.9.2012.06.18.02.29.05 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 02:29:16 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.121 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.121; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.121 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob106.postini.com ([207.126.147.11]) with SMTP ID DSNKT9704VdgrATHs/lzTt+L1Tf1GZ1PyuyZ@postini.com; Mon, 18 Jun 2012 09:29:15 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 16B10B7; Mon, 18 Jun 2012 09:20:41 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 0347117E7; Mon, 18 Jun 2012 09:29:00 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id A5BE524C2F8; Mon, 18 Jun 2012 11:28:53 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 18 Jun 2012 11:28:58 +0200 From: Linus Walleij To: Andrew Morton Cc: Alessandro Zummo , , Linus Walleij Subject: [PATCH 1/3] rtc: pl031: encapsulate per-vendor ops Date: Mon, 18 Jun 2012 11:28:54 +0200 Message-ID: <1340011734-5039-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmKaNpjtrJqay5VLlRhqNe1oogmhijVk+NBg0JrdCfDebc/GcOFONjjSj/nRykseqMQ04S3 From: Linus Walleij Move the per-vendor operations for this RTC into a encapsulating struct to we can have more per-vendor variables than just the ops. Signed-off-by: Linus Walleij --- drivers/rtc/rtc-pl031.c | 61 ++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index cc05339..575fbbf 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c @@ -68,7 +68,16 @@ #define RTC_TIMER_FREQ 32768 +/** + * struct pl031_vendor_data - per-vendor variations + * @ops: the vendor-specific operations used on this silicon version + */ +struct pl031_vendor_data { + struct rtc_class_ops ops; +}; + struct pl031_local { + struct pl031_vendor_data *vendor; struct rtc_device *rtc; void __iomem *base; u8 hw_designer; @@ -303,7 +312,8 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) { int ret; struct pl031_local *ldata; - struct rtc_class_ops *ops = id->data; + struct pl031_vendor_data *vendor = id->data; + struct rtc_class_ops *ops = &vendor->ops; unsigned long time; ret = amba_request_regions(adev, NULL); @@ -315,6 +325,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) ret = -ENOMEM; goto out; } + ldata->vendor = vendor; ldata->base = ioremap(adev->res.start, resource_size(&adev->res)); @@ -383,48 +394,54 @@ err_req: } /* Operations for the original ARM version */ -static struct rtc_class_ops arm_pl031_ops = { - .read_time = pl031_read_time, - .set_time = pl031_set_time, - .read_alarm = pl031_read_alarm, - .set_alarm = pl031_set_alarm, - .alarm_irq_enable = pl031_alarm_irq_enable, +static struct pl031_vendor_data arm_pl031 = { + .ops = { + .read_time = pl031_read_time, + .set_time = pl031_set_time, + .read_alarm = pl031_read_alarm, + .set_alarm = pl031_set_alarm, + .alarm_irq_enable = pl031_alarm_irq_enable, + }, }; /* The First ST derivative */ -static struct rtc_class_ops stv1_pl031_ops = { - .read_time = pl031_read_time, - .set_time = pl031_set_time, - .read_alarm = pl031_read_alarm, - .set_alarm = pl031_set_alarm, - .alarm_irq_enable = pl031_alarm_irq_enable, +static struct pl031_vendor_data stv1_pl031 = { + .ops = { + .read_time = pl031_read_time, + .set_time = pl031_set_time, + .read_alarm = pl031_read_alarm, + .set_alarm = pl031_set_alarm, + .alarm_irq_enable = pl031_alarm_irq_enable, + }, }; /* And the second ST derivative */ -static struct rtc_class_ops stv2_pl031_ops = { - .read_time = pl031_stv2_read_time, - .set_time = pl031_stv2_set_time, - .read_alarm = pl031_stv2_read_alarm, - .set_alarm = pl031_stv2_set_alarm, - .alarm_irq_enable = pl031_alarm_irq_enable, +static struct pl031_vendor_data stv2_pl031 = { + .ops = { + .read_time = pl031_stv2_read_time, + .set_time = pl031_stv2_set_time, + .read_alarm = pl031_stv2_read_alarm, + .set_alarm = pl031_stv2_set_alarm, + .alarm_irq_enable = pl031_alarm_irq_enable, + }, }; static struct amba_id pl031_ids[] = { { .id = 0x00041031, .mask = 0x000fffff, - .data = &arm_pl031_ops, + .data = &arm_pl031, }, /* ST Micro variants */ { .id = 0x00180031, .mask = 0x00ffffff, - .data = &stv1_pl031_ops, + .data = &stv1_pl031, }, { .id = 0x00280031, .mask = 0x00ffffff, - .data = &stv2_pl031_ops, + .data = &stv2_pl031, }, {0, 0}, };