Re: [PATCH v5 09/10] gpio: Add a driver for Cadence I3C GPIO expander

From
Andy Shevchenko <hidden>
Date
2018-06-26 19:07:13
Also in
linux-devicetree, linux-doc, linux-gpio, lkml
Reply to
Boris Brezillon, 2018-06-22
On Fri, Jun 22, 2018 at 1:49 PM, Boris Brezillon
[off-list ref] wrote:
Add a driver for Cadence I3C GPIO expander.

Signed-off-by: Boris Brezillon <redacted>
+       scratchbuf = kmalloc(sizeof(*scratchbuf) * 2, GFP_KERNEL);
kmalloc_array() ?
+       ret = i3c_device_do_priv_xfers(gpioc->i3cdev, xfers,
+                                      ARRAY_SIZE(xfers));
One line?

quoted hunk ↗ jump to hunk
+static void cdns_i3c_gpio_set_multiple(struct gpio_chip *g,
+                                      unsigned long *mask,
+                                      unsigned long *bits)
+{
+       struct cdns_i3c_gpio *gpioc = gpioc_to_cdns_gpioc(g);
+       u8 newovr;
+       int ret;
+
+       newovr = (gpioc->ovr & ~(*mask)) | (*bits & *mask);
+       if (newovr == gpioc->ovr)
+               return;
+
+       ret = cdns_i3c_gpio_write_reg(gpioc, OVR, newovr);
+       if (!ret)
+               gpioc->ovr = newovr;
You don't change mask here, why do you need a pointer to it?
+}
quoted hunk ↗ jump to hunk
+static int cdns_i3c_gpio_get_multiple(struct gpio_chip *g,
+                                     unsigned long *mask,
+                                     unsigned long *bits)
+{
+       struct cdns_i3c_gpio *gpioc = gpioc_to_cdns_gpioc(g);
+       int ret;
+       u8 ivr;
+
+       ret = cdns_i3c_gpio_read_reg(gpioc, IVR, &ivr);
+       if (ret)
+               return ret;
+
+       *bits = ivr & *mask & gpioc->dir;
+       *bits |= gpioc->ovr & *mask & ~gpioc->dir;
Ditto.
quoted hunk ↗ jump to hunk
+
+       return 0;
+}
quoted hunk ↗ jump to hunk
+static void cdns_i3c_gpio_ibi_handler(struct i3c_device *i3cdev,
+                                     const struct i3c_ibi_payload *payload)
+{
+       struct cdns_i3c_gpio *gpioc = i3cdev_get_drvdata(i3cdev);
+       u8 isr = 0;
Perhaps you need to check the result of _read_reg() below instead of
dummy assignment?
quoted hunk ↗ jump to hunk
+       int i;
+
+       cdns_i3c_gpio_read_reg(gpioc, ISR, &isr);
quoted hunk ↗ jump to hunk
+       for (i = 0; i < 8; i++) {
+               unsigned int irq;
+
+               if (!(BIT(i) & isr & gpioc->imr))
+                       continue;
for_each_set_bit() ?
quoted hunk ↗ jump to hunk
+
+               irq = irq_find_mapping(gpioc->gpioc.irq.domain, i);
+               handle_nested_irq(irq);
+       }
+}
+static const struct i3c_device_id cdns_i3c_gpio_ids[] = {
+       I3C_DEVICE(0x1c9, 0x0, NULL),
+       { /* sentinel */ },
Slightly better without comma.
+};
+MODULE_DEVICE_TABLE(i3c, cdns_i3c_gpio_ids);
-- 
With Best Regards,
Andy Shevchenko
Thread (39 messages) 39 messages, 9 authors, last reply 2018-07-11
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help