Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp46892rbe; Wed, 28 Feb 2024 11:33:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdbABxcuovC8tlmwwdAYjE66JUbyWPrAgErkLjsOC/mlMIw97AMl3GNIZg9diwki6OHT2B/szaCunMxsuL5SqY6kDLcDJmWjBCEDz3LA== X-Google-Smtp-Source: AGHT+IG7+dGat5YrWUhQfk6djUFfPaClUmrtfl7unyvcQ2Aq/41wXT+UwS/g2G2pBX2PZWpwLPGZ X-Received: by 2002:a17:906:dc53:b0:a3e:720a:b961 with SMTP id yz19-20020a170906dc5300b00a3e720ab961mr476403ejb.34.1709148826592; Wed, 28 Feb 2024 11:33:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709148826; cv=pass; d=google.com; s=arc-20160816; b=GBGuh6r/0IDQGeSzXlzNS+Td/qlFQ0mWqC1/vgtjKLLKZ6zdc+BXbq9yncFFic6aWS cYEp8v+TTjxAA3fpszo/YTmYDJaehYasKYOK+69WbtdtkfY6/Cd51coVY1oyHhQdLlhr nT6D6k2A5TqVUuT9BdXq9CgYRAM2pkQOC8QSL2C/Ht880UuAT2LnDNKjiOF6T1kT1L1w 02mjThNEI815lAm2e+6NagbPCUSrKZg28B00IBhgkoRI7/8Ba4bD7RNsDMMjxpU0QKr2 ssrkhlKj4baC+AfOIwyztFW6NJ2qKr91I78Gg2OTwyP8AAwi7pakufprUCwp+AXUKW1i h5uw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=9bBtdqZU69did2kAKCCWY2ZDwXXlO1B8hapvzVZTWrI=; fh=bYNgxUv5aDVv8ODFnU81QVGUrcSfp9UeUM+wu8I0NkA=; b=A7pFHuj8bv8VqekfsXbGWYCHlzWebBdlfZ++vGGV+lQKmhPei9EE+MMp1pTfiBb+AA 9eTWHpiJpAJdCuczjV1OkxwXq/KShComhKZHooY/K+8tahrfaf81C0xIP4Qkj0VsIJPS 2kVjpCXmZLIzJga++VV/xGbiGg4I1mDNjt1a6tj52ShhlMWCMKF/zecG4pVOe3aWemSp Pstk+rWCzGm+SSPiBnx6cS2UiT7Suu7FU14UCeQs+aYc2Ko5WNh3v2BmeDMRFoESvrI5 yY1frUp4Ptl3pUd6aTXmBnkdOtWlLhGJ+x/8qJBQA6uz+WfNn+TCSFHrg1vvjQt5/tbk nRkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-85603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85603-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c15-20020a170906694f00b00a4380e6d6cfsi2038731ejs.37.2024.02.28.11.33.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 11:33:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-85603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85603-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 59F181F24AC0 for ; Wed, 28 Feb 2024 19:33:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD9D915F304; Wed, 28 Feb 2024 19:33:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AED9B15DBB9 for ; Wed, 28 Feb 2024 19:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709148794; cv=none; b=ZbdAaQSkxMxhNS3mVHQ3fP0LsbpbqmKZkZH48l/UyhYLrTqQusEX/kF3z7y7tfyDs6I5htxsTdXdelEMbgnNd8GSHg+BO3bdlwBWwROmh1gT6WIkf/qCWxL0WXUgAyX6gTuFe9Gedke6Jpt9DTh0L7GQCncVdxC6RXGdh9Q5XL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709148794; c=relaxed/simple; bh=R1HN6cNrtXWrVeHwA6L4bNTI2kbh4VCicV68kbU/F7c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SHubu61c2Zy9Y3dg00KlR5EvY/8oZQcCOVsIKJgsiHy7wpNL00ZKdVRaFzJakeUW54hOtK0kfj/Sj/n/M/eHDw17J7zxJNNxDBLrTL9M7VPyp9j5zb0yrpABjK3LUSsjB+yWT1csBJ5mh/AeKRiBzXNuZ1XycCds6Xqj/r5HDgQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 E454CC15; Wed, 28 Feb 2024 11:33:49 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 510493F73F; Wed, 28 Feb 2024 11:33:09 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, peng.fan@oss.nxp.com, michal.simek@amd.com, quic_sibis@quicinc.com, quic_nkela@quicinc.com, Cristian Marussi Subject: [PATCH 3/4] firmware: arm_scmi: Simplify scmi_devm_notifier_unregister Date: Wed, 28 Feb 2024 19:32:37 +0000 Message-ID: <20240228193238.2102157-4-cristian.marussi@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240228193238.2102157-1-cristian.marussi@arm.com> References: <20240228193238.2102157-1-cristian.marussi@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Unregistering SCMI notifications using the managed devres interface can be done providing as a reference simply the previously successfully registered notification block since it could have been registered only on one kernel notification_chain: drop any reference to SCMI protocol, events and sources. Devres internal helpers can search for the provided notification block reference and, once found, the associated devres object will already provide the above SCMI references for the event. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/notify.c | 30 ++++-------------------------- include/linux/scmi_protocol.h | 2 -- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c index 27c52531194d..e160ecb22948 100644 --- a/drivers/firmware/arm_scmi/notify.c +++ b/drivers/firmware/arm_scmi/notify.c @@ -1513,17 +1513,12 @@ static int scmi_devm_notifier_register(struct scmi_device *sdev, static int scmi_devm_notifier_match(struct device *dev, void *res, void *data) { struct scmi_notifier_devres *dres = res; - struct scmi_notifier_devres *xres = data; + struct notifier_block *nb = data; - if (WARN_ON(!dres || !xres)) + if (WARN_ON(!dres || !nb)) return 0; - return dres->proto_id == xres->proto_id && - dres->evt_id == xres->evt_id && - dres->nb == xres->nb && - ((!dres->src_id && !xres->src_id) || - (dres->src_id && xres->src_id && - dres->__src_id == xres->__src_id)); + return dres->nb == nb; } /** @@ -1531,10 +1526,6 @@ static int scmi_devm_notifier_match(struct device *dev, void *res, void *data) * notifier_block for an event * @sdev: A reference to an scmi_device whose embedded struct device is to * be used for devres accounting. - * @proto_id: Protocol ID - * @evt_id: Event ID - * @src_id: Source ID, when NULL register for events coming form ALL possible - * sources * @nb: A standard notifier block to register for the specified event * * Generic devres managed helper to explicitly un-register a notifier_block @@ -1544,25 +1535,12 @@ static int scmi_devm_notifier_match(struct device *dev, void *res, void *data) * Return: 0 on Success */ static int scmi_devm_notifier_unregister(struct scmi_device *sdev, - u8 proto_id, u8 evt_id, - const u32 *src_id, struct notifier_block *nb) { int ret; - struct scmi_notifier_devres dres; - - dres.handle = sdev->handle; - dres.proto_id = proto_id; - dres.evt_id = evt_id; - if (src_id) { - dres.__src_id = *src_id; - dres.src_id = &dres.__src_id; - } else { - dres.src_id = NULL; - } ret = devres_release(&sdev->dev, scmi_devm_release_notifier, - scmi_devm_notifier_match, &dres); + scmi_devm_notifier_match, nb); WARN_ON(ret); diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 2ee94ff0320c..305d89c02a94 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -775,8 +775,6 @@ struct scmi_notify_ops { const u32 *src_id, struct notifier_block *nb); int (*devm_event_notifier_unregister)(struct scmi_device *sdev, - u8 proto_id, u8 evt_id, - const u32 *src_id, struct notifier_block *nb); int (*event_notifier_register)(const struct scmi_handle *handle, u8 proto_id, u8 evt_id, -- 2.43.0