Message ID | 20250213-max33359-irq-name-v1-1-1900da7a1e79@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | usb: typec: tcpm/tcpci_maxim: better interrupt name | expand |
On Thu, Feb 13, 2025 at 09:37:54AM +0000, André Draszik wrote: > This changes the output of /proc/interrupts from the non-descriptive: > 1-0025 > (or similar) to a more descriptive: > 1-0025-max33359 > > This makes it easier to find the device, in particular if there are > multiple i2c devices, as one doesn't have to remember (or lookup) where > it is located. > > Signed-off-by: André Draszik <andre.draszik@linaro.org> > --- > drivers/usb/typec/tcpm/tcpci_maxim_core.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > index fd1b80593367..46fc626589db 100644 > --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c > +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > @@ -420,12 +420,14 @@ static irqreturn_t max_tcpci_isr(int irq, void *dev_id) > return IRQ_WAKE_THREAD; > } > > -static int max_tcpci_init_alert(struct max_tcpci_chip *chip, struct i2c_client *client) > +static int max_tcpci_init_alert(struct max_tcpci_chip *chip, > + struct i2c_client *client, > + const char *name) > { > int ret; > > ret = devm_request_threaded_irq(chip->dev, client->irq, max_tcpci_isr, max_tcpci_irq, > - (IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev), > + (IRQF_TRIGGER_LOW | IRQF_ONESHOT), name, > chip); > > if (ret < 0) > @@ -485,6 +487,7 @@ static int max_tcpci_probe(struct i2c_client *client) > int ret; > struct max_tcpci_chip *chip; > u8 power_status; > + const char *name; > > chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); > if (!chip) > @@ -531,7 +534,11 @@ static int max_tcpci_probe(struct i2c_client *client) > > chip->port = tcpci_get_tcpm_port(chip->tcpci); > > - ret = max_tcpci_init_alert(chip, client); > + name = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%s", > + dev_name(&client->dev), client->name); > + if (!name) > + return -ENOMEM; Please always test your code before sending it out. You just leaked a bunch of stuff here :( thanks, greg k-h
Hi Greg, On Thu, 2025-02-13 at 11:11 +0100, Greg Kroah-Hartman wrote: > On Thu, Feb 13, 2025 at 09:37:54AM +0000, André Draszik wrote: > > This changes the output of /proc/interrupts from the non-descriptive: > > 1-0025 > > (or similar) to a more descriptive: > > 1-0025-max33359 > > > > This makes it easier to find the device, in particular if there are > > multiple i2c devices, as one doesn't have to remember (or lookup) where > > it is located. > > > > Signed-off-by: André Draszik <andre.draszik@linaro.org> > > --- > > drivers/usb/typec/tcpm/tcpci_maxim_core.c | 13 ++++++++++--- > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > > index fd1b80593367..46fc626589db 100644 > > --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c > > +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > > @@ -420,12 +420,14 @@ static irqreturn_t max_tcpci_isr(int irq, void *dev_id) > > return IRQ_WAKE_THREAD; > > } > > > > -static int max_tcpci_init_alert(struct max_tcpci_chip *chip, struct i2c_client *client) > > +static int max_tcpci_init_alert(struct max_tcpci_chip *chip, > > + struct i2c_client *client, > > + const char *name) > > { > > int ret; > > > > ret = devm_request_threaded_irq(chip->dev, client->irq, max_tcpci_isr, max_tcpci_irq, > > - (IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev), > > + (IRQF_TRIGGER_LOW | IRQF_ONESHOT), name, > > chip); > > > > if (ret < 0) > > @@ -485,6 +487,7 @@ static int max_tcpci_probe(struct i2c_client *client) > > int ret; > > struct max_tcpci_chip *chip; > > u8 power_status; > > + const char *name; > > > > chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); > > if (!chip) > > @@ -531,7 +534,11 @@ static int max_tcpci_probe(struct i2c_client *client) > > > > chip->port = tcpci_get_tcpm_port(chip->tcpci); > > > > - ret = max_tcpci_init_alert(chip, client); > > + name = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%s", > > + dev_name(&client->dev), client->name); > > + if (!name) > > + return -ENOMEM; > > Please always test your code before sending it out. You just leaked a > bunch of stuff here :( Thanks for the review! I can not see what leak you're referring to. Could you please clarify? Thanks, Andre'
On Thu, Feb 13, 2025 at 11:44:59AM +0000, André Draszik wrote: > Hi Greg, > > On Thu, 2025-02-13 at 11:11 +0100, Greg Kroah-Hartman wrote: > > On Thu, Feb 13, 2025 at 09:37:54AM +0000, André Draszik wrote: > > > This changes the output of /proc/interrupts from the non-descriptive: > > > 1-0025 > > > (or similar) to a more descriptive: > > > 1-0025-max33359 > > > > > > This makes it easier to find the device, in particular if there are > > > multiple i2c devices, as one doesn't have to remember (or lookup) where > > > it is located. > > > > > > Signed-off-by: André Draszik <andre.draszik@linaro.org> > > > --- > > > drivers/usb/typec/tcpm/tcpci_maxim_core.c | 13 ++++++++++--- > > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > > > index fd1b80593367..46fc626589db 100644 > > > --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c > > > +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > > > @@ -420,12 +420,14 @@ static irqreturn_t max_tcpci_isr(int irq, void *dev_id) > > > return IRQ_WAKE_THREAD; > > > } > > > > > > -static int max_tcpci_init_alert(struct max_tcpci_chip *chip, struct i2c_client *client) > > > +static int max_tcpci_init_alert(struct max_tcpci_chip *chip, > > > + struct i2c_client *client, > > > + const char *name) > > > { > > > int ret; > > > > > > ret = devm_request_threaded_irq(chip->dev, client->irq, max_tcpci_isr, max_tcpci_irq, > > > - (IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev), > > > + (IRQF_TRIGGER_LOW | IRQF_ONESHOT), name, > > > chip); > > > > > > if (ret < 0) > > > @@ -485,6 +487,7 @@ static int max_tcpci_probe(struct i2c_client *client) > > > int ret; > > > struct max_tcpci_chip *chip; > > > u8 power_status; > > > + const char *name; > > > > > > chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); > > > if (!chip) > > > @@ -531,7 +534,11 @@ static int max_tcpci_probe(struct i2c_client *client) > > > > > > chip->port = tcpci_get_tcpm_port(chip->tcpci); > > > > > > - ret = max_tcpci_init_alert(chip, client); > > > + name = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%s", > > > + dev_name(&client->dev), client->name); > > > + if (!name) > > > + return -ENOMEM; > > > > Please always test your code before sending it out. You just leaked a > > bunch of stuff here :( > > Thanks for the review! > > I can not see what leak you're referring to. Could you please clarify? At a quick glance, tcpci_register_port() is called earlier in the function, but when you error out here you did not call tcpci_unregister_port(). What else needs to also be unwound? thanks, greg k-h
Thanks Greg, On Thu, 2025-02-13 at 12:56 +0100, Greg Kroah-Hartman wrote: > At a quick glance, tcpci_register_port() is called earlier in the > function, but when you error out here you did not call > tcpci_unregister_port(). What else needs to also be unwound? This driver manages everything using devres, including calling of tcpci_unregister_port() via devres: ret = devm_add_action_or_reset(&client->dev, max_tcpci_unregister_tcpci_port, chip->tcpci); is done just after tcpci_register_port(). As far as I can see nothing needs to be unwound explicitly. Cheers, Andre'
On Thu, Feb 13, 2025 at 01:10:49PM +0000, André Draszik wrote: > Thanks Greg, > > On Thu, 2025-02-13 at 12:56 +0100, Greg Kroah-Hartman wrote: > > At a quick glance, tcpci_register_port() is called earlier in the > > function, but when you error out here you did not call > > tcpci_unregister_port(). What else needs to also be unwound? > > This driver manages everything using devres, including calling of > tcpci_unregister_port() via devres: > > ret = devm_add_action_or_reset(&client->dev, > max_tcpci_unregister_tcpci_port, > chip->tcpci); > > is done just after tcpci_register_port(). As far as I can see nothing > needs to be unwound explicitly. Ugh, that wasn't obvious at all, sorry about that. Yet another reason to hate devm apis :) thanks, greg k-h
On 02/13/2025, André Draszik wrote: > This changes the output of /proc/interrupts from the non-descriptive: > 1-0025 > (or similar) to a more descriptive: > 1-0025-max33359 > > This makes it easier to find the device, in particular if there are > multiple i2c devices, as one doesn't have to remember (or lookup) where > it is located. > > Signed-off-by: André Draszik <andre.draszik@linaro.org> > --- > drivers/usb/typec/tcpm/tcpci_maxim_core.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > index fd1b80593367..46fc626589db 100644 > --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c > +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > @@ -420,12 +420,14 @@ static irqreturn_t max_tcpci_isr(int irq, void *dev_id) > return IRQ_WAKE_THREAD; > } > > -static int max_tcpci_init_alert(struct max_tcpci_chip *chip, struct i2c_client *client) > +static int max_tcpci_init_alert(struct max_tcpci_chip *chip, > + struct i2c_client *client, > + const char *name) > { > int ret; > > ret = devm_request_threaded_irq(chip->dev, client->irq, max_tcpci_isr, max_tcpci_irq, > - (IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev), > + (IRQF_TRIGGER_LOW | IRQF_ONESHOT), name, > chip); > > if (ret < 0) > @@ -485,6 +487,7 @@ static int max_tcpci_probe(struct i2c_client *client) > int ret; > struct max_tcpci_chip *chip; > u8 power_status; > + const char *name; > > chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); > if (!chip) > @@ -531,7 +534,11 @@ static int max_tcpci_probe(struct i2c_client *client) > > chip->port = tcpci_get_tcpm_port(chip->tcpci); > > - ret = max_tcpci_init_alert(chip, client); > + name = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%s", > + dev_name(&client->dev), client->name); > + if (!name) > + return -ENOMEM; > + ret = max_tcpci_init_alert(chip, client, name); > if (ret < 0) > return dev_err_probe(&client->dev, ret, > "IRQ initialization failed\n"); Can you just change the `init_name` instead like this? chip->client->dev.init_name = name; That way calling `dev_name()` will get you this more informative name as well? Thanks, Will
diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c index fd1b80593367..46fc626589db 100644 --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c @@ -420,12 +420,14 @@ static irqreturn_t max_tcpci_isr(int irq, void *dev_id) return IRQ_WAKE_THREAD; } -static int max_tcpci_init_alert(struct max_tcpci_chip *chip, struct i2c_client *client) +static int max_tcpci_init_alert(struct max_tcpci_chip *chip, + struct i2c_client *client, + const char *name) { int ret; ret = devm_request_threaded_irq(chip->dev, client->irq, max_tcpci_isr, max_tcpci_irq, - (IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev), + (IRQF_TRIGGER_LOW | IRQF_ONESHOT), name, chip); if (ret < 0) @@ -485,6 +487,7 @@ static int max_tcpci_probe(struct i2c_client *client) int ret; struct max_tcpci_chip *chip; u8 power_status; + const char *name; chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); if (!chip) @@ -531,7 +534,11 @@ static int max_tcpci_probe(struct i2c_client *client) chip->port = tcpci_get_tcpm_port(chip->tcpci); - ret = max_tcpci_init_alert(chip, client); + name = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%s", + dev_name(&client->dev), client->name); + if (!name) + return -ENOMEM; + ret = max_tcpci_init_alert(chip, client, name); if (ret < 0) return dev_err_probe(&client->dev, ret, "IRQ initialization failed\n");
This changes the output of /proc/interrupts from the non-descriptive: 1-0025 (or similar) to a more descriptive: 1-0025-max33359 This makes it easier to find the device, in particular if there are multiple i2c devices, as one doesn't have to remember (or lookup) where it is located. Signed-off-by: André Draszik <andre.draszik@linaro.org> --- drivers/usb/typec/tcpm/tcpci_maxim_core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- base-commit: 808eb958781e4ebb6e9c0962af2e856767e20f45 change-id: 20250213-max33359-irq-name-0665d6b69058 Best regards,