hwmon: (sht15) remove multiple driver registration
Declare an array of platform_device_id, instead of registering a driver for each supported chip. This makes the code cleaner. Also add a module description. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Родитель
6c1fe725fd
Коммит
edec5af7c5
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* sht15.c - support for the SHT15 Temperature and Humidity Sensor
|
* sht15.c - support for the SHT15 Temperature and Humidity Sensor
|
||||||
*
|
*
|
||||||
* Portions Copyright (c) 2010-2011 Savoir-faire Linux Inc.
|
* Portions Copyright (c) 2010-2012 Savoir-faire Linux Inc.
|
||||||
* Jerome Oufella <jerome.oufella@savoirfairelinux.com>
|
* Jerome Oufella <jerome.oufella@savoirfairelinux.com>
|
||||||
* Vivien Didelot <vivien.didelot@savoirfairelinux.com>
|
* Vivien Didelot <vivien.didelot@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
|
@ -53,6 +53,9 @@
|
||||||
#define SHT15_STATUS_HEATER 0x04
|
#define SHT15_STATUS_HEATER 0x04
|
||||||
#define SHT15_STATUS_LOW_BATTERY 0x40
|
#define SHT15_STATUS_LOW_BATTERY 0x40
|
||||||
|
|
||||||
|
/* List of supported chips */
|
||||||
|
enum sht15_chips { sht10, sht11, sht15, sht71, sht75 };
|
||||||
|
|
||||||
/* Actions the driver may be doing */
|
/* Actions the driver may be doing */
|
||||||
enum sht15_state {
|
enum sht15_state {
|
||||||
SHT15_READING_NOTHING,
|
SHT15_READING_NOTHING,
|
||||||
|
@ -1024,77 +1027,26 @@ static int __devexit sht15_remove(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static struct platform_device_id sht15_device_ids[] = {
|
||||||
* sht_drivers simultaneously refers to __devinit and __devexit function
|
{ "sht10", sht10 },
|
||||||
* which causes spurious section mismatch warning. So use __refdata to
|
{ "sht11", sht11 },
|
||||||
* get rid from this.
|
{ "sht15", sht15 },
|
||||||
*/
|
{ "sht71", sht71 },
|
||||||
static struct platform_driver __refdata sht_drivers[] = {
|
{ "sht75", sht75 },
|
||||||
{
|
{ }
|
||||||
.driver = {
|
|
||||||
.name = "sht10",
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
},
|
|
||||||
.probe = sht15_probe,
|
|
||||||
.remove = __devexit_p(sht15_remove),
|
|
||||||
}, {
|
|
||||||
.driver = {
|
|
||||||
.name = "sht11",
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
},
|
|
||||||
.probe = sht15_probe,
|
|
||||||
.remove = __devexit_p(sht15_remove),
|
|
||||||
}, {
|
|
||||||
.driver = {
|
|
||||||
.name = "sht15",
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
},
|
|
||||||
.probe = sht15_probe,
|
|
||||||
.remove = __devexit_p(sht15_remove),
|
|
||||||
}, {
|
|
||||||
.driver = {
|
|
||||||
.name = "sht71",
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
},
|
|
||||||
.probe = sht15_probe,
|
|
||||||
.remove = __devexit_p(sht15_remove),
|
|
||||||
}, {
|
|
||||||
.driver = {
|
|
||||||
.name = "sht75",
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
},
|
|
||||||
.probe = sht15_probe,
|
|
||||||
.remove = __devexit_p(sht15_remove),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
MODULE_DEVICE_TABLE(platform, sht15_device_ids);
|
||||||
|
|
||||||
static int __init sht15_init(void)
|
static struct platform_driver sht15_driver = {
|
||||||
{
|
.driver = {
|
||||||
int ret;
|
.name = "sht15",
|
||||||
int i;
|
.owner = THIS_MODULE,
|
||||||
|
},
|
||||||
for (i = 0; i < ARRAY_SIZE(sht_drivers); i++) {
|
.probe = sht15_probe,
|
||||||
ret = platform_driver_register(&sht_drivers[i]);
|
.remove = __devexit_p(sht15_remove),
|
||||||
if (ret)
|
.id_table = sht15_device_ids,
|
||||||
goto error_unreg;
|
};
|
||||||
}
|
module_platform_driver(sht15_driver);
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error_unreg:
|
|
||||||
while (--i >= 0)
|
|
||||||
platform_driver_unregister(&sht_drivers[i]);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
module_init(sht15_init);
|
|
||||||
|
|
||||||
static void __exit sht15_exit(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = ARRAY_SIZE(sht_drivers) - 1; i >= 0; i--)
|
|
||||||
platform_driver_unregister(&sht_drivers[i]);
|
|
||||||
}
|
|
||||||
module_exit(sht15_exit);
|
|
||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_DESCRIPTION("Sensirion SHT15 temperature and humidity sensor driver");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче