Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp624965rdb; Fri, 17 Nov 2023 08:11:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRvbZ2tQ5GOmqexMHSFqhr4sl/E5Vd26x+NAPAUFgZAyYGsf/7PMaZYpG7FBclMdUMzNNz X-Received: by 2002:a17:902:ce01:b0:1cc:3b87:8997 with SMTP id k1-20020a170902ce0100b001cc3b878997mr8621plg.57.1700237491891; Fri, 17 Nov 2023 08:11:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700237491; cv=none; d=google.com; s=arc-20160816; b=mUnPI8FHE9MA5Wq7UcOh57gIhaOWtB2oeY56HSc6lv6L24f3Bb/et37xtGgGlLBS0u TFFd4jPJq/kaGcc84B/CSD6sS7Qk7uUAOq7/eZEyjSKF+cyfqTZmEjMTq8bLWyNvLf7b hk9jBQO6LAMxpJREzitcGydxU/u1Kof55fQZtkqj04CrvlP10STDgd4790gvMaB3x+q8 rmRRBpv1ixG0qZ45/aA5lRedfcH81dvFCvEtjXecBFBU3xKPAJWLLKor5JJxii88C4rj N5CBtbPM/scQIN/GOgCKXJZbpouqK4fq0IJU6+Xa9/FntVGj8CjSBNNq5NNP3aZzKkiD EBDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WJT/GOWye4bOLJhDVAPxuu/+d14nf1WjFFi9pEOVeR0=; fh=ZNXiR1CgqXSElSE++n277vbYyA5ziWtgsjdBgmIqkL4=; b=ZxQVFNtReax+4ppSNgmX0faNsRB8WSpwt6rfu+dTonetLLOqFZWwQziZK0kzyrTHfP 8iUVAWbQS/ptkKYGS5E30MGAYA2JPmxOZs5nYELmVm+mePWCveFcdtWGc4b+pZdiCPyi hTFfl5XEOudJOOYWGfmPw0E2A+A5maL8K9BekecNaQc8iNyPoerAV8zsNdPFLMIKEou1 INdGuzYtAZU9OUNt34iWkHyr48C2S/MF1VNjM4mE4r6jMtoGEhlX7qdlfPMLuCLiWy1G MneFBLSMcmjEWTAcHktFZ7xBfKa14LfaShPrnaSaiRM+3oy6KJTYvwNxbf2Jt7GsRUrX cwew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=f+H9IQOi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id t6-20020a1709027fc600b001b3d6c68bd1si1986025plb.643.2023.11.17.08.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 08:11:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=f+H9IQOi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 02E8D8316EBB; Fri, 17 Nov 2023 08:11:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346087AbjKQQKx (ORCPT + 99 others); Fri, 17 Nov 2023 11:10:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234008AbjKQQKu (ORCPT ); Fri, 17 Nov 2023 11:10:50 -0500 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44883A5; Fri, 17 Nov 2023 08:10:47 -0800 (PST) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3AHGAC0V065961; Fri, 17 Nov 2023 10:10:12 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1700237412; bh=WJT/GOWye4bOLJhDVAPxuu/+d14nf1WjFFi9pEOVeR0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=f+H9IQOiWQoklBsSg45iOmIz74Il/11yhq18CCiEx0h8trl5XLeyvORCUkP0kT8kb I4tyBGD8Tw+b+aisKiaxjr2kc7wT0Fr9c3T+nz4V0DE+vgxWHdgBMwACTWl/fJxCus sF0NzjYa40dK+pGDvnUFznV1jmSzm0YMHr2LmLNc= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3AHGACpL070310 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 17 Nov 2023 10:10:12 -0600 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 17 Nov 2023 10:10:11 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 17 Nov 2023 10:10:11 -0600 Received: from fllv0039.itg.ti.com (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3AHGA8GL004950; Fri, 17 Nov 2023 10:10:10 -0600 From: Andrew Davis To: Mark Rutland , Lorenzo Pieralisi , Sebastian Reichel , Karol Gugala , Mateusz Holenko , Gabriel Somlo , Joel Stanley , Mark Brown , Orson Zhai , Baolin Wang , Chunyan Zhang , Lee Jones , Dmitry Osipenko CC: , , , , Andrew Davis Subject: [PATCH RFC 2/5] drivers/soc/litex: Use devm_register_restart_handler() Date: Fri, 17 Nov 2023 10:10:03 -0600 Message-ID: <20231117161006.87734-3-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231117161006.87734-1-afd@ti.com> References: <20231117161006.87734-1-afd@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 17 Nov 2023 08:11:19 -0800 (PST) Use device life-cycle managed register function to simplify probe error path and eliminate need for explicit remove function. Signed-off-by: Andrew Davis --- drivers/soc/litex/litex_soc_ctrl.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/soc/litex/litex_soc_ctrl.c b/drivers/soc/litex/litex_soc_ctrl.c index 10813299aa106..7a0096d93c73d 100644 --- a/drivers/soc/litex/litex_soc_ctrl.c +++ b/drivers/soc/litex/litex_soc_ctrl.c @@ -69,14 +69,11 @@ static int litex_check_csr_access(void __iomem *reg_addr) struct litex_soc_ctrl_device { void __iomem *base; - struct notifier_block reset_nb; }; -static int litex_reset_handler(struct notifier_block *this, unsigned long mode, - void *cmd) +static int litex_reset_handler(struct sys_off_data *data) { - struct litex_soc_ctrl_device *soc_ctrl_dev = - container_of(this, struct litex_soc_ctrl_device, reset_nb); + struct litex_soc_ctrl_device *soc_ctrl_dev = data->cb_data; litex_write32(soc_ctrl_dev->base + RESET_REG_OFF, RESET_REG_VALUE); return NOTIFY_DONE; @@ -107,11 +104,9 @@ static int litex_soc_ctrl_probe(struct platform_device *pdev) if (error) return error; - platform_set_drvdata(pdev, soc_ctrl_dev); - - soc_ctrl_dev->reset_nb.notifier_call = litex_reset_handler; - soc_ctrl_dev->reset_nb.priority = 128; - error = register_restart_handler(&soc_ctrl_dev->reset_nb); + error = devm_register_restart_handler(&pdev->dev, + litex_reset_handler, + soc_ctrl_dev); if (error) { dev_warn(&pdev->dev, "cannot register restart handler: %d\n", error); @@ -120,20 +115,12 @@ static int litex_soc_ctrl_probe(struct platform_device *pdev) return 0; } -static void litex_soc_ctrl_remove(struct platform_device *pdev) -{ - struct litex_soc_ctrl_device *soc_ctrl_dev = platform_get_drvdata(pdev); - - unregister_restart_handler(&soc_ctrl_dev->reset_nb); -} - static struct platform_driver litex_soc_ctrl_driver = { .driver = { .name = "litex-soc-controller", .of_match_table = of_match_ptr(litex_soc_ctrl_of_match) }, .probe = litex_soc_ctrl_probe, - .remove_new = litex_soc_ctrl_remove, }; module_platform_driver(litex_soc_ctrl_driver); -- 2.39.2