All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <mike@compulab.co.il>
To: Mark Brown <broonie@sirena.org.uk>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFD] voltage/current regulator consumer interface
Date: Tue, 21 Apr 2009 16:54:51 +0300	[thread overview]
Message-ID: <49EDD02B.5020407@compulab.co.il> (raw)
In-Reply-To: <20090421125528.GD25828@sirena.org.uk>

Mark Brown wrote:
> On Tue, Apr 21, 2009 at 03:00:41PM +0300, Mike Rapoport wrote:
> 
>> I've managed to create some preliminary "line-consumer" driver. I don't really
>> like the name, but I couldn't think of something better and "virtual" is
>> already taken :)
> 
> "userspace" or "user"?  The goal here is to let userspace applications
> be consumers.

I don't quite understand your intention here. Do you mean that it would bebetter
to use a character device rather than sysfs?

>> +static ssize_t set_state(struct device *dev, struct device_attribute *attr,
>> +			 const char *buf, size_t count)
>> +{
>> +	struct line_consumer_data *data = dev_get_drvdata(dev);
>> +	bool enabled;
>> +	int ret;
>> +
>> +	/*
>> +	 * sysfs_streq() doesn't need the \n's, but we add them so the strings
>> +	 * will be shared with show_state(), above.
>> +	 */
>> +	if (sysfs_streq(buf, "enabled\n") == 0)
>> +		enabled = true;
>> +	else if (sysfs_streq(buf, "disabled\n") == 0)
>> +		enabled = false;
> 
> I'd be inclined to also accept 1 and 0 here.
> 
>> +static DEVICE_ATTR(name, 0444, show_name, NULL);
>> +static DEVICE_ATTR(state, 0666, show_state, set_state);
> 
> Permissions for set_state() should probably be tighter?
> 
>> +	for (i = 0; i < ARRAY_SIZE(attributes); i++) {
>> +		ret = device_create_file(&pdev->dev, attributes[i]);
>> +		if (ret != 0)
>> +			goto err_create_attrs;
>> +	}
> 
> device_add_attributes()?
> 
>> +	if (pdata->init_on)
>> +		ret = regulator_bulk_enable(drvdata->num_supplies,
>> +					    drvdata->supplies);
>> +	else
>> +		ret = regulator_bulk_disable(drvdata->num_supplies,
>> +					     drvdata->supplies);
> 
> The disable case will lead to unbalanced enables and disables, loosing
> a reference to the supply.  Just don't do anything if the supplies
> should not be enabled.
> 
>> +static int regulator_line_consumer_remove(struct platform_device *pdev)
>> +{
>> +	struct line_consumer_data *drvdata = platform_get_drvdata(pdev);
>> +	int i;
>> +
>> +	for (i = 0; i < ARRAY_SIZE(attributes); i++)
>> +		device_remove_file(&pdev->dev, attributes[i]);
>> +
>> +	regulator_bulk_free(drvdata->num_supplies, drvdata->supplies);
>> +	kfree(drvdata->supplies);
>> +	kfree(drvdata);
>> +
>> +	return 0;
>> +}
> 
> Hrm.  You probably want to disable the supplies if you weren't using
> them here.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

-- 
Sincerely yours,
Mike.




  reply	other threads:[~2009-04-21 13:55 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-20 14:32 [RFD] voltage/current regulator consumer interface Mike Rapoport
2009-04-20 14:56 ` Mark Brown
2009-04-21 12:00   ` Mike Rapoport
2009-04-21 12:55     ` Mark Brown
2009-04-21 13:54       ` Mike Rapoport [this message]
2009-04-21 13:56         ` Mark Brown
2009-04-21 14:01           ` Mike Rapoport
2009-04-21 14:14             ` Mark Brown
2009-04-22  7:57               ` Mike Rapoport
2009-04-22  8:26                 ` Mark Brown
     [not found] <ct38K-3Fq-11@gated-at.bofh.it>
2009-04-20 15:38 ` James Kosin
2009-04-21  6:07   ` Mike Rapoport
2009-04-21 13:25     ` James Kosin
2009-04-21 14:05       ` Mike Rapoport
2009-04-21 14:31         ` James Kosin
2009-04-25  8:19         ` Pavel Machek
2009-04-25  9:04           ` Mark Brown
2009-04-27 13:47             ` James Kosin
2009-04-27 14:21               ` Mark Brown
2009-04-21 14:30       ` Mark Brown
2009-04-21 10:05   ` Mark Brown
     [not found] ` <ct38K-3Fq-9@gated-at.bofh.it>
     [not found]   ` <ctmXD-1yA-3@gated-at.bofh.it>
     [not found]     ` <ctnK4-2zP-11@gated-at.bofh.it>
     [not found]       ` <ctoG9-458-7@gated-at.bofh.it>
     [not found]         ` <ctoG9-458-5@gated-at.bofh.it>
     [not found]           ` <ctoPK-4y5-5@gated-at.bofh.it>
     [not found]             ` <ctoZv-4KN-23@gated-at.bofh.it>
     [not found]               ` <ctFxn-5OC-11@gated-at.bofh.it>
     [not found]                 ` <ctG0r-6HL-31@gated-at.bofh.it>
2009-04-22 14:31                   ` James Kosin
2009-04-22 14:49                     ` Alan Cox
2009-04-22 15:00                       ` James Kosin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49EDD02B.5020407@compulab.co.il \
    --to=mike@compulab.co.il \
    --cc=broonie@sirena.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.