lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200930065726.fjcsm4pfh65medgl@pengutronix.de>
Date:   Wed, 30 Sep 2020 08:57:26 +0200
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     poeschel@...onage.de
Cc:     Thierry Reding <thierry.reding@...il.com>,
        Lee Jones <lee.jones@...aro.org>,
        "open list:PWM SUBSYSTEM" <linux-pwm@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] pwm: sysfs: Set class on pwm devices

Hello Lars,

On Tue, Sep 29, 2020 at 02:19:53PM +0200, poeschel@...onage.de wrote:
> From: Lars Poeschel <poeschel@...onage.de>
> 
> This adds a class to exported pwm devices.
> Exporting a pwm through sysfs did not yield udev events. The

I wonder what is your use-case here. This for sure also has a place to
be mentioned in the commit log. I suspect there is a better way to
accomplish you way.

> 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

This sounds conceptually wrong. 

> 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 <poeschel@...onage.de>
> ---
>  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);

This needs error handling.

> +	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);
>  }

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ