Re: [PATCH v2] arch/tile: add hypervisor-based character driver forSPI flash ROM

From: Greg KH
Date: Sat May 28 2011 - 17:23:49 EST


On Sat, May 28, 2011 at 11:13:54AM -0400, Chris Metcalf wrote:
> --- /dev/null
> +++ b/drivers/char/tile-srom.c
> @@ -0,0 +1,453 @@
> +/*
> + * Copyright 2011 Tilera Corporation. All Rights Reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation, version 2.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
> + * NON INFRINGEMENT. See the GNU General Public License for
> + * more details.
> + *
> + * SPI Flash ROM driver
> + *
> + * This source code is derived from code provided in "Linux Device
> + * Drivers" by Alessandro Rubini and Jonathan Corbet, published by
> + * O'Reilly & Associates.
> + */

LDD version 2? Wow, this driver is old.

> +MODULE_LICENSE("Dual BSD/GPL");

Wait, where did the BSD come from? You just said it was GPL only above
in the header of the file?

> +/**
> + * srom_setup_cdev() - Set up a device instance in the cdev table.
> + * @dev: Per-device SROM state.
> + * @index: Device to set up.
> + */
> +static void srom_setup_cdev(struct srom_dev *dev, int index)
> +{
> + int err, devno = MKDEV(srom_major, index);
> +
> + cdev_init(&dev->cdev, &srom_fops);
> + dev->cdev.owner = THIS_MODULE;
> + dev->cdev.ops = &srom_fops;
> + err = cdev_add(&dev->cdev, devno, 1);
> + /* Fail gracefully if need be */
> + if (err)
> + pr_notice("Error %d adding srom%d", err, index);
> +}

As you are only using 1 minor device, why not just use a misc device
instead? It's simpler, and you get the sysfs code for free, which you
forgot to do, so your device node will never show up in userspace :(

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/