Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2986930pxj; Sun, 23 May 2021 17:59:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZxW7mKa7grPo45B0dnvWM/5hPx7iOJs+M95YI0fRIqWO7VeYMNZp6Fe763BWNpbb8e55t X-Received: by 2002:a50:d69c:: with SMTP id r28mr22814953edi.64.1621817989929; Sun, 23 May 2021 17:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621817989; cv=none; d=google.com; s=arc-20160816; b=cBrFKAW8xi8ZTo2DFWEcRaMmh1w+Ye/P18IDB9RmxgTlqphT+gzxxEBMGYS2nc78wk bRYVU99JQ5sHyrDLLIb6CSyHD0yDwnVKhZG1t2nlV7D3hosCwgsAuNCeBd87luMNo/Jq FJomzTdwQcEwltRv+6/Ihea8FEhk3HQCYjiDbN9TruKIPYAuI26XFm9+TA/i/g4PWC9a Jm1GG6z8jpbnPBpQSLW5KXZUi2NY3UFnCst3LrVgLUK6kpByYMp0fEm30TEmRLfBCL9p NAu/JZwxKdmIPJ9zUOIj1rdMzV0mEhbKu6zFlva9IVnAQstegDoJpKLH8Y3ESRURithv zdHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:dkim-signature:dkim-signature; bh=c1N+jbjenOjR/XYKJ9JrzDDr2ArT8jHcPPYVtFN0+8s=; b=adq1oNxzK3LRpwxPKqhfvQ7zImMY7kCaTkYmOQY/jqp9Gyf9rc/dPsKLLOBxSQWohP KreqVX6l85lKVFv7ZazqYeb9W8bRy1lx8o3DyCyFncngS8DnQd2akFzXldnrFjGpaTBv rktlgSSrJO8PEKt8fDQvgmM7KBQpoXVzNGhtSnAshp90W505WEvPk/6ohHqCuHZg/8RP BBY/tUOL7Gq7kYkLlkMb2+Nw7HdOz8LqoQv4FnTEMSDA4NnnRvZd7IklqhbzWLtXcFzt nSNiocVpsSpLvyAYxW64FdiINDcY6cGzLHu24n5kT952t7dqsE0pT/TP2inp9yGMIZUB rqjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm2 header.b=ok68MILG; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=sPFszQIN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id re2si11196058ejb.407.2021.05.23.17.59.26; Sun, 23 May 2021 17:59:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm2 header.b=ok68MILG; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=sPFszQIN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232114AbhEXAza (ORCPT + 99 others); Sun, 23 May 2021 20:55:30 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:34691 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232050AbhEXAza (ORCPT ); Sun, 23 May 2021 20:55:30 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id C31455802BD; Sun, 23 May 2021 20:54:02 -0400 (EDT) Received: from imap2 ([10.202.2.52]) by compute3.internal (MEProxy); Sun, 23 May 2021 20:54:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm2; bh=c1N+jbjenOjR/XYKJ9JrzDDr2ArT8jH cPPYVtFN0+8s=; b=ok68MILGrCZHwK/EEaDToidzeAy70JVtB9FjJ/pwDgHMLPY ovb+ac2A0hKcALq3BTdinuwCUU4tFEwGrOvVUL4mgilE0fbIeLVIYkvTSg/A3C9A isVLljZCWMdha3ynTPS17MuqSVPwWl+xJfQt4IZm5lrj3u6/bDh1GWIUQBVKySVd 7ERl6fYx9Hzwm7OyafapAf+HBqlPX9FYAxNvCWVQ9ffjN0rYZxPnzQvHDbFhf3R7 IkCLkHtnZMQBtAnVcG+H+5GnhaCsHT3HniEb+iFzns1yaffCeyg6si9NuN84TU7r 3z366tuQSQtEi+GBbH7tKxItf/Q+Fdx23+XX7rw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=c1N+jb jenOjR/XYKJ9JrzDDr2ArT8jHcPPYVtFN0+8s=; b=sPFszQINYn+1MtITcFCPyx lNphgTAT0DJen+WqjLY3YH7HctWzuSJZ3zFTeSqLVuWZDYrW/idxoBb2M6LPgQEt ki/8+/Rk5S3eboxuGAYSLYMeGt4FwnCgkj+pOAJmlbNiPSPABGZshOSo60atWGdN cG0D6RtmqjLAFdmo/kORMxRpta5VgktFkB9TRMbfmX0piFWDr6uIDOQAVJbV4LjE DzJ46YD4tCg8RGGDBhp/tGiEQT+XdDLiX7JE1q4DwXdCPcoKSS4zY+wSpDL+idNh R1IVg/tHltd7L39TDpOgOOuq+WjNKHaAYxtN9BElPSGpkJQYPt1F36fzw4/0Bt1g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejkedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreerjeenucfhrhhomhepfdetnhgu rhgvficulfgvfhhfvghrhidfuceorghnughrvgifsegrjhdrihgurdgruheqnecuggftrf grthhtvghrnhepuddttdekueeggedvtddtueekiedutdfguedutdefieeuteefieelteet vddthfeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvgifsegrjhdrihgurdgruh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id A081EA004B1; Sun, 23 May 2021 20:54:01 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-448-gae190416c7-fm-20210505.004-gae190416 Mime-Version: 1.0 Message-Id: <79f3c6d1-1f74-46ec-99a0-37faf11517b6@www.fastmail.com> In-Reply-To: <20210521171412.GI2921206@minyard.net> References: <20210510054213.1610760-1-andrew@aj.id.au> <20210510054213.1610760-6-andrew@aj.id.au> <20210521171412.GI2921206@minyard.net> Date: Mon, 24 May 2021 10:23:36 +0930 From: "Andrew Jeffery" To: "Corey Minyard" Cc: openipmi-developer@lists.sourceforge.net, openbmc@lists.ozlabs.org, devicetree@vger.kernel.org, "Tomer Maimon" , linux-aspeed@lists.ozlabs.org, "Avi Fishman" , "Patrick Venture" , linux-kernel@vger.kernel.org, "Tali Perry" , "Rob Herring" , "Chia-Wei, Wang" , linux-arm-kernel@lists.infradead.org, "Benjamin Fair" , "Arnd Bergmann" , "Zev Weiss" Subject: =?UTF-8?Q?Re:_[PATCH_v3_05/16]_ipmi:_kcs=5Fbmc:_Turn_the_driver_data-str?= =?UTF-8?Q?uctures_inside-out?= Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 22 May 2021, at 02:44, Corey Minyard wrote: > On Mon, May 10, 2021 at 03:12:02PM +0930, Andrew Jeffery wrote: > > Make the KCS device drivers responsible for allocating their own memory. > > > > Until now the private data for the device driver was allocated internal > > to the private data for the chardev interface. This coupling required > > the slightly awkward API of passing through the struct size for the > > driver private data to the chardev constructor, and then retrieving a > > pointer to the driver private data from the allocated chardev memory. > > > > In addition to being awkward, the arrangement prevents the > > implementation of alternative userspace interfaces as the device driver > > private data is not independent. > > > > Peel a layer off the onion and turn the data-structures inside out by > > exploiting container_of() and embedding `struct kcs_device` in the > > driver private data. > > All in all a very nice cleanup. A few nits inline. > > > > > Signed-off-by: Andrew Jeffery > > Reviewed-by: Zev Weiss > > --- > > drivers/char/ipmi/kcs_bmc.c | 19 +++++++-- > > drivers/char/ipmi/kcs_bmc.h | 12 ++---- > > drivers/char/ipmi/kcs_bmc_aspeed.c | 56 +++++++++++++------------ > > drivers/char/ipmi/kcs_bmc_cdev_ipmi.c | 60 ++++++++++++++++++--------- > > drivers/char/ipmi/kcs_bmc_npcm7xx.c | 37 ++++++++++------- > > 5 files changed, 111 insertions(+), 73 deletions(-) > > > > diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c > > index ef5c48ffe74a..83da681bf49e 100644 > > --- a/drivers/char/ipmi/kcs_bmc.c > > +++ b/drivers/char/ipmi/kcs_bmc.c > > @@ -44,12 +44,23 @@ int kcs_bmc_handle_event(struct kcs_bmc *kcs_bmc) > > } > > EXPORT_SYMBOL(kcs_bmc_handle_event); > > > > -struct kcs_bmc *kcs_bmc_ipmi_alloc(struct device *dev, int sizeof_priv, u32 channel); > > -struct kcs_bmc *kcs_bmc_alloc(struct device *dev, int sizeof_priv, u32 channel) > > +int kcs_bmc_ipmi_add_device(struct kcs_bmc *kcs_bmc); > > The above (and it's remove function) should be in an include file. This is a short-term hack while I'm refactoring the code. It goes away in a later patch when we switch to using an ops struct. I didn't move it to a header as it's an implementation detail at the end of the day. I see headers as describing a public interface, and in the bigger picture this function isn't part of the public API. But maybe it's too tricky by half. My approach here generated some discussion with Zev as well. > > > +void kcs_bmc_add_device(struct kcs_bmc *kcs_bmc) > > This should return an error so the probe can be failed and cleaned up > and so confusing message don't get printed after this in one case. Hmm. I did this because the end result of the series is that we can have multiple chardev interfaces in distinct modules exposing the one KCS device in the one kernel. If more than one of the chardev modules is configured in and one of them fails to initialise themselves with respect to the device driver I didn't think it was right to fail the probe of the device driver (and thus remove any chardev interfaces that did succeed to initialise against it). But this does limit the usefulness of the device driver instance in the case that only one of the chardev interfaces is configured in and it fails to initialise. So I think we need to decide on the direction before I adjust the interface here. The patches are architected around the idea of multiple chardevs being configured in to the kernel build and all are exposed at runtime. The serio subsystem does have the 'drvctl' sysfs knob that allows userspace to dictate which serio chardev interface they want to connect to a serio device driver. Maybe that's preferred over my "connect them all" strategy? Andrew