Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp625047rdb; Fri, 17 Nov 2023 08:11:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEaH/U0hdnHnSiyTMv10POXJ2TzqWg17X+cjCl9P+fCZQE/V6XEa6Gp5Xf2Xyg2GVuwf3M6 X-Received: by 2002:a17:902:a413:b0:1cc:2f9d:6e9b with SMTP id p19-20020a170902a41300b001cc2f9d6e9bmr37363plq.20.1700237497885; Fri, 17 Nov 2023 08:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700237497; cv=none; d=google.com; s=arc-20160816; b=kxuFYby82Dbo+f4OwYTAV8NO4JPvViXf4UuW0RrJeGTcnZcdVsTJYB6k8Ll9ie7sBk jimBm8fyWjTIRUtAk4M1jjopJPQubYXrZS6WQtJUan11WZaMbhB+GWk9VH0lktO4wd8e zNs3dNSPgwtvQD51rglHbwL4AeAvzLNGeIZkPmFUjYDmcnZ52lOS5FvI5/mvdz5cWp0t 6EuYh67xXJowXKTYeyYP+CJj2/a9S2StmbMXkIfLbluA7gSKm+kAYQJMepWxovmrmjG4 DsmD8pXvQ13Ft/4K4/bNur2Dn/3lNf7X0KY5XjjJZ1k0fCdTj1BwwlUcz6XCzSi67Z8v 7TSQ== 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=T/wBuC6DtVWXHqmfK8fabulf+ENqoFBjAQef4pkVTeM=; fh=ZNXiR1CgqXSElSE++n277vbYyA5ziWtgsjdBgmIqkL4=; b=YsryTWfQJBhB/D00se++8TORndQE/uJrjgKnqRX3nl+M4dWwVkLphSmmIByHfnlq8E +f3UXVV5Rh8EIVgeeMAjfOkKcursfUYhCmiJ9mIzcptiw2x6k6R14RCgAgmBch+Ufn8y 8RWhNNd9Z5xD3dzOo0wdWrxNVtWqFs05J98odnzNe8fYSK2Jg9BgLP6k9O0FN0DAjnEr isId6V0C2pO2qMTJ3ovpQWFx64GfYvnyDrUl2m0Gk5JFBHmxubRB3sj6mVzfkWpLqy1s 6fLpMiWKwcKZDpYMg9Xw96QlDXQybpLNPB8Uyj6yeHXB+KoiFfzQ55qZNk6x2TT3dq/P AF5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CRnP6wGs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u15-20020a170902e5cf00b001ce6693d6edsi56954plf.370.2023.11.17.08.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 08:11:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CRnP6wGs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id DB8698340104; Fri, 17 Nov 2023 08:11:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346133AbjKQQLC (ORCPT + 99 others); Fri, 17 Nov 2023 11:11:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346084AbjKQQKw (ORCPT ); Fri, 17 Nov 2023 11:10:52 -0500 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12DC090; Fri, 17 Nov 2023 08:10:48 -0800 (PST) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3AHGAEte032286; Fri, 17 Nov 2023 10:10:14 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1700237414; bh=T/wBuC6DtVWXHqmfK8fabulf+ENqoFBjAQef4pkVTeM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CRnP6wGsm8MksLN9E655pnO/IhR8fhXvG8PWulKwIit1g6xzStqQ8CS5PFCZDPIav ZIaFBoEZPtpvgInWvFH3Bxl4iI3VE2yicIRMclx8ZZDXzmOl5OvzbNEKKNT6XcUbkF DSC+alD49Y+OdRj0k9OUQlVQdbS28bRMvuKoDBzY= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3AHGAENf081164 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 17 Nov 2023 10:10:14 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) 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:14 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE114.ent.ti.com (10.64.6.35) 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:13 -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 3AHGA8GN004950; Fri, 17 Nov 2023 10:10:13 -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 4/5] spi: sprd: adi: Use devm_register_restart_handler() Date: Fri, 17 Nov 2023 10:10:05 -0600 Message-ID: <20231117161006.87734-5-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, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 17 Nov 2023 08:11:30 -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/spi/spi-sprd-adi.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c index bf01feedbf93f..58c3badd9c79a 100644 --- a/drivers/spi/spi-sprd-adi.c +++ b/drivers/spi/spi-sprd-adi.c @@ -138,8 +138,7 @@ struct sprd_adi_data { u32 slave_offset; u32 slave_addr_size; int (*read_check)(u32 val, u32 reg); - int (*restart)(struct notifier_block *this, - unsigned long mode, void *cmd); + int (*restart)(struct sys_off_data *data); void (*wdg_rst)(void *p); }; @@ -150,7 +149,6 @@ struct sprd_adi { struct hwspinlock *hwlock; unsigned long slave_vbase; unsigned long slave_pbase; - struct notifier_block restart_handler; const struct sprd_adi_data *data; }; @@ -370,11 +368,9 @@ static void sprd_adi_set_wdt_rst_mode(void *p) #endif } -static int sprd_adi_restart(struct notifier_block *this, unsigned long mode, - void *cmd, struct sprd_adi_wdg *wdg) +static int sprd_adi_restart(struct sprd_adi *sadi, unsigned long mode, + const char *cmd, struct sprd_adi_wdg *wdg) { - struct sprd_adi *sadi = container_of(this, struct sprd_adi, - restart_handler); u32 val, reboot_mode = 0; if (!cmd) @@ -448,8 +444,7 @@ static int sprd_adi_restart(struct notifier_block *this, unsigned long mode, return NOTIFY_DONE; } -static int sprd_adi_restart_sc9860(struct notifier_block *this, - unsigned long mode, void *cmd) +static int sprd_adi_restart_sc9860(struct sys_off_data *data) { struct sprd_adi_wdg wdg = { .base = PMIC_WDG_BASE, @@ -458,7 +453,7 @@ static int sprd_adi_restart_sc9860(struct notifier_block *this, .wdg_clk = PMIC_CLK_EN, }; - return sprd_adi_restart(this, mode, cmd, &wdg); + return sprd_adi_restart(data->cb_data, data->mode, data->cmd, &wdg); } static void sprd_adi_hw_init(struct sprd_adi *sadi) @@ -590,9 +585,9 @@ static int sprd_adi_probe(struct platform_device *pdev) } if (sadi->data->restart) { - sadi->restart_handler.notifier_call = sadi->data->restart; - sadi->restart_handler.priority = 128; - ret = register_restart_handler(&sadi->restart_handler); + ret = devm_register_restart_handler(&pdev->dev, + sadi->data->restart, + sadi); if (ret) { dev_err(&pdev->dev, "can not register restart handler\n"); goto put_ctlr; @@ -606,14 +601,6 @@ static int sprd_adi_probe(struct platform_device *pdev) return ret; } -static void sprd_adi_remove(struct platform_device *pdev) -{ - struct spi_controller *ctlr = dev_get_drvdata(&pdev->dev); - struct sprd_adi *sadi = spi_controller_get_devdata(ctlr); - - unregister_restart_handler(&sadi->restart_handler); -} - static struct sprd_adi_data sc9860_data = { .slave_offset = ADI_10BIT_SLAVE_OFFSET, .slave_addr_size = ADI_10BIT_SLAVE_ADDR_SIZE, @@ -657,7 +644,6 @@ static struct platform_driver sprd_adi_driver = { .of_match_table = sprd_adi_of_match, }, .probe = sprd_adi_probe, - .remove_new = sprd_adi_remove, }; module_platform_driver(sprd_adi_driver); -- 2.39.2