Skip to content

Commit 6996312

Browse files
digetxsre
authored andcommitted
power: supply: smb347-charger: Fix interrupt usage if interrupt is unavailable
The IRQ=0 could be a valid interrupt number in kernel because interrupt numbers are virtual in a modern kernel. Hence fix the interrupt usage in a case if interrupt is unavailable by not overriding the interrupt number which is used by the driver. Note that currently Nexus 7 is the only know device which uses SMB347 kernel diver and it has a properly working interrupt, hence this patch doesn't fix any real problems, it's a minor cleanup/improvement. Fixes: 99298de ("power: supply: smb347-charger: Replace mutex with IRQ disable/enable") Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent b5e8642 commit 6996312

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/power/supply/smb347-charger.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
* @mains_online: is AC/DC input connected
138138
* @usb_online: is USB input connected
139139
* @charging_enabled: is charging enabled
140+
* @irq_unsupported: is interrupt unsupported by SMB hardware
140141
* @max_charge_current: maximum current (in uA) the battery can be charged
141142
* @max_charge_voltage: maximum voltage (in uV) the battery can be charged
142143
* @pre_charge_current: current (in uA) to use in pre-charging phase
@@ -193,6 +194,7 @@ struct smb347_charger {
193194
bool mains_online;
194195
bool usb_online;
195196
bool charging_enabled;
197+
bool irq_unsupported;
196198

197199
unsigned int max_charge_current;
198200
unsigned int max_charge_voltage;
@@ -862,6 +864,9 @@ static int smb347_irq_set(struct smb347_charger *smb, bool enable)
862864
{
863865
int ret;
864866

867+
if (smb->irq_unsupported)
868+
return 0;
869+
865870
ret = smb347_set_writable(smb, true);
866871
if (ret < 0)
867872
return ret;
@@ -923,8 +928,6 @@ static int smb347_irq_init(struct smb347_charger *smb,
923928
ret = regmap_update_bits(smb->regmap, CFG_STAT,
924929
CFG_STAT_ACTIVE_HIGH | CFG_STAT_DISABLED,
925930
CFG_STAT_DISABLED);
926-
if (ret < 0)
927-
client->irq = 0;
928931

929932
smb347_set_writable(smb, false);
930933

@@ -1345,6 +1348,7 @@ static int smb347_probe(struct i2c_client *client,
13451348
if (ret < 0) {
13461349
dev_warn(dev, "failed to initialize IRQ: %d\n", ret);
13471350
dev_warn(dev, "disabling IRQ support\n");
1351+
smb->irq_unsupported = true;
13481352
} else {
13491353
smb347_irq_enable(smb);
13501354
}
@@ -1357,8 +1361,8 @@ static int smb347_remove(struct i2c_client *client)
13571361
{
13581362
struct smb347_charger *smb = i2c_get_clientdata(client);
13591363

1360-
if (client->irq)
1361-
smb347_irq_disable(smb);
1364+
smb347_irq_disable(smb);
1365+
13621366
return 0;
13631367
}
13641368

0 commit comments

Comments
 (0)