Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1656547ybj; Fri, 20 Sep 2019 14:14:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaJ6yyjp686rcVwNCwIcI65vNbTGIzgJwSnbfKxbliq+4KdM1RuNvfAtC9esJMk6vzLq5E X-Received: by 2002:a05:6402:651:: with SMTP id u17mr11194147edx.104.1569014057957; Fri, 20 Sep 2019 14:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569014057; cv=none; d=google.com; s=arc-20160816; b=LXyyFONvm4eRiDQz81XPNQiwr9hBzblpNXRSZHzN3EyPqZYTAczbnNg/00XQBDIeDm 1uOD4xd/T7t0qV6jboB+v6xvypawtJJydz4seA03vuAv2d/iemfyKmivWC41d9c5a4ZR 1N6bkO0ng8becIp/KB3hQwY+O7HhVEJ7q3K9oLn/cEExwje8+3qr3lijRPwzfkMr7CLB OFyddff2IVZ8WbI9Jhbz50f+1fO1dAUfdsoFvNGStn5woANVXp/T3uAEwXh74UKN2a2V DiOZ2Em7/z5p7IU+ngsVM8QQWdgsyjOSqWggcbLHxWPO4jCGrvMcvt+pybl8F8aulS9C PTuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4Z44c9d2j6jpHtp6Wz9V5pb2NaXhIO8McHyRO5TVviw=; b=KL8/aAUs+ziBVUe0RQHGx5XTEu+6jVV7Ga1Eit7VuaBrk4czv5TQzwCrOYf3IUE3JH bdUeHlx6rGZoed2CAqkuWYifoX2scZJQkyYcgNGWySo8eCKw4ewE5bmk5CLddIJX08Tp mduEFZXOh1Bk1VAKC1Q0FB5DAk78yBQ1/bIY2LCFiWqjyCn8QloxR/SoIgjuzTYpiqty AtXCqPoyprit7hczOJBMmdStOcWqJSkaGKCT41FAlNF+LqBOOi6UnGoBgJTi3BoHDPuQ StNp4Vnq1s3rODMs1EfaLEKCyqo7W3htjH5cJ42EUWH/tJ+1mJqpQefZBBN7FLSiglx/ zWfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Y/ojsji3"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pk7si1678112ejb.216.2019.09.20.14.13.54; Fri, 20 Sep 2019 14:14:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Y/ojsji3"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393532AbfISWq2 (ORCPT + 99 others); Thu, 19 Sep 2019 18:46:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:54088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389023AbfISWq2 (ORCPT ); Thu, 19 Sep 2019 18:46:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 342A3206C2; Thu, 19 Sep 2019 22:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568933186; bh=KV4GAsafWdjKZTnkNayZVObWw9Ya4mDpcmbTQx6aqQc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y/ojsji3vxAtAA8k57gz4oj7lWE19V19CYjtiGeLH0c8ggXOZtqmRUpKiDaU5W3e3 628ll+A/AuOwMHPg94KSIIK7tsPHS1330ba2/TkYKP6MbvYPh1yDTlKF4JBs+KfkwB 0HXbFJGxSE386I/GeIMKGQXpAVMsrL4/LGO2xcM8= Date: Fri, 20 Sep 2019 00:46:24 +0200 From: Greg KH To: mnalajal@codeaurora.org Cc: Bjorn Andersson , rafael@kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij Subject: Re: [PATCH] base: soc: Export soc_device_to_device API Message-ID: <20190919224624.GB447028@kroah.com> References: <1568927624-13682-1-git-send-email-mnalajal@codeaurora.org> <20190919213203.GA395325@kroah.com> <20190919215300.GC1418@minitux> <20190919215836.GA426988@kroah.com> <0fa861c7210c0e929a9955f48e1486ee@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0fa861c7210c0e929a9955f48e1486ee@codeaurora.org> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 19, 2019 at 03:27:45PM -0700, mnalajal@codeaurora.org wrote: > On 2019-09-19 14:58, Greg KH wrote: > > On Thu, Sep 19, 2019 at 02:53:00PM -0700, Bjorn Andersson wrote: > > > On Thu 19 Sep 14:32 PDT 2019, Greg KH wrote: > > > > > > > On Thu, Sep 19, 2019 at 02:13:44PM -0700, Murali Nalajala wrote: > > > > > If the soc drivers want to add custom sysfs entries it needs to > > > > > access "dev" field in "struct soc_device". This can be achieved > > > > > by "soc_device_to_device" API. Soc drivers which are built as a > > > > > module they need above API to be exported. Otherwise one can > > > > > observe compilation issues. > > > > > > > > > > Signed-off-by: Murali Nalajala > > > > > --- > > > > > drivers/base/soc.c | 1 + > > > > > 1 file changed, 1 insertion(+) > > > > > > > > > > diff --git a/drivers/base/soc.c b/drivers/base/soc.c > > > > > index 7c0c5ca..4ad52f6 100644 > > > > > --- a/drivers/base/soc.c > > > > > +++ b/drivers/base/soc.c > > > > > @@ -41,6 +41,7 @@ struct device *soc_device_to_device(struct soc_device *soc_dev) > > > > > { > > > > > return &soc_dev->dev; > > > > > } > > > > > +EXPORT_SYMBOL_GPL(soc_device_to_device); > > > > > > > > > > static umode_t soc_attribute_mode(struct kobject *kobj, > > > > > struct attribute *attr, > > > > > > > > What in-kernel driver needs this? > > > > > > > > > > Half of the drivers interacting with the soc driver calls this API, > > > several of these I see no reason for being builtin (e.g. > > > ux500 andversatile). So I think this patch makes sense to allow us to > > > build these as modules. > > > > > > > Is linux-next breaking without this? > > > > > > > > > > No, we postponed the addition of any sysfs attributes in the Qualcomm > > > socinfo driver. > > > > > > > We don't export things unless we have a user of the export. > > > > > > > > Also, adding "custom" sysfs attributes is almost always not the correct > > > > thing to do at all. The driver should be doing it, by setting up the > > > > attribute group properly so that the driver core can do it automatically > > > > for it. > > > > > > > > No driver should be doing individual add/remove of sysfs files. If it > > > > does so, it is almost guaranteed to be doing it incorrectly and racing > > > > userspace. > > > > > > > > > > The problem here is that the attributes are expected to be attached to > > > the soc driver, which is separate from the platform-specific > > > drivers. So > > > there's no way to do platform specific attributes the right way. > > > > > > > And yes, there's loads of in-kernel examples of doing this wrong, I've > > > > been working on fixing that up, look at the patches now in Linus's tree > > > > for platform and USB drivers that do this as examples of how to do it > > > > right. > > > > > > > > > > Agreed, this patch should not be used as an approval for any crazy > > > attributes; but it's necessary in order to extend the soc device's > > > attributes, per the current design. > > > > Wait, no, let's not let the "current design" remain if it is broken! > > > > Why can't the soc driver handle the attributes properly so that the > > individual driver doesn't have to do the create/remove? > > > > thanks, > > > > greg k-h > > Current soc framework is allowing the soc info drivers to create very > limited > soc information as sysfs entries like machine name, family, revision and > soc_id. > Sometimes it become a limited information for the clients to know more about > soc > information. In this scenario soc info drivers are adding their own sysfs > entries > on top of what soc framework is doing like hw_platform, hw_platform_subtype > etc. > I believe this will be an issue for the other soc vendors as well. It is > good that > if we could add these into the soc framework rather than individual clients > defining > and adding them as per their requirement. It's fine to add sysfs files (as long as you document them in Documentation/ABI/) but don't do so file-by-file in a driver as that is racy and will not work. See 6d03c140db2e ("USB: phy: fsl-usb: convert platform driver to use dev_groups") as an example of how to do this in a simple way to have the driver core do all of the work for you automatically. thanks, greg k-h