Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2923415iog; Mon, 27 Jun 2022 05:52:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tiKx7sgXqXdX8w0YsJx1pC01Me5ZdjffFkIH2e1fYagqtt41boRomTlFNCbH3NvgxOJVAq X-Received: by 2002:a17:902:a601:b0:16a:6632:7f14 with SMTP id u1-20020a170902a60100b0016a66327f14mr14681528plq.2.1656334347072; Mon, 27 Jun 2022 05:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656334347; cv=none; d=google.com; s=arc-20160816; b=RK4Iw1CnoOnO9Yhi1WpyRqIIW+jCxaE63Kq14y9QYb6W+gjlSV6ghHmX3lRW/7UQNf NHIRw2dcjEJEqVSXxoWj04nwCYETvIo7BFxv3bAnQVOd5XM35K+dDeniTJhlVwTpMlIC bP/x6Nbyf+bUq/HUOLkysE1At4AVm9lFqvNIHEjL1f+u2u9iLmJ9ELkA1ywtfxBh0YKh CTaAWTuevk6rXw6RsE8zcSwX2dbCqiUlmccluT6Wq8t1Hm/GdHVExV+FAjr644q3kBwA G3Vdv2Tl3TeUtPZduzh5T0MnVpw/uG/FcZfPDEtgFbCJiaFBAi90rxNT7BPkruP6axED dEWg== 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; bh=blJgpSk7BEDV57VFDkm4VvIw/DcN2eVCyty+FFKGTN0=; b=TsyM2W2IatPvwJI5fmUta00vlMiIEV8icOMTwMn/AYz/gtWRmzUDrqUwKY2StMqnGG 54lK8JUMMFrjqDtEIkb+sNITAwVlTJ1t4VHOaREG/VzarPrcdiAGxtpQGmRBCL6pozia axclu4xRMeGwugYeBtShsVK6j2bfQ7in2vry60/+c+NfnkNu37dQJaLScHgVRoUsS/5q kNo0Ky05wslwwhKFteFv+oNzMYfy+pw07gjrfCBjYq6/RMu0+CrzZgvUE87ZP2LNISm+ 4XT1fh9QZrsLQKSREU0AbkkrYEVlK/G/WQje8mfU+QFLXO+iox37pXqLF/M9QvQKe3CM 47JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qe11-20020a17090b4f8b00b001df8f8d3daasi11036557pjb.162.2022.06.27.05.52.15; Mon, 27 Jun 2022 05:52:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236110AbiF0Mbf (ORCPT + 99 others); Mon, 27 Jun 2022 08:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236031AbiF0MbL (ORCPT ); Mon, 27 Jun 2022 08:31:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3119EBF7F for ; Mon, 27 Jun 2022 05:31:10 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3242C19F0; Mon, 27 Jun 2022 05:31:10 -0700 (PDT) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 172523F792; Mon, 27 Jun 2022 05:31:07 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com, etienne.carriere@linaro.org, vincent.guittot@linaro.org, daniel.lezcano@linaro.org, tarek.el-sherbiny@arm.com, adrian.slatineanu@arm.com, souvik.chakravarty@arm.com, wleavitt@marvell.com, wbartczak@marvell.com, Cristian Marussi Subject: [PATCH v3 8/9] firmware: arm_scmi: Add scmi_driver optional setup/teardown callbacks Date: Mon, 27 Jun 2022 13:30:37 +0100 Message-Id: <20220627123038.1427067-9-cristian.marussi@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220627123038.1427067-1-cristian.marussi@arm.com> References: <20220627123038.1427067-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add optional .setup and .teardown methods to the scmi_driver descriptor: such callbacks, if provided, will be called by the SCIM core at driver registration time, so that, an SCMI driver, registered as usual with the module_scmi_driver() helper macro, can provide custom callbacks to be run once for all at module load/unload time to perform specific setup or teardown operations before/after .probe and .remove steps. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/bus.c | 15 +++++++++++++-- include/linux/scmi_protocol.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index f6fe723ab869..e95085a66bc4 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -132,12 +132,21 @@ int scmi_driver_register(struct scmi_driver *driver, struct module *owner, { int retval; - if (!driver->probe) + if (!driver->probe || !driver->id_table) return -EINVAL; + if (driver->setup) { + retval = driver->setup(); + if (retval) + return retval; + } + retval = scmi_protocol_device_request(driver->id_table); - if (retval) + if (retval) { + if (driver->teardown) + driver->teardown(); return retval; + } driver->driver.bus = &scmi_bus_type; driver->driver.name = driver->name; @@ -156,6 +165,8 @@ void scmi_driver_unregister(struct scmi_driver *driver) { driver_unregister(&driver->driver); scmi_protocol_device_unrequest(driver->id_table); + if (driver->teardown) + driver->teardown(); } EXPORT_SYMBOL_GPL(scmi_driver_unregister); diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index ad9641dbdd25..a922707bdfe8 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -805,6 +805,8 @@ struct scmi_device_id { struct scmi_driver { const char *name; + int (*setup)(void); + void (*teardown)(void); int (*probe)(struct scmi_device *sdev); void (*remove)(struct scmi_device *sdev); const struct scmi_device_id *id_table; -- 2.32.0