diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-jz4780.c | 7 | ||||
-rw-r--r-- | drivers/i2c/i2c-core.c | 10 | ||||
-rw-r--r-- | drivers/i2c/muxes/i2c-demux-pinctrl.c | 39 |
3 files changed, 37 insertions, 19 deletions
diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c index f325663c27c5..ba14a863b451 100644 --- a/drivers/i2c/busses/i2c-jz4780.c +++ b/drivers/i2c/busses/i2c-jz4780.c | |||
@@ -771,11 +771,16 @@ static int jz4780_i2c_probe(struct platform_device *pdev) | |||
771 | ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", | 771 | ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", |
772 | &clk_freq); | 772 | &clk_freq); |
773 | if (ret) { | 773 | if (ret) { |
774 | dev_err(&pdev->dev, "clock-frequency not specified in DT"); | 774 | dev_err(&pdev->dev, "clock-frequency not specified in DT\n"); |
775 | goto err; | 775 | goto err; |
776 | } | 776 | } |
777 | 777 | ||
778 | i2c->speed = clk_freq / 1000; | 778 | i2c->speed = clk_freq / 1000; |
779 | if (i2c->speed == 0) { | ||
780 | ret = -EINVAL; | ||
781 | dev_err(&pdev->dev, "clock-frequency minimum is 1000\n"); | ||
782 | goto err; | ||
783 | } | ||
779 | jz4780_i2c_set_speed(i2c); | 784 | jz4780_i2c_set_speed(i2c); |
780 | 785 | ||
781 | dev_info(&pdev->dev, "Bus frequency is %d KHz\n", i2c->speed); | 786 | dev_info(&pdev->dev, "Bus frequency is %d KHz\n", i2c->speed); |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 0f2f8484e8ec..e584d88ee337 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -525,22 +525,16 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv) | |||
525 | return 0; | 525 | return 0; |
526 | } | 526 | } |
527 | 527 | ||
528 | |||
529 | /* uevent helps with hotplug: modprobe -q $(MODALIAS) */ | ||
530 | static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env) | 528 | static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env) |
531 | { | 529 | { |
532 | struct i2c_client *client = to_i2c_client(dev); | 530 | struct i2c_client *client = to_i2c_client(dev); |
533 | int rc; | 531 | int rc; |
534 | 532 | ||
535 | rc = acpi_device_uevent_modalias(dev, env); | 533 | rc = acpi_device_uevent_modalias(dev, env); |
536 | if (rc != -ENODEV) | 534 | if (rc != -ENODEV) |
537 | return rc; | 535 | return rc; |
538 | 536 | ||
539 | if (add_uevent_var(env, "MODALIAS=%s%s", | 537 | return add_uevent_var(env, "MODALIAS=%s%s", I2C_MODULE_PREFIX, client->name); |
540 | I2C_MODULE_PREFIX, client->name)) | ||
541 | return -ENOMEM; | ||
542 | dev_dbg(dev, "uevent\n"); | ||
543 | return 0; | ||
544 | } | 538 | } |
545 | 539 | ||
546 | /* i2c bus recovery routines */ | 540 | /* i2c bus recovery routines */ |
diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c index 7748a0a5ddb9..8de073aed001 100644 --- a/drivers/i2c/muxes/i2c-demux-pinctrl.c +++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c | |||
@@ -140,22 +140,34 @@ static int i2c_demux_change_master(struct i2c_demux_pinctrl_priv *priv, u32 new_ | |||
140 | return i2c_demux_activate_master(priv, new_chan); | 140 | return i2c_demux_activate_master(priv, new_chan); |
141 | } | 141 | } |
142 | 142 | ||
143 | static ssize_t cur_master_show(struct device *dev, struct device_attribute *attr, | 143 | static ssize_t available_masters_show(struct device *dev, |
144 | char *buf) | 144 | struct device_attribute *attr, |
145 | char *buf) | ||
145 | { | 146 | { |
146 | struct i2c_demux_pinctrl_priv *priv = dev_get_drvdata(dev); | 147 | struct i2c_demux_pinctrl_priv *priv = dev_get_drvdata(dev); |
147 | int count = 0, i; | 148 | int count = 0, i; |
148 | 149 | ||
149 | for (i = 0; i < priv->num_chan && count < PAGE_SIZE; i++) | 150 | for (i = 0; i < priv->num_chan && count < PAGE_SIZE; i++) |
150 | count += scnprintf(buf + count, PAGE_SIZE - count, "%c %d - %s\n", | 151 | count += scnprintf(buf + count, PAGE_SIZE - count, "%d:%s%c", |
151 | i == priv->cur_chan ? '*' : ' ', i, | 152 | i, priv->chan[i].parent_np->full_name, |
152 | priv->chan[i].parent_np->full_name); | 153 | i == priv->num_chan - 1 ? '\n' : ' '); |
153 | 154 | ||
154 | return count; | 155 | return count; |
155 | } | 156 | } |
157 | static DEVICE_ATTR_RO(available_masters); | ||
156 | 158 | ||
157 | static ssize_t cur_master_store(struct device *dev, struct device_attribute *attr, | 159 | static ssize_t current_master_show(struct device *dev, |
158 | const char *buf, size_t count) | 160 | struct device_attribute *attr, |
161 | char *buf) | ||
162 | { | ||
163 | struct i2c_demux_pinctrl_priv *priv = dev_get_drvdata(dev); | ||
164 | |||
165 | return sprintf(buf, "%d\n", priv->cur_chan); | ||
166 | } | ||
167 | |||
168 | static ssize_t current_master_store(struct device *dev, | ||
169 | struct device_attribute *attr, | ||
170 | const char *buf, size_t count) | ||
159 | { | 171 | { |
160 | struct i2c_demux_pinctrl_priv *priv = dev_get_drvdata(dev); | 172 | struct i2c_demux_pinctrl_priv *priv = dev_get_drvdata(dev); |
161 | unsigned int val; | 173 | unsigned int val; |
@@ -172,7 +184,7 @@ static ssize_t cur_master_store(struct device *dev, struct device_attribute *att | |||
172 | 184 | ||
173 | return ret < 0 ? ret : count; | 185 | return ret < 0 ? ret : count; |
174 | } | 186 | } |
175 | static DEVICE_ATTR_RW(cur_master); | 187 | static DEVICE_ATTR_RW(current_master); |
176 | 188 | ||
177 | static int i2c_demux_pinctrl_probe(struct platform_device *pdev) | 189 | static int i2c_demux_pinctrl_probe(struct platform_device *pdev) |
178 | { | 190 | { |
@@ -218,12 +230,18 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) | |||
218 | /* switch to first parent as active master */ | 230 | /* switch to first parent as active master */ |
219 | i2c_demux_activate_master(priv, 0); | 231 | i2c_demux_activate_master(priv, 0); |
220 | 232 | ||
221 | err = device_create_file(&pdev->dev, &dev_attr_cur_master); | 233 | err = device_create_file(&pdev->dev, &dev_attr_available_masters); |
222 | if (err) | 234 | if (err) |
223 | goto err_rollback; | 235 | goto err_rollback; |
224 | 236 | ||
237 | err = device_create_file(&pdev->dev, &dev_attr_current_master); | ||
238 | if (err) | ||
239 | goto err_rollback_available; | ||
240 | |||
225 | return 0; | 241 | return 0; |
226 | 242 | ||
243 | err_rollback_available: | ||
244 | device_remove_file(&pdev->dev, &dev_attr_available_masters); | ||
227 | err_rollback: | 245 | err_rollback: |
228 | for (j = 0; j < i; j++) { | 246 | for (j = 0; j < i; j++) { |
229 | of_node_put(priv->chan[j].parent_np); | 247 | of_node_put(priv->chan[j].parent_np); |
@@ -238,7 +256,8 @@ static int i2c_demux_pinctrl_remove(struct platform_device *pdev) | |||
238 | struct i2c_demux_pinctrl_priv *priv = platform_get_drvdata(pdev); | 256 | struct i2c_demux_pinctrl_priv *priv = platform_get_drvdata(pdev); |
239 | int i; | 257 | int i; |
240 | 258 | ||
241 | device_remove_file(&pdev->dev, &dev_attr_cur_master); | 259 | device_remove_file(&pdev->dev, &dev_attr_current_master); |
260 | device_remove_file(&pdev->dev, &dev_attr_available_masters); | ||
242 | 261 | ||
243 | i2c_demux_deactivate_master(priv); | 262 | i2c_demux_deactivate_master(priv); |
244 | 263 | ||