From: Greg KH <greg@kroah.com>
To: dmitry pervushin <dpervushin@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC] SPI core -- revisited
Date: Thu, 23 Jun 2005 17:35:56 -0700 [thread overview]
Message-ID: <20050624003555.GA22397@kroah.com> (raw)
In-Reply-To: <1119529135.4739.6.camel@diimka.dev.rtsoft.ru>
On Thu, Jun 23, 2005 at 04:18:54PM +0400, dmitry pervushin wrote:
> +int driver_for_each_dev(struct device_driver *drv, void *data,
> + int (*callback) (struct device * dev, void *data))
> +{
> + _find_t local_data;
> +
> + local_data.drv = drv;
> + local_data.data = data;
> + local_data.callback = callback;
> + return bus_for_each_dev(drv->bus, NULL, &local_data, dfed_callback);
> +}
> +
> +EXPORT_SYMBOL(driver_for_each_dev);
Use the built-in kernel functions, don't create a new one and go around
the _GPL export.
> +#ifdef CONFIG_SPI_DEBUG
> +#define DEBUG
> +#endif /* CONFIG_SPI_DEBUG */
Have the Makefile define this for you, it's not needed in the .c file
> +#include <linux/spi/spi.h>
Why a separate subdirectory? It should just go in include/linux/ like
everything else.
> + if (NULL == dev || NULL == driver) {
dev == NULL instead of the other way around (yes, I know why you do
this, but the rest of the kernel is the other way, and gcc will warn you
if you forget a '=').
> +SPI_IDS_TABLE_BEGIN
> + SPI_ID_ANY
> +SPI_IDS_TABLE_END
Ick, that's a horrible way to define things. Please make it look like
real .c code.
> +static struct spi_driver spidev_driver = {
> + .owner = THIS_MODULE,
> + .driver = {
> + .name = "generic spi",
No spaces in driver names please.
> + drvdata = (spidev_driver_data_t *) kmalloc(sizeof(spidev_driver_data_t),
> + GFP_KERNEL);
Cast is unnecessary.
Also, get rid of all typedefs, they are not acceptable.
> +#ifdef CONFIG_DEVFS_FS
> + devfs_mk_cdev(MKDEV(SPI_MAJOR, drvdata->minor),
> + S_IFCHR | S_IRUSR | S_IWUSR, "spi/%d", drvdata->minor);
> +#endif
Don't put #ifdef in code where it is not needed at all.
> + if (NULL == dev) {
> + printk(KERN_ERR "%s: removing the NULL device\n", __FUNCTION__);
> + }
Extra { } are not needed.
What is this checking for anyway?
Use dev_err() for these things.
> +static ssize_t spidev_read(struct file *file, char *buf, size_t count,
> + loff_t * offset)
> +{
> + char *tmp;
> + int ret = 0;
> +#ifdef DEBUG
> + struct inode *inode = file->f_dentry->d_inode;
> +#endif
#ifdef not nice to have here, it's not needed.
> +#define SPI_STUFF_FOUND -ECANCELED
Just use the raw error number, don't redefine it.
> +struct spi_adapter {
> + /*
> + * This name is used to uniquely identify the adapter.
> + * It should be the same as the module name.
> + */
> + char name[32];
Why not use the device.bus_id instead?
I too would like to see how this code is used, example drivers please.
thanks,
greg k-h
next prev parent reply other threads:[~2005-06-24 0:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-23 12:18 [RFC] SPI core -- revisited dmitry pervushin
2005-06-23 15:50 ` Jamey Hicks
2005-06-23 16:43 ` Russell King
2005-06-24 12:56 ` Jamey Hicks
2005-06-23 21:59 ` Jean Delvare
2005-06-24 0:35 ` Greg KH [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-06-26 19:36 dpervushin
2005-06-26 20:49 ` Alexey Dobriyan
2005-06-26 20:59 ` Arjan van de Ven
2005-06-27 3:37 ` Vitaly Wool
2005-06-27 8:28 ` Arjan van de Ven
2005-06-27 9:13 ` Vitaly Wool
2005-06-27 9:20 ` Russell King
2005-06-27 10:20 ` Vitaly Wool
2005-06-28 16:49 ` Greg KH
2005-06-27 3:39 ` Vitaly Wool
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=20050624003555.GA22397@kroah.com \
--to=greg@kroah.com \
--cc=dpervushin@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox