public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Ryazanov <ryazanov.s.a@gmail.com>
To: Slark Xiao <slark_xiao@163.com>,
	Sai Krishna Gajula <saikrishnag@marvell.com>
Cc: "loic.poulain@oss.qualcomm.com" <loic.poulain@oss.qualcomm.com>,
	"johannes@sipsolutions.net" <johannes@sipsolutions.net>,
	"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"mani@kernel.org" <mani@kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [net-next v4 2/8] net: wwan: core: split port creation and registration
Date: Thu, 8 Jan 2026 02:42:54 +0200	[thread overview]
Message-ID: <af3aba1d-984b-46e1-824f-8cdbd774f89f@gmail.com> (raw)
In-Reply-To: <65a926ef.5e4a.19b97551cdb.Coremail.slark_xiao@163.com>

On 1/7/26 09:21, Slark Xiao wrote:
> At 2026-01-07 00:49:50, "Sai Krishna Gajula" <saikrishnag@marvell.com> wrote:
>>> -----Original Message-----
>>> From: Slark Xiao <slark_xiao@163.com>
>>> Sent: Monday, January 5, 2026 3:50 PM
>>> To: loic.poulain@oss.qualcomm.com; ryazanov.s.a@gmail.com;
>>> johannes@sipsolutions.net; andrew+netdev@lunn.ch;
>>> davem@davemloft.net; edumazet@google.com; kuba@kernel.org;
>>> pabeni@redhat.com; mani@kernel.org
>>> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org
>>> Subject: [net-next v4 2/8] net: wwan: core: split port creation and
>>> registration
>>>
>>> From: Sergey Ryazanov <ryazanov. s. a@ gmail. com> Upcoming GNSS (NMEA)
>>> port type support requires exporting it via the GNSS subsystem. On another
>>> hand, we still need to do basic WWAN core work: find or allocate the WWAN
>>> device, make it the
>>> From: Sergey Ryazanov <ryazanov.s.a@gmail.com>
>>>
>>> Upcoming GNSS (NMEA) port type support requires exporting it via the GNSS
>>> subsystem. On another hand, we still need to do basic WWAN core
>>> work: find or allocate the WWAN device, make it the port parent, etc. To reuse
>>> as much code as possible, split the port creation function into the registration
>>> of a regular WWAN port device, and basic port struct initialization.
>>>
>>> To be able to use put_device() uniformly, break the device_register() call into
>>> device_initialize() and device_add() and call device initialization earlier.

[skipped]

>>> +	struct wwan_device *wwandev = to_wwan_dev(port->dev.parent);
>>> +	char namefmt[0x20];
>>> +	int minor, err;
>>> +
>>> +	/* A port is exposed as character device, get a minor */
>>> +	minor = ida_alloc_range(&minors, 0, WWAN_MAX_MINORS - 1,
>>> GFP_KERNEL);
>>> +	if (minor < 0)
>>> +		return minor;
>>> +
>>> +	port->dev.class = &wwan_class;
>>> +	port->dev.devt = MKDEV(wwan_major, minor);
>>> +
>>> +	/* allocate unique name based on wwan device id, port type and
>>> number */
>>> +	snprintf(namefmt, sizeof(namefmt), "wwan%u%s%%d", wwandev-
>>>> id,
>>> +		 wwan_port_types[port->type].devsuf);
>>> +
>>> +	/* Serialize ports registration */
>>> +	mutex_lock(&wwan_register_lock);
>>> +
>>> +	__wwan_port_dev_assign_name(port, namefmt);
>>> +	err = device_add(&port->dev);
>>> +
>>> +	mutex_unlock(&wwan_register_lock);
>>> +
>>> +	if (err)
>>> +		return err;
>> Please check, if freeing with ida_free is required before returning err.
>> if (err) {
>>     ida_free(&minors, minor);
>>     return err;
>> }
> Yes, you are right.
> And patch 7/8 modifies this file as well. We need to align with that changes
> since there are some issues(we still allocates the minor even the cdev is
> false). This would lead to the release function can't release the correct
> devt.

Sai, nice catch! It should free the minor number on error exactly like this.

--
Sergey

  reply	other threads:[~2026-01-08  0:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05 10:20 [net-next v4 0/8] net: wwan: add NMEA port type support Slark Xiao
2026-01-05 10:20 ` [net-next v4 1/8] net: wwan: core: remove unused port_id field Slark Xiao
2026-01-05 10:20 ` [net-next v4 2/8] net: wwan: core: split port creation and registration Slark Xiao
2026-01-06 16:49   ` Sai Krishna Gajula
2026-01-07  7:21     ` Slark Xiao
2026-01-08  0:42       ` Sergey Ryazanov [this message]
2026-01-05 10:20 ` [net-next v4 3/8] net: wwan: core: split port unregister and stop Slark Xiao
2026-01-06 20:34   ` Loic Poulain
2026-01-05 10:20 ` [net-next v4 4/8] net: wwan: add NMEA port support Slark Xiao
2026-01-06 20:36   ` Loic Poulain
2026-01-05 10:20 ` [net-next v4 5/8] net: wwan: hwsim: refactor to support more port types Slark Xiao
2026-01-05 10:20 ` [net-next v4 6/8] net: wwan: hwsim: support NMEA port emulation Slark Xiao
2026-01-06 20:37   ` Loic Poulain
2026-01-05 10:20 ` [net-next v4 7/8] net: wwan: prevent premature device unregister when NMEA port is present Slark Xiao
2026-01-07  1:06   ` Sergey Ryazanov
2026-01-07  7:29     ` Slark Xiao
2026-01-07 10:24       ` Sergey Ryazanov
2026-01-08  2:05       ` [RFC PATCH 0/1] prevent premature device unregister via Sergey Ryazanov
2026-01-08  2:05         ` [RFC PATCH 1/1] net: wwan: core: explicit WWAN device reference counting Sergey Ryazanov
2026-01-08  8:59           ` Loic Poulain
2026-01-08 13:01             ` Sergey Ryazanov
2026-01-08 11:01         ` Re:[RFC PATCH 0/1] prevent premature device unregister via Slark Xiao
2026-01-08 13:12           ` Sergey Ryazanov
2026-01-05 10:20 ` [net-next v4 8/8] net: wwan: mhi_wwan_ctrl: Add NMEA channel support Slark Xiao
2026-01-06 20:38   ` Loic Poulain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=af3aba1d-984b-46e1-824f-8cdbd774f89f@gmail.com \
    --to=ryazanov.s.a@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=mani@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saikrishnag@marvell.com \
    --cc=slark_xiao@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox