Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164787
b: refs/heads/master
c: 8cec03e
h: refs/heads/master
i:
  164785: 77af666
  164783: acea951
v: v3
  • Loading branch information
Anton Vorontsov authored and Linus Torvalds committed Sep 23, 2009
1 parent 4ce0dc8 commit 5140d18
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 37 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d2a5c10f806b089a6e6f10deefd01dc4ce67940d
refs/heads/master: 8cec03eee4a771f949c70cff07775c9bb21d4642
55 changes: 19 additions & 36 deletions trunk/drivers/hwmon/lm70.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/sysfs.h>
#include <linux/hwmon.h>
#include <linux/mutex.h>
#include <linux/mod_devicetable.h>
#include <linux/spi/spi.h>


Expand Down Expand Up @@ -130,11 +131,20 @@ static DEVICE_ATTR(name, S_IRUGO, lm70_show_name, NULL);

/*----------------------------------------------------------------------*/

static int __devinit common_probe(struct spi_device *spi, int chip)
static int __devinit lm70_probe(struct spi_device *spi)
{
int chip = spi_get_device_id(spi)->driver_data;
struct lm70 *p_lm70;
int status;

/* signaling is SPI_MODE_0 for both LM70 and TMP121 */
if (spi->mode & (SPI_CPOL | SPI_CPHA))
return -EINVAL;

/* 3-wire link (shared SI/SO) for LM70 */
if (chip == LM70_CHIP_LM70 && !(spi->mode & SPI_3WIRE))
return -EINVAL;

/* NOTE: we assume 8-bit words, and convert to 16 bits manually */

p_lm70 = kzalloc(sizeof *p_lm70, GFP_KERNEL);
Expand Down Expand Up @@ -170,24 +180,6 @@ static int __devinit common_probe(struct spi_device *spi, int chip)
return status;
}

static int __devinit lm70_probe(struct spi_device *spi)
{
/* signaling is SPI_MODE_0 on a 3-wire link (shared SI/SO) */
if ((spi->mode & (SPI_CPOL | SPI_CPHA)) || !(spi->mode & SPI_3WIRE))
return -EINVAL;

return common_probe(spi, LM70_CHIP_LM70);
}

static int __devinit tmp121_probe(struct spi_device *spi)
{
/* signaling is SPI_MODE_0 with only MISO connected */
if (spi->mode & (SPI_CPOL | SPI_CPHA))
return -EINVAL;

return common_probe(spi, LM70_CHIP_TMP121);
}

static int __devexit lm70_remove(struct spi_device *spi)
{
struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev);
Expand All @@ -201,41 +193,32 @@ static int __devexit lm70_remove(struct spi_device *spi)
return 0;
}

static struct spi_driver tmp121_driver = {
.driver = {
.name = "tmp121",
.owner = THIS_MODULE,
},
.probe = tmp121_probe,
.remove = __devexit_p(lm70_remove),

static const struct spi_device_id lm70_ids[] = {
{ "lm70", LM70_CHIP_LM70 },
{ "tmp121", LM70_CHIP_TMP121 },
{ },
};
MODULE_DEVICE_TABLE(spi, lm70_ids);

static struct spi_driver lm70_driver = {
.driver = {
.name = "lm70",
.owner = THIS_MODULE,
},
.id_table = lm70_ids,
.probe = lm70_probe,
.remove = __devexit_p(lm70_remove),
};

static int __init init_lm70(void)
{
int ret = spi_register_driver(&lm70_driver);
if (ret)
return ret;

ret = spi_register_driver(&tmp121_driver);
if (ret)
spi_unregister_driver(&lm70_driver);

return ret;
return spi_register_driver(&lm70_driver);
}

static void __exit cleanup_lm70(void)
{
spi_unregister_driver(&lm70_driver);
spi_unregister_driver(&tmp121_driver);
}

module_init(init_lm70);
Expand Down

0 comments on commit 5140d18

Please sign in to comment.