diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-07-16 13:30:11 -0400 |
---|---|---|
committer | Jean Delvare <khali@mahadeva.delvare> | 2008-07-16 13:30:11 -0400 |
commit | 935ada8c4481f9591caa1b88c83127c5931a8855 (patch) | |
tree | 3cc60878af6989a51e00b54311f16990e62087b2 | |
parent | 70313eabfc63ce6aa89b9fa3074129e5c521568a (diff) |
hwmon: (f75375s) Drop legacy i2c driver
Drop the legacy f75375s i2c driver, and add a detect callback to the
new-style i2c driver to achieve the same functionality.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Riku Voipio <riku.voipio@movial.fi>
-rw-r--r-- | drivers/hwmon/f75375s.c | 89 |
1 files changed, 12 insertions, 77 deletions
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c index dc1f30e432ea..1692de369969 100644 --- a/drivers/hwmon/f75375s.c +++ b/drivers/hwmon/f75375s.c | |||
@@ -87,7 +87,6 @@ I2C_CLIENT_INSMOD_2(f75373, f75375); | |||
87 | 87 | ||
88 | struct f75375_data { | 88 | struct f75375_data { |
89 | unsigned short addr; | 89 | unsigned short addr; |
90 | struct i2c_client *client; | ||
91 | struct device *hwmon_dev; | 90 | struct device *hwmon_dev; |
92 | 91 | ||
93 | const char *name; | 92 | const char *name; |
@@ -114,21 +113,12 @@ struct f75375_data { | |||
114 | s8 temp_max_hyst[2]; | 113 | s8 temp_max_hyst[2]; |
115 | }; | 114 | }; |
116 | 115 | ||
117 | static int f75375_attach_adapter(struct i2c_adapter *adapter); | 116 | static int f75375_detect(struct i2c_client *client, int kind, |
118 | static int f75375_detect(struct i2c_adapter *adapter, int address, int kind); | 117 | struct i2c_board_info *info); |
119 | static int f75375_detach_client(struct i2c_client *client); | ||
120 | static int f75375_probe(struct i2c_client *client, | 118 | static int f75375_probe(struct i2c_client *client, |
121 | const struct i2c_device_id *id); | 119 | const struct i2c_device_id *id); |
122 | static int f75375_remove(struct i2c_client *client); | 120 | static int f75375_remove(struct i2c_client *client); |
123 | 121 | ||
124 | static struct i2c_driver f75375_legacy_driver = { | ||
125 | .driver = { | ||
126 | .name = "f75375_legacy", | ||
127 | }, | ||
128 | .attach_adapter = f75375_attach_adapter, | ||
129 | .detach_client = f75375_detach_client, | ||
130 | }; | ||
131 | |||
132 | static const struct i2c_device_id f75375_id[] = { | 122 | static const struct i2c_device_id f75375_id[] = { |
133 | { "f75373", f75373 }, | 123 | { "f75373", f75373 }, |
134 | { "f75375", f75375 }, | 124 | { "f75375", f75375 }, |
@@ -137,12 +127,15 @@ static const struct i2c_device_id f75375_id[] = { | |||
137 | MODULE_DEVICE_TABLE(i2c, f75375_id); | 127 | MODULE_DEVICE_TABLE(i2c, f75375_id); |
138 | 128 | ||
139 | static struct i2c_driver f75375_driver = { | 129 | static struct i2c_driver f75375_driver = { |
130 | .class = I2C_CLASS_HWMON, | ||
140 | .driver = { | 131 | .driver = { |
141 | .name = "f75375", | 132 | .name = "f75375", |
142 | }, | 133 | }, |
143 | .probe = f75375_probe, | 134 | .probe = f75375_probe, |
144 | .remove = f75375_remove, | 135 | .remove = f75375_remove, |
145 | .id_table = f75375_id, | 136 | .id_table = f75375_id, |
137 | .detect = f75375_detect, | ||
138 | .address_data = &addr_data, | ||
146 | }; | 139 | }; |
147 | 140 | ||
148 | static inline int f75375_read8(struct i2c_client *client, u8 reg) | 141 | static inline int f75375_read8(struct i2c_client *client, u8 reg) |
@@ -607,22 +600,6 @@ static const struct attribute_group f75375_group = { | |||
607 | .attrs = f75375_attributes, | 600 | .attrs = f75375_attributes, |
608 | }; | 601 | }; |
609 | 602 | ||
610 | static int f75375_detach_client(struct i2c_client *client) | ||
611 | { | ||
612 | int err; | ||
613 | |||
614 | f75375_remove(client); | ||
615 | err = i2c_detach_client(client); | ||
616 | if (err) { | ||
617 | dev_err(&client->dev, | ||
618 | "Client deregistration failed, " | ||
619 | "client not detached.\n"); | ||
620 | return err; | ||
621 | } | ||
622 | kfree(client); | ||
623 | return 0; | ||
624 | } | ||
625 | |||
626 | static void f75375_init(struct i2c_client *client, struct f75375_data *data, | 603 | static void f75375_init(struct i2c_client *client, struct f75375_data *data, |
627 | struct f75375s_platform_data *f75375s_pdata) | 604 | struct f75375s_platform_data *f75375s_pdata) |
628 | { | 605 | { |
@@ -651,7 +628,6 @@ static int f75375_probe(struct i2c_client *client, | |||
651 | return -ENOMEM; | 628 | return -ENOMEM; |
652 | 629 | ||
653 | i2c_set_clientdata(client, data); | 630 | i2c_set_clientdata(client, data); |
654 | data->client = client; | ||
655 | mutex_init(&data->update_lock); | 631 | mutex_init(&data->update_lock); |
656 | data->kind = id->driver_data; | 632 | data->kind = id->driver_data; |
657 | 633 | ||
@@ -700,29 +676,13 @@ static int f75375_remove(struct i2c_client *client) | |||
700 | return 0; | 676 | return 0; |
701 | } | 677 | } |
702 | 678 | ||
703 | static int f75375_attach_adapter(struct i2c_adapter *adapter) | 679 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
704 | { | 680 | static int f75375_detect(struct i2c_client *client, int kind, |
705 | if (!(adapter->class & I2C_CLASS_HWMON)) | 681 | struct i2c_board_info *info) |
706 | return 0; | ||
707 | return i2c_probe(adapter, &addr_data, f75375_detect); | ||
708 | } | ||
709 | |||
710 | /* This function is called by i2c_probe */ | ||
711 | static int f75375_detect(struct i2c_adapter *adapter, int address, int kind) | ||
712 | { | 682 | { |
713 | struct i2c_client *client; | 683 | struct i2c_adapter *adapter = client->adapter; |
714 | u8 version = 0; | 684 | u8 version = 0; |
715 | int err = 0; | ||
716 | const char *name = ""; | 685 | const char *name = ""; |
717 | struct i2c_device_id id; | ||
718 | |||
719 | if (!(client = kzalloc(sizeof(*client), GFP_KERNEL))) { | ||
720 | err = -ENOMEM; | ||
721 | goto exit; | ||
722 | } | ||
723 | client->addr = address; | ||
724 | client->adapter = adapter; | ||
725 | client->driver = &f75375_legacy_driver; | ||
726 | 686 | ||
727 | if (kind < 0) { | 687 | if (kind < 0) { |
728 | u16 vendid = f75375_read16(client, F75375_REG_VENDOR); | 688 | u16 vendid = f75375_read16(client, F75375_REG_VENDOR); |
@@ -736,7 +696,7 @@ static int f75375_detect(struct i2c_adapter *adapter, int address, int kind) | |||
736 | dev_err(&adapter->dev, | 696 | dev_err(&adapter->dev, |
737 | "failed,%02X,%02X,%02X\n", | 697 | "failed,%02X,%02X,%02X\n", |
738 | chipid, version, vendid); | 698 | chipid, version, vendid); |
739 | goto exit_free; | 699 | return -ENODEV; |
740 | } | 700 | } |
741 | } | 701 | } |
742 | 702 | ||
@@ -746,43 +706,18 @@ static int f75375_detect(struct i2c_adapter *adapter, int address, int kind) | |||
746 | name = "f75373"; | 706 | name = "f75373"; |
747 | } | 707 | } |
748 | dev_info(&adapter->dev, "found %s version: %02X\n", name, version); | 708 | dev_info(&adapter->dev, "found %s version: %02X\n", name, version); |
749 | strlcpy(client->name, name, I2C_NAME_SIZE); | 709 | strlcpy(info->type, name, I2C_NAME_SIZE); |
750 | |||
751 | if ((err = i2c_attach_client(client))) | ||
752 | goto exit_free; | ||
753 | |||
754 | strlcpy(id.name, name, I2C_NAME_SIZE); | ||
755 | id.driver_data = kind; | ||
756 | if ((err = f75375_probe(client, &id)) < 0) | ||
757 | goto exit_detach; | ||
758 | 710 | ||
759 | return 0; | 711 | return 0; |
760 | |||
761 | exit_detach: | ||
762 | i2c_detach_client(client); | ||
763 | exit_free: | ||
764 | kfree(client); | ||
765 | exit: | ||
766 | return err; | ||
767 | } | 712 | } |
768 | 713 | ||
769 | static int __init sensors_f75375_init(void) | 714 | static int __init sensors_f75375_init(void) |
770 | { | 715 | { |
771 | int status; | 716 | return i2c_add_driver(&f75375_driver); |
772 | status = i2c_add_driver(&f75375_driver); | ||
773 | if (status) | ||
774 | return status; | ||
775 | |||
776 | status = i2c_add_driver(&f75375_legacy_driver); | ||
777 | if (status) | ||
778 | i2c_del_driver(&f75375_driver); | ||
779 | |||
780 | return status; | ||
781 | } | 717 | } |
782 | 718 | ||
783 | static void __exit sensors_f75375_exit(void) | 719 | static void __exit sensors_f75375_exit(void) |
784 | { | 720 | { |
785 | i2c_del_driver(&f75375_legacy_driver); | ||
786 | i2c_del_driver(&f75375_driver); | 721 | i2c_del_driver(&f75375_driver); |
787 | } | 722 | } |
788 | 723 | ||