From nobody Tue Dec 2 02:41:12 2025 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5A3F35CB9F for ; Tue, 18 Nov 2025 15:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763480526; cv=none; b=nOBs8OJFn5vcaFdfYEBsSm3WIl0Luqj+krVqacVEssyUug//CCjV8qlVR0j/4pe7suGlYxR9/M7HhRT+rqOiGGB5AK4+iaVJpLZ1y1ENR5/k1c8bIqHS6p4TR/KALimxzR898Y1Mmc1FoXZzoJsfYhSb8mClV5OLVinrq3gbULo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763480526; c=relaxed/simple; bh=p7JmlZu7aX2oza+mhHmm837atoJM0dG3uJyoPzvTEUo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NWwgpJ0f2voKdDUS2tQzbjZTKq2wi4s8H/K7V8XCBPbaFxA18h33QM1FR4azrX/YYotXOn5bBIEqtNnwMKTEe132gwBhWl+/lLAjQVpRVQpLj/9g+/1uVRjOj891ncT21biMRK2ZPgTbml39SSyvQWXDt/D86J0FGcrRW2rgyS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=qfxmlxwJ; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="qfxmlxwJ" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763480520; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JMBn6kpg/KtrTcaUg3wwySbqhmE37Z6eHvYm9uflh8s=; b=qfxmlxwJchfijDosgAxIMu1GLpjHS0tXWsShr2fsy5DlZLEBfjn6Kb+15H6VMlZwin1TFI 6cZboYNBhCUeKaM9k5fKvWhTQ/7pV+ndvAN/URlH28/HWm+8xLhmMG+dLiZVMzA9VI0UJi uxTx3N/YsZFYfZDgOJlrh2sxszq3LSM= From: Dawei Li To: andersson@kernel.org, mathieu.poirier@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, dawei.li@linux.dev, set_pte_at@outlook.com Subject: [PATCH v4 3/3] rpmsg: char: Merge cdev branches in rpmsg_eptdev_add() Date: Tue, 18 Nov 2025 23:41:07 +0800 Message-Id: <20251118154107.3100-4-dawei.li@linux.dev> In-Reply-To: <20251118154107.3100-1-dawei.li@linux.dev> References: <20251118154107.3100-1-dawei.li@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" There are two if(cdev) branches in rpmsg_eptdev_add(), merge them. Note that cdev_device_add() still must be last one since dev->release() doesn't reclaim cdev related resource. Signed-off-by: Dawei Li --- drivers/rpmsg/rpmsg_char.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 56371899212f..505411029fe0 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -467,14 +467,6 @@ static int rpmsg_eptdev_add(struct rpmsg_eptdev *eptde= v, =20 eptdev->chinfo =3D chinfo; =20 - if (cdev) { - ret =3D ida_alloc_max(&rpmsg_minor_ida, RPMSG_DEV_MAX - 1, GFP_KERNEL); - if (ret < 0) - return ret; - - dev->devt =3D MKDEV(MAJOR(rpmsg_major), ret); - } - /* Anonymous inode device still need device name for dev_err() and friend= s */ ret =3D ida_alloc(&rpmsg_ept_ida, GFP_KERNEL); if (ret < 0) @@ -485,6 +477,12 @@ static int rpmsg_eptdev_add(struct rpmsg_eptdev *eptde= v, ret =3D 0; =20 if (cdev) { + ret =3D ida_alloc_max(&rpmsg_minor_ida, RPMSG_DEV_MAX - 1, GFP_KERNEL); + if (ret < 0) + return ret; + + dev->devt =3D MKDEV(MAJOR(rpmsg_major), ret); + ret =3D cdev_device_add(&eptdev->cdev, &eptdev->dev); } =20 --=20 2.25.1