Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/806713/?format=api
{ "id": 806713, "url": "http://patchwork.ozlabs.org/api/patches/806713/?format=api", "web_url": "http://patchwork.ozlabs.org/project/rtc-linux/patch/57598a86-21c7-b354-2840-309563440435@gmail.com/", "project": { "id": 9, "url": "http://patchwork.ozlabs.org/api/projects/9/?format=api", "name": "Linux RTC development", "link_name": "rtc-linux", "list_id": "linux-rtc.vger.kernel.org", "list_email": "linux-rtc@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<57598a86-21c7-b354-2840-309563440435@gmail.com>", "list_archive_url": null, "date": "2017-08-28T18:37:21", "name": "rtc: ds1307: improve weekday handling", "commit_ref": null, "pull_url": null, "state": "rejected", "archived": false, "hash": "ae84f3a55885eac444c3c512d9ca10326cc320f5", "submitter": { "id": 65365, "url": "http://patchwork.ozlabs.org/api/people/65365/?format=api", "name": "Heiner Kallweit", "email": "hkallweit1@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/rtc-linux/patch/57598a86-21c7-b354-2840-309563440435@gmail.com/mbox/", "series": [ { "id": 238, "url": "http://patchwork.ozlabs.org/api/series/238/?format=api", "web_url": "http://patchwork.ozlabs.org/project/rtc-linux/list/?series=238", "date": "2017-08-28T18:37:21", "name": "rtc: ds1307: improve weekday handling", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/238/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/806713/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/806713/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-rtc-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-rtc-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Ij7gaI6W\"; dkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xh0qv0K72z9ryT\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 29 Aug 2017 04:37:31 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751192AbdH1Sha (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tMon, 28 Aug 2017 14:37:30 -0400", "from mail-wr0-f195.google.com ([209.85.128.195]:36022 \"EHLO\n\tmail-wr0-f195.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751184AbdH1Sh3 (ORCPT\n\t<rfc822; linux-rtc@vger.kernel.org>); Mon, 28 Aug 2017 14:37:29 -0400", "by mail-wr0-f195.google.com with SMTP id 40so666111wrv.3\n\tfor <linux-rtc@vger.kernel.org>; Mon, 28 Aug 2017 11:37:29 -0700 (PDT)", "from ?IPv6:2003:ea:8bc7:5e00:d03d:3b20:7ef4:d434?\n\t(p200300EA8BC75E00D03D3B207EF4D434.dip0.t-ipconnect.de.\n\t[2003:ea:8bc7:5e00:d03d:3b20:7ef4:d434])\n\tby smtp.googlemail.com with ESMTPSA id\n\tg51sm1989102wrg.49.2017.08.28.11.37.26\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 28 Aug 2017 11:37:27 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20161025;\n\th=to:cc:from:subject:message-id:date:user-agent:mime-version\n\t:content-transfer-encoding;\n\tbh=O07Td1Tz+ngc1jgWA516bQDpkDLS6eHT8bOchFZ6Af4=;\n\tb=Ij7gaI6W6GwZFz5fS15yanCZexMNdS1OmzHRHeoXjJZa0uI7xJtOlt20zTnZqqKJtZ\n\ttBxvQBGZH3+g39JmpDNQURx3FKR3ZQmv9fAWTKcINQhkDlo/7Zg93eiYTqclhhBWOFR0\n\tFkomfgJOVXiQOOH83YRcVcMjKhv1P0cPEWP+LoXm9CJpjQ4favfJHadE0Z5u6HX8A80w\n\te7YlXOXyiqJyckFMfDmkkUCdAPDxMM0ooIK3bekR6wiG3m6qmB5YrgwDZIjbYGha+Rpr\n\ts4SUYYtudPw5py4hqM149xMPVpLGUug06+wETDwcMnz9Q5GhDRPtHpl8Fh0cu8qtjNIt\n\thEBg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent\n\t:mime-version:content-transfer-encoding;\n\tbh=O07Td1Tz+ngc1jgWA516bQDpkDLS6eHT8bOchFZ6Af4=;\n\tb=ucf4ZqU25AebNFFm5aqwY8NxgifoOzQ86Z0AZaw+qGJxs/C1oNtynKXIceO9IpSMF5\n\tWVbCXVvJFxVnUHomhcl4lPDn+ud8q//NF6TTlypKm2oG34uW17spw6/PGthLrvpT9DlD\n\tMGi9M1X9R7JEkeBZGuvyqaCAOGWEGBniD4rj9ysP8EH6SIopFpzRirosFfnisMiOjTNX\n\t3itLoq9jM8GoHgD/Jji2bOCsAku9RgnvJcFNePoB3leF4SQiMSbIwooFRPtfGnR+Eanz\n\tvYIyrvWSddPXJfcCAmTLvdTpEzMwFGENQmzzymyH12A9kdWVrAIQ0EzXx2dr5e5R6Yff\n\ttN+A==", "X-Gm-Message-State": "AHYfb5i2jAX1xrVn8pAvEdSJY/B1s3NRgn+tsf8F0+p1pCvnZ8OgF/tY\n\twozCmue9rZWqzW/7", "X-Received": "by 10.223.183.7 with SMTP id l7mr988762wre.270.1503945447948;\n\tMon, 28 Aug 2017 11:37:27 -0700 (PDT)", "To": "Alexandre Belloni <alexandre.belloni@free-electrons.com>", "Cc": "linux-rtc@vger.kernel.org", "From": "Heiner Kallweit <hkallweit1@gmail.com>", "Subject": "[PATCH] rtc: ds1307: improve weekday handling", "Message-ID": "<57598a86-21c7-b354-2840-309563440435@gmail.com>", "Date": "Mon, 28 Aug 2017 20:37:21 +0200", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Transfer-Encoding": "7bit", "Sender": "linux-rtc-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-rtc.vger.kernel.org>", "X-Mailing-List": "linux-rtc@vger.kernel.org" }, "content": "mcp794xx as one chip supported by this driver needs the weekday for\nalarm matching. RTC core ignores the weekday so we can't rely on\nthe values we receive in member tm_wday of struct rtc_time.\nTherefore calculate the weekday from date/time when setting the\ntime and setting the alarm time for mcp794xx.\n\nWhen having this in place we don't have to check the weekday\nat each driver load.\nAfter a chip reset date/time and weekday may be out of sync but\nin this case date/time need to be set anyway.\n\nSigned-off-by: Heiner Kallweit <hkallweit1@gmail.com>\n---\n drivers/rtc/rtc-ds1307.c | 39 +++++++++++++++------------------------\n 1 file changed, 15 insertions(+), 24 deletions(-)", "diff": "diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c\nindex 9d680d36..83b8c997 100644\n--- a/drivers/rtc/rtc-ds1307.c\n+++ b/drivers/rtc/rtc-ds1307.c\n@@ -437,6 +437,18 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)\n \treturn rtc_valid_tm(t);\n }\n \n+/*\n+ * Certain chips need the weekday for alarm matching and tm->t_wday\n+ * may be not or not properly populated\n+ */\n+static int ds1307_get_weekday(struct rtc_time *tm)\n+{\n+\ttime64_t secs64 = rtc_tm_to_time64(tm);\n+\tint days = div_s64(secs64, 24 * 60 * 60);\n+\n+\treturn (days + 4) % 7 + 1;\n+}\n+\n static int ds1307_set_time(struct device *dev, struct rtc_time *t)\n {\n \tstruct ds1307\t*ds1307 = dev_get_drvdata(dev);\n@@ -465,7 +477,7 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)\n \tregs[DS1307_REG_SECS] = bin2bcd(t->tm_sec);\n \tregs[DS1307_REG_MIN] = bin2bcd(t->tm_min);\n \tregs[DS1307_REG_HOUR] = bin2bcd(t->tm_hour);\n-\tregs[DS1307_REG_WDAY] = bin2bcd(t->tm_wday + 1);\n+\tregs[DS1307_REG_WDAY] = ds1307_get_weekday(t);\n \tregs[DS1307_REG_MDAY] = bin2bcd(t->tm_mday);\n \tregs[DS1307_REG_MONTH] = bin2bcd(t->tm_mon + 1);\n \n@@ -902,7 +914,7 @@ static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t)\n \tregs[3] = bin2bcd(t->time.tm_sec);\n \tregs[4] = bin2bcd(t->time.tm_min);\n \tregs[5] = bin2bcd(t->time.tm_hour);\n-\tregs[6] = bin2bcd(t->time.tm_wday + 1);\n+\tregs[6] = ds1307_get_weekday(&t->time);\n \tregs[7] = bin2bcd(t->time.tm_mday);\n \tregs[8] = bin2bcd(t->time.tm_mon + 1);\n \n@@ -1355,14 +1367,12 @@ static int ds1307_probe(struct i2c_client *client,\n {\n \tstruct ds1307\t\t*ds1307;\n \tint\t\t\terr = -ENODEV;\n-\tint\t\t\ttmp, wday;\n+\tint\t\t\ttmp;\n \tconst struct chip_desc\t*chip;\n \tbool\t\t\twant_irq;\n \tbool\t\t\tds1307_can_wakeup_device = false;\n \tunsigned char\t\tregs[8];\n \tstruct ds1307_platform_data *pdata = dev_get_platdata(&client->dev);\n-\tstruct rtc_time\t\ttm;\n-\tunsigned long\t\ttimestamp;\n \tu8\t\t\ttrickle_charger_setup = 0;\n \n \tds1307 = devm_kzalloc(&client->dev, sizeof(struct ds1307), GFP_KERNEL);\n@@ -1642,25 +1652,6 @@ static int ds1307_probe(struct i2c_client *client,\n \t\t\t bin2bcd(tmp));\n \t}\n \n-\t/*\n-\t * Some IPs have weekday reset value = 0x1 which might not correct\n-\t * hence compute the wday using the current date/month/year values\n-\t */\n-\tds1307_get_time(ds1307->dev, &tm);\n-\twday = tm.tm_wday;\n-\ttimestamp = rtc_tm_to_time64(&tm);\n-\trtc_time64_to_tm(timestamp, &tm);\n-\n-\t/*\n-\t * Check if reset wday is different from the computed wday\n-\t * If different then set the wday which we computed using\n-\t * timestamp\n-\t */\n-\tif (wday != tm.tm_wday)\n-\t\tregmap_update_bits(ds1307->regmap, MCP794XX_REG_WEEKDAY,\n-\t\t\t\t MCP794XX_REG_WEEKDAY_WDAY_MASK,\n-\t\t\t\t tm.tm_wday + 1);\n-\n \tif (want_irq || ds1307_can_wakeup_device) {\n \t\tdevice_set_wakeup_capable(ds1307->dev, true);\n \t\tset_bit(HAS_ALARM, &ds1307->flags);\n", "prefixes": [] }