From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 594D3C19F28 for ; Wed, 3 Aug 2022 12:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v/MrBRovAiUUhGjFJSVAkX/vjrSqGIGXvH4UVHjN9Zw=; b=u+ymEbv07/srIe vlyvFyUh9N2JxeC0wdfvLpm3RrwHOoo2/PsNOL73qk3aCdfZrV9D0+bXhk7c7g5QKtv5jC4BjBsG6 fftChsuAeyHQEhF+PGpngnaK7bZE16pEPxXtnkFrTR39raqULqVXiacd8jwWl0lF9Z/pR6E3+RIdA F9JqDOg63jZ1AxG+3A+h/p0i5iVI78L6nf+KH7PMYuXXNAag2SN63duPDZjBNoo1tQ12/lG7q2COh 23gIEmQsFP9tvS95h0sB+vOyugOyMCtU0deQc4ZxfyZxAEm5CbaZELRAK+j4UBwJ5lHs92qYmV8x3 W13y499xsrHSqAovzO7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJDXi-005uGy-IA; Wed, 03 Aug 2022 12:32:06 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJDXc-005uA8-FS for linux-arm-kernel@lists.infradead.org; Wed, 03 Aug 2022 12:32:02 +0000 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 878B6B8225C; Wed, 3 Aug 2022 12:31:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC3D0C433D7; Wed, 3 Aug 2022 12:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1659529915; bh=hHyOWrVaNjl5PfSM5D5Apuu2LwwIaKPH1g2WPnvwQYE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YAQi4kc1RpEdCuPBKsZ+UR+zlE2pLu+IWBS/ngrYLpIKWY25Ey/Ygcrq2mV1/NaAS sfP+3YAXjKwjkIqG5KKkQn6oTwjhcGfEa1v7d+zu1IFVaPLYGNJPiaNVj1sQhsBhqm 2QL/EuGYCGcyK0WsrEm3qkGLaUbjPicbbPpEaWN4= Date: Wed, 3 Aug 2022 14:31:52 +0200 From: Greg KH To: Nipun Gupta Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rafael@kernel.org, maz@kernel.org, tglx@linutronix.de, okaya@kernel.org, harpreet.anand@amd.com, michal.simek@amd.com, nikhil.agarwal@amd.com Subject: Re: [RFC PATCH 2/2] driver core: add compatible string in sysfs for platform devices Message-ID: References: <20220803122655.100254-1-nipun.gupta@amd.com> <20220803122655.100254-3-nipun.gupta@amd.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220803122655.100254-3-nipun.gupta@amd.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220803_053200_716327_E890B6C4 X-CRM114-Status: GOOD ( 19.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Aug 03, 2022 at 05:56:55PM +0530, Nipun Gupta wrote: > For devices registered dynamically using platform_device_register > API, this patch exposes the sysfs entry for the compatible string. > > Signed-off-by: Nipun Gupta > --- > drivers/base/platform.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index 51bb2289865c..89949f88a0a1 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -1289,10 +1289,25 @@ static ssize_t driver_override_store(struct device *dev, > } > static DEVICE_ATTR_RW(driver_override); > > +static ssize_t compatible_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + const char *compat; > + int ret; > + > + ret = device_property_read_string(dev, "compatible", &compat); > + if (ret != 0) > + return 0; > + > + return sysfs_emit(buf, "%s", compat); > +} > +static DEVICE_ATTR_RO(compatible); You forgot the Documentation/ABI/ update :( Also, what happens if there is no such string to read? Why are you returning 0? You should not create the attribute at all then, right? thanks, greg k-h _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel