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] [day] [month] [year] [list]
Date:	Tue, 8 Nov 2011 11:12:09 +0000
From:	Li Yang-R58472 <r58472@...escale.com>
To:	Wood Scott-B07421 <B07421@...escale.com>,
	Zhao Chenhui-B35336 <B35336@...escale.com>
CC:	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>
Subject: RE: [PATCH 6/7] fsl_pmc: Add API to enable device as wakeup event
 source



>-----Original Message-----
>From: linuxppc-dev-bounces+leoli=freescale.com@...ts.ozlabs.org
>[mailto:linuxppc-dev-bounces+leoli=freescale.com@...ts.ozlabs.org] On
>Behalf Of Scott Wood
>Sent: Saturday, November 05, 2011 5:14 AM
>To: Zhao Chenhui-B35336
>Cc: netdev@...r.kernel.org; linuxppc-dev@...ts.ozlabs.org
>Subject: Re: [PATCH 6/7] fsl_pmc: Add API to enable device as wakeup event
>source
>
>On 11/04/2011 07:39 AM, Zhao Chenhui wrote:
>> @@ -45,6 +46,72 @@ static int has_lossless;
>>   * code can be compatible with both 32-bit & 36-bit */  extern void
>> mpc85xx_enter_deep_sleep(u64 ccsrbar, u32 powmgtreq);
>>
>> +#ifdef CONFIG_FSL_PMC
>> +/**
>> + * pmc_enable_wake - enable OF device as wakeup event source
>> + * @pdev: platform device affected
>> + * @state: PM state from which device will issue wakeup events
>> + * @enable: True to enable event generation; false to disable
>> + *
>> + * This enables the device as a wakeup event source, or disables it.
>> + *
>> + * RETURN VALUE:
>> + * 0 is returned on success
>> + * -EINVAL is returned if device is not supposed to wake up the
>> +system
>> + * Error code depending on the platform is returned if both the
>> +platform and
>> + * the native mechanism fail to enable the generation of wake-up
>> +events  */ int pmc_enable_wake(struct platform_device *pdev,
>> +				suspend_state_t state, bool enable)
>
>"pmc" is too generic for a global function.  If this can be either enable
>or disable, perhaps it should be something like mpc85xx_pmc_set_wake().
>
>> +{
>> +	int ret = 0;
>> +	struct device_node *clk_np;
>> +	u32 *pmcdr_mask;
>> +
>> +	if (!pmc_regs) {
>> +		printk(KERN_WARNING "PMC is unavailable\n");
>> +		return -ENOMEM;
>> +	}
>
>-ENOMEM is not appropriate here, maybe -ENODEV?
>
>Should print __func__ so the user knows what's complaining.
>
>> +	if (enable && !device_may_wakeup(&pdev->dev))
>> +		return -EINVAL;
>> +
>> +	clk_np = of_parse_phandle(pdev->dev.of_node, "clk-handle", 0);
>> +	if (!clk_np)
>> +		return -EINVAL;
>> +
>> +	pmcdr_mask = (u32 *)of_get_property(clk_np, "fsl,pmcdr-mask", NULL);
>> +	if (!pmcdr_mask) {
>> +		ret = -EINVAL;
>> +		goto out;
>> +	}
>> +
>> +	/* clear to enable clock in low power mode */
>> +	if (enable)
>> +		clrbits32(&pmc_regs->pmcdr, *pmcdr_mask);
>> +	else
>> +		setbits32(&pmc_regs->pmcdr, *pmcdr_mask);
>
>We should probably initialize PMCDR to all bits set (or at least all ones
>we know are valid) -- the default should be "not a wakeup source".

Ideally I agree with you.  But currently we only have the UI of changing wake-up source for Ethernet device.  Will do when we can change all of the devices.

>
>> +/**
>> + * pmc_enable_lossless - enable lossless ethernet in low power mode
>> + * @enable: True to enable event generation; false to disable  */
>> +void pmc_enable_lossless(int enable) {
>> +	if (enable && has_lossless)
>> +		setbits32(&pmc_regs->pmcsr, PMCSR_LOSSLESS);
>> +	else
>> +		clrbits32(&pmc_regs->pmcsr, PMCSR_LOSSLESS); }
>> +EXPORT_SYMBOL_GPL(pmc_enable_lossless);
>> +#endif
>
>Won't we overwrite this later?

You are right.  Will remove the code that overwrite this.

- Leo

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ