Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2941213lqp; Mon, 25 Mar 2024 13:54:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUX0J/cWxDj5aXEbsOCiGIhpV+Drji3w3fo0NTxZibDiviKt/nj+kimG2TRDA+FIXN8ONVzPlIx8YdqDjM7mh/Xx9Z2QtQdcX+2LOOILQ== X-Google-Smtp-Source: AGHT+IFiW7NlGowqBfeiBOyIPxqBaLpaRv88l/5MnvwyO3tkTZ7vjI92mPeiEGzuBH6GPMAqUuFx X-Received: by 2002:a05:6a00:4f8e:b0:6ea:7e56:8dab with SMTP id ld14-20020a056a004f8e00b006ea7e568dabmr8555507pfb.26.1711400059935; Mon, 25 Mar 2024 13:54:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711400059; cv=pass; d=google.com; s=arc-20160816; b=JY8d+7RtKsOO1YGxWYT0jbWZiBcAsBEHzz+fVzbRyTjjE4VqPIL/rdeFxPcD1XogaM dLWXXxXigJkNkpF1meOYPpOKK++1PV3st7Bqt5r2sxsPM+ucRaC8bJqj9e6ZPSxdJk9H Fs+wscdK2NOtBlNMSz29ETzGuO3/vD6gC9qV8yMCcoBrcN6nSU2ioHoAP9kJojKKhiDQ p+ctsrbGdjVsttt89wRKfX5hGLDgZlaSA8yt+P6bWB19ZsEhogjY2RfShJ4ZY+gYVHSa EgdTACc/Fg2Ph67GroBOiLOsfIlbbc++nf8rs6Bo2E/pji0kyjCW/SrfsKo4m7AuycJ+ 7W6g== 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=pULnSu0rLrFNfTHqQP2eKloJ+iGjIloL0tcIvHg90No=; fh=WtL5fQT7ZUc/CxFY5ivX7o+R0egHbl7+G/zS94M/DC4=; b=noOoY5eb9XEG62PQsr0j4vDYfiWUmjgaDdZjbMNVw62F6PpXa2PPDrMdLCrCxNeVdo VdvwPm4rBSdneSt3yph1tI+pOpntnS5LTnIhvU0NRwAkYEuuTBuAT1EBQCR9Orw2Gph2 2jJQbJm71gADyGTbV5JLo2glQWv41Y9x9ODU8LxweGH6o1AfnbM7TANyaBh8yg8Ztk0R UhbeuNfQ8vQSuolkY3VDXTSK/RupB2ZKBT3sGwUFzh86zV2ScNA5DNBT0jdxCATBqMLu FKKdpaiYWVIOm+c4QnFpw4YY6IrbJD3DzfRyiisCDVyhwWdijbqtvL4YrbqZEWl0G3pW R3VQ==; 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-117985-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117985-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p18-20020a635b12000000b005cdc5c9d6a2si8471339pgb.576.2024.03.25.13.54.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 13:54:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117985-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-117985-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117985-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E85522E58FA for ; Mon, 25 Mar 2024 20:51:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CDD0C12838E; Mon, 25 Mar 2024 20:46:47 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DF1770CC2 for ; Mon, 25 Mar 2024 20:46:45 +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=1711399607; cv=none; b=A96raJJBquKGAsX5eR1gt91K+gpOtKbhFFhxpPaXEUEbELuTblJYM69xp6fXV6tmti01Kt94RA6zHlsuYfduPPK9u+vHWaLf5Am3gYZen6uLxsSiGsAcg6EZ4AJnsOd088GOBb0CGxnMX55qDp5x/Hw1BLMbMT0/VuTosyPpXmc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711399607; c=relaxed/simple; bh=5N73T9GLJexFRc9xgbr743q+8aZOE0ro0e7hvr8o8gg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gl2ZBtGia+B+o4pgT3m5abpurYXWOlQSpA7J7W6OV06ouROqx+WXSlHxBosgNBjCjRp1/qTXkjqha6HG7oF5TAUMLHfJ/9nukSkWQwTh4f6AGeXzk3rI65LnjhpR8N7PYv0GF774l/qMU2Zys1obpfcq+UyIiUY2wuz8XjA6xus= 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 3F5321595; Mon, 25 Mar 2024 13:47:18 -0700 (PDT) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E5EF23F64C; Mon, 25 Mar 2024 13:46:43 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, Cristian Marussi Subject: [PATCH v2 4/5] firmware: arm_scmi: Simplify scmi_devm_notifier_unregister Date: Mon, 25 Mar 2024 20:46:19 +0000 Message-ID: <20240325204620.1437237-5-cristian.marussi@arm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240325204620.1437237-1-cristian.marussi@arm.com> References: <20240325204620.1437237-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 b807141acc14..a3addb07e00a 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -783,8 +783,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.44.0