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]
Date:   Wed, 6 Oct 2021 11:29:03 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Sergio Paracuellos <sergio.paracuellos@...il.com>
Cc:     sboyd@...nel.org, linux-clk@...r.kernel.org,
        gregkh@...uxfoundation.org, devicetree@...r.kernel.org,
        robh+dt@...nel.org, linux-staging@...ts.linux.dev, neil@...wn.name,
        linux-kernel@...r.kernel.org, john@...ozen.org
Subject: Re: [PATCH 3/4] clk: ralink: make system controller node a reset
 provider

On Wed, Oct 06, 2021 at 08:12:03AM +0200, Sergio Paracuellos wrote:
> @@ -398,6 +401,76 @@ static void __init mt7621_clk_init(struct device_node *node)
>  }
>  CLK_OF_DECLARE_DRIVER(mt7621_clk, "mediatek,mt7621-sysc", mt7621_clk_init);
>  
> +struct mt7621_rst {
> +	struct reset_controller_dev rcdev;
> +	struct regmap *sysc;
> +};
> +
> +static inline struct mt7621_rst *to_mt7621_rst(struct reset_controller_dev *dev)

No need to mark this as inline.  The compiler should do it automatically
or it will ignore the inline.

> +{
> +	return container_of(dev, struct mt7621_rst, rcdev);
> +}
> +
> +static int mt7621_assert_device(struct reset_controller_dev *rcdev,
> +				unsigned long id)
> +{
> +	struct mt7621_rst *data = to_mt7621_rst(rcdev);
> +	struct regmap *sysc = data->sysc;
> +
> +	if (id == MT7621_RST_SYS)
> +		return -1;

Please, return proper error codes.

> +
> +	return regmap_update_bits(sysc, SYSC_REG_RESET_CTRL, BIT(id), BIT(id));
> +}
> +
> +static int mt7621_deassert_device(struct reset_controller_dev *rcdev,
> +				  unsigned long id)
> +{
> +	struct mt7621_rst *data = to_mt7621_rst(rcdev);
> +	struct regmap *sysc = data->sysc;
> +
> +	if (id == MT7621_RST_SYS)
> +		return -1;

Here too.

> +
> +	return regmap_update_bits(sysc, SYSC_REG_RESET_CTRL, BIT(id), 0);
> +}
> +
> +static int mt7621_reset_device(struct reset_controller_dev *rcdev,
> +			       unsigned long id)
> +{
> +	int ret;
> +
> +	ret = mt7621_assert_device(rcdev, id);
> +	if (ret < 0)
> +		return ret;
> +
> +	return mt7621_deassert_device(rcdev, id);
> +}
> +
> +static const struct reset_control_ops reset_ops = {
> +	.reset = mt7621_reset_device,
> +	.assert = mt7621_assert_device,
> +	.deassert = mt7621_deassert_device
> +};
> +
> +static int mt7621_reset_init(struct device *dev, struct regmap *sysc)
> +{
> +	struct mt7621_rst *rst_data;
> +
> +	rst_data = kzalloc(sizeof(*rst_data), GFP_KERNEL);


Can we use devm_ to allocate this or do we need to clean up if
devm_reset_controller_register() fails?  Also a free in the release
function I suppose.  (Please, use devm_).


> +	if (!rst_data)
> +		return -ENOMEM;
> +
> +	rst_data->sysc = sysc;
> +	rst_data->rcdev.ops = &reset_ops;
> +	rst_data->rcdev.owner = THIS_MODULE;
> +	rst_data->rcdev.nr_resets = 32;
> +	rst_data->rcdev.of_reset_n_cells = 1;
> +	rst_data->rcdev.of_node = dev_of_node(dev);
> +
> +	return devm_reset_controller_register(dev, &rst_data->rcdev);
> +}


regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ