From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751654AbcA0EXf (ORCPT ); Tue, 26 Jan 2016 23:23:35 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:27793 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751021AbcA0EXb (ORCPT ); Tue, 26 Jan 2016 23:23:31 -0500 X-AuditID: cbfec7f5-f79b16d000005389-b8-56a8463f236c Subject: Re: [PATCH v4 06/10] rtc: max77686: Add max77802 support To: Javier Martinez Canillas , linux-kernel@vger.kernel.org References: <1453865806-4661-1-git-send-email-javier@osg.samsung.com> <1453865806-4661-7-git-send-email-javier@osg.samsung.com> Cc: Kukjin Kim , rtc-linux@googlegroups.com, Andi Shyti , Chanwoo Choi , Alexandre Belloni , Laxman Dewangan , linux-samsung-soc@vger.kernel.org From: Krzysztof Kozlowski Message-id: <56A84636.2000107@samsung.com> Date: Wed, 27 Jan 2016 13:23:18 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-version: 1.0 In-reply-to: <1453865806-4661-7-git-send-email-javier@osg.samsung.com> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrALMWRmVeSWpSXmKPExsVy+t/xy7r2bivCDJYsNLXouLaYyWL7kWes Fte/PGe1ePN2DZPF6xeGFv2PXzNbLN23msXi8q45bBYzzu9jstjf2cHowOXxZNNFRo89E0+y eWxa1cnm0dv8js1jS/9ddo++LasYPT5vkgtgj+KySUnNySxLLdK3S+DK2L/tN1PBLYmK16/N Ghg/CXcxcnJICJhItG95xwJhi0lcuLeerYuRi0NIYCmjxKuvs1ghnKeMEhsXvGUEqRIWcJS4 vf46WIeIQKjEv4u3GSGKGhklpp2dxgLiMAtMZpJ429rHBlLFJmAssXn5EiCbg4NXQEvi/YNo EJNFQFXiy+kwkApRgQiJw51d7CA2r4CgxI/J91hASjgF3CS+fZQEMZkF9CTuX9QCqWAWkJfY vOYt8wRGgVlIGmYhVM1CUrWAkXkVo2hqaXJBcVJ6rpFecWJucWleul5yfu4mRkg8fN3BuPSY 1SFGAQ5GJR7eG/uXhwmxJpYVV+YeYpTgYFYS4RW3WxEmxJuSWFmVWpQfX1Sak1p8iFGag0VJ nHfmrvchQgLpiSWp2ampBalFMFkmDk6pBsYQbqZDkWxbXr87uWttbPlJ5SPGsXezRcLeelxc aMjN+nPWVPngg7d2PLR3Fb2w6upbrync5Y++HmhesHmFn7jyT+lZtprWz404xQMd/Brl2bce m2i+011oi+r6pOXfDfaZtl99actgvkIo3ODjZrba8MBM1gom6fTItPdPb2oEV8QyCeh1OSqx FGckGmoxFxUnAgBRdz0vgwIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27.01.2016 12:36, Javier Martinez Canillas wrote: > The MAX77686 and MAX77802 RTC IP blocks are very similar with only > these differences: > > 0) The RTC registers layout and addresses are different. > > 1) The MAX77686 use 1 bit of the sec/min/hour/etc registers as the > alarm enable while MAX77802 has a separate register for that. > > 2) The MAX77686 RTCYEAR register valid values range is 0..99 while > for MAX77802 is 0..199. > > 3) The MAX77686 has a separate I2C address for the RTC registers > while the MAX77802 uses the same I2C address as the PMIC regs. > > 5) The minimum delay before a RTC update (16 msecs vs 200 usecs). > > There are separate drivers for MAX77686 and MAX77802 RTC IP blocks > but the differences are not that big so the driver can be extended > to support both instead of duplicating a lot of code in 2 drivers. > > Suggested-by: Krzysztof Kozlowski > Signed-off-by: Javier Martinez Canillas > Acked-by: Laxman Dewangan > Tested-by: Krzysztof Kozlowski > Reviewed-by: Andi Shyti > > --- > > Changes in v4: > - Add Krzysztof Kozlowski's Tested-by tag to patch #6. > - Add Andi Shyti's Reviewed-by tag to patch #6. > - Reverse alarm enable reg check logic. Suggeted by Krzysztof Kozlowski. > - Return early to avoid an else statement. Suggested by Andi Shyti. > > Changes in v3: > - Add Laxman Dewangan's Acked-by tag to patch #6. > > Changes in v2: > - Add a MAX77802 prefix to ALARM_ENABLE_VALUE. Suggested by Krzysztof Kozlowski. > - Rename .rtcae to .alarm_enable_reg and .rtcrm to .separate_i2c_addr. > Suggested by Krzysztof Kozlowski. > - Don't use func and LINE in error messages. Suggested by Krzysztof Kozlowski. > - Remove REG_RTC_AE2 since is not used by neither max77686 nor max77802. > - Check if REG_RTC_AE1 has a valid address before accessing it. > > drivers/rtc/rtc-max77686.c | 196 ++++++++++++++++++++++++++++++++++++--------- > 1 file changed, 156 insertions(+), 40 deletions(-) > Reviewed-by: Krzysztof Kozlowski One comment at the end... [...] > @@ -524,6 +636,9 @@ static int max77686_rtc_probe(struct platform_device *pdev) > info->drv_data = (const struct max77686_rtc_driver_data *) > id->driver_data; > > + if (!info->drv_data->separate_i2c_addr) > + info->max77686->rtc_regmap = info->max77686->regmap; > + At this stage I don't like the idea of messing with parent's state structure. The driver should not modify any of parents data (the best way would be to take a pointer to const). In this patch this looks like breaking the encapsulation. If the parent is responsible for regmaps, then the parent should set rtc_regmap for children (parent also knows what type device it is working on). ...but I am assuming that a new patch will be following this one - the patch moving ownership of i2c dummy and regmap to the RTC driver. In that case this code makes a lot more sense. Am I thinking correctly? Best regards, Krzysztof