Received: by 10.192.165.156 with SMTP id m28csp1082227imm; Wed, 11 Apr 2018 12:04:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx487HJSF11fHtRAq3RNVMZEprjLYXBZ6XWExVTNshudtDGZfefyx98qXLcyWz/ZJ2H3OUr/k X-Received: by 10.99.95.22 with SMTP id t22mr4410338pgb.315.1523473495741; Wed, 11 Apr 2018 12:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523473495; cv=none; d=google.com; s=arc-20160816; b=xIJWw9BQn7XUYVYEjkgOYBsbnhCwAg2P8NX68saLfQ0WLMLxNmmulom0P7GaJrJLQK 13Gi54y1q1S92Z+wDl/FasBKr0v14gik2r/mUfOyDUrfq68ebuseD3Bty0FGImPJHYmA nhpPpji64BASxnDLqZYIPCbhvJRS3gXNZWFJkRwSVtRBp+B725Y8UKhuXCB1JmoYeC52 WZkvGJqM4TyfebSbWlP1BchC04TboSc76iYJUxP5R4pPOjncIIrxlmeCFw9y3HKqI3Pk +evVHX1Tfkkmw0o9MHZZsMzUMRPe/HEw5FeD7n2xyID67WdyVo5bHaR/gis2hMIkEuIS Hu6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Us2jcT793qaf+gZOhpgNvyyaaKftPGXpPLpAPHhvY0Y=; b=JdAcUfxc/NDfY4FvcogPyvuNWK16pKkd0XH8n+udZX04qn3spIGESHfVpqolNI4ABG XeEIzRFbZt9aJ3woloteVyQK36GvgFPYF7aQFSaYMBAP5vEyp1EUQtALIrFxjySBGEda q7jcVSTJdR5h/tzrkGbKGe3H77yWdFw0+H8BNZhBWP1R1UeD7cHUw/50PTBUt5AbeHW1 Ae9JZ7Ge66HRUQIpzUvMBFqs6BZfUBVJhWJUoKjixGFa9S2QpIZTJf9VOy2E8fmwcggJ sCXp7SOC+bKbO+9MFVq88hUhqSzqGQb3kGs4VrvYb2PTC7XC83JEpDS9BNHJqgTJTIZi yr+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6-v6si1754643pln.619.2018.04.11.12.04.19; Wed, 11 Apr 2018 12:04:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756610AbeDKS75 (ORCPT + 99 others); Wed, 11 Apr 2018 14:59:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37544 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753050AbeDKS7z (ORCPT ); Wed, 11 Apr 2018 14:59:55 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 874F59C1; Wed, 11 Apr 2018 18:59:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gary Bisson , Alexandre Belloni , Sasha Levin Subject: [PATCH 4.9 160/310] rtc: m41t80: fix SQW dividers override when setting a date Date: Wed, 11 Apr 2018 20:34:59 +0200 Message-Id: <20180411183629.277414543@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gary Bisson [ Upstream commit 0f546b058b86ea2f661cc7a6e931cee5a29959ef ] This patch is only relevant for RTC with the SQ_ALT feature which means the clock output frequency divider is stored in the weekday register. Current implementation discards the previous dividers value and clear them as soon as the time is set. Signed-off-by: Gary Bisson Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-m41t80.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c @@ -168,6 +168,7 @@ static int m41t80_get_datetime(struct i2 /* Sets the given date and time to the real time clock. */ static int m41t80_set_datetime(struct i2c_client *client, struct rtc_time *tm) { + struct m41t80_data *clientdata = i2c_get_clientdata(client); unsigned char buf[8]; int err, flags; @@ -183,6 +184,17 @@ static int m41t80_set_datetime(struct i2 buf[M41T80_REG_YEAR] = bin2bcd(tm->tm_year - 100); buf[M41T80_REG_WDAY] = tm->tm_wday; + /* If the square wave output is controlled in the weekday register */ + if (clientdata->features & M41T80_FEATURE_SQ_ALT) { + int val; + + val = i2c_smbus_read_byte_data(client, M41T80_REG_WDAY); + if (val < 0) + return val; + + buf[M41T80_REG_WDAY] |= (val & 0xf0); + } + err = i2c_smbus_write_i2c_block_data(client, M41T80_REG_SSEC, sizeof(buf), buf); if (err < 0) {