On 28.10.2016 15:23, Tom Gundersen wrote: > On Fri, Oct 28, 2016 at 3:05 PM, Richard Weinberger > <richard.weinber...@gmail.com> wrote: >> On Wed, Oct 26, 2016 at 9:18 PM, David Herrmann <dh.herrm...@gmail.com> >> wrote: >>> + /* initialize constant fields */ >>> + peer->id = atomic64_inc_return(&peer_ids); >>> + peer->flags = 0; >>> + peer->cred = get_cred(current_cred()); >>> + peer->pid_ns = get_pid_ns(task_active_pid_ns(current)); >>> + peer->user = user; >>> + peer->debugdir = NULL; >>> + init_waitqueue_head(&peer->waitq); >>> + bus1_active_init(&peer->active); >>> + >>> + /* initialize data section */ >>> + mutex_init(&peer->data.lock); >>> + >>> + /* initialize peer-private section */ >>> + mutex_init(&peer->local.lock); >>> + >>> + if (!IS_ERR_OR_NULL(bus1_debugdir)) { >> >> How can bus1_debugdir contain an error code? AFACT it is either a >> valid dentry or NULL. > > If debugfs is not enabled it will be ERR_PTR(-ENODEV).
I thought you handle that earlier. But just figured that you check only for NULL after doing debugfs_create_dir(). This confused me. >>> + char idstr[22]; >>> + >>> + snprintf(idstr, sizeof(idstr), "peer-%llx", peer->id); >>> + >>> + peer->debugdir = debugfs_create_dir(idstr, bus1_debugdir); >>> + if (!peer->debugdir) { >>> + pr_err("cannot create debugfs dir for peer %llx\n", >>> + peer->id); >>> + } else if (!IS_ERR_OR_NULL(peer->debugdir)) { >>> + bus1_debugfs_create_atomic_x("active", S_IRUGO, >>> + peer->debugdir, >>> + &peer->active.count); >>> + } >>> + } >>> + >>> + bus1_active_activate(&peer->active); >> >> This is a no-nop since bus1_active_init() set ->count to BUS1_ACTIVE_NEW. > > bus1_active_activate() changes count from BUS1_ACTIVE_NEW to 0. Too many "active" words. ;) Now it makes sense. BUS1_ACTIVE_NEW is state "NEW" and the unnamed state "ready to use" is a counter >= 0. Thanks, //richard