Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp434268pxk; Fri, 11 Sep 2020 10:46:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziUR4f6cq0wk2H7b3gZ1wZJJ0NnJpm6gQYaomuFL8ZEoMJsqbzARy7+RBA8AA5XzUE/g6P X-Received: by 2002:a17:906:f8d1:: with SMTP id lh17mr3000506ejb.409.1599846378343; Fri, 11 Sep 2020 10:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599846378; cv=none; d=google.com; s=arc-20160816; b=jHVMDUaq8YPr8je0wnEiCm7mQ25kFi3iOABojoD4uD77eujs5u0KyiNxsyK56fYhqC hGFOoLBbZvqExwjOZAA0LSPM3M1PqBPDTk4u1Efv9iJTzxkxP3OaKN3KQmbLaKln0nGv /QW6ciNOnerAvwL44yAkLGUbw/w2BLHTWmZt1BnUcRiYnZI2ktLlbaflwPlItfIAfg7I a3fnSmt9TE44+AHDEQYCvXSM6sif1A99YPL7eRT9xzw8BBgv83Zgway1YVBoqE2l7XZl RVupajexf1v/IYiywfI/WK9xpgfGz6TSIP35uTblWDBoRDos7EUC9d1ovyFfVkmMwLqL 3iZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=c67lZrfuPG9UEb4z+gGzewLHNymIshXcnV6L3t1rNMU=; b=kWntGGaLUTDLp7oF7ur50vYk130a4Yf9KSt+5icvLROp/71+nxpxes5jSm9Chpr6KQ 347cmlpqe6lPMPmRzkDY/eGb6ssT+yHCD2aYgG92K62WHgEZXcDtHcJ1dNnRTBq2/SgK qojY1GPmID0L1Cl42jelIQCIENKV2lqHFo0YVKvDeDox7PSN8MhjvHJ7UKPO4gBs2w4w LkX75HRcd+tqIiPq4+t54iUnOunDiyf+RpnOAv2z7jjxJUy4nSP16iBV4HCa59pDWt4z tRdvKYU60ppdBCToTPOb8qULRODwkNUQV5MHKYK5OPSCMCc5coH7/IRis94F5JmJodLz 9I9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=kCrWHuwt; 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 f7si1710176ejt.351.2020.09.11.10.45.55; Fri, 11 Sep 2020 10:46:18 -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=kCrWHuwt; 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 S1725870AbgIKRpS (ORCPT + 99 others); Fri, 11 Sep 2020 13:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbgIKMd6 (ORCPT ); Fri, 11 Sep 2020 08:33:58 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9C8CC061573 for ; Fri, 11 Sep 2020 05:33:58 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id p13so8830367ils.3 for ; Fri, 11 Sep 2020 05:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c67lZrfuPG9UEb4z+gGzewLHNymIshXcnV6L3t1rNMU=; b=kCrWHuwtfF3Kz6oMUFtaIUJYr7GSVZJv9D6I7/BRCW7yvjyLMOlhDR3l+5dk1/eyaR 3o6dqr2G+mnq7Wjvr7Sg37CwfxuzvzDxIrsidoeEAd98fiz9dLVHS0mhMvrig9lnJ+YQ ZiZf82Hr/V+EWT1YkS3G0O3JgiEcg0rs2+eT6gVemAq0LUiqHYSv1OAXTn7h6xFI9Li1 kLhYCDp1HcXFTINC3q8q8Gw2Mr/Ar/k6mxEHJnk1zZihbWJu1oXT75cVOLSNKGJCPHio sTNlxvPvJmuV2NPPHdn8vnIB0a3IgbLsyjvClnEbgS05b6QCVl9IcrMmqLz0Y9mVaWRn g92A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=c67lZrfuPG9UEb4z+gGzewLHNymIshXcnV6L3t1rNMU=; b=LqYL+prlP/3wHEeh0HAWmybihygv8qOrcwFsE5yzDnnuhQoyHTRFtgK0HJbVzkVWpT 0VjUIiHpdzImx4aQBkKI6RHBheJ2zR63snKI+0ebobxjq+fg2i4zWI8khh6bowjUoiMX LEmE3H4QM+VdGkX4H1SSq1NqPqNbo7ccZgNaL5YIAxw9T8WakKV/hwM5wjafW+O+qc0C ovwmmtBNPID0z/Utelk1auNHDCVbc5m80DexMu2Aw+i1627F01JsH7vTYkc6KtIXPgJz evDGmc7SY6t2plboH0yfeqVP8uaasTys858uAf1Tj7fkguXeYVqY5SaSqtco7cXq3vY2 Z+sg== X-Gm-Message-State: AOAM530Mj5N2E/c3xhT/azEtBor0ekdFEBvkcGuoJ0OIP+LPl/TFNSiY DXeMjTMtHCZC0d0bpNNmpPvQmDbkxswFXcFUtDj7EQ== X-Received: by 2002:a05:6e02:968:: with SMTP id q8mr1513812ilt.220.1599827637490; Fri, 11 Sep 2020 05:33:57 -0700 (PDT) MIME-Version: 1.0 References: <20200904152116.2157-1-brgl@bgdev.pl> <20200904152116.2157-8-brgl@bgdev.pl> <20200904154144.GL230586@piout.net> <20200911122837.GC230586@piout.net> In-Reply-To: <20200911122837.GC230586@piout.net> From: Bartosz Golaszewski Date: Fri, 11 Sep 2020 14:33:46 +0200 Message-ID: Subject: Re: [PATCH 7/8] rtc: rx8010: fix indentation in probe() To: Alexandre Belloni Cc: Bartosz Golaszewski , Alessandro Zummo , linux-rtc@vger.kernel.org, LKML 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 On Fri, Sep 11, 2020 at 2:28 PM Alexandre Belloni wrote: > > On 07/09/2020 11:34:59+0200, Bartosz Golaszewski wrote: > > On Fri, Sep 4, 2020 at 5:41 PM Alexandre Belloni > > wrote: > > > > > > On 04/09/2020 17:21:15+0200, Bartosz Golaszewski wrote: > > > > From: Bartosz Golaszewski > > > > > > > > Align the arguments passed to devm_rtc_device_register() with the upper > > > > line. > > > > > > > > Signed-off-by: Bartosz Golaszewski > > > > --- > > > > drivers/rtc/rtc-rx8010.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c > > > > index 181fc21cefa8..ed8ba38b4991 100644 > > > > --- a/drivers/rtc/rtc-rx8010.c > > > > +++ b/drivers/rtc/rtc-rx8010.c > > > > @@ -450,7 +450,7 @@ static int rx8010_probe(struct i2c_client *client, > > > > } > > > > > > > > rx8010->rtc = devm_rtc_device_register(&client->dev, client->name, > > > > - &rx8010_rtc_ops, THIS_MODULE); > > > > + &rx8010_rtc_ops, THIS_MODULE); > > > > > > > > > > You have bonus points if you replace that patch by switching from > > > devm_rtc_device_register to devm_rtc_allocate_device and > > > rtc_register_device. > > > > > > More bonus points if you also set range_min and range_max and then get > > > rid of the range checking in set_time. > > > > > > > Hi Alexandre! > > > > I've just looked at the code and wondered why there's no devm > > counterpart for rtc_register_device(). Then I noticed that the release > > callback for devm_rtc_allocate_device() takes care of unregistering > > the device. This looks like serious devres abuse to me. In general the > > idea is for the release callback to only undo whatever the devres > > function did and this should be opaque to the concerned resources. > > > > In this case I believe there's no need for the 'registered' field in > > struct rtc_device - this structure should *not* care about this - and > > there should be devm_rtc_register_device() whose release callback > > would take care of the unregistering. Since this function would be > > called after devm_rtc_allocate_device(), it would be released before > > so the ordering should be fine. > > > > Note that the input subsystem is also doing it that way which is > probably not a good reason alone to do it like that. But, IIRC, there I'm seeing this pattern elsewhere in the kernel too and I just recently fixed this for MDIO. I think it's just a matter of people copy-pasting a bad implementation. > was an actual reason this was done this way and it was the ordering of > the rtc_nvmem_register/rtc_nvmem_unregister with rtc_device_unregister. > I'm not sure this is still necessary though. > To me - each of these should have their own 'unregister' function and appropriate devres helpers *OR* RTC-related nvmem structures could be set up and assigned to struct rtc_device after devm_rtc_allocate_device() and picked up by the registration function (and also undone by rtc_unregister_device()). I'll try to allocate some time to look into this but it's not like it's urgent or anything - it's just a potential improvement. Bartosz