Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp429647pxa; Tue, 4 Aug 2020 08:52:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYcUAjU0Oa4cXpXcPrRBkJj9fOWs3nimdaDFmjVNpM00cvHqNh4skOqjNS/VZlem9f4b6Q X-Received: by 2002:a50:9548:: with SMTP id v8mr1245987eda.189.1596556334667; Tue, 04 Aug 2020 08:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596556334; cv=none; d=google.com; s=arc-20160816; b=VPpGtp2NvPFdZUXTL0tXPoOThwbrQRFtH7M+lE3c5mYbxy9PcU3/6rvPoDE84NqrtW F2wVigVupmAOYqWml9M+98mVH34PLVm7GHjBE4CQB7wkSNuVLeuCfhePfPyD4bp/xqbg 9BvKHnoXmEV63GymofdJCpqNOvTiNV85dfYXLhWlqRqcntx5tHwdYd6a307jovJs/FXO ZBlfopxIDTYNSLBcuJoUbbvcrOUGoW1K9R7+oHYxPJEvbClTSG7E9uNZlT6fjoYCIUzO PGXO5TqFcXtu2H9YdYXl3Y7z++mAqTI8EO3xk95f8MnxaEu3vGzPEPVlPN1iJ8ONKg1+ nsCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bbJYQ8qPF8LnW0NhVShTCuvrfIgUwq8ghqO0NIrPnyM=; b=w/5miBBMZffKw507gz+LDtEdnp1ZSMDqTt5Ch5o3PZeH/qxWARcAEaGfpxqDgeXtdO arJ1Lz/Nwew9h8gETfB4kSIh2ggeTzasXihyIAb+Ktqash3PGDfEkFEPdHvoOD8MDVjo JpiOBBcdkcHqyLH4OZNwcxJlsJgab4LzGRbbFJO/rHqCrgqbuRqxA7+KZrezJXM4pr60 fPhBO4STrA7uGZqjppTNDeEPOB/+hsLY/QKpGoX222fT8LsgzaW/+56nWh9wtX0XNhlc OIyI1ayoapzuqkyr5UsgvWyT1OCIi3LTgZFJzsyfVeMV1d/ZdGxmUYN0k7xwJg9z9VLl 4xkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="rdNvOcx/"; 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 bs25si12739371edb.174.2020.08.04.08.51.46; Tue, 04 Aug 2020 08:52:14 -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=@kernel.org header.s=default header.b="rdNvOcx/"; 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 S1729194AbgHDPvH (ORCPT + 99 others); Tue, 4 Aug 2020 11:51:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:55458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728157AbgHDPvB (ORCPT ); Tue, 4 Aug 2020 11:51:01 -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 38C4F208A9; Tue, 4 Aug 2020 15:51:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596556260; bh=OtA0EW8iaXuoVIFAIgh1KuT3uEjn0AAO/2QdeC/r5FA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rdNvOcx/C/QBAmmNbx2kEz7HV7AG9W6G/LHdx67gZbzUj6EBVIXA+Xzl5Ln9iwRol Dk/vWrU+PEqGDGTGOxxue63JHVdSYIM7lKHgBq1XL9wW/63bp4g3MYScoDdlnSkNGr xzTh1LQol6MghcQajeEM7cJ4eudzb584hPevBoXM= Date: Tue, 4 Aug 2020 17:51:20 +0200 From: Greg Kroah-Hartman To: Daniel Gutson Cc: Derek Kiernan , Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mika Westerberg , Arnd Bergmann , Mauro Carvalho Chehab , linux-kernel , Richard Hughes , Alex Bazhaniuk Subject: Re: [PATCH] Platform lockdown information in SYSFS Message-ID: <20200804155120.GA496635@kroah.com> References: <20200731070053.GC1518178@kroah.com> <20200731141503.GA1717752@kroah.com> <20200804064154.GE696690@kroah.com> <20200804142250.GA247448@kroah.com> <20200804144414.GA50022@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 04, 2020 at 12:05:25PM -0300, Daniel Gutson wrote: > On Tue, Aug 4, 2020 at 11:43 AM Greg Kroah-Hartman > wrote: > > > > On Tue, Aug 04, 2020 at 11:37:02AM -0300, Daniel Gutson wrote: > > > On Tue, Aug 4, 2020 at 11:23 AM Greg Kroah-Hartman < > > > gregkh@linuxfoundation.org> wrote: > > > > > > > > On Tue, Aug 04, 2020 at 10:50:13AM -0300, Daniel Gutson wrote: > > > > > On Tue, Aug 4, 2020 at 3:41 AM Greg Kroah-Hartman > > > > > wrote: > > > > > > > > > > > > On Mon, Aug 03, 2020 at 07:04:56PM -0300, Daniel Gutson wrote: > > > > > > > > > > Think of this as an input device. You don't put the random > > > input > > > > > > > > > > attributes all in one place, you create a new device that > > > represents the > > > > > > > > > > input interface and register that. > > > > > > > > > > > > > > I'm having trouble with this. What's the dev_t for the child > > > devices? > > > > > > > I'm doing > > > > > > > child_device = device_create(&my_class, &pdev->dev, MKDEV(0, 0), > > > > > > > NULL, "child"); > > > > > > > pdev is the pci_device (intel-spi-pci) > > > > > > > dmesg shows > > > > > > > > > > > > > > sysfs: cannot create duplicate filename '/class/my-class' > > > > > > > (call trace) > > > > > > > kobject_add_internal failed for my-class with -EEXIST, don't try > > > > > > > to register things with the same name in the same directory. > > > > > > > > > > > > Without seeing all of your code, I can't tell you what you are doing > > > > > > wrong, but the kernel should be giving you a huge hint here... > > > > > > > > > > > > Don't create duplicate names in the same subdirectory. > > > > > > > > > > I'm not doing that. One of my questions is if MKDEV(0, 0) is valid for > > > > > create_device, which I inferred so from the documentation. > > > > > > > > Yes it is, but that's not the error given to you :) > > > > > > > > Many in-kernel users call device_create() with MKDEV(0, 0) > > > > > > > > > Here is the listing > > > > > > > > > > > > > > > > It's not in any format to read, please never strip leading whitespace, > > > > it hurts my brain... > > > > > > (trying again) > > > Also, this is in pastebin: https://pastebin.com/8Ye9eUm5 > > > > > > #include > > > #include > > > #include > > > #include > > > #include > > > #include > > > #include > > > #include > > > > > > static ssize_t howareyou_show(struct class *class, struct class_attribute > > > *attr, > > > char *buf) > > > { > > > return sprintf(buf, "%s\n", "How are you?"); > > > } > > > static CLASS_ATTR_RO(howareyou); > > > > These are rare, as they are "global" for a class, are you sure you want > > that? > > I'm no longer using class attributes, this is from my previous > experiment. Sorry for the confusion. > In the "real" code I'll use DEVICE_ATTR_RO. > > > > > > > > > static struct class my_class = { > > > .name = "my-class", > > > .owner = THIS_MODULE, > > > }; > > > > > > struct device* child_device; > > > > > > static int mypci_probe(struct pci_dev *pdev, > > > const struct pci_device_id *id) > > > { > > > int ret; > > > > > > ret = pcim_enable_device(pdev); > > > if (ret) > > > return ret; > > > > > > ret = class_register(&my_class); > > > if (ret < 0) > > > return ret; > > > > > > > > > pr_info("DFG: Recognized. DID: %lx\n", (unsigned long > > > int)id->driver_data); > > > pr_info("DFG: device DID: %lx\n", (unsigned long int)pdev->device); > > > > > > ret = class_create_file(&my_class, &class_attr_howareyou); > > > if (ret != 0) { > > > pr_err("DFG class create file error: %d\n", ret); > > > class_unregister(&my_class); > > > return ret; > > > } > > > > > > child_device = device_create(&my_class, &pdev->dev, MKDEV(0, 0), > > > NULL, "child"); > > > if (child_device == NULL) { > > > pr_err("DFG error child device NULL"); > > > } > > > > > > return ret; > > > } > > > > > > > > > Looks sane, what does your kernel log say when you load this? > first insmod, OK. > rmmod, OK. > Second insmod: > > [ 4149.389133] sysfs: cannot create duplicate filename > '/devices/pci0000:00/0000:00:1f.0/my-class' Ok, that means you did not clean up properly. After rmmod see if you really did clean up all of the directories/files you created. The kernel is trying to be nice and give you a hint here :) thanks, greg k-h