On Mon, Sep 09, 2019 at 01:38:38PM +0000, Igor Russkikh wrote:
> From: Dmitry Bezrukov <dmitry.bezru...@aquantia.com>

Hi Igor, et al.

> @@ -331,6 +332,10 @@ int aq_nic_init(struct aq_nic_s *self)
>               self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i])
>               aq_vec_init(aq_vec, self->aq_hw_ops, self->aq_hw);

> +int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec)
> +{
> +     struct hw_atl_utils_mbox mbox;
> +     struct ptp_clock *clock;
> +     struct aq_ptp_s *self;

I find the use of self in this code quite confusing. It does not
appear to have a clear meaning. It can be a aq_ring_s, aq_nic_c,
aq_hw_s, aq_vec_s.

Looking at this code i always have to figure out what self is. Could
you not just use struct aq_ptp_s aq_ptp consistently in the code?

> +     int err = 0;
> +
> +     hw_atl_utils_mpi_read_stats(aq_nic->aq_hw, &mbox);
> +
> +     if (!(mbox.info.caps_ex & BIT(CAPS_EX_PHY_PTP_EN))) {
> +             aq_nic->aq_ptp = NULL;
> +             return 0;
> +     }
> +
> +     self = kzalloc(sizeof(*self), GFP_KERNEL);

Using devm_kzalloc() will make your clean up easier.

> +void aq_ptp_free(struct aq_nic_s *aq_nic)
> +{
> +     struct aq_ptp_s *self = aq_nic->aq_ptp;
> +
> +     if (!self)
> +             return;
> +
> +     kfree(self);

kfree() is happy to take a NULL pointer. But this could all go away
with devm_kzalloc().

     Andrew

Reply via email to