Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1397911pxk; Fri, 4 Sep 2020 08:25:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOQ7qp+kaAzlLMZ25JBLj64y78jb9cKa4HKcAJFfdP7/3EVojZWPvCzcgVrj9eL3sZ/HBY X-Received: by 2002:a17:906:c0d1:: with SMTP id bn17mr7677623ejb.311.1599233121392; Fri, 04 Sep 2020 08:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599233121; cv=none; d=google.com; s=arc-20160816; b=WadnbvTKaVD5jfcz1Ejpgdzjdzq6hvKND7FHwCfMmuMkySrDlJ+LmCOuwk0kZ1DWru uy+0gRegar1+fW4ROBqIHYD32wWiQtJ0+ZuRxXJqAE4/8MUU9yen7hD2IGipqSOEvD5S AzO9v9KoVGW+0x6lvKoX4mZKq3er8IgzA9YHWcBted/GnkuhOQYLYHKfIRNPRdFWqQ75 3Crg+nmWyakdhEa0R3HA5nBKDdNLdtJpvYD6sw5ehPuVQdVz/Nya0NpvJuFkXMwywlBm r5wkUVTzeoN8xHobU6Qt0Ln+Iilkm2tBQvS88L+sBHwvUkj/PcySdPxWjnYbmzLcGvNU EceQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c+NW3ywAC/uanmt42NpnVbbuokCChZKYNRWziVF2DC4=; b=GehhBrcb8jWlCqGwhAy8XXnysJKkf/Ki38zK3w5jKRR2s+YXBj8PHuXavmsqLTzha/ J9k+PTctzo6698XJD0LsuJUntlmIpQ1qMYxOTrg1V/R1sVO+Q+2CqunTtdypgCTyuPFg jIb2Inmnre8hmYACvMxleOhNMm48MIrpWPimZK517xZ14cp7inQf81smYSsITlFGTWTA jgWJ+KQC/yFhfHS4eHmofdHDqwUWkXlb7J14c9d7KDNV5utwpM/C91HDDuCrM6MhGOvi YYK5lIe+awz7Ud1JYXKJRCKAhUvavxtt4g4aUlRXMVlVjJ/kwG/M+ylvlYhmskxQne0Y 19YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=N2blinJj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c33si1051468edf.530.2020.09.04.08.24.56; Fri, 04 Sep 2020 08:25:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=N2blinJj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730870AbgIDPWC (ORCPT + 99 others); Fri, 4 Sep 2020 11:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730777AbgIDPVa (ORCPT ); Fri, 4 Sep 2020 11:21:30 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F35C061245 for ; Fri, 4 Sep 2020 08:21:28 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id t10so7173241wrv.1 for ; Fri, 04 Sep 2020 08:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c+NW3ywAC/uanmt42NpnVbbuokCChZKYNRWziVF2DC4=; b=N2blinJjlupo88maqUS5WAVYUyr4cxdQ/rPg+8LSJY7CEPEpxcFJhypybzP5x7Z/Nm yAJhPV3cpxBcd60hXygcgcH7AR+nGWKLfJ7Cv5dpnUe0tLctk2M9ZFINwnFcTZF3ydz7 DlBED3Hz2zkW54uoD/Gtdl2ITJrjDCHDqDOEzOFM1KFx+luO59Nhad90V+4GY9Gfv8yl 9n7/6UlXhxjWci5hFnYNAj6edZWfWEOSG25t4zJdYFZEvyp1qZEJPGXDVqW8BuWIiqlK IiSYTF/YNhPQh/feA5TbMizHcAvFnuKdOGYEuV4NsENV+rVTG76FVmKlFx31zFNA+Cdm 21xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c+NW3ywAC/uanmt42NpnVbbuokCChZKYNRWziVF2DC4=; b=DVT1EOpYCl3A/JT+e5VfdhXuZSnaoMkPrf2VIKcTmwipctk7z3GKkBIz8Lr7O+z3/1 7IU/btjQAOeGE/8xBZvuQkF5uQtOuMBHhKIaq4NKjJz6a5sSubddOXw8iGnn7bouW3LG 3XJD91oktGz9123HXICtRX9Vx+lSXWPdjnZLNFiCnvxA6aegCYGGLENzrXg3YhCNYi4F nS/PDj60XBGLkLNVIkdNjNoZDVzuVWqUU91tueO14Kpu4hsn4kwpeVc61igrBi0dqdpB hSH1XwA8xyySkhwjtwLMTQGY2r8XRCzD/hYvl0+TjdbJM9VXw0kUxNiZUCxqtzBOV8h2 FWbA== X-Gm-Message-State: AOAM5335OGeo/HVoPZ+gDSHaVonWFdcU1m9hp8XcRLg4sI0gs3hbzYdl a9ZX5i5CwULHc27r/vrIck2HSQ== X-Received: by 2002:adf:f44d:: with SMTP id f13mr2605254wrp.224.1599232887545; Fri, 04 Sep 2020 08:21:27 -0700 (PDT) Received: from debian-brgl.home (lfbn-nic-1-68-20.w2-15.abo.wanadoo.fr. [2.15.159.20]) by smtp.gmail.com with ESMTPSA id a11sm7789534wmm.18.2020.09.04.08.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 08:21:27 -0700 (PDT) From: Bartosz Golaszewski To: Alessandro Zummo , Alexandre Belloni Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 5/8] rtc: rx8010: don't use magic values for time buffer length Date: Fri, 4 Sep 2020 17:21:13 +0200 Message-Id: <20200904152116.2157-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200904152116.2157-1-brgl@bgdev.pl> References: <20200904152116.2157-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski The time buffer len is used directly in this driver. For readability it's better to define a constant. Signed-off-by: Bartosz Golaszewski --- drivers/rtc/rtc-rx8010.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c index 67ff06a76629..f3bed7be2533 100644 --- a/drivers/rtc/rtc-rx8010.c +++ b/drivers/rtc/rtc-rx8010.c @@ -48,6 +48,8 @@ #define RX8010_ALARM_AE BIT(7) +#define RX8010_TIME_BUF_LEN 7 + static const struct i2c_device_id rx8010_id[] = { { "rx8010", 0 }, { } @@ -108,7 +110,7 @@ static irqreturn_t rx8010_irq_1_handler(int irq, void *dev_id) static int rx8010_get_time(struct device *dev, struct rtc_time *dt) { struct rx8010_data *rx8010 = dev_get_drvdata(dev); - u8 date[7]; + u8 date[RX8010_TIME_BUF_LEN]; int flagreg, err; flagreg = i2c_smbus_read_byte_data(rx8010->client, RX8010_FLAG); @@ -121,8 +123,8 @@ static int rx8010_get_time(struct device *dev, struct rtc_time *dt) } err = i2c_smbus_read_i2c_block_data(rx8010->client, RX8010_SEC, - 7, date); - if (err != 7) + RX8010_TIME_BUF_LEN, date); + if (err != RX8010_TIME_BUF_LEN) return err < 0 ? err : -EIO; dt->tm_sec = bcd2bin(date[RX8010_SEC - RX8010_SEC] & 0x7f); @@ -139,7 +141,7 @@ static int rx8010_get_time(struct device *dev, struct rtc_time *dt) static int rx8010_set_time(struct device *dev, struct rtc_time *dt) { struct rx8010_data *rx8010 = dev_get_drvdata(dev); - u8 date[7]; + u8 date[RX8010_TIME_BUF_LEN]; int ctrl, flagreg, err; if ((dt->tm_year < 100) || (dt->tm_year > 199)) @@ -164,7 +166,8 @@ static int rx8010_set_time(struct device *dev, struct rtc_time *dt) date[RX8010_WDAY - RX8010_SEC] = bin2bcd(1 << dt->tm_wday); err = i2c_smbus_write_i2c_block_data(rx8010->client, - RX8010_SEC, 7, date); + RX8010_SEC, RX8010_TIME_BUF_LEN, + date); if (err < 0) return err; -- 2.26.1