Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1691841iob; Thu, 19 May 2022 12:04:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzA0y6D8NeuTdtgnDdQBwo4529URL8tY1KuoLQp9fOIRt6N/LWmqkCVbM6I+oHr6WmAqFTV X-Received: by 2002:a63:5a5a:0:b0:3c2:8205:17a6 with SMTP id k26-20020a635a5a000000b003c2820517a6mr4985369pgm.609.1652987040501; Thu, 19 May 2022 12:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652987040; cv=none; d=google.com; s=arc-20160816; b=hQ4A+RiPY1C7RyEYg6espjNAHzoKhK7hiLBSfrjOXTRLga2HDQmo2F4S2p0jP4roIt VwOp/+GeB/y9m7rZLjsq8QpwOjl5dPNECUlVmSKaOM2lpH0WKLB3dZUbqyVOdoZNsav5 Bmhbvf5WcSzf+n5BL7mHzBsE7TqdJOEsz4hN9LvI0zCzqsb8J5xcGaIiFnTmS7kHJbjc 5nRXfS8iwF3UGDAZZWmcgD7bxrCgP9LA4j3aopZpAEGEdoVT47JaRAnqDT+yplccx1ao 1mnANyKg0/UQ9vJfs1qMxtaFS12yaRji9eOSrN5/LJ3q9TJV1TJA+Qq0revFYoqrbiwT VPJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+DjTRyrEIk/7+NviFFDq38Gooy9b1TSP3ZgNYCx/iRQ=; b=Ux8ByF0zjjWJEbl8QDnhNiOev6OVmDN91ucNx9BccWVEd/4g8vabvCUJlu8JOzr8CQ pYEQa3BntoLrwPMifdx5cn3h8eR04Fs6zUZNDJq3IBuQHORlgTHX9caDY6QCcTI6LO1/ r8wKwsvsFbco70TeQXI/7ghBKMEeVVJevXDQINrRPfwYNvexNshfnR+0xulu7H2Dt80m 5FvGy1sP5usv3Xr1aerpd5moHGFYYFWmWJhEHGLFS7ovoIP3bxfLQZAmZh/lDZLqzSx4 Z2JLUqD6Tm6bDo3td1kMCvBNS4h2jUq5b6IH+zR+s96akfTTDICisB4BdOO4dgB5vb4a s0vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="i/dsq4N7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r2-20020a63b102000000b003f5eaf2ad31si6396628pgf.565.2022.05.19.12.03.44; Thu, 19 May 2022 12:04:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="i/dsq4N7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231745AbiESP0q (ORCPT + 99 others); Thu, 19 May 2022 11:26:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241000AbiESP0N (ORCPT ); Thu, 19 May 2022 11:26:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D949F33E0E for ; Thu, 19 May 2022 08:26:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 99A0CB824E6 for ; Thu, 19 May 2022 15:26:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA9ABC385AA; Thu, 19 May 2022 15:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652973968; bh=sjj+mlnWDG2Xdrw+/4hBO5MRvw9CHxqz/fuaCtwbXyo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i/dsq4N7kRmTcuUlDgj7DS/wfYh6C7TjvTKmCbKHG6YD9WsbuAU6HpAFkhwqXRw+0 ekPV/lqa+IabiiJgCl644gN/Th+kgSwQvTpnGW0qbx9iudnK0gepFqiGL2iay4iuBD vVt2ZdqLONtp01j+zY4isC4gn9Pi/OEG6YHcBrr8= Date: Thu, 19 May 2022 17:25:17 +0200 From: Greg Kroah-Hartman To: Chris Down Cc: linux-kernel@vger.kernel.org, Petr Mladek , kernel-team@fb.com Subject: Re: [RFC PATCH] printk: console: Allow each console to have its own loglevel Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 19, 2022 at 04:08:04PM +0100, Chris Down wrote: > Greg Kroah-Hartman writes: > > > struct console { > > > char name[16]; > > > void (*write)(struct console *, const char *, unsigned); > > > @@ -179,9 +173,11 @@ struct console { > > > void *data; > > > struct console *next; > > > int level; > > > - struct device classdev; > > > + struct device *classdev; > > > > Ick, no, keep the real structure here. It can properly handle the > > reference counting for the object. Just correctly clean up in the > > release function, not anywhere else. > > Sorry, I'm getting more and more confused about what you're asking me to do, > and less and less clear on the rationale. > > Can you please clarify what "correctly cleaning up" would mean for a > non-pointer `struct device'? > > Is your concern that... > > register_console(c) > device_initialize(c->d) > device_add(c->d) > unregister_console(c) > device_unregister(c->d) console_classdev_release(c->d) > register_console(c) > device_initialize(c->d) <-- classdev was not previously zeroed out > in console_classdev_release() and bad things may happen Note, you can not "recycle" a structure in the driver model. So when the console is unregistered, it should be freed. When it is registered, it should be created. Perhaps that is the confusion here? thakns, greg k-h