Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3746201pxk; Tue, 29 Sep 2020 05:22:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf4U6EwSGspDj/5pLq6dwQokCmKuIwmdpM+868j2SxcXIY5brQgqVelsO0J/9jbKs78RYb X-Received: by 2002:a17:906:a093:: with SMTP id q19mr3360705ejy.295.1601382150487; Tue, 29 Sep 2020 05:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601382150; cv=none; d=google.com; s=arc-20160816; b=YhIQZ36nyUA8Oe0Y+tYddTDV7MZ2Zr7Rlx4AvjLjaW4jA5HGkvU/wiWD6vbrDxAVms gbNiVzkikIn1mthoqaU9zG4oDDf6fjsTyQ6ohkDjqyndkCvpQLi8zLA6iFnzpjyCDsfQ v4mbwYoS7SB5ROO5HV8uyu+sVqR4klkv8o3sBNhxoP3PfnqcEgY+W5m5lv/w/JGJjSWs cRLTYrFZxGGpeT7c7e5DE16tsgMVfNDe9kbR6wHD3TF2Le25zKZEjiIpcNx+ZzQUzouQ mLMZ+T/JuGnlz5MXE0ZDTYVyInztL/v7fuD4w/ZezOVkTpQW9VQLkO7gQ0JsoYiZ1Gof Kr4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Sn2U/DavwkCBIUSoQlLM6eJqrMyIlVy41m3cYDK3gjc=; b=hoU2LEAseRnlZzEqKGN8BvsHktJg5EaeFPllq/9j3aFyIBcT4/MazVeGs44MOE9LsU PuOXf8DMN7CQK4MwwY+tXDj+5cXRM5jylAb8QKXmSmWbvby8EyitZJkXnM7eUtYWK/0z 78GOI3BH710qeOH5o4spFrPrTQzVLo42x0/c/IycZqbls02hWwtw1HGRF8I2NqRsYgk/ LePOctitmZYlb7g8fx4mcWtmYhdG1f2MVgwyfc2udTh/DkXtoARZY3JdSBUl33u0ipSq L9n4T7wbo1BueVTqfR5II5YNts/tYgfIxI9b5RqhrBwsQvjNpOrDVlQHy5q/jFcU0Scj pw5g== ARC-Authentication-Results: i=1; mx.google.com; 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 e3si2518586ejt.37.2020.09.29.05.22.07; Tue, 29 Sep 2020 05:22:30 -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; 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 S1732533AbgI2MVO (ORCPT + 99 others); Tue, 29 Sep 2020 08:21:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731561AbgI2MUt (ORCPT ); Tue, 29 Sep 2020 08:20:49 -0400 Received: from smtp3.goneo.de (smtp3.goneo.de [IPv6:2001:1640:5::8:37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AAD7C061755 for ; Tue, 29 Sep 2020 05:20:48 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.goneo.de (Postfix) with ESMTP id 2D39823F719; Tue, 29 Sep 2020 14:20:47 +0200 (CEST) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -2.959 X-Spam-Level: X-Spam-Status: No, score=-2.959 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.059, BAYES_00=-1.9] autolearn=ham Received: from smtp3.goneo.de ([127.0.0.1]) by localhost (smtp3.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aMnj5Bosl1_X; Tue, 29 Sep 2020 14:20:45 +0200 (CEST) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp3.goneo.de (Postfix) with ESMTPA id A1EAE23F113; Tue, 29 Sep 2020 14:20:45 +0200 (CEST) From: poeschel@lemonage.de To: Thierry Reding , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Lee Jones , linux-pwm@vger.kernel.org (open list:PWM SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Cc: Lars Poeschel Subject: [PATCH] pwm: sysfs: Set class on pwm devices Date: Tue, 29 Sep 2020 14:19:53 +0200 Message-Id: <20200929121953.2817843-1-poeschel@lemonage.de> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lars Poeschel This adds a class to exported pwm devices. Exporting a pwm through sysfs did not yield udev events. The dev_uevent_filter function does filter-out devices without a bus or class. This was already addressed in commit commit 7e5d1fd75c3d ("pwm: Set class for exported channels in sysfs") but this did cause problems and the commit got reverted with commit c289d6625237 ("Revert "pwm: Set class for exported channels in sysfs"") pwm's have to be local to its pwmchip, so we create an individual class for each pwmchip and assign this class to the pwm belonging to the pwmchip. This does better map to structure that is also visible in sysfs. Signed-off-by: Lars Poeschel --- drivers/pwm/sysfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c index 449dbc0f49ed..e2dfbc335366 100644 --- a/drivers/pwm/sysfs.c +++ b/drivers/pwm/sysfs.c @@ -259,7 +259,7 @@ static int pwm_export_child(struct device *parent, struct pwm_device *pwm) export->child.release = pwm_export_release; export->child.parent = parent; export->child.devt = MKDEV(0, 0); - export->child.groups = pwm_groups; + export->child.class = parent->class; dev_set_name(&export->child, "pwm%u", pwm->hwpwm); ret = device_register(&export->child); @@ -499,6 +499,9 @@ void pwmchip_sysfs_export(struct pwm_chip *chip) dev_warn(chip->dev, "device_create failed for pwm_chip sysfs export\n"); } + + parent->class = class_create(THIS_MODULE, parent->kobj.name); + parent->class->dev_groups = pwm_groups; } void pwmchip_sysfs_unexport(struct pwm_chip *chip) @@ -518,6 +521,7 @@ void pwmchip_sysfs_unexport(struct pwm_chip *chip) pwm_unexport_child(parent, pwm); } + class_destroy(parent->class); put_device(parent); device_unregister(parent); } -- 2.28.0